From 4ec15094555e5bc71a46f16ea9bf101e41e59631 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Feb 2010 17:04:25 -0600 Subject: First pass, get the string. --- src/session-service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/session-service.c b/src/session-service.c index e89a9a0..3cbb29c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -481,7 +481,9 @@ rebuild_items (DbusmenuMenuitem *root, ensure_gconf_client (); switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User...")); + gchar * switchlabel = g_strdup_printf(_("Switch from %s..."), g_get_user_name()); + dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, switchlabel); + g_free(switchlabel); dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); -- cgit v1.2.3 From b1d66f9d77fa960d7e59353e1e33250060493ec6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 13:16:32 -0600 Subject: Refactoring so the menu is created in init. --- src/indicator-session.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index dda8c76..2017fff 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -51,6 +51,8 @@ struct _IndicatorSessionClass { struct _IndicatorSession { IndicatorObject parent; IndicatorServiceManager * service; + GtkImage * status_image; + GtkMenu * menu; }; GType indicator_session_get_type (void); @@ -96,6 +98,9 @@ indicator_session_init (IndicatorSession *self) /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); + self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); + self->menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + return; } @@ -130,9 +135,8 @@ get_label (IndicatorObject * io) static GtkImage * get_icon (IndicatorObject * io) { - GtkImage * status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); - gtk_widget_show(GTK_WIDGET(status_image)); - return status_image; + gtk_widget_show(GTK_WIDGET(INDICATOR_SESSION(io)->status_image)); + return INDICATOR_SESSION(io)->status_image; } /* Indicator based function to get the menu for the whole @@ -141,7 +145,7 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + return INDICATOR_SESSION(io)->menu; } -- cgit v1.2.3 From 70d29699c60a2507e457357a72eb484644f67dfd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 13:18:17 -0600 Subject: Woot, a dbusmenu, much better. --- src/indicator-session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 2017fff..840965e 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -52,7 +52,7 @@ struct _IndicatorSession { IndicatorObject parent; IndicatorServiceManager * service; GtkImage * status_image; - GtkMenu * menu; + DbusmenuGtkMenu * menu; }; GType indicator_session_get_type (void); @@ -99,7 +99,7 @@ indicator_session_init (IndicatorSession *self) self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); - self->menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); return; } @@ -145,7 +145,7 @@ get_icon (IndicatorObject * io) static GtkMenu * get_menu (IndicatorObject * io) { - return INDICATOR_SESSION(io)->menu; + return GTK_MENU(INDICATOR_SESSION(io)->menu); } -- cgit v1.2.3 From 51ac202d7332f31df4912290bb180e2b4a7d413d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 13:26:17 -0600 Subject: Building shared names for dbusmenu objects. --- src/Makefile.am | 2 ++ src/dbusmenu-shared.h | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 src/dbusmenu-shared.h diff --git a/src/Makefile.am b/src/Makefile.am index 2c607f5..fdbf466 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ sessionlib_LTLIBRARIES = libsession.la libsession_la_SOURCES = \ indicator-session.c \ dbus-shared-names.h \ + dbusmenu-shared.h \ users-service-client.h libsession_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror libsession_la_LIBADD = $(APPLET_LIBS) @@ -42,6 +43,7 @@ indicator_session_service_SOURCES = \ lock-helper.c \ lock-helper.h \ session-service.c \ + dbusmenu-shared.h \ gtk-dialog/gconf-helper.c \ users-service-dbus.h \ users-service-dbus.c \ diff --git a/src/dbusmenu-shared.h b/src/dbusmenu-shared.h new file mode 100644 index 0000000..1ef179b --- /dev/null +++ b/src/dbusmenu-shared.h @@ -0,0 +1,4 @@ + +#define MENU_SWITCH_TYPE "x-canonical-switch-from" +#define MENU_SWITCH_USER "x-canonical-switch-username" + -- cgit v1.2.3 From 3ccc99e803d8a43bd932275b2e172cdcce213ad9 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Thu, 11 Feb 2010 14:43:29 -0500 Subject: included autogen.sh in EXTRA_DIST to make packagers happy --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 0233fbf..3d97874 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = \ data \ po -EXTRA_DIST = COPYING.LGPL +EXTRA_DIST = COPYING.LGPL autogen.sh DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall -- cgit v1.2.3 From a36272659c9dbcff0c083a2083417ac65d876c3b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 14:53:20 -0600 Subject: Setting up the type handler --- src/indicator-session.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/indicator-session.c b/src/indicator-session.c index 840965e..a1f83d1 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -33,6 +33,7 @@ with this program. If not, see . #include #include "dbus-shared-names.h" +#include "dbusmenu-shared.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) #define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession)) @@ -65,6 +66,7 @@ INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE) static GtkLabel * get_label (IndicatorObject * io); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); +static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -101,6 +103,9 @@ indicator_session_init (IndicatorSession *self) self->status_image = GTK_IMAGE(gtk_image_new_from_icon_name("system-shutdown-panel", GTK_ICON_SIZE_MENU)); self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); + DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); + dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); + return; } @@ -148,4 +153,13 @@ get_menu (IndicatorObject * io) return GTK_MENU(INDICATOR_SESSION(io)->menu); } +/* This function checks to see if the user name is short enough + to not need ellipsing itself, or if, it will get ellipsed by + the standard label processor. */ +static gboolean +build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + + return FALSE; +} -- cgit v1.2.3 From 2398976ff0152f8cdbd1c2ec84663b33598abd7d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 16:08:36 -0600 Subject: Fleshing out the menu_switch function with a function that looks at the length of the label and sees if we need to ellipsize it or not. --- src/indicator-session.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/src/indicator-session.c b/src/indicator-session.c index a1f83d1..7e9bb45 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -22,6 +22,7 @@ with this program. If not, see . #include #include +#include #include #include @@ -153,13 +154,81 @@ get_menu (IndicatorObject * io) return GTK_MENU(INDICATOR_SESSION(io)->menu); } +static void +switch_property_change (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data) +{ + if (g_strcmp0(property, MENU_SWITCH_USER) != 0) { + return; + } + + gchar * finalstring = NULL; + gboolean set_ellipsize = FALSE; + + /* If there's a NULL string of some type, then we want to + go back to our old 'Switch User' which isn't great but + eh, this error condition should never happen. */ + if (value == NULL || g_value_get_string(value) == NULL || g_value_get_string(value)[0] == '\0') { + finalstring = _("Switch User..."); + set_ellipsize = FALSE; + } + + if (finalstring == NULL) { + const gchar * username = g_value_get_string(value); + GtkWidget * off = gtk_offscreen_window_new(); + GtkWidget * label = gtk_label_new(username); + gtk_container_add(GTK_CONTAINER(off), label); + GdkPixmap * pixmap = gtk_offscreen_window_get_pixmap(GTK_OFFSCREEN_WINDOW(off)); + + gint width, height; + gdk_drawable_get_size(GDK_DRAWABLE(pixmap), &width, &height); + + GtkStyle * style = gtk_widget_get_style(label); /* TODO: Switch to menuitem label */ + gint point = pango_font_description_get_size(style->font_desc); + + gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); + + gdouble pixels_per_em = point * dpi / 72.0f; + gdouble ems = width / pixels_per_em; + + /* TODO: We need some way to remove the elipsis from appearing + twice in the label. Not sure how to do that yet. */ + finalstring = g_strdup_printf(_("Switch from %s..."), username); + if (ems >= 20.0f) { + set_ellipsize = TRUE; + } else { + set_ellipsize = FALSE; + } + } + + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); + gtk_menu_item_set_label(gmi, finalstring); + + GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); + if (label != NULL) { + if (set_ellipsize) { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); + } else { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); + } + } + + return; +} + + /* This function checks to see if the user name is short enough to not need ellipsing itself, or if, it will get ellipsed by the standard label processor. */ static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + /* TODO: Setup style update */ + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(switch_property_change), client); + switch_property_change(newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_value(newitem, MENU_SWITCH_USER), client); return FALSE; } -- cgit v1.2.3 From ccaa76fac008a5de7b8eacf3f70dfe96dd15ce16 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 16:12:01 -0600 Subject: Switching the menu item that we're creating. --- src/session-service.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index 3cbb29c..b414328 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -38,6 +38,7 @@ with this program. If not, see . #include #include "dbus-shared-names.h" +#include "dbusmenu-shared.h" #include "gtk-dialog/gconf-helper.h" @@ -481,9 +482,8 @@ rebuild_items (DbusmenuMenuitem *root, ensure_gconf_client (); switch_menuitem = dbusmenu_menuitem_new (); - gchar * switchlabel = g_strdup_printf(_("Switch from %s..."), g_get_user_name()); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, switchlabel); - g_free(switchlabel); + dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_TYPE, MENU_SWITCH_TYPE); + dbusmenu_menuitem_property_set (switch_menuitem, MENU_SWITCH_USER, g_get_user_name()); dbusmenu_menuitem_child_append (root, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); -- cgit v1.2.3 From 54cd89f665c38244b811508d5995010c9a9d08e0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 16:17:54 -0600 Subject: Get returns in better shape --- src/indicator-session.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 7e9bb45..f0ec5a4 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -223,6 +223,9 @@ static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + if (gmi == NULL) { + return FALSE; + } /* TODO: Setup style update */ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); @@ -230,5 +233,5 @@ build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(switch_property_change), client); switch_property_change(newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_value(newitem, MENU_SWITCH_USER), client); - return FALSE; + return TRUE; } -- cgit v1.2.3 From d2bc464709c47d37d110179c291a914fc989f148 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 16:22:51 -0600 Subject: Make sure to realize the offscreen window --- src/indicator-session.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/indicator-session.c b/src/indicator-session.c index f0ec5a4..81453f2 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -177,6 +177,7 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G GtkWidget * off = gtk_offscreen_window_new(); GtkWidget * label = gtk_label_new(username); gtk_container_add(GTK_CONTAINER(off), label); + gtk_widget_realize(off); GdkPixmap * pixmap = gtk_offscreen_window_get_pixmap(GTK_OFFSCREEN_WINDOW(off)); gint width, height; -- cgit v1.2.3 From 5540e6c1c6321ec9c9d10060dc5917d842bcf08a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 20:37:28 -0600 Subject: Switching to using Pango to get the width --- src/indicator-session.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 81453f2..c685203 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -161,6 +161,7 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G return; } + GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); gchar * finalstring = NULL; gboolean set_ellipsize = FALSE; @@ -174,22 +175,25 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G if (finalstring == NULL) { const gchar * username = g_value_get_string(value); - GtkWidget * off = gtk_offscreen_window_new(); - GtkWidget * label = gtk_label_new(username); - gtk_container_add(GTK_CONTAINER(off), label); - gtk_widget_realize(off); - GdkPixmap * pixmap = gtk_offscreen_window_get_pixmap(GTK_OFFSCREEN_WINDOW(off)); + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); /* TODO: Switch to menuitem label */ + + PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); + pango_layout_set_text(layout, username, -1); + pango_layout_set_font_description(layout, style->font_desc); gint width, height; - gdk_drawable_get_size(GDK_DRAWABLE(pixmap), &width, &height); + pango_layout_get_pixel_size(layout, &width, &height); + g_debug("Username width %dpx", width); - GtkStyle * style = gtk_widget_get_style(label); /* TODO: Switch to menuitem label */ gint point = pango_font_description_get_size(style->font_desc); + g_debug("Font size %d pt", point); gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); + g_debug("Screen DPI %f", dpi); gdouble pixels_per_em = point * dpi / 72.0f; gdouble ems = width / pixels_per_em; + g_debug("Username width %fem", ems); /* TODO: We need some way to remove the elipsis from appearing twice in the label. Not sure how to do that yet. */ @@ -201,7 +205,6 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G } } - GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); gtk_menu_item_set_label(gmi, finalstring); GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); -- cgit v1.2.3 From 78fa67257e72eb43d2a4f4d82d51f881af8ad91c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 20:44:35 -0600 Subject: Calculating font size with PANGO_SCALE getting involved --- src/indicator-session.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index c685203..f0232c6 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -181,17 +181,17 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G pango_layout_set_text(layout, username, -1); pango_layout_set_font_description(layout, style->font_desc); - gint width, height; - pango_layout_get_pixel_size(layout, &width, &height); + gint width; + pango_layout_get_pixel_size(layout, &width, NULL); g_debug("Username width %dpx", width); gint point = pango_font_description_get_size(style->font_desc); - g_debug("Font size %d pt", point); + g_debug("Font size %f pt", (gfloat)point / PANGO_SCALE); gdouble dpi = gdk_screen_get_resolution(gdk_screen_get_default()); g_debug("Screen DPI %f", dpi); - gdouble pixels_per_em = point * dpi / 72.0f; + gdouble pixels_per_em = ((point * dpi) / 72.0f) / PANGO_SCALE; gdouble ems = width / pixels_per_em; g_debug("Username width %fem", ems); -- cgit v1.2.3 From 93c4617240197202846fd9305f2154f885d17224 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 20:45:09 -0600 Subject: Fixing a value --- src/indicator-session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index f0232c6..9a5385e 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -210,9 +210,9 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); if (label != NULL) { if (set_ellipsize) { - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); - } else { gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); + } else { + gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); } } -- cgit v1.2.3 From a2cf14bc54d903dbc51557ff6d06e38f92714010 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 22:48:04 -0600 Subject: Adding in the ability to monitor style changes and re-evaluate. --- src/indicator-session.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 9a5385e..4dc3d11 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -219,6 +219,20 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G return; } +static const gchar * dbusmenu_item_data = "dbusmenu-item"; + +/* Callback for when the style changes so we can reevaluate the + size of the user name with the potentially new font. */ +static void +switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) +{ + DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), dbusmenu_item_data)); + + switch_property_change(mi, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_value(mi, MENU_SWITCH_USER), client); + return; +} + /* This function checks to see if the user name is short enough to not need ellipsing itself, or if, it will get ellipsed by @@ -230,11 +244,12 @@ build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme if (gmi == NULL) { return FALSE; } - /* TODO: Setup style update */ + g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(switch_property_change), client); + g_signal_connect(G_OBJECT(gmi), "style-set", G_CALLBACK(switch_style_set), client); switch_property_change(newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_value(newitem, MENU_SWITCH_USER), client); return TRUE; -- cgit v1.2.3 From c6661b02cfede0afff6102d7ebff656a166e0b29 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 11 Feb 2010 22:48:43 -0600 Subject: Removing comment. --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 4dc3d11..1b9629b 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -175,7 +175,7 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, const G if (finalstring == NULL) { const gchar * username = g_value_get_string(value); - GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); /* TODO: Switch to menuitem label */ + GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); PangoLayout * layout = pango_layout_new(gtk_widget_get_pango_context(GTK_WIDGET(gmi))); pango_layout_set_text(layout, username, -1); -- cgit v1.2.3 From 07f36b8de87ccdaebee842105bd86892f6465d3d Mon Sep 17 00:00:00 2001 From: David Barth Date: Tue, 16 Feb 2010 19:40:23 +0100 Subject: add forgotten separator and re-order the user switch entry according to the spec --- src/session-service.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index e89a9a0..a2da207 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -437,6 +437,10 @@ rebuild_items (DbusmenuMenuitem *root, if (can_activate == TRUE) { + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator1); + if (check_guest_session ()) { mi = dbusmenu_menuitem_new (); @@ -445,6 +449,25 @@ rebuild_items (DbusmenuMenuitem *root, g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); } + if (check_new_session ()) + { + ensure_gconf_client (); + + switch_menuitem = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User...")); + dbusmenu_menuitem_child_append (root, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); + + if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) + { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + } + else + { + dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + } + } + if (count > MINIMUM_USERS && count < MAXIMUM_USERS) { if (users != NULL) @@ -476,24 +499,6 @@ rebuild_items (DbusmenuMenuitem *root, } } - if (check_new_session ()) - { - ensure_gconf_client (); - - switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Switch User...")); - dbusmenu_menuitem_child_append (root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), NULL); - - if (gconf_client_get_bool (gconf_client, LOCKDOWN_KEY, NULL)) - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } - else - { - dbusmenu_menuitem_property_set_bool (switch_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - } - } } DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); -- cgit v1.2.3 From b800d54c8ab32368153003cb61d1c00f9b76ccad Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 17 Feb 2010 11:03:06 +0100 Subject: Port from DeviceKit-power to upower --- src/session-service.c | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index e89a9a0..0d9552a 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -44,9 +44,9 @@ with this program. If not, see . #include "users-service-dbus.h" #include "lock-helper.h" -#define DKP_ADDRESS "org.freedesktop.DeviceKit.Power" -#define DKP_OBJECT "/org/freedesktop/DeviceKit/Power" -#define DKP_INTERFACE "org.freedesktop.DeviceKit.Power" +#define UP_ADDRESS "org.freedesktop.UPower" +#define UP_OBJECT "/org/freedesktop/UPower" +#define UP_INTERFACE "org.freedesktop.UPower" #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" @@ -72,8 +72,8 @@ static GList *users; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; -static DBusGProxy * dkp_main_proxy = NULL; -static DBusGProxy * dkp_prop_proxy = NULL; +static DBusGProxy * up_main_proxy = NULL; +static DBusGProxy * up_prop_proxy = NULL; static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; @@ -147,14 +147,14 @@ machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { gchar * type = (gchar *)userdata; - if (dkp_main_proxy == NULL) { - g_warning("Can not %s as no DeviceKit Power Proxy", type); + if (up_main_proxy == NULL) { + g_warning("Can not %s as no upower proxy", type); } screensaver_throttle(type); lock_screen(NULL, 0, NULL); - dbus_g_proxy_begin_call(dkp_main_proxy, + dbus_g_proxy_begin_call(up_main_proxy, type, sleep_response, NULL, @@ -213,17 +213,17 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) /* A signal that we need to recheck to ensure we can still hibernate and/or suspend */ static void -dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) +up_changed_cb (DBusGProxy * proxy, gpointer user_data) { /* Start Async call to see if we can hibernate */ if (suspend_call == NULL) { - suspend_call = dbus_g_proxy_begin_call(dkp_prop_proxy, + suspend_call = dbus_g_proxy_begin_call(up_prop_proxy, "Get", suspend_prop_cb, NULL, NULL, G_TYPE_STRING, - DKP_INTERFACE, + UP_INTERFACE, G_TYPE_STRING, "can-suspend", G_TYPE_INVALID, @@ -233,13 +233,13 @@ dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) /* Start Async call to see if we can suspend */ if (hibernate_call == NULL) { - hibernate_call = dbus_g_proxy_begin_call(dkp_prop_proxy, + hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, "Get", hibernate_prop_cb, NULL, NULL, G_TYPE_STRING, - DKP_INTERFACE, + UP_INTERFACE, G_TYPE_STRING, "can-hibernate", G_TYPE_INVALID, @@ -254,39 +254,39 @@ dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) DKp checking. We're even setting up the calls for the props we need */ static void -setup_dkp (void) { +setup_up (void) { DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); g_return_if_fail(bus != NULL); - if (dkp_main_proxy == NULL) { - dkp_main_proxy = dbus_g_proxy_new_for_name(bus, - DKP_ADDRESS, - DKP_OBJECT, - DKP_INTERFACE); + if (up_main_proxy == NULL) { + up_main_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, + UP_INTERFACE); } - g_return_if_fail(dkp_main_proxy != NULL); + g_return_if_fail(up_main_proxy != NULL); - if (dkp_prop_proxy == NULL) { - dkp_prop_proxy = dbus_g_proxy_new_for_name(bus, - DKP_ADDRESS, - DKP_OBJECT, + if (up_prop_proxy == NULL) { + up_prop_proxy = dbus_g_proxy_new_for_name(bus, + UP_ADDRESS, + UP_OBJECT, DBUS_INTERFACE_PROPERTIES); } - g_return_if_fail(dkp_prop_proxy != NULL); + g_return_if_fail(up_prop_proxy != NULL); /* Connect to changed signal */ - dbus_g_proxy_add_signal(dkp_main_proxy, + dbus_g_proxy_add_signal(up_main_proxy, "Changed", G_TYPE_INVALID); - dbus_g_proxy_connect_signal(dkp_main_proxy, + dbus_g_proxy_connect_signal(up_main_proxy, "Changed", - G_CALLBACK(dpk_changed_cb), + G_CALLBACK(up_changed_cb), NULL, NULL); /* Force an original "changed" event */ - dpk_changed_cb(dkp_main_proxy, NULL); + up_changed_cb(up_main_proxy, NULL); return; } @@ -639,7 +639,7 @@ main (int argc, char ** argv) G_CALLBACK (user_removed), root_menuitem); - setup_dkp(); + setup_up(); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, root_menuitem); -- cgit v1.2.3 From fe30d5b4e43323cd8c85f15fcd25399396fdd30a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:14:50 -0600 Subject: Adding a status directory and icons for accounts that are logged in --- data/icons/16x16/Makefile.am | 2 +- data/icons/16x16/status/Makefile.am | 7 + data/icons/16x16/status/account-logged-in.png | Bin 0 -> 962 bytes data/icons/22x22/Makefile.am | 2 +- data/icons/22x22/status/Makefile.am | 7 + data/icons/22x22/status/account-logged-in.png | Bin 0 -> 1356 bytes data/icons/24x24/Makefile.am | 2 +- data/icons/24x24/status/Makefile.am | 7 + data/icons/24x24/status/account-logged-in.png | Bin 0 -> 1356 bytes data/icons/32x32/Makefile.am | 2 +- data/icons/32x32/status/Makefile.am | 7 + data/icons/32x32/status/account-logged-in.png | Bin 0 -> 2136 bytes data/icons/scalable/Makefile.am | 2 +- data/icons/scalable/status/Makefile.am | 7 + data/icons/scalable/status/account-logged-in.svg | 270 +++++++++++++++++++++++ 15 files changed, 310 insertions(+), 5 deletions(-) create mode 100644 data/icons/16x16/status/Makefile.am create mode 100644 data/icons/16x16/status/account-logged-in.png create mode 100644 data/icons/22x22/status/Makefile.am create mode 100644 data/icons/22x22/status/account-logged-in.png create mode 100644 data/icons/24x24/status/Makefile.am create mode 100644 data/icons/24x24/status/account-logged-in.png create mode 100644 data/icons/32x32/status/Makefile.am create mode 100644 data/icons/32x32/status/account-logged-in.png create mode 100644 data/icons/scalable/status/Makefile.am create mode 100644 data/icons/scalable/status/account-logged-in.svg diff --git a/data/icons/16x16/Makefile.am b/data/icons/16x16/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/16x16/Makefile.am +++ b/data/icons/16x16/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/16x16/status/Makefile.am b/data/icons/16x16/status/Makefile.am new file mode 100644 index 0000000..c0af60e --- /dev/null +++ b/data/icons/16x16/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/16x16/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/16x16/status/account-logged-in.png b/data/icons/16x16/status/account-logged-in.png new file mode 100644 index 0000000..fb4362c Binary files /dev/null and b/data/icons/16x16/status/account-logged-in.png differ diff --git a/data/icons/22x22/Makefile.am b/data/icons/22x22/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/22x22/Makefile.am +++ b/data/icons/22x22/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/22x22/status/Makefile.am b/data/icons/22x22/status/Makefile.am new file mode 100644 index 0000000..1ce0fa1 --- /dev/null +++ b/data/icons/22x22/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/22x22/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/22x22/status/account-logged-in.png b/data/icons/22x22/status/account-logged-in.png new file mode 100644 index 0000000..e27d75f Binary files /dev/null and b/data/icons/22x22/status/account-logged-in.png differ diff --git a/data/icons/24x24/Makefile.am b/data/icons/24x24/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/24x24/Makefile.am +++ b/data/icons/24x24/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/24x24/status/Makefile.am b/data/icons/24x24/status/Makefile.am new file mode 100644 index 0000000..4fa065a --- /dev/null +++ b/data/icons/24x24/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/24x24/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/24x24/status/account-logged-in.png b/data/icons/24x24/status/account-logged-in.png new file mode 100644 index 0000000..db4f548 Binary files /dev/null and b/data/icons/24x24/status/account-logged-in.png differ diff --git a/data/icons/32x32/Makefile.am b/data/icons/32x32/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/32x32/Makefile.am +++ b/data/icons/32x32/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/32x32/status/Makefile.am b/data/icons/32x32/status/Makefile.am new file mode 100644 index 0000000..b852725 --- /dev/null +++ b/data/icons/32x32/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/32x32/status + +icons_DATA = \ + account-logged-in.png + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/32x32/status/account-logged-in.png b/data/icons/32x32/status/account-logged-in.png new file mode 100644 index 0000000..05bff57 Binary files /dev/null and b/data/icons/32x32/status/account-logged-in.png differ diff --git a/data/icons/scalable/Makefile.am b/data/icons/scalable/Makefile.am index 0224d45..c163076 100644 --- a/data/icons/scalable/Makefile.am +++ b/data/icons/scalable/Makefile.am @@ -1 +1 @@ -SUBDIRS = actions +SUBDIRS = actions status diff --git a/data/icons/scalable/status/Makefile.am b/data/icons/scalable/status/Makefile.am new file mode 100644 index 0000000..cb006e2 --- /dev/null +++ b/data/icons/scalable/status/Makefile.am @@ -0,0 +1,7 @@ + +iconsdir = $(INDICATORICONSDIR)/hicolor/scalable/status + +icons_DATA = \ + account-logged-in.svg + +EXTRA_DIST = $(icons_DATA) diff --git a/data/icons/scalable/status/account-logged-in.svg b/data/icons/scalable/status/account-logged-in.svg new file mode 100644 index 0000000..c3ef44f --- /dev/null +++ b/data/icons/scalable/status/account-logged-in.svg @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Emblem Urgent + + + Jakub Steiner + + + + + Andreas Nilsson + + + + + + generic + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From de76d333676d3c04a00d48ff5c57f7bff031f399 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:16:26 -0600 Subject: Building the make files --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 1b4ecfa..b401694 100644 --- a/configure.ac +++ b/configure.ac @@ -132,14 +132,19 @@ data/Makefile data/icons/Makefile data/icons/16x16/Makefile data/icons/16x16/actions/Makefile +data/icons/16x16/status/Makefile data/icons/22x22/Makefile data/icons/22x22/actions/Makefile +data/icons/22x22/status/Makefile data/icons/24x24/Makefile data/icons/24x24/actions/Makefile +data/icons/24x24/status/Makefile data/icons/32x32/Makefile data/icons/32x32/actions/Makefile +data/icons/32x32/status/Makefile data/icons/scalable/Makefile data/icons/scalable/actions/Makefile +data/icons/scalable/status/Makefile po/Makefile.in ]) -- cgit v1.2.3 From 59c5e7039b4549c2e7e7a4052c0a3f9407961357 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:20:23 -0600 Subject: Adding in some defines for our new menu type. --- src/dbus-shared-names.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 1fd256f..253cba8 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -38,4 +38,8 @@ with this program. If not, see . #define INDICATOR_SESSION_DBUS_OBJECT "/org/ayatana/indicator/session/menu" #define INDICATOR_SESSION_DBUS_VERSION 0 +#define USER_ITEM_TYPE "x-canonical-user-item" +#define USER_ITEM_PROP_NAME "user-item-name" +#define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" + #endif /* __DBUS_SHARED_NAMES_H__ */ -- cgit v1.2.3 From 765a3b87d9812680615dcb7278e16fea8f0fa1d1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:24:09 -0600 Subject: Registering a handler for our new type --- src/indicator-session.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index dda8c76..d931bcd 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -135,13 +135,25 @@ get_icon (IndicatorObject * io) return status_image; } +static gboolean +new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + + return FALSE; +} + /* Indicator based function to get the menu for the whole applet. This starts up asking for the parts of the menu from the various services. */ static GtkMenu * get_menu (IndicatorObject * io) { - return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); + DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); + + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), USER_ITEM_TYPE, new_user_item); + + return GTK_MENU(menu); } -- cgit v1.2.3 From 7723397ac8f8f5875ffac86f007b9321a503a846 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:36:13 -0600 Subject: Fleshing out the building of the user item --- src/indicator-session.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index d931bcd..a39e4a0 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -135,11 +135,33 @@ get_icon (IndicatorObject * io) return status_image; } +/* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + + GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME)); + gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); + gtk_widget_show(label); + + GtkWidget * icon = gtk_image_new_from_icon_name("account-logged-in", GTK_ICON_SIZE_MENU); + gtk_misc_set_alignment(GTK_MISC(icon), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); + if (dbusmenu_menuitem_property_get_bool(newitem, USER_ITEM_PROP_LOGGED_IN)) { + gtk_widget_show(icon); + } else { + gtk_widget_hide(icon); + } + + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); - return FALSE; + return TRUE; } /* Indicator based function to get the menu for the whole -- cgit v1.2.3 From 6868e64c17ba4aea5f8aa22b84a6518119b6754e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:39:11 -0600 Subject: Switching the guest over to a user item. --- src/session-service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/session-service.c b/src/session-service.c index 3303317..fed4446 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -444,7 +444,9 @@ rebuild_items (DbusmenuMenuitem *root, if (check_guest_session ()) { mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Guest Session")); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, _("Guest Session")); + dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, FALSE); dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); } -- cgit v1.2.3 From 4a297fec6d7fbc75035aa7d3d1eedb90bea98d15 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 23:42:54 -0600 Subject: Switching users over to user items --- src/session-service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/session-service.c b/src/session-service.c index fed4446..1a01174 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -495,7 +495,9 @@ rebuild_items (DbusmenuMenuitem *root, user->service = service; mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, user->real_name); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); + dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, user->sessions != NULL); dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); } -- cgit v1.2.3 From db48c78c85af5ba8380ad147ba8576fd4d878c6f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 09:39:20 -0600 Subject: adding prototype for new user item --- src/indicator-session.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/indicator-session.c b/src/indicator-session.c index ee7d76c..a97eb95 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -68,6 +68,7 @@ static GtkLabel * get_label (IndicatorObject * io); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); -- cgit v1.2.3 From e07cdb88407dc186d7cdb236e410b6ae9c4fc3f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 09:39:50 -0600 Subject: 0.2.3 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b401694..221da2c 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-session.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-session, 0.2.2) +AM_INIT_AUTOMAKE(indicator-session, 0.2.3) AM_MAINTAINER_MODE -- cgit v1.2.3 From 074759daa9712565f6e42be55ec85967fb523a0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 09:47:36 -0600 Subject: Removed debian/patches/01_port_to_upower.patch as it is now merged upstream. --- debian/changelog | 2 + debian/patches/01_port_to_upower.patch | 151 --------------------------------- 2 files changed, 2 insertions(+), 151 deletions(-) delete mode 100644 debian/patches/01_port_to_upower.patch diff --git a/debian/changelog b/debian/changelog index 739b729..794c28d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ indicator-session (0.2.3-0ubuntu1~ppa1) UNRELEASED; urgency=low * Change switch menu item to "Switch from..." * Move from Devkit-Power to upower * Adding in user logged in icon and menu item + * Removed debian/patches/01_port_to_upower.patch as it is now merged + upstream. -- Ted Gould Thu, 18 Feb 2010 09:42:50 -0600 diff --git a/debian/patches/01_port_to_upower.patch b/debian/patches/01_port_to_upower.patch deleted file mode 100644 index f04c1c7..0000000 --- a/debian/patches/01_port_to_upower.patch +++ /dev/null @@ -1,151 +0,0 @@ -Description: Port to upower -Author: Martin Pitt -Upstream: https://code.launchpad.net/~pitti/indicator-session/upower/+merge/19472 ---- indicator-session/src/session-service.c 2010-02-16 10:25:28.000000000 +0100 -+++ indicator-session.new/src/session-service.c 2010-02-17 11:11:18.149652860 +0100 -@@ -44,9 +44,9 @@ - #include "users-service-dbus.h" - #include "lock-helper.h" - --#define DKP_ADDRESS "org.freedesktop.DeviceKit.Power" --#define DKP_OBJECT "/org/freedesktop/DeviceKit/Power" --#define DKP_INTERFACE "org.freedesktop.DeviceKit.Power" -+#define UP_ADDRESS "org.freedesktop.UPower" -+#define UP_OBJECT "/org/freedesktop/UPower" -+#define UP_INTERFACE "org.freedesktop.UPower" - - #define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" - -@@ -72,8 +72,8 @@ - - static DbusmenuMenuitem * root_menuitem = NULL; - static GMainLoop * mainloop = NULL; --static DBusGProxy * dkp_main_proxy = NULL; --static DBusGProxy * dkp_prop_proxy = NULL; -+static DBusGProxy * up_main_proxy = NULL; -+static DBusGProxy * up_prop_proxy = NULL; - - static DBusGProxyCall * suspend_call = NULL; - static DBusGProxyCall * hibernate_call = NULL; -@@ -147,14 +147,14 @@ - { - gchar * type = (gchar *)userdata; - -- if (dkp_main_proxy == NULL) { -- g_warning("Can not %s as no DeviceKit Power Proxy", type); -+ if (up_main_proxy == NULL) { -+ g_warning("Can not %s as no upower proxy", type); - } - - screensaver_throttle(type); - lock_screen(NULL, 0, NULL); - -- dbus_g_proxy_begin_call(dkp_main_proxy, -+ dbus_g_proxy_begin_call(up_main_proxy, - type, - sleep_response, - NULL, -@@ -213,17 +213,17 @@ - /* A signal that we need to recheck to ensure we can still - hibernate and/or suspend */ - static void --dpk_changed_cb (DBusGProxy * proxy, gpointer user_data) -+up_changed_cb (DBusGProxy * proxy, gpointer user_data) - { - /* Start Async call to see if we can hibernate */ - if (suspend_call == NULL) { -- suspend_call = dbus_g_proxy_begin_call(dkp_prop_proxy, -+ suspend_call = dbus_g_proxy_begin_call(up_prop_proxy, - "Get", - suspend_prop_cb, - NULL, - NULL, - G_TYPE_STRING, -- DKP_INTERFACE, -+ UP_INTERFACE, - G_TYPE_STRING, - "can-suspend", - G_TYPE_INVALID, -@@ -233,13 +233,13 @@ - - /* Start Async call to see if we can suspend */ - if (hibernate_call == NULL) { -- hibernate_call = dbus_g_proxy_begin_call(dkp_prop_proxy, -+ hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, - "Get", - hibernate_prop_cb, - NULL, - NULL, - G_TYPE_STRING, -- DKP_INTERFACE, -+ UP_INTERFACE, - G_TYPE_STRING, - "can-hibernate", - G_TYPE_INVALID, -@@ -254,39 +254,39 @@ - DKp checking. We're even setting up the calls for the props - we need */ - static void --setup_dkp (void) { -+setup_up (void) { - DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); - g_return_if_fail(bus != NULL); - -- if (dkp_main_proxy == NULL) { -- dkp_main_proxy = dbus_g_proxy_new_for_name(bus, -- DKP_ADDRESS, -- DKP_OBJECT, -- DKP_INTERFACE); -- } -- g_return_if_fail(dkp_main_proxy != NULL); -- -- if (dkp_prop_proxy == NULL) { -- dkp_prop_proxy = dbus_g_proxy_new_for_name(bus, -- DKP_ADDRESS, -- DKP_OBJECT, -+ if (up_main_proxy == NULL) { -+ up_main_proxy = dbus_g_proxy_new_for_name(bus, -+ UP_ADDRESS, -+ UP_OBJECT, -+ UP_INTERFACE); -+ } -+ g_return_if_fail(up_main_proxy != NULL); -+ -+ if (up_prop_proxy == NULL) { -+ up_prop_proxy = dbus_g_proxy_new_for_name(bus, -+ UP_ADDRESS, -+ UP_OBJECT, - DBUS_INTERFACE_PROPERTIES); - } -- g_return_if_fail(dkp_prop_proxy != NULL); -+ g_return_if_fail(up_prop_proxy != NULL); - - /* Connect to changed signal */ -- dbus_g_proxy_add_signal(dkp_main_proxy, -+ dbus_g_proxy_add_signal(up_main_proxy, - "Changed", - G_TYPE_INVALID); - -- dbus_g_proxy_connect_signal(dkp_main_proxy, -+ dbus_g_proxy_connect_signal(up_main_proxy, - "Changed", -- G_CALLBACK(dpk_changed_cb), -+ G_CALLBACK(up_changed_cb), - NULL, - NULL); - - /* Force an original "changed" event */ -- dpk_changed_cb(dkp_main_proxy, NULL); -+ up_changed_cb(up_main_proxy, NULL); - - return; - } -@@ -639,7 +639,7 @@ - G_CALLBACK (user_removed), - root_menuitem); - -- setup_dkp(); -+ setup_up(); - - DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); - dbusmenu_server_set_root(server, root_menuitem); -- cgit v1.2.3 From eb535929ba34980cb6963f0b30ec5bc023a75e1c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 09:49:25 -0600 Subject: releasing version 0.2.3-0ubuntu1~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 794c28d..a9295ef 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-session (0.2.3-0ubuntu1~ppa1) UNRELEASED; urgency=low +indicator-session (0.2.3-0ubuntu1~ppa1) lucid; urgency=low * Upstream release 0.2.3 * Switch menu ordering to match design spec @@ -8,7 +8,7 @@ indicator-session (0.2.3-0ubuntu1~ppa1) UNRELEASED; urgency=low * Removed debian/patches/01_port_to_upower.patch as it is now merged upstream. - -- Ted Gould Thu, 18 Feb 2010 09:42:50 -0600 + -- Ted Gould Thu, 18 Feb 2010 09:49:22 -0600 indicator-session (0.2.2-0ubuntu2) lucid; urgency=low -- cgit v1.2.3