[gnome-panel] panel: Fix panels forced to be big because of user menu
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel: Fix panels forced to be big because of user menu
- Date: Mon, 17 Oct 2011 11:44:19 +0000 (UTC)
commit cff8f9f22a031ca1ccab06a1460f8984d97f871f
Author: Vincent Untz <vuntz gnome org>
Date: Mon Oct 17 13:07:15 2011 +0200
panel: Fix panels forced to be big because of user menu
The user menu item was created with some functions that change the way
the size of the menu item is negotiated, and we don't want this when
this user menu item is in the user menu applet (we want this when it's
in the main menu, though).
Helps with https://bugzilla.gnome.org/show_bug.cgi?id=661790
gnome-panel/menu.c | 2 +-
gnome-panel/panel-menu-items.c | 48 ++++++++++++++++++++++++++-------------
gnome-panel/panel-menu-items.h | 1 +
gnome-panel/panel-user-menu.c | 2 +-
4 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/gnome-panel/menu.c b/gnome-panel/menu.c
index 4077940..497b7fd 100644
--- a/gnome-panel/menu.c
+++ b/gnome-panel/menu.c
@@ -1388,7 +1388,7 @@ main_menu_append (GtkWidget *main_menu,
gtk_menu_shell_append (GTK_MENU_SHELL (main_menu), item);
gtk_widget_show (item);
- item = panel_desktop_menu_item_new (TRUE, FALSE);
+ item = panel_desktop_menu_item_new (TRUE, FALSE, FALSE);
panel_desktop_menu_item_set_panel (item, panel);
gtk_menu_shell_append (GTK_MENU_SHELL (main_menu), item);
gtk_widget_show (item);
diff --git a/gnome-panel/panel-menu-items.c b/gnome-panel/panel-menu-items.c
index 0e48181..a58801d 100644
--- a/gnome-panel/panel-menu-items.c
+++ b/gnome-panel/panel-menu-items.c
@@ -48,6 +48,7 @@
#include <libpanel-util/panel-glib.h>
#include <libpanel-util/panel-keyfile.h>
#include <libpanel-util/panel-launch.h>
+#include <libpanel-util/panel-menu-item.h>
#include <libpanel-util/panel-session-manager.h>
#include <libpanel-util/panel-show.h>
@@ -1693,10 +1694,12 @@ panel_desktop_menu_item_on_presence_changed (PanelSessionManager *ma
GtkWidget *
panel_desktop_menu_item_new (gboolean use_image,
+ gboolean in_menubar,
gboolean append_lock_logout)
{
PanelDesktopMenuItem *menuitem;
char *name;
+ const char *icon_name;
#ifdef HAVE_TELEPATHY_GLIB
PanelSessionManager *manager;
#endif
@@ -1704,27 +1707,40 @@ panel_desktop_menu_item_new (gboolean use_image,
menuitem = g_object_new (PANEL_TYPE_DESKTOP_MENU_ITEM, NULL);
name = panel_util_get_user_name ();
+#ifdef HAVE_TELEPATHY_GLIB
+ icon_name = PANEL_ICON_USER_AVAILABLE;
+#else
+ icon_name = PANEL_ICON_COMPUTER;
+#endif
+
+ /* if we're in a menubar, we don't want to use setup_* as it changes
+ * the size requests and can make the panels bigger than we'd like */
+ if (in_menubar) {
+ gtk_menu_item_set_label (GTK_MENU_ITEM (menuitem), name);
+ if (use_image) {
+ GtkWidget *image;
+ image = gtk_image_new_from_icon_name (icon_name,
+ panel_menu_icon_get_size ());
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
+ image);
+ }
+ } else {
+ if (use_image)
+ setup_menu_item_with_icon (GTK_WIDGET (menuitem),
+ panel_menu_icon_get_size (),
+ icon_name, NULL, NULL,
+ name);
+ else
+ setup_menuitem (GTK_WIDGET (menuitem),
+ GTK_ICON_SIZE_INVALID, NULL,
+ name);
+ }
- if (use_image) {
#ifdef HAVE_TELEPATHY_GLIB
- setup_menu_item_with_icon (GTK_WIDGET (menuitem),
- panel_menu_icon_get_size (),
- PANEL_ICON_USER_AVAILABLE,
- NULL, NULL,
- name);
+ if (use_image)
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem),
TRUE);
-#else
- setup_menu_item_with_icon (GTK_WIDGET (menuitem),
- panel_menu_icon_get_size (),
- PANEL_ICON_COMPUTER,
- NULL, NULL,
- name);
#endif
- } else
- setup_menuitem (GTK_WIDGET (menuitem),
- GTK_ICON_SIZE_INVALID, NULL,
- name);
g_free (name);
diff --git a/gnome-panel/panel-menu-items.h b/gnome-panel/panel-menu-items.h
index 44c000c..86d766b 100644
--- a/gnome-panel/panel-menu-items.h
+++ b/gnome-panel/panel-menu-items.h
@@ -80,6 +80,7 @@ GType panel_desktop_menu_item_get_type (void) G_GNUC_CONST;
GtkWidget *panel_place_menu_item_new (gboolean use_image);
GtkWidget *panel_desktop_menu_item_new (gboolean use_image,
+ gboolean in_menubar,
gboolean append_lock_logout);
void panel_place_menu_item_set_panel (GtkWidget *item,
diff --git a/gnome-panel/panel-user-menu.c b/gnome-panel/panel-user-menu.c
index 2ff36f4..fa68dba 100644
--- a/gnome-panel/panel-user-menu.c
+++ b/gnome-panel/panel-user-menu.c
@@ -51,7 +51,7 @@ panel_user_menu_init (PanelUserMenu *usermenu)
usermenu->priv->info = NULL;
- usermenu->priv->desktop_item = panel_desktop_menu_item_new (TRUE, TRUE);
+ usermenu->priv->desktop_item = panel_desktop_menu_item_new (TRUE, TRUE, TRUE);
gtk_menu_shell_append (GTK_MENU_SHELL (usermenu),
usermenu->priv->desktop_item);
gtk_widget_show (usermenu->priv->desktop_item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]