From 62d5071180e89c16c32d7b1bfee4410d37bee5f5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 23 Aug 2011 16:54:52 +0100 Subject: removed bluetooth item and labels on webcams and scanners are now manufacturer specific --- src/device-menu-mgr.c | 28 +++++++--------------- src/udev-mgr.c | 65 +++++++++++++++++++++++++++++++++++++++++++++------ src/user-menu-mgr.c | 4 ++++ 3 files changed, 70 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index c298682..e111450 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -49,7 +49,6 @@ static GSettings *keybinding_settings = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; static DbusmenuMenuitem *system_settings_menuitem = NULL; static DbusmenuMenuitem *display_settings_menuitem = NULL; -static DbusmenuMenuitem *bluetooth_settings_menuitem = NULL; static DbusmenuMenuitem *login_settings_menuitem = NULL; static DbusmenuMenuitem *software_updates_menuitem = NULL; static DbusmenuMenuitem *printers_menuitem = NULL; @@ -535,17 +534,6 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position(self->root_item, display_settings_menuitem, 1); - bluetooth_settings_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (bluetooth_settings_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Bluetooth…")); - g_signal_connect (G_OBJECT(bluetooth_settings_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), "bluetooth"); - dbusmenu_menuitem_child_add_position(self->root_item, - bluetooth_settings_menuitem, - 2); - login_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (login_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -556,20 +544,20 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self) "login"); dbusmenu_menuitem_child_add_position(self->root_item, login_settings_menuitem, - 3); + 2); software_updates_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (software_updates_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Software Up to Date")); dbusmenu_menuitem_child_add_position(self->root_item, software_updates_menuitem, - 4); + 3); DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (self->root_item, separator1, 5); + dbusmenu_menuitem_child_add_position (self->root_item, separator1, 4); } static void @@ -584,7 +572,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) FALSE); dbusmenu_menuitem_child_add_position (self->root_item, device_heading, - 6); + 5); printers_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (printers_menuitem, @@ -596,7 +584,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) "printers"); dbusmenu_menuitem_child_add_position(self->root_item, printers_menuitem, - 7); + 6); scanners_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (scanners_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -607,7 +595,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) NULL); dbusmenu_menuitem_child_add_position (self->root_item, scanners_menuitem, - 8); + 7); dbusmenu_menuitem_property_set_bool (scanners_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); @@ -622,7 +610,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) NULL); dbusmenu_menuitem_child_add_position (self->root_item, webcam_menuitem, - 10); + 8); dbusmenu_menuitem_property_set_bool (webcam_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); @@ -631,7 +619,7 @@ device_menu_mgr_build_devices_items (DeviceMenuMgr* self) dbusmenu_menuitem_property_set (separator3, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (self->root_item, separator3, 11); + dbusmenu_menuitem_child_add_position (self->root_item, separator3, 9); } static void diff --git a/src/udev-mgr.c b/src/udev-mgr.c index f66d862..179e56f 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -22,8 +22,7 @@ with this program. If not, see . // TEMP #include #include -#include -#include +#include #include "udev-mgr.h" #include "sane-rules.h" @@ -235,13 +234,29 @@ udev_mgr_handle_webcam (UdevMgr* self, } g_hash_table_remove (self->webcams_present, product); - + dbusmenu_menuitem_property_set (self->webcam_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Webcams")); } else { if (g_hash_table_lookup (self->webcams_present, product) != NULL){ g_warning ("Got an ADD event on a webcam device but we already have that device in our webcam cache"); return; } + + const gchar* manufacturer = NULL; + 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)); + } + g_hash_table_insert (self->webcams_present, g_strdup (product), g_strdup (vendor)); @@ -254,23 +269,26 @@ debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action) { - /*const gchar* vendor; + const gchar* vendor; const gchar* product; const gchar* number; const gchar* name; + const gchar* manufacturer; vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + manufacturer = g_udev_device_get_property (device, "ID_VENDOR"); product = g_udev_device_get_property (device, "ID_MODEL_ID"); number = g_udev_device_get_number (device); name = g_udev_device_get_name (device); - g_debug ("device vendor id %s , product id of %s , number of %s and name of %s", + g_debug ("%s device vendor id %s , product id of %s , number of %s and name of %s", + g_strdup(manufacturer), g_strdup(vendor), g_strdup(product), g_strdup(number), g_strdup(name)); - const gchar *const *list; + /*const gchar *const *list; const gchar *const *iter; char propstr[500]; guint32 namelen = 0, i; @@ -290,7 +308,7 @@ debug_device (UdevMgr* self, strcat(propstr, " "); strcat(propstr, g_udev_device_get_property(device, *iter)); g_debug("%s", propstr); - }*/ + }*/ } static void udev_mgr_handle_scsi_device (UdevMgr* self, @@ -344,6 +362,10 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, } else{ g_hash_table_remove (self->scanners_present, vendor); + dbusmenu_menuitem_property_set (self->scanner_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Scanners")); + } } else{ @@ -351,6 +373,18 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); } else{ + const gchar* manufacturer = NULL; + 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)); + } g_hash_table_insert (self->scanners_present, g_strdup(vendor), g_strdup(model_id)); @@ -397,6 +431,9 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, } else{ g_hash_table_remove (self->scanners_present, vendor); + dbusmenu_menuitem_property_set (self->scanner_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Scanners")); } } else{ @@ -404,6 +441,20 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); } else{ + const gchar* manufacturer = NULL; + + 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)); + } + g_hash_table_insert (self->scanners_present, g_strdup(vendor), g_strdup(model_id)); diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 588d3d0..9d76b8b 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -49,6 +49,10 @@ static gint compare_users_by_username (const gchar *a, static void activate_online_accounts (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data); +static void activate_user_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data); + static void user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode); static gboolean check_new_session (); -- cgit v1.2.3