diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-08-25 18:58:59 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-08-25 18:58:59 +0100 |
commit | ae28c6c7dae6fe4112b9ce625413cc32c07ed1b4 (patch) | |
tree | d23d884d9420a2b2ba0b971e6f0320a6a8c73579 | |
parent | a8fbf33eb06441519330210519e37be6f8e0aed2 (diff) | |
parent | 9631736c86733243e55b82b6e3f0ce2bc8489d8c (diff) | |
download | ayatana-indicator-session-0.3.3.1.tar.gz ayatana-indicator-session-0.3.3.1.tar.bz2 ayatana-indicator-session-0.3.3.1.zip |
fixes for the min users and label on panel for guest0.3.3.1
-rw-r--r-- | src/session-service.c | 2 | ||||
-rw-r--r-- | src/udev-mgr.c | 78 | ||||
-rw-r--r-- | src/user-menu-mgr.c | 48 | ||||
-rw-r--r-- | src/users-service-dbus.h | 2 |
4 files changed, 80 insertions, 50 deletions
diff --git a/src/session-service.c b/src/session-service.c index 753e304..e16832c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -97,7 +97,7 @@ main (int argc, char ** argv) /* Setting up i18n and gettext. Apparently, we need all of these. */ - setlocale (LC_ALL, ""); + setlocale (LC_ALL, "C"); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 7e51383..cf148e2 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -49,7 +49,9 @@ static void debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action); - +static gchar* format_device_name (UdevMgr* self, + gchar* brand, + gchar* type); struct _UdevMgr { GObject parent_instance; @@ -233,7 +235,7 @@ udev_mgr_handle_webcam (UdevMgr* self, product); dbusmenu_menuitem_property_set (self->webcam_item, DBUSMENU_MENUITEM_PROP_LABEL, - _("Webcams")); + _("Webcam")); } else { if (g_hash_table_lookup (self->webcams_present, product) != NULL){ @@ -245,13 +247,11 @@ udev_mgr_handle_webcam (UdevMgr* self, manufacturer = g_udev_device_get_property (device, "ID_VENDOR"); if (manufacturer != NULL){ - gchar* lowered = g_ascii_strdown (manufacturer, -1); - lowered[0] = g_ascii_toupper (lowered[0]); - gchar* label = g_strdup_printf(_("%s Webcam"), lowered); - g_free (lowered); dbusmenu_menuitem_property_set (self->webcam_item, DBUSMENU_MENUITEM_PROP_LABEL, - label); + format_device_name (self, + g_strdup(manufacturer), + "Webcam")); } g_hash_table_insert (self->webcams_present, @@ -307,7 +307,8 @@ debug_device (UdevMgr* self, g_debug("%s", propstr); }*/ } - +// TODO SCSI is not dynamic right ? +// i.e. just need to handle startup scan. static void udev_mgr_handle_scsi_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action) @@ -315,7 +316,19 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, const gchar* type = NULL; type = g_udev_device_get_property (device, "TYPE"); // apparently anything thats type 3 and SCSI is a Scanner - if (g_strcmp0 (type, "6") == 0){ + if (g_strcmp0 (type, "6") == 0 && action == ADD){ + + const gchar* manufacturer = NULL; + manufacturer = g_udev_device_get_property (device, "ID_VENDOR"); + + if (manufacturer != NULL){ + dbusmenu_menuitem_property_set (self->scanner_item, + DBUSMENU_MENUITEM_PROP_LABEL, + format_device_name (self, + g_strdup(manufacturer), + "Scanner")); + } + gchar* random_scanner_name = g_strdup_printf("%p--scanner", self); g_hash_table_insert (self->scanners_present, random_scanner_name, @@ -361,7 +374,7 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, g_hash_table_remove (self->scanners_present, vendor); dbusmenu_menuitem_property_set (self->scanner_item, DBUSMENU_MENUITEM_PROP_LABEL, - _("Scanners")); + _("Scanner")); } } @@ -374,13 +387,11 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, manufacturer = g_udev_device_get_property (device, "ID_VENDOR"); if (manufacturer != NULL){ - gchar* lowered = g_ascii_strdown (manufacturer, -1); - lowered[0] = g_ascii_toupper (lowered[0]); - gchar* label = g_strdup_printf(_("%s Scanner"), lowered); - g_free (lowered); dbusmenu_menuitem_property_set (self->scanner_item, DBUSMENU_MENUITEM_PROP_LABEL, - label); + format_device_name (self, + g_strdup(manufacturer), + "Scanner")); } g_hash_table_insert (self->scanners_present, g_strdup(vendor), @@ -397,7 +408,7 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, UdevMgrDeviceAction action) { const gchar* vendor = NULL; - debug_device (self, device, action); + //debug_device (self, device, action); vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); @@ -430,7 +441,7 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, g_hash_table_remove (self->scanners_present, vendor); dbusmenu_menuitem_property_set (self->scanner_item, DBUSMENU_MENUITEM_PROP_LABEL, - _("Scanners")); + _("Scanner")); } } else{ @@ -442,14 +453,12 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, manufacturer = g_udev_device_get_property (device, "ID_VENDOR"); if (manufacturer != NULL){ - - gchar* lowered = g_ascii_strdown (manufacturer, -1); - lowered[0] = g_ascii_toupper (lowered[0]); - gchar* label = g_strdup_printf(_("%s Scanner"), lowered); - g_free (lowered); + dbusmenu_menuitem_property_set (self->scanner_item, DBUSMENU_MENUITEM_PROP_LABEL, - label); + format_device_name (self, + g_strdup(manufacturer), + "Scanner")); } g_hash_table_insert (self->scanners_present, @@ -502,3 +511,26 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, } return mgr; } + +static gchar* format_device_name (UdevMgr* self, + gchar* brand, + gchar* type) +{ + // We don't want to accommodate long names + if (strlen(brand) > 7) + return type; + + gint i = 0; + + // If it contains something other than an alphabetic entry ignore it. + for(i = 0; i < sizeof(brand); i++){ + if ( !g_ascii_isalpha (brand[i]) ) + return type; + } + + gchar* lowered = g_ascii_strdown (brand, -1); + lowered[0] = g_ascii_toupper (lowered[0]); + gchar* label = g_strdup_printf(_("%s %s"), lowered, type); + g_free (lowered); + return label; +} diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 64b29c5..1b404d3 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -188,17 +188,29 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) for (u = users; u != NULL; u = g_list_next (u)) { user = u->data; - g_debug ("%p: %s", user, user->real_name); + //g_debug ("%p: %s", user, user->real_name); user->service = self->users_dbus_interface; - + gboolean current_user = g_strcmp0 (user->user_name, g_get_user_name()) == 0; + if (current_user == TRUE){ + if (check_guest_session()){ + g_debug ("about to set the users real name to %s for user %s", + user->real_name, user->user_name); + session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name); + } + else{ + g_debug ("about to set the users real name to GUEST"); + session_dbus_set_users_real_name (self->session_dbus_interface, + _("Guest")); + } + } + + if (g_strcmp0(user->user_name, "guest") == 0) { /* Check to see if the guest has sessions and so therefore should get a check mark. */ - if (user->sessions != NULL) { - dbusmenu_menuitem_property_set_bool (guest_mi, - USER_ITEM_PROP_LOGGED_IN, - TRUE); - } + dbusmenu_menuitem_property_set_bool (guest_mi, + USER_ITEM_PROP_LOGGED_IN, + user->sessions != NULL); /* If we're showing user accounts, keep going through the list */ if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { continue; @@ -217,7 +229,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); g_free(conflictedname); } else { - g_debug ("%p: %s", user, user->real_name); + //g_debug ("%p: %s", user, user->real_name); dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); @@ -238,28 +250,14 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) USER_ITEM_ICON_DEFAULT); } - gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; - g_debug ("user name = %s and g user name = %s", + /*g_debug ("user name = %s and g user name = %s", user->user_name, - g_get_user_name()); + g_get_user_name());*/ dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_IS_CURRENT_USER, - logged_in); - if (logged_in == TRUE){ - if (check_guest_session()){ - g_debug ("about to set the users real name to %s for user %s", - user->real_name, user->user_name); - session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name); - } - else{ - g_debug ("about to set the users real name to GUEST"); - session_dbus_set_users_real_name (self->session_dbus_interface, - _("Guest")); - } - } - + current_user); dbusmenu_menuitem_child_append (self->root_item, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index c3f0171..4dbf2a4 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -57,7 +57,7 @@ struct _UserData /* XXX - MAXIMUM_USERS should be set to 7 once we've * got some gdm issues worked out. */ -#define MINIMUM_USERS 1 +#define MINIMUM_USERS 0 #define MAXIMUM_USERS 7 struct _UsersServiceDbus { |