diff options
-rw-r--r-- | data/Makefile.am | 3 | ||||
-rw-r--r-- | data/org.mate.panel.menubar.gschema.xml.in.in | 29 | ||||
-rw-r--r-- | mate-panel/panel-menu-bar.c | 47 | ||||
-rw-r--r-- | mate-panel/panel-schemas.h | 7 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
5 files changed, 83 insertions, 4 deletions
diff --git a/data/Makefile.am b/data/Makefile.am index 516294cc..7b7d3721 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -9,7 +9,8 @@ gsettings_ENUM_FILES = $(top_srcdir)/mate-panel/panel-enums-gsettings.h panel_gschemas_in_in = \ org.mate.panel.gschema.xml.in.in \ org.mate.panel.object.gschema.xml.in.in \ - org.mate.panel.toplevel.gschema.xml.in.in + org.mate.panel.toplevel.gschema.xml.in.in \ + org.mate.panel.menubar.gschema.xml.in.in panel_gschemas_in = $(panel_gschemas_in_in:.xml.in.in=.xml.in) gsettings_SCHEMAS = $(panel_gschemas_in:.xml.in=.xml) diff --git a/data/org.mate.panel.menubar.gschema.xml.in.in b/data/org.mate.panel.menubar.gschema.xml.in.in new file mode 100644 index 00000000..9c7ed19f --- /dev/null +++ b/data/org.mate.panel.menubar.gschema.xml.in.in @@ -0,0 +1,29 @@ +<schemalist gettext-domain="@GETTEXT_PACKAGE@"> + <schema id="org.mate.panel.menubar" path="/org/mate/panel/menubar/"> + <key name="show-applications" type="b"> + <default>true</default> + <_summary>Show applications menu</_summary> + <_description>If true, show applications item in menu bar.</_description> + </key> + <key name="show-places" type="b"> + <default>true</default> + <_summary>Show places menu</_summary> + <_description>If true, show places item in menu bar.</_description> + </key> + <key name="show-desktop" type="b"> + <default>true</default> + <_summary>Show desktop menu</_summary> + <_description>If true, show desktop item in menu bar.</_description> + </key> + <key name="show-icon" type="b"> + <default>true</default> + <_summary>Show icon</_summary> + <_description>If true, show icon in menu bar.</_description> + </key> + <key name="icon-name" type="s"> + <default>'start-here'</default> + <_summary>Icon to show in menu bar</_summary> + <_description>Set the theme icon name to use in menu bar.</_description> + </key> + </schema> +</schemalist> diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c index 005e6be0..358eac95 100644 --- a/mate-panel/panel-menu-bar.c +++ b/mate-panel/panel-menu-bar.c @@ -47,6 +47,7 @@ #include "panel-stock-icons.h" #include "panel-typebuiltins.h" #include "panel-icon-names.h" +#include "panel-schemas.h" G_DEFINE_TYPE (PanelMenuBar, panel_menu_bar, GTK_TYPE_MENU_BAR) @@ -61,6 +62,8 @@ struct _PanelMenuBarPrivate { GtkWidget* places_item; GtkWidget* desktop_item; + GSettings* settings; + PanelOrientation orientation; }; @@ -107,12 +110,34 @@ static void panel_menu_bar_setup_tooltip(PanelMenuBar* menubar) g_signal_connect(GTK_MENU_SHELL (menubar), "deactivate", G_CALLBACK (panel_menu_bar_reinit_tooltip), menubar); } +static void panel_menu_bar_update_visibility (GSettings* settings, gchar* key, PanelMenuBar* menubar) +{ + GtkWidget* image; + gchar *str; + + gtk_widget_set_visible (GTK_WIDGET (menubar->priv->applications_item), g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_APPLICATIONS_KEY)); + gtk_widget_set_visible (GTK_WIDGET (menubar->priv->places_item), g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_PLACES_KEY)); + gtk_widget_set_visible (GTK_WIDGET (menubar->priv->desktop_item), g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_DESKTOP_KEY)); + + if (g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_ICON_KEY)) + { + str = g_settings_get_string (settings, PANEL_MENU_BAR_ICON_NAME_KEY); + if (str != NULL && str[0] != 0) + image = gtk_image_new_from_icon_name(str, panel_menu_bar_icon_get_size()); + else + image = gtk_image_new_from_icon_name(PANEL_ICON_MAIN_MENU, panel_menu_bar_icon_get_size()); + g_free (str); + } + else + image = NULL; + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menubar->priv->applications_item), image); +} + static void panel_menu_bar_init(PanelMenuBar* menubar) { #if GTK_CHECK_VERSION (3, 0, 0) GtkCssProvider *provider; #endif - GtkWidget* image; menubar->priv = PANEL_MENU_BAR_GET_PRIVATE(menubar); @@ -131,13 +156,12 @@ static void panel_menu_bar_init(PanelMenuBar* menubar) menubar->priv->info = NULL; + menubar->priv->settings = g_settings_new (PANEL_MENU_BAR_SCHEMA); menubar->priv->applications_menu = create_applications_menu("mate-applications.menu", NULL, TRUE); menubar->priv->applications_item = panel_image_menu_item_new(); gtk_menu_item_set_label(GTK_MENU_ITEM(menubar->priv->applications_item), _("Applications")); - image = gtk_image_new_from_icon_name(PANEL_ICON_MAIN_MENU, panel_menu_bar_icon_get_size()); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menubar->priv->applications_item), image); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar->priv->applications_item), menubar->priv->applications_menu); gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menubar->priv->applications_item); @@ -150,6 +174,9 @@ static void panel_menu_bar_init(PanelMenuBar* menubar) panel_menu_bar_setup_tooltip(menubar); + panel_menu_bar_update_visibility(menubar->priv->settings, NULL, menubar); + g_signal_connect(menubar->priv->settings, "changed", G_CALLBACK (panel_menu_bar_update_visibility), menubar); + panel_menu_bar_update_text_gravity(menubar); g_signal_connect(menubar, "screen-changed", G_CALLBACK(panel_menu_bar_update_text_gravity), NULL); } @@ -249,6 +276,19 @@ static void panel_menu_bar_size_allocate(GtkWidget* widget, GtkAllocation* alloc panel_menu_bar_change_background(PANEL_MENU_BAR(widget)); } +static void panel_menu_bar_finalize (GObject* object) +{ + PanelMenuBar* menubar; + + menubar = PANEL_MENU_BAR (object); + + if (menubar->priv->settings != NULL) + { + g_object_unref (menubar->priv->settings); + menubar->priv->settings = NULL; + } +} + static void panel_menu_bar_class_init(PanelMenuBarClass* klass) { GObjectClass* gobject_class = (GObjectClass*) klass; @@ -256,6 +296,7 @@ static void panel_menu_bar_class_init(PanelMenuBarClass* klass) gobject_class->get_property = panel_menu_bar_get_property; gobject_class->set_property = panel_menu_bar_set_property; + gobject_class->finalize = panel_menu_bar_finalize; widget_class->parent_set = panel_menu_bar_parent_set; widget_class->size_allocate = panel_menu_bar_size_allocate; diff --git a/mate-panel/panel-schemas.h b/mate-panel/panel-schemas.h index b57a4063..c21a8464 100644 --- a/mate-panel/panel-schemas.h +++ b/mate-panel/panel-schemas.h @@ -59,6 +59,13 @@ #define PANEL_OBJECT_LAUNCHER_LOCATION_KEY "launcher-location" #define PANEL_OBJECT_ACTION_TYPE_KEY "action-type" +#define PANEL_MENU_BAR_SCHEMA "org.mate.panel.menubar" +#define PANEL_MENU_BAR_SHOW_APPLICATIONS_KEY "show-applications" +#define PANEL_MENU_BAR_SHOW_PLACES_KEY "show-places" +#define PANEL_MENU_BAR_SHOW_DESKTOP_KEY "show-desktop" +#define PANEL_MENU_BAR_SHOW_ICON_KEY "show-icon" +#define PANEL_MENU_BAR_ICON_NAME_KEY "icon-name" + /* external schemas */ #define CAJA_DESKTOP_SCHEMA "org.mate.caja.desktop" diff --git a/po/POTFILES.in b/po/POTFILES.in index aa1bd2f6..0c84bf7a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -27,6 +27,7 @@ applets/wncklet/wncklet.c applets/wncklet/workspace-switcher.c [type: gettext/glade]applets/wncklet/workspace-switcher.ui data/org.mate.panel.gschema.xml.in.in +data/org.mate.panel.menubar.gschema.xml.in.in data/org.mate.panel.object.gschema.xml.in.in data/org.mate.panel.toplevel.gschema.xml.in.in mate-panel/libegg/eggdesktopfile.c |