From e3dd4555543b5476ee2b9197bd19f49476aca5d4 Mon Sep 17 00:00:00 2001 From: Felipe Erias Morandeira Date: Thu, 13 Jun 2013 16:54:34 +0100 Subject: Small changes to EosActionMenu. A more complete example of how to use it in an application, including changes to CSS. [endlessm/eos-sdk#79] --- endless/eosactionmenu.c | 17 +++++++++++++---- test/smoke-tests/action-buttons.js | 27 +++++++++++++++++++++------ test/smoke-tests/eosactionbutton.css | 16 ++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/endless/eosactionmenu.c b/endless/eosactionmenu.c index 5f44958..6e8fc0a 100644 --- a/endless/eosactionmenu.c +++ b/endless/eosactionmenu.c @@ -47,15 +47,24 @@ eos_action_menu_class_init (EosActionMenuClass *klass) } static void -eos_action_menu_init (EosActionMenu *menu) +eos_action_menu_init (EosActionMenu *self) { EosActionMenuPrivate *priv; + GtkStyleContext *context; - menu->priv = EOS_ACTION_MENU_PRIVATE (menu); - priv = menu->priv; + self->priv = EOS_ACTION_MENU_PRIVATE (self); + priv = self->priv; + + context = gtk_widget_get_style_context (GTK_WIDGET (self)); + gtk_style_context_add_class (context, _EOS_STYLE_CLASS_ACTION_MENU); // TODO : name? priv->action_group = gtk_action_group_new ("EosActionMenu"); + + gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); + gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); + gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER); + gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER); } /* ******* LIFECYCLE ******* */ @@ -99,7 +108,7 @@ eos_action_menu_add_action (EosActionMenu *menu, { EosActionMenuPrivate *priv; - g_return_val_if_fail (EOS_IS_ACTION_MENU (menu), NULL); + g_return_if_fail (EOS_IS_ACTION_MENU (menu)); priv = menu->priv; if (action) diff --git a/test/smoke-tests/action-buttons.js b/test/smoke-tests/action-buttons.js index 85499f9..7fe046b 100644 --- a/test/smoke-tests/action-buttons.js +++ b/test/smoke-tests/action-buttons.js @@ -13,9 +13,24 @@ const TestApplication = new Lang.Class ({ vfunc_startup: function() { this.parent(); - this._page = new Endless.ActionMenu(); + this._page = new Gtk.Grid (); - this._page.add_action ({ + this._content = new Gtk.Label ({name: 'content', label: 'Content'}); + + this._menu = new Endless.ActionMenu (); + + // put the ActionMenu in a panel, as GtkGrid doesn't expand if none of its children want to + this._menu_panel = new Gtk.Frame ({name: 'menu'}); + this._menu_panel.add (this._menu); + this._menu_panel.set_hexpand (true); + this._menu_panel.set_vexpand (true); + + // the ActionMenu takes 1/6 of the width + this._page.set_column_homogeneous (true); + this._page.attach (this._content, 0, 0, 5, 1); + this._page.attach (this._menu_panel, 5, 0, 1, 1); + + this._menu.add_action ({ name: 'select', 'icon-name': 'object-select-symbolic', label: 'select stuff', @@ -28,19 +43,19 @@ const TestApplication = new Lang.Class ({ md.destroy(); })); - this._page.add_action ({ + this._menu.add_action ({ name: 'delete', 'icon-name': 'edit-delete-symbolic', label: 'delete stuff', 'is-important': false }); - this._page.add_action ({ + this._menu.add_action ({ name: 'smile', 'icon-name': 'face-smile-symbolic', label: 'smile', 'is-important': false }); - this._page.add_action ({ + this._menu.add_action ({ name: 'sadface', 'icon-name': 'face-sad-symbolic', label: 'sadface', @@ -54,7 +69,7 @@ const TestApplication = new Lang.Class ({ this._window = new Endless.Window({ application: this, - border_width: 16, + border_width: 1, page_manager: this._pm }); diff --git a/test/smoke-tests/eosactionbutton.css b/test/smoke-tests/eosactionbutton.css index 6fd657b..e4a8267 100644 --- a/test/smoke-tests/eosactionbutton.css +++ b/test/smoke-tests/eosactionbutton.css @@ -1,3 +1,5 @@ +/* ****** ACTION BUTTONS ****** */ + EosActionButton { background-color: transparent; border-color: #012345; @@ -54,3 +56,17 @@ EosActionButton:focused { EosActionButton:inconsistent { border-color: #6789AB; } + +/* ****** ACTION MENU ****** */ + +GtkFrame#menu { + background-color: #D3D7CF; + border-color: #E1E2DE; + border-width: 0 0 0 6px; +} + +GtkLabel#content { + color: #BABDB6; + font-size: 48pt; + background: #EEEEEC; +} -- cgit v1.2.3