diff options
-rw-r--r-- | data/com.canonical.indicator.session.gschema.xml.in | 6 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/dbusmenu-shared.h | 4 | ||||
-rw-r--r-- | src/device-menu-mgr.c | 1 | ||||
-rw-r--r-- | src/indicator-session.c | 133 | ||||
-rw-r--r-- | src/session-service.c | 1 | ||||
-rw-r--r-- | src/settings-helper.h | 1 | ||||
-rw-r--r-- | src/user-menu-mgr.c | 7 |
8 files changed, 4 insertions, 151 deletions
diff --git a/data/com.canonical.indicator.session.gschema.xml.in b/data/com.canonical.indicator.session.gschema.xml.in index c26d8c1..ec8e954 100644 --- a/data/com.canonical.indicator.session.gschema.xml.in +++ b/data/com.canonical.indicator.session.gschema.xml.in @@ -25,12 +25,6 @@ <summary>Determine the visibility of the User's real name on the panel</summary> <description>Allow for the Removal of the users name from the panel</description> </key> - <key type="b" name="use-username-in-switch-item"> - <default>false</default> - <summary>Determine what string to use for the user's name in the switch menuitem.</summary> - <description>The switch menuitem as part of the user menu should be default have the label 'Switch User Account'. - This settings gives the user the potential to have the label read 'Switch from $username'</description> - </key> </schema> diff --git a/src/Makefile.am b/src/Makefile.am index 55262a1..209b72d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,6 @@ libsession_la_SOURCES = \ indicator-session.c \ gen-session-dbus.xml.h \ dbus-shared-names.h \ - dbusmenu-shared.h \ user-widget.c \ user-widget.h libsession_la_CFLAGS = \ @@ -133,7 +132,6 @@ indicator_session_service_SOURCES = \ session-dbus.c \ session-dbus.h \ gen-session-dbus.xml.c \ - dbusmenu-shared.h \ settings-helper.c \ users-service-dbus.h \ users-service-dbus.c \ diff --git a/src/dbusmenu-shared.h b/src/dbusmenu-shared.h deleted file mode 100644 index 1ef179b..0000000 --- a/src/dbusmenu-shared.h +++ /dev/null @@ -1,4 +0,0 @@ - -#define MENU_SWITCH_TYPE "x-canonical-switch-from" -#define MENU_SWITCH_USER "x-canonical-switch-username" - diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 9cfb913..23a8dc0 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -29,7 +29,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "device-menu-mgr.h" #include "settings-helper.h" #include "dbus-shared-names.h" -#include "dbusmenu-shared.h" #include "lock-helper.h" #define UP_ADDRESS "org.freedesktop.UPower" diff --git a/src/indicator-session.c b/src/indicator-session.c index 94ab18b..54fdab6 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -39,7 +39,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-image-helper.h> #include "dbus-shared-names.h" -#include "dbusmenu-shared.h" #include "user-widget.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) @@ -75,10 +74,6 @@ INDICATOR_SET_VERSION INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE) /* Prototypes */ -static gboolean build_menu_switch (DbusmenuMenuitem * newitem, - DbusmenuMenuitem * parent, - DbusmenuClient * client, - gpointer user_data); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, @@ -152,10 +147,6 @@ indicator_session_init (IndicatorSession *self) dbusmenu_client_add_type_handler (menu_client, RESTART_ITEM_TYPE, build_restart_item); - dbusmenu_client_add_type_handler_full (menu_client, - MENU_SWITCH_TYPE, - build_menu_switch, - self, NULL); dbusmenu_gtkclient_set_accel_group (DBUSMENU_GTKCLIENT(menu_client), gtk_accel_group_new()); } @@ -354,83 +345,6 @@ receive_signal (GDBusProxy * proxy, -static void -switch_property_change (DbusmenuMenuitem * item, - const gchar * property, - GVariant * variant, - gpointer user_data) -{ - if (g_strcmp0 (property, MENU_SWITCH_USER) != 0) { - return; - } - - GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(DBUSMENU_GTKCLIENT(user_data), item); - gchar * finalstring = NULL; - gboolean set_ellipsize = FALSE; - gboolean no_name_in_lang = FALSE; - - const gchar * translate = C_("session_menu:switchfrom", "1"); - if (g_strcmp0(translate, "1") != 0) { - no_name_in_lang = TRUE; - } - - GSettings* settings = g_settings_new ("com.canonical.indicator.session"); - gboolean use_username = g_settings_get_boolean (settings, - "use-username-in-switch-item"); - g_object_unref (settings); - - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || - g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang - || use_username == FALSE) { - finalstring = _("Switch User Account…"); - set_ellipsize = FALSE; - } - - if (finalstring == NULL) { - const gchar * username = g_variant_get_string(variant, NULL); - 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); - pango_layout_set_font_description(layout, style->font_desc); - - gint width; - pango_layout_get_pixel_size(layout, &width, NULL); - g_object_unref(layout); - g_debug("Username width %dpx", width); - - gint point = pango_font_description_get_size(style->font_desc); - 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) / PANGO_SCALE; - gdouble ems = width / pixels_per_em; - g_debug("Username width %fem", ems); - - finalstring = g_strdup_printf(_("Switch From %s…"), username); - if (ems >= 20.0f) { - set_ellipsize = TRUE; - } else { - set_ellipsize = FALSE; - } - - } - 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_END); - } else { - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_NONE); - } - } - return; -} - -static const gchar * dbusmenu_item_data = "dbusmenu-item"; static void restart_property_change (DbusmenuMenuitem * item, @@ -488,53 +402,6 @@ build_restart_item (DbusmenuMenuitem * newitem, } 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_variant(mi, MENU_SWITCH_USER), - client); - return; -} - -static gboolean -build_menu_switch (DbusmenuMenuitem * newitem, - DbusmenuMenuitem * parent, - DbusmenuClient * client, - gpointer user_data) -{ - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - if (gmi == NULL) { - return FALSE; - } - - 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_variant(newitem, MENU_SWITCH_USER), client); - - return TRUE; -} - -static void indicator_session_update_users_label (IndicatorSession * self, const gchar * name) { diff --git a/src/session-service.c b/src/session-service.c index 52018db..508887f 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -43,7 +43,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-service.h> #include "dbus-shared-names.h" -#include "dbusmenu-shared.h" #include "users-service-dbus.h" #include "user-menu-mgr.h" #include "device-menu-mgr.h" diff --git a/src/settings-helper.h b/src/settings-helper.h index 29372f3..17304af 100644 --- a/src/settings-helper.h +++ b/src/settings-helper.h @@ -34,7 +34,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define RESTART_KEY "suppress-restart-menuitem" #define SHUTDOWN_KEY "suppress-shutdown-menuitem" #define SHOW_USER_MENU "user-show-menu" -#define USER_USERNAME_IN_SWITCH_ITEM "use-username-in-switch-item" #define LOCKDOWN_SCHEMA "org.gnome.desktop.lockdown" #define LOCKDOWN_KEY_USER "disable-user-switching" diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 2fe042a..37aca14 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -21,7 +21,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "user-menu-mgr.h" #include "settings-helper.h" #include "dbus-shared-names.h" -#include "dbusmenu-shared.h" #include "lock-helper.h" #include "users-service-dbus.h" @@ -299,12 +298,14 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) /* TODO we should really return here if the menu is not going to be shown. */ DbusmenuMenuitem * switch_menuitem = dbusmenu_menuitem_new (); +/* 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()); + USER_ITEM_PROP_NAME, + _("Switch User Account…")); dbusmenu_menuitem_child_append (self->root_item, switch_menuitem); g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |