summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/org.mate.panel.menubar.gschema.xml.in5
-rw-r--r--mate-panel/panel-menu-items.c23
-rw-r--r--mate-panel/panel-schemas.h1
3 files changed, 23 insertions, 6 deletions
diff --git a/data/org.mate.panel.menubar.gschema.xml.in b/data/org.mate.panel.menubar.gschema.xml.in
index 71cd4e97..343880e9 100644
--- a/data/org.mate.panel.menubar.gschema.xml.in
+++ b/data/org.mate.panel.menubar.gschema.xml.in
@@ -45,5 +45,10 @@
<summary>Menu items icon size</summary>
<description>Set the size of icons used in the menu. The panel must be restarted for this to take effect.</description>
</key>
+ <key name="max-items-or-submenu" type="i">
+ <default>8</default>
+ <summary>Threshold of menu items before submenu is created</summary>
+ <description>Maximum number of menu items (i.e. bookmarks) that are displayed without being put in a submenu.</description>
+ </key>
</schema>
</schemalist>
diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c
index 6d9be2e1..8955a018 100644
--- a/mate-panel/panel-menu-items.c
+++ b/mate-panel/panel-menu-items.c
@@ -75,6 +75,7 @@ struct _PanelPlaceMenuItemPrivate {
GSettings *caja_desktop_settings;
GSettings *caja_prefs_settings;
+ GSettings *menubar_settings;
GtkRecentManager *recent_manager;
@@ -351,7 +352,7 @@ panel_menu_items_create_action_item (PanelActionButtonType action_type)
}
static void
-panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu)
+panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu, int max_items_or_submenu)
{
typedef struct {
char *full_uri;
@@ -378,7 +379,7 @@ panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu)
/* We use a hard limit to avoid having users shooting their
* own feet, and to avoid crashing the system if a misbehaving
- * application creates a big bookmars file.
+ * application creates a big bookmarks file.
*/
for (i = 0; i < MAX_BOOKMARK_ITEMS; i++) {
char *contents;
@@ -462,7 +463,7 @@ panel_place_menu_item_append_gtk_bookmarks (GtkWidget *menu)
add_bookmarks = g_slist_reverse (add_bookmarks);
- if (g_slist_length (add_bookmarks) <= MAX_ITEMS_OR_SUBMENU) {
+ if (g_slist_length (add_bookmarks) <= max_items_or_submenu) {
add_menu = menu;
} else {
GtkWidget *item;
@@ -906,7 +907,7 @@ panel_place_menu_item_append_local_gio (PanelPlaceMenuItem *place_item,
/* now that we have everything, add the items inline or in a submenu */
items = g_slist_reverse (items);
- if (g_slist_length (items) <= MAX_ITEMS_OR_SUBMENU) {
+ if (g_slist_length (items) <= g_settings_get_int (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU)) {
add_menu = menu;
} else {
GtkWidget *item;
@@ -993,7 +994,7 @@ panel_place_menu_item_append_remote_gio (PanelPlaceMenuItem *place_item,
}
add_mounts = g_slist_reverse (add_mounts);
- if (g_slist_length (add_mounts) <= MAX_ITEMS_OR_SUBMENU) {
+ if (g_slist_length (add_mounts) <= g_settings_get_int (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU)) {
add_menu = menu;
} else {
GtkWidget *item;
@@ -1069,7 +1070,7 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item)
g_free (uri);
}
- panel_place_menu_item_append_gtk_bookmarks (places_menu);
+ panel_place_menu_item_append_gtk_bookmarks (places_menu, g_settings_get_int (place_item->priv->menubar_settings, PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU));
add_menu_separator (places_menu);
if (place_item->priv->caja_desktop_settings != NULL)
@@ -1377,6 +1378,16 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem)
else
menuitem->priv->caja_prefs_settings = NULL;
+ if (mate_gsettings_schema_exists (PANEL_MENU_BAR_SCHEMA)) {
+ menuitem->priv->menubar_settings = g_settings_new (PANEL_MENU_BAR_SCHEMA);
+ g_signal_connect (menuitem->priv->menubar_settings,
+ "changed::" PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU,
+ G_CALLBACK (panel_place_menu_item_key_changed),
+ G_OBJECT (menuitem));
+ }
+ else
+ menuitem->priv->menubar_settings = NULL;
+
menuitem->priv->recent_manager = gtk_recent_manager_get_default ();
bookmarks_filename = g_build_filename (g_get_home_dir (),
diff --git a/mate-panel/panel-schemas.h b/mate-panel/panel-schemas.h
index 53247f99..abcb7cbb 100644
--- a/mate-panel/panel-schemas.h
+++ b/mate-panel/panel-schemas.h
@@ -65,6 +65,7 @@
#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"
+#define PANEL_MENU_BAR_MAX_ITEMS_OR_SUBMENU "max-items-or-submenu"
/* external schemas */