summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mate-panel/applet.c51
-rw-r--r--mate-panel/libpanel-util/panel-gtk.c72
-rw-r--r--mate-panel/libpanel-util/panel-gtk.h5
3 files changed, 95 insertions, 33 deletions
diff --git a/mate-panel/applet.c b/mate-panel/applet.c
index 92ec8762..7d6176ea 100644
--- a/mate-panel/applet.c
+++ b/mate-panel/applet.c
@@ -16,6 +16,7 @@
#include <gio/gio.h>
#include <libpanel-util/panel-show.h>
+#include <libpanel-util/panel-gtk.h>
#include "button-widget.h"
#include "drawer.h"
@@ -41,6 +42,8 @@ static GSList *registered_applets = NULL;
static GSList *queued_position_saves = NULL;
static guint queued_position_source = 0;
+static GtkCheckMenuItem *checkbox_id = NULL;
+
static void applet_menu_show (GtkWidget *w, AppletInfo *info);
static void applet_menu_deactivate (GtkWidget *w, AppletInfo *info);
@@ -98,14 +101,21 @@ mate_panel_applet_toggle_locked (AppletInfo *info)
}
static void
-mate_panel_applet_lock (GtkCheckMenuItem *menuitem,
- AppletInfo *info)
+checkbox_status (GtkCheckMenuItem *menuitem,
+ AppletInfo *info)
+{
+ checkbox_id = GTK_CHECK_MENU_ITEM (menuitem);
+}
+
+static void
+mate_panel_applet_lock (GtkMenuItem *menuitem,
+ AppletInfo *info)
{
gboolean locked;
locked = mate_panel_applet_toggle_locked (info);
- gtk_check_menu_item_set_active (menuitem, locked);
+ gtk_check_menu_item_set_active (checkbox_id, locked);
if (info->move_item)
gtk_widget_set_sensitive (info->move_item, !locked);
@@ -382,15 +392,8 @@ setup_an_item (AppletUserMenu *menu,
GtkWidget *submenu,
int is_submenu)
{
- GtkWidget *image = NULL;
-
- menu->menuitem = gtk_image_menu_item_new_with_mnemonic (menu->text);
- if (menu->gicon) {
- image = gtk_image_new_from_gicon (menu->gicon,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->menuitem),
- image);
- }
+ menu->menuitem = panel_image_menu_item_new_from_gicon (menu->gicon, menu->text);
+
gtk_widget_show (menu->menuitem);
g_signal_connect (G_OBJECT (menu->menuitem), "destroy",
@@ -503,6 +506,8 @@ mate_panel_applet_create_menu (AppletInfo *info)
menu = g_object_ref_sink (gtk_menu_new ());
+ gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE);
+
/* connect the show & deactivate signal, so that we can "disallow" and
* "re-allow" autohide when the menu is shown/deactivated.
*/
@@ -524,7 +529,6 @@ mate_panel_applet_create_menu (AppletInfo *info)
}
if (!panel_lockdown_get_locked_down ()) {
- GtkWidget *image;
gboolean locked;
gboolean lockable;
gboolean movable;
@@ -542,18 +546,16 @@ mate_panel_applet_create_menu (AppletInfo *info)
gtk_widget_show (menuitem);
}
- menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Panel"));
- image = gtk_image_new_from_icon_name ("list-remove",
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
- image);
+ menuitem = panel_image_menu_item_new_from_icon ("list-remove", _("_Remove From Panel"));
+
g_signal_connect (menuitem, "activate",
G_CALLBACK (applet_remove_callback), info);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_set_sensitive (menuitem, (!locked || lockable) && removable);
- menuitem = gtk_menu_item_new_with_mnemonic (_("_Move"));
+ menuitem = panel_image_menu_item_new_from_icon (NULL, _("_Move"));
+
g_signal_connect (menuitem, "activate",
G_CALLBACK (move_applet_callback), info);
gtk_widget_show (menuitem);
@@ -571,11 +573,20 @@ mate_panel_applet_create_menu (AppletInfo *info)
gtk_widget_show (menuitem);
menuitem = gtk_check_menu_item_new_with_mnemonic (_("Loc_k To Panel"));
+
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem),
locked);
- g_signal_connect (menuitem, "toggled",
+
+ g_signal_connect (menuitem, "map",
+ G_CALLBACK (checkbox_status), info);
+
+ menuitem = panel_check_menu_item_new (menuitem);
+
+ g_signal_connect (menuitem, "activate",
G_CALLBACK (mate_panel_applet_lock), info);
+
gtk_widget_show (menuitem);
+
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_set_sensitive (menuitem, lockable);
diff --git a/mate-panel/libpanel-util/panel-gtk.c b/mate-panel/libpanel-util/panel-gtk.c
index ce6705c4..4ac3e9bc 100644
--- a/mate-panel/libpanel-util/panel-gtk.c
+++ b/mate-panel/libpanel-util/panel-gtk.c
@@ -164,22 +164,68 @@ GtkWidget *
panel_image_menu_item_new_from_icon (const gchar *icon_name,
const gchar *label_name)
{
- GtkWidget *icon;
- GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ GtkWidget *icon;
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- if (icon_name)
- icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- else
- icon = gtk_image_new ();
+ if (icon_name)
+ icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ else
+ icon = gtk_image_new ();
- GtkWidget *label_menu = gtk_label_new_with_mnemonic (g_strconcat (label_name, " ", NULL));
- GtkWidget *menuitem = gtk_menu_item_new ();
+ GtkWidget *label_menu = gtk_label_new_with_mnemonic (g_strconcat (label_name, " ", NULL));
+ GtkWidget *menuitem = gtk_menu_item_new ();
- gtk_container_add (GTK_CONTAINER (box), icon);
- gtk_container_add (GTK_CONTAINER (box), label_menu);
+ gtk_container_add (GTK_CONTAINER (box), icon);
+ gtk_container_add (GTK_CONTAINER (box), label_menu);
- gtk_container_add (GTK_CONTAINER (menuitem), box);
- gtk_widget_show_all (menuitem);
+ gtk_container_add (GTK_CONTAINER (menuitem), box);
+ gtk_widget_show_all (menuitem);
- return menuitem;
+ return menuitem;
+}
+
+GtkWidget *
+panel_image_menu_item_new_from_gicon (GIcon *gicon,
+ const gchar *label_name)
+{
+ GtkWidget *icon;
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+ if (gicon)
+ icon = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_MENU);
+ else
+ icon = gtk_image_new ();
+
+ GtkWidget *label_menu = gtk_label_new_with_mnemonic (g_strconcat (label_name, " ", NULL));
+ GtkWidget *menuitem = gtk_menu_item_new ();
+
+ gtk_container_add (GTK_CONTAINER (box), icon);
+ gtk_container_add (GTK_CONTAINER (box), label_menu);
+
+ gtk_container_add (GTK_CONTAINER (menuitem), box);
+ gtk_widget_show_all (menuitem);
+
+ return menuitem;
+}
+
+GtkWidget *
+panel_check_menu_item_new (GtkWidget *widget_check)
+{
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ GtkWidget *menuitem = gtk_menu_item_new ();
+ GtkWidget *label_name = gtk_bin_get_child (GTK_BIN (widget_check));
+
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (label_name),
+ g_strconcat (gtk_label_get_label (GTK_LABEL (label_name)), " ", NULL));
+
+ gtk_widget_set_margin_start (widget_check, 2);
+ gtk_widget_set_margin_start (gtk_bin_get_child (GTK_BIN (widget_check)), 11);
+ gtk_box_pack_start (GTK_BOX (box), widget_check, FALSE, FALSE, 5);
+
+ gtk_container_add (GTK_CONTAINER (menuitem), box);
+ gtk_widget_show_all (menuitem);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label_name), menuitem);
+
+ return menuitem;
}
diff --git a/mate-panel/libpanel-util/panel-gtk.h b/mate-panel/libpanel-util/panel-gtk.h
index 80188aed..3703e5a4 100644
--- a/mate-panel/libpanel-util/panel-gtk.h
+++ b/mate-panel/libpanel-util/panel-gtk.h
@@ -49,6 +49,11 @@ GtkWidget* panel_file_chooser_dialog_new (const gchar *title,
GtkWidget* panel_image_menu_item_new_from_icon (const gchar *icon_name,
const gchar *label_name);
+GtkWidget* panel_image_menu_item_new_from_gicon (GIcon *gicon,
+ const gchar *label_name);
+
+GtkWidget* panel_check_menu_item_new (GtkWidget *widget_check);
+
#ifdef __cplusplus
}
#endif