From 5f2c8d9947d60271fd13dc1adbe6f001eae9b6d2 Mon Sep 17 00:00:00 2001 From: Gabor Kelemen Date: Sun, 12 Jun 2011 14:42:53 +0200 Subject: Use ellipsis character instead of full stops. Fixes LP: 621339 --- src/gconf-helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gconf-helper.c b/src/gconf-helper.c index 4911dcb..93ae96f 100644 --- a/src/gconf-helper.c +++ b/src/gconf-helper.c @@ -82,9 +82,9 @@ static void update_menu_entries_callback (GConfClient *client, guint cnxn_id, GC dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart")); dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); } else { - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out...")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart...")); - dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down...")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out…")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->restart_mi, RESTART_ITEM_LABEL, _("Restart…")); + dbusmenu_menuitem_property_set(restart_shutdown_logout_mi->shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down…")); } } } -- cgit v1.2.3 From 61e02bbcb28a1496f000eac79426577c5d7d9acf Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 1 Jul 2011 16:18:56 +0100 Subject: initial menu reshuffle in progress --- src/Makefile.am | 4 +- src/indicator-session.c | 116 +++++++++++++++++++++++++----------------------- 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 0317de7..db49fa7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,7 +14,7 @@ libsession_la_SOURCES = \ gen-session-dbus.xml.h \ dbus-shared-names.h \ dbusmenu-shared.h \ - users-service-client.h + users-service-client.h libsession_la_CFLAGS = \ $(APPLET_CFLAGS) \ -Wall -Werror \ @@ -140,7 +140,7 @@ BUILT_SOURCES = \ upower-client.h \ users-service-client.h \ users-service-marshal.h \ - users-service-marshal.c + users-service-marshal.c EXTRA_DIST = \ consolekit-manager.xml \ diff --git a/src/indicator-session.c b/src/indicator-session.c index c9617c4..8394775 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -61,8 +61,8 @@ struct _IndicatorSessionClass { struct _IndicatorSession { IndicatorObject parent; IndicatorServiceManager * service; - GtkImage * status_image; - DbusmenuGtkMenu * menu; + IndicatorObjectEntry users; + IndicatorObjectEntry devices; GCancellable * service_proxy_cancel; GDBusProxy * service_proxy; }; @@ -74,15 +74,11 @@ INDICATOR_SET_VERSION INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE) /* Prototypes */ -static GtkLabel * get_label (IndicatorObject * io); -static GtkImage * get_icon (IndicatorObject * io); -static GtkMenu * get_menu (IndicatorObject * io); -static const gchar * get_accessible_desc (IndicatorObject * io); -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, gpointer user_data); +//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, gpointer user_data); +//static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); static void icon_changed (IndicatorSession * session, const gchar * icon_name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); -static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -90,6 +86,7 @@ static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); static void indicator_session_dispose (GObject *object); static void indicator_session_finalize (GObject *object); +static GList* indicator_session_get_entries (IndicatorObject* obj); G_DEFINE_TYPE (IndicatorSession, indicator_session, INDICATOR_OBJECT_TYPE); @@ -102,11 +99,7 @@ indicator_session_class_init (IndicatorSessionClass *klass) object_class->finalize = indicator_session_finalize; IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); - io_class->get_label = get_label; - io_class->get_image = get_icon; - io_class->get_menu = get_menu; - io_class->get_accessible_desc = get_accessible_desc; - + io_class->get_entries = indicator_session_get_entries; return; } @@ -117,37 +110,66 @@ indicator_session_init (IndicatorSession *self) self->service = NULL; self->service_proxy_cancel = NULL; self->service_proxy = NULL; - + /* Now let's fire these guys up. */ - self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); - g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - - self->status_image = indicator_image_helper(ICON_DEFAULT); - self->menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); - - DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); + self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_VERSION); + g_signal_connect(G_OBJECT(self->service), + INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, + G_CALLBACK(service_connection_cb), self); + + self->users.menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_OBJECT); + self->users.label = "Users"; + + self->devices.menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_OBJECT); + self->devices.label = "Devices"; + + g_object_ref (self->devices); + g_object_ref (self->users); + + /*DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); - + */ + GtkAccelGroup * agroup = gtk_accel_group_new(); dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); self->service_proxy_cancel = g_cancellable_new(); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - self->service_proxy_cancel, - service_proxy_cb, - self); + G_DBUS_PROXY_FLAGS_NONE, + NULL, + INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + self->service_proxy_cancel, + service_proxy_cb, + self); return; } +static GList* +indicator_session_get_entries (IndicatorObject* obj) +{ + g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); + IndicatorSession* self = INDICATOR_SESSION (obj); + + GList * retval = NULL; + + retval = g_list_prepend &(self.users); + retval = g_list_prepend &(self.devices); + + if (retval != NULL) { + retval = g_list_reverse(retval); + } + return retval; +} + /* Callback from trying to create the proxy for the serivce, this could include starting the service. Sometime it'll fail and we'll try to start that dang service again! */ @@ -214,7 +236,7 @@ indicator_session_finalize (GObject *object) return; } -static void +/*static void icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { IndicatorSession * self = INDICATOR_SESSION(user_data); @@ -236,7 +258,7 @@ icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) indicator_image_helper_update(self->status_image, name); return; -} +}*/ static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) @@ -248,24 +270,12 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe G_DBUS_CALL_FLAGS_NONE, -1, NULL, icon_name_get_cb, user_data); } else { - indicator_image_helper_update(self->status_image, ICON_DEFAULT); + //indicator_image_helper_update(self->status_image, ICON_DEFAULT); } return; } -static GtkLabel * -get_label (IndicatorObject * io) -{ - return NULL; -} - -static const gchar * -get_accessible_desc (IndicatorObject * io) -{ - return _("Session"); -} - static void icon_changed (IndicatorSession * session, const gchar * icon_name) { @@ -280,12 +290,6 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, { IndicatorSession * self = INDICATOR_SESSION(user_data); - if (g_strcmp0(signal_name, "IconUpdated") == 0) { - const gchar *name; - g_variant_get (parameters, "(&s)", &name); - icon_changed(self, name); - } - return; } @@ -488,6 +492,7 @@ restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVaria /* Builds the restart item which is a more traditional GTK image menu item that puts the graphic into the gutter. */ + /* static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { @@ -501,7 +506,7 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(restart_property_change), client); /* Grab the inital variants and put them into the item */ - GVariant * variant; + /*GVariant * variant; variant = dbusmenu_menuitem_property_get_variant(newitem, RESTART_ITEM_LABEL); if (variant != NULL) { restart_property_change(newitem, RESTART_ITEM_LABEL, variant, client); @@ -518,6 +523,7 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* 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) { @@ -531,7 +537,7 @@ switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) /* 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 +/*static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); @@ -547,4 +553,4 @@ build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme switch_property_change(newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER), client); return TRUE; -} +}*/ -- cgit v1.2.3 From c972f0989e66b47e809e87b2f400565540d7f00d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sat, 2 Jul 2011 16:31:36 +0100 Subject: compiling at least --- src/indicator-session.c | 83 ++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 60 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 8394775..3f5c8ae 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +//TODO - remember to reinsert Ted's comments. #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -77,7 +78,6 @@ INDICATOR_SET_TYPE(INDICATOR_SESSION_TYPE) //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, gpointer user_data); //static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -static void icon_changed (IndicatorSession * session, const gchar * icon_name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -118,16 +118,15 @@ indicator_session_init (IndicatorSession *self) INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - self->users.menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_DBUS_OBJECT); - self->users.label = "Users"; + self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_OBJECT)); + self->users.label = GTK_LABEL (gtk_label_new ("Users")); + self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_OBJECT)); + self->devices.label = GTK_LABEL (gtk_label_new ("Devices")); - self->devices.menu = dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_DBUS_OBJECT); - self->devices.label = "Devices"; - - g_object_ref (self->devices); - g_object_ref (self->users); + g_object_ref (self->users.menu); + g_object_ref (self->devices.menu); /*DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); @@ -135,8 +134,8 @@ indicator_session_init (IndicatorSession *self) dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); */ - GtkAccelGroup * agroup = gtk_accel_group_new(); - dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); + //GtkAccelGroup * agroup = gtk_accel_group_new(); + //dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); self->service_proxy_cancel = g_cancellable_new(); @@ -161,8 +160,8 @@ indicator_session_get_entries (IndicatorObject* obj) GList * retval = NULL; - retval = g_list_prepend &(self.users); - retval = g_list_prepend &(self.devices); + retval = g_list_prepend (retval, &self->users); + retval = g_list_prepend (retval, &self->devices); if (retval != NULL) { retval = g_list_reverse(retval); @@ -263,12 +262,12 @@ icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) { - IndicatorSession * self = INDICATOR_SESSION(user_data); + //IndicatorSession * self = INDICATOR_SESSION(user_data); if (connected) { - g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, + /*g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, - icon_name_get_cb, user_data); + icon_name_get_cb, user_data);*/ } else { //indicator_image_helper_update(self->status_image, ICON_DEFAULT); } @@ -276,31 +275,17 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe return; } -static void -icon_changed (IndicatorSession * session, const gchar * icon_name) -{ - indicator_image_helper_update(session->status_image, icon_name); - return; -} - /* Receives all signals from the service, routed to the appropriate functions */ static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data) { - IndicatorSession * self = INDICATOR_SESSION(user_data); + //IndicatorSession * self = INDICATOR_SESSION(user_data); return; } -static GtkImage * -get_icon (IndicatorObject * io) -{ - gtk_widget_show(GTK_WIDGET(INDICATOR_SESSION(io)->status_image)); - return INDICATOR_SESSION(io)->status_image; -} - -static void +/*static void user_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) { if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { @@ -313,7 +298,6 @@ user_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant return; } -/* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { @@ -376,12 +360,12 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuCl g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(user_property_change), icon); return TRUE; -} +}*/ /* 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 * +/*static GtkMenu * get_menu (IndicatorObject * io) { return GTK_MENU(INDICATOR_SESSION(io)->menu); @@ -399,17 +383,11 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVarian gboolean set_ellipsize = FALSE; gboolean no_name_in_lang = FALSE; - /* TRANSLATORS: Translate the '1' below into anything other than - '1' if "Switch From %s..." doesn't make sense in your language. - Instead, the string "Switch User..." will be used. */ const gchar * translate = C_("session_menu:switchfrom", "1"); if (g_strcmp0(translate, "1") != 0) { no_name_in_lang = TRUE; } - /* 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 (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { finalstring = _("Switch User..."); set_ellipsize = FALSE; @@ -438,8 +416,6 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVarian 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. */ finalstring = g_strdup_printf(_("Switch From %s..."), username); if (ems >= 20.0f) { set_ellipsize = TRUE; @@ -462,10 +438,8 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVarian return; } -static const gchar * dbusmenu_item_data = "dbusmenu-item"; +//static const gchar * dbusmenu_item_data = "dbusmenu-item"; -/* IF the label or icon changes we need to grab that and update - the menu item */ static void restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) { @@ -486,13 +460,9 @@ restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVaria } g_object_unref(G_OBJECT(gicon)); } - return; } -/* Builds the restart item which is a more traditional GTK image - menu item that puts the graphic into the gutter. */ - /* static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { @@ -505,8 +475,7 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(restart_property_change), client); - /* Grab the inital variants and put them into the item */ - /*GVariant * variant; + GVariant * variant; variant = dbusmenu_menuitem_property_get_variant(newitem, RESTART_ITEM_LABEL); if (variant != NULL) { restart_property_change(newitem, RESTART_ITEM_LABEL, variant, client); @@ -521,9 +490,6 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm } -/* 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) { @@ -534,10 +500,7 @@ switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) 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 +static gboolean build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); -- cgit v1.2.3 From 170728d5fe4d449eb0fa233db9a6a80ce3cae2bb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 4 Jul 2011 17:14:32 +0100 Subject: menus split somewhat --- src/indicator-session.c | 183 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 145 insertions(+), 38 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 3f5c8ae..2fc9b9f 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -76,7 +76,15 @@ 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, gpointer user_data); +static gboolean new_user_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); +static void user_property_change (DbusmenuMenuitem * item, + const gchar * property, + GVariant * variant, + gpointer user_data); + //static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); @@ -106,7 +114,6 @@ indicator_session_class_init (IndicatorSessionClass *klass) static void indicator_session_init (IndicatorSession *self) { - /* Set good defaults */ self->service = NULL; self->service_proxy_cancel = NULL; self->service_proxy = NULL; @@ -117,22 +124,26 @@ indicator_session_init (IndicatorSession *self) g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); - + // users self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); - self->users.label = GTK_LABEL (gtk_label_new ("Users")); + self->users.label = GTK_LABEL (gtk_label_new ("Users")); + + // devices self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); self->devices.label = GTK_LABEL (gtk_label_new ("Devices")); + gtk_widget_show (GTK_WIDGET(self->devices.menu)); + gtk_widget_show (GTK_WIDGET(self->devices.label)); + gtk_widget_show (GTK_WIDGET(self->users.label)); + gtk_widget_show (GTK_WIDGET(self->users.menu)); + g_object_ref (self->users.menu); g_object_ref (self->devices.menu); - /*DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(self->menu)); - dbusmenu_client_add_type_handler(client, MENU_SWITCH_TYPE, build_menu_switch); + DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); - dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); - */ //GtkAccelGroup * agroup = gtk_accel_group_new(); //dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); @@ -152,24 +163,48 @@ indicator_session_init (IndicatorSession *self) return; } -static GList* -indicator_session_get_entries (IndicatorObject* obj) +static void +indicator_session_dispose (GObject *object) { - g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); - IndicatorSession* self = INDICATOR_SESSION (obj); - - GList * retval = NULL; + IndicatorSession * self = INDICATOR_SESSION(object); - retval = g_list_prepend (retval, &self->users); - retval = g_list_prepend (retval, &self->devices); + if (self->service != NULL) { + g_object_unref(G_OBJECT(self->service)); + self->service = NULL; + } - if (retval != NULL) { - retval = g_list_reverse(retval); + if (self->service_proxy != NULL) { + g_object_unref(self->service_proxy); + self->service_proxy = NULL; } - return retval; + + if (self->service_proxy_cancel != NULL) { + g_cancellable_cancel(self->service_proxy_cancel); + g_object_unref(self->service_proxy_cancel); + self->service_proxy_cancel = NULL; + } + + if (self->users.menu != NULL) { + g_object_unref (self->users.menu); + } + + if (self->devices.menu != NULL) { + g_object_unref (self->devices.menu); + } + + G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); + return; } -/* Callback from trying to create the proxy for the serivce, this +static void +indicator_session_finalize (GObject *object) +{ + + G_OBJECT_CLASS (indicator_session_parent_class)->finalize (object); + return; +} + +/* Callback from trying to create the proxy for the service, this could include starting the service. Sometime it'll fail and we'll try to start that dang service again! */ static void @@ -202,39 +237,111 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) return; } -static void -indicator_session_dispose (GObject *object) + +static GList* +indicator_session_get_entries (IndicatorObject* obj) { - IndicatorSession * self = INDICATOR_SESSION(object); + g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); + IndicatorSession* self = INDICATOR_SESSION (obj); + + GList * retval = NULL; - if (self->service != NULL) { - g_object_unref(G_OBJECT(self->service)); - self->service = NULL; + retval = g_list_prepend (retval, &self->users); + retval = g_list_prepend (retval, &self->devices); + + if (retval != NULL) { + retval = g_list_reverse(retval); } + return retval; +} - if (self->service_proxy != NULL) { - g_object_unref(self->service_proxy); - self->service_proxy = NULL; +/* Builds an item with a hip little logged in icon. */ +static gboolean +new_user_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) +{ + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + gint padding = 0; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + GtkWidget * hbox = gtk_hbox_new(FALSE, padding); + + GtkWidget * usericon = NULL; + const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); + g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); + if (icon_name != NULL && icon_name[0] != '\0') { + if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) != 0 && g_file_test(icon_name, G_FILE_TEST_EXISTS)) { + gint width, height; + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + + GError * error = NULL; + GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size(icon_name, width, height, &error); + + if (error == NULL) { + usericon = gtk_image_new_from_pixbuf(pixbuf); + g_object_unref(pixbuf); + } else { + g_warning("Unable to load user icon '%s': %s", icon_name, error->message); + g_error_free(error); + } + } + + if (usericon == NULL) { + GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); + usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); + g_object_unref(gicon); + } + } + if (usericon != NULL) { + gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), usericon, FALSE, FALSE, 0); + gtk_widget_show(usericon); } - if (self->service_proxy_cancel != NULL) { - g_cancellable_cancel(self->service_proxy_cancel); - g_object_unref(self->service_proxy_cancel); - self->service_proxy_cancel = NULL; + 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); } - G_OBJECT_CLASS (indicator_session_parent_class)->dispose (object); - return; + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + + g_signal_connect (G_OBJECT(newitem), + DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, + G_CALLBACK(user_property_change), icon); + + return TRUE; } static void -indicator_session_finalize (GObject *object) +user_property_change (DbusmenuMenuitem * item, + const gchar * property, + GVariant * variant, + gpointer user_data) { - - G_OBJECT_CLASS (indicator_session_parent_class)->finalize (object); + if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { + if (g_variant_get_boolean(variant)) { + gtk_widget_show(GTK_WIDGET(user_data)); + } else { + gtk_widget_hide(GTK_WIDGET(user_data)); + } + } return; } + /*static void icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { -- cgit v1.2.3 From 147a832a0d4f1997232de20aee3d21e3e9c73afd Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 5 Jul 2011 16:57:20 +0100 Subject: split out the menus --- src/indicator-session.c | 4 +- src/session-service.c | 379 +++++++++++++++++++++++------------------------- 2 files changed, 181 insertions(+), 202 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 2fc9b9f..551ae1a 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -125,8 +125,8 @@ indicator_session_init (IndicatorSession *self) INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); // users - self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_DBUS_OBJECT)); + self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, + INDICATOR_USERS_DBUS_OBJECT)); self->users.label = GTK_LABEL (gtk_label_new ("Users")); // devices diff --git a/src/session-service.c b/src/session-service.c index ddcb7cb..a29fe21 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -8,6 +8,7 @@ Authors: Ted Gould Christoph Korn Cody Russell + Conor Curran This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -80,7 +81,9 @@ static SessionDbus *session_dbus = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; -static DbusmenuMenuitem * root_menuitem = NULL; +static DbusmenuMenuitem * session_root_menuitem = NULL; +static DbusmenuMenuitem * users_root_menuitem = NULL; + static GMainLoop * mainloop = NULL; static DBusGProxy * up_main_proxy = NULL; static DBusGProxy * up_prop_proxy = NULL; @@ -101,7 +104,8 @@ static gboolean allow_suspend = TRUE; static GConfClient * gconf_client = NULL; -static void rebuild_items (DbusmenuMenuitem *root, UsersServiceDbus *service); +static void rebuild_session_items (DbusmenuMenuitem *root, UsersServiceDbus *service); +static void rebuild_user_items (DbusmenuMenuitem *root, UsersServiceDbus *service); static void lockdown_changed (GConfClient *client, @@ -117,7 +121,7 @@ lockdown_changed (GConfClient *client, } if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { - rebuild_items(root_menuitem, dbus_interface); + rebuild_session_items(session_root_menuitem, dbus_interface); } return; @@ -228,7 +232,7 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) gboolean local_can_suspend = g_value_get_boolean(&candoit); if (local_can_suspend != can_suspend) { can_suspend = local_can_suspend; - rebuild_items(root_menuitem, dbus_interface); + rebuild_session_items(session_root_menuitem, dbus_interface); } return; @@ -253,7 +257,7 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) gboolean local_can_hibernate = g_value_get_boolean(&candoit); if (local_can_hibernate != can_hibernate) { can_hibernate = local_can_hibernate; - rebuild_items(root_menuitem, dbus_interface); + rebuild_session_items(session_root_menuitem, dbus_interface); } return; @@ -314,7 +318,7 @@ allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer use if (OUT_allowed != *can_do) { *can_do = OUT_allowed; - rebuild_items (root_menuitem, dbus_interface); + rebuild_session_items (session_root_menuitem, dbus_interface); } } @@ -508,18 +512,18 @@ compare_users_by_username (const gchar *a, } /* Take a desktop file and execute it */ -static void +/*static void desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data) { GAppInfo * appinfo = G_APP_INFO(data); g_return_if_fail(appinfo != NULL); g_app_info_launch(appinfo, NULL, NULL, NULL); return; -} +}*/ /* Look at the GAppInfo structures and sort based on the application names */ -static gint +/*static gint sort_app_infos (gconstpointer a, gconstpointer b) { GAppInfo * appa = G_APP_INFO(a); @@ -537,20 +541,20 @@ sort_app_infos (gconstpointer a, gconstpointer b) } return g_strcmp0(namea, nameb); -} +}*/ /* Builds up the menu for us */ -static void -rebuild_items (DbusmenuMenuitem *root, - UsersServiceDbus *service) + +static void +rebuild_user_items (DbusmenuMenuitem *root, + UsersServiceDbus *service) { + DbusmenuMenuitem *guest_mi = NULL; DbusmenuMenuitem *mi = NULL; - DbusmenuMenuitem * guest_mi = NULL; - GList *u; - UserData *user; - gboolean can_activate; - gboolean can_lockscreen; + GList *children; + gboolean can_activate; + /* Make sure we have a valid GConf client, and build one if needed */ @@ -559,13 +563,118 @@ rebuild_items (DbusmenuMenuitem *root, /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); - can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); /* Remove the old menu items if that makes sense */ children = dbusmenu_menuitem_take_children (root); + g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); + GList *u; + UserData *user; + + GList * users = NULL; + users = users_service_dbus_get_user_list (service); + guint user_count = g_list_length(users); + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + } + + for (u = users; u != NULL; u = g_list_next (u)) { + user = u->data; + user->service = service; + + if (user->uid == getuid()) { + /* Hide me from the list */ + continue; + } + + 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); + } + /* If we're showing user accounts, keep going through the list */ + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + continue; + } + /* If not, we can stop here */ + break; + } + + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + if (user->real_name_conflict) { + gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); + g_free(conflictedname); + } else { + 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); + if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://")); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } + dbusmenu_menuitem_child_append (root, mi); + g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); + user->menuitem = mi; + } + } + + g_list_free(users); + + /* Set to NULL just incase we don't end up building one */ + users_service_dbus_set_guest_item(service, NULL); + + /* Build all of the user switching items */ + if (can_activate == TRUE) + { + if (check_guest_session ()) + { + guest_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session")); + dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); + dbusmenu_menuitem_child_append (root, guest_mi); + g_signal_connect (G_OBJECT (guest_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_guest_session), + service); + users_service_dbus_set_guest_item(service, guest_mi); + } + + if (check_new_session ()) + { + 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()); + 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); + } + } +} + +static void +rebuild_session_items (DbusmenuMenuitem *root, + UsersServiceDbus *service) +{ + gboolean can_lockscreen; + + /* Make sure we have a valid GConf client, and build one + if needed */ + ensure_gconf_client (); + + can_lockscreen = !gconf_client_get_bool ( gconf_client, + LOCKDOWN_KEY_SCREENSAVER, + NULL); /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); @@ -580,124 +689,42 @@ rebuild_items (DbusmenuMenuitem *root, g_debug("Unable to get lock screen shortcut."); } - g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), NULL); dbusmenu_menuitem_child_append(root, lock_menuitem); } - /* Set to NULL just incase we don't end up building one */ - users_service_dbus_set_guest_item(service, NULL); - - /* Build all of the user switching items */ - if (can_activate == TRUE) - { - if (can_lockscreen) { - 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 ()) - { - guest_mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session")); - dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); - dbusmenu_menuitem_child_append (root, guest_mi); - g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), service); - users_service_dbus_set_guest_item(service, guest_mi); - } - - if (check_new_session ()) - { - - 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()); - 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); - } - - GList * users = NULL; - users = users_service_dbus_get_user_list (service); - guint user_count = g_list_length(users); - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - users = g_list_sort (users, (GCompareFunc)compare_users_by_username); - } - - for (u = users; u != NULL; u = g_list_next (u)) { - user = u->data; - user->service = service; - - if (user->uid == getuid()) { - /* Hide me from the list */ - continue; - } - - 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); - } - /* If we're showing user accounts, keep going through the list */ - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - continue; - } - /* If not, we can stop here */ - break; - } - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - if (user->real_name_conflict) { - gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); - g_free(conflictedname); - } else { - 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); - if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://")); - } else { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); - } - dbusmenu_menuitem_child_append (root, mi); - g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); - user->menuitem = mi; - } - } - - g_list_free(users); - } - - /* If there were a bunch of items before us, we need a - separator. */ - if (can_lockscreen || can_activate) { - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); - } - /* Start going through the session based items. */ logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out")); + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out")); } else { - dbusmenu_menuitem_property_set(logout_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Log Out\342\200\246")); + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out\342\200\246")); } - dbusmenu_menuitem_property_set_bool(logout_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_logout()); + dbusmenu_menuitem_property_set_bool (logout_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_logout()); dbusmenu_menuitem_child_append(root, logout_mi); - g_signal_connect(G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); + g_signal_connect( G_OBJECT(logout_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "logout"); if (can_suspend && allow_suspend) { suspend_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(suspend_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Suspend")); - dbusmenu_menuitem_child_append(root, suspend_mi); - g_signal_connect(G_OBJECT(suspend_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Suspend"); + dbusmenu_menuitem_property_set (suspend_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Suspend")); + dbusmenu_menuitem_child_append (root, suspend_mi); + g_signal_connect( G_OBJECT(suspend_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep), + "Suspend"); } if (can_hibernate && allow_hibernate) { @@ -735,61 +762,6 @@ rebuild_items (DbusmenuMenuitem *root, update_menu_entries(restart_shutdown_logout_mi); - /* now add extra launchers */ - GDir *extra_launchers_dir; - extra_launchers_dir = g_dir_open (EXTRA_LAUNCHER_DIR, 0, NULL); - if (extra_launchers_dir != NULL) { - GList * launchers = NULL; - - /* Find all the desktop files we want to use */ - for (;;) { - const gchar *extra_launcher_file; - - extra_launcher_file = g_dir_read_name (extra_launchers_dir); - if (extra_launcher_file == NULL) - break; - if (!g_str_has_suffix (extra_launcher_file, ".desktop")) - continue; - - gchar *full_path = g_build_filename (EXTRA_LAUNCHER_DIR, extra_launcher_file, NULL); - GAppInfo * appinfo = G_APP_INFO(g_desktop_app_info_new_from_filename (full_path)); - g_free (full_path); - - launchers = g_list_prepend(launchers, appinfo); - } - g_dir_close(extra_launchers_dir); - - /* Sort the desktop files based on their names */ - launchers = g_list_sort(launchers, sort_app_infos); - - /* Turn each one into a separate menu item */ - GList * launcher = NULL; - gboolean sepadded = FALSE; - for (launcher = launchers; launcher != NULL; launcher = g_list_next(launcher)) { - GAppInfo * appinfo = G_APP_INFO(launcher->data); - - /* Make sure we have a separator */ - if (!sepadded) { - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); - g_object_unref(separator); - sepadded = TRUE; - } - - /* Build the item */ - DbusmenuMenuitem * desktop_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(desktop_mi, DBUSMENU_MENUITEM_PROP_LABEL, g_app_info_get_name(appinfo)); - g_signal_connect(G_OBJECT(desktop_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(desktop_activate_cb), appinfo); - g_object_weak_ref(G_OBJECT(desktop_mi), (GWeakNotify)g_object_unref, appinfo); - - /* Put into the menu */ - dbusmenu_menuitem_child_append(root, desktop_mi); - } - - g_list_free(launchers); - } - return; } @@ -801,7 +773,7 @@ user_change (UsersServiceDbus *service, gpointer user_data) { DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; - rebuild_items (root, service); + rebuild_user_items (root, service); return; } @@ -869,7 +841,7 @@ setup_restart_watch (void) int main (int argc, char ** argv) { - g_type_init(); + g_type_init(); /* Setting up i18n and gettext. Apparently, we need all of these. */ @@ -887,32 +859,39 @@ main (int argc, char ** argv) g_idle_add(lock_screen_setup, NULL); - root_menuitem = dbusmenu_menuitem_new(); - g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem)); + session_root_menuitem = dbusmenu_menuitem_new(); + g_debug("Session Root ID: %d", dbusmenu_menuitem_get_id(session_root_menuitem)); - dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); + dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); - rebuild_items (root_menuitem, dbus_interface); + rebuild_session_items (session_root_menuitem, dbus_interface); - g_signal_connect (G_OBJECT (dbus_interface), - "user-added", - G_CALLBACK (user_change), - root_menuitem); - g_signal_connect (G_OBJECT (dbus_interface), - "user-removed", - G_CALLBACK (user_change), - root_menuitem); setup_restart_watch(); setup_up(); - DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); - dbusmenu_server_set_root(server, root_menuitem); - - mainloop = g_main_loop_new(NULL, FALSE); - g_main_loop_run(mainloop); - - return 0; + DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); + dbusmenu_server_set_root(server, session_root_menuitem); + + users_root_menuitem = dbusmenu_menuitem_new(); + g_signal_connect (G_OBJECT (dbus_interface), + "user-added", + G_CALLBACK (user_change), + users_root_menuitem); + g_signal_connect (G_OBJECT (dbus_interface), + "user-removed", + G_CALLBACK (user_change), + users_root_menuitem); + + rebuild_user_items (users_root_menuitem, dbus_interface); + + DbusmenuServer * users_server = dbusmenu_server_new(INDICATOR_USERS_DBUS_OBJECT); + dbusmenu_server_set_root (users_server, users_root_menuitem); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; } -- cgit v1.2.3 From 9ee6a254c71c3bd7196f7b7f1921d0ec66ef3b01 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 5 Jul 2011 18:28:22 +0100 Subject: code tidied, menu splittage in progress --- src/indicator-session.c | 162 +++++++++++++++++------------------------------- src/session-service.c | 51 ++++++++++----- 2 files changed, 95 insertions(+), 118 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 551ae1a..185e184 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -75,7 +75,10 @@ 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 build_menu_switch (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, @@ -85,7 +88,10 @@ static void user_property_change (DbusmenuMenuitem * item, GVariant * variant, gpointer user_data); -//static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static gboolean build_restart_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -142,11 +148,19 @@ indicator_session_init (IndicatorSession *self) g_object_ref (self->users.menu); g_object_ref (self->devices.menu); - DbusmenuClient * client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); - dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); + // Setup the handlers for users + DbusmenuClient * users_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); + dbusmenu_client_add_type_handler(users_client, USER_ITEM_TYPE, new_user_item); + dbusmenu_client_add_type_handler(users_client, MENU_SWITCH_TYPE, build_menu_switch); - //GtkAccelGroup * agroup = gtk_accel_group_new(); - //dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); + // Setup the handlers for devices + DbusmenuClient * devices_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->devices.menu))); + dbusmenu_client_add_type_handler (devices_client, + RESTART_ITEM_TYPE, + build_restart_item); + + GtkAccelGroup * agroup = gtk_accel_group_new(); + dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(devices_client), agroup); self->service_proxy_cancel = g_cancellable_new(); @@ -392,94 +406,12 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, return; } -/*static void -user_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) -{ - if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { - if (g_variant_get_boolean(variant)) { - gtk_widget_show(GTK_WIDGET(user_data)); - } else { - gtk_widget_hide(GTK_WIDGET(user_data)); - } - } - return; -} - -static gboolean -new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) -{ - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - gint padding = 0; - gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - GtkWidget * hbox = gtk_hbox_new(FALSE, padding); - - GtkWidget * usericon = NULL; - const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); - g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); - if (icon_name != NULL && icon_name[0] != '\0') { - if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) != 0 && g_file_test(icon_name, G_FILE_TEST_EXISTS)) { - gint width, height; - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - - GError * error = NULL; - GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size(icon_name, width, height, &error); - - if (error == NULL) { - usericon = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - } else { - g_warning("Unable to load user icon '%s': %s", icon_name, error->message); - g_error_free(error); - } - } - - if (usericon == NULL) { - GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); - usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); - g_object_unref(gicon); - } - } - if (usericon != NULL) { - gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), usericon, FALSE, FALSE, 0); - gtk_widget_show(usericon); - } - - 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); - - g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(user_property_change), icon); - - return TRUE; -}*/ - -/* 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(INDICATOR_SESSION(io)->menu); -} static void -switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) +switch_property_change (DbusmenuMenuitem * item, + const gchar * property, + GVariant * variant, + gpointer user_data) { if (g_strcmp0(property, MENU_SWITCH_USER) != 0) { return; @@ -545,10 +477,13 @@ switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVarian return; } -//static const gchar * dbusmenu_item_data = "dbusmenu-item"; +static const gchar * dbusmenu_item_data = "dbusmenu-item"; static void -restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) +restart_property_change (DbusmenuMenuitem * item, + const gchar * property, + GVariant * variant, + gpointer user_data) { DbusmenuGtkClient * client = DBUSMENU_GTKCLIENT(user_data); GtkMenuItem * gmi = dbusmenu_gtkclient_menuitem_get(client, item); @@ -571,7 +506,10 @@ restart_property_change (DbusmenuMenuitem * item, const gchar * property, GVaria } static gboolean -build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data) +build_restart_item (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); if (gmi == NULL) { @@ -596,19 +534,27 @@ build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm return TRUE; } - static void -switch_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data) +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)); + 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); + 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) +build_menu_switch (DbusmenuMenuitem * newitem, + DbusmenuMenuitem * parent, + DbusmenuClient * client, + gpointer user_data) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); if (gmi == NULL) { @@ -618,9 +564,17 @@ build_menu_switch (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme 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); + 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; -}*/ +} diff --git a/src/session-service.c b/src/session-service.c index a29fe21..d1b9bb3 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -678,7 +678,9 @@ rebuild_session_items (DbusmenuMenuitem *root, /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); if (shortcut != NULL) { @@ -729,31 +731,53 @@ rebuild_session_items (DbusmenuMenuitem *root, if (can_hibernate && allow_hibernate) { hibernate_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(hibernate_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Hibernate")); + dbusmenu_menuitem_property_set (hibernate_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Hibernate")); dbusmenu_menuitem_child_append(root, hibernate_mi); - g_signal_connect(G_OBJECT(hibernate_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(machine_sleep), "Hibernate"); + g_signal_connect (G_OBJECT(hibernate_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep), "Hibernate"); } restart_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_TYPE, RESTART_ITEM_TYPE); + dbusmenu_menuitem_property_set (restart_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + RESTART_ITEM_TYPE); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart")); } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246")); + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart\342\200\246")); } - dbusmenu_menuitem_property_set_bool(restart_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_restart()); + dbusmenu_menuitem_property_set_bool (restart_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_restart()); dbusmenu_menuitem_child_append(root, restart_mi); - g_signal_connect(G_OBJECT(restart_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart"); + g_signal_connect (G_OBJECT(restart_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "restart"); shutdown_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { - dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down")); + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down")); } else { - dbusmenu_menuitem_property_set(shutdown_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Shut Down\342\200\246")); + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down\342\200\246")); } - dbusmenu_menuitem_property_set_bool(shutdown_mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_shutdown()); - dbusmenu_menuitem_child_append(root, shutdown_mi); - g_signal_connect(G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown"); + dbusmenu_menuitem_property_set_bool (shutdown_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_shutdown()); + dbusmenu_menuitem_child_append (root, shutdown_mi); + g_signal_connect (G_OBJECT(shutdown_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "shutdown"); RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); restart_shutdown_logout_mi->logout_mi = logout_mi; @@ -866,7 +890,6 @@ main (int argc, char ** argv) rebuild_session_items (session_root_menuitem, dbus_interface); - setup_restart_watch(); setup_up(); -- cgit v1.2.3 From b2a247c043866468fd7b898c8e904611fc087388 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 6 Jul 2011 17:55:08 +0100 Subject: tidy up --- src/indicator-session.c | 30 +++++-- src/session-service.c | 221 ++++++++++++++++++++++++++++-------------------- 2 files changed, 151 insertions(+), 100 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 185e184..5c582b4 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -276,6 +276,7 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data) { + g_debug ("new user item called "); GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); gint padding = 0; gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); @@ -356,7 +357,7 @@ user_property_change (DbusmenuMenuitem * item, } -/*static void +static void icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { IndicatorSession * self = INDICATOR_SESSION(user_data); @@ -376,32 +377,45 @@ icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) return; } - indicator_image_helper_update(self->status_image, name); + indicator_image_helper_update(self->users.image, name); return; -}*/ +} static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) { - //IndicatorSession * self = INDICATOR_SESSION(user_data); + IndicatorSession * self = INDICATOR_SESSION (user_data); if (connected) { - /*g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, + g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, - icon_name_get_cb, user_data);*/ + icon_name_get_cb, user_data); } else { - //indicator_image_helper_update(self->status_image, ICON_DEFAULT); + indicator_image_helper_update(self->users.image, ICON_DEFAULT); } return; } +static void +icon_changed (IndicatorSession * session, const gchar * icon_name) +{ + indicator_image_helper_update(session->users.image, icon_name); + return; +} + /* Receives all signals from the service, routed to the appropriate functions */ static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data) { - //IndicatorSession * self = INDICATOR_SESSION(user_data); + IndicatorSession * self = INDICATOR_SESSION(user_data); + + if (g_strcmp0(signal_name, "IconUpdated") == 0) { + const gchar *name; + g_variant_get (parameters, "(&s)", &name); + icon_changed(self, name); + } return; } diff --git a/src/session-service.c b/src/session-service.c index d1b9bb3..ed95080 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -549,12 +549,13 @@ static void rebuild_user_items (DbusmenuMenuitem *root, UsersServiceDbus *service) { - DbusmenuMenuitem *guest_mi = NULL; DbusmenuMenuitem *mi = NULL; - - GList *children; + DbusmenuMenuitem * guest_mi = NULL; + GList *u; + UserData *user; gboolean can_activate; - + gboolean can_lockscreen; + GList *children; /* Make sure we have a valid GConf client, and build one if needed */ @@ -563,103 +564,140 @@ rebuild_user_items (DbusmenuMenuitem *root, /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); /* Remove the old menu items if that makes sense */ children = dbusmenu_menuitem_take_children (root); - g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); - GList *u; - UserData *user; - - GList * users = NULL; - users = users_service_dbus_get_user_list (service); - guint user_count = g_list_length(users); - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - users = g_list_sort (users, (GCompareFunc)compare_users_by_username); - } + /* Lock screen item */ + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); - for (u = users; u != NULL; u = g_list_next (u)) { - user = u->data; - user->service = service; - - if (user->uid == getuid()) { - /* Hide me from the list */ - continue; - } - - 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); - } - /* If we're showing user accounts, keep going through the list */ - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - continue; - } - /* If not, we can stop here */ - break; - } - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - if (user->real_name_conflict) { - gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); - g_free(conflictedname); - } else { - 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); - if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://")); - } else { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); - } - dbusmenu_menuitem_child_append (root, mi); - g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); - user->menuitem = mi; - } + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); + } else { + g_debug("Unable to get lock screen shortcut."); + } + + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), + NULL); + dbusmenu_menuitem_child_append(root, lock_menuitem); } - g_list_free(users); - /* Set to NULL just incase we don't end up building one */ users_service_dbus_set_guest_item(service, NULL); /* Build all of the user switching items */ if (can_activate == TRUE) - { - if (check_guest_session ()) - { - guest_mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session")); - dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); - dbusmenu_menuitem_child_append (root, guest_mi); - g_signal_connect (G_OBJECT (guest_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_guest_session), - service); - users_service_dbus_set_guest_item(service, guest_mi); - } - - if (check_new_session ()) { - switch_menuitem = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (switch_menuitem, + if (can_lockscreen) { + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set_bool (separator1, + DBUSMENU_MENUITEM_PROP_VISIBLE, + TRUE); + dbusmenu_menuitem_property_set (separator1, 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); - } - } + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append (root, separator1); + } + + if (check_guest_session ()) + { + guest_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set_bool (guest_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + TRUE); + dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session")); + dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); + dbusmenu_menuitem_child_append (root, guest_mi); + g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), service); + users_service_dbus_set_guest_item(service, guest_mi); + } + + if (check_new_session ()) + { + + 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()); + 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); + } + + GList * users = NULL; + users = users_service_dbus_get_user_list (service); + guint user_count = g_list_length(users); + + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + } + + for (u = users; u != NULL; u = g_list_next (u)) { + user = u->data; + user->service = service; + + if (user->uid == getuid()) { + /* Hide me from the list */ + continue; + } + + 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); + } + /* If we're showing user accounts, keep going through the list */ + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + continue; + } + /* If not, we can stop here */ + break; + } + + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + if (user->real_name_conflict) { + gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); + g_free(conflictedname); + } else { + 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); + if (user->icon_url != NULL && user->icon_url[0] != '\0' && g_str_has_prefix(user->icon_url, "file://")) { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_url + strlen("file://")); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } + dbusmenu_menuitem_child_append (root, mi); + g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); + user->menuitem = mi; + } + } + + g_list_free(users); + } + + /* If there were a bunch of items before us, we need a + separator. */ + if (can_lockscreen || can_activate) { + DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append(root, separator); + } } static void @@ -890,14 +928,12 @@ main (int argc, char ** argv) rebuild_session_items (session_root_menuitem, dbus_interface); - setup_restart_watch(); - - setup_up(); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, session_root_menuitem); users_root_menuitem = dbusmenu_menuitem_new(); + rebuild_user_items (users_root_menuitem, dbus_interface); g_signal_connect (G_OBJECT (dbus_interface), "user-added", G_CALLBACK (user_change), @@ -906,15 +942,16 @@ main (int argc, char ** argv) "user-removed", G_CALLBACK (user_change), users_root_menuitem); - - rebuild_user_items (users_root_menuitem, dbus_interface); - DbusmenuServer * users_server = dbusmenu_server_new(INDICATOR_USERS_DBUS_OBJECT); + setup_restart_watch(); + setup_up(); + + DbusmenuServer * users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); dbusmenu_server_set_root (users_server, users_root_menuitem); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); - + return 0; } -- cgit v1.2.3 From 052462b2e3ee1b6104115f6f8c161a11bc8a980d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Jul 2011 12:18:59 -0500 Subject: Remvoing unused result --- src/users-service-dbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 11ee497..07a81b1 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -586,7 +586,6 @@ seat_proxy_session_added (DBusGProxy *seat_proxy, g_return_if_fail(IS_USERS_SERVICE_DBUS(service)); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service); uid_t uid; - gboolean res; struct passwd *pwent; UserData *user; @@ -621,7 +620,7 @@ seat_proxy_session_added (DBusGProxy *seat_proxy, return; } - res = do_add_session (service, user, session_id); + do_add_session (service, user, session_id); } static void -- cgit v1.2.3 From 097f3b178651f6f8dc8d5759abd65cfa8cf0554a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 6 Jul 2011 13:12:35 -0500 Subject: Making sure that users has the same dbus name as session as there is one process. --- src/dbus-shared-names.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index f97dddc..fd19e5f 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -24,12 +24,7 @@ with this program. If not, see . #ifndef __DBUS_SHARED_NAMES_H__ #define __DBUS_SHARED_NAMES_H__ 1 -#define INDICATOR_STATUS_DBUS_NAME "com.canonical.indicator.status" -#define INDICATOR_STATUS_DBUS_OBJECT "/com/canonical/indicator/status/menu" -#define INDICATOR_STATUS_SERVICE_DBUS_OBJECT "/com/canonical/indicator/status/service" -#define INDICATOR_STATUS_SERVICE_DBUS_INTERFACE "com.canonical.indicator.status.service" - -#define INDICATOR_USERS_DBUS_NAME "com.canonical.indicator.users" +#define INDICATOR_USERS_DBUS_NAME INDICATOR_SESSION_DBUS_NAME #define INDICATOR_USERS_DBUS_OBJECT "/com/canonical/indicator/users/menu" #define INDICATOR_USERS_SERVICE_DBUS_OBJECT "/org/gnome/DisplayManager/UserManager" #define INDICATOR_USERS_SERVICE_DBUS_INTERFACE "org.gnome.DisplayManager.UserManager" -- cgit v1.2.3 From c79e4167d0fa73fc20b008ec428142bb00f44507 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 7 Jul 2011 11:42:24 +0100 Subject: icon now being shown on the panel for devices --- src/indicator-session.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 5c582b4..0bb782d 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -133,20 +133,22 @@ indicator_session_init (IndicatorSession *self) // users self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); - self->users.label = GTK_LABEL (gtk_label_new ("Users")); + self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); // devices self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); - self->devices.label = GTK_LABEL (gtk_label_new ("Devices")); + self->devices.image = indicator_image_helper (ICON_DEFAULT); gtk_widget_show (GTK_WIDGET(self->devices.menu)); - gtk_widget_show (GTK_WIDGET(self->devices.label)); - gtk_widget_show (GTK_WIDGET(self->users.label)); + gtk_widget_show (GTK_WIDGET(self->devices.image)); + gtk_widget_show (GTK_WIDGET(self->users.image)); gtk_widget_show (GTK_WIDGET(self->users.menu)); g_object_ref (self->users.menu); + g_object_ref (self->users.image); g_object_ref (self->devices.menu); + g_object_ref (self->devices.image); // Setup the handlers for users DbusmenuClient * users_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); -- cgit v1.2.3 From b59889fbafb30da9db8178b541581716ebf5008f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 7 Jul 2011 14:07:59 +0100 Subject: added the username to the panel --- src/indicator-session.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 0bb782d..51c15a4 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -86,12 +86,13 @@ static gboolean new_user_item (DbusmenuMenuitem * newitem, static void user_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, - gpointer user_data); - + gpointer user_data); static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static void indicator_session_update_users_label (IndicatorSession* self, + GVariant * variant); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -104,7 +105,7 @@ static GList* indicator_session_get_entries (IndicatorObject* obj); G_DEFINE_TYPE (IndicatorSession, indicator_session, INDICATOR_OBJECT_TYPE); -static void +static void indicator_session_class_init (IndicatorSessionClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -134,6 +135,9 @@ indicator_session_init (IndicatorSession *self) self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); + self->users.label = GTK_LABEL (gtk_label_new (NULL)); + // Only show once we have a valid username + gtk_widget_hide (GTK_WIDGET(self->users.label)); // devices self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, @@ -153,7 +157,7 @@ indicator_session_init (IndicatorSession *self) // Setup the handlers for users DbusmenuClient * users_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); dbusmenu_client_add_type_handler(users_client, USER_ITEM_TYPE, new_user_item); - dbusmenu_client_add_type_handler(users_client, MENU_SWITCH_TYPE, build_menu_switch); + dbusmenu_client_add_type_handler_full (users_client, MENU_SWITCH_TYPE, build_menu_switch, self, NULL); // Setup the handlers for devices DbusmenuClient * devices_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->devices.menu))); @@ -576,7 +580,10 @@ build_menu_switch (DbusmenuMenuitem * newitem, if (gmi == NULL) { return FALSE; } - g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); + + IndicatorSession* self = INDICATOR_SESSION (user_data); + + g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); @@ -588,9 +595,37 @@ build_menu_switch (DbusmenuMenuitem * newitem, "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); + + indicator_session_update_users_label (self, + dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER)); + + return TRUE; +} - return TRUE; +static void +indicator_session_update_users_label (IndicatorSession* self, + GVariant * variant) +{ + const gchar* username = NULL; + if (g_variant_get_string(variant, NULL) == NULL || + g_variant_get_string(variant, NULL)[0] == '\0'){ + // Get out of here - no valid username to display + return; + } + + username = g_variant_get_string(variant, NULL); + // Just in case protect again. + if (username != NULL) { + g_debug ("Updating username label"); + gtk_label_set_text (self->users.label, username); + gtk_widget_show(GTK_WIDGET(self->users.label)); + } + else { + gtk_widget_hide(GTK_WIDGET(self->users.label)); + } } + -- cgit v1.2.3 From 6721214222e040c718da1c417cdbd8d3489c855d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 7 Jul 2011 14:31:39 +0100 Subject: user label is now updated dynamically --- src/indicator-session.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 51c15a4..729b838 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -450,7 +450,13 @@ switch_property_change (DbusmenuMenuitem * item, if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { finalstring = _("Switch User..."); set_ellipsize = FALSE; + indicator_session_update_users_label (INDICATOR_SESSION (user_data), + NULL); } + else{ + indicator_session_update_users_label (INDICATOR_SESSION (user_data), + variant); + } if (finalstring == NULL) { const gchar * username = g_variant_get_string(variant, NULL); @@ -481,8 +487,8 @@ switch_property_change (DbusmenuMenuitem * item, } else { set_ellipsize = FALSE; } + } - gtk_menu_item_set_label(gmi, finalstring); GtkLabel * label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(gmi))); @@ -611,13 +617,15 @@ indicator_session_update_users_label (IndicatorSession* self, GVariant * variant) { const gchar* username = NULL; - if (g_variant_get_string(variant, NULL) == NULL || + if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0'){ - // Get out of here - no valid username to display + // either way set the user label to blank + gtk_label_set_text (self->users.label, ""); return; } username = g_variant_get_string(variant, NULL); + // Just in case protect again. if (username != NULL) { g_debug ("Updating username label"); -- cgit v1.2.3 From 4f535763d9e05e41c81b1a8fbf262aea1246f616 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 7 Jul 2011 17:46:00 +0100 Subject: icon updates for the user menu panel --- src/dbus-shared-names.h | 2 +- src/indicator-session.c | 119 ++++++++++++++++++++++++------------------------ src/session-service.c | 5 +- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index fd19e5f..b69c6ad 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -40,7 +40,7 @@ with this program. If not, see . #define USER_ITEM_PROP_NAME "user-item-name" #define USER_ITEM_PROP_LOGGED_IN "user-item-logged-in" #define USER_ITEM_PROP_ICON "user-item-icon-path" -#define USER_ITEM_ICON_DEFAULT "default-icon" +#define USER_ITEM_ICON_DEFAULT "user-offline" #define RESTART_ITEM_TYPE "x-canonical-restart-item" #define RESTART_ITEM_LABEL "restart-label" diff --git a/src/indicator-session.c b/src/indicator-session.c index 729b838..23d7f37 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -362,7 +362,6 @@ user_property_change (DbusmenuMenuitem * item, return; } - static void icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { @@ -396,10 +395,11 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, icon_name_get_cb, user_data); - } else { - indicator_image_helper_update(self->users.image, ICON_DEFAULT); } - + else { + indicator_image_helper_update (self->users.image, + USER_ITEM_ICON_DEFAULT); + } return; } @@ -412,8 +412,11 @@ icon_changed (IndicatorSession * session, const gchar * icon_name) /* Receives all signals from the service, routed to the appropriate functions */ static void -receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, - GVariant * parameters, gpointer user_data) +receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data) { IndicatorSession * self = INDICATOR_SESSION(user_data); @@ -422,83 +425,81 @@ receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, g_variant_get (parameters, "(&s)", &name); icon_changed(self, name); } - return; } - static void switch_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, gpointer user_data) { - if (g_strcmp0(property, MENU_SWITCH_USER) != 0) { - return; - } + 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; - } + 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; + } - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { - finalstring = _("Switch User..."); - set_ellipsize = FALSE; + if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { + finalstring = _("Switch User..."); + set_ellipsize = FALSE; indicator_session_update_users_label (INDICATOR_SESSION (user_data), NULL); - } + } else{ indicator_session_update_users_label (INDICATOR_SESSION (user_data), variant); } - if (finalstring == NULL) { - const gchar * username = g_variant_get_string(variant, NULL); - GtkStyle * style = gtk_widget_get_style(GTK_WIDGET(gmi)); + 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); + 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 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); + 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 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); + 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; - } + 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); - } - } + } + 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; } @@ -628,7 +629,7 @@ indicator_session_update_users_label (IndicatorSession* self, // Just in case protect again. if (username != NULL) { - g_debug ("Updating username label"); + g_debug ("Updating username label "); gtk_label_set_text (self->users.label, username); gtk_widget_show(GTK_WIDGET(self->users.label)); } diff --git a/src/session-service.c b/src/session-service.c index ed95080..9cd7800 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -627,10 +627,9 @@ rebuild_user_items (DbusmenuMenuitem *root, if (check_new_session ()) { - 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()); + 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 1f2a83323b5fa9c46c581d5a08be9798691e6e71 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Thu, 7 Jul 2011 14:52:05 -0400 Subject: setting to UNRELEASED --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 64dd44b..790a3c6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-session (0.2.92-0ubuntu1~ppa1) oneiric; urgency=low +indicator-session (0.2.92-0ubuntu1) UNRELEASED; urgency=low * New upstream release. (0.2.91) * Integrates with LightDM now -- cgit v1.2.3 From 8560474e28215aabd0d1dfa99e6e93656af7b9e7 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Thu, 7 Jul 2011 15:31:59 -0400 Subject: releasing version 0.2.92-0ubuntu1 --- debian/changelog | 9 +++++++-- debian/control | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 790a3c6..85ef594 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ -indicator-session (0.2.92-0ubuntu1) UNRELEASED; urgency=low +indicator-session (0.2.92-0ubuntu1) oneiric; urgency=low + [ Ted Gould ] * New upstream release. (0.2.91) * Integrates with LightDM now * Moved to libindicator 0.4 @@ -7,7 +8,11 @@ indicator-session (0.2.92-0ubuntu1) UNRELEASED; urgency=low * Fixed dist'ing the XML files * debian/control: Move suggests from gdm to lightdm - -- Ted Gould Thu, 07 Jul 2011 11:29:48 -0500 + [ Ken VanDine ] + * debian/control + - bumped build depends for libindicator to >= 0.3.90 + + -- Ken VanDine Thu, 07 Jul 2011 14:59:44 -0400 indicator-session (0.2.90-0ubuntu3) oneiric; urgency=low diff --git a/debian/control b/debian/control index a5cb161..4f2d296 100644 --- a/debian/control +++ b/debian/control @@ -9,8 +9,8 @@ Build-Depends: debhelper (>= 5.0), libgconf2-dev, libdbus-glib-1-dev, gnome-doc-utils, - libindicator-dev (>= 0.3.19), - libindicator3-dev (>= 0.3.19), + libindicator-dev (>= 0.3.90), + libindicator3-dev (>= 0.3.90), libdbusmenu-glib-dev (>= 0.3.90), libdbusmenu-gtk-dev (>= 0.3.94), libdbusmenu-gtk3-dev (>= 0.3.94), -- cgit v1.2.3 From c596a941fd9dd70a49f5eb541ffe33d4e5bc7f53 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Fri, 8 Jul 2011 15:01:04 +0800 Subject: Keep Log Out / Restart / Shut Down dialogs on top (LP: #807357) --- src/dialog.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dialog.c b/src/dialog.c index 9633224..d38f8bf 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -183,6 +183,8 @@ logout_dialog_new (LogoutDialogType type) "text", _(body_strings[type]), NULL)); + gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE); + gboolean allowed = FALSE; if (type == LOGOUT_DIALOG_TYPE_LOG_OUT) { allowed = ck_check_allowed(LOGOUT_DIALOG_TYPE_RESTART); -- cgit v1.2.3 From 4d959cd5b8477c86b92a1c2217037e5889d74ad9 Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Fri, 8 Jul 2011 11:53:21 +0200 Subject: releasing version 0.2.92-0ubuntu2 --- debian/changelog | 6 ++++++ src/session-service.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 85ef594..5b7f595 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +indicator-session (0.2.92-0ubuntu2) oneiric; urgency=low + + * src/session-service.c: drop g_debug leftover which broke the build + + -- Sebastien Bacher Fri, 08 Jul 2011 11:52:43 +0200 + indicator-session (0.2.92-0ubuntu1) oneiric; urgency=low [ Ted Gould ] diff --git a/src/session-service.c b/src/session-service.c index dfc3805..6c57274 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -589,7 +589,6 @@ rebuild_items (DbusmenuMenuitem *root, /* Hide me from the list */ continue; } - g_debug ("%li %s", user->uid, user->user_name); if (g_strcmp0(user->user_name, "guest") == 0) { /* Check to see if the guest has sessions and so therefore should -- cgit v1.2.3 From 8ab26b1cd3f1a5e67c6f06adf59d3de8c9bb14d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 9 Jul 2011 05:42:45 +0200 Subject: Get support for gtk+2.0 back indicator-session can still be compiled with gtk, using the --with-gtk=2 configure flag (I've changed it to match the other indicators). --- configure.ac | 45 +++++++++++++++++++++++++++++++-------------- src/session-service.c | 6 ++++++ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 4f2cb04..f3a9039 100644 --- a/configure.ac +++ b/configure.ac @@ -31,18 +31,18 @@ INDICATOR_REQUIRED_VERSION=0.3.19 DBUSMENUGTK_REQUIRED_VERSION=0.3.91 POLKIT_REQUIRED_VERSION=0.92 -AC_ARG_WITH([indicator-gtk], - [AS_HELP_STRING([--with-indicator-gtk], +AC_ARG_WITH([gtk], + [AS_HELP_STRING([--with-gtk], [Which version of gtk to use for the indicator @<:@default=3@:>@])], [], - [with_indicator_gtk=3]) + [with_gtk=3]) -AS_IF([test "x$with_indicator_gtk" = x3], +AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK3_REQUIRED_VERSION indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) ], - [test "x$with_indicator_gtk" = x2], + [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION indicator-0.4 >= $INDICATOR_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) @@ -54,17 +54,34 @@ AC_SUBST(APPLET_LIBS) DBUSMENUGLIB_REQUIRED_VERSION=0.1.1 -PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - dbus-glib-1 - gio-unix-2.0 - indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gio-unix-2.0 + indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + dbus-glib-1 + gio-unix-2.0 + indicator-0.4 >= $INDICATOR_REQUIRED_VERSION) + ] +) AC_SUBST(SESSIONERVICE_CFLAGS) AC_SUBST(SESSIONERVICE_LIBS) -PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-3.0 >= $GTK3_REQUIRED_VERSION - polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) +AS_IF([test "x$with_gtk" = x3], + [PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-3.0 >= $GTK3_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) + ], + [test "x$with_gtk" = x2], + [PKG_CHECK_MODULES(GTKLOGOUTHELPER, gtk+-2.0 >= $GTK_REQUIRED_VERSION + polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) + ] +) AC_SUBST(GTKLOGOUTHELPER_CFLAGS) @@ -94,7 +111,7 @@ AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all if test "x$with_localinstall" = "xyes"; then INDICATORDIR="${libdir}/indicators/2/" INDICATORICONSDIR="${datadir}/indicator-applet/icons/" -elif test "x$with_indicator_gtk" = x2; then +elif test "x$with_gtk" = x2; then INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator-0.4` INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator-0.4` else @@ -179,5 +196,5 @@ AC_MSG_NOTICE([ SUS Indicator Configuration: Prefix: $prefix - Indicator GTK: $with_indicator_gtk + Indicator GTK: $with_gtk ]) diff --git a/src/session-service.c b/src/session-service.c index dfc3805..424a3ac 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -36,7 +36,13 @@ with this program. If not, see . #include #include #include + +#include +#if GTK_CHECK_VERSION(3, 0, 0) #include +#else +#include +#endif #include -- cgit v1.2.3 From ff7cd22d1cc2ff22dc35dc7c0e513bd3423020ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 9 Jul 2011 05:57:42 +0200 Subject: configure.ac: include the indicator dir in output --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index f3a9039..c03639e 100644 --- a/configure.ac +++ b/configure.ac @@ -196,5 +196,6 @@ AC_MSG_NOTICE([ SUS Indicator Configuration: Prefix: $prefix + Indicator Dir: $INDICATORDIR Indicator GTK: $with_gtk ]) -- cgit v1.2.3 From befcd5ef6df74dc2c7c308b83335103597ee6f3c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 11 Jul 2011 12:13:50 +0100 Subject: tidied user menu --- src/session-service.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index 1c59bce..ab80bfd 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -510,7 +510,6 @@ rebuild_user_items (DbusmenuMenuitem *root, GList *u; UserData *user; gboolean can_activate; - gboolean can_lockscreen; GList *children; /* Make sure we have a valid GConf client, and build one @@ -520,20 +519,12 @@ rebuild_user_items (DbusmenuMenuitem *root, /* Check to see which menu items we're allowed to have */ can_activate = users_service_dbus_can_activate_session (service) && !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); - can_lockscreen = !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); /* Remove the old menu items if that makes sense */ children = dbusmenu_menuitem_take_children (root); g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); - /* Lock screen item */ - if (can_lockscreen) { - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (lock_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Lock Screen")); - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); if (shortcut != NULL) { g_debug("Lock screen shortcut: %s", shortcut); @@ -543,30 +534,12 @@ rebuild_user_items (DbusmenuMenuitem *root, g_debug("Unable to get lock screen shortcut."); } - g_signal_connect (G_OBJECT(lock_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(lock_screen), - NULL); - dbusmenu_menuitem_child_append(root, lock_menuitem); - } - /* Set to NULL just incase we don't end up building one */ users_service_dbus_set_guest_item(service, NULL); /* Build all of the user switching items */ if (can_activate == TRUE) { - if (can_lockscreen) { - DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set_bool (separator1, - DBUSMENU_MENUITEM_PROP_VISIBLE, - TRUE); - dbusmenu_menuitem_property_set (separator1, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append (root, separator1); - } - if (check_guest_session ()) { guest_mi = dbusmenu_menuitem_new (); @@ -646,14 +619,6 @@ rebuild_user_items (DbusmenuMenuitem *root, g_list_free(users); } - - /* If there were a bunch of items before us, we need a - separator. */ - if (can_lockscreen || can_activate) { - DbusmenuMenuitem * separator = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append(root, separator); - } } static void -- cgit v1.2.3 From 2d5bc28e81e87cb9a75644fd863ebc7ecb84c76c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 11 Jul 2011 15:00:23 +0100 Subject: user account items shown, items rearranged --- src/session-service.c | 216 ++++++++++++++++---------------------------------- 1 file changed, 69 insertions(+), 147 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index ab80bfd..590778c 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -391,32 +391,6 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) return; } -/* Checks to see if we should show the guest session item */ -static gboolean -check_guest_session (void) -{ - if (geteuid() < 500) { - /* System users shouldn't have guest account shown. Mosly - this would be the case of the guest user itself. */ - return FALSE; - } - // FIXME: Ask DisplayManager - - return TRUE; -} - -/* Called when someone clicks on the guest session item. */ -static void -activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) -{ - lock_if_possible(); - - if (!users_service_dbus_activate_guest_session(USERS_SERVICE_DBUS(user_data))) - g_warning("Unable to activate guest session"); - - return; -} - /* Checks to see if we can create sessions */ static gboolean check_new_session (void) @@ -467,46 +441,13 @@ compare_users_by_username (const gchar *a, return retval; } -/* Take a desktop file and execute it */ -/*static void -desktop_activate_cb (DbusmenuMenuitem * mi, guint timestamp, gpointer data) -{ - GAppInfo * appinfo = G_APP_INFO(data); - g_return_if_fail(appinfo != NULL); - g_app_info_launch(appinfo, NULL, NULL, NULL); - return; -}*/ - -/* Look at the GAppInfo structures and sort based on - the application names */ -/*static gint -sort_app_infos (gconstpointer a, gconstpointer b) -{ - GAppInfo * appa = G_APP_INFO(a); - GAppInfo * appb = G_APP_INFO(b); - - const gchar * namea = NULL; - const gchar * nameb = NULL; - - if (appa != NULL) { - namea = g_app_info_get_name(appa); - } - - if (appb != NULL) { - nameb = g_app_info_get_name(appb); - } - - return g_strcmp0(namea, nameb); -}*/ - /* Builds up the menu for us */ - static void rebuild_user_items (DbusmenuMenuitem *root, UsersServiceDbus *service) { DbusmenuMenuitem *mi = NULL; - DbusmenuMenuitem * guest_mi = NULL; + DbusmenuMenuitem *guest_mi = NULL; GList *u; UserData *user; gboolean can_activate; @@ -525,100 +466,81 @@ rebuild_user_items (DbusmenuMenuitem *root, g_list_foreach (children, (GFunc)g_object_unref, NULL); g_list_free (children); - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); - if (shortcut != NULL) { - g_debug("Lock screen shortcut: %s", shortcut); - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); - g_free(shortcut); - } else { - g_debug("Unable to get lock screen shortcut."); - } - /* Set to NULL just incase we don't end up building one */ users_service_dbus_set_guest_item(service, NULL); /* Build all of the user switching items */ if (can_activate == TRUE) - { - if (check_guest_session ()) - { - guest_mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set_bool (guest_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - TRUE); - dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - dbusmenu_menuitem_property_set (guest_mi, USER_ITEM_PROP_NAME, _("Guest Session")); - dbusmenu_menuitem_property_set_bool (guest_mi, USER_ITEM_PROP_LOGGED_IN, FALSE); - dbusmenu_menuitem_child_append (root, guest_mi); - g_signal_connect (G_OBJECT (guest_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), service); - users_service_dbus_set_guest_item(service, guest_mi); + { + if (check_new_session ()){ + 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()); + dbusmenu_menuitem_child_append (root, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_new_session), + service); + } + + GList * users = NULL; + users = users_service_dbus_get_user_list (service); + guint user_count = g_list_length(users); + + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + } + + for (u = users; u != NULL; u = g_list_next (u)) { + user = u->data; + user->service = service; + + g_debug ("%i %s", (gint)user->uid, user->user_name); + + 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); } - - if (check_new_session ()) - { - 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()); - dbusmenu_menuitem_child_append (root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), service); + /* If we're showing user accounts, keep going through the list */ + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + continue; } - - GList * users = NULL; - users = users_service_dbus_get_user_list (service); - guint user_count = g_list_length(users); - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - users = g_list_sort (users, (GCompareFunc)compare_users_by_username); - } - - for (u = users; u != NULL; u = g_list_next (u)) { - user = u->data; - user->service = service; - - if (user->uid == getuid()) { - /* Hide me from the list */ - continue; - } - g_debug ("%i %s", (gint)user->uid, user->user_name); - - 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); - } - /* If we're showing user accounts, keep going through the list */ - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - continue; - } - /* If not, we can stop here */ - break; - } - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - if (user->real_name_conflict) { - gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); - g_free(conflictedname); - } else { - 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); - if (user->icon_file != NULL && user->icon_file[0] != '\0') { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); - } else { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); - } - dbusmenu_menuitem_child_append (root, mi); - g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_user_session), user); - user->menuitem = mi; - } - } - - g_list_free(users); - } + /* If not, we can stop here */ + break; + } + + if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + if (user->real_name_conflict) { + gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); + g_free(conflictedname); + } else { + 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); + if (user->icon_file != NULL && user->icon_file[0] != '\0') { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } + dbusmenu_menuitem_child_append (root, mi); + g_signal_connect (G_OBJECT (mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_user_session), + user); + user->menuitem = mi; + } + } + g_list_free(users); + } } static void -- cgit v1.2.3 From 0e39b3235ecebf14936ef64d77f4e376d3f852ba Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 11 Jul 2011 17:14:57 +0100 Subject: online accounts item added@ --- src/session-service.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/session-service.c b/src/session-service.c index 590778c..001d0e6 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -102,6 +102,7 @@ static GConfClient * gconf_client = NULL; static void rebuild_session_items (DbusmenuMenuitem *root, UsersServiceDbus *service); static void rebuild_user_items (DbusmenuMenuitem *root, UsersServiceDbus *service); +static void activate_online_accounts (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data); static void lockdown_changed (GConfClient *client, @@ -541,6 +542,42 @@ rebuild_user_items (DbusmenuMenuitem *root, } g_list_free(users); } + // Add the online accounts and separator + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator1, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append (root, separator1); + DbusmenuMenuitem * online_accounts_item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_DEFAULT); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Online Accounts...")); + + g_signal_connect (G_OBJECT (online_accounts_item), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_online_accounts), + NULL); + + dbusmenu_menuitem_child_append (root, online_accounts_item); +} + +// TODO +// Wait until dialog is complete to find out name to pass +// to the control centre. +static void +activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-control-center", &error)) + { + g_warning("Unable to show control centre: %s", error->message); + g_error_free(error); + } } static void -- cgit v1.2.3 From 4998457e8fe3d6cd90cd6f651eb9d7392138dd87 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 12 Jul 2011 16:03:02 +0100 Subject: the beginnings of the custom user item --- src/Makefile.am | 2 + src/indicator-session.c | 38 ++++-- src/session-service.c | 5 +- src/user-widget.c | 303 ++++++++++++++++++++++++++++++++++++++++++++++++ src/user-widget.h | 54 +++++++++ 5 files changed, 389 insertions(+), 13 deletions(-) create mode 100644 src/user-widget.c create mode 100644 src/user-widget.h diff --git a/src/Makefile.am b/src/Makefile.am index df0ec0f..71537c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,8 @@ libsession_la_SOURCES = \ gen-session-dbus.xml.h \ dbus-shared-names.h \ dbusmenu-shared.h \ + user-widget.c \ + user-widget.h \ accounts-service-client.h \ accounts-service-user-client.h libsession_la_CFLAGS = \ diff --git a/src/indicator-session.c b/src/indicator-session.c index 23d7f37..35a55e0 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -44,6 +44,7 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "dbusmenu-shared.h" +#include "user-widget.h" #define INDICATOR_SESSION_TYPE (indicator_session_get_type ()) #define INDICATOR_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_SESSION_TYPE, IndicatorSession)) @@ -83,10 +84,6 @@ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); -static void user_property_change (DbusmenuMenuitem * item, - const gchar * property, - GVariant * variant, - gpointer user_data); static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, @@ -282,7 +279,25 @@ new_user_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data) { - g_debug ("new user item called "); + + + GtkWidget* user_item = NULL; + + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + + user_item = user_widget_new(newitem); + + GtkMenuItem *user_widget = GTK_MENU_ITEM(user_item); + + gtk_widget_show_all (user_item); + dbusmenu_gtkclient_newitem_base (DBUSMENU_GTKCLIENT(client), + newitem, + user_widget, + parent); + return TRUE; + + /*g_debug ("new user item called "); GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); gint padding = 0; gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); @@ -320,12 +335,14 @@ new_user_item (DbusmenuMenuitem * newitem, gtk_widget_show(usericon); } - GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME)); + 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); + 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)) { @@ -344,9 +361,10 @@ new_user_item (DbusmenuMenuitem * newitem, G_CALLBACK(user_property_change), icon); return TRUE; + */ } -static void +/*static void user_property_change (DbusmenuMenuitem * item, const gchar * property, GVariant * variant, @@ -360,7 +378,7 @@ user_property_change (DbusmenuMenuitem * item, } } return; -} +}*/ static void icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) @@ -382,7 +400,7 @@ icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) return; } - indicator_image_helper_update(self->users.image, name); + //indicator_image_helper_update(self->users.image, name); return; } diff --git a/src/session-service.c b/src/session-service.c index 001d0e6..fb5c7a9 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -759,7 +759,6 @@ restart_dir_changed (void) session_dbus_set_name(session_dbus, ICON_DEFAULT); } } - return; } @@ -794,8 +793,8 @@ main (int argc, char ** argv) IndicatorService * service = indicator_service_new_version(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); g_signal_connect(G_OBJECT(service), - INDICATOR_SERVICE_SIGNAL_SHUTDOWN, - G_CALLBACK(service_shutdown), NULL); + INDICATOR_SERVICE_SIGNAL_SHUTDOWN, + G_CALLBACK(service_shutdown), NULL); session_dbus = session_dbus_new(); diff --git a/src/user-widget.c b/src/user-widget.c new file mode 100644 index 0000000..bd6634a --- /dev/null +++ b/src/user-widget.c @@ -0,0 +1,303 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include "user-widget.h" + +typedef struct _UserWidgetPrivate UserWidgetPrivate; + +struct _UserWidgetPrivate +{ + DbusmenuMenuitem* twin_item; + GtkWidget* user_image; + GtkWidget* user_name; + gboolean logged_in; + gboolean sessions_active; +}; + +#define USER_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USER_WIDGET_TYPE, UserWidgetPrivate)) + +/* Prototypes */ +static void user_widget_class_init (UserWidgetClass *klass); +static void user_widget_init (UserWidget *self); +static void user_widget_dispose (GObject *object); +static void user_widget_finalize (GObject *object); + +static void user_widget_set_twin_item (UserWidget* self, + DbusmenuMenuitem* twin_item); +// keyevent consumers +static gboolean user_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event); +// Dbusmenuitem properties update callback +static void user_widget_property_update (DbusmenuMenuitem* item, + gchar* property, + GVariant* value, + gpointer userdata); +#if GTK_CHECK_VERSION(3, 0, 0) +static gboolean user_widget_primitive_draw_cb_gtk_3 (GtkWidget *image, + cairo_t* cr, + gpointer user_data); +#else +static gboolean user_widget_primitive_draw_cb (GtkWidget *image, + GdkEventExpose *event, + gpointer user_data); +#endif + +G_DEFINE_TYPE (UserWidget, user_widget, GTK_TYPE_MENU_ITEM); + +static void +user_widget_class_init (UserWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->button_release_event = user_widget_button_release_event; + + g_type_class_add_private (klass, sizeof (UserWidgetPrivate)); + + gobject_class->dispose = user_widget_dispose; + gobject_class->finalize = user_widget_finalize; +} + +static void +user_widget_init (UserWidget *self) +{ + UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(self); + priv->user_image = NULL; + priv->user_name = NULL; + priv->logged_in = FALSE; + priv->sessions_active = FALSE; + + priv->user_image = gtk_image_new (); + + // Just for now set the image to the default avator image + GdkPixbuf* pixbuf = NULL; + GError* error = NULL; + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "avatar-default", + 12, + GTK_ICON_LOOKUP_FORCE_SIZE, + &error); + + if (pixbuf == NULL || error != NULL) { + g_warning ("Could not load the default avatar image for some reason"); + } + else{ + gtk_image_set_from_pixbuf (GTK_IMAGE(priv->user_image), pixbuf); + g_object_unref (pixbuf); + } + + priv->user_name = gtk_label_new (""); + + #if GTK_CHECK_VERSION(3, 0, 0) + g_signal_connect_after (GTK_WIDGET(self), "draw", + G_CALLBACK(user_widget_primitive_draw_cb_gtk_3), + GTK_WIDGET(self)); + #else + g_signal_connect_after (GTK_WIDGET(self), "expose-event", + G_CALLBACK(user_widget_primitive_draw_cb), + GTK_WIDGET(self)); + #endif +} + +static void +user_widget_dispose (GObject *object) +{ + //UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(USER_WIDGET(object)); + + G_OBJECT_CLASS (user_widget_parent_class)->dispose (object); +} + +// TODO tidy up image and name +static void +user_widget_finalize (GObject *object) +{ + G_OBJECT_CLASS (user_widget_parent_class)->finalize (object); +} + +/** + * We override the expose method to enable primitive drawing of the + * empty album art image and rounded rectangles on the album art. + */ + +#if GTK_CHECK_VERSION(3, 0, 0) + +// Draw the triangle if the player is running ... +static gboolean +user_widget_primitive_draw_cb_gtk_3 (GtkWidget *widget, + cairo_t* cr, + gpointer user_data) +{ + /* + g_return_val_if_fail(IS_USER_WIDGET(user_data), FALSE); + UserWidget* meta = USER_WIDGET(user_data); + UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(meta); + + GtkStyle *style; + int x, y, arrow_width, arrow_height; + + gint offset = 3; + arrow_width = 5; + arrow_height = 9; + + style = gtk_widget_get_style (widget); + + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = 0; + + // Draw player icon + if (priv->icon_buf != NULL){ + gdk_cairo_set_source_pixbuf (cr, + priv->icon_buf, + x + arrow_width + 1, + y + offset); + cairo_paint (cr); + } + + // Draw triangle but only if the player is running. + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ + y += (double)arrow_height/2.0 + offset; + cairo_set_line_width (cr, 1.0); + + //g_debug ("triangle drawing"); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + }*/ + + return FALSE; +} + +// GTK 2 Expose handler +#else + +// Draw the triangle if the player is running ... +static gboolean +user_widget_primitive_draw_cb (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data) +{ + /* + g_return_val_if_fail(IS_USER_WIDGET(user_data), FALSE); + UserWidget* meta = USER_WIDGET(user_data); + UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(meta); + + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + gint offset = 3; + arrow_width = 5; + arrow_height = 9; + + style = gtk_widget_get_style (widget); + + cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget)); + + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; + + // Draw player icon + if (priv->icon_buf != NULL){ + gdk_cairo_set_source_pixbuf (cr, + priv->icon_buf, + x + arrow_width + 1, + y + offset); + cairo_paint (cr); + } + + // Draw triangle but only if the player is running. + if (dbusmenu_menuitem_property_get_bool (priv->twin_item, + DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ + y += (double)arrow_height/2.0 + offset; + cairo_set_line_width (cr, 1.0); + + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + } + + cairo_destroy (cr);*/ + return FALSE; +} +#endif + + +/* Suppress/consume keyevents */ +static gboolean +user_widget_button_release_event (GtkWidget *menuitem, + GdkEventButton *event) +{ + return FALSE; +} + +static void +user_widget_property_update (DbusmenuMenuitem* item, gchar* property, + GVariant* value, gpointer userdata) +{ + g_return_if_fail (IS_USER_WIDGET (userdata)); + +} + + +static void +user_widget_set_twin_item (UserWidget* self, + DbusmenuMenuitem* twin_item) +{ + UserWidgetPrivate* priv = USER_WIDGET_GET_PRIVATE(self); + priv->twin_item = twin_item; + g_signal_connect( G_OBJECT(priv->twin_item), "property-changed", + G_CALLBACK(user_widget_property_update), self); + +} + + /** + * transport_new: + * @returns: a new #UserWidget. + **/ +GtkWidget* +user_widget_new(DbusmenuMenuitem *item) +{ + GtkWidget* widget = g_object_new(USER_WIDGET_TYPE, NULL); + user_widget_set_twin_item ( USER_WIDGET(widget), item ); + return widget; +} diff --git a/src/user-widget.h b/src/user-widget.h new file mode 100644 index 0000000..e1f6d1a --- /dev/null +++ b/src/user-widget.h @@ -0,0 +1,54 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ +#ifndef __USER_WIDGET_H__ +#define __USER_WIDGET_H__ + +#include +#if GTK_CHECK_VERSION(3, 0, 0) +#include +#else +#include +#endif + +G_BEGIN_DECLS + +#define USER_WIDGET_TYPE (user_widget_get_type ()) +#define USER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USER_WIDGET_TYPE, UserWidget)) +#define USER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USER_WIDGET_TYPE, UserWidgetClass)) +#define IS_USER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USER_WIDGET_TYPE)) +#define IS_USER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USER_WIDGET_TYPE)) +#define USER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USER_WIDGET_TYPE, UserWidgetClass)) + +typedef struct _UserWidget UserWidget; +typedef struct _UserWidgetClass UserWidgetClass; + +struct _UserWidgetClass { + GtkMenuItemClass parent_class; +}; + +struct _UserWidget { + GtkMenuItem parent; +}; + +GType user_widget_get_type (void); +GtkWidget* user_widget_new(DbusmenuMenuitem *twin_item); + +G_END_DECLS + +#endif -- cgit v1.2.3 From 6fe9d17b60870f96ff4325277118e555e8054d74 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 12 Jul 2011 19:48:30 +0100 Subject: radio button for is-current-user handled --- src/dbus-shared-names.h | 2 + src/indicator-session.c | 19 ++++++-- src/session-service.c | 16 +++++-- src/user-widget.c | 119 ++++++++++++++++++++++++++++++++---------------- 4 files changed, 109 insertions(+), 47 deletions(-) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index b69c6ad..2e8e959 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -36,9 +36,11 @@ with this program. If not, see . #define INDICATOR_SESSION_SERVICE_DBUS_OBJECT "/com/canonical/indicator/session/service" #define INDICATOR_SESSION_SERVICE_DBUS_IFACE "com.canonical.indicator.session.service" +// TODO change the logged in prop to 'has-sessions' in keeping with the spec. #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" +#define USER_ITEM_PROP_IS_CURRENT_USER "user-item-is-current-user" #define USER_ITEM_PROP_ICON "user-item-icon-path" #define USER_ITEM_ICON_DEFAULT "user-offline" diff --git a/src/indicator-session.c b/src/indicator-session.c index 35a55e0..f254957 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -153,8 +153,13 @@ indicator_session_init (IndicatorSession *self) // Setup the handlers for users DbusmenuClient * users_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); - dbusmenu_client_add_type_handler(users_client, USER_ITEM_TYPE, new_user_item); - dbusmenu_client_add_type_handler_full (users_client, MENU_SWITCH_TYPE, build_menu_switch, self, NULL); + dbusmenu_client_add_type_handler (users_client, + USER_ITEM_TYPE, + new_user_item); + dbusmenu_client_add_type_handler_full (users_client, + MENU_SWITCH_TYPE, + build_menu_switch, + self, NULL); // Setup the handlers for devices DbusmenuClient * devices_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->devices.menu))); @@ -290,11 +295,16 @@ new_user_item (DbusmenuMenuitem * newitem, GtkMenuItem *user_widget = GTK_MENU_ITEM(user_item); - gtk_widget_show_all (user_item); dbusmenu_gtkclient_newitem_base (DBUSMENU_GTKCLIENT(client), newitem, user_widget, parent); + + g_debug ("%s (\"%s\")", __func__, + dbusmenu_menuitem_property_get (newitem, + USER_ITEM_PROP_NAME)); + gtk_widget_show_all (user_item); + return TRUE; /*g_debug ("new user item called "); @@ -466,7 +476,8 @@ switch_property_change (DbusmenuMenuitem * item, no_name_in_lang = TRUE; } - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { + if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || + g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { finalstring = _("Switch User..."); set_ellipsize = FALSE; indicator_session_update_users_label (INDICATOR_SESSION (user_data), diff --git a/src/session-service.c b/src/session-service.c index fb5c7a9..c1fad59 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -506,7 +506,9 @@ rebuild_user_items (DbusmenuMenuitem *root, /* 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, + TRUE); } /* If we're showing user accounts, keep going through the list */ if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { @@ -526,12 +528,20 @@ rebuild_user_items (DbusmenuMenuitem *root, } else { 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_property_set_bool (mi, + USER_ITEM_PROP_LOGGED_IN, + user->sessions != NULL); if (user->icon_file != NULL && user->icon_file[0] != '\0') { dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); } else { dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); } + + gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; + dbusmenu_menuitem_property_set_bool (mi, + USER_ITEM_PROP_IS_CURRENT_USER, + logged_in); + dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, @@ -573,7 +583,7 @@ activate_online_accounts (DbusmenuMenuitem *mi, gpointer user_data) { GError * error = NULL; - if (!g_spawn_command_line_async("gnome-control-center", &error)) + if (!g_spawn_command_line_async("gnome-control-center online-accounts", &error)) { g_warning("Unable to show control centre: %s", error->message); g_error_free(error); diff --git a/src/user-widget.c b/src/user-widget.c index bd6634a..22f611c 100644 --- a/src/user-widget.c +++ b/src/user-widget.c @@ -26,6 +26,8 @@ with this program. If not, see . #include #include #include "user-widget.h" +#include "dbus-shared-names.h" + typedef struct _UserWidgetPrivate UserWidgetPrivate; @@ -34,6 +36,8 @@ struct _UserWidgetPrivate DbusmenuMenuitem* twin_item; GtkWidget* user_image; GtkWidget* user_name; + GtkWidget* container; + GtkWidget* tick_icon; gboolean logged_in; gboolean sessions_active; }; @@ -86,11 +90,21 @@ static void user_widget_init (UserWidget *self) { UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(self); + + gint padding = 0; + gtk_widget_style_get (GTK_WIDGET(self), + "horizontal-padding", + &padding, + NULL); + priv->user_image = NULL; priv->user_name = NULL; priv->logged_in = FALSE; priv->sessions_active = FALSE; + priv->container = NULL; + priv->tick_icon = NULL; + // Create the UI elements. priv->user_image = gtk_image_new (); // Just for now set the image to the default avator image @@ -98,7 +112,7 @@ user_widget_init (UserWidget *self) GError* error = NULL; pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), "avatar-default", - 12, + 32, GTK_ICON_LOOKUP_FORCE_SIZE, &error); @@ -109,9 +123,35 @@ user_widget_init (UserWidget *self) gtk_image_set_from_pixbuf (GTK_IMAGE(priv->user_image), pixbuf); g_object_unref (pixbuf); } - + priv->user_name = gtk_label_new (""); + priv->container = gtk_hbox_new (FALSE, 0); + // TODO: + // Delete tick icon and draw primitively. + priv->tick_icon = gtk_image_new_from_icon_name ("account-logged-in", + GTK_ICON_SIZE_MENU); + gtk_misc_set_alignment(GTK_MISC(priv->tick_icon), 1.0, 0.5); + + // Pack it together + gtk_box_pack_start (GTK_BOX (priv->container), + priv->user_image, + FALSE, + FALSE, + 0); + gtk_box_pack_start (GTK_BOX (priv->container), + priv->user_name, + FALSE, + FALSE, + 3); + gtk_box_pack_start (GTK_BOX(priv->container), + priv->tick_icon, + FALSE, + FALSE, 5); + + gtk_widget_show_all (priv->container); + gtk_container_add (GTK_CONTAINER (self), priv->container); + // Fetch the drawing context. #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect_after (GTK_WIDGET(self), "draw", G_CALLBACK(user_widget_primitive_draw_cb_gtk_3), @@ -145,58 +185,43 @@ user_widget_finalize (GObject *object) #if GTK_CHECK_VERSION(3, 0, 0) -// Draw the triangle if the player is running ... +// Draw the radio dot and/or green check mark +// TODO handle drawing of green check mark static gboolean user_widget_primitive_draw_cb_gtk_3 (GtkWidget *widget, cairo_t* cr, gpointer user_data) { - /* + g_return_val_if_fail(IS_USER_WIDGET(user_data), FALSE); UserWidget* meta = USER_WIDGET(user_data); UserWidgetPrivate * priv = USER_WIDGET_GET_PRIVATE(meta); + // Draw dot only when user is the current user. + if (!dbusmenu_menuitem_property_get_bool (priv->twin_item, + USER_ITEM_PROP_IS_CURRENT_USER)){ + return FALSE; + } + + GtkStyle *style; - int x, y, arrow_width, arrow_height; - - gint offset = 3; - arrow_width = 5; - arrow_height = 9; + gdouble x, y; + gdouble offset = 15.0; style = gtk_widget_get_style (widget); GtkAllocation allocation; gtk_widget_get_allocation (widget, &allocation); - x = allocation.x; - y = 0; - - // Draw player icon - if (priv->icon_buf != NULL){ - gdk_cairo_set_source_pixbuf (cr, - priv->icon_buf, - x + arrow_width + 1, - y + offset); - cairo_paint (cr); - } - - // Draw triangle but only if the player is running. - if (dbusmenu_menuitem_property_get_bool (priv->twin_item, - DBUSMENU_METADATA_MENUITEM_PLAYER_RUNNING)){ - y += (double)arrow_height/2.0 + offset; - cairo_set_line_width (cr, 1.0); - - //g_debug ("triangle drawing"); - - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - }*/ + x = allocation.x + 13; + y = offset; + + cairo_arc (cr, x, y, 3.0, 0.0, 2 * G_PI);; + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + return FALSE; } @@ -275,7 +300,7 @@ user_widget_property_update (DbusmenuMenuitem* item, gchar* property, GVariant* value, gpointer userdata) { g_return_if_fail (IS_USER_WIDGET (userdata)); - + //gtk_widget_queue_redraw (GTK_WIDGET(userdata)); } @@ -287,7 +312,21 @@ user_widget_set_twin_item (UserWidget* self, priv->twin_item = twin_item; g_signal_connect( G_OBJECT(priv->twin_item), "property-changed", G_CALLBACK(user_widget_property_update), self); - + + const gchar * icon_name = dbusmenu_menuitem_property_get (twin_item, + USER_ITEM_PROP_ICON); + gtk_label_set_label (GTK_LABEL (priv->user_name), + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + + //if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { + // gtk_widget_show(priv->tick_icon); + //} else { + gtk_widget_show(priv->tick_icon); + //} + + g_debug("Using user icon for '%s' from file: %s", + dbusmenu_menuitem_property_get(twin_item, USER_ITEM_PROP_NAME), icon_name); + } /** -- cgit v1.2.3 From 8cabcd77fd3788d9b2b3ffeb09b57a46bcfa640e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 12 Jul 2011 20:17:57 +0100 Subject: correct icon on the user panel --- src/indicator-session.c | 28 +++++++++++++++++++++++++++- src/user-widget.c | 1 - 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index f254957..58708fd 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -131,7 +131,33 @@ indicator_session_init (IndicatorSession *self) // users self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); - self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); + // Set the image to the default avator image + GdkPixbuf* pixbuf = NULL; + GError* error = NULL; + pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), + "avatar-default", + 17, + GTK_ICON_LOOKUP_FORCE_SIZE, + &error); + + + + GtkWidget* avatar_icon = NULL; + + if (pixbuf == NULL || error != NULL) { + g_warning ("Could not load the default avatar image for some reason"); + self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); + } + else{ + avatar_icon = gtk_image_new (); + gtk_image_set_from_pixbuf (GTK_IMAGE (avatar_icon), pixbuf); + self->users.image = GTK_IMAGE (avatar_icon); + g_object_unref (pixbuf); + } + + + + //self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); self->users.label = GTK_LABEL (gtk_label_new (NULL)); // Only show once we have a valid username gtk_widget_hide (GTK_WIDGET(self->users.label)); diff --git a/src/user-widget.c b/src/user-widget.c index 22f611c..9b046c5 100644 --- a/src/user-widget.c +++ b/src/user-widget.c @@ -203,7 +203,6 @@ user_widget_primitive_draw_cb_gtk_3 (GtkWidget *widget, return FALSE; } - GtkStyle *style; gdouble x, y; gdouble offset = 15.0; -- cgit v1.2.3 From 1967b9c58fd2727733fb38c10d610eb80e365ae3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 13 Jul 2011 13:12:00 +0100 Subject: tidied up signals and methods for the session service so as the users real name should be available and not the icon, icon should not change on the panel --- src/dbus-shared-names.h | 1 - src/indicator-session.c | 156 +++++++----------------------------------------- src/session-dbus.c | 29 ++++----- src/session-dbus.xml | 4 +- src/session-service.c | 10 ++-- 5 files changed, 45 insertions(+), 155 deletions(-) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 2e8e959..c4ccd05 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -36,7 +36,6 @@ with this program. If not, see . #define INDICATOR_SESSION_SERVICE_DBUS_OBJECT "/com/canonical/indicator/session/service" #define INDICATOR_SESSION_SERVICE_DBUS_IFACE "com.canonical.indicator.session.service" -// TODO change the logged in prop to 'has-sessions' in keeping with the spec. #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" diff --git a/src/indicator-session.c b/src/indicator-session.c index 58708fd..1de33d9 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -140,11 +140,10 @@ indicator_session_init (IndicatorSession *self) GTK_ICON_LOOKUP_FORCE_SIZE, &error); - - GtkWidget* avatar_icon = NULL; - if (pixbuf == NULL || error != NULL) { + // I think the avatar image is available always but just in case have a fallback + if (error != NULL) { g_warning ("Could not load the default avatar image for some reason"); self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); } @@ -153,14 +152,12 @@ indicator_session_init (IndicatorSession *self) gtk_image_set_from_pixbuf (GTK_IMAGE (avatar_icon), pixbuf); self->users.image = GTK_IMAGE (avatar_icon); g_object_unref (pixbuf); + g_error_free (error); } - - - //self->users.image = indicator_image_helper (USER_ITEM_ICON_DEFAULT); self->users.label = GTK_LABEL (gtk_label_new (NULL)); // Only show once we have a valid username - gtk_widget_hide (GTK_WIDGET(self->users.label)); + // gtk_widget_hide (GTK_WIDGET(self->users.label)); // devices self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, @@ -326,117 +323,30 @@ new_user_item (DbusmenuMenuitem * newitem, user_widget, parent); - g_debug ("%s (\"%s\")", __func__, + g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get (newitem, USER_ITEM_PROP_NAME)); gtk_widget_show_all (user_item); return TRUE; - - /*g_debug ("new user item called "); - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - gint padding = 0; - gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - GtkWidget * hbox = gtk_hbox_new(FALSE, padding); - - GtkWidget * usericon = NULL; - const gchar * icon_name = dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_ICON); - g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(newitem, USER_ITEM_PROP_NAME), icon_name); - if (icon_name != NULL && icon_name[0] != '\0') { - if (g_strcmp0(icon_name, USER_ITEM_ICON_DEFAULT) != 0 && g_file_test(icon_name, G_FILE_TEST_EXISTS)) { - gint width, height; - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - - GError * error = NULL; - GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size(icon_name, width, height, &error); - - if (error == NULL) { - usericon = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - } else { - g_warning("Unable to load user icon '%s': %s", icon_name, error->message); - g_error_free(error); - } - } - - if (usericon == NULL) { - GIcon * gicon = g_themed_icon_new_with_default_fallbacks("stock_person-panel"); - usericon = gtk_image_new_from_gicon(gicon, GTK_ICON_SIZE_MENU); - g_object_unref(gicon); - } - } - if (usericon != NULL) { - gtk_misc_set_alignment(GTK_MISC(usericon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), usericon, FALSE, FALSE, 0); - gtk_widget_show(usericon); - } - - 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); - - g_signal_connect (G_OBJECT(newitem), - DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, - G_CALLBACK(user_property_change), icon); - - return TRUE; - */ } -/*static void -user_property_change (DbusmenuMenuitem * item, - const gchar * property, - GVariant * variant, - gpointer user_data) -{ - if (g_strcmp0(property, USER_ITEM_PROP_LOGGED_IN) == 0) { - if (g_variant_get_boolean(variant)) { - gtk_widget_show(GTK_WIDGET(user_data)); - } else { - gtk_widget_hide(GTK_WIDGET(user_data)); - } - } - return; -}*/ static void -icon_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) +user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { IndicatorSession * self = INDICATOR_SESSION(user_data); GError * error = NULL; - gchar * name; GVariant * result; result = g_dbus_proxy_call_finish(self->service_proxy, res, &error); if (error != NULL) { + g_warning ("unable to complete real name dbus query"); + g_error_free (error); return; } - - g_variant_get(result, "(&s)", &name); - - if (name == NULL || name[0] == '\0') { - return; - } - - //indicator_image_helper_update(self->users.image, name); + indicator_session_update_users_label (self, result); return; } @@ -446,23 +356,13 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe IndicatorSession * self = INDICATOR_SESSION (user_data); if (connected) { - g_dbus_proxy_call(self->service_proxy, "GetIcon", NULL, + g_dbus_proxy_call(self->service_proxy, "GetUserRealName", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, - icon_name_get_cb, user_data); - } - else { - indicator_image_helper_update (self->users.image, - USER_ITEM_ICON_DEFAULT); + user_real_name_get_cb, user_data); } return; } -static void -icon_changed (IndicatorSession * session, const gchar * icon_name) -{ - indicator_image_helper_update(session->users.image, icon_name); - return; -} /* Receives all signals from the service, routed to the appropriate functions */ static void @@ -474,14 +374,14 @@ receive_signal (GDBusProxy * proxy, { IndicatorSession * self = INDICATOR_SESSION(user_data); - if (g_strcmp0(signal_name, "IconUpdated") == 0) { - const gchar *name; - g_variant_get (parameters, "(&s)", &name); - icon_changed(self, name); - } + if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) { + indicator_session_update_users_label (self, parameters); + } return; } + + static void switch_property_change (DbusmenuMenuitem * item, const gchar * property, @@ -506,12 +406,6 @@ switch_property_change (DbusmenuMenuitem * item, g_variant_get_string(variant, NULL)[0] == '\0' || no_name_in_lang) { finalstring = _("Switch User..."); set_ellipsize = FALSE; - indicator_session_update_users_label (INDICATOR_SESSION (user_data), - NULL); - } - else{ - indicator_session_update_users_label (INDICATOR_SESSION (user_data), - variant); } if (finalstring == NULL) { @@ -642,9 +536,7 @@ build_menu_switch (DbusmenuMenuitem * newitem, if (gmi == NULL) { return FALSE; } - - IndicatorSession* self = INDICATOR_SESSION (user_data); - + g_object_set_data(G_OBJECT(gmi), dbusmenu_item_data, newitem); dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); @@ -661,10 +553,7 @@ build_menu_switch (DbusmenuMenuitem * newitem, switch_property_change (newitem, MENU_SWITCH_USER, dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER), client); - - indicator_session_update_users_label (self, - dbusmenu_menuitem_property_get_variant(newitem, MENU_SWITCH_USER)); - + return TRUE; } @@ -675,16 +564,15 @@ indicator_session_update_users_label (IndicatorSession* self, const gchar* username = NULL; if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || g_variant_get_string(variant, NULL)[0] == '\0'){ - // either way set the user label to blank - gtk_label_set_text (self->users.label, ""); - return; + gtk_widget_hide(GTK_WIDGET(self->users.label)); + return; } - username = g_variant_get_string(variant, NULL); + username = g_strdup (g_variant_get_string(variant, NULL)); // Just in case protect again. if (username != NULL) { - g_debug ("Updating username label "); + g_debug ("!!!!!!!!!!!!update users label: %s", username); gtk_label_set_text (self->users.label, username); gtk_widget_show(GTK_WIDGET(self->users.label)); } diff --git a/src/session-dbus.c b/src/session-dbus.c index fa9ea54..07cebf7 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -5,6 +5,7 @@ Copyright 2010 Canonical Ltd. Authors: Ted Gould + Conor Curran This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -28,7 +29,7 @@ with this program. If not, see . #include "session-dbus.h" #include "dbus-shared-names.h" -static GVariant * get_icon (SessionDbus * service); +static GVariant * get_users_real_name (SessionDbus * service); static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data); @@ -98,7 +99,7 @@ session_dbus_init (SessionDbus *self) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); - priv->name = g_strdup(ICON_DEFAULT); + priv->name = NULL; priv->bus = NULL; priv->bus_cancel = NULL; priv->dbus_registration = 0; @@ -163,8 +164,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, SessionDbus * service = SESSION_DBUS(user_data); GVariant * retval = NULL; - if (g_strcmp0(method, "GetIcon") == 0) { - retval = get_icon(service); + if (g_strcmp0(method, "GetUserRealName") == 0) { + retval = get_users_real_name (service); } else { g_warning("Calling method '%s' on the indicator service and it's unknown", method); } @@ -214,10 +215,11 @@ session_dbus_finalize (GObject *object) } static GVariant * -get_icon (SessionDbus * service) +get_users_real_name (SessionDbus * service) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); - return g_variant_new("(s)", priv->name); + g_debug ("Get users real name: %s", priv->name); + return g_variant_new ("(s)", priv->name); } SessionDbus * @@ -239,19 +241,18 @@ session_dbus_set_name (SessionDbus * session, const gchar * name) if (priv->bus != NULL) { g_dbus_connection_emit_signal (priv->bus, - NULL, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - "IconUpdated", - g_variant_new ("(s)", priv->name, NULL), - &error); + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "UserRealNameUpdated", + g_variant_new ("(s)", priv->name, NULL), + &error); if (error != NULL) { - g_warning("Unable to send IconUpdated signal: %s", error->message); + g_warning("Unable to send UserRealNameUpdated signal: %s", error->message); g_error_free(error); return; } } - return; } diff --git a/src/session-dbus.xml b/src/session-dbus.xml index ee724f5..82c8dc8 100644 --- a/src/session-dbus.xml +++ b/src/session-dbus.xml @@ -3,11 +3,11 @@ - + - + diff --git a/src/session-service.c b/src/session-service.c index c1fad59..d213b6d 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -143,7 +143,6 @@ keybinding_changed (GConfClient *client, dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value)); } } - return; } @@ -161,7 +160,7 @@ ensure_gconf_client (void) gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); } - return; + return; } /* Check to see if the lockdown key is protecting from @@ -541,6 +540,9 @@ rebuild_user_items (DbusmenuMenuitem *root, dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_IS_CURRENT_USER, logged_in); + if (logged_in == TRUE){ + session_dbus_set_name (session_dbus, user->real_name); + } dbusmenu_menuitem_child_append (root, mi); g_signal_connect (G_OBJECT (mi), @@ -800,8 +802,8 @@ main (int argc, char ** argv) bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); - IndicatorService * service = indicator_service_new_version(INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_DBUS_VERSION); + IndicatorService * service = indicator_service_new_version (INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_VERSION); g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_shutdown), NULL); -- cgit v1.2.3 From ee23d617b4f66ddeddaa355faef5760d62314823 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 13 Jul 2011 17:34:03 +0100 Subject: user label fixed for now --- src/indicator-session.c | 152 ++++++++++++++++++++++++++---------------------- src/session-dbus.c | 8 +++ src/session-dbus.h | 3 +- src/session-service.c | 4 +- 4 files changed, 94 insertions(+), 73 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 1de33d9..ab3e87a 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -89,10 +89,11 @@ static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data); static void indicator_session_update_users_label (IndicatorSession* self, - GVariant * variant); + const gchar* name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); +static void user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -128,6 +129,8 @@ indicator_session_init (IndicatorSession *self) g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); + + GtkWidget* avatar_icon = NULL; // users self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); @@ -140,8 +143,6 @@ indicator_session_init (IndicatorSession *self) GTK_ICON_LOOKUP_FORCE_SIZE, &error); - GtkWidget* avatar_icon = NULL; - // I think the avatar image is available always but just in case have a fallback if (error != NULL) { g_warning ("Could not load the default avatar image for some reason"); @@ -192,19 +193,6 @@ indicator_session_init (IndicatorSession *self) GtkAccelGroup * agroup = gtk_accel_group_new(); dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(devices_client), agroup); - - self->service_proxy_cancel = g_cancellable_new(); - - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - self->service_proxy_cancel, - service_proxy_cb, - self); - return; } @@ -249,9 +237,59 @@ indicator_session_finalize (GObject *object) return; } -/* Callback from trying to create the proxy for the service, this - could include starting the service. Sometime it'll fail and - we'll try to start that dang service again! */ +static GList* +indicator_session_get_entries (IndicatorObject* obj) +{ + g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); + IndicatorSession* self = INDICATOR_SESSION (obj); + + GList * retval = NULL; + + retval = g_list_prepend (retval, &self->users); + retval = g_list_prepend (retval, &self->devices); + + if (retval != NULL) { + retval = g_list_reverse(retval); + } + return retval; +} + +/* callback for the service manager state of being */ +static void +service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION (user_data); + + if (connected) { + if (self->service_proxy != NULL){ + // Its a reconnect ! + // fetch the users's real name and return + g_dbus_proxy_call (self->service_proxy, + "GetUserRealName", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_real_name_get_cb, + user_data); + return; + } + + self->service_proxy_cancel = g_cancellable_new(); + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + self->service_proxy_cancel, + service_proxy_cb, + self); + } + return; +} + + static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) { @@ -278,29 +316,20 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) self->service_proxy = proxy; g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); - + + // Fetch the user's real name for the user entry label + g_dbus_proxy_call (self->service_proxy, + "GetUserRealName", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_real_name_get_cb, + user_data); return; } -static GList* -indicator_session_get_entries (IndicatorObject* obj) -{ - g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); - IndicatorSession* self = INDICATOR_SESSION (obj); - - GList * retval = NULL; - - retval = g_list_prepend (retval, &self->users); - retval = g_list_prepend (retval, &self->devices); - - if (retval != NULL) { - retval = g_list_reverse(retval); - } - return retval; -} - -/* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, @@ -346,20 +375,10 @@ user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) g_error_free (error); return; } - indicator_session_update_users_label (self, result); - return; -} - -static void -service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) -{ - IndicatorSession * self = INDICATOR_SESSION (user_data); - - if (connected) { - g_dbus_proxy_call(self->service_proxy, "GetUserRealName", NULL, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, - user_real_name_get_cb, user_data); - } + + const gchar* username = NULL; + g_variant_get (result, "(s)", &username); + indicator_session_update_users_label (self, username); return; } @@ -375,7 +394,9 @@ receive_signal (GDBusProxy * proxy, IndicatorSession * self = INDICATOR_SESSION(user_data); if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) { - indicator_session_update_users_label (self, parameters); + const gchar* username = NULL; + g_variant_get (parameters, "(s)", &username); + indicator_session_update_users_label (self, username); } return; } @@ -559,25 +580,14 @@ build_menu_switch (DbusmenuMenuitem * newitem, static void indicator_session_update_users_label (IndicatorSession* self, - GVariant * variant) + const gchar* name) { - const gchar* username = NULL; - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || - g_variant_get_string(variant, NULL)[0] == '\0'){ - gtk_widget_hide(GTK_WIDGET(self->users.label)); - return; - } + g_debug ("update users label"); - username = g_strdup (g_variant_get_string(variant, NULL)); - - // Just in case protect again. - if (username != NULL) { - g_debug ("!!!!!!!!!!!!update users label: %s", username); - gtk_label_set_text (self->users.label, username); - gtk_widget_show(GTK_WIDGET(self->users.label)); - } - else { + if (name == NULL){ gtk_widget_hide(GTK_WIDGET(self->users.label)); - } + return; + } + gtk_label_set_text (self->users.label, g_strdup(name)); + gtk_widget_show(GTK_WIDGET(self->users.label)); } - diff --git a/src/session-dbus.c b/src/session-dbus.c index 07cebf7..d28629b 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -230,6 +230,11 @@ session_dbus_new (void) void session_dbus_set_name (SessionDbus * session, const gchar * name) +{ +} + +void +session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; @@ -237,6 +242,9 @@ session_dbus_set_name (SessionDbus * session, const gchar * name) g_free(priv->name); priv->name = NULL; } + + g_debug ("sesssion dbus set name with %s", name); + priv->name = g_strdup(name); if (priv->bus != NULL) { diff --git a/src/session-dbus.h b/src/session-dbus.h index 792917b..377212b 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -48,7 +48,8 @@ struct _SessionDbus { GType session_dbus_get_type (void); SessionDbus * session_dbus_new (void); -void session_dbus_set_name (SessionDbus * session, const gchar * name); +void session_dbus_set_name (SessionDbus * session, const gchar * name); +void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name); G_END_DECLS diff --git a/src/session-service.c b/src/session-service.c index d213b6d..2110241 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -541,7 +541,9 @@ rebuild_user_items (DbusmenuMenuitem *root, USER_ITEM_PROP_IS_CURRENT_USER, logged_in); if (logged_in == TRUE){ - session_dbus_set_name (session_dbus, user->real_name); + 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 (session_dbus, user->real_name); } dbusmenu_menuitem_child_append (root, mi); -- cgit v1.2.3 From d8eae0b9560084bc68781d73c14fcb54cd53fd02 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 13:06:38 +0100 Subject: dynamic user menu hiding on the way# --- src/indicator-session.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++--- src/session-dbus.c | 42 +++++++++++++++++++++++++++++++---- src/session-dbus.h | 1 + src/session-dbus.xml | 9 +++++--- src/session-service.c | 4 ++++ 5 files changed, 104 insertions(+), 10 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index ab3e87a..704e959 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -65,6 +65,7 @@ struct _IndicatorSession { IndicatorServiceManager * service; IndicatorObjectEntry users; IndicatorObjectEntry devices; + gboolean show_users_entry; GCancellable * service_proxy_cancel; GDBusProxy * service_proxy; }; @@ -94,6 +95,7 @@ static void service_connection_cb (IndicatorServiceManager * sm, gboolean connec static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data); +static void user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -122,6 +124,7 @@ indicator_session_init (IndicatorSession *self) self->service = NULL; self->service_proxy_cancel = NULL; self->service_proxy = NULL; + self->show_users_entry = FALSE; /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, @@ -244,8 +247,10 @@ indicator_session_get_entries (IndicatorObject* obj) IndicatorSession* self = INDICATOR_SESSION (obj); GList * retval = NULL; - - retval = g_list_prepend (retval, &self->users); + // Only show the users menu if we have more than one + if (self->show_users_entry == TRUE){ + retval = g_list_prepend (retval, &self->users); + } retval = g_list_prepend (retval, &self->devices); if (retval != NULL) { @@ -263,7 +268,15 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe if (connected) { if (self->service_proxy != NULL){ // Its a reconnect ! - // fetch the users's real name and return + // Fetch synchronisation data and return (proxy is still legit) + g_dbus_proxy_call (self->service_proxy, + "GetUserMenuVisibility", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_menu_visibility_get_cb, + user_data); g_dbus_proxy_call (self->service_proxy, "GetUserRealName", NULL, @@ -317,6 +330,16 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); + // Figure out whether we should show the user menu at all. + g_dbus_proxy_call (self->service_proxy, + "GetUserMenuVisibility", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_menu_visibility_get_cb, + user_data); + // Fetch the user's real name for the user entry label g_dbus_proxy_call (self->service_proxy, "GetUserRealName", @@ -382,6 +405,31 @@ user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) return; } +static void +user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION(user_data); + GError * error = NULL; + GVariant * result; + + result = g_dbus_proxy_call_finish(self->service_proxy, res, &error); + + if (error != NULL) { + g_warning ("unable to complete real name dbus query"); + g_error_free (error); + return; + } + gboolean update; + g_variant_get (result, "(b)", &update); + g_debug ("GET VISIBILITY CB: NEW VALUE = %i", update); + self->show_users_entry = update; + g_signal_emit_by_name (user_data, + "entry-added", + self->parent, + self->users); + return; +} + /* Receives all signals from the service, routed to the appropriate functions */ static void @@ -397,6 +445,10 @@ receive_signal (GDBusProxy * proxy, const gchar* username = NULL; g_variant_get (parameters, "(s)", &username); indicator_session_update_users_label (self, username); + } + else if (g_strcmp0(signal_name, "UserMenuIsVisible") == 0) { + gboolean result = g_variant_get_boolean (parameters); + g_debug ("GET VISIBILITY signal: NEW VALUE = %i", result); } return; } diff --git a/src/session-dbus.c b/src/session-dbus.c index d28629b..9e24141 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -38,6 +38,7 @@ static void bus_method_call (GDBusConnection * connection, const gchar * sender, typedef struct _SessionDbusPrivate SessionDbusPrivate; struct _SessionDbusPrivate { gchar * name; + gboolean user_menu_is_visible; GDBusConnection * bus; GCancellable * bus_cancel; guint dbus_registration; @@ -103,6 +104,7 @@ session_dbus_init (SessionDbus *self) priv->bus = NULL; priv->bus_cancel = NULL; priv->dbus_registration = 0; + priv->user_menu_is_visible = FALSE; priv->bus_cancel = g_cancellable_new(); g_bus_get(G_BUS_TYPE_SESSION, @@ -161,15 +163,20 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { - SessionDbus * service = SESSION_DBUS(user_data); + SessionDbus * service = SESSION_DBUS (user_data); + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE (service); + GVariant * retval = NULL; if (g_strcmp0(method, "GetUserRealName") == 0) { retval = get_users_real_name (service); - } else { - g_warning("Calling method '%s' on the indicator service and it's unknown", method); } - + else if (g_strcmp0 (method, "GetUserMenuVisibility") == 0){ + retval = g_variant_new ("(b)", priv->user_menu_is_visible); + } + else { + g_warning("Calling method '%s' on the indicator service and it's unknown", method); + } g_dbus_method_invocation_return_value(invocation, retval); return; } @@ -264,3 +271,30 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) } return; } + +void +session_dbus_set_user_menu_visibility (SessionDbus* session, + gboolean visible) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); + GError * error = NULL; + + g_debug ("sesssion dbus set user visibility - %i", visible); + + priv->user_menu_is_visible = visible; + + if (priv->bus != NULL) { + g_dbus_connection_emit_signal (priv->bus, + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "UserMenuIsVisible", + g_variant_new ("(b)", priv->user_menu_is_visible), + &error); + + if (error != NULL) { + g_warning("Unable to send UserMenuIsVisible signal: %s", error->message); + g_error_free(error); + } + } +} diff --git a/src/session-dbus.h b/src/session-dbus.h index 377212b..45ebae2 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -50,6 +50,7 @@ GType session_dbus_get_type (void); SessionDbus * session_dbus_new (void); void session_dbus_set_name (SessionDbus * session, const gchar * name); void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name); +void session_dbus_set_user_menu_visibility (SessionDbus* session, gboolean visible); G_END_DECLS diff --git a/src/session-dbus.xml b/src/session-dbus.xml index 82c8dc8..f496ff1 100644 --- a/src/session-dbus.xml +++ b/src/session-dbus.xml @@ -2,14 +2,17 @@ - - + + + - + + + diff --git a/src/session-service.c b/src/session-service.c index 2110241..812769e 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -490,6 +490,10 @@ rebuild_user_items (DbusmenuMenuitem *root, GList * users = NULL; users = users_service_dbus_get_user_list (service); guint user_count = g_list_length(users); + g_debug ("USER COUNT = %i", user_count); + // We only want to show this menu when we have more than one registered + // user + session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { users = g_list_sort (users, (GCompareFunc)compare_users_by_username); -- cgit v1.2.3 From f2d458b0addfe408835366939b49f4a38c0a14cb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 16:35:57 +0100 Subject: get location overridden and debugs tidied up --- src/indicator-session.c | 74 +++++++++++++++++++++++++++++++++++++++++-------- src/session-dbus.c | 9 ++---- src/session-service.c | 2 +- 3 files changed, 66 insertions(+), 19 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 704e959..5a5e26c 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -102,7 +102,9 @@ static void indicator_session_init (IndicatorSession *self); static void indicator_session_dispose (GObject *object); static void indicator_session_finalize (GObject *object); static GList* indicator_session_get_entries (IndicatorObject* obj); - +static guint indicator_session_get_location (IndicatorObject * io, + IndicatorObjectEntry * entry); + G_DEFINE_TYPE (IndicatorSession, indicator_session, INDICATOR_OBJECT_TYPE); static void @@ -115,6 +117,7 @@ indicator_session_class_init (IndicatorSessionClass *klass) IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); io_class->get_entries = indicator_session_get_entries; + io_class->get_location = indicator_session_get_location; return; } @@ -246,6 +249,7 @@ indicator_session_get_entries (IndicatorObject* obj) g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); IndicatorSession* self = INDICATOR_SESSION (obj); + g_debug ("get entries"); GList * retval = NULL; // Only show the users menu if we have more than one if (self->show_users_entry == TRUE){ @@ -259,6 +263,21 @@ indicator_session_get_entries (IndicatorObject* obj) return retval; } +static guint +indicator_session_get_location (IndicatorObject * io, + IndicatorObjectEntry * entry) +{ + IndicatorSession * self = INDICATOR_SESSION (io); + if (entry == &self->users){ + return 1; + } + else if (entry == &self->devices){ + return 0; + } + g_warning ("IOEntry handed to us to position but we don't own it!"); + return -1; +} + /* callback for the service manager state of being */ static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) @@ -421,15 +440,28 @@ user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data } gboolean update; g_variant_get (result, "(b)", &update); - g_debug ("GET VISIBILITY CB: NEW VALUE = %i", update); + + // If it is what we had before no need to do anything... + if (self->show_users_entry == update){ + return; + } + + //Otherwise self->show_users_entry = update; - g_signal_emit_by_name (user_data, - "entry-added", - self->parent, - self->users); - return; -} + IndicatorObjectEntry user_entry = self->users; + + if (self->show_users_entry == TRUE){ + g_signal_emit_by_name ((gpointer)self, + "entry-added", + &user_entry); + } + else{ + g_signal_emit_by_name ((gpointer)self, + "entry-removed", + &user_entry); + } +} /* Receives all signals from the service, routed to the appropriate functions */ static void @@ -447,10 +479,30 @@ receive_signal (GDBusProxy * proxy, indicator_session_update_users_label (self, username); } else if (g_strcmp0(signal_name, "UserMenuIsVisible") == 0) { - gboolean result = g_variant_get_boolean (parameters); - g_debug ("GET VISIBILITY signal: NEW VALUE = %i", result); + gboolean update; + g_variant_get (parameters, "(b)", &update); + + // If it is what we had before no need to do anything... + if (self->show_users_entry == update){ + return; + } + + //Otherwise + self->show_users_entry = update; + + IndicatorObjectEntry user_entry = self->users; + + if (self->show_users_entry == TRUE){ + g_signal_emit_by_name ((gpointer)self, + "entry-added", + &user_entry); + } + else{ + g_signal_emit_by_name ((gpointer)self, + "entry-removed", + &user_entry); + } } - return; } diff --git a/src/session-dbus.c b/src/session-dbus.c index 9e24141..9aa75ef 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -225,7 +225,6 @@ static GVariant * get_users_real_name (SessionDbus * service) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); - g_debug ("Get users real name: %s", priv->name); return g_variant_new ("(s)", priv->name); } @@ -249,9 +248,7 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) g_free(priv->name); priv->name = NULL; } - - g_debug ("sesssion dbus set name with %s", name); - + priv->name = g_strdup(name); if (priv->bus != NULL) { @@ -278,9 +275,7 @@ session_dbus_set_user_menu_visibility (SessionDbus* session, { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; - - g_debug ("sesssion dbus set user visibility - %i", visible); - + priv->user_menu_is_visible = visible; if (priv->bus != NULL) { diff --git a/src/session-service.c b/src/session-service.c index 812769e..fb6ce37 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -490,7 +490,7 @@ rebuild_user_items (DbusmenuMenuitem *root, GList * users = NULL; users = users_service_dbus_get_user_list (service); guint user_count = g_list_length(users); - g_debug ("USER COUNT = %i", user_count); + // g_debug ("USER COUNT = %i", user_count); // We only want to show this menu when we have more than one registered // user session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); -- cgit v1.2.3 From f4cab4f88b251b4abdf8add234c4ba04d9cce03a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 17:19:11 +0100 Subject: ref sink instead of ref on the images and menus --- 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 5a5e26c..ded9218 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -176,10 +176,10 @@ indicator_session_init (IndicatorSession *self) gtk_widget_show (GTK_WIDGET(self->users.image)); gtk_widget_show (GTK_WIDGET(self->users.menu)); - g_object_ref (self->users.menu); - g_object_ref (self->users.image); - g_object_ref (self->devices.menu); - g_object_ref (self->devices.image); + g_object_ref_sink (self->users.menu); + g_object_ref_sink (self->users.image); + g_object_ref_sink (self->devices.menu); + g_object_ref_sink (self->devices.image); // Setup the handlers for users DbusmenuClient * users_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->users.menu))); -- cgit v1.2.3 From fed6348d65e3d927e0fe42733de91a09cf43fec2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 17:20:38 +0100 Subject: changed default return value of get location to 0 --- 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 ded9218..068ffef 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -275,7 +275,7 @@ indicator_session_get_location (IndicatorObject * io, return 0; } g_warning ("IOEntry handed to us to position but we don't own it!"); - return -1; + return 0; } /* callback for the service manager state of being */ -- cgit v1.2.3 From 84fb2fdde96442f79bb1da1edf4d707019b68f98 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 17:40:43 +0100 Subject: bumped release version --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4f2cb04..59227b8 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.92) +AM_INIT_AUTOMAKE(indicator-session, 0.2.93) AM_MAINTAINER_MODE -- cgit v1.2.3 From 5a947834adb7f0cbe10550e328c0f895070affdb Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Thu, 14 Jul 2011 16:57:09 -0400 Subject: * debian/control - Added Replaces indicator-me --- debian/changelog | 2 ++ debian/control | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b8d0784..a0f1515 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ indicator-session (0.2.93-0ubuntu1) UNRELEASED; urgency=low * New upstream release. + * debian/control + - Added Replaces indicator-me -- Ken VanDine Thu, 14 Jul 2011 14:29:15 -0400 diff --git a/debian/control b/debian/control index 4f2d296..efc5d53 100644 --- a/debian/control +++ b/debian/control @@ -27,7 +27,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, upower Recommends: indicator-applet (>= 0.2) | indicator-renderer Suggests: lightdm Conflicts: gdm (<= 2.27.4-0ubuntu9), indicator-sus -Replaces: indicator-sus +Replaces: indicator-sus, indicator-me +Breaks: indicator-me Description: Indicator showing session management, status and user switching. This indicator is designed to be placed on the right side of a panel and give the user easy control for changing their instant message status. -- cgit v1.2.3 From f32ca6117a1313f39baa317900e9a297d167a479 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 15 Jul 2011 12:06:53 +0100 Subject: please tidy up that user manager --- src/Makefile.am | 4 +- src/gconf-helper.h | 6 + src/session-service.c | 269 ++++---------------------------------------- src/users-menu-mgr.c | 303 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/users-menu-mgr.h | 55 +++++++++ 5 files changed, 388 insertions(+), 249 deletions(-) create mode 100644 src/users-menu-mgr.c create mode 100644 src/users-menu-mgr.h diff --git a/src/Makefile.am b/src/Makefile.am index 71537c5..17dd041 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -91,7 +91,9 @@ indicator_session_service_SOURCES = \ dbusmenu-shared.h \ gconf-helper.c \ users-service-dbus.h \ - users-service-dbus.c + users-service-dbus.c \ + users_menu_mgr.h \ + users_menu_mgr.c indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/gconf-helper.h b/src/gconf-helper.h index 505c24f..039b309 100644 --- a/src/gconf-helper.h +++ b/src/gconf-helper.h @@ -39,6 +39,12 @@ with this program. If not, see . #define RESTART_KEY GLOBAL_DIR "/suppress_restart_menuitem" #define SHUTDOWN_KEY GLOBAL_DIR "/suppress_shutdown_menuitem" +#define LOCKDOWN_DIR "/desktop/gnome/lockdown" +#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" +#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" +#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings" +#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver" + typedef struct _RestartShutdownLogoutMenuItems { DbusmenuMenuitem * logout_mi; diff --git a/src/session-service.c b/src/session-service.c index fb6ce37..78cd9ae 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -43,26 +43,22 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "dbusmenu-shared.h" +#include "users-service-dbus.h" +#include "users-menu-mgr.h" #include "gconf-helper.h" #include "session-dbus.h" -#include "users-service-dbus.h" #include "lock-helper.h" #include "upower-client.h" + #define UP_ADDRESS "org.freedesktop.UPower" #define UP_OBJECT "/org/freedesktop/UPower" #define UP_INTERFACE "org.freedesktop.UPower" #define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications" -#define LOCKDOWN_DIR "/desktop/gnome/lockdown" -#define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" -#define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" - -#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings" -#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver" typedef struct _ActivateData ActivateData; struct _ActivateData @@ -71,14 +67,10 @@ struct _ActivateData UserData *user; }; -static UsersServiceDbus *dbus_interface = NULL; +//static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; - static DbusmenuMenuitem *lock_menuitem = NULL; -static DbusmenuMenuitem *switch_menuitem = NULL; - static DbusmenuMenuitem * session_root_menuitem = NULL; -static DbusmenuMenuitem * users_root_menuitem = NULL; static GMainLoop * mainloop = NULL; static DBusGProxy * up_main_proxy = NULL; @@ -100,9 +92,7 @@ static gboolean allow_suspend = TRUE; static GConfClient * gconf_client = NULL; -static void rebuild_session_items (DbusmenuMenuitem *root, UsersServiceDbus *service); -static void rebuild_user_items (DbusmenuMenuitem *root, UsersServiceDbus *service); -static void activate_online_accounts (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data); +static void rebuild_session_items (DbusmenuMenuitem *root); static void lockdown_changed (GConfClient *client, @@ -118,7 +108,7 @@ lockdown_changed (GConfClient *client, } if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { - rebuild_session_items(session_root_menuitem, dbus_interface); + rebuild_session_items(session_root_menuitem); } return; @@ -228,7 +218,7 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) gboolean local_can_suspend = g_value_get_boolean(&candoit); if (local_can_suspend != can_suspend) { can_suspend = local_can_suspend; - rebuild_session_items(session_root_menuitem, dbus_interface); + rebuild_session_items(session_root_menuitem); } return; @@ -253,7 +243,7 @@ hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) gboolean local_can_hibernate = g_value_get_boolean(&candoit); if (local_can_hibernate != can_hibernate) { can_hibernate = local_can_hibernate; - rebuild_session_items(session_root_menuitem, dbus_interface); + rebuild_session_items(session_root_menuitem); } return; @@ -314,7 +304,7 @@ allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer use if (OUT_allowed != *can_do) { *can_do = OUT_allowed; - rebuild_session_items (session_root_menuitem, dbus_interface); + rebuild_session_items (session_root_menuitem); } } @@ -391,216 +381,10 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) return; } -/* Checks to see if we can create sessions */ -static gboolean -check_new_session (void) -{ - return TRUE; -} - -/* Starts a new generic session */ -static void -activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) -{ - lock_if_possible(); - - users_service_dbus_show_greeter (USERS_SERVICE_DBUS(user_data)); - - return; -} -/* Activates a session for a particular user. */ static void -activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) -{ - UserData *user = (UserData *)user_data; - UsersServiceDbus *service = user->service; - - lock_if_possible(); - - users_service_dbus_activate_user_session (service, user); -} - -/* Comparison function to look into the UserData struct - to compare by using the username value */ -static gint -compare_users_by_username (const gchar *a, - const gchar *b) -{ - UserData *user1 = (UserData *)a; - UserData *user2 = (UserData *)b; - - gint retval = g_strcmp0 (user1->real_name, user2->real_name); - - /* If they're the same, they're both in conflict. */ - if (retval == 0) { - user1->real_name_conflict = TRUE; - user2->real_name_conflict = TRUE; - } - - return retval; -} - -/* Builds up the menu for us */ -static void -rebuild_user_items (DbusmenuMenuitem *root, - UsersServiceDbus *service) -{ - DbusmenuMenuitem *mi = NULL; - DbusmenuMenuitem *guest_mi = NULL; - GList *u; - UserData *user; - gboolean can_activate; - GList *children; - - /* Make sure we have a valid GConf client, and build one - if needed */ - ensure_gconf_client (); - - /* Check to see which menu items we're allowed to have */ - can_activate = users_service_dbus_can_activate_session (service) && - !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); - - /* Remove the old menu items if that makes sense */ - children = dbusmenu_menuitem_take_children (root); - g_list_foreach (children, (GFunc)g_object_unref, NULL); - g_list_free (children); - - /* Set to NULL just incase we don't end up building one */ - users_service_dbus_set_guest_item(service, NULL); - - /* Build all of the user switching items */ - if (can_activate == TRUE) - { - if (check_new_session ()){ - 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()); - dbusmenu_menuitem_child_append (root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_new_session), - service); - } - - GList * users = NULL; - users = users_service_dbus_get_user_list (service); - guint user_count = g_list_length(users); - // g_debug ("USER COUNT = %i", user_count); - // We only want to show this menu when we have more than one registered - // user - session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - users = g_list_sort (users, (GCompareFunc)compare_users_by_username); - } - - for (u = users; u != NULL; u = g_list_next (u)) { - user = u->data; - user->service = service; - - g_debug ("%i %s", (gint)user->uid, user->user_name); - - 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); - } - /* If we're showing user accounts, keep going through the list */ - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - continue; - } - /* If not, we can stop here */ - break; - } - - if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { - mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - if (user->real_name_conflict) { - gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); - g_free(conflictedname); - } else { - 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); - if (user->icon_file != NULL && user->icon_file[0] != '\0') { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); - } else { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); - } - - gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; - dbusmenu_menuitem_property_set_bool (mi, - USER_ITEM_PROP_IS_CURRENT_USER, - logged_in); - if (logged_in == TRUE){ - 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 (session_dbus, user->real_name); - } - - dbusmenu_menuitem_child_append (root, mi); - g_signal_connect (G_OBJECT (mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_user_session), - user); - user->menuitem = mi; - } - } - g_list_free(users); - } - // Add the online accounts and separator - DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (separator1, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append (root, separator1); - DbusmenuMenuitem * online_accounts_item = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (online_accounts_item, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_DEFAULT); - dbusmenu_menuitem_property_set (online_accounts_item, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Online Accounts...")); - - g_signal_connect (G_OBJECT (online_accounts_item), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_online_accounts), - NULL); - - dbusmenu_menuitem_child_append (root, online_accounts_item); -} - -// TODO -// Wait until dialog is complete to find out name to pass -// to the control centre. -static void -activate_online_accounts (DbusmenuMenuitem *mi, - guint timestamp, - gpointer user_data) -{ - GError * error = NULL; - if (!g_spawn_command_line_async("gnome-control-center online-accounts", &error)) - { - g_warning("Unable to show control centre: %s", error->message); - g_error_free(error); - } -} - -static void -rebuild_session_items (DbusmenuMenuitem *root, - UsersServiceDbus *service) +rebuild_session_items (DbusmenuMenuitem *root) + { gboolean can_lockscreen; @@ -725,17 +509,6 @@ rebuild_session_items (DbusmenuMenuitem *root, return; } -/* Signal called when a user is added. It updates the count and - rebuilds the menu */ -static void -user_change (UsersServiceDbus *service, - const gchar *user_id, - gpointer user_data) -{ - DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; - rebuild_user_items (root, service); - return; -} /* When the service interface starts to shutdown, we should follow it. */ @@ -819,18 +592,18 @@ main (int argc, char ** argv) g_idle_add(lock_screen_setup, NULL); session_root_menuitem = dbusmenu_menuitem_new(); - g_debug("Session Root ID: %d", dbusmenu_menuitem_get_id(session_root_menuitem)); - - dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); - - rebuild_session_items (session_root_menuitem, dbus_interface); + rebuild_session_items (session_root_menuitem); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, session_root_menuitem); - users_root_menuitem = dbusmenu_menuitem_new(); - rebuild_user_items (users_root_menuitem, dbus_interface); - g_signal_connect (G_OBJECT (dbus_interface), + + // Users + UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); + + //users_root_menuitem = dbusmenu_menuitem_new(); + //rebuild_user_items (users_root_menuitem, dbus_interface); + /*g_signal_connect (G_OBJECT (dbus_interface), "user-added", G_CALLBACK (user_change), users_root_menuitem); @@ -838,13 +611,13 @@ main (int argc, char ** argv) "user-removed", G_CALLBACK (user_change), users_root_menuitem); + */ setup_restart_watch(); - setup_up(); DbusmenuServer * users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); - dbusmenu_server_set_root (users_server, users_root_menuitem); + dbusmenu_server_set_root (users_server, user_mgr->root_item); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/src/users-menu-mgr.c b/src/users-menu-mgr.c new file mode 100644 index 0000000..a736dfd --- /dev/null +++ b/src/users-menu-mgr.c @@ -0,0 +1,303 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * user-menu-mgr.c + * Copyright (C) Conor Curran 2011 + * + * user-menu-mgr.c is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * user-menu-mgr.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + + */ + +#include "user-menu-mgr.h" +#include "gconf-helper.h" +#include "users-service-dbus.h" + +static GConfClient * gconf_client = NULL; +static DbusmenuMenuitem *switch_menuitem = NULL; + +G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); + +static void activate_new_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); +static void activate_user_session (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data) +static gint compare_users_by_username (const gchar *a, + const gchar *b); +static void activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data); + +static void +user_menu_mgr_init (UserMenuMgr *self) +{ + self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); + self->root_item = dbusmenu_menuitem_new (); + user_menu_mgr_rebuild_items (self); +} + +static void +user_menu_mgr_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + G_OBJECT_CLASS (user_menu_mgr_parent_class)->finalize (object); +} + +static void +user_menu_mgr_class_init (UserMenuMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + GObjectClass* parent_class = G_OBJECT_CLASS (klass); + + object_class->finalize = user_menu_mgr_finalize; +} + +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ +static void +ensure_gconf_client () +{ + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); + gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); + } +} + +/* Builds up the menu for us */ +static void +user_menu_mgr_rebuild_items (UserMenuMgr *self) +{ + DbusmenuMenuitem *mi = NULL; + DbusmenuMenuitem *guest_mi = NULL; + GList *u; + UserData *user; + gboolean can_activate; + GList *children; + + /* Make sure we have a valid GConf client, and build one + if needed */ + ensure_gconf_client (); + + /* Check to see which menu items we're allowed to have */ + can_activate = users_service_dbus_can_activate_session (service) && + !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + + /* Remove the old menu items if that makes sense */ + children = dbusmenu_menuitem_take_children (root); + g_list_foreach (children, (GFunc)g_object_unref, NULL); + g_list_free (children); + + /* Set to NULL just incase we don't end up building one */ + users_service_dbus_set_guest_item(service, NULL); + + /* Build all of the user switching items */ + if (can_activate == TRUE) + { + if (check_new_session ()){ + 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()); + dbusmenu_menuitem_child_append (self->root, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_new_session), + service); + } + + GList * users = NULL; + users = users_service_dbus_get_user_list (service); + self->user_count = g_list_length(users); + + // TODO !!!!! + // g_debug ("USER COUNT = %i", user_count); + // We only want to show this menu when we have more than one registered + // user + // session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); + + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + } + + for (u = users; u != NULL; u = g_list_next (u)) { + user = u->data; + user->service = service; + + g_debug ("%i %s", (gint)user->uid, user->user_name); + + 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); + } + /* If we're showing user accounts, keep going through the list */ + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + continue; + } + /* If not, we can stop here */ + break; + } + + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + if (user->real_name_conflict) { + gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); + g_free(conflictedname); + } else { + 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); + if (user->icon_file != NULL && user->icon_file[0] != '\0') { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } + + gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; + dbusmenu_menuitem_property_set_bool (mi, + USER_ITEM_PROP_IS_CURRENT_USER, + logged_in); + // TODO + // Figure where this lives. + if (logged_in == TRUE){ + 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 (session_dbus, user->real_name); + } + + dbusmenu_menuitem_child_append (self->root_item, mi); + g_signal_connect (G_OBJECT (mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_user_session), + user); + user->menuitem = mi; + } + } + g_list_free(users); + } + // Add the online accounts and separator + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator1, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append (self->root_item, separator1); + DbusmenuMenuitem * online_accounts_item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_DEFAULT); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Online Accounts...")); + + g_signal_connect (G_OBJECT (online_accounts_item), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_online_accounts), + NULL); + + dbusmenu_menuitem_child_append (self->root_item, online_accounts_item); +} + +/* Checks to see if we can create sessions */ +// TODO what is this ? +static gboolean +check_new_session (void) +{ + return TRUE; +} + +/* Starts a new generic session */ +static void +activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + lock_if_possible(); + + users_service_dbus_show_greeter (USERS_SERVICE_DBUS(user_data)); + + return; +} + +/* Activates a session for a particular user. */ +static void +activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) +{ + UserData *user = (UserData *)user_data; + UsersServiceDbus *service = user->service; + + lock_if_possible(); + + users_service_dbus_activate_user_session (service, user); +} + +/* Comparison function to look into the UserData struct + to compare by using the username value */ +static gint +compare_users_by_username (const gchar *a, + const gchar *b) +{ + UserData *user1 = (UserData *)a; + UserData *user2 = (UserData *)b; + + gint retval = g_strcmp0 (user1->real_name, user2->real_name); + + /* If they're the same, they're both in conflict. */ + if (retval == 0) { + user1->real_name_conflict = TRUE; + user2->real_name_conflict = TRUE; + } + + return retval; +} + +// TODO +// Wait until dialog is complete to find out name to pass +// to the control centre. +static void +activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-control-center online-accounts", &error)) + { + g_warning("Unable to show control centre: %s", error->message); + g_error_free(error); + } +} + +/* Signal called when a user is added. It updates the count and + rebuilds the menu */ +static void +user_change (UsersServiceDbus *service, + const gchar *user_id, + gpointer user_data) +{ + DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; + rebuild_user_items (root, service); + return; +} + + diff --git a/src/users-menu-mgr.h b/src/users-menu-mgr.h new file mode 100644 index 0000000..c573b91 --- /dev/null +++ b/src/users-menu-mgr.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * user-menu-mgr.c + * Copyright (C) Conor Curran 2011 + * + * user-menu-mgr.c is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * user-menu-mgr.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + + */ + +#ifndef _USER_MENU_MGR_H_ +#define _USER_MENU_MGR_H_ + +#include + +G_BEGIN_DECLS + +#define USER_TYPE_MENU_MGR (user_menu_mgr_get_type ()) +#define USER_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USER_TYPE_MENU_MGR, UserMenuMgr)) +#define USER_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USER_TYPE_MENU_MGR, UserMenuMgrClass)) +#define USER_IS_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USER_TYPE_MENU_MGR)) +#define USER_IS_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USER_TYPE_MENU_MGR)) +#define USER_MENU_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USER_TYPE_MENU_MGR, UserMenuMgrClass)) + +typedef struct _UserMenuMgrClass UserMenuMgrClass; +typedef struct _UserMenuMgr UserMenuMgr; + +struct _UserMenuMgrClass +{ + GObjectClass parent_class; +}; + +struct _UserMenuMgr +{ + GObject parent_instance; + UsersServiceDbus* users_dbus_interface; + DbusmenuMenuitem* root_item; + gint user_count; +}; + +GType user_menu_mgr_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _USER_MENU_MGR_H_ */ -- cgit v1.2.3 From a25c68ce0d98e56921f38683a81e6d996446f744 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 15 Jul 2011 12:07:46 +0100 Subject: please tidy up that user manager --- src/users-menu-mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/users-menu-mgr.c b/src/users-menu-mgr.c index a736dfd..baf08ab 100644 --- a/src/users-menu-mgr.c +++ b/src/users-menu-mgr.c @@ -18,7 +18,7 @@ */ -#include "user-menu-mgr.h" +#include "users-menu-mgr.h" #include "gconf-helper.h" #include "users-service-dbus.h" -- cgit v1.2.3 From 019030dc92107fb553e1f791cc2225b67b74968b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 15 Jul 2011 12:54:17 +0100 Subject: first step - it compiles --- src/Makefile.am | 4 +- src/session-service.c | 20 +-- src/user-menu-mgr.c | 336 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/user-menu-mgr.h | 56 +++++++++ src/users-menu-mgr.c | 303 --------------------------------------------- src/users-menu-mgr.h | 55 --------- 6 files changed, 397 insertions(+), 377 deletions(-) create mode 100644 src/user-menu-mgr.c create mode 100644 src/user-menu-mgr.h delete mode 100644 src/users-menu-mgr.c delete mode 100644 src/users-menu-mgr.h diff --git a/src/Makefile.am b/src/Makefile.am index 17dd041..9bf43cd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -92,8 +92,8 @@ indicator_session_service_SOURCES = \ gconf-helper.c \ users-service-dbus.h \ users-service-dbus.c \ - users_menu_mgr.h \ - users_menu_mgr.c + user-menu-mgr.h \ + user-menu-mgr.c indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/session-service.c b/src/session-service.c index 78cd9ae..6095838 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -44,7 +44,7 @@ with this program. If not, see . #include "dbus-shared-names.h" #include "dbusmenu-shared.h" #include "users-service-dbus.h" -#include "users-menu-mgr.h" +#include "user-menu-mgr.h" #include "gconf-helper.h" @@ -52,7 +52,6 @@ with this program. If not, see . #include "lock-helper.h" #include "upower-client.h" - #define UP_ADDRESS "org.freedesktop.UPower" #define UP_OBJECT "/org/freedesktop/UPower" #define UP_INTERFACE "org.freedesktop.UPower" @@ -160,9 +159,8 @@ lock_if_possible (void) { ensure_gconf_client (); if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { - lock_screen(NULL, 0, NULL); + lock_screen (NULL, 0, NULL); } - return; } @@ -600,19 +598,7 @@ main (int argc, char ** argv) // Users UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); - - //users_root_menuitem = dbusmenu_menuitem_new(); - //rebuild_user_items (users_root_menuitem, dbus_interface); - /*g_signal_connect (G_OBJECT (dbus_interface), - "user-added", - G_CALLBACK (user_change), - users_root_menuitem); - g_signal_connect (G_OBJECT (dbus_interface), - "user-removed", - G_CALLBACK (user_change), - users_root_menuitem); - */ - + setup_restart_watch(); setup_up(); diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c new file mode 100644 index 0000000..404114a --- /dev/null +++ b/src/user-menu-mgr.c @@ -0,0 +1,336 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * user-menu-mgr.c + * Copyright (C) Conor Curran 2011 + * + * user-menu-mgr.c is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * user-menu-mgr.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + + */ + +#include +#include + +#include "user-menu-mgr.h" +#include "gconf-helper.h" +#include "dbus-shared-names.h" +#include "dbusmenu-shared.h" +#include "lock-helper.h" + + +static GConfClient * gconf_client = NULL; +static DbusmenuMenuitem *switch_menuitem = NULL; + +G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); + +static void activate_new_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); +static void activate_user_session (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data); +static gint compare_users_by_username (const gchar *a, + const gchar *b); +static void activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data); +static void user_menu_mgr_rebuild_items (UserMenuMgr *self); +static gboolean check_new_session (); +static void user_change (UsersServiceDbus *service, + const gchar *user_id, + gpointer user_data); + + +static void +user_menu_mgr_init (UserMenuMgr *self) +{ + self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); + self->root_item = dbusmenu_menuitem_new (); + user_menu_mgr_rebuild_items (self); + g_signal_connect (G_OBJECT (self->users_dbus_interface), + "user-added", + G_CALLBACK (user_change), + self); + g_signal_connect (G_OBJECT (self->users_dbus_interface), + "user-removed", + G_CALLBACK (user_change), + self); +} + +static void +user_menu_mgr_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + G_OBJECT_CLASS (user_menu_mgr_parent_class)->finalize (object); +} + +static void +user_menu_mgr_class_init (UserMenuMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + //GObjectClass* parent_class = G_OBJECT_CLASS (klass); + + object_class->finalize = user_menu_mgr_finalize; +} + +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ +static void +ensure_gconf_client () +{ + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + } +} + +/* Builds up the menu for us */ +static void +user_menu_mgr_rebuild_items (UserMenuMgr *self) +{ + DbusmenuMenuitem *mi = NULL; + DbusmenuMenuitem *guest_mi = NULL; + GList *u; + UserData *user; + gboolean can_activate; + GList *children; + + /* Make sure we have a valid GConf client, and build one + if needed */ + ensure_gconf_client (); + + /* Check to see which menu items we're allowed to have */ + can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) && + !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); + + /* Remove the old menu items if that makes sense */ + children = dbusmenu_menuitem_take_children (self->root_item); + g_list_foreach (children, (GFunc)g_object_unref, NULL); + g_list_free (children); + + /* Set to NULL just incase we don't end up building one */ + users_service_dbus_set_guest_item(self->users_dbus_interface, NULL); + + /* Build all of the user switching items */ + if (can_activate == TRUE) + { + if (check_new_session ()){ + 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()); + dbusmenu_menuitem_child_append (self->root_item, switch_menuitem); + g_signal_connect (G_OBJECT (switch_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_new_session), + self->users_dbus_interface); + } + + GList * users = NULL; + users = users_service_dbus_get_user_list (self->users_dbus_interface); + self->user_count = g_list_length(users); + + // TODO !!!!! + // g_debug ("USER COUNT = %i", user_count); + // We only want to show this menu when we have more than one registered + // user + // session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); + + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + users = g_list_sort (users, (GCompareFunc)compare_users_by_username); + } + + for (u = users; u != NULL; u = g_list_next (u)) { + user = u->data; + user->service = self->users_dbus_interface; + + g_debug ("%i %s", (gint)user->uid, user->user_name); + + 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); + } + /* If we're showing user accounts, keep going through the list */ + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + continue; + } + /* If not, we can stop here */ + break; + } + + if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + if (user->real_name_conflict) { + gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); + dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); + g_free(conflictedname); + } else { + 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); + if (user->icon_file != NULL && user->icon_file[0] != '\0') { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); + } else { + dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); + } + + gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; + dbusmenu_menuitem_property_set_bool (mi, + USER_ITEM_PROP_IS_CURRENT_USER, + logged_in); + // TODO + // Figure where this lives. + /*if (logged_in == TRUE){ + 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 (session_dbus, user->real_name); + }*/ + + dbusmenu_menuitem_child_append (self->root_item, mi); + g_signal_connect (G_OBJECT (mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_user_session), + user); + user->menuitem = mi; + } + } + g_list_free(users); + } + // Add the online accounts and separator + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator1, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append (self->root_item, separator1); + DbusmenuMenuitem * online_accounts_item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_DEFAULT); + dbusmenu_menuitem_property_set (online_accounts_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Online Accounts...")); + + g_signal_connect (G_OBJECT (online_accounts_item), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_online_accounts), + NULL); + + dbusmenu_menuitem_child_append (self->root_item, online_accounts_item); +} + +/* Checks to see if we can create sessions */ +// TODO what is this ? +static gboolean +check_new_session () +{ + return TRUE; +} + +/* Check to see if the lockdown key is protecting from + locking the screen. If not, lock it. */ +static void +lock_if_possible (void) { + ensure_gconf_client (); + + if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + lock_screen(NULL, 0, NULL); + } + + return; +} + + +/* Starts a new generic session */ +static void +activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + lock_if_possible(); + + users_service_dbus_show_greeter (USERS_SERVICE_DBUS(user_data)); + + return; +} + +/* Activates a session for a particular user. */ +static void +activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) +{ + UserData *user = (UserData *)user_data; + UsersServiceDbus *service = user->service; + + lock_if_possible(); + + users_service_dbus_activate_user_session (service, user); +} + +/* Comparison function to look into the UserData struct + to compare by using the username value */ +static gint +compare_users_by_username (const gchar *a, + const gchar *b) +{ + UserData *user1 = (UserData *)a; + UserData *user2 = (UserData *)b; + + gint retval = g_strcmp0 (user1->real_name, user2->real_name); + + /* If they're the same, they're both in conflict. */ + if (retval == 0) { + user1->real_name_conflict = TRUE; + user2->real_name_conflict = TRUE; + } + + return retval; +} + +// TODO +// Wait until dialog is complete to find out name to pass +// to the control centre. +static void +activate_online_accounts (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-control-center online-accounts", &error)) + { + g_warning("Unable to show control centre: %s", error->message); + g_error_free(error); + } +} + +/* Signal called when a user is added. It updates the count and + rebuilds the menu */ +static void +user_change (UsersServiceDbus *service, + const gchar *user_id, + gpointer user_data) +{ + //DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; + // TODO sort this out. + //rebuild_user_items (root, service); + return; +} + + diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h new file mode 100644 index 0000000..214c9c7 --- /dev/null +++ b/src/user-menu-mgr.h @@ -0,0 +1,56 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * user-menu-mgr.c + * Copyright (C) Conor Curran 2011 + * + * user-menu-mgr.c is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * user-menu-mgr.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + + */ + +#ifndef _USER_MENU_MGR_H_ +#define _USER_MENU_MGR_H_ + +#include +#include "users-service-dbus.h" + +G_BEGIN_DECLS + +#define USER_TYPE_MENU_MGR (user_menu_mgr_get_type ()) +#define USER_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USER_TYPE_MENU_MGR, UserMenuMgr)) +#define USER_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USER_TYPE_MENU_MGR, UserMenuMgrClass)) +#define USER_IS_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USER_TYPE_MENU_MGR)) +#define USER_IS_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USER_TYPE_MENU_MGR)) +#define USER_MENU_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USER_TYPE_MENU_MGR, UserMenuMgrClass)) + +typedef struct _UserMenuMgrClass UserMenuMgrClass; +typedef struct _UserMenuMgr UserMenuMgr; + +struct _UserMenuMgrClass +{ + GObjectClass parent_class; +}; + +struct _UserMenuMgr +{ + GObject parent_instance; + UsersServiceDbus* users_dbus_interface; + DbusmenuMenuitem* root_item; + gint user_count; +}; + +GType user_menu_mgr_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _USER_MENU_MGR_H_ */ diff --git a/src/users-menu-mgr.c b/src/users-menu-mgr.c deleted file mode 100644 index baf08ab..0000000 --- a/src/users-menu-mgr.c +++ /dev/null @@ -1,303 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * user-menu-mgr.c - * Copyright (C) Conor Curran 2011 - * - * user-menu-mgr.c is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * user-menu-mgr.c is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - - */ - -#include "users-menu-mgr.h" -#include "gconf-helper.h" -#include "users-service-dbus.h" - -static GConfClient * gconf_client = NULL; -static DbusmenuMenuitem *switch_menuitem = NULL; - -G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); - -static void activate_new_session (DbusmenuMenuitem * mi, - guint timestamp, - gpointer user_data); -static void activate_user_session (DbusmenuMenuitem *mi, - guint timestamp, - gpointer user_data) -static gint compare_users_by_username (const gchar *a, - const gchar *b); -static void activate_online_accounts (DbusmenuMenuitem *mi, - guint timestamp, - gpointer user_data); - -static void -user_menu_mgr_init (UserMenuMgr *self) -{ - self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); - self->root_item = dbusmenu_menuitem_new (); - user_menu_mgr_rebuild_items (self); -} - -static void -user_menu_mgr_finalize (GObject *object) -{ - /* TODO: Add deinitalization code here */ - G_OBJECT_CLASS (user_menu_mgr_parent_class)->finalize (object); -} - -static void -user_menu_mgr_class_init (UserMenuMgrClass *klass) -{ - GObjectClass* object_class = G_OBJECT_CLASS (klass); - GObjectClass* parent_class = G_OBJECT_CLASS (klass); - - object_class->finalize = user_menu_mgr_finalize; -} - -/* Ensures that we have a GConf client and if we build one - set up the signal handler. */ -static void -ensure_gconf_client () -{ - if (!gconf_client) { - gconf_client = gconf_client_get_default (); - gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); - gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); - } -} - -/* Builds up the menu for us */ -static void -user_menu_mgr_rebuild_items (UserMenuMgr *self) -{ - DbusmenuMenuitem *mi = NULL; - DbusmenuMenuitem *guest_mi = NULL; - GList *u; - UserData *user; - gboolean can_activate; - GList *children; - - /* Make sure we have a valid GConf client, and build one - if needed */ - ensure_gconf_client (); - - /* Check to see which menu items we're allowed to have */ - can_activate = users_service_dbus_can_activate_session (service) && - !gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_USER, NULL); - - /* Remove the old menu items if that makes sense */ - children = dbusmenu_menuitem_take_children (root); - g_list_foreach (children, (GFunc)g_object_unref, NULL); - g_list_free (children); - - /* Set to NULL just incase we don't end up building one */ - users_service_dbus_set_guest_item(service, NULL); - - /* Build all of the user switching items */ - if (can_activate == TRUE) - { - if (check_new_session ()){ - 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()); - dbusmenu_menuitem_child_append (self->root, switch_menuitem); - g_signal_connect (G_OBJECT (switch_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_new_session), - service); - } - - GList * users = NULL; - users = users_service_dbus_get_user_list (service); - self->user_count = g_list_length(users); - - // TODO !!!!! - // g_debug ("USER COUNT = %i", user_count); - // We only want to show this menu when we have more than one registered - // user - // session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); - - if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { - users = g_list_sort (users, (GCompareFunc)compare_users_by_username); - } - - for (u = users; u != NULL; u = g_list_next (u)) { - user = u->data; - user->service = service; - - g_debug ("%i %s", (gint)user->uid, user->user_name); - - 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); - } - /* If we're showing user accounts, keep going through the list */ - if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { - continue; - } - /* If not, we can stop here */ - break; - } - - if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { - mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); - if (user->real_name_conflict) { - gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); - g_free(conflictedname); - } else { - 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); - if (user->icon_file != NULL && user->icon_file[0] != '\0') { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); - } else { - dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, USER_ITEM_ICON_DEFAULT); - } - - gboolean logged_in = g_strcmp0 (user->user_name, g_get_user_name()) == 0; - dbusmenu_menuitem_property_set_bool (mi, - USER_ITEM_PROP_IS_CURRENT_USER, - logged_in); - // TODO - // Figure where this lives. - if (logged_in == TRUE){ - 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 (session_dbus, user->real_name); - } - - dbusmenu_menuitem_child_append (self->root_item, mi); - g_signal_connect (G_OBJECT (mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_user_session), - user); - user->menuitem = mi; - } - } - g_list_free(users); - } - // Add the online accounts and separator - DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (separator1, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append (self->root_item, separator1); - DbusmenuMenuitem * online_accounts_item = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (online_accounts_item, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_DEFAULT); - dbusmenu_menuitem_property_set (online_accounts_item, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Online Accounts...")); - - g_signal_connect (G_OBJECT (online_accounts_item), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_online_accounts), - NULL); - - dbusmenu_menuitem_child_append (self->root_item, online_accounts_item); -} - -/* Checks to see if we can create sessions */ -// TODO what is this ? -static gboolean -check_new_session (void) -{ - return TRUE; -} - -/* Starts a new generic session */ -static void -activate_new_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) -{ - lock_if_possible(); - - users_service_dbus_show_greeter (USERS_SERVICE_DBUS(user_data)); - - return; -} - -/* Activates a session for a particular user. */ -static void -activate_user_session (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data) -{ - UserData *user = (UserData *)user_data; - UsersServiceDbus *service = user->service; - - lock_if_possible(); - - users_service_dbus_activate_user_session (service, user); -} - -/* Comparison function to look into the UserData struct - to compare by using the username value */ -static gint -compare_users_by_username (const gchar *a, - const gchar *b) -{ - UserData *user1 = (UserData *)a; - UserData *user2 = (UserData *)b; - - gint retval = g_strcmp0 (user1->real_name, user2->real_name); - - /* If they're the same, they're both in conflict. */ - if (retval == 0) { - user1->real_name_conflict = TRUE; - user2->real_name_conflict = TRUE; - } - - return retval; -} - -// TODO -// Wait until dialog is complete to find out name to pass -// to the control centre. -static void -activate_online_accounts (DbusmenuMenuitem *mi, - guint timestamp, - gpointer user_data) -{ - GError * error = NULL; - if (!g_spawn_command_line_async("gnome-control-center online-accounts", &error)) - { - g_warning("Unable to show control centre: %s", error->message); - g_error_free(error); - } -} - -/* Signal called when a user is added. It updates the count and - rebuilds the menu */ -static void -user_change (UsersServiceDbus *service, - const gchar *user_id, - gpointer user_data) -{ - DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data; - rebuild_user_items (root, service); - return; -} - - diff --git a/src/users-menu-mgr.h b/src/users-menu-mgr.h deleted file mode 100644 index c573b91..0000000 --- a/src/users-menu-mgr.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ -/* - * user-menu-mgr.c - * Copyright (C) Conor Curran 2011 - * - * user-menu-mgr.c is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * user-menu-mgr.c is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - - */ - -#ifndef _USER_MENU_MGR_H_ -#define _USER_MENU_MGR_H_ - -#include - -G_BEGIN_DECLS - -#define USER_TYPE_MENU_MGR (user_menu_mgr_get_type ()) -#define USER_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USER_TYPE_MENU_MGR, UserMenuMgr)) -#define USER_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USER_TYPE_MENU_MGR, UserMenuMgrClass)) -#define USER_IS_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USER_TYPE_MENU_MGR)) -#define USER_IS_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USER_TYPE_MENU_MGR)) -#define USER_MENU_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USER_TYPE_MENU_MGR, UserMenuMgrClass)) - -typedef struct _UserMenuMgrClass UserMenuMgrClass; -typedef struct _UserMenuMgr UserMenuMgr; - -struct _UserMenuMgrClass -{ - GObjectClass parent_class; -}; - -struct _UserMenuMgr -{ - GObject parent_instance; - UsersServiceDbus* users_dbus_interface; - DbusmenuMenuitem* root_item; - gint user_count; -}; - -GType user_menu_mgr_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* _USER_MENU_MGR_H_ */ -- cgit v1.2.3 From 797cf05a2f643dfed7b70db6abf2095f1216aa89 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 15 Jul 2011 16:26:37 +0100 Subject: user menu nicely separated for now, next the session menu --- src/session-service.c | 8 +++--- src/user-menu-mgr.c | 74 +++++++++++++++++++++++++++++++++------------------ src/user-menu-mgr.h | 15 +++++------ 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index 6095838..23cb6ab 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -595,15 +595,15 @@ main (int argc, char ** argv) DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, session_root_menuitem); - // Users - UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); setup_restart_watch(); setup_up(); - DbusmenuServer * users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); - dbusmenu_server_set_root (users_server, user_mgr->root_item); + DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); + + dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 404114a..8338739 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -18,7 +18,6 @@ */ -#include #include #include "user-menu-mgr.h" @@ -26,12 +25,19 @@ #include "dbus-shared-names.h" #include "dbusmenu-shared.h" #include "lock-helper.h" - +#include "users-service-dbus.h" static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; -G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); +struct _UserMenuMgr +{ + GObject parent_instance; + UsersServiceDbus* users_dbus_interface; + DbusmenuMenuitem* root_item; + gint user_count; + SessionDbus* session_dbus_interface; +}; static void activate_new_session (DbusmenuMenuitem * mi, guint timestamp, @@ -50,13 +56,16 @@ static void user_change (UsersServiceDbus *service, const gchar *user_id, gpointer user_data); +static void ensure_gconf_client (); + +G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); + static void user_menu_mgr_init (UserMenuMgr *self) { self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); self->root_item = dbusmenu_menuitem_new (); - user_menu_mgr_rebuild_items (self); g_signal_connect (G_OBJECT (self->users_dbus_interface), "user-added", G_CALLBACK (user_change), @@ -83,18 +92,6 @@ user_menu_mgr_class_init (UserMenuMgrClass *klass) object_class->finalize = user_menu_mgr_finalize; } -/* Ensures that we have a GConf client and if we build one - set up the signal handler. */ -static void -ensure_gconf_client () -{ - if (!gconf_client) { - gconf_client = gconf_client_get_default (); - gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - } -} - /* Builds up the menu for us */ static void user_menu_mgr_rebuild_items (UserMenuMgr *self) @@ -144,11 +141,8 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) users = users_service_dbus_get_user_list (self->users_dbus_interface); self->user_count = g_list_length(users); - // TODO !!!!! - // g_debug ("USER COUNT = %i", user_count); - // We only want to show this menu when we have more than one registered - // user - // session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); + g_debug ("USER COUNT = %i", self->user_count); + session_dbus_set_user_menu_visibility (self->session_dbus_interface, self->user_count > 1); if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { users = g_list_sort (users, (GCompareFunc)compare_users_by_username); @@ -199,13 +193,11 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_IS_CURRENT_USER, logged_in); - // TODO - // Figure where this lives. - /*if (logged_in == TRUE){ + if (logged_in == TRUE){ 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 (session_dbus, user->real_name); - }*/ + session_dbus_set_users_real_name (self->session_dbus_interface, user->real_name); + } dbusmenu_menuitem_child_append (self->root_item, mi); g_signal_connect (G_OBJECT (mi), @@ -333,4 +325,34 @@ user_change (UsersServiceDbus *service, return; } +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ +static void +ensure_gconf_client () +{ + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + gconf_client_add_dir (gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_add_dir (gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + } +} + +DbusmenuMenuitem* +user_mgr_get_root_item (UserMenuMgr* self) +{ + return self->root_item; +} + + +/* + * Clean Entry Point + */ +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus) +{ + UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); + user_mgr->session_dbus_interface = session_dbus; + user_menu_mgr_rebuild_items (user_mgr); + return user_mgr; +} + diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h index 214c9c7..16ac055 100644 --- a/src/user-menu-mgr.h +++ b/src/user-menu-mgr.h @@ -21,8 +21,11 @@ #ifndef _USER_MENU_MGR_H_ #define _USER_MENU_MGR_H_ + #include -#include "users-service-dbus.h" +#include + +#include "session-dbus.h" G_BEGIN_DECLS @@ -41,16 +44,10 @@ struct _UserMenuMgrClass GObjectClass parent_class; }; -struct _UserMenuMgr -{ - GObject parent_instance; - UsersServiceDbus* users_dbus_interface; - DbusmenuMenuitem* root_item; - gint user_count; -}; - GType user_menu_mgr_get_type (void) G_GNUC_CONST; +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus); +DbusmenuMenuitem* user_mgr_get_root_item (UserMenuMgr* self); G_END_DECLS #endif /* _USER_MENU_MGR_H_ */ -- cgit v1.2.3 From eefb008c18560d9e0c7505e0dad7216bf2441bd8 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Fri, 15 Jul 2011 12:58:26 -0400 Subject: releasing version 0.2.93-0ubuntu1 --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a0f1515..61af3b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-session (0.2.93-0ubuntu1) UNRELEASED; urgency=low +indicator-session (0.2.93-0ubuntu1) oneiric; urgency=low * New upstream release. * debian/control -- cgit v1.2.3 From 21edabb3c895ebb60e2ef125d94ca58e256bdb03 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 18 Jul 2011 12:19:38 +0100 Subject: session menu mgr in progress --- src/Makefile.am | 4 ++- src/device-menu-mgr.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/device-menu-mgr.h | 54 ++++++++++++++++++++++++++++++++++++++++ src/user-menu-mgr.c | 33 ++++++++++++------------ src/user-menu-mgr.h | 36 +++++++++++++-------------- 5 files changed, 160 insertions(+), 36 deletions(-) create mode 100644 src/device-menu-mgr.c create mode 100644 src/device-menu-mgr.h diff --git a/src/Makefile.am b/src/Makefile.am index 9bf43cd..2230910 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,7 +93,9 @@ indicator_session_service_SOURCES = \ users-service-dbus.h \ users-service-dbus.c \ user-menu-mgr.h \ - user-menu-mgr.c + user-menu-mgr.c \ + device-menu-mgr.h \ + device-menu-mgr.c indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c new file mode 100644 index 0000000..2bddbb3 --- /dev/null +++ b/src/device-menu-mgr.c @@ -0,0 +1,69 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + + +#include "device-menu-mgr.h" + +struct _DeviceMenuMgr +{ + GObject parent_instance; + DbusmenuMenuitem* root_item; + SessionDbus* session_dbus_interface; +}; + +G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); + +static void +device_menu_mgr_init (DeviceMenuMgr *object) +{ + /* TODO: Add initialization code here */ +} + +static void +device_menu_mgr_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + + G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object); +} + +static void +device_menu_mgr_class_init (DeviceMenuMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + //GObjectClass* parent_class = G_OBJECT_CLASS (klass); + object_class->finalize = device_menu_mgr_finalize; +} + +DbusmenuMenuitem* +device_mgr_get_root_item (DeviceMenuMgr* self) +{ + return self->root_item; +} + +/* + * Clean Entry Point + */ +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus) +{ + DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); + device_mgr->session_dbus_interface = session_dbus; + //device_menu_mgr_rebuild_items (device_mgr); + return device_mgr; +} diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h new file mode 100644 index 0000000..caa9aee --- /dev/null +++ b/src/device-menu-mgr.h @@ -0,0 +1,54 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + + +#ifndef _DEVICE_MENU_MGR_H_ +#define _DEVICE_MENU_MGR_H_ + +#include +#include + +#include "session-dbus.h" + +G_BEGIN_DECLS + +#define DEVICE_TYPE_MENU_MGR (device_menu_mgr_get_type ()) +#define DEVICE_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEVICE_TYPE_MENU_MGR, DeviceMenuMgr)) +#define DEVICE_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEVICE_TYPE_MENU_MGR, DeviceMenuMgrClass)) +#define DEVICE_IS_MENU_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEVICE_TYPE_MENU_MGR)) +#define DEVICE_IS_MENU_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEVICE_TYPE_MENU_MGR)) +#define DEVICE_MENU_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEVICE_TYPE_MENU_MGR, DeviceMenuMgrClass)) + +typedef struct _DeviceMenuMgrClass DeviceMenuMgrClass; +typedef struct _DeviceMenuMgr DeviceMenuMgr; + +struct _DeviceMenuMgrClass +{ + GObjectClass parent_class; +}; + +GType device_menu_mgr_get_type (void) G_GNUC_CONST; + +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus); + +DbusmenuMenuitem* device_mgr_get_root_item (DeviceMenuMgr* self); + +G_END_DECLS + +#endif /* _DEVICE_MENU_MGR_H_ */ diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 8338739..611bcc7 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -1,22 +1,21 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * user-menu-mgr.c - * Copyright (C) Conor Curran 2011 - * - * user-menu-mgr.c is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * user-menu-mgr.c is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . +Copyright 2011 Canonical Ltd. - */ +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ #include diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h index 16ac055..ff2cb77 100644 --- a/src/user-menu-mgr.h +++ b/src/user-menu-mgr.h @@ -1,22 +1,22 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * user-menu-mgr.c - * Copyright (C) Conor Curran 2011 - * - * user-menu-mgr.c is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * user-menu-mgr.c is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - - */ +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + #ifndef _USER_MENU_MGR_H_ #define _USER_MENU_MGR_H_ -- cgit v1.2.3 From 5762761151a8a8168c7bf0281d83682a260cbcce Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 18 Jul 2011 18:17:37 +0100 Subject: device menu has been isolated --- src/device-menu-mgr.c | 577 +++++++++++++++++++++++++++++++++++++++++++++++++- src/session-service.c | 517 +------------------------------------------- 2 files changed, 582 insertions(+), 512 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 2bddbb3..0114b92 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -17,8 +17,18 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #include "device-menu-mgr.h" +#include "gconf-helper.h" +#include "dbus-shared-names.h" +#include "dbusmenu-shared.h" +#include "lock-helper.h" +#include "upower-client.h" + +#define UP_ADDRESS "org.freedesktop.UPower" +#define UP_OBJECT "/org/freedesktop/UPower" +#define UP_INTERFACE "org.freedesktop.UPower" + +#define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications" struct _DeviceMenuMgr { @@ -27,22 +37,61 @@ struct _DeviceMenuMgr SessionDbus* session_dbus_interface; }; +static GConfClient *gconf_client = NULL; +static DbusmenuMenuitem *lock_menuitem = NULL; + +static DBusGProxyCall * suspend_call = NULL; +static DBusGProxyCall * hibernate_call = NULL; + +static DbusmenuMenuitem * hibernate_mi = NULL; +static DbusmenuMenuitem * suspend_mi = NULL; +static DbusmenuMenuitem * logout_mi = NULL; +static DbusmenuMenuitem * restart_mi = NULL; +static DbusmenuMenuitem * shutdown_mi = NULL; + +static gboolean can_hibernate = TRUE; +static gboolean can_suspend = TRUE; +static gboolean allow_hibernate = TRUE; +static gboolean allow_suspend = TRUE; + +static DBusGProxy * up_main_proxy = NULL; +static DBusGProxy * up_prop_proxy = NULL; + +static void device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self); +static void setup_restart_watch (DeviceMenuMgr* self); +static void setup_up (DeviceMenuMgr* self); +static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self); +static void lock_if_possible (DeviceMenuMgr* self); +static void machine_sleep_with_context (DeviceMenuMgr* self, + gchar* type); +static void +machine_sleep_from_hibernate (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata); +static void +machine_sleep_from_suspend (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata); + G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); static void -device_menu_mgr_init (DeviceMenuMgr *object) +device_menu_mgr_init (DeviceMenuMgr *self) { - /* TODO: Add initialization code here */ + self->root_item = dbusmenu_menuitem_new (); + setup_restart_watch(self); + setup_up(self); + g_idle_add(lock_screen_setup, NULL); } static void device_menu_mgr_finalize (GObject *object) { /* TODO: Add deinitalization code here */ - G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object); } +// TODO refactor into one helper method for both menu mgrs. static void device_menu_mgr_class_init (DeviceMenuMgrClass *klass) { @@ -51,6 +100,524 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) object_class->finalize = device_menu_mgr_finalize; } + +static void +lockdown_changed (GConfClient *client, + guint cnxd_id, + GConfEntry *entry, + gpointer user_data) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (user_data); + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); + + if (value == NULL || key == NULL) { + return; + } + + if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || + g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { + device_menu_mgr_rebuild_items(self); + } + + return; +} + +static void +keybinding_changed (GConfClient *client, + guint cnxd_id, + GConfEntry *entry, + gpointer user_data) +{ + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); + + if (value == NULL || key == NULL) { + return; + } + + if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { + g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); + if (lock_menuitem != NULL) { + dbusmenu_menuitem_property_set_shortcut_string (lock_menuitem, + gconf_value_get_string(value)); + } + } + return; +} + +/* Check to see if the lockdown key is protecting from + locking the screen. If not, lock it. */ +static void +lock_if_possible (DeviceMenuMgr* self) { + device_menu_mgr_ensure_gconf_client (self); + + if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { + lock_screen (NULL, 0, NULL); + } + return; +} + +/* A return from the command to sleep the system. Make sure + that we unthrottle the screensaver. */ +static void +sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) +{ + screensaver_unthrottle(); + return; +} + +static void +machine_sleep_from_suspend (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + machine_sleep_with_context (self, "Suspend"); +} + +static void +machine_sleep_from_hibernate (DbusmenuMenuitem * mi, + guint timestamp, + gpointer userdata) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + machine_sleep_with_context (self, "Hibernate"); +} + +/* Let's put this machine to sleep, with some info on how + it should sleep. */ +static void +machine_sleep_with_context (DeviceMenuMgr* self, gchar* type) +{ + if (up_main_proxy == NULL) { + g_warning("Can not %s as no upower proxy", type); + } + + screensaver_throttle(type); + lock_if_possible (self); + + dbus_g_proxy_begin_call(up_main_proxy, + type, + sleep_response, + NULL, + NULL, + G_TYPE_INVALID); + + return; +} + +/* A response to getting the suspend property */ +static void +suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) +{ + suspend_call = NULL; + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + + GValue candoit = {0}; + GError * error = NULL; + dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); + if (error != NULL) { + g_warning("Unable to check suspend: %s", error->message); + g_error_free(error); + return; + } + g_debug("Got Suspend: %s", g_value_get_boolean(&candoit) ? "true" : "false"); + + gboolean local_can_suspend = g_value_get_boolean(&candoit); + if (local_can_suspend != can_suspend) { + can_suspend = local_can_suspend; + device_menu_mgr_rebuild_items(self); + } + + return; +} + +/* Response to getting the hibernate property */ +static void +hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) +{ + hibernate_call = NULL; + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + + GValue candoit = {0}; + GError * error = NULL; + dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); + if (error != NULL) { + g_warning("Unable to check hibernate: %s", error->message); + g_error_free(error); + return; + } + g_debug("Got Hibernate: %s", g_value_get_boolean(&candoit) ? "true" : "false"); + + gboolean local_can_hibernate = g_value_get_boolean(&candoit); + if (local_can_hibernate != can_hibernate) { + can_hibernate = local_can_hibernate; + device_menu_mgr_rebuild_items(self); + } +} + +/* A signal that we need to recheck to ensure we can still + hibernate and/or suspend */ +static void +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(up_prop_proxy, + "Get", + suspend_prop_cb, + user_data, + NULL, + G_TYPE_STRING, + UP_INTERFACE, + G_TYPE_STRING, + "CanSuspend", + G_TYPE_INVALID, + G_TYPE_VALUE, + G_TYPE_INVALID); + } + + /* Start Async call to see if we can suspend */ + if (hibernate_call == NULL) { + hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, + "Get", + hibernate_prop_cb, + user_data, + NULL, + G_TYPE_STRING, + UP_INTERFACE, + G_TYPE_STRING, + "CanHibernate", + G_TYPE_INVALID, + G_TYPE_VALUE, + G_TYPE_INVALID); + } +} +/* Handle the callback from the allow functions to check and + see if we're changing the value, and if so, rebuilding the + menus based on that info. */ +static void +allowed_suspend_cb (DBusGProxy *proxy, + gboolean OUT_allowed, + GError *error, + gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get information on what is allowed from UPower: %s", + error->message); + return; + } + + if (OUT_allowed != allow_suspend) { + allow_suspend = OUT_allowed; + device_menu_mgr_rebuild_items(DEVICE_MENU_MGR (userdata)); + } +} + +/* Handle the callback from the allow functions to check and + see if we're changing the value, and if so, rebuilding the + menus based on that info. */ +static void +allowed_hibernate_cb (DBusGProxy *proxy, + gboolean OUT_allowed, + GError *error, + gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get information on what is allowed from UPower: %s", + error->message); + return; + } + + if (OUT_allowed != allow_hibernate) { + allow_hibernate = OUT_allowed; + device_menu_mgr_rebuild_items(DEVICE_MENU_MGR (userdata)); + } +} + +/* This function goes through and sets up what we need for + DKp checking. We're even setting up the calls for the props + we need */ +static void +setup_up (DeviceMenuMgr* self) { + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + g_return_if_fail(bus != NULL); + + 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); + /* Connect to changed signal */ + dbus_g_proxy_add_signal(up_main_proxy, + "Changed", + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal(up_main_proxy, + "Changed", + G_CALLBACK(up_changed_cb), + self, + NULL); + } + g_return_if_fail(up_prop_proxy != NULL); + + + /* Force an original "changed" event */ + up_changed_cb(up_main_proxy, self); + + /* Check to see if these are getting blocked by PolicyKit */ + org_freedesktop_UPower_suspend_allowed_async(up_main_proxy, + allowed_suspend_cb, + self); + org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy, + allowed_hibernate_cb, + self); + + return; +} + +/* This is the function to show a dialog on actions that + can destroy data. Currently it just calls the GTK version + but it seems that in the future it should figure out + what's going on and something better. */ +static void +show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) +{ + gchar * helper = g_build_filename(LIBEXECDIR, "gtk-logout-helper", NULL); + gchar * dialog_line = g_strdup_printf("%s --%s", helper, type); + g_free(helper); + + g_debug("Showing dialog '%s'", dialog_line); + + GError * error = NULL; + if (!g_spawn_command_line_async(dialog_line, &error)) { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } + + g_free(dialog_line); + + return; +} + + +static void +device_menu_mgr_rebuild_items (DeviceMenuMgr* self) +{ + gboolean can_lockscreen; + + /* Make sure we have a valid GConf client, and build one + if needed */ + device_menu_mgr_ensure_gconf_client (self); + + can_lockscreen = !gconf_client_get_bool ( gconf_client, + LOCKDOWN_KEY_SCREENSAVER, + NULL); + /* Lock screen item */ + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); + + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); + } else { + g_debug("Unable to get lock screen shortcut."); + } + + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); + } + + /* Start going through the session based items. */ + + logout_mi = dbusmenu_menuitem_new(); + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out")); + } else { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (logout_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_logout()); + dbusmenu_menuitem_child_append(self->root_item, logout_mi); + g_signal_connect( G_OBJECT(logout_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "logout"); + + if (can_suspend && allow_suspend) { + suspend_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (suspend_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Suspend")); + dbusmenu_menuitem_child_append (self->root_item, suspend_mi); + g_signal_connect( G_OBJECT(suspend_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep_from_suspend), + self); + } + + if (can_hibernate && allow_hibernate) { + hibernate_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (hibernate_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Hibernate")); + dbusmenu_menuitem_child_append(self->root_item, hibernate_mi); + g_signal_connect (G_OBJECT(hibernate_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep_from_hibernate), self); + } + + restart_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (restart_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + RESTART_ITEM_TYPE); + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart")); + } else { + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (restart_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_restart()); + dbusmenu_menuitem_child_append(self->root_item, restart_mi); + g_signal_connect (G_OBJECT(restart_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "restart"); + + shutdown_mi = dbusmenu_menuitem_new(); + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down")); + } else { + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (shutdown_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_shutdown()); + dbusmenu_menuitem_child_append (self->root_item, shutdown_mi); + g_signal_connect (G_OBJECT(shutdown_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "shutdown"); + + RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); + restart_shutdown_logout_mi->logout_mi = logout_mi; + restart_shutdown_logout_mi->restart_mi = restart_mi; + restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; + + update_menu_entries(restart_shutdown_logout_mi); + + return; +} + +/* When the directory changes we need to figure out how our menu + item should look. */ +static void +restart_dir_changed (gpointer userdata) +{ + DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); + gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS); + + if (restart_required) { + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart to Complete Update")); + } else { + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_LABEL, + _("Restart to Complete Update\342\200\246")); + } + dbusmenu_menuitem_property_set (restart_mi, + RESTART_ITEM_ICON, + "system-restart-panel"); + if (self->session_dbus_interface != NULL) { + session_dbus_set_name (self->session_dbus_interface, ICON_RESTART); + } + } else { + if (supress_confirmations()) { + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); + } else { + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246")); + } + dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON); + if (self->session_dbus_interface != NULL) { + session_dbus_set_name(self->session_dbus_interface, ICON_DEFAULT); + } + } + return; +} + +/* Buids a file watcher for the directory so that when it + changes we can check to see if our reboot-required is + there. */ +static void +setup_restart_watch (DeviceMenuMgr* self) +{ + GFile * filedir = g_file_new_for_path("/var/run"); + GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); + if (filemon != NULL) { + g_signal_connect (G_OBJECT(filemon), + "changed", + G_CALLBACK(restart_dir_changed), + self); + } + restart_dir_changed(self); + return; +} + +/* Ensures that we have a GConf client and if we build one + set up the signal handler. */ +static void +device_menu_mgr_ensure_gconf_client (DeviceMenuMgr* self) +{ + if (!gconf_client) { + gconf_client = gconf_client_get_default (); + + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (gconf_client, + LOCKDOWN_DIR, + lockdown_changed, + self, + NULL, + NULL); + + gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add (gconf_client, + KEYBINDING_DIR, + keybinding_changed, + self, + NULL, + NULL); + } +} + DbusmenuMenuitem* device_mgr_get_root_item (DeviceMenuMgr* self) { @@ -64,6 +631,6 @@ DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus) { DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); device_mgr->session_dbus_interface = session_dbus; - //device_menu_mgr_rebuild_items (device_mgr); + device_menu_mgr_rebuild_items (device_mgr); return device_mgr; } diff --git a/src/session-service.c b/src/session-service.c index 23cb6ab..fc7983d 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -45,18 +45,12 @@ with this program. If not, see . #include "dbusmenu-shared.h" #include "users-service-dbus.h" #include "user-menu-mgr.h" +#include "device-menu-mgr.h" -#include "gconf-helper.h" +//#include "gconf-helper.h" #include "session-dbus.h" -#include "lock-helper.h" -#include "upower-client.h" - -#define UP_ADDRESS "org.freedesktop.UPower" -#define UP_OBJECT "/org/freedesktop/UPower" -#define UP_INTERFACE "org.freedesktop.UPower" - -#define EXTRA_LAUNCHER_DIR "/usr/share/indicators/session/applications" +//#include "lock-helper.h" typedef struct _ActivateData ActivateData; @@ -68,444 +62,7 @@ struct _ActivateData //static UsersServiceDbus *dbus_interface = NULL; static SessionDbus *session_dbus = NULL; -static DbusmenuMenuitem *lock_menuitem = NULL; -static DbusmenuMenuitem * session_root_menuitem = NULL; - static GMainLoop * mainloop = NULL; -static DBusGProxy * up_main_proxy = NULL; -static DBusGProxy * up_prop_proxy = NULL; - -static DBusGProxyCall * suspend_call = NULL; -static DBusGProxyCall * hibernate_call = NULL; - -static DbusmenuMenuitem * hibernate_mi = NULL; -static DbusmenuMenuitem * suspend_mi = NULL; -static DbusmenuMenuitem * logout_mi = NULL; -static DbusmenuMenuitem * restart_mi = NULL; -static DbusmenuMenuitem * shutdown_mi = NULL; - -static gboolean can_hibernate = TRUE; -static gboolean can_suspend = TRUE; -static gboolean allow_hibernate = TRUE; -static gboolean allow_suspend = TRUE; - -static GConfClient * gconf_client = NULL; - -static void rebuild_session_items (DbusmenuMenuitem *root); - -static void -lockdown_changed (GConfClient *client, - guint cnxd_id, - GConfEntry *entry, - gpointer user_data) -{ - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); - - if (value == NULL || key == NULL) { - return; - } - - if (g_strcmp0 (key, LOCKDOWN_KEY_USER) == 0 || g_strcmp0 (key, LOCKDOWN_KEY_SCREENSAVER) == 0) { - rebuild_session_items(session_root_menuitem); - } - - return; -} - -static void -keybinding_changed (GConfClient *client, - guint cnxd_id, - GConfEntry *entry, - gpointer user_data) -{ - GConfValue *value = gconf_entry_get_value (entry); - const gchar *key = gconf_entry_get_key (entry); - - if (value == NULL || key == NULL) { - return; - } - - if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { - g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); - if (lock_menuitem != NULL) { - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value)); - } - } - return; -} - -/* Ensures that we have a GConf client and if we build one - set up the signal handler. */ -static void -ensure_gconf_client (void) -{ - if (!gconf_client) { - gconf_client = gconf_client_get_default (); - - gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); - - gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); - } - return; -} - -/* Check to see if the lockdown key is protecting from - locking the screen. If not, lock it. */ -static void -lock_if_possible (void) { - ensure_gconf_client (); - - if (!gconf_client_get_bool (gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL)) { - lock_screen (NULL, 0, NULL); - } - return; -} - -/* A return from the command to sleep the system. Make sure - that we unthrottle the screensaver. */ -static void -sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) -{ - screensaver_unthrottle(); - return; -} - -/* Let's put this machine to sleep, with some info on how - it should sleep. */ -static void -machine_sleep (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) -{ - gchar * type = (gchar *)userdata; - - if (up_main_proxy == NULL) { - g_warning("Can not %s as no upower proxy", type); - } - - screensaver_throttle(type); - lock_if_possible(); - - dbus_g_proxy_begin_call(up_main_proxy, - type, - sleep_response, - NULL, - NULL, - G_TYPE_INVALID); - - return; -} - -/* A response to getting the suspend property */ -static void -suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) -{ - suspend_call = NULL; - - GValue candoit = {0}; - GError * error = NULL; - dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); - if (error != NULL) { - g_warning("Unable to check suspend: %s", error->message); - g_error_free(error); - return; - } - g_debug("Got Suspend: %s", g_value_get_boolean(&candoit) ? "true" : "false"); - - gboolean local_can_suspend = g_value_get_boolean(&candoit); - if (local_can_suspend != can_suspend) { - can_suspend = local_can_suspend; - rebuild_session_items(session_root_menuitem); - } - - return; -} - -/* Response to getting the hibernate property */ -static void -hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) -{ - hibernate_call = NULL; - - GValue candoit = {0}; - GError * error = NULL; - dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &candoit, G_TYPE_INVALID); - if (error != NULL) { - g_warning("Unable to check hibernate: %s", error->message); - g_error_free(error); - return; - } - g_debug("Got Hibernate: %s", g_value_get_boolean(&candoit) ? "true" : "false"); - - gboolean local_can_hibernate = g_value_get_boolean(&candoit); - if (local_can_hibernate != can_hibernate) { - can_hibernate = local_can_hibernate; - rebuild_session_items(session_root_menuitem); - } - - return; -} - -/* A signal that we need to recheck to ensure we can still - hibernate and/or suspend */ -static void -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(up_prop_proxy, - "Get", - suspend_prop_cb, - NULL, - NULL, - G_TYPE_STRING, - UP_INTERFACE, - G_TYPE_STRING, - "CanSuspend", - G_TYPE_INVALID, - G_TYPE_VALUE, - G_TYPE_INVALID); - } - - /* Start Async call to see if we can suspend */ - if (hibernate_call == NULL) { - hibernate_call = dbus_g_proxy_begin_call(up_prop_proxy, - "Get", - hibernate_prop_cb, - NULL, - NULL, - G_TYPE_STRING, - UP_INTERFACE, - G_TYPE_STRING, - "CanHibernate", - G_TYPE_INVALID, - G_TYPE_VALUE, - G_TYPE_INVALID); - } - - return; -} - -/* Handle the callback from the allow functions to check and - see if we're changing the value, and if so, rebuilding the - menus based on that info. */ -static void -allowed_cb (DBusGProxy *proxy, gboolean OUT_allowed, GError *error, gpointer userdata) -{ - if (error != NULL) { - g_warning("Unable to get information on what is allowed from UPower: %s", error->message); - return; - } - - gboolean * can_do = (gboolean *)userdata; - - if (OUT_allowed != *can_do) { - *can_do = OUT_allowed; - rebuild_session_items (session_root_menuitem); - } -} - -/* This function goes through and sets up what we need for - DKp checking. We're even setting up the calls for the props - we need */ -static void -setup_up (void) { - DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); - g_return_if_fail(bus != NULL); - - 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); - /* Connect to changed signal */ - dbus_g_proxy_add_signal(up_main_proxy, - "Changed", - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(up_main_proxy, - "Changed", - G_CALLBACK(up_changed_cb), - NULL, - NULL); - } - g_return_if_fail(up_prop_proxy != NULL); - - - /* Force an original "changed" event */ - up_changed_cb(up_main_proxy, NULL); - - /* Check to see if these are getting blocked by PolicyKit */ - org_freedesktop_UPower_suspend_allowed_async(up_main_proxy, - allowed_cb, - &allow_suspend); - org_freedesktop_UPower_hibernate_allowed_async(up_main_proxy, - allowed_cb, - &allow_hibernate); - - return; -} - -/* This is the function to show a dialog on actions that - can destroy data. Currently it just calls the GTK version - but it seems that in the future it should figure out - what's going on and something better. */ -static void -show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) -{ - gchar * helper = g_build_filename(LIBEXECDIR, "gtk-logout-helper", NULL); - gchar * dialog_line = g_strdup_printf("%s --%s", helper, type); - g_free(helper); - - g_debug("Showing dialog '%s'", dialog_line); - - GError * error = NULL; - if (!g_spawn_command_line_async(dialog_line, &error)) { - g_warning("Unable to show dialog: %s", error->message); - g_error_free(error); - } - - g_free(dialog_line); - - return; -} - - -static void -rebuild_session_items (DbusmenuMenuitem *root) - -{ - gboolean can_lockscreen; - - /* Make sure we have a valid GConf client, and build one - if needed */ - ensure_gconf_client (); - - can_lockscreen = !gconf_client_get_bool ( gconf_client, - LOCKDOWN_KEY_SCREENSAVER, - NULL); - /* Lock screen item */ - if (can_lockscreen) { - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (lock_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Lock Screen")); - - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); - if (shortcut != NULL) { - g_debug("Lock screen shortcut: %s", shortcut); - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); - g_free(shortcut); - } else { - g_debug("Unable to get lock screen shortcut."); - } - - g_signal_connect (G_OBJECT(lock_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(root, lock_menuitem); - } - - /* Start going through the session based items. */ - - logout_mi = dbusmenu_menuitem_new(); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out")); - } else { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (logout_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_logout()); - dbusmenu_menuitem_child_append(root, logout_mi); - g_signal_connect( G_OBJECT(logout_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "logout"); - - if (can_suspend && allow_suspend) { - suspend_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (suspend_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Suspend")); - dbusmenu_menuitem_child_append (root, suspend_mi); - g_signal_connect( G_OBJECT(suspend_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(machine_sleep), - "Suspend"); - } - - if (can_hibernate && allow_hibernate) { - hibernate_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (hibernate_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Hibernate")); - dbusmenu_menuitem_child_append(root, hibernate_mi); - g_signal_connect (G_OBJECT(hibernate_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(machine_sleep), "Hibernate"); - } - - restart_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (restart_mi, - DBUSMENU_MENUITEM_PROP_TYPE, - RESTART_ITEM_TYPE); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (restart_mi, - RESTART_ITEM_LABEL, - _("Restart")); - } else { - dbusmenu_menuitem_property_set (restart_mi, - RESTART_ITEM_LABEL, - _("Restart\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (restart_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_restart()); - dbusmenu_menuitem_child_append(root, restart_mi); - g_signal_connect (G_OBJECT(restart_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "restart"); - - shutdown_mi = dbusmenu_menuitem_new(); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (shutdown_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Shut Down")); - } else { - dbusmenu_menuitem_property_set (shutdown_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Shut Down\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (shutdown_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_shutdown()); - dbusmenu_menuitem_child_append (root, shutdown_mi); - g_signal_connect (G_OBJECT(shutdown_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "shutdown"); - - RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); - restart_shutdown_logout_mi->logout_mi = logout_mi; - restart_shutdown_logout_mi->restart_mi = restart_mi; - restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - - update_menu_entries(restart_shutdown_logout_mi); - - return; -} /* When the service interface starts to shutdown, we @@ -520,52 +77,6 @@ service_shutdown (IndicatorService * service, gpointer user_data) return; } -/* When the directory changes we need to figure out how our menu - item should look. */ -static void -restart_dir_changed (void) -{ - gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS); - - if (restart_required) { - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update")); - } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update\342\200\246")); - } - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "system-restart-panel"); - if (session_dbus != NULL) { - session_dbus_set_name(session_dbus, ICON_RESTART); - } - } else { - if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart")); - } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246")); - } - dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON); - if (session_dbus != NULL) { - session_dbus_set_name(session_dbus, ICON_DEFAULT); - } - } - return; -} - -/* Buids a file watcher for the directory so that when it - changes we can check to see if our reboot-required is - there. */ -static void -setup_restart_watch (void) -{ - GFile * filedir = g_file_new_for_path("/var/run"); - GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL); - if (filemon != NULL) { - g_signal_connect(G_OBJECT(filemon), "changed", G_CALLBACK(restart_dir_changed), NULL); - } - restart_dir_changed(); - return; -} - /* Main, is well, main. It brings everything up and throws us into the mainloop of no return. */ int @@ -581,28 +92,20 @@ main (int argc, char ** argv) IndicatorService * service = indicator_service_new_version (INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_VERSION); - g_signal_connect(G_OBJECT(service), - INDICATOR_SERVICE_SIGNAL_SHUTDOWN, - G_CALLBACK(service_shutdown), NULL); + g_signal_connect (G_OBJECT(service), + INDICATOR_SERVICE_SIGNAL_SHUTDOWN, + G_CALLBACK(service_shutdown), NULL); session_dbus = session_dbus_new(); - g_idle_add(lock_screen_setup, NULL); - - session_root_menuitem = dbusmenu_menuitem_new(); - rebuild_session_items (session_root_menuitem); - + // Devices + DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); - dbusmenu_server_set_root(server, session_root_menuitem); + dbusmenu_server_set_root(server, device_mgr_get_root_item (device_mgr)); // Users - UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); - - setup_restart_watch(); - setup_up(); - + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); - dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From 76d7de16d24e97aa6b58472b21b3a8e8bb795af5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 19 Jul 2011 11:21:02 +0100 Subject: add the udev mgr files --- src/udev-mgr.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/udev-mgr.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/udev-mgr.c create mode 100644 src/udev-mgr.h diff --git a/src/udev-mgr.c b/src/udev-mgr.c new file mode 100644 index 0000000..045c603 --- /dev/null +++ b/src/udev-mgr.c @@ -0,0 +1,49 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * udev-mgr.c + * Copyright (C) Conor Curran 2011 + * + * udev-mgr.c is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * udev-mgr.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + + */ + +#include "udev-mgr.h" + + + +G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); + +static void +udev_mgr_init (UdevMgr *object) +{ + /* TODO: Add initialization code here */ +} + +static void +udev_mgr_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + + G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object); +} + +static void +udev_mgr_class_init (UdevMgrClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + GObjectClass* parent_class = G_OBJECT_CLASS (klass); + + object_class->finalize = udev_mgr_finalize; +} + diff --git a/src/udev-mgr.h b/src/udev-mgr.h new file mode 100644 index 0000000..77d62f1 --- /dev/null +++ b/src/udev-mgr.h @@ -0,0 +1,52 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * udev-mgr.c + * Copyright (C) Conor Curran 2011 + * + * udev-mgr.c is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * udev-mgr.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + + */ + +#ifndef _UDEV_MGR_H_ +#define _UDEV_MGR_H_ + +#include + +G_BEGIN_DECLS + +#define UDEV_TYPE_MGR (udev_mgr_get_type ()) +#define UDEV_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UDEV_TYPE_MGR, UdevMgr)) +#define UDEV_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UDEV_TYPE_MGR, UdevMgrClass)) +#define UDEV_IS_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UDEV_TYPE_MGR)) +#define UDEV_IS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UDEV_TYPE_MGR)) +#define UDEV_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UDEV_TYPE_MGR, UdevMgrClass)) + +typedef struct _UdevMgrClass UdevMgrClass; +typedef struct _UdevMgr UdevMgr; + +struct _UdevMgrClass +{ + GObjectClass parent_class; +}; + +struct _UdevMgr +{ + GObject parent_instance; +}; + +GType udev_mgr_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _UDEV_MGR_H_ */ -- cgit v1.2.3 From 66af46666904be8c2b056fc32d2bf258bf31b91f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 19 Jul 2011 13:18:54 +0100 Subject: system added to device menu, more tidying as we go --- src/device-menu-mgr.c | 185 ++++++++++++++++++++++++++++++++++++++++++-------- src/session-service.c | 4 +- src/udev-mgr.c | 36 +++++----- src/udev-mgr.h | 35 +++++----- 4 files changed, 191 insertions(+), 69 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 0114b92..b8a2050 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include + #include "device-menu-mgr.h" #include "gconf-helper.h" #include "dbus-shared-names.h" @@ -24,6 +26,7 @@ with this program. If not, see . #include "lock-helper.h" #include "upower-client.h" + #define UP_ADDRESS "org.freedesktop.UPower" #define UP_OBJECT "/org/freedesktop/UPower" #define UP_INTERFACE "org.freedesktop.UPower" @@ -39,12 +42,13 @@ struct _DeviceMenuMgr static GConfClient *gconf_client = NULL; static DbusmenuMenuitem *lock_menuitem = NULL; +static DbusmenuMenuitem *system_settings_menuitem = NULL; static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; static DbusmenuMenuitem * hibernate_mi = NULL; -static DbusmenuMenuitem * suspend_mi = NULL; +//static DbusmenuMenuitem * suspend_mi = NULL; static DbusmenuMenuitem * logout_mi = NULL; static DbusmenuMenuitem * restart_mi = NULL; static DbusmenuMenuitem * shutdown_mi = NULL; @@ -64,15 +68,19 @@ static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self); static void lock_if_possible (DeviceMenuMgr* self); static void machine_sleep_with_context (DeviceMenuMgr* self, gchar* type); +static void show_system_settings_with_context (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); + static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); -static void +/*static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); - +*/ G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); static void @@ -100,7 +108,8 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) object_class->finalize = device_menu_mgr_finalize; } - +// TODO +// Is this needed anymore static void lockdown_changed (GConfClient *client, guint cnxd_id, @@ -167,14 +176,14 @@ sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) return; } -static void +/*static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); machine_sleep_with_context (self, "Suspend"); -} +}*/ static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, @@ -208,6 +217,9 @@ machine_sleep_with_context (DeviceMenuMgr* self, gchar* type) } /* A response to getting the suspend property */ +// TODO +// Is this needed anymore + static void suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) { @@ -234,6 +246,9 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) } /* Response to getting the hibernate property */ +// TODO +// Is this needed anymore + static void hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) { @@ -392,6 +407,7 @@ setup_up (DeviceMenuMgr* self) { static void show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) { + gchar * helper = g_build_filename(LIBEXECDIR, "gtk-logout-helper", NULL); gchar * dialog_line = g_strdup_printf("%s --%s", helper, type); g_free(helper); @@ -403,16 +419,50 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) g_warning("Unable to show dialog: %s", error->message); g_error_free(error); } + g_free(dialog_line); +} + +static void +show_system_settings_with_context (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + gchar * control_centre_command = g_strdup_printf("%s %s", + "gnome-control-center", + type); - g_free(dialog_line); + g_debug("Command centre exec call '%s'", control_centre_command); - return; + GError * error = NULL; + if (!g_spawn_command_line_async(control_centre_command, &error)) + { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } + g_free(control_centre_command); } - static void -device_menu_mgr_rebuild_items (DeviceMenuMgr* self) +device_menu_mgr_build_static_items (DeviceMenuMgr* self) { + system_settings_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (system_settings_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("System Settings...")); + g_signal_connect (G_OBJECT(system_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), ""); + + dbusmenu_menuitem_child_add_position(self->root_item, + system_settings_menuitem, + 0); + + DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator1, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_append (self->root_item, separator1); + gboolean can_lockscreen; /* Make sure we have a valid GConf client, and build one @@ -423,6 +473,99 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self) LOCKDOWN_KEY_SCREENSAVER, NULL); /* Lock screen item */ + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); + + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); + } + else { + g_debug("Unable to get lock screen shortcut."); + } + + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); + } + + logout_mi = dbusmenu_menuitem_new(); + + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out")); + } + else { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (logout_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_logout()); + dbusmenu_menuitem_child_append(self->root_item, logout_mi); + g_signal_connect( G_OBJECT(logout_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "logout"); + + if (can_hibernate && allow_hibernate) { + hibernate_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (hibernate_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Hibernate")); + dbusmenu_menuitem_child_append(self->root_item, hibernate_mi); + g_signal_connect (G_OBJECT(hibernate_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep_from_hibernate), self); + } + + shutdown_mi = dbusmenu_menuitem_new(); + + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down")); + } + else { + dbusmenu_menuitem_property_set (shutdown_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Shut Down\342\200\246")); + } + dbusmenu_menuitem_property_set_bool (shutdown_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_shutdown()); + dbusmenu_menuitem_child_append (self->root_item, shutdown_mi); + g_signal_connect (G_OBJECT(shutdown_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_dialog), "shutdown"); + + RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); + restart_shutdown_logout_mi->logout_mi = logout_mi; + restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; + + update_menu_entries(restart_shutdown_logout_mi); +} + + +static void +device_menu_mgr_rebuild_items (DeviceMenuMgr* self) +{ + //gboolean can_lockscreen; + + /* Make sure we have a valid GConf client, and build one + if needed */ + //device_menu_mgr_ensure_gconf_client (self); + + /*can_lockscreen = !gconf_client_get_bool ( gconf_client, + LOCKDOWN_KEY_SCREENSAVER, + NULL); if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (lock_menuitem, @@ -444,8 +587,6 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); } - /* Start going through the session based items. */ - logout_mi = dbusmenu_menuitem_new(); if (supress_confirmations()) { dbusmenu_menuitem_property_set (logout_mi, @@ -487,22 +628,6 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self) G_CALLBACK(machine_sleep_from_hibernate), self); } - restart_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (restart_mi, - DBUSMENU_MENUITEM_PROP_TYPE, - RESTART_ITEM_TYPE); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (restart_mi, - RESTART_ITEM_LABEL, - _("Restart")); - } else { - dbusmenu_menuitem_property_set (restart_mi, - RESTART_ITEM_LABEL, - _("Restart\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (restart_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_restart()); dbusmenu_menuitem_child_append(self->root_item, restart_mi); g_signal_connect (G_OBJECT(restart_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, @@ -533,7 +658,7 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self) update_menu_entries(restart_shutdown_logout_mi); - return; + return;*/ } /* When the directory changes we need to figure out how our menu @@ -631,6 +756,6 @@ DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus) { DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); device_mgr->session_dbus_interface = session_dbus; - device_menu_mgr_rebuild_items (device_mgr); + device_menu_mgr_build_static_items (device_mgr); return device_mgr; } diff --git a/src/session-service.c b/src/session-service.c index 8bdd0c1..e043d65 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -76,10 +76,10 @@ static GMainLoop * mainloop = NULL; void service_shutdown (IndicatorService * service, gpointer user_data) { - if (mainloop != NULL) { + /*if (mainloop != NULL) { g_debug("Service shutdown"); g_main_loop_quit(mainloop); - } + }*/ return; } diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 045c603..75f760d 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -1,25 +1,23 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * udev-mgr.c - * Copyright (C) Conor Curran 2011 - * - * udev-mgr.c is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * udev-mgr.c is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - - */ +Copyright 2011 Canonical Ltd. -#include "udev-mgr.h" +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include "udev-mgr.h" G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); diff --git a/src/udev-mgr.h b/src/udev-mgr.h index 77d62f1..1c5ae73 100644 --- a/src/udev-mgr.h +++ b/src/udev-mgr.h @@ -1,22 +1,21 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * udev-mgr.c - * Copyright (C) Conor Curran 2011 - * - * udev-mgr.c is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * udev-mgr.c is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - - */ +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ #ifndef _UDEV_MGR_H_ #define _UDEV_MGR_H_ -- cgit v1.2.3 From 04b9f0bc0b0b7715b9a261ceae059a8b7ba69ced Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 19 Jul 2011 16:08:27 +0100 Subject: settings dialog in place --- src/device-menu-mgr.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index b8a2050..49dfad7 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -43,6 +43,10 @@ struct _DeviceMenuMgr static GConfClient *gconf_client = 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 DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; @@ -71,6 +75,9 @@ static void machine_sleep_with_context (DeviceMenuMgr* self, static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, gchar * type); +static void show_apt_dialog (DbusmenuMenuitem* mi, + guint timestamp, + gchar * type); static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, @@ -422,6 +429,11 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) g_free(dialog_line); } +static void +show_apt_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) +{ +} + static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, @@ -445,6 +457,7 @@ show_system_settings_with_context (DbusmenuMenuitem * mi, static void device_menu_mgr_build_static_items (DeviceMenuMgr* self) { + // Static Setting items system_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (system_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -452,17 +465,63 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) g_signal_connect (G_OBJECT(system_settings_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_system_settings_with_context), ""); - + dbusmenu_menuitem_child_add_position(self->root_item, system_settings_menuitem, 0); + + + display_settings_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (display_settings_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Displays...")); + g_signal_connect (G_OBJECT(display_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), "display"); + 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, + _("Login Items...")); + g_signal_connect (G_OBJECT(login_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), "login"); + dbusmenu_menuitem_child_add_position(self->root_item, + login_settings_menuitem, + 3); + + software_updates_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (software_updates_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + g_signal_connect (G_OBJECT(login_settings_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_apt_dialog), NULL); + dbusmenu_menuitem_child_add_position(self->root_item, + software_updates_menuitem, + 4); DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append (self->root_item, separator1); - + + // Devices gboolean can_lockscreen; /* Make sure we have a valid GConf client, and build one -- cgit v1.2.3 From 123c9776b0a67b8dd8a58b8295c3356b1f8be606 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 19 Jul 2011 16:58:33 +0100 Subject: all items in place, now for the gudev backend --- src/device-menu-mgr.c | 69 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 49dfad7..ccb4523 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -47,6 +47,10 @@ 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; +static DbusmenuMenuitem *scanners_menuitem = NULL; +static DbusmenuMenuitem *webcam_menuitem = NULL; + static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; @@ -465,12 +469,10 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) g_signal_connect (G_OBJECT(system_settings_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_system_settings_with_context), ""); - dbusmenu_menuitem_child_add_position(self->root_item, system_settings_menuitem, 0); - display_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (display_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -481,7 +483,6 @@ device_menu_mgr_build_static_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, @@ -499,11 +500,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) _("Login Items...")); g_signal_connect (G_OBJECT(login_settings_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), "login"); + G_CALLBACK(show_system_settings_with_context), + "login"); dbusmenu_menuitem_child_add_position(self->root_item, login_settings_menuitem, 3); - software_updates_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (software_updates_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -519,15 +520,65 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) dbusmenu_menuitem_property_set (separator1, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_append (self->root_item, separator1); - - // Devices + dbusmenu_menuitem_child_add_position (self->root_item, separator1, 5); + + // Devices control + DbusmenuMenuitem * device_heading = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (device_heading, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Attached Devices")); + dbusmenu_menuitem_property_set_bool (device_heading, + DBUSMENU_MENUITEM_PROP_ENABLED, + FALSE); + dbusmenu_menuitem_child_add_position (self->root_item, + device_heading, + 6); + + printers_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (printers_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Printers")); + g_signal_connect (G_OBJECT(printers_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), + "printers"); + dbusmenu_menuitem_child_add_position(self->root_item, + printers_menuitem, + 7); + scanners_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (scanners_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("HP Scanners")); + g_signal_connect (G_OBJECT(scanners_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), + "scanners"); + dbusmenu_menuitem_child_add_position (self->root_item, + scanners_menuitem, + 8); + webcam_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (webcam_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("HP Webcam")); + g_signal_connect (G_OBJECT(webcam_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_system_settings_with_context), + "HP Webcam"); + dbusmenu_menuitem_child_add_position (self->root_item, + webcam_menuitem, + 10); + DbusmenuMenuitem * separator3 = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (separator3, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_add_position (self->root_item, separator3, 11); + + // Session control gboolean can_lockscreen; /* Make sure we have a valid GConf client, and build one if needed */ device_menu_mgr_ensure_gconf_client (self); - can_lockscreen = !gconf_client_get_bool ( gconf_client, LOCKDOWN_KEY_SCREENSAVER, NULL); -- cgit v1.2.3 From 34a5a7289ede2d662d6c64457afcd1c22354d21b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 19 Jul 2011 19:53:15 +0100 Subject: apt watcher coming along nicely --- src/Makefile.am | 6 +- src/apt-watcher.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/apt-watcher.h | 46 +++++++++++++ src/device-menu-mgr.c | 4 ++ src/udev-mgr.c | 1 - 5 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 src/apt-watcher.c create mode 100644 src/apt-watcher.h diff --git a/src/Makefile.am b/src/Makefile.am index 2230910..753b71d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -95,7 +95,11 @@ indicator_session_service_SOURCES = \ user-menu-mgr.h \ user-menu-mgr.c \ device-menu-mgr.h \ - device-menu-mgr.c + device-menu-mgr.c \ + apt-watcher.h \ + apt-watcher.c \ + udev-mgr.h \ + udev-mgr.c indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/apt-watcher.c b/src/apt-watcher.c new file mode 100644 index 0000000..daab2ee --- /dev/null +++ b/src/apt-watcher.c @@ -0,0 +1,177 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include "apt-watcher.h" +#include + +static guint watcher_id; + +struct _AptWatcher +{ + GObject parent_instance; + GCancellable * proxy_cancel; + GDBusProxy * proxy; +}; + +static void +apt_watcher_on_name_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data); +static void +apt_watcher_on_name_vanished (GDBusConnection *connection, + const gchar *name, + gpointer user_data); +static void +apt_watcher_get_active_transactions_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data); +static void +fetch_proxy_cb (GObject * object, + GAsyncResult * res, + gpointer user_data); + +G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); + +static void +apt_watcher_init (AptWatcher *self) +{ + self->proxy_cancel = g_cancellable_new(); + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.debian.apt", + "/org/debian/apt", + "org.debian.apt", + self->proxy_cancel, + fetch_proxy_cb, + self); +} + +static void +apt_watcher_finalize (GObject *object) +{ + g_bus_unwatch_name (watcher_id); + + G_OBJECT_CLASS (apt_watcher_parent_class)->finalize (object); +} + +static void +apt_watcher_class_init (AptWatcherClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + object_class->finalize = apt_watcher_finalize; +} + +static void +fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + + AptWatcher* self = APT_WATCHER(user_data); + g_return_if_fail(self != NULL); + + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (self->proxy_cancel != NULL) { + g_object_unref(self->proxy_cancel); + self->proxy_cancel = NULL; + } + + if (error != NULL) { + g_warning("Could not grab DBus proxy for %s: %s", + "org.debian.apt", error->message); + g_error_free(error); + return; + } + + self->proxy = proxy; + // Set up the watch. + watcher_id = g_bus_watch_name (G_BUS_TYPE_SYSTEM, + "org.debian.apt", + G_BUS_NAME_WATCHER_FLAGS_NONE, + apt_watcher_on_name_appeared, + apt_watcher_on_name_vanished, + self, + NULL); + + //We'll need to connect to the state changed signal + //g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); +} + + +static void +apt_watcher_on_name_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* watcher = APT_WATCHER (user_data); + + g_print ("Name %s on %s is owned by %s\n", + name, + "the system bus", + name_owner); + + + g_dbus_proxy_call (watcher->proxy, + "GetActiveTransactions", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_watcher_get_active_transactions_cb, + user_data); +} + +static void +apt_watcher_get_active_transactions_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + GError * error = NULL; + GVariant * result; + + result = g_dbus_proxy_call_finish(self->proxy, res, &error); + + if (error != NULL) { + g_warning ("unable to complete the fetching of active transactions"); + g_error_free (error); + return; + } + + g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s", + g_variant_get_type_string (result)); + //gchar ** transactions = g_variant_get_strv (result); + +} + +static void +apt_watcher_on_name_vanished (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + g_print ("Name %s does not exist on %s\n", + name, + "the system bus"); +} diff --git a/src/apt-watcher.h b/src/apt-watcher.h new file mode 100644 index 0000000..148072f --- /dev/null +++ b/src/apt-watcher.h @@ -0,0 +1,46 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifndef _APT_WATCHER_H_ +#define _APT_WATCHER_H_ + +#include + +G_BEGIN_DECLS + +#define APT_TYPE_WATCHER (apt_watcher_get_type ()) +#define APT_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APT_TYPE_WATCHER, AptWatcher)) +#define APT_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APT_TYPE_WATCHER, AptWatcherClass)) +#define APT_IS_WATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APT_TYPE_WATCHER)) +#define APT_IS_WATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APT_TYPE_WATCHER)) +#define APT_WATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APT_TYPE_WATCHER, AptWatcherClass)) + +typedef struct _AptWatcherClass AptWatcherClass; +typedef struct _AptWatcher AptWatcher; + +struct _AptWatcherClass +{ + GObjectClass parent_class; +}; + +GType apt_watcher_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _APT_WATCHER_H_ */ diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index ccb4523..a3cea61 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -25,6 +25,7 @@ with this program. If not, see . #include "dbusmenu-shared.h" #include "lock-helper.h" #include "upower-client.h" +#include "apt-watcher.h" #define UP_ADDRESS "org.freedesktop.UPower" @@ -87,6 +88,7 @@ static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); +static AptWatcher* watcher = NULL; /*static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, @@ -101,6 +103,7 @@ device_menu_mgr_init (DeviceMenuMgr *self) setup_restart_watch(self); setup_up(self); g_idle_add(lock_screen_setup, NULL); + } static void @@ -117,6 +120,7 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) GObjectClass* object_class = G_OBJECT_CLASS (klass); //GObjectClass* parent_class = G_OBJECT_CLASS (klass); object_class->finalize = device_menu_mgr_finalize; + watcher = g_object_new (APT_TYPE_WATCHER, NULL); } // TODO diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 75f760d..6575ca5 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -40,7 +40,6 @@ static void udev_mgr_class_init (UdevMgrClass *klass) { GObjectClass* object_class = G_OBJECT_CLASS (klass); - GObjectClass* parent_class = G_OBJECT_CLASS (klass); object_class->finalize = udev_mgr_finalize; } -- cgit v1.2.3 From ec2941976b938e93fc94cdc4309a221b3194c881 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 20 Jul 2011 18:17:49 +0100 Subject: apt watcher now controlling menuitem with signals and methods in place --- src/apt-watcher.c | 40 +++++++++++++++++++++++++++++++++++++--- src/apt-watcher.h | 7 +++++++ src/dbus-shared-names.h | 7 +++++++ src/device-menu-mgr.c | 23 +++++++---------------- src/device-menu-mgr.h | 1 - src/indicator-session.c | 4 ++-- src/session-dbus.xml | 6 ++++++ src/session-service.c | 5 ----- 8 files changed, 66 insertions(+), 27 deletions(-) diff --git a/src/apt-watcher.c b/src/apt-watcher.c index daab2ee..bc012ed 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -17,9 +17,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "apt-watcher.h" #include +#include "apt-watcher.h" + static guint watcher_id; struct _AptWatcher @@ -27,6 +28,8 @@ struct _AptWatcher GObject parent_instance; GCancellable * proxy_cancel; GDBusProxy * proxy; + SessionDbus* session_dbus_interface; + DbusmenuMenuitem* apt_item; }; static void @@ -47,6 +50,10 @@ fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); +static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi, + guint timestamp, + gchar * type); + G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); static void @@ -159,11 +166,16 @@ apt_watcher_get_active_transactions_cb (GObject * obj, g_error_free (error); return; } - g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s", g_variant_get_type_string (result)); - //gchar ** transactions = g_variant_get_strv (result); + //g_variant_get (result, "(sas)"); + gchar* first_param = NULL; + gchar ** transactions = NULL; + g_variant_get (result, "(sas)", first_param, transactions); + g_debug ("And the size is the string array %u", + g_strv_length (transactions)); + g_debug ("first param = %s", first_param); } static void @@ -175,3 +187,25 @@ apt_watcher_on_name_vanished (GDBusConnection *connection, name, "the system bus"); } + +static void +apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + +} + + +AptWatcher* apt_watcher_new (SessionDbus* session_dbus, + DbusmenuMenuitem* item) +{ + AptWatcher* watcher = g_object_new (APT_TYPE_WATCHER, NULL); + watcher->session_dbus_interface = session_dbus; + watcher->apt_item = item; + g_signal_connect (G_OBJECT(watcher->apt_item), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(apt_watcher_show_apt_dialog), watcher); + return watcher; +} + diff --git a/src/apt-watcher.h b/src/apt-watcher.h index 148072f..cbe0e29 100644 --- a/src/apt-watcher.h +++ b/src/apt-watcher.h @@ -21,6 +21,10 @@ with this program. If not, see . #define _APT_WATCHER_H_ #include +#include +#include + +#include "session-dbus.h" G_BEGIN_DECLS @@ -41,6 +45,9 @@ struct _AptWatcherClass GType apt_watcher_get_type (void) G_GNUC_CONST; +AptWatcher* apt_watcher_new (SessionDbus* session_dbus, + DbusmenuMenuitem* apt_item); + G_END_DECLS #endif /* _APT_WATCHER_H_ */ diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index c4ccd05..f2dbede 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -20,6 +20,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +typedef enum { + RESTART_NEEDED, + UPDATES_IN_PROGRESS, + UPDATES_AVAILABLE, + UP_TO_DATE, +}AptState; + #ifndef __DBUS_SHARED_NAMES_H__ #define __DBUS_SHARED_NAMES_H__ 1 diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index a3cea61..9c54ef3 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -18,6 +18,7 @@ with this program. If not, see . */ #include +#include #include "device-menu-mgr.h" #include "gconf-helper.h" @@ -39,6 +40,7 @@ struct _DeviceMenuMgr GObject parent_instance; DbusmenuMenuitem* root_item; SessionDbus* session_dbus_interface; + AptWatcher* apt_watcher; }; static GConfClient *gconf_client = NULL; @@ -79,16 +81,12 @@ static void machine_sleep_with_context (DeviceMenuMgr* self, gchar* type); static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, - gchar * type); -static void show_apt_dialog (DbusmenuMenuitem* mi, - guint timestamp, - gchar * type); + gchar * type); static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); -static AptWatcher* watcher = NULL; /*static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, @@ -99,11 +97,11 @@ G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); static void device_menu_mgr_init (DeviceMenuMgr *self) { + self->apt_watcher = NULL; self->root_item = dbusmenu_menuitem_new (); setup_restart_watch(self); setup_up(self); g_idle_add(lock_screen_setup, NULL); - } static void @@ -120,7 +118,6 @@ device_menu_mgr_class_init (DeviceMenuMgrClass *klass) GObjectClass* object_class = G_OBJECT_CLASS (klass); //GObjectClass* parent_class = G_OBJECT_CLASS (klass); object_class->finalize = device_menu_mgr_finalize; - watcher = g_object_new (APT_TYPE_WATCHER, NULL); } // TODO @@ -437,11 +434,6 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) g_free(dialog_line); } -static void -show_apt_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) -{ -} - static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, @@ -513,9 +505,6 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) dbusmenu_menuitem_property_set (software_updates_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Software Up to Date")); - g_signal_connect (G_OBJECT(login_settings_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_apt_dialog), NULL); dbusmenu_menuitem_child_add_position(self->root_item, software_updates_menuitem, 4); @@ -870,6 +859,8 @@ DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus) { DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); device_mgr->session_dbus_interface = session_dbus; - device_menu_mgr_build_static_items (device_mgr); + device_menu_mgr_build_static_items (device_mgr); + device_mgr->apt_watcher = apt_watcher_new (session_dbus, + software_updates_menuitem); return device_mgr; } diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h index caa9aee..503b36a 100644 --- a/src/device-menu-mgr.h +++ b/src/device-menu-mgr.h @@ -22,7 +22,6 @@ with this program. If not, see . #define _DEVICE_MENU_MGR_H_ #include -#include #include "session-dbus.h" diff --git a/src/indicator-session.c b/src/indicator-session.c index 068ffef..df8cbdf 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -6,7 +6,8 @@ Copyright 2009 Canonical Ltd. Authors: Ted Gould - + Conor Curran + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. @@ -20,7 +21,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -//TODO - remember to reinsert Ted's comments. #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/session-dbus.xml b/src/session-dbus.xml index f496ff1..c42aca8 100644 --- a/src/session-dbus.xml +++ b/src/session-dbus.xml @@ -8,11 +8,17 @@ + + + + + + diff --git a/src/session-service.c b/src/session-service.c index e043d65..22552dc 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -52,12 +52,7 @@ with this program. If not, see . #include "users-service-dbus.h" #include "user-menu-mgr.h" #include "device-menu-mgr.h" - -//#include "gconf-helper.h" - #include "session-dbus.h" -//#include "lock-helper.h" - typedef struct _ActivateData ActivateData; struct _ActivateData -- cgit v1.2.3 From 1ac92fe1d81c7d7180d44fb0a22339b09600b2af Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 20 Jul 2011 20:04:10 +0100 Subject: signals and methods from apt are working somewhat --- src/apt-watcher.c | 82 +++++++++++++++++++++++++++++++++++++++++-------- src/dbus-shared-names.h | 4 +-- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/src/apt-watcher.c b/src/apt-watcher.c index bc012ed..703137a 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -18,8 +18,10 @@ with this program. If not, see . */ #include +#include #include "apt-watcher.h" +#include "dbus-shared-names.h" static guint watcher_id; @@ -30,6 +32,7 @@ struct _AptWatcher GDBusProxy * proxy; SessionDbus* session_dbus_interface; DbusmenuMenuitem* apt_item; + gint current_state; }; static void @@ -49,16 +52,23 @@ static void fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); - static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi, guint timestamp, gchar * type); +static void apt_watcher_signal_cb (GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, + gpointer user_data); +static void apt_watcher_determine_state (AptWatcher* self, + GVariant* update); G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); static void apt_watcher_init (AptWatcher *self) { + self->current_state = UP_TO_DATE; self->proxy_cancel = g_cancellable_new(); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, @@ -119,7 +129,10 @@ fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) NULL); //We'll need to connect to the state changed signal - //g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); + g_signal_connect (self->proxy, + "g-signal", + G_CALLBACK(apt_watcher_signal_cb), + self); } @@ -136,7 +149,6 @@ apt_watcher_on_name_appeared (GDBusConnection *connection, name, "the system bus", name_owner); - g_dbus_proxy_call (watcher->proxy, "GetActiveTransactions", @@ -166,16 +178,7 @@ apt_watcher_get_active_transactions_cb (GObject * obj, g_error_free (error); return; } - g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s", - g_variant_get_type_string (result)); - //g_variant_get (result, "(sas)"); - gchar* first_param = NULL; - gchar ** transactions = NULL; - g_variant_get (result, "(sas)", first_param, transactions); - - g_debug ("And the size is the string array %u", - g_strv_length (transactions)); - g_debug ("first param = %s", first_param); + apt_watcher_determine_state (self, result); } static void @@ -188,6 +191,41 @@ apt_watcher_on_name_vanished (GDBusConnection *connection, "the system bus"); } +static void +apt_watcher_determine_state (AptWatcher* self, + GVariant* update) +{ + g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s", + g_variant_get_type_string (update)); + + gchar* first_param = NULL; + gchar ** transactions = NULL; + + g_variant_get (update, "(sas)", &first_param, &transactions); + + g_debug ("apt_watcher_determine_state - the size is the string array %u", + g_strv_length (transactions)); + g_debug ("apt_watcher_determine_state - first param = %s", first_param); + + if (first_param == NULL){ + if (self->current_state != UP_TO_DATE){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + } + } + else{ + gboolean updating = g_str_has_prefix (first_param, + "/org/debian/apt/transaction/"); + if (updating == TRUE){ + self->current_state = UPDATES_IN_PROGRESS; + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Updates Installing...")); + } + } +} + static void apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, guint timestamp, @@ -195,7 +233,25 @@ apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, { } +// TODO signal is of type s not sas which is on d-feet !!! +static void apt_watcher_signal_cb ( GDBusProxy* proxy, + gchar* sender_name, + gchar* signal_name, + GVariant* parameters, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + g_variant_ref (parameters); + GVariant *value = g_variant_get_child_value (parameters, 0); + + if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){ + g_debug ("Active Transactions signal received"); + apt_watcher_determine_state (self, value); + } + g_variant_unref (parameters); +} AptWatcher* apt_watcher_new (SessionDbus* session_dbus, DbusmenuMenuitem* item) diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index f2dbede..8d0c6db 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -21,10 +21,10 @@ with this program. If not, see . */ typedef enum { - RESTART_NEEDED, + UP_TO_DATE, UPDATES_IN_PROGRESS, UPDATES_AVAILABLE, - UP_TO_DATE, + RESTART_NEEDED }AptState; -- cgit v1.2.3 From c6687bb3bc9e34b20da5c77a5adf42afb4a168f9 Mon Sep 17 00:00:00 2001 From: Neil Jagdish Patel Date: Thu, 21 Jul 2011 13:18:47 +0100 Subject: Always send the actual pointers to the entry not pointers to copies --- src/indicator-session.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/indicator-session.c b/src/indicator-session.c index 068ffef..af4e2eb 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -449,17 +449,15 @@ user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data //Otherwise self->show_users_entry = update; - IndicatorObjectEntry user_entry = self->users; - if (self->show_users_entry == TRUE){ g_signal_emit_by_name ((gpointer)self, "entry-added", - &user_entry); + &self->users); } else{ g_signal_emit_by_name ((gpointer)self, "entry-removed", - &user_entry); + &self->users); } } @@ -489,18 +487,16 @@ receive_signal (GDBusProxy * proxy, //Otherwise self->show_users_entry = update; - - IndicatorObjectEntry user_entry = self->users; if (self->show_users_entry == TRUE){ g_signal_emit_by_name ((gpointer)self, "entry-added", - &user_entry); + &self->users); } else{ g_signal_emit_by_name ((gpointer)self, "entry-removed", - &user_entry); + &self->users); } } } -- cgit v1.2.3 From dfa3b112e2b9c303102cf3805aa2e8f77f9aaffe Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 21 Jul 2011 14:03:09 +0100 Subject: trying to figure out if upgrades are needed in progress --- src/apt-watcher.c | 150 +++++++++++++++++++++++++++++++++++++++++++----- src/indicator-session.c | 6 +- 2 files changed, 139 insertions(+), 17 deletions(-) diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 703137a..d02203b 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -19,7 +19,6 @@ with this program. If not, see . #include #include - #include "apt-watcher.h" #include "dbus-shared-names.h" @@ -30,6 +29,7 @@ struct _AptWatcher GObject parent_instance; GCancellable * proxy_cancel; GDBusProxy * proxy; + GDBusProxy * transaction_proxy; SessionDbus* session_dbus_interface; DbusmenuMenuitem* apt_item; gint current_state; @@ -44,25 +44,42 @@ static void apt_watcher_on_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data); -static void +/*static void apt_watcher_get_active_transactions_cb (GObject * obj, GAsyncResult * res, gpointer user_data); -static void -fetch_proxy_cb (GObject * object, - GAsyncResult * res, - gpointer user_data); + * */ +static void fetch_proxy_cb (GObject * object, + GAsyncResult * res, + gpointer user_data); + +static void apt_watcher_simulate_transaction_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data); + +static void apt_watcher_upgrade_system_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data); + + static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi, guint timestamp, gchar * type); + static void apt_watcher_signal_cb (GDBusProxy* proxy, gchar* sender_name, gchar* signal_name, GVariant* parameters, gpointer user_data); + static void apt_watcher_determine_state (AptWatcher* self, GVariant* update); +static void transaction_on_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + const gchar* const *invalidated_properties, + gpointer user_data); + G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); static void @@ -70,6 +87,8 @@ apt_watcher_init (AptWatcher *self) { self->current_state = UP_TO_DATE; self->proxy_cancel = g_cancellable_new(); + self->proxy = NULL; + self->transaction_proxy = NULL; g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, @@ -149,18 +168,41 @@ apt_watcher_on_name_appeared (GDBusConnection *connection, name, "the system bus", name_owner); - + g_dbus_proxy_call (watcher->proxy, + "UpgradeSystem", + g_variant_new_boolean (TRUE), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_watcher_upgrade_system_cb, + user_data); + + /*g_dbus_proxy_call (watcher->proxy, "GetActiveTransactions", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, apt_watcher_get_active_transactions_cb, - user_data); + user_data);*/ } static void +apt_watcher_on_name_vanished (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + g_debug ("Name %s does not exist or has just vanished", + name); + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + if (self->proxy != NULL) + g_object_unref (self->proxy); +} + +/*static void apt_watcher_get_active_transactions_cb (GObject * obj, GAsyncResult * res, gpointer user_data) @@ -179,16 +221,96 @@ apt_watcher_get_active_transactions_cb (GObject * obj, return; } apt_watcher_determine_state (self, result); +}*/ + +static void +apt_watcher_upgrade_system_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data) +{ + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + GError * error = NULL; + GVariant * result; + + result = g_dbus_proxy_call_finish(self->proxy, res, &error); + + if (error != NULL) { + g_warning ("unable to complete the UpgradeSystem apt call"); + g_error_free (error); + return; + } + + gchar* transaction_id = NULL; + g_variant_get (result, "(s)", &transaction_id); + + if (transaction_id != NULL){ + if (self->transaction_proxy != NULL){ + g_object_unref (self->transaction_proxy); + self->transaction_proxy = NULL; + } + self->transaction_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, /* GDBusInterfaceInfo */ + "org.debian.apt", + transaction_id, + "org.debian.apt", + NULL, /* GCancellable */ + &error); + if (error != NULL) { + g_warning ("unable to fetch proxy for transaction object path"); + g_error_free (error); + return; + } + g_signal_connect (self->transaction_proxy, + "g-properties-changed", + G_CALLBACK (transaction_on_properties_changed), + self); + + g_dbus_proxy_call (self->transaction_proxy, + "Simulate", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_watcher_simulate_transaction_cb, + self); + } } static void -apt_watcher_on_name_vanished (GDBusConnection *connection, - const gchar *name, - gpointer user_data) +apt_watcher_simulate_transaction_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data) { - g_print ("Name %s does not exist on %s\n", - name, - "the system bus"); +} + +static void +transaction_on_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + const gchar* const *invalidated_properties, + gpointer user_data) +{ + if (g_variant_n_children (changed_properties) > 0) + { + GVariantIter *iter; + const gchar *key; + GVariant *value; + + g_print (" *** Properties Changed:\n"); + g_variant_get (changed_properties, + "a{sv}", + &iter); + while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) + { + gchar *value_str; + value_str = g_variant_print (value, TRUE); + g_print (" %s -> %s\n", key, value_str); + g_free (value_str); + } + g_variant_iter_free (iter); + } } static void diff --git a/src/indicator-session.c b/src/indicator-session.c index df8cbdf..990140a 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -449,17 +449,17 @@ user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data //Otherwise self->show_users_entry = update; - IndicatorObjectEntry user_entry = self->users; + //IndicatorObjectEntry user_entry = self->users; if (self->show_users_entry == TRUE){ g_signal_emit_by_name ((gpointer)self, "entry-added", - &user_entry); + &self->users); } else{ g_signal_emit_by_name ((gpointer)self, "entry-removed", - &user_entry); + &self->users); } } -- cgit v1.2.3 From d89b98ffa2abc0c38dea6d30399073d239a66ce1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 21 Jul 2011 16:38:44 +0100 Subject: transaction object in place --- src/Makefile.am | 2 + src/apt-transaction.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/apt-transaction.h | 48 +++++++++++++++ src/apt-watcher.c | 118 ++++++++++------------------------- 4 files changed, 250 insertions(+), 85 deletions(-) create mode 100644 src/apt-transaction.c create mode 100644 src/apt-transaction.h diff --git a/src/Makefile.am b/src/Makefile.am index 753b71d..83d12bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,6 +98,8 @@ indicator_session_service_SOURCES = \ device-menu-mgr.c \ apt-watcher.h \ apt-watcher.c \ + apt-transaction.h \ + apt-transaction.c \ udev-mgr.h \ udev-mgr.c indicator_session_service_CFLAGS = \ diff --git a/src/apt-transaction.c b/src/apt-transaction.c new file mode 100644 index 0000000..68e1f6b --- /dev/null +++ b/src/apt-transaction.c @@ -0,0 +1,167 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include "apt-transaction.h" + + +static void apt_transaction_on_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + const gchar* const *invalidated_properties, + gpointer user_data); + +static void apt_transaction_investigate (AptTransaction* self); +static void apt_transaction_simulate_transaction_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data); + +struct _AptTransaction +{ + GObject parent_instance; + GDBusProxy * proxy; + gchar* id; +}; + +G_DEFINE_TYPE (AptTransaction, apt_transaction, G_TYPE_OBJECT); + +static void +apt_transaction_init (AptTransaction *self) +{ + self->proxy = NULL; + self->id = NULL; +} + +static void +apt_transaction_finalize (GObject *object) +{ + /* TODO: Add deinitalization code here */ + AptTransaction* self = APT_TRANSACTION(object); + if (self->proxy != NULL){ + g_object_unref (self->proxy); + self->proxy = NULL; + } + g_free (self->id); + G_OBJECT_CLASS (apt_transaction_parent_class)->finalize (object); +} + +static void +apt_transaction_class_init (AptTransactionClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + //GObjectClass* parent_class = G_OBJECT_CLASS (klass); + object_class->finalize = apt_transaction_finalize; +} + +static void +apt_transaction_investigate(AptTransaction* self) +{ + GError * error = NULL; + + self->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, /* GDBusInterfaceInfo */ + "org.debian.apt", + self->id, + "org.debian.apt.transaction", + NULL, /* GCancellable */ + &error); + if (error != NULL) { + g_warning ("unable to fetch proxy for transaction object path %s", self->id); + g_error_free (error); + return; + } + g_debug ("connecting to the properties changed signal on the transaction object"); + g_signal_connect (self->proxy, + "g-properties-changed", + G_CALLBACK (apt_transaction_on_properties_changed), + self); + + g_debug ("calling simulate on the transaction object"); + g_dbus_proxy_call (self->proxy, + "Simulate", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_transaction_simulate_transaction_cb, + self); +} + +static void +apt_transaction_on_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + const gchar* const *invalidated_properties, + gpointer user_data) +{ + if (g_variant_n_children (changed_properties) > 0) + { + GVariantIter *iter; + const gchar *key; + GVariant *value; + + g_print (" *** Apt Transaction Properties Changed:\n"); + g_variant_get (changed_properties, + "a{sv}", + &iter); + while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) + { + gchar *value_str; + value_str = g_variant_print (value, TRUE); + g_print (" %s -> %s\n", key, value_str); + g_free (value_str); + } + g_variant_iter_free (iter); + } +} + +static void +apt_transaction_simulate_transaction_cb (GObject * obj, + GAsyncResult * res, + gpointer user_data) +{ + g_debug ("Simulate return"); + g_return_if_fail (APT_IS_TRANSACTION (user_data)); + AptTransaction* self = APT_TRANSACTION (user_data); + + GError * error = NULL; + GVariant * result; + + result = g_dbus_proxy_call_finish(self->proxy, res, &error); + + if (error != NULL) { + g_warning ("unable to complete the simulate call"); + g_error_free (error); + return; + } + + g_debug ("simulate returned a %s", + g_variant_get_type_string (result)); + +} + + +AptTransaction* apt_transaction_new (gchar* transaction_id) +{ + AptTransaction* tr = g_object_new (APT_TYPE_TRANSACTION, NULL); + tr->id = transaction_id; + g_debug ("Apt transaction new"); + apt_transaction_investigate (tr); + return tr; +} diff --git a/src/apt-transaction.h b/src/apt-transaction.h new file mode 100644 index 0000000..dec62ef --- /dev/null +++ b/src/apt-transaction.h @@ -0,0 +1,48 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifndef _APT_TRANSACTION_H_ +#define _APT_TRANSACTION_H_ + +#include + +G_BEGIN_DECLS + +#define APT_TYPE_TRANSACTION (apt_transaction_get_type ()) +#define APT_TRANSACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APT_TYPE_TRANSACTION, AptTransaction)) +#define APT_TRANSACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APT_TYPE_TRANSACTION, AptTransactionClass)) +#define APT_IS_TRANSACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APT_TYPE_TRANSACTION)) +#define APT_IS_TRANSACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APT_TYPE_TRANSACTION)) +#define APT_TRANSACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APT_TYPE_TRANSACTION, AptTransactionClass)) + +typedef struct _AptTransactionClass AptTransactionClass; +typedef struct _AptTransaction AptTransaction; + +struct _AptTransactionClass +{ + GObjectClass parent_class; +}; + +AptTransaction* apt_transaction_new (gchar* transaction_id); + +GType apt_transaction_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _APT_TRANSACTION_H_ */ diff --git a/src/apt-watcher.c b/src/apt-watcher.c index d02203b..7553f6e 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -21,6 +21,7 @@ with this program. If not, see . #include #include "apt-watcher.h" #include "dbus-shared-names.h" +#include "apt-transaction.h" static guint watcher_id; @@ -29,10 +30,10 @@ struct _AptWatcher GObject parent_instance; GCancellable * proxy_cancel; GDBusProxy * proxy; - GDBusProxy * transaction_proxy; SessionDbus* session_dbus_interface; DbusmenuMenuitem* apt_item; gint current_state; + AptTransaction* current_transaction; }; static void @@ -53,10 +54,6 @@ static void fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); -static void apt_watcher_simulate_transaction_cb (GObject * obj, - GAsyncResult * res, - gpointer user_data); - static void apt_watcher_upgrade_system_cb (GObject * obj, GAsyncResult * res, gpointer user_data); @@ -72,13 +69,9 @@ static void apt_watcher_signal_cb (GDBusProxy* proxy, GVariant* parameters, gpointer user_data); -static void apt_watcher_determine_state (AptWatcher* self, - GVariant* update); +/*static void apt_watcher_determine_state (AptWatcher* self, + GVariant* update);*/ -static void transaction_on_properties_changed (GDBusProxy *proxy, - GVariant *changed_properties, - const gchar* const *invalidated_properties, - gpointer user_data); G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); @@ -88,7 +81,7 @@ apt_watcher_init (AptWatcher *self) self->current_state = UP_TO_DATE; self->proxy_cancel = g_cancellable_new(); self->proxy = NULL; - self->transaction_proxy = NULL; + self->current_transaction = NULL; g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, @@ -104,6 +97,10 @@ static void apt_watcher_finalize (GObject *object) { g_bus_unwatch_name (watcher_id); + AptWatcher* self = APT_WATCHER (object); + + if (self->proxy != NULL) + g_object_unref (self->proxy); G_OBJECT_CLASS (apt_watcher_parent_class)->finalize (object); } @@ -171,13 +168,15 @@ apt_watcher_on_name_appeared (GDBusConnection *connection, g_dbus_proxy_call (watcher->proxy, "UpgradeSystem", - g_variant_new_boolean (TRUE), + g_variant_new("(b)", TRUE), G_DBUS_CALL_FLAGS_NONE, -1, NULL, apt_watcher_upgrade_system_cb, user_data); + g_debug ("UpgradeSystem apt call made"); + /*g_dbus_proxy_call (watcher->proxy, "GetActiveTransactions", NULL, @@ -196,10 +195,6 @@ apt_watcher_on_name_vanished (GDBusConnection *connection, g_debug ("Name %s does not exist or has just vanished", name); g_return_if_fail (APT_IS_WATCHER (user_data)); - AptWatcher* self = APT_WATCHER (user_data); - - if (self->proxy != NULL) - g_object_unref (self->proxy); } /*static void @@ -228,6 +223,8 @@ apt_watcher_upgrade_system_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { + g_debug ("UpgradeSystem apt callback"); + g_return_if_fail (APT_IS_WATCHER (user_data)); AptWatcher* self = APT_WATCHER (user_data); @@ -244,76 +241,21 @@ apt_watcher_upgrade_system_cb (GObject * obj, gchar* transaction_id = NULL; g_variant_get (result, "(s)", &transaction_id); + + if (transaction_id == NULL){ + g_debug ("apt_watcher_upgrade_system_cb - transaction id is null"); + return; + } - if (transaction_id != NULL){ - if (self->transaction_proxy != NULL){ - g_object_unref (self->transaction_proxy); - self->transaction_proxy = NULL; - } - self->transaction_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - NULL, /* GDBusInterfaceInfo */ - "org.debian.apt", - transaction_id, - "org.debian.apt", - NULL, /* GCancellable */ - &error); - if (error != NULL) { - g_warning ("unable to fetch proxy for transaction object path"); - g_error_free (error); - return; - } - g_signal_connect (self->transaction_proxy, - "g-properties-changed", - G_CALLBACK (transaction_on_properties_changed), - self); - - g_dbus_proxy_call (self->transaction_proxy, - "Simulate", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - apt_watcher_simulate_transaction_cb, - self); - } -} + if (self->current_transaction == NULL){ + self->current_transaction = apt_transaction_new (transaction_id); + } -static void -apt_watcher_simulate_transaction_cb (GObject * obj, - GAsyncResult * res, - gpointer user_data) -{ } -static void -transaction_on_properties_changed (GDBusProxy *proxy, - GVariant *changed_properties, - const gchar* const *invalidated_properties, - gpointer user_data) -{ - if (g_variant_n_children (changed_properties) > 0) - { - GVariantIter *iter; - const gchar *key; - GVariant *value; - - g_print (" *** Properties Changed:\n"); - g_variant_get (changed_properties, - "a{sv}", - &iter); - while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) - { - gchar *value_str; - value_str = g_variant_print (value, TRUE); - g_print (" %s -> %s\n", key, value_str); - g_free (value_str); - } - g_variant_iter_free (iter); - } -} -static void + +/*static void apt_watcher_determine_state (AptWatcher* self, GVariant* update) { @@ -346,7 +288,7 @@ apt_watcher_determine_state (AptWatcher* self, _("Updates Installing...")); } } -} +}*/ static void apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, @@ -355,7 +297,8 @@ apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, { } -// TODO signal is of type s not sas which is on d-feet !!! +// TODO - Ask MVO about this. +// Signal is of type s not sas which is on d-feet !!! static void apt_watcher_signal_cb ( GDBusProxy* proxy, gchar* sender_name, gchar* signal_name, @@ -370,7 +313,12 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){ g_debug ("Active Transactions signal received"); - apt_watcher_determine_state (self, value); + gchar* input = NULL; + g_variant_get(value, "s", & input); + g_debug ("Active Transactions signal - input = %s", input); + if (self->current_transaction == NULL){ + self->current_transaction = apt_transaction_new (input); + } } g_variant_unref (parameters); } -- cgit v1.2.3 From c3a8c16fbfed17d6c3f8a3cae0a6f6abe5194eaa Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 21 Jul 2011 17:00:41 +0100 Subject: properties changed signal is being triggered --- src/apt-transaction.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index 68e1f6b..89a62af 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -110,6 +110,8 @@ apt_transaction_on_properties_changed (GDBusProxy *proxy, const gchar* const *invalidated_properties, gpointer user_data) { + g_print (" *** Apt Transaction Properties Changed:\n"); + if (g_variant_n_children (changed_properties) > 0) { GVariantIter *iter; @@ -156,12 +158,11 @@ apt_transaction_simulate_transaction_cb (GObject * obj, } - AptTransaction* apt_transaction_new (gchar* transaction_id) { AptTransaction* tr = g_object_new (APT_TYPE_TRANSACTION, NULL); tr->id = transaction_id; - g_debug ("Apt transaction new"); + g_debug ("Apt transaction new id = %s", tr->id); apt_transaction_investigate (tr); return tr; } -- cgit v1.2.3 From 7e6cf4cec8da62fc8e784d183af0baed8e7f905c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 21 Jul 2011 20:23:22 +0100 Subject: apt item now sensitive to updates available --- src/apt-transaction.c | 128 +++++++++++++++++++++++++++++++----------------- src/apt-watcher.c | 93 ++++++++++++++++------------------- src/dbus-shared-names.h | 4 +- src/device-menu-mgr.c | 122 ++++++--------------------------------------- 4 files changed, 146 insertions(+), 201 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index 89a62af..1a4aa47 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -20,25 +20,33 @@ with this program. If not, see . #include #include "apt-transaction.h" - - -static void apt_transaction_on_properties_changed (GDBusProxy *proxy, - GVariant *changed_properties, - const gchar* const *invalidated_properties, - gpointer user_data); +#include "dbus-shared-names.h" static void apt_transaction_investigate (AptTransaction* self); static void apt_transaction_simulate_transaction_cb (GObject * obj, GAsyncResult * res, gpointer user_data); +static void apt_transaction_receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data); struct _AptTransaction { GObject parent_instance; GDBusProxy * proxy; gchar* id; + AptState current_state; }; +enum { + UPDATE, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + G_DEFINE_TYPE (AptTransaction, apt_transaction, G_TYPE_OBJECT); static void @@ -46,6 +54,7 @@ apt_transaction_init (AptTransaction *self) { self->proxy = NULL; self->id = NULL; + } static void @@ -67,6 +76,14 @@ apt_transaction_class_init (AptTransactionClass *klass) GObjectClass* object_class = G_OBJECT_CLASS (klass); //GObjectClass* parent_class = G_OBJECT_CLASS (klass); object_class->finalize = apt_transaction_finalize; + + signals[UPDATE] = g_signal_new("state-update", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); } static void @@ -75,22 +92,24 @@ apt_transaction_investigate(AptTransaction* self) GError * error = NULL; self->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, /* GDBusInterfaceInfo */ "org.debian.apt", self->id, "org.debian.apt.transaction", NULL, /* GCancellable */ &error); + g_debug ("Just after creating the proxy for the transaction - id = %s", + self->id); if (error != NULL) { g_warning ("unable to fetch proxy for transaction object path %s", self->id); g_error_free (error); return; } g_debug ("connecting to the properties changed signal on the transaction object"); - g_signal_connect (self->proxy, - "g-properties-changed", - G_CALLBACK (apt_transaction_on_properties_changed), + g_signal_connect (G_OBJECT(self->proxy), + "g-signal", + G_CALLBACK (apt_transaction_receive_signal), self); g_debug ("calling simulate on the transaction object"); @@ -105,32 +124,64 @@ apt_transaction_investigate(AptTransaction* self) } static void -apt_transaction_on_properties_changed (GDBusProxy *proxy, - GVariant *changed_properties, - const gchar* const *invalidated_properties, - gpointer user_data) +apt_transaction_receive_signal (GDBusProxy * proxy, + gchar * sender_name, + gchar * signal_name, + GVariant * parameters, + gpointer user_data) { - g_print (" *** Apt Transaction Properties Changed:\n"); - - if (g_variant_n_children (changed_properties) > 0) + g_return_if_fail (APT_IS_TRANSACTION (user_data)); + AptTransaction* self = APT_TRANSACTION(user_data); + + if (g_strcmp0 (signal_name, "Finished") == 0){ + g_signal_emit (self, + signals[UPDATE], + 0, + FINISHED_CHECKING); + + } + else if (g_strcmp0(signal_name, "PropertyChanged") == 0) { - GVariantIter *iter; - const gchar *key; - GVariant *value; - - g_print (" *** Apt Transaction Properties Changed:\n"); - g_variant_get (changed_properties, - "a{sv}", - &iter); - while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) - { - gchar *value_str; - value_str = g_variant_print (value, TRUE); - g_print (" %s -> %s\n", key, value_str); - g_free (value_str); + gchar* prop_name= NULL; + GVariant* value = NULL; + g_variant_get (parameters, "(sv)", &prop_name, &value); + + if (g_strcmp0 (prop_name, "Dependencies") == 0){ + + + gchar** install = NULL; + gchar** reinstall = NULL; + gchar** remove = NULL; + gchar** purge = NULL; + gchar** upgrade = NULL; + gchar** downgrade = NULL; + gchar** keep = NULL; + g_variant_get (value, "(asasasasasasas)", &install, + &reinstall, &remove, &purge, &upgrade, &downgrade, + &keep); + + //g_debug ("Seemed to uppack dependencies without any warnings"); + //g_debug ("Upgrade quantity : %u", g_strv_length(upgrade)); + gboolean upgrade_needed = (g_strv_length(upgrade) > 0) || + (g_strv_length(install) > 0) || + (g_strv_length(reinstall) > 0) || + (g_strv_length(remove) > 0) || + (g_strv_length(purge) > 0); + if (upgrade_needed == TRUE){ + g_signal_emit (self, + signals[UPDATE], + 0, + UPDATES_AVAILABLE); + + } + else{ + g_signal_emit (self, + signals[UPDATE], + 0, + UP_TO_DATE); + } } - g_variant_iter_free (iter); - } + } } static void @@ -138,24 +189,13 @@ apt_transaction_simulate_transaction_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { - g_debug ("Simulate return"); - g_return_if_fail (APT_IS_TRANSACTION (user_data)); - AptTransaction* self = APT_TRANSACTION (user_data); - GError * error = NULL; - GVariant * result; - - result = g_dbus_proxy_call_finish(self->proxy, res, &error); if (error != NULL) { g_warning ("unable to complete the simulate call"); g_error_free (error); return; } - - g_debug ("simulate returned a %s", - g_variant_get_type_string (result)); - } AptTransaction* apt_transaction_new (gchar* transaction_id) diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 7553f6e..844e273 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -32,7 +32,7 @@ struct _AptWatcher GDBusProxy * proxy; SessionDbus* session_dbus_interface; DbusmenuMenuitem* apt_item; - gint current_state; + AptState current_state; AptTransaction* current_transaction; }; @@ -45,11 +45,6 @@ static void apt_watcher_on_name_vanished (GDBusConnection *connection, const gchar *name, gpointer user_data); -/*static void -apt_watcher_get_active_transactions_cb (GObject * obj, - GAsyncResult * res, - gpointer user_data); - * */ static void fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); @@ -68,9 +63,9 @@ static void apt_watcher_signal_cb (GDBusProxy* proxy, gchar* signal_name, GVariant* parameters, gpointer user_data); - -/*static void apt_watcher_determine_state (AptWatcher* self, - GVariant* update);*/ +static void apt_watcher_manage_transactions (AptWatcher* self, + gchar* transaction_id); + G_DEFINE_TYPE (AptWatcher, apt_watcher, G_TYPE_OBJECT); @@ -144,7 +139,6 @@ fetch_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) self, NULL); - //We'll need to connect to the state changed signal g_signal_connect (self->proxy, "g-signal", G_CALLBACK(apt_watcher_signal_cb), @@ -174,17 +168,6 @@ apt_watcher_on_name_appeared (GDBusConnection *connection, NULL, apt_watcher_upgrade_system_cb, user_data); - - g_debug ("UpgradeSystem apt call made"); - - /*g_dbus_proxy_call (watcher->proxy, - "GetActiveTransactions", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - apt_watcher_get_active_transactions_cb, - user_data);*/ } static void @@ -197,27 +180,6 @@ apt_watcher_on_name_vanished (GDBusConnection *connection, g_return_if_fail (APT_IS_WATCHER (user_data)); } -/*static void -apt_watcher_get_active_transactions_cb (GObject * obj, - GAsyncResult * res, - gpointer user_data) -{ - g_return_if_fail (APT_IS_WATCHER (user_data)); - AptWatcher* self = APT_WATCHER (user_data); - - GError * error = NULL; - GVariant * result; - - result = g_dbus_proxy_call_finish(self->proxy, res, &error); - - if (error != NULL) { - g_warning ("unable to complete the fetching of active transactions"); - g_error_free (error); - return; - } - apt_watcher_determine_state (self, result); -}*/ - static void apt_watcher_upgrade_system_cb (GObject * obj, GAsyncResult * res, @@ -247,10 +209,8 @@ apt_watcher_upgrade_system_cb (GObject * obj, return; } - if (self->current_transaction == NULL){ - self->current_transaction = apt_transaction_new (transaction_id); - } - + apt_watcher_manage_transactions (self, transaction_id); + } @@ -297,6 +257,42 @@ apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, { } + +static void +apt_watcher_transaction_state_update_cb (AptTransaction* trans, + gint update, + gpointer user_data) +{ + g_debug ("apt-watcher -transaction update %i", update); + g_return_if_fail (APT_IS_WATCHER (user_data)); + AptWatcher* self = APT_WATCHER (user_data); + + AptState state = (AptState)update; + + if ( state == UP_TO_DATE ){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + } + else if ( state == UPDATES_AVAILABLE ){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Updates Available…")); + } + self->current_state = state; +} + +static void +apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id) +{ + if (self->current_transaction == NULL){ + self->current_transaction = apt_transaction_new (transaction_id); + g_signal_connect (G_OBJECT(self->current_transaction), + "state-update", + G_CALLBACK(apt_watcher_transaction_state_update_cb), self); + } +} + // TODO - Ask MVO about this. // Signal is of type s not sas which is on d-feet !!! static void apt_watcher_signal_cb ( GDBusProxy* proxy, @@ -312,13 +308,10 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, GVariant *value = g_variant_get_child_value (parameters, 0); if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){ - g_debug ("Active Transactions signal received"); gchar* input = NULL; g_variant_get(value, "s", & input); g_debug ("Active Transactions signal - input = %s", input); - if (self->current_transaction == NULL){ - self->current_transaction = apt_transaction_new (input); - } + apt_watcher_manage_transactions (self, input); } g_variant_unref (parameters); } diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 8d0c6db..13ad227 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -22,8 +22,10 @@ with this program. If not, see . typedef enum { UP_TO_DATE, - UPDATES_IN_PROGRESS, + CHECKING_FOR_UPDATES, UPDATES_AVAILABLE, + FINISHED_CHECKING, + UPDATING, RESTART_NEEDED }AptState; diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 9c54ef3..b13b2fa 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -54,7 +54,6 @@ static DbusmenuMenuitem *printers_menuitem = NULL; static DbusmenuMenuitem *scanners_menuitem = NULL; static DbusmenuMenuitem *webcam_menuitem = NULL; - static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; @@ -188,6 +187,7 @@ sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) return; } + /*static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, @@ -251,16 +251,15 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) gboolean local_can_suspend = g_value_get_boolean(&candoit); if (local_can_suspend != can_suspend) { can_suspend = local_can_suspend; + // TODO figure out what needs updating on the menu device_menu_mgr_rebuild_items(self); } - return; } /* Response to getting the hibernate property */ // TODO // Is this needed anymore - static void hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) { @@ -434,6 +433,19 @@ show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) g_free(dialog_line); } +static void +show_session_properties (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("gnome-session-properties", &error)) + { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } +} + static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, @@ -496,7 +508,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) _("Login Items...")); g_signal_connect (G_OBJECT(login_settings_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), + G_CALLBACK(show_session_properties), "login"); dbusmenu_menuitem_child_add_position(self->root_item, login_settings_menuitem, @@ -660,108 +672,6 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) static void device_menu_mgr_rebuild_items (DeviceMenuMgr* self) { - //gboolean can_lockscreen; - - /* Make sure we have a valid GConf client, and build one - if needed */ - //device_menu_mgr_ensure_gconf_client (self); - - /*can_lockscreen = !gconf_client_get_bool ( gconf_client, - LOCKDOWN_KEY_SCREENSAVER, - NULL); - if (can_lockscreen) { - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (lock_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Lock Screen")); - - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); - if (shortcut != NULL) { - g_debug("Lock screen shortcut: %s", shortcut); - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); - g_free(shortcut); - } else { - g_debug("Unable to get lock screen shortcut."); - } - - g_signal_connect (G_OBJECT(lock_menuitem), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); - } - - logout_mi = dbusmenu_menuitem_new(); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out")); - } else { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (logout_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_logout()); - dbusmenu_menuitem_child_append(self->root_item, logout_mi); - g_signal_connect( G_OBJECT(logout_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "logout"); - - if (can_suspend && allow_suspend) { - suspend_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (suspend_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Suspend")); - dbusmenu_menuitem_child_append (self->root_item, suspend_mi); - g_signal_connect( G_OBJECT(suspend_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(machine_sleep_from_suspend), - self); - } - - if (can_hibernate && allow_hibernate) { - hibernate_mi = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (hibernate_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Hibernate")); - dbusmenu_menuitem_child_append(self->root_item, hibernate_mi); - g_signal_connect (G_OBJECT(hibernate_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(machine_sleep_from_hibernate), self); - } - - dbusmenu_menuitem_child_append(self->root_item, restart_mi); - g_signal_connect (G_OBJECT(restart_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "restart"); - - shutdown_mi = dbusmenu_menuitem_new(); - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (shutdown_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Shut Down")); - } else { - dbusmenu_menuitem_property_set (shutdown_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Shut Down\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (shutdown_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_shutdown()); - dbusmenu_menuitem_child_append (self->root_item, shutdown_mi); - g_signal_connect (G_OBJECT(shutdown_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "shutdown"); - - RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); - restart_shutdown_logout_mi->logout_mi = logout_mi; - restart_shutdown_logout_mi->restart_mi = restart_mi; - restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - - update_menu_entries(restart_shutdown_logout_mi); - - return;*/ } /* When the directory changes we need to figure out how our menu -- cgit v1.2.3 From f94d6c4fe9c1ccb5a5e731b327fd57635c0ce326 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 21 Jul 2011 20:48:52 +0100 Subject: apt transactions working nicely --- src/apt-transaction.c | 15 ++---------- src/apt-watcher.c | 64 +++++++++++++++++---------------------------------- src/session-service.c | 4 ++-- 3 files changed, 25 insertions(+), 58 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index 1a4aa47..e613507 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -74,7 +74,6 @@ static void apt_transaction_class_init (AptTransactionClass *klass) { GObjectClass* object_class = G_OBJECT_CLASS (klass); - //GObjectClass* parent_class = G_OBJECT_CLASS (klass); object_class->finalize = apt_transaction_finalize; signals[UPDATE] = g_signal_new("state-update", @@ -99,20 +98,17 @@ apt_transaction_investigate(AptTransaction* self) "org.debian.apt.transaction", NULL, /* GCancellable */ &error); - g_debug ("Just after creating the proxy for the transaction - id = %s", - self->id); if (error != NULL) { g_warning ("unable to fetch proxy for transaction object path %s", self->id); g_error_free (error); return; } - g_debug ("connecting to the properties changed signal on the transaction object"); + g_signal_connect (G_OBJECT(self->proxy), "g-signal", G_CALLBACK (apt_transaction_receive_signal), self); - g_debug ("calling simulate on the transaction object"); g_dbus_proxy_call (self->proxy, "Simulate", NULL, @@ -133,14 +129,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy, g_return_if_fail (APT_IS_TRANSACTION (user_data)); AptTransaction* self = APT_TRANSACTION(user_data); - if (g_strcmp0 (signal_name, "Finished") == 0){ - g_signal_emit (self, - signals[UPDATE], - 0, - FINISHED_CHECKING); - - } - else if (g_strcmp0(signal_name, "PropertyChanged") == 0) + if (g_strcmp0(signal_name, "PropertyChanged") == 0) { gchar* prop_name= NULL; GVariant* value = NULL; diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 844e273..546c733 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -185,8 +185,6 @@ apt_watcher_upgrade_system_cb (GObject * obj, GAsyncResult * res, gpointer user_data) { - g_debug ("UpgradeSystem apt callback"); - g_return_if_fail (APT_IS_WATCHER (user_data)); AptWatcher* self = APT_WATCHER (user_data); @@ -205,7 +203,7 @@ apt_watcher_upgrade_system_cb (GObject * obj, g_variant_get (result, "(s)", &transaction_id); if (transaction_id == NULL){ - g_debug ("apt_watcher_upgrade_system_cb - transaction id is null"); + g_warning ("apt_watcher_upgrade_system_cb - transaction id is null"); return; } @@ -213,49 +211,17 @@ apt_watcher_upgrade_system_cb (GObject * obj, } - - -/*static void -apt_watcher_determine_state (AptWatcher* self, - GVariant* update) -{ - g_debug ("WE GOT SOME ACTIVE TRANSACTIONS TO EXAMINE, type is %s", - g_variant_get_type_string (update)); - - gchar* first_param = NULL; - gchar ** transactions = NULL; - - g_variant_get (update, "(sas)", &first_param, &transactions); - - g_debug ("apt_watcher_determine_state - the size is the string array %u", - g_strv_length (transactions)); - g_debug ("apt_watcher_determine_state - first param = %s", first_param); - - if (first_param == NULL){ - if (self->current_state != UP_TO_DATE){ - dbusmenu_menuitem_property_set (self->apt_item, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Software Up to Date")); - } - } - else{ - gboolean updating = g_str_has_prefix (first_param, - "/org/debian/apt/transaction/"); - if (updating == TRUE){ - self->current_state = UPDATES_IN_PROGRESS; - dbusmenu_menuitem_property_set (self->apt_item, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Updates Installing...")); - } - } -}*/ - static void apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) { - + GError * error = NULL; + if (!g_spawn_command_line_async("update-manager", &error)) + { + g_warning("Unable to show update-manager: %s", error->message); + g_error_free(error); + } } static void @@ -280,6 +246,8 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, _("Updates Available…")); } self->current_state = state; + g_object_unref (self->current_transaction); + self->current_transaction = NULL; } static void @@ -287,6 +255,7 @@ apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id) { if (self->current_transaction == NULL){ self->current_transaction = apt_transaction_new (transaction_id); + g_object_ref (self->current_transaction); g_signal_connect (G_OBJECT(self->current_transaction), "state-update", G_CALLBACK(apt_watcher_transaction_state_update_cb), self); @@ -310,8 +279,17 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){ gchar* input = NULL; g_variant_get(value, "s", & input); - g_debug ("Active Transactions signal - input = %s", input); - apt_watcher_manage_transactions (self, input); + + g_debug ("Active Transactions signal - input is null = %i", input == NULL); + // TODO don't call on null terminated input + g_dbus_proxy_call (self->proxy, + "UpgradeSystem", + g_variant_new("(b)", TRUE), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_watcher_upgrade_system_cb, + user_data); } g_variant_unref (parameters); } diff --git a/src/session-service.c b/src/session-service.c index 22552dc..bb473e9 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -71,10 +71,10 @@ static GMainLoop * mainloop = NULL; void service_shutdown (IndicatorService * service, gpointer user_data) { - /*if (mainloop != NULL) { + if (mainloop != NULL) { g_debug("Service shutdown"); g_main_loop_quit(mainloop); - }*/ + } return; } -- cgit v1.2.3 From 3bfa1c305fbba42c48ed7338e5064745bb122a91 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 11:59:15 +0100 Subject: suspend plugged back in plus both it and hibernate menuitems should now be sensitive to changes coming from upower --- src/device-menu-mgr.c | 40 ++++++++++++++++++++++++++-------------- src/session-service.c | 4 ++-- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index b13b2fa..22e970f 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -58,7 +58,7 @@ static DBusGProxyCall * suspend_call = NULL; static DBusGProxyCall * hibernate_call = NULL; static DbusmenuMenuitem * hibernate_mi = NULL; -//static DbusmenuMenuitem * suspend_mi = NULL; +static DbusmenuMenuitem * suspend_mi = NULL; static DbusmenuMenuitem * logout_mi = NULL; static DbusmenuMenuitem * restart_mi = NULL; static DbusmenuMenuitem * shutdown_mi = NULL; @@ -86,11 +86,11 @@ static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); -/*static void +static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata); -*/ + G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); static void @@ -106,7 +106,6 @@ device_menu_mgr_init (DeviceMenuMgr *self) static void device_menu_mgr_finalize (GObject *object) { - /* TODO: Add deinitalization code here */ G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object); } @@ -115,7 +114,6 @@ static void device_menu_mgr_class_init (DeviceMenuMgrClass *klass) { GObjectClass* object_class = G_OBJECT_CLASS (klass); - //GObjectClass* parent_class = G_OBJECT_CLASS (klass); object_class->finalize = device_menu_mgr_finalize; } @@ -187,15 +185,14 @@ sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) return; } - -/*static void +static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata); machine_sleep_with_context (self, "Suspend"); -}*/ +} static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, @@ -229,9 +226,6 @@ machine_sleep_with_context (DeviceMenuMgr* self, gchar* type) } /* A response to getting the suspend property */ -// TODO -// Is this needed anymore - static void suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) { @@ -252,14 +246,14 @@ suspend_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) if (local_can_suspend != can_suspend) { can_suspend = local_can_suspend; // TODO figure out what needs updating on the menu + // And add or remove it but just don't rebuild the whole menu + // a waste device_menu_mgr_rebuild_items(self); } return; } /* Response to getting the hibernate property */ -// TODO -// Is this needed anymore static void hibernate_prop_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) { @@ -630,6 +624,18 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout"); + if (can_suspend && allow_suspend) { + suspend_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (suspend_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Suspend")); + dbusmenu_menuitem_child_append (self->root_item, suspend_mi); + g_signal_connect( G_OBJECT(suspend_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(machine_sleep_from_suspend), + self); + } + if (can_hibernate && allow_hibernate) { hibernate_mi = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (hibernate_mi, @@ -672,7 +678,13 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) static void device_menu_mgr_rebuild_items (DeviceMenuMgr* self) { -} + dbusmenu_menuitem_property_set_bool (hibernate_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + can_hibernate && allow_hibernate); + dbusmenu_menuitem_property_set_bool (suspend_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + can_suspend && allow_suspend); +} /* When the directory changes we need to figure out how our menu item should look. */ diff --git a/src/session-service.c b/src/session-service.c index bb473e9..74fe5b0 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -71,11 +71,11 @@ static GMainLoop * mainloop = NULL; void service_shutdown (IndicatorService * service, gpointer user_data) { - if (mainloop != NULL) { + /*if (mainloop != NULL) { g_debug("Service shutdown"); g_main_loop_quit(mainloop); } - return; + return;*/ } /* Main, is well, main. It brings everything up and throws -- cgit v1.2.3 From bc829db4eb65f7373b2ff13cd5dc8ce96a469af3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 13:37:16 +0100 Subject: transaction object now properly disposed of --- src/apt-transaction.c | 40 +++++++++++++++++++++++++++++++++++----- src/apt-watcher.c | 13 +++++++++---- src/dbus-shared-names.h | 3 +-- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index e613507..4f800ad 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -54,14 +54,16 @@ apt_transaction_init (AptTransaction *self) { self->proxy = NULL; self->id = NULL; - } static void apt_transaction_finalize (GObject *object) { - /* TODO: Add deinitalization code here */ AptTransaction* self = APT_TRANSACTION(object); + g_signal_handlers_disconnect_by_func (G_OBJECT (self->proxy), + G_CALLBACK (apt_transaction_receive_signal), + self); + if (self->proxy != NULL){ g_object_unref (self->proxy); self->proxy = NULL; @@ -91,7 +93,7 @@ apt_transaction_investigate(AptTransaction* self) GError * error = NULL; self->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, + G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo */ "org.debian.apt", self->id, @@ -127,14 +129,42 @@ apt_transaction_receive_signal (GDBusProxy * proxy, gpointer user_data) { g_return_if_fail (APT_IS_TRANSACTION (user_data)); - AptTransaction* self = APT_TRANSACTION(user_data); - + AptTransaction* self = APT_TRANSACTION(user_data); + + GVariant* role = g_dbus_proxy_get_cached_property (self->proxy, + "Role"); + g_debug ("Role variant type = %s", g_variant_get_type_string (role)); + if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){ + gchar* current_role = NULL; + g_variant_get (role, "s", ¤t_role); + g_debug ("Current transaction role = %s", current_role); + if (g_strcmp0 (current_role, "role-commit-packages") == 0 || + g_strcmp0 (current_role, "role-upgrade-system") == 0){ + g_debug ("UPGRADE IN PROGRESS"); + g_signal_emit (self, + signals[UPDATE], + 0, + UPGRADE_IN_PROGRESS); + // Return from here because an upgrade is in progress so + // any other information is irrelevant. + return; + } + } + if (g_strcmp0(signal_name, "PropertyChanged") == 0) { gchar* prop_name= NULL; GVariant* value = NULL; g_variant_get (parameters, "(sv)", &prop_name, &value); + g_debug ("transaction prop update - prop = %s", prop_name); + + if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING) == TRUE){ + gchar* key = NULL; + g_variant_get (value, "s", &key); + g_debug ("transaction prop update - value = %s", key); + } + if (g_strcmp0 (prop_name, "Dependencies") == 0){ diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 546c733..c7238ec 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -235,18 +235,23 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, AptState state = (AptState)update; - if ( state == UP_TO_DATE ){ + if (state == UP_TO_DATE){ dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Software Up to Date")); } - else if ( state == UPDATES_AVAILABLE ){ + else if (state == UPDATES_AVAILABLE){ dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Updates Available…")); + } + else if (state == UPGRADE_IN_PROGRESS){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Updates Installing…")); } self->current_state = state; - g_object_unref (self->current_transaction); + g_object_unref (G_OBJECT(self->current_transaction)); self->current_transaction = NULL; } @@ -255,7 +260,7 @@ apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id) { if (self->current_transaction == NULL){ self->current_transaction = apt_transaction_new (transaction_id); - g_object_ref (self->current_transaction); + //g_object_ref (self->current_transaction); g_signal_connect (G_OBJECT(self->current_transaction), "state-update", G_CALLBACK(apt_watcher_transaction_state_update_cb), self); diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 13ad227..7c6c14f 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -24,8 +24,7 @@ typedef enum { UP_TO_DATE, CHECKING_FOR_UPDATES, UPDATES_AVAILABLE, - FINISHED_CHECKING, - UPDATING, + UPGRADE_IN_PROGRESS, RESTART_NEEDED }AptState; -- cgit v1.2.3 From 13452b541f9aabf229f16a029a4c823c76e2b1f0 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 15:36:59 +0100 Subject: apt progress now reflected dynamically in the menu --- src/apt-transaction.c | 107 +++++++++++++++++++++++++----------------------- src/apt-transaction.h | 5 ++- src/apt-watcher.c | 60 +++++++++++++++++++-------- src/dbus-shared-names.h | 13 ++++-- src/device-menu-mgr.c | 14 ++++++- src/session-service.c | 4 +- 6 files changed, 123 insertions(+), 80 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index 4f800ad..61868a3 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -34,10 +34,10 @@ static void apt_transaction_receive_signal (GDBusProxy * proxy, struct _AptTransaction { - GObject parent_instance; - GDBusProxy * proxy; - gchar* id; - AptState current_state; + GObject parent_instance; + GDBusProxy * proxy; + gchar* id; + TransactionType type; }; enum { @@ -63,11 +63,10 @@ apt_transaction_finalize (GObject *object) g_signal_handlers_disconnect_by_func (G_OBJECT (self->proxy), G_CALLBACK (apt_transaction_receive_signal), self); - if (self->proxy != NULL){ g_object_unref (self->proxy); self->proxy = NULL; - } + } g_free (self->id); G_OBJECT_CLASS (apt_transaction_parent_class)->finalize (object); } @@ -111,14 +110,16 @@ apt_transaction_investigate(AptTransaction* self) G_CALLBACK (apt_transaction_receive_signal), self); - g_dbus_proxy_call (self->proxy, - "Simulate", - NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - apt_transaction_simulate_transaction_cb, - self); + if (self->type == SIMULATION){ + g_dbus_proxy_call (self->proxy, + "Simulate", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + apt_transaction_simulate_transaction_cb, + self); + } } static void @@ -130,33 +131,13 @@ apt_transaction_receive_signal (GDBusProxy * proxy, { g_return_if_fail (APT_IS_TRANSACTION (user_data)); AptTransaction* self = APT_TRANSACTION(user_data); + AptState current_state = UP_TO_DATE; - GVariant* role = g_dbus_proxy_get_cached_property (self->proxy, - "Role"); - g_debug ("Role variant type = %s", g_variant_get_type_string (role)); - if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){ - gchar* current_role = NULL; - g_variant_get (role, "s", ¤t_role); - g_debug ("Current transaction role = %s", current_role); - if (g_strcmp0 (current_role, "role-commit-packages") == 0 || - g_strcmp0 (current_role, "role-upgrade-system") == 0){ - g_debug ("UPGRADE IN PROGRESS"); - g_signal_emit (self, - signals[UPDATE], - 0, - UPGRADE_IN_PROGRESS); - // Return from here because an upgrade is in progress so - // any other information is irrelevant. - return; - } - } - - if (g_strcmp0(signal_name, "PropertyChanged") == 0) + if (g_strcmp0(signal_name, "PropertyChanged") == 0 && self->type == SIMULATION) { gchar* prop_name= NULL; GVariant* value = NULL; - g_variant_get (parameters, "(sv)", &prop_name, &value); - + g_variant_get (parameters, "(sv)", &prop_name, &value); g_debug ("transaction prop update - prop = %s", prop_name); if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING) == TRUE){ @@ -166,8 +147,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy, } if (g_strcmp0 (prop_name, "Dependencies") == 0){ - - + gchar** install = NULL; gchar** reinstall = NULL; gchar** remove = NULL; @@ -177,8 +157,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy, gchar** keep = NULL; g_variant_get (value, "(asasasasasasas)", &install, &reinstall, &remove, &purge, &upgrade, &downgrade, - &keep); - + &keep); //g_debug ("Seemed to uppack dependencies without any warnings"); //g_debug ("Upgrade quantity : %u", g_strv_length(upgrade)); gboolean upgrade_needed = (g_strv_length(upgrade) > 0) || @@ -187,20 +166,39 @@ apt_transaction_receive_signal (GDBusProxy * proxy, (g_strv_length(remove) > 0) || (g_strv_length(purge) > 0); if (upgrade_needed == TRUE){ - g_signal_emit (self, - signals[UPDATE], - 0, - UPDATES_AVAILABLE); - + current_state = UPDATES_AVAILABLE; } else{ - g_signal_emit (self, - signals[UPDATE], - 0, - UP_TO_DATE); + current_state = UP_TO_DATE; + } + } + } + else if (g_strcmp0(signal_name, "PropertyChanged") == 0 && + self->type == REAL) + { + GVariant* role = g_dbus_proxy_get_cached_property (self->proxy, + "Role"); + if (g_variant_is_of_type (role, G_VARIANT_TYPE_STRING) == TRUE){ + gchar* current_role = NULL; + g_variant_get (role, "s", ¤t_role); + g_debug ("Current transaction role = %s", current_role); + if (g_strcmp0 (current_role, "role-commit-packages") == 0 || + g_strcmp0 (current_role, "role-upgrade-system") == 0){ + g_debug ("UPGRADE IN PROGRESS"); + current_state = UPGRADE_IN_PROGRESS; } } + } + else if (g_strcmp0(signal_name, "Finished") == 0) + { + g_debug ("TRANSACTION Finished"); + current_state = FINISHED; } + // Finally send out the state update + g_signal_emit (self, + signals[UPDATE], + 0, + current_state); } static void @@ -209,18 +207,23 @@ apt_transaction_simulate_transaction_cb (GObject * obj, gpointer user_data) { GError * error = NULL; - if (error != NULL) { g_warning ("unable to complete the simulate call"); g_error_free (error); return; } } +TransactionType +apt_transaction_get_transaction_type (AptTransaction* self) +{ + return self->type; +} -AptTransaction* apt_transaction_new (gchar* transaction_id) +AptTransaction* apt_transaction_new (gchar* transaction_id, TransactionType t) { AptTransaction* tr = g_object_new (APT_TYPE_TRANSACTION, NULL); tr->id = transaction_id; + tr->type = t; g_debug ("Apt transaction new id = %s", tr->id); apt_transaction_investigate (tr); return tr; diff --git a/src/apt-transaction.h b/src/apt-transaction.h index dec62ef..9e4370d 100644 --- a/src/apt-transaction.h +++ b/src/apt-transaction.h @@ -21,6 +21,7 @@ with this program. If not, see . #define _APT_TRANSACTION_H_ #include +#include "dbus-shared-names.h" G_BEGIN_DECLS @@ -39,8 +40,8 @@ struct _AptTransactionClass GObjectClass parent_class; }; -AptTransaction* apt_transaction_new (gchar* transaction_id); - +AptTransaction* apt_transaction_new (gchar* transaction_id, TransactionType t); +TransactionType apt_transaction_get_transaction_type (AptTransaction* self); GType apt_transaction_get_type (void) G_GNUC_CONST; G_END_DECLS diff --git a/src/apt-watcher.c b/src/apt-watcher.c index c7238ec..285eb81 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -20,7 +20,6 @@ with this program. If not, see . #include #include #include "apt-watcher.h" -#include "dbus-shared-names.h" #include "apt-transaction.h" static guint watcher_id; @@ -238,33 +237,53 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, if (state == UP_TO_DATE){ dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, - _("Software Up to Date")); + _("Software Up to Date")); + // Simulations don't send a finished signal for some reason + // Anyway from a simulation we just need one state update + // (updates available or not) + if (apt_transaction_get_transaction_type (self->current_transaction) + == SIMULATION){ + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } } else if (state == UPDATES_AVAILABLE){ dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Updates Available…")); + // Simulations don't send a finished signal for some reason + // Anyway from a simulation we just need one state update + // (updates available or not) + if (apt_transaction_get_transaction_type (self->current_transaction) + == SIMULATION){ + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } } else if (state == UPGRADE_IN_PROGRESS){ dbusmenu_menuitem_property_set (self->apt_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Updates Installing…")); } + else if (state == FINISHED){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } self->current_state = state; - g_object_unref (G_OBJECT(self->current_transaction)); - self->current_transaction = NULL; } static void apt_watcher_manage_transactions (AptWatcher* self, gchar* transaction_id) { if (self->current_transaction == NULL){ - self->current_transaction = apt_transaction_new (transaction_id); - //g_object_ref (self->current_transaction); + self->current_transaction = apt_transaction_new (transaction_id, SIMULATION); g_signal_connect (G_OBJECT(self->current_transaction), "state-update", G_CALLBACK(apt_watcher_transaction_state_update_cb), self); - } + } } // TODO - Ask MVO about this. @@ -284,17 +303,22 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, if (g_strcmp0(signal_name, "ActiveTransactionsChanged") == 0){ gchar* input = NULL; g_variant_get(value, "s", & input); - - g_debug ("Active Transactions signal - input is null = %i", input == NULL); - // TODO don't call on null terminated input - g_dbus_proxy_call (self->proxy, - "UpgradeSystem", - g_variant_new("(b)", TRUE), - G_DBUS_CALL_FLAGS_NONE, - -1, - NULL, - apt_watcher_upgrade_system_cb, - user_data); + if (g_str_has_prefix (input, "/org/debian/apt/transaction/") == TRUE){ + g_debug ("Active Transactions signal - input is null = %i", input == NULL); + + if (self->current_transaction != NULL) + { + g_object_unref (G_OBJECT(self->current_transaction)); + self->current_transaction = NULL; + } + + self->current_transaction = apt_transaction_new (input, REAL); + g_signal_connect (G_OBJECT(self->current_transaction), + "state-update", + G_CALLBACK(apt_watcher_transaction_state_update_cb), self); + + + } } g_variant_unref (parameters); } diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h index 7c6c14f..2114332 100644 --- a/src/dbus-shared-names.h +++ b/src/dbus-shared-names.h @@ -20,17 +20,22 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#ifndef __DBUS_SHARED_NAMES_H__ +#define __DBUS_SHARED_NAMES_H__ + typedef enum { UP_TO_DATE, CHECKING_FOR_UPDATES, UPDATES_AVAILABLE, - UPGRADE_IN_PROGRESS, + UPGRADE_IN_PROGRESS, + FINISHED, RESTART_NEEDED }AptState; - -#ifndef __DBUS_SHARED_NAMES_H__ -#define __DBUS_SHARED_NAMES_H__ 1 +typedef enum { + SIMULATION, + REAL +}TransactionType; #define INDICATOR_USERS_DBUS_NAME INDICATOR_SESSION_DBUS_NAME #define INDICATOR_USERS_DBUS_OBJECT "/com/canonical/indicator/users/menu" diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 22e970f..324b3f1 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -499,13 +499,13 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) login_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (login_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, - _("Login Items...")); + _("Startup Applications...")); g_signal_connect (G_OBJECT(login_settings_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_session_properties), "login"); dbusmenu_menuitem_child_add_position(self->root_item, - login_settings_menuitem, + login_settings_menuitem, 3); software_updates_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (software_updates_menuitem, @@ -555,6 +555,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position (self->root_item, scanners_menuitem, 8); + //tmp + dbusmenu_menuitem_property_set_bool (scanners_menuitem, + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + webcam_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (webcam_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -566,6 +571,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position (self->root_item, webcam_menuitem, 10); + //tmp + dbusmenu_menuitem_property_set_bool (webcam_menuitem, + DBUSMENU_MENUITEM_PROP_VISIBLE, + FALSE); + DbusmenuMenuitem * separator3 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (separator3, DBUSMENU_MENUITEM_PROP_TYPE, diff --git a/src/session-service.c b/src/session-service.c index 74fe5b0..bb473e9 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -71,11 +71,11 @@ static GMainLoop * mainloop = NULL; void service_shutdown (IndicatorService * service, gpointer user_data) { - /*if (mainloop != NULL) { + if (mainloop != NULL) { g_debug("Service shutdown"); g_main_loop_quit(mainloop); } - return;*/ + return; } /* Main, is well, main. It brings everything up and throws -- cgit v1.2.3 From ae4e70778e02f44c68a5860d701f216cefe58cd3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 17:40:20 +0100 Subject: fixed issues --- src/apt-transaction.c | 63 ++++++++++++++++++++++++++++++++++++--------------- src/apt-watcher.h | 7 ++++++ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index e613507..51a5ce9 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -31,11 +31,15 @@ static void apt_transaction_receive_signal (GDBusProxy * proxy, gchar * signal_name, GVariant * parameters, gpointer user_data); +static void apt_transaction_finish_proxy_setup (GObject *source_object, + GAsyncResult *res, + gpointer user_data); struct _AptTransaction { GObject parent_instance; GDBusProxy * proxy; + GCancellable * proxy_cancel; gchar* id; AptState current_state; }; @@ -54,7 +58,7 @@ apt_transaction_init (AptTransaction *self) { self->proxy = NULL; self->id = NULL; - + self->proxy_cancel = g_cancellable_new(); } static void @@ -84,25 +88,46 @@ apt_transaction_class_init (AptTransactionClass *klass) g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); } +// TODO: you don't need this additional helper +// Just GObject properties properly +static void +apt_transaction_investigate (AptTransaction* self) +{ + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.debian.apt", + self->id, + "org.debian.apt.transaction", + self->proxy_cancel, + apt_transaction_finish_proxy_setup, + self); +} static void -apt_transaction_investigate(AptTransaction* self) +apt_transaction_finish_proxy_setup (GObject *source_object, + GAsyncResult *res, + gpointer user_data) { - GError * error = NULL; - - self->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, - NULL, /* GDBusInterfaceInfo */ - "org.debian.apt", - self->id, - "org.debian.apt.transaction", - NULL, /* GCancellable */ - &error); - if (error != NULL) { - g_warning ("unable to fetch proxy for transaction object path %s", self->id); - g_error_free (error); - return; - } + g_return_if_fail (APT_IS_TRANSACTION (user_data)); + AptTransaction* self = APT_TRANSACTION(user_data); + GError * error = NULL; + + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (self->proxy_cancel != NULL) { + g_object_unref(self->proxy_cancel); + self->proxy_cancel = NULL; + } + + if (error != NULL) { + g_warning("Could not grab DBus proxy for %s: %s", + "org.debian.apt", error->message); + g_error_free(error); + return; + } + + self->proxy = proxy; g_signal_connect (G_OBJECT(self->proxy), "g-signal", @@ -117,7 +142,8 @@ apt_transaction_investigate(AptTransaction* self) NULL, apt_transaction_simulate_transaction_cb, self); -} + +} static void apt_transaction_receive_signal (GDBusProxy * proxy, @@ -171,6 +197,7 @@ apt_transaction_receive_signal (GDBusProxy * proxy, } } } + g_variant_unref (parameters); } static void diff --git a/src/apt-watcher.h b/src/apt-watcher.h index cbe0e29..7b98a44 100644 --- a/src/apt-watcher.h +++ b/src/apt-watcher.h @@ -21,8 +21,15 @@ with this program. If not, see . #define _APT_WATCHER_H_ #include + #include + +#include +#if GTK_CHECK_VERSION(3, 0, 0) #include +#else +#include +#endif #include "session-dbus.h" -- cgit v1.2.3 From 92208b4e83ca7d486aa65ebc4b80e0d36e94095f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 18:07:00 +0100 Subject: bumped version in configure ac in prep for release --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2c4c867..17f5c55 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.93) +AM_INIT_AUTOMAKE(indicator-session, 0.2.94) AM_MAINTAINER_MODE -- cgit v1.2.3 From 213927976eb58fe6c3cc26d5426ad6e3e2d69c14 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 18:12:20 +0100 Subject: added new files to the po index --- po/POTFILES.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/po/POTFILES.in b/po/POTFILES.in index c2256c1..08eff5f 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,3 +7,6 @@ src/gtk-logout-helper.c src/dialog.c src/indicator-session.c src/session-service.c +src/apt-watcher.c +src/device-menu-mgr.c +src/user-menu-mgr.c -- cgit v1.2.3 From df0f2927babbf31d51b8a33fcf744d2a92e70ac5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 18:15:55 +0100 Subject: moving to 0.3.0 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 17f5c55..369f12b 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.94) +AM_INIT_AUTOMAKE(indicator-session, 0.3.0) AM_MAINTAINER_MODE -- cgit v1.2.3 From a1a7357b58d182e077ebfe8fb11c083e5eb18839 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 22 Jul 2011 18:22:37 +0100 Subject: uncomment the disconnect method --- src/session-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index 22552dc..bb473e9 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -71,10 +71,10 @@ static GMainLoop * mainloop = NULL; void service_shutdown (IndicatorService * service, gpointer user_data) { - /*if (mainloop != NULL) { + if (mainloop != NULL) { g_debug("Service shutdown"); g_main_loop_quit(mainloop); - }*/ + } return; } -- cgit v1.2.3 From 9ba850c1b9a28b2773ea4a8fedc1eaa2e606704a Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Fri, 22 Jul 2011 14:26:36 -0400 Subject: - fixed bug where the user menu wouldn't open in unity (LP: #812728) - Include apt, settings and device menus * debian/rules - Updated gtk configure args --- debian/changelog | 4 ++++ debian/rules | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9641785..0cb8580 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,10 @@ indicator-session (0.3.0-0ubuntu1) UNRELEASED; urgency=low * New upstream release. + - fixed bug where the user menu wouldn't open in unity (LP: #812728) + - Include apt, settings and device menus + * debian/rules + - Updated gtk configure args -- Ken VanDine Fri, 22 Jul 2011 13:41:08 -0400 diff --git a/debian/rules b/debian/rules index c8bc001..8d716bc 100755 --- a/debian/rules +++ b/debian/rules @@ -9,8 +9,8 @@ include /usr/share/cdbs/1/class/gnome.mk DEB_MAKE_DESTDIRSKEL = $(CURDIR)/debian/tmp/@FLAVOR@ DEB_DESTDIR = $(CURDIR)/debian/tmp/$(cdbs_make_curflavor)/ -DEB_CONFIGURE_FLAGS_gtk2 = --with-indicator-gtk=2 -DEB_CONFIGURE_FLAGS_gtk3 = --with-indicator-gtk=3 +DEB_CONFIGURE_FLAGS_gtk2 = --with-gtk=2 +DEB_CONFIGURE_FLAGS_gtk3 = --with-gtk=3 DEB_CONFIGURE_EXTRA_FLAGS = --disable-static LDFLAGS += -Wl,-z,defs -Wl,--as-needed -- cgit v1.2.3 From f0c187f8dd55d8b831892ce30937aed2b737c5f8 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Fri, 22 Jul 2011 14:35:37 -0400 Subject: releasing version 0.3.0-0ubuntu1 --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 0cb8580..59544bb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-session (0.3.0-0ubuntu1) UNRELEASED; urgency=low +indicator-session (0.3.0-0ubuntu1) oneiric; urgency=low * New upstream release. - fixed bug where the user menu wouldn't open in unity (LP: #812728) -- cgit v1.2.3 From 6dce39846999951353c2e866019a79d568c99dfa Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 25 Jul 2011 18:42:24 +0100 Subject: the beginnings of the udev work --- configure.ac | 2 ++ src/device-menu-mgr.c | 8 +++--- src/udev-mgr.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++---- src/udev-mgr.h | 14 ++++++++--- 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 369f12b..e32ac4a 100644 --- a/configure.ac +++ b/configure.ac @@ -58,12 +58,14 @@ AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION dbus-glib-1 + gudev-1.0 gio-unix-2.0 indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(SESSIONSERVICE, dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + gudev-1.0 dbus-glib-1 gio-unix-2.0 indicator-0.4 >= $INDICATOR_REQUIRED_VERSION) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 324b3f1..063045e 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -27,7 +27,7 @@ with this program. If not, see . #include "lock-helper.h" #include "upower-client.h" #include "apt-watcher.h" - +#include "udev-mgr.h" #define UP_ADDRESS "org.freedesktop.UPower" #define UP_OBJECT "/org/freedesktop/UPower" @@ -41,6 +41,7 @@ struct _DeviceMenuMgr DbusmenuMenuitem* root_item; SessionDbus* session_dbus_interface; AptWatcher* apt_watcher; + UdevMgr* udev_mgr; }; static GConfClient *gconf_client = NULL; @@ -214,7 +215,6 @@ machine_sleep_with_context (DeviceMenuMgr* self, gchar* type) screensaver_throttle(type); lock_if_possible (self); - dbus_g_proxy_begin_call(up_main_proxy, type, sleep_response, @@ -681,7 +681,9 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) restart_shutdown_logout_mi->logout_mi = logout_mi; restart_shutdown_logout_mi->shutdown_mi = shutdown_mi; - update_menu_entries(restart_shutdown_logout_mi); + update_menu_entries(restart_shutdown_logout_mi); + // Time to create the udev mgr and hand it the static relevant items. + self->udev_mgr = udev_mgr_new (webcam_menuitem, scanners_menuitem); } diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 6575ca5..b5c1936 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -18,21 +18,63 @@ with this program. If not, see . */ #include "udev-mgr.h" +#include + +static void udevice_mgr_device_list_iterator (gpointer data, + gpointer userdata); +static void udev_mgr_uevent_cb (GUdevClient *client, + gchar *action, + GUdevDevice *device, + gpointer user_data); +struct _UdevMgr +{ + GObject parent_instance; + DbusmenuMenuitem* scanner_item; + DbusmenuMenuitem* webcam_item; + GUdevClient* client; +}; G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); static void -udev_mgr_init (UdevMgr *object) +udev_mgr_init (UdevMgr* self) +{ + self->client = NULL; + const gchar *subsystems[1] = {"usb"}; + self->client = g_udev_client_new (subsystems); + const gchar* usb_subsystem = "usb"; + + GList* devices_available = g_udev_client_query_by_subsystem (self->client, + usb_subsystem); + + if (FALSE){ + g_list_foreach (devices_available, udevice_mgr_device_list_iterator, self); + } + //g_list_free (devices_available); + if (FALSE){ + g_signal_connect (G_OBJECT (self->client), + "u-event", + G_CALLBACK (udev_mgr_uevent_cb), + self); + } +} + +static void +udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) { - /* TODO: Add initialization code here */ + g_return_if_fail (G_UDEV_IS_DEVICE (data)); + GUdevDevice* device = G_UDEV_DEVICE (data); + const gchar* name = g_udev_device_get_name (device); + + g_debug ("UDEV MGR - the name of the device = %s", name); + // for now tidy up here. + g_object_unref (device); } static void udev_mgr_finalize (GObject *object) { - /* TODO: Add deinitalization code here */ - G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object); } @@ -40,7 +82,23 @@ static void udev_mgr_class_init (UdevMgrClass *klass) { GObjectClass* object_class = G_OBJECT_CLASS (klass); - object_class->finalize = udev_mgr_finalize; } +static void udev_mgr_uevent_cb (GUdevClient *client, + gchar *action, + GUdevDevice *device, + gpointer user_data) +{ + g_debug ("just received a UEVENT with an action : %s", action); + g_return_if_fail (UDEV_IS_MGR (user_data)); +} + +UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, + DbusmenuMenuitem* webcam) +{ + UdevMgr* mgr = g_object_new (UDEV_TYPE_MGR, NULL); + mgr->scanner_item = scanner; + mgr->webcam_item = webcam; + return mgr; +} diff --git a/src/udev-mgr.h b/src/udev-mgr.h index 1c5ae73..323364a 100644 --- a/src/udev-mgr.h +++ b/src/udev-mgr.h @@ -21,6 +21,14 @@ with this program. If not, see . #define _UDEV_MGR_H_ #include +#include + +#include +#if GTK_CHECK_VERSION(3, 0, 0) +#include +#else +#include +#endif G_BEGIN_DECLS @@ -39,12 +47,10 @@ struct _UdevMgrClass GObjectClass parent_class; }; -struct _UdevMgr -{ - GObject parent_instance; -}; GType udev_mgr_get_type (void) G_GNUC_CONST; +UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner_item, + DbusmenuMenuitem* webcam_item); G_END_DECLS -- cgit v1.2.3 From bdfda68f33615dd7f24b35f425c44c9ef63a1675 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 26 Jul 2011 12:48:56 +0100 Subject: fixed gudev segfault --- src/udev-mgr.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index b5c1936..e100f16 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -26,6 +26,7 @@ static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer user_data); + struct _UdevMgr { GObject parent_instance; @@ -34,6 +35,8 @@ struct _UdevMgr GUdevClient* client; }; +const char *subsystems[1] = {"usb"}; +const gchar* usb_subsystem = "usb"; G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); @@ -41,37 +44,19 @@ static void udev_mgr_init (UdevMgr* self) { self->client = NULL; - const gchar *subsystems[1] = {"usb"}; self->client = g_udev_client_new (subsystems); - const gchar* usb_subsystem = "usb"; GList* devices_available = g_udev_client_query_by_subsystem (self->client, usb_subsystem); - if (FALSE){ - g_list_foreach (devices_available, udevice_mgr_device_list_iterator, self); - } - //g_list_free (devices_available); - if (FALSE){ + g_list_foreach (devices_available, udevice_mgr_device_list_iterator, self); + g_list_free (devices_available); g_signal_connect (G_OBJECT (self->client), - "u-event", + "uevent", G_CALLBACK (udev_mgr_uevent_cb), self); - } } -static void -udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) -{ - g_return_if_fail (G_UDEV_IS_DEVICE (data)); - GUdevDevice* device = G_UDEV_DEVICE (data); - const gchar* name = g_udev_device_get_name (device); - - g_debug ("UDEV MGR - the name of the device = %s", name); - // for now tidy up here. - g_object_unref (device); -} - static void udev_mgr_finalize (GObject *object) { @@ -85,6 +70,18 @@ udev_mgr_class_init (UdevMgrClass *klass) object_class->finalize = udev_mgr_finalize; } +static void +udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) +{ + g_return_if_fail (G_UDEV_IS_DEVICE (data)); + GUdevDevice* device = G_UDEV_DEVICE (data); + const gchar* name = g_udev_device_get_name (device); + + g_debug ("UDEV MGR - the name of the device = %s", name); + // for now tidy up here. + g_object_unref (device); +} + static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, @@ -94,6 +91,7 @@ static void udev_mgr_uevent_cb (GUdevClient *client, g_return_if_fail (UDEV_IS_MGR (user_data)); } + UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, DbusmenuMenuitem* webcam) { -- cgit v1.2.3 From e3b36473ed5400c60f4f08b8cc88bc4e384f3b32 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 26 Jul 2011 16:38:53 +0100 Subject: research trace for devices in udev --- src/sane_rules.h | 0 src/udev-mgr.c | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/sane_rules.h diff --git a/src/sane_rules.h b/src/sane_rules.h new file mode 100644 index 0000000..e69de29 diff --git a/src/udev-mgr.c b/src/udev-mgr.c index e100f16..4dde1b8 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -20,6 +20,11 @@ with this program. If not, see . #include "udev-mgr.h" #include +#include +#include +#include +#include + static void udevice_mgr_device_list_iterator (gpointer data, gpointer userdata); static void udev_mgr_uevent_cb (GUdevClient *client, @@ -87,8 +92,43 @@ static void udev_mgr_uevent_cb (GUdevClient *client, GUdevDevice *device, gpointer user_data) { - g_debug ("just received a UEVENT with an action : %s", action); g_return_if_fail (UDEV_IS_MGR (user_data)); + + g_debug ("just received a UEVENT with an action : %s", action); + + const gchar* vendor; + const gchar* product; + const gchar* number; + + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + product = g_udev_device_get_property (device, "ID_MODEL_ID"); + number = g_udev_device_get_number (device); + g_debug ("device vendor id %s and product id of %s and number of %s", + g_strdup(vendor), + g_strdup(product), + g_strdup(number)); + + const gchar *const *list; + const gchar *const *iter; + char propstr[500]; + guint32 namelen = 0, i; + + list = g_udev_device_get_property_keys(device); + + for (iter = list; iter && *iter; iter++) { + if (strlen(*iter) > namelen) + namelen = strlen(*iter); + } + namelen++; + + for (iter = list; iter && *iter; iter++) { + strcpy(propstr, *iter); + strcat(propstr, ":"); + for (i = 0; i < namelen - strlen(*iter); i++) + strcat(propstr, " "); + strcat(propstr, g_udev_device_get_property(device, *iter)); + g_debug("%s", propstr); + } } -- cgit v1.2.3 From 8e8a2b83bd5e5f5d293a64bfb5e5a163b80fad0d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 26 Jul 2011 18:23:59 +0100 Subject: pattern established as to how to handle these sane rules --- src/Makefile.am | 3 ++- src/sane-rules.h | 20 ++++++++++++++++++++ src/sane_rules.h | 0 src/udev-mgr.c | 27 +++++++++++++++++++++------ 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/sane-rules.h delete mode 100644 src/sane_rules.h diff --git a/src/Makefile.am b/src/Makefile.am index 83d12bb..36a1d1f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -101,7 +101,8 @@ indicator_session_service_SOURCES = \ apt-transaction.h \ apt-transaction.c \ udev-mgr.h \ - udev-mgr.c + udev-mgr.c \ + sane-rules.h indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ diff --git a/src/sane-rules.h b/src/sane-rules.h new file mode 100644 index 0000000..fc43e39 --- /dev/null +++ b/src/sane-rules.h @@ -0,0 +1,20 @@ + + +void populate_usb_scanners (GHashTable* scanners) +{ + GList* epson = NULL; + + epson = g_list_append (epson, g_strdup("0101")); + epson = g_list_append (epson, g_strdup("0103")); + epson = g_list_append (epson, g_strdup("0104")); + epson = g_list_append (epson, g_strdup("0105")); + epson = g_list_append (epson, g_strdup("0106")); + epson = g_list_append (epson, g_strdup("0107")); + epson = g_list_append (epson, g_strdup("0109")); + epson = g_list_append (epson, g_strdup("010a")); + epson = g_list_append (epson, g_strdup("010b")); + + g_hash_table_insert (scanners, + g_strdup("04b8"), + g_list_copy(epson)); +} diff --git a/src/sane_rules.h b/src/sane_rules.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 4dde1b8..31ccb63 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -17,27 +17,29 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "udev-mgr.h" #include - +// TEMP #include #include #include #include +#include "udev-mgr.h" +#include "sane-rules.h" + static void udevice_mgr_device_list_iterator (gpointer data, gpointer userdata); static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, - gpointer user_data); - + gpointer user_data); struct _UdevMgr { GObject parent_instance; DbusmenuMenuitem* scanner_item; DbusmenuMenuitem* webcam_item; GUdevClient* client; + GHashTable* supported_scanners; }; const char *subsystems[1] = {"usb"}; @@ -45,12 +47,24 @@ const gchar* usb_subsystem = "usb"; G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); +static void +test_usb_scanners(gpointer data, gpointer user_data) +{ + gchar* model = (gchar*)data; + g_debug ("in hash table for epsom model %s was found", model); +} + static void udev_mgr_init (UdevMgr* self) { self->client = NULL; - self->client = g_udev_client_new (subsystems); - + self->supported_scanners = NULL; + + self->client = g_udev_client_new (subsystems); + self->supported_scanners = g_hash_table_new (g_str_hash, g_str_equal); + populate_usb_scanners(self->supported_scanners); + GList* epsom = g_hash_table_lookup(self->supported_scanners, "04b8"); + g_list_foreach(epsom, test_usb_scanners, NULL); GList* devices_available = g_udev_client_query_by_subsystem (self->client, usb_subsystem); @@ -62,6 +76,7 @@ udev_mgr_init (UdevMgr* self) self); } + static void udev_mgr_finalize (GObject *object) { -- cgit v1.2.3 From b806cc0e1da3010055c196de59eff15ced2a51b5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 27 Jul 2011 12:50:24 +0100 Subject: udev scanner detection working at startup --- src/sane-rules.h | 3 ++- src/udev-mgr.c | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index fc43e39..356acc6 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -3,7 +3,8 @@ void populate_usb_scanners (GHashTable* scanners) { GList* epson = NULL; - + // For testing + epson = g_list_append (epson, g_strdup("0001")); epson = g_list_append (epson, g_strdup("0101")); epson = g_list_append (epson, g_strdup("0103")); epson = g_list_append (epson, g_strdup("0104")); diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 31ccb63..8a5f539 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -18,6 +18,7 @@ with this program. If not, see . */ #include + // TEMP #include #include @@ -32,7 +33,10 @@ static void udevice_mgr_device_list_iterator (gpointer data, static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, - gpointer user_data); + gpointer user_data); +/*static gboolean udev_mgr_compare_models (gconstpointer data1, + gconstpointer data2); +*/ struct _UdevMgr { GObject parent_instance; @@ -47,12 +51,12 @@ const gchar* usb_subsystem = "usb"; G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); -static void +/*static void test_usb_scanners(gpointer data, gpointer user_data) { gchar* model = (gchar*)data; g_debug ("in hash table for epsom model %s was found", model); -} +}*/ static void udev_mgr_init (UdevMgr* self) @@ -63,8 +67,6 @@ udev_mgr_init (UdevMgr* self) self->client = g_udev_client_new (subsystems); self->supported_scanners = g_hash_table_new (g_str_hash, g_str_equal); populate_usb_scanners(self->supported_scanners); - GList* epsom = g_hash_table_lookup(self->supported_scanners, "04b8"); - g_list_foreach(epsom, test_usb_scanners, NULL); GList* devices_available = g_udev_client_query_by_subsystem (self->client, usb_subsystem); @@ -94,11 +96,40 @@ static void udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) { g_return_if_fail (G_UDEV_IS_DEVICE (data)); + g_return_if_fail (UDEV_IS_MGR (userdata)); + + UdevMgr* self = UDEV_MGR (userdata); + GUdevDevice* device = G_UDEV_DEVICE (data); + const gchar* name = g_udev_device_get_name (device); - g_debug ("UDEV MGR - the name of the device = %s", name); - // for now tidy up here. + const gchar* vendor = NULL; + const gchar* product = NULL; + GList* vendor_list = NULL; + + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + + if (vendor == NULL){ + g_object_unref (device); + return; + } + + product = g_udev_device_get_property (device, "ID_MODEL_ID"); + vendor_list = g_hash_table_lookup(self->supported_scanners, (gpointer)vendor); + + GList* model = NULL; + + if (vendor_list != NULL){ + model = g_list_find_custom(vendor_list, product, (GCompareFunc)g_strcmp0); + if (model == NULL){ + g_debug ("CANT FIND THE MODEL %s FOR VENDOR %s", product, vendor); + } + else{ + dbusmenu_menuitem + g_debug ("WE HAVE A SUCCESSFUL MATCH!"); + } + } g_object_unref (device); } @@ -118,6 +149,7 @@ static void udev_mgr_uevent_cb (GUdevClient *client, vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); product = g_udev_device_get_property (device, "ID_MODEL_ID"); number = g_udev_device_get_number (device); + g_debug ("device vendor id %s and product id of %s and number of %s", g_strdup(vendor), g_strdup(product), @@ -146,6 +178,12 @@ static void udev_mgr_uevent_cb (GUdevClient *client, } } +/*static gboolean +udev_mgr_compare_models (gconstpointer data1, + gconstpointer data2) +{ + return FALSE; +}*/ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, DbusmenuMenuitem* webcam) -- cgit v1.2.3 From b4fd0a59df355527593522e66120a12778af11b2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 27 Jul 2011 16:15:36 +0100 Subject: refactor with a more generic utility function --- src/device-menu-mgr.c | 3 +-- src/udev-mgr.c | 50 +++++++++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 063045e..2c559ee 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -555,7 +555,6 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position (self->root_item, scanners_menuitem, 8); - //tmp dbusmenu_menuitem_property_set_bool (scanners_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); @@ -683,7 +682,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) update_menu_entries(restart_shutdown_logout_mi); // Time to create the udev mgr and hand it the static relevant items. - self->udev_mgr = udev_mgr_new (webcam_menuitem, scanners_menuitem); + self->udev_mgr = udev_mgr_new (scanners_menuitem, webcam_menuitem); } diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 8a5f539..80e49dd 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -34,9 +34,8 @@ static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer user_data); -/*static gboolean udev_mgr_compare_models (gconstpointer data1, - gconstpointer data2); -*/ +static void udev_mgr_update_menuitems (UdevMgr* self); + struct _UdevMgr { GObject parent_instance; @@ -44,6 +43,7 @@ struct _UdevMgr DbusmenuMenuitem* webcam_item; GUdevClient* client; GHashTable* supported_scanners; + gint scanners_present; }; const char *subsystems[1] = {"usb"}; @@ -63,15 +63,11 @@ udev_mgr_init (UdevMgr* self) { self->client = NULL; self->supported_scanners = NULL; - + self->scanners_present = 0; + self->client = g_udev_client_new (subsystems); self->supported_scanners = g_hash_table_new (g_str_hash, g_str_equal); populate_usb_scanners(self->supported_scanners); - GList* devices_available = g_udev_client_query_by_subsystem (self->client, - usb_subsystem); - - g_list_foreach (devices_available, udevice_mgr_device_list_iterator, self); - g_list_free (devices_available); g_signal_connect (G_OBJECT (self->client), "uevent", G_CALLBACK (udev_mgr_uevent_cb), @@ -101,9 +97,7 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) UdevMgr* self = UDEV_MGR (userdata); GUdevDevice* device = G_UDEV_DEVICE (data); - - const gchar* name = g_udev_device_get_name (device); - + const gchar* vendor = NULL; const gchar* product = NULL; GList* vendor_list = NULL; @@ -126,13 +120,22 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) g_debug ("CANT FIND THE MODEL %s FOR VENDOR %s", product, vendor); } else{ - dbusmenu_menuitem + self->scanners_present += 1; g_debug ("WE HAVE A SUCCESSFUL MATCH!"); - } + } } + g_debug ("JUST SET SCANNERS TO TRUE"); g_object_unref (device); } + +static void udev_mgr_update_menuitems (UdevMgr* self) +{ + dbusmenu_menuitem_property_set_bool (self->scanner_item, + DBUSMENU_MENUITEM_PROP_VISIBLE, + self->scanners_present > 0); +} + static void udev_mgr_uevent_cb (GUdevClient *client, gchar *action, GUdevDevice *device, @@ -178,12 +181,12 @@ static void udev_mgr_uevent_cb (GUdevClient *client, } } -/*static gboolean -udev_mgr_compare_models (gconstpointer data1, - gconstpointer data2) +static gboolean +udev_mgr_is_this_a_supported_scanner (UdevMgr* self, + GUdevDevice *device) { - return FALSE; -}*/ + +} UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, DbusmenuMenuitem* webcam) @@ -191,5 +194,14 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, UdevMgr* mgr = g_object_new (UDEV_TYPE_MGR, NULL); mgr->scanner_item = scanner; mgr->webcam_item = webcam; + + GList* devices_available = g_udev_client_query_by_subsystem (mgr->client, + usb_subsystem); + + g_list_foreach (devices_available, + udevice_mgr_device_list_iterator, + mgr); + g_list_free (devices_available); + udev_mgr_update_menuitems (mgr); return mgr; } -- cgit v1.2.3 From 764a81d40737fdb3acb76103c7c895b77e18d300 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 27 Jul 2011 17:23:28 +0100 Subject: convenience method added to handle the insertion and startup detection of scanners --- src/udev-mgr.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++----------- src/udev-mgr.h | 5 ++++ 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 80e49dd..f4b357d 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -35,7 +35,10 @@ static void udev_mgr_uevent_cb (GUdevClient *client, GUdevDevice *device, gpointer user_data); static void udev_mgr_update_menuitems (UdevMgr* self); - +static void udev_mgr_check_if_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action); + struct _UdevMgr { GObject parent_instance; @@ -43,10 +46,10 @@ struct _UdevMgr DbusmenuMenuitem* webcam_item; GUdevClient* client; GHashTable* supported_scanners; - gint scanners_present; + GHashTable* scanners_present; }; -const char *subsystems[1] = {"usb"}; +const char *subsystems[2] = {"usb", "scsi"}; const gchar* usb_subsystem = "usb"; G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); @@ -63,21 +66,23 @@ udev_mgr_init (UdevMgr* self) { self->client = NULL; self->supported_scanners = NULL; - self->scanners_present = 0; - + self->scanners_present = NULL; + self->client = g_udev_client_new (subsystems); self->supported_scanners = g_hash_table_new (g_str_hash, g_str_equal); + self->scanners_present = g_hash_table_new (g_str_hash, g_str_equal); + populate_usb_scanners(self->supported_scanners); g_signal_connect (G_OBJECT (self->client), "uevent", G_CALLBACK (udev_mgr_uevent_cb), self); } - static void udev_mgr_finalize (GObject *object) { + // TODO tidy up hashtables. G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object); } @@ -97,8 +102,9 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) UdevMgr* self = UDEV_MGR (userdata); GUdevDevice* device = G_UDEV_DEVICE (data); - - const gchar* vendor = NULL; + udev_mgr_check_if_device_is_supported (self, device, ADD); + + /*const gchar* vendor = NULL; const gchar* product = NULL; GList* vendor_list = NULL; @@ -124,7 +130,7 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) g_debug ("WE HAVE A SUCCESSFUL MATCH!"); } } - g_debug ("JUST SET SCANNERS TO TRUE"); + g_debug ("JUST SET SCANNERS TO TRUE");*/ g_object_unref (device); } @@ -133,7 +139,7 @@ static void udev_mgr_update_menuitems (UdevMgr* self) { dbusmenu_menuitem_property_set_bool (self->scanner_item, DBUSMENU_MENUITEM_PROP_VISIBLE, - self->scanners_present > 0); + g_hash_table_size (self->scanners_present) > 0); } static void udev_mgr_uevent_cb (GUdevClient *client, @@ -142,9 +148,15 @@ static void udev_mgr_uevent_cb (GUdevClient *client, gpointer user_data) { g_return_if_fail (UDEV_IS_MGR (user_data)); - + UdevMgr* self = UDEV_MGR (user_data); g_debug ("just received a UEVENT with an action : %s", action); + + UdevMgrDeviceAction udev_mgr_action = ADD; + if (g_strcmp0 (action, "remove") == 0){ + udev_mgr_action = REMOVE; + } + udev_mgr_check_if_device_is_supported (self, device, udev_mgr_action); const gchar* vendor; const gchar* product; const gchar* number; @@ -178,14 +190,53 @@ static void udev_mgr_uevent_cb (GUdevClient *client, strcat(propstr, " "); strcat(propstr, g_udev_device_get_property(device, *iter)); g_debug("%s", propstr); - } + } } -static gboolean -udev_mgr_is_this_a_supported_scanner (UdevMgr* self, - GUdevDevice *device) +static void +udev_mgr_check_if_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action) { + const gchar* vendor = NULL; + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + if (vendor == NULL) + return; + + GList* vendor_list = NULL; + vendor_list = g_hash_table_lookup (self->supported_scanners, + (gpointer)vendor); + if (vendor_list == NULL) + return; + + const gchar* model_id = NULL; + model_id = g_udev_device_get_property (device, "ID_MODEL_ID"); + + if (model_id == NULL) + return; + + GList* model_entry = NULL; + model_entry = g_list_find_custom(vendor_list, model_id, (GCompareFunc)g_strcmp0); + + if (model_entry != NULL){ + if (action == REMOVE){ + // TODO handle the case where its removed + // remove it if present from the hash and call update_menuitems + } + else{ + g_hash_table_insert (self->scanners_present, + g_strdup(vendor), + g_strdup(model_id)); + } + } + // DEBUG purposes. + if (model_entry == NULL){ + g_debug ("CANT FIND THE MODEL %s FOR VENDOR %s", model_id, vendor); + } + else{ + g_debug ("WE HAVE A SUCCESSFUL MATCH!"); + } } UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, diff --git a/src/udev-mgr.h b/src/udev-mgr.h index 323364a..5119803 100644 --- a/src/udev-mgr.h +++ b/src/udev-mgr.h @@ -52,6 +52,11 @@ GType udev_mgr_get_type (void) G_GNUC_CONST; UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner_item, DbusmenuMenuitem* webcam_item); +typedef enum { + ADD, + REMOVE +}UdevMgrDeviceAction; + G_END_DECLS #endif /* _UDEV_MGR_H_ */ -- cgit v1.2.3 From ab746cb4fde79721ddf85761a6496555206fd89b Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 28 Jul 2011 12:41:59 -0400 Subject: update interface with LightDM --- src/display-manager.xml | 9 ++++++--- src/users-service-dbus.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/display-manager.xml b/src/display-manager.xml index 004eca1..92f5e05 100644 --- a/src/display-manager.xml +++ b/src/display-manager.xml @@ -1,17 +1,20 @@ - + - + + - + + + diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 087378c..83edaa3 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -195,15 +195,50 @@ static void create_display_manager_proxy (UsersServiceDbus *self) { UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + DBusGProxy *dm_proxy = NULL; + GError *error = NULL; + const gchar *cookie = NULL; + gchar *seat = NULL; + + cookie = g_getenv ("XDG_SESSION_COOKIE"); + if (cookie == NULL || cookie[0] == 0) + { + g_warning ("Failed to get DisplayManager proxy: XDG_SESSION_COOKIE undefined."); + return; + } + + dm_proxy = dbus_g_proxy_new_for_name (priv->system_bus, + "org.freedesktop.DisplayManager", + "/org/freedesktop/DisplayManager", + "org.freedesktop.DisplayManager"); + + if (!dm_proxy) + { + g_warning ("Failed to get DisplayManager proxy."); + return; + } + + /* Now request the proper seat */ + if (!dbus_g_proxy_call (dm_proxy, "GetSeatForCookie", &error, + G_TYPE_STRING, cookie, G_TYPE_INVALID, + DBUS_TYPE_G_OBJECT_PATH, &seat, G_TYPE_INVALID)) + { + g_warning ("Failed to get DisplayManager seat proxy: %s", error->message); + g_object_unref (dm_proxy); + g_error_free (error); + return; + } + g_object_unref (dm_proxy); priv->display_manager_proxy = dbus_g_proxy_new_for_name (priv->system_bus, "org.freedesktop.DisplayManager", - "/org/freedesktop/DisplayManager", - "org.freedesktop.DisplayManager"); + seat, + "org.freedesktop.DisplayManager.Seat"); + g_free (seat); if (!priv->display_manager_proxy) { - g_warning ("Failed to get DisplayManager proxy."); + g_warning ("Failed to get DisplayManager seat proxy."); return; } } @@ -780,7 +815,7 @@ users_service_dbus_show_greeter (UsersServiceDbus *self) { g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - return org_freedesktop_DisplayManager_show_greeter(priv->display_manager_proxy, NULL); + return org_freedesktop_DisplayManager_Seat_switch_to_greeter(priv->display_manager_proxy, NULL); } /* Activates the guest account if it can. */ @@ -789,7 +824,7 @@ users_service_dbus_activate_guest_session (UsersServiceDbus *self) { g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - return org_freedesktop_DisplayManager_switch_to_guest(priv->display_manager_proxy, NULL); + return org_freedesktop_DisplayManager_Seat_switch_to_guest(priv->display_manager_proxy, "", NULL); } /* Activates a specific user */ @@ -799,7 +834,7 @@ users_service_dbus_activate_user_session (UsersServiceDbus *self, { g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE); UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); - return org_freedesktop_DisplayManager_switch_to_user(priv->display_manager_proxy, user->user_name, NULL); + return org_freedesktop_DisplayManager_Seat_switch_to_user(priv->display_manager_proxy, user->user_name, "", NULL); } gboolean -- cgit v1.2.3 From 435c58bec6f9af0779bb47312cc9cd6bc5e67846 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 29 Jul 2011 19:54:51 +0100 Subject: half way through those usb scanner udev rules --- src/sane-rules.h | 1077 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1074 insertions(+), 3 deletions(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index 356acc6..92c7ad7 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -1,10 +1,1081 @@ - void populate_usb_scanners (GHashTable* scanners) { GList* epson = NULL; - // For testing - epson = g_list_append (epson, g_strdup("0001")); + GList* hp = NULL; + + hp = g_list_append (hp, g_strdup ("0101")); + hp = g_list_append (hp, g_strdup ("0105")); + hp = g_list_append (hp, g_strdup ("0201")); + hp = g_list_append (hp, g_strdup ("0205")); + hp = g_list_append (hp, g_strdup ("0305")); + hp = g_list_append (hp, g_strdup ("0401")); + hp = g_list_append (hp, g_strdup ("0405")); + hp = g_list_append (hp, g_strdup ("0505")); + hp = g_list_append (hp, g_strdup ("0601")); + hp = g_list_append (hp, g_strdup ("0605")); + hp = g_list_append (hp, g_strdup ("0701")); + hp = g_list_append (hp, g_strdup ("0705")); + hp = g_list_append (hp, g_strdup ("0801")); + hp = g_list_append (hp, g_strdup ("0805")); + hp = g_list_append (hp, g_strdup ("0901")); + hp = g_list_append (hp, g_strdup ("0a01")); + hp = g_list_append (hp, g_strdup ("0b01")); + hp = g_list_append (hp, g_strdup ("1005")); + hp = g_list_append (hp, g_strdup ("1105")); + hp = g_list_append (hp, g_strdup ("1205")); + hp = g_list_append (hp, g_strdup ("1305")); + hp = g_list_append (hp, g_strdup ("1405")); + hp = g_list_append (hp, g_strdup ("1705")); + hp = g_list_append (hp, g_strdup ("1805")); + hp = g_list_append (hp, g_strdup ("2005")); + hp = g_list_append (hp, g_strdup ("2205")); + hp = g_list_append (hp, g_strdup ("2305")); + hp = g_list_append (hp, g_strdup ("2405")); + hp = g_list_append (hp, g_strdup ("2605")); + hp = g_list_append (hp, g_strdup ("2805")); + hp = g_list_append (hp, g_strdup ("3805")); + hp = g_list_append (hp, g_strdup ("3905")); + hp = g_list_append (hp, g_strdup ("3B17")); + hp = g_list_append (hp, g_strdup ("4105")); + hp = g_list_append (hp, g_strdup ("4205")); + hp = g_list_append (hp, g_strdup ("4305")); + hp = g_list_append (hp, g_strdup ("4505")); + hp = g_list_append (hp, g_strdup ("4605")); + hp = g_list_append (hp, g_strdup ("5617")); + hp = g_list_append (hp, g_strdup ("5717")); + + g_hash_table_insert (scanners, + g_strdup("03f0"), + g_list_copy(hp)); + + GList* mustek = NULL; + + mustek = g_list_append (mustek, g_strdup ("1000")); + mustek = g_list_append (mustek, g_strdup ("1001")); + + g_hash_table_insert (scanners, + g_strdup("03f0"), + g_list_copy(mustek)); + + GList* kodak = NULL; + + kodak = g_list_append (kodak, g_strdup ("6001")); + kodak = g_list_append (kodak, g_strdup ("6002")); + kodak = g_list_append (kodak, g_strdup ("6003")); + kodak = g_list_append (kodak, g_strdup ("6004")); + kodak = g_list_append (kodak, g_strdup ("6005")); + + g_hash_table_insert (scanners, + g_strdup("040a"), + g_list_copy(kodak)); + + GList* creative = NULL; + + creative = g_list_append (creative, g_strdup ("4007")); + + g_hash_table_insert (scanners, + g_strdup("041e"), + g_list_copy(creative)); + + GList* lexmark = NULL; + + lexmark = g_list_append (lexmark, g_strdup("002d")); + lexmark = g_list_append (lexmark, g_strdup("0060")); + lexmark = g_list_append (lexmark, g_strdup("007c")); + lexmark = g_list_append (lexmark, g_strdup("007d")); + + g_hash_table_insert (scanners, + g_strdup("043d"), + g_list_copy(lexmark)); + + + GList* genius = NULL; + genius = g_list_append (genius, g_strdup("2004")); + genius = g_list_append (genius, g_strdup("2007")); + genius = g_list_append (genius, g_strdup("2008")); + genius = g_list_append (genius, g_strdup("2009")); + genius = g_list_append (genius, g_strdup("2011")); + genius = g_list_append (genius, g_strdup("2013")); + genius = g_list_append (genius, g_strdup("2014")); + genius = g_list_append (genius, g_strdup("2015")); + genius = g_list_append (genius, g_strdup("2016")); + genius = g_list_append (genius, g_strdup("2017")); + genius = g_list_append (genius, g_strdup("201a")); + genius = g_list_append (genius, g_strdup("201b")); + genius = g_list_append (genius, g_strdup("201d")); + genius = g_list_append (genius, g_strdup("201e")); + genius = g_list_append (genius, g_strdup("201f")); + genius = g_list_append (genius, g_strdup("20c1")); + g_hash_table_insert (scanners, + g_strdup("0458"), + g_list_copy(genius)); + + GList* medion = NULL; + medion = g_list_append (medion, g_strdup("0377")); + g_hash_table_insert (scanners, + g_strdup("0461"), + g_list_copy(medion)); + + GList* trust = NULL; + trust = g_list_append (trust, g_strdup("1000")); + trust = g_list_append (trust, g_strdup("1002")); + g_hash_table_insert (scanners, + g_strdup("047b"), + g_list_copy(trust)); + + GList* kyocera = NULL; + kyocera = g_list_append (kyocera, g_strdup("0335")); + g_hash_table_insert (scanners, + g_strdup("0482"), + g_list_copy(kyocera)); + + GList* compaq = NULL; + compaq = g_list_append (compaq, g_strdup("001a")); + g_hash_table_insert (scanners, + g_strdup("049f"), + g_list_copy(compaq)); + GList* benq = NULL; + benq = g_list_append (benq, g_strdup("1a20")); + benq = g_list_append (benq, g_strdup("1a2a")); + benq = g_list_append (benq, g_strdup("2022")); + benq = g_list_append (benq, g_strdup("2040")); + benq = g_list_append (benq, g_strdup("2060")); + benq = g_list_append (benq, g_strdup("207e")); + benq = g_list_append (benq, g_strdup("20b0")); + benq = g_list_append (benq, g_strdup("20be")); + benq = g_list_append (benq, g_strdup("20c0")); + benq = g_list_append (benq, g_strdup("20de")); + benq = g_list_append (benq, g_strdup("20f8")); + benq = g_list_append (benq, g_strdup("20fc")); + benq = g_list_append (benq, g_strdup("20fe")); + benq = g_list_append (benq, g_strdup("2137")); + benq = g_list_append (benq, g_strdup("2211")); + g_hash_table_insert (scanners, + g_strdup("04a5"), + g_list_copy(benq)); + + GList* visioneer = NULL; + visioneer = g_list_append (visioneer, g_strdup("0229")); + visioneer = g_list_append (visioneer, g_strdup("0390")); + visioneer = g_list_append (visioneer, g_strdup("0420")); + visioneer = g_list_append (visioneer, g_strdup("0421")); + visioneer = g_list_append (visioneer, g_strdup("0422")); + visioneer = g_list_append (visioneer, g_strdup("0423")); + visioneer = g_list_append (visioneer, g_strdup("0424")); + visioneer = g_list_append (visioneer, g_strdup("0426")); + visioneer = g_list_append (visioneer, g_strdup("0427")); + visioneer = g_list_append (visioneer, g_strdup("0444")); + visioneer = g_list_append (visioneer, g_strdup("0446")); + visioneer = g_list_append (visioneer, g_strdup("0447")); + visioneer = g_list_append (visioneer, g_strdup("0448")); + visioneer = g_list_append (visioneer, g_strdup("0449")); + visioneer = g_list_append (visioneer, g_strdup("044c")); + visioneer = g_list_append (visioneer, g_strdup("0474")); + visioneer = g_list_append (visioneer, g_strdup("0475")); + visioneer = g_list_append (visioneer, g_strdup("0477")); + visioneer = g_list_append (visioneer, g_strdup("0478")); + visioneer = g_list_append (visioneer, g_strdup("0479")); + visioneer = g_list_append (visioneer, g_strdup("047a")); + visioneer = g_list_append (visioneer, g_strdup("047b")); + visioneer = g_list_append (visioneer, g_strdup("047c")); + visioneer = g_list_append (visioneer, g_strdup("048c")); + visioneer = g_list_append (visioneer, g_strdup("048d")); + visioneer = g_list_append (visioneer, g_strdup("048e")); + visioneer = g_list_append (visioneer, g_strdup("048f")); + visioneer = g_list_append (visioneer, g_strdup("0490")); + visioneer = g_list_append (visioneer, g_strdup("0491")); + visioneer = g_list_append (visioneer, g_strdup("0492")); + visioneer = g_list_append (visioneer, g_strdup("0493")); + visioneer = g_list_append (visioneer, g_strdup("0494")); + visioneer = g_list_append (visioneer, g_strdup("0495")); + visioneer = g_list_append (visioneer, g_strdup("0497")); + visioneer = g_list_append (visioneer, g_strdup("0498")); + visioneer = g_list_append (visioneer, g_strdup("0499")); + visioneer = g_list_append (visioneer, g_strdup("049a")); + visioneer = g_list_append (visioneer, g_strdup("049b")); + visioneer = g_list_append (visioneer, g_strdup("049c")); + visioneer = g_list_append (visioneer, g_strdup("049d")); + visioneer = g_list_append (visioneer, g_strdup("04a7")); + visioneer = g_list_append (visioneer, g_strdup("04ac")); + g_hash_table_insert (scanners, + g_strdup("04a7"), + g_list_copy(visioneer)); + +# Canon DR-2080C +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1601", ENV{libsane_matched}="yes" +# Canon CR-180 | Canon CR-180II +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1602", ENV{libsane_matched}="yes" +# Canon DR-9080C +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1603", ENV{libsane_matched}="yes" +# Canon DR-7080C +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1604", ENV{libsane_matched}="yes" +# Canon DR-5010C +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1606", ENV{libsane_matched}="yes" +# Canon DR-6080 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1607", ENV{libsane_matched}="yes" +# Canon DR-2580C +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1608", ENV{libsane_matched}="yes" +# Canon DR-3080CII +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1609", ENV{libsane_matched}="yes" +# Canon DR-2050C | Canon DR-2050SP +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160a", ENV{libsane_matched}="yes" +# Canon DR-7580 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160b", ENV{libsane_matched}="yes" +# Canon PIXMA MP750 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1706", ENV{libsane_matched}="yes" +# Canon PIXMA MP780 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1707", ENV{libsane_matched}="yes" +# Canon PIXMA MP760 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1708", ENV{libsane_matched}="yes" +# Canon PIXMA MP150 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1709", ENV{libsane_matched}="yes" +# Canon PIXMA MP170 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170a", ENV{libsane_matched}="yes" +# Canon PIXMA MP450 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170b", ENV{libsane_matched}="yes" +# Canon PIXMA MP500 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170c", ENV{libsane_matched}="yes" +# Canon PIXMA MP800 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170d", ENV{libsane_matched}="yes" +# Canon PIXMA MP800R +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170e", ENV{libsane_matched}="yes" +# Canon PIXMA MP530 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1712", ENV{libsane_matched}="yes" +# Canon PIXMA MP830 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1713", ENV{libsane_matched}="yes" +# Canon PIXMA MP160 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1714", ENV{libsane_matched}="yes" +# Canon PIXMA MP180 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1715", ENV{libsane_matched}="yes" +# Canon PIXMA MP460 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1716", ENV{libsane_matched}="yes" +# Canon PIXMA MP510 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1717", ENV{libsane_matched}="yes" +# Canon PIXMA MP600 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1718", ENV{libsane_matched}="yes" +# Canon PIXMA MP600R +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1719", ENV{libsane_matched}="yes" +# Canon PIXMA MP810 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171a", ENV{libsane_matched}="yes" +# Canon PIXMA MP960 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171b", ENV{libsane_matched}="yes" +# Canon PIXMA MX7600 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171c", ENV{libsane_matched}="yes" +# Canon PIXMA MP210 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1721", ENV{libsane_matched}="yes" +# Canon PIXMA MP220 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1722", ENV{libsane_matched}="yes" +# Canon PIXMA MP470 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1723", ENV{libsane_matched}="yes" +# Canon PIXMA MP520 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1724", ENV{libsane_matched}="yes" +# Canon PIXMA MP610 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1725", ENV{libsane_matched}="yes" +# Canon PIXMA MP970 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1726", ENV{libsane_matched}="yes" +# Canon PIXMA MX300 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1727", ENV{libsane_matched}="yes" +# Canon PIXMA MX310 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1728", ENV{libsane_matched}="yes" +# Canon PIXMA MX700 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1729", ENV{libsane_matched}="yes" +# Canon PIXMA MP140 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172b", ENV{libsane_matched}="yes" +# Canon PIXMA MX850 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172c", ENV{libsane_matched}="yes" +# Canon PIXMA MP980 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172d", ENV{libsane_matched}="yes" +# Canon PIXMA MP630 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172e", ENV{libsane_matched}="yes" +# Canon PIXMA MP620 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172f", ENV{libsane_matched}="yes" +# Canon PIXMA MP540 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1730", ENV{libsane_matched}="yes" +# Canon PIXMA MP480 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1731", ENV{libsane_matched}="yes" +# Canon PIXMA MP240 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1732", ENV{libsane_matched}="yes" +# Canon PIXMA MP260 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1733", ENV{libsane_matched}="yes" +# Canon PIXMA MP190 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1734", ENV{libsane_matched}="yes" +# Canon PIXMA MX860 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1735", ENV{libsane_matched}="yes" +# Canon PIXMA MX320 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1736", ENV{libsane_matched}="yes" +# Canon PIXMA MX330 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1737", ENV{libsane_matched}="yes" +# Canon PIXMA MP250 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173a", ENV{libsane_matched}="yes" +# Canon PIXMA MP270 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173b", ENV{libsane_matched}="yes" +# Canon PIXMA MP490 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173c", ENV{libsane_matched}="yes" +# Canon PIXMA MP550 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173d", ENV{libsane_matched}="yes" +# Canon PIXMA MP560 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", ENV{libsane_matched}="yes" +# Canon PIXMA MP640 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173f", ENV{libsane_matched}="yes" +# Canon PIXMA MP990 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1740", ENV{libsane_matched}="yes" +# Canon PIXMA MX340 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1741", ENV{libsane_matched}="yes" +# Canon PIXMA MX350 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1742", ENV{libsane_matched}="yes" +# Canon PIXMA MX870 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1743", ENV{libsane_matched}="yes" +# Canon CanoScan 8800F +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1901", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE 100 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1904", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE 200 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1905", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE 110 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1909", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE 210 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190a", ENV{libsane_matched}="yes" +# Canon CanoScan fb630u | Canon CanoScan fb636u +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2204", ENV{libsane_matched}="yes" +# Canon CanoScan N650U/N656U +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2206", ENV{libsane_matched}="yes" +# Canon CanoScan N1220U +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2207", ENV{libsane_matched}="yes" +# Canon CanoScan D660U +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2208", ENV{libsane_matched}="yes" +# Canon CanoScan N670U/N676U/LiDE20 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220d", ENV{libsane_matched}="yes" +# Canon CanoScan N1240U/LiDE30 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220e", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2213", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE 60 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="221c", ENV{libsane_matched}="yes" +# Canon CanoScan LiDE25 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2220", ENV{libsane_matched}="yes" +# Canon DR-1210C +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2222", ENV{libsane_matched}="yes" +# Canon PIXMA MP730 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="262f", ENV{libsane_matched}="yes" +# Canon PIXMA MP700 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2630", ENV{libsane_matched}="yes" +# Canon PIXMA MP360 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263c", ENV{libsane_matched}="yes" +# Canon PIXMA MP370 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263d", ENV{libsane_matched}="yes" +# Canon PIXMA MP390 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263e", ENV{libsane_matched}="yes" +# Canon PIXMA MP375R +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263f", ENV{libsane_matched}="yes" +# Canon PIXMA MP740 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264c", ENV{libsane_matched}="yes" +# Canon PIXMA MP710 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264d", ENV{libsane_matched}="yes" +# Canon imageCLASS MF5630 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264e", ENV{libsane_matched}="yes" +# Canon laserBase MF5650 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264f", ENV{libsane_matched}="yes" +# Canon imageCLASS MF8170c +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2659", ENV{libsane_matched}="yes" +# Canon imageCLASS MF5730 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265d", ENV{libsane_matched}="yes" +# Canon imageCLASS MF5750 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265e", ENV{libsane_matched}="yes" +# Canon imageCLASS MF5770 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265f", ENV{libsane_matched}="yes" +# Canon imageCLASS MF3110 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2660", ENV{libsane_matched}="yes" +# Canon imageCLASS MF3240 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2684", ENV{libsane_matched}="yes" +# Canon imageCLASS MF6500 series +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2686", ENV{libsane_matched}="yes" +# Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 +# Canon imageCLASS MF4150 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26a3", ENV{libsane_matched}="yes" +# Canon imageCLASS MF4690 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b0", ENV{libsane_matched}="yes" +# Canon imageCLASS MF4010 | Canon imageCLASS MF4018 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b4", ENV{libsane_matched}="yes" +# Canon imageCLASS MF4270 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b5", ENV{libsane_matched}="yes" +# Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ec", ENV{libsane_matched}="yes" +# Canon imageCLASS D480 +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ed", ENV{libsane_matched}="yes" +# Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d +ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ee", ENV{libsane_matched}="yes" +# Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV +ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4000", ENV{libsane_matched}="yes" +# Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED +# Nikon Coolscan V ED +ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4001", ENV{libsane_matched}="yes" +# Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED +ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4002", ENV{libsane_matched}="yes" +# Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0101", ENV{libsane_matched}="yes" +# Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0103", ENV{libsane_matched}="yes" +# Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U +# Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0104", ENV{libsane_matched}="yes" +# Epson Stylus Scan 2000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0105", ENV{libsane_matched}="yes" +# Epson Stylus Scan 2500 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0106", ENV{libsane_matched}="yes" +# Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0107", ENV{libsane_matched}="yes" +# Epson ES-8500 | Epson Expression 1640XL +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0109", ENV{libsane_matched}="yes" +# Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F +# Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010a", ENV{libsane_matched}="yes" +# Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010b", ENV{libsane_matched}="yes" +# Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010c", ENV{libsane_matched}="yes" +# Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010e", ENV{libsane_matched}="yes" +# Epson Perfection 1250 | Epson Perfection 1250Photo +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010f", ENV{libsane_matched}="yes" +# Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF +# Epson Perfection 1650 | Epson Perfection 1650 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0110", ENV{libsane_matched}="yes" +# Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0112", ENV{libsane_matched}="yes" +# Epson Perfection 660 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0114", ENV{libsane_matched}="yes" +# Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011b", ENV{libsane_matched}="yes" +# Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011c", ENV{libsane_matched}="yes" +# Epson Perfection 1260 | Epson Perfection 1260Photo +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011d", ENV{libsane_matched}="yes" +# Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011e", ENV{libsane_matched}="yes" +# Epson Perfection 1670 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011f", ENV{libsane_matched}="yes" +# Epson Perfection 1270 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0120", ENV{libsane_matched}="yes" +# Epson Perfection 2480 | Epson Perfection 2580 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0121", ENV{libsane_matched}="yes" +# Epson Perfection 3490 | Epson Perfection 3590 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0122", ENV{libsane_matched}="yes" +# Epson ES-7000H | Epson GT-15000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0126", ENV{libsane_matched}="yes" +# Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0128", ENV{libsane_matched}="yes" +# Epson ES-10000G | Epson Expression 10000XL +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0129", ENV{libsane_matched}="yes" +# Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012a", ENV{libsane_matched}="yes" +# Epson ES-H300 | Epson GT-2500 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012b", ENV{libsane_matched}="yes" +# Epson V700 | Epson V750 | Epson GT-X900 +# Epson Perfection V700 Photo | Epson Perfection V750 Photo +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012c", ENV{libsane_matched}="yes" +# Epson GT-X970 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0135", ENV{libsane_matched}="yes" +# Epson CX-5200 | Epson CX-5400 | Epson CC-600PX +# Epson Stylus CX5100 | Epson Stylus CX5200 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0801", ENV{libsane_matched}="yes" +# Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 +# Epson Stylus CX3200 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0802", ENV{libsane_matched}="yes" +# Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 +# Epson Stylus CX6400 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0805", ENV{libsane_matched}="yes" +# Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0806", ENV{libsane_matched}="yes" +# Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0807", ENV{libsane_matched}="yes" +# Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0808", ENV{libsane_matched}="yes" +# Epson Stylus CX-1500 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080c", ENV{libsane_matched}="yes" +# Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080d", ENV{libsane_matched}="yes" +# Epson CX-3600 | Epson CX-3650 | Epson PX-A550 +# Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080e", ENV{libsane_matched}="yes" +# Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 +# Epson Stylus Photo RX430 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080f", ENV{libsane_matched}="yes" +# Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0810", ENV{libsane_matched}="yes" +# Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 +# Epson Stylus Photo RX630 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0811", ENV{libsane_matched}="yes" +# Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 +# Epson Stylus CX6600 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0813", ENV{libsane_matched}="yes" +# Epson PM-A700 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0814", ENV{libsane_matched}="yes" +# Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 +# Epson AcuLaser CX11NF | Epson LP-A500 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0815", ENV{libsane_matched}="yes" +# Epson LP-M5500 | Epson LP-M5500F +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0817", ENV{libsane_matched}="yes" +# Epson DX-3850 | Epson CX-3700 | Epson CX-3800 +# Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 +# Epson Stylus DX3800 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0818", ENV{libsane_matched}="yes" +# Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 +# Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0819", ENV{libsane_matched}="yes" +# Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081a", ENV{libsane_matched}="yes" +# Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081c", ENV{libsane_matched}="yes" +# Epson PM-A950 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081d", ENV{libsane_matched}="yes" +# Epson Stylus CX7700 | Epson Stylus CX7800 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081f", ENV{libsane_matched}="yes" +# Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 +# Epson Stylus DX4200 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0820", ENV{libsane_matched}="yes" +# Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 +# Epson Stylus Photo RX590 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0827", ENV{libsane_matched}="yes" +# Epson PM-A970 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0828", ENV{libsane_matched}="yes" +# Epson PM-T990 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0829", ENV{libsane_matched}="yes" +# Epson PM-A920 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082a", ENV{libsane_matched}="yes" +# Epson CX-5000 | Epson DX-5000 | Epson DX-5050 +# Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082b", ENV{libsane_matched}="yes" +# Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 +# Epson Stylus CX6000 | Epson Stylus DX6000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082e", ENV{libsane_matched}="yes" +# Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 +# Epson Stylus DX4000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082f", ENV{libsane_matched}="yes" +# Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0830", ENV{libsane_matched}="yes" +# Epson LP-M5600 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0833", ENV{libsane_matched}="yes" +# Epson LP-M6000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0834", ENV{libsane_matched}="yes" +# Epson AcuLaser CX21 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0835", ENV{libsane_matched}="yes" +# Epson PM-T960 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0836", ENV{libsane_matched}="yes" +# Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 +# Epson Stylus Photo RX690 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0837", ENV{libsane_matched}="yes" +# Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 +# Epson Stylus CX7400 | Epson Stylus DX7400 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0838", ENV{libsane_matched}="yes" +# Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 +# Epson Stylus DX8400 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0839", ENV{libsane_matched}="yes" +# Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax +# Epson Stylus DX9400F +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083a", ENV{libsane_matched}="yes" +# Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 +# Epson Stylus Photo RX595 | Epson Stylus Photo RX610 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083c", ENV{libsane_matched}="yes" +# Epson ME 300 | Epson PX-401A | Epson Stylus NX100 +# Epson Stylus SX100 | Epson Stylus TX100 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0841", ENV{libsane_matched}="yes" +# Epson LP-M5000 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0843", ENV{libsane_matched}="yes" +# Epson Artisan 800 | Epson EP-901A | Epson EP-901F +# Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0844", ENV{libsane_matched}="yes" +# Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W +# Epson Stylus Photo TX700W +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0846", ENV{libsane_matched}="yes" +# Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW +# Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0847", ENV{libsane_matched}="yes" +# Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F +# Epson Stylus NX300 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0848", ENV{libsane_matched}="yes" +# Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 +# Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0849", ENV{libsane_matched}="yes" +# Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 +# Epson Stylus SX405 | Epson Stylus TX400 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084a", ENV{libsane_matched}="yes" +# Epson WorkForce 500 +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084c", ENV{libsane_matched}="yes" +# Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series +# Epson Stylus TX110 Series +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084d", ENV{libsane_matched}="yes" +# Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series +# Epson Stylus TX210 Series +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084f", ENV{libsane_matched}="yes" +# Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0851", ENV{libsane_matched}="yes" +# Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series +# Epson WorkForce 310 Series +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0854", ENV{libsane_matched}="yes" +# Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series +# Epson Stylus TX550W Series +ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0856", ENV{libsane_matched}="yes" +# Fujitsu fi-4010CU +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1029", ENV{libsane_matched}="yes" +# Fujitsu fi-4120C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1041", ENV{libsane_matched}="yes" +# Fujitsu fi-4220C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1042", ENV{libsane_matched}="yes" +# Fujitsu fi-4530C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1078", ENV{libsane_matched}="yes" +# Fujitsu fi-5750C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1095", ENV{libsane_matched}="yes" +# Fujitsu fi-5110EOX/2 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1096", ENV{libsane_matched}="yes" +# Fujitsu fi-5110C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1097", ENV{libsane_matched}="yes" +# Fujitsu fi-5650C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ad", ENV{libsane_matched}="yes" +# Fujitsu fi-4120C2 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ae", ENV{libsane_matched}="yes" +# Fujitsu fi-4220C2 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10af", ENV{libsane_matched}="yes" +# Fujitsu fi-60F +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10c7", ENV{libsane_matched}="yes" +# Fujitsu fi-4340C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10cf", ENV{libsane_matched}="yes" +# Fujitsu fi-5120C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e0", ENV{libsane_matched}="yes" +# Fujitsu fi-5220C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e1", ENV{libsane_matched}="yes" +# Fujitsu fi-5530C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e2", ENV{libsane_matched}="yes" +# Fujitsu fi-5110EOX3 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e6", ENV{libsane_matched}="yes" +# Fujitsu fi-5900C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e7", ENV{libsane_matched}="yes" +# Fujitsu fi-5015C +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ef", ENV{libsane_matched}="yes" +# Fujitsu fi-5110EOXM +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10f2", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S500 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10fe", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S500M +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1135", ENV{libsane_matched}="yes" +# Fujitsu fi-5530C2 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114a", ENV{libsane_matched}="yes" +# Fujitsu fi-6140 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114d", ENV{libsane_matched}="yes" +# Fujitsu fi-6240 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114e", ENV{libsane_matched}="yes" +# Fujitsu fi-6130 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114f", ENV{libsane_matched}="yes" +# Fujitsu fi-6230 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1150", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S510 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1155", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S300 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1156", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S510M +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="116f", ENV{libsane_matched}="yes" +# Fujitsu fi-6770 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1174", ENV{libsane_matched}="yes" +# Fujitsu fi-6770A +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1175", ENV{libsane_matched}="yes" +# Fujitsu fi-6670 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1176", ENV{libsane_matched}="yes" +# Fujitsu fi-6670A +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1177", ENV{libsane_matched}="yes" +# Fujitsu fi-6750S +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1178", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S300M +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="117f", ENV{libsane_matched}="yes" +# Fujitsu fi-6800 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119d", ENV{libsane_matched}="yes" +# Fujitsu fi-6800-CGA +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119e", ENV{libsane_matched}="yes" +# Fujitsu fi-6900 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119f", ENV{libsane_matched}="yes" +# Fujitsu fi-6900-CGA +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11a0", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11a2", ENV{libsane_matched}="yes" +# Fujitsu ScanSnap S1300 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ed", ENV{libsane_matched}="yes" +# Fujitsu fi-6125 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ee", ENV{libsane_matched}="yes" +# Fujitsu fi-6225 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ef", ENV{libsane_matched}="yes" +# Fujitsu fi-6145 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f1", ENV{libsane_matched}="yes" +# Fujitsu fi-6245 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f2", ENV{libsane_matched}="yes" +# Fujitsu fi-6135 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f3", ENV{libsane_matched}="yes" +# Fujitsu fi-6235 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f4", ENV{libsane_matched}="yes" +# Fujitsu fi-6110 +ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11fc", ENV{libsane_matched}="yes" +# Konica e-mini +ATTRS{idVendor}=="04c8", ATTRS{idProduct}=="0722", ENV{libsane_matched}="yes" +# Panasonic KV-S2026C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" +# Panasonic KV-S2046C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1001", ENV{libsane_matched}="yes" +# Panasonic KV-S1025C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1006", ENV{libsane_matched}="yes" +# Panasonic KV-S1020C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1007", ENV{libsane_matched}="yes" +# Panasonic KV-S2048C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1009", ENV{libsane_matched}="yes" +# Panasonic KV-S2028C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100a", ENV{libsane_matched}="yes" +# Panasonic KV-SS080 +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100f", ENV{libsane_matched}="yes" +# Panasonic KV-S1045C +ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1010", ENV{libsane_matched}="yes" +# Samsung SCX-4200 +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341b", ENV{libsane_matched}="yes" +# Samsung SCX4725-FN +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341f", ENV{libsane_matched}="yes" +# Samsung SCX-4500 +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3426", ENV{libsane_matched}="yes" +# Samsung CLX-3170fn | Samsung CLX-3175FW +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342a", ENV{libsane_matched}="yes" +# Samsung SCX-4500W +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", ENV{libsane_matched}="yes" +# Samsung SCX-4824 +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342c", ENV{libsane_matched}="yes" +# Samsung SCX-4300 +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342e", ENV{libsane_matched}="yes" +# Samsung SCX-4600 +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3433", ENV{libsane_matched}="yes" +# Samsung SCX-4623 +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3434", ENV{libsane_matched}="yes" +# Samsung SCX-4825FN +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343c", ENV{libsane_matched}="yes" +# Samsung SCX-4623FW +ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3440", ENV{libsane_matched}="yes" +# Pentax DSmobile 600 +ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="2038", ENV{libsane_matched}="yes" +# Aiptek Aiptek Pencam +ATTRS{idVendor}=="0553", ATTRS{idProduct}=="0202", ENV{libsane_matched}="yes" +# Mustek ScanExpress 1200 CU +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" +# Mustek ScanExpress 600 CU +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" +# Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0006", ENV{libsane_matched}="yes" +# Mustek ScanExpress 1200 CU Plus +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0008", ENV{libsane_matched}="yes" +# Mustek BearPaw 1200 F +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" +# Mustek ScanExpress A3 USB +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0210", ENV{libsane_matched}="yes" +# Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0218", ENV{libsane_matched}="yes" +# Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT +# Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0219", ENV{libsane_matched}="yes" +# Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021a", ENV{libsane_matched}="yes" +# Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021b", ENV{libsane_matched}="yes" +# Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus +# Trust Direct WebScan 19200 +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021c", ENV{libsane_matched}="yes" +# Mustek BearPaw 2400 CU Plus +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021d", ENV{libsane_matched}="yes" +# Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021e", ENV{libsane_matched}="yes" +# Mustek ScanExpress 1248 UB +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021f", ENV{libsane_matched}="yes" +# Mustek BearPaw 2448TA Pro +ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0409", ENV{libsane_matched}="yes" +# Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition +# Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 +# Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 +# Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU +# Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus +# Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4002", ENV{libsane_matched}="yes" +# Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 +# Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4003", ENV{libsane_matched}="yes" +# Artec/Ultima E+ Pro +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4004", ENV{libsane_matched}="yes" +# Memorex MEM 48U +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4005", ENV{libsane_matched}="yes" +# Trust Easy Webscan 19200 +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4006", ENV{libsane_matched}="yes" +# Trust 240H Easy Webscan Gold +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4007", ENV{libsane_matched}="yes" +# UMAX AstraSlim SE +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4009", ENV{libsane_matched}="yes" +# UMAX AstraSlim 1200 SE +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4010", ENV{libsane_matched}="yes" +# Yakumo Scan50 +ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4011", ENV{libsane_matched}="yes" +# Microtek ScanMaker X6USB +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="0099", ENV{libsane_matched}="yes" +# Microtek SlimScan C6 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="009a", ENV{libsane_matched}="yes" +# Microtek ScanMaker V6USL +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00a3", ENV{libsane_matched}="yes" +# Microtek ScanMaker V6UPL +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00b6", ENV{libsane_matched}="yes" +# Microtek ScanMaker 4800 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30cf", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3840 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30d4", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3600 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b3", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3700 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b8", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3600 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ca", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3700 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40cb", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3750 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40dd", ENV{libsane_matched}="yes" +# Microtek ScanMaker 3600 +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ff", ENV{libsane_matched}="yes" +# Microtek ScanMaker V6USL +ATTRS{idVendor}=="05da", ATTRS{idProduct}=="80a3", ENV{libsane_matched}="yes" +# iVina 1200U +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0268", ENV{libsane_matched}="yes" +# Minolta Dimage Scan Dual II +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="026a", ENV{libsane_matched}="yes" +# Avision AV600U +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a13", ENV{libsane_matched}="yes" +# Minolta-QMS SC-110 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a15", ENV{libsane_matched}="yes" +# Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a16", ENV{libsane_matched}="yes" +# Avision AV600U Plus +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a18", ENV{libsane_matched}="yes" +# Avision AV610 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a19", ENV{libsane_matched}="yes" +# Avision AV220 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a23", ENV{libsane_matched}="yes" +# Avision AV210 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a24", ENV{libsane_matched}="yes" +# Avision AV210 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a25", ENV{libsane_matched}="yes" +# Avision AV120 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a27", ENV{libsane_matched}="yes" +# Avision AV220C2 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2a", ENV{libsane_matched}="yes" +# Avision AV220D2 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2b", ENV{libsane_matched}="yes" +# Avision AV220+ +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2c", ENV{libsane_matched}="yes" +# Avision AV220C2-G +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2d", ENV{libsane_matched}="yes" +# Avision AV220C2-B +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2e", ENV{libsane_matched}="yes" +# Avision AV210C2-G +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2f", ENV{libsane_matched}="yes" +# Avision AV122 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a33", ENV{libsane_matched}="yes" +# Avision AV210C2 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3a", ENV{libsane_matched}="yes" +# Avision AV121 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3c", ENV{libsane_matched}="yes" +# Avision AV8300 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a40", ENV{libsane_matched}="yes" +# Avision AM3000 Series +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a41", ENV{libsane_matched}="yes" +# Avision @V5100 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a45", ENV{libsane_matched}="yes" +# Avision AV8050U +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4d", ENV{libsane_matched}="yes" +# Avision AV3200SU +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4e", ENV{libsane_matched}="yes" +# Avision AV3730SU +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4f", ENV{libsane_matched}="yes" +# Avision AV610C2 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a5e", ENV{libsane_matched}="yes" +# Avision IT8300 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a61", ENV{libsane_matched}="yes" +# Avision AV3750SU +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a65", ENV{libsane_matched}="yes" +# Avision AV3850SU +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a66", ENV{libsane_matched}="yes" +# Avision AV8350 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a68", ENV{libsane_matched}="yes" +# Avision FB6080E +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a82", ENV{libsane_matched}="yes" +# Avision FB2080E +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a84", ENV{libsane_matched}="yes" +# Avision AV122 C2 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a93", ENV{libsane_matched}="yes" +# Avision AV220-G +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a94", ENV{libsane_matched}="yes" +# Avision @V2500 +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0aa1", ENV{libsane_matched}="yes" +# Avision AV210D2+ +ATTRS{idVendor}=="0638", ATTRS{idProduct}=="1a35", ENV{libsane_matched}="yes" +# Minolta Elite II +ATTRS{idVendor}=="0686", ATTRS{idProduct}=="4004", ENV{libsane_matched}="yes" +# Minolta Dimage Scan Dual III +ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400d", ENV{libsane_matched}="yes" +# Minolta Dimage Scan Elite 5400 +ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400e", ENV{libsane_matched}="yes" +# AGFA SnapScan 1212U +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" +# AGFA SnapScan 1236u +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" +# Agfa Snapscan Touch +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0100", ENV{libsane_matched}="yes" +# AGFA SnapScan 1212U_2 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2061", ENV{libsane_matched}="yes" +# AGFA SnapScan e40 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208d", ENV{libsane_matched}="yes" +# AGFA SnapScan e50 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208f", ENV{libsane_matched}="yes" +# AGFA SnapScan e20 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2091", ENV{libsane_matched}="yes" +# AGFA SnapScan e10 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2093", ENV{libsane_matched}="yes" +# AGFA SnapScan e25 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2095", ENV{libsane_matched}="yes" +# AGFA SnapScan e26 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2097", ENV{libsane_matched}="yes" +# AGFA SnapScan e52 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20fd", ENV{libsane_matched}="yes" +# AGFA SnapScan e42 +ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20ff", ENV{libsane_matched}="yes" +# UMAX Astra 4900 +ATTRS{idVendor}=="06dc", ATTRS{idProduct}=="0020", ENV{libsane_matched}="yes" +# Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U +# RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" +# Plustek OpticPro U12 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" +# Plustek OpticPro U24 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0011", ENV{libsane_matched}="yes" +# Plustek OpticPro UT12 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0013", ENV{libsane_matched}="yes" +# Plustek OpticPro U24 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0015", ENV{libsane_matched}="yes" +# Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0017", ENV{libsane_matched}="yes" +# Plustek OpticPro 1248U | RevScan 19200i +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0400", ENV{libsane_matched}="yes" +# Plustek OpticPro 1248U +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0401", ENV{libsane_matched}="yes" +# Plustek OpticPro U16B +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0402", ENV{libsane_matched}="yes" +# Plustek OpticPro U16B+ | Plustek OpticPro UT16B +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0403", ENV{libsane_matched}="yes" +# Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040b", ENV{libsane_matched}="yes" +# Plustek OpticPro S24 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040e", ENV{libsane_matched}="yes" +# NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0412", ENV{libsane_matched}="yes" +# Plustek OpticSlim 1200 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0413", ENV{libsane_matched}="yes" +# Plustek OpticSlim 2400 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0422", ENV{libsane_matched}="yes" +# Plustek OpticSlim 2400 plus +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0454", ENV{libsane_matched}="yes" +# Plustek Iriscan Express 2 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="045f", ENV{libsane_matched}="yes" +# NeatReceipts Mobile Scanner +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0462", ENV{libsane_matched}="yes" +# Plustek OpticBook 3600 +ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0900", ENV{libsane_matched}="yes" +# Corex 600c +ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" +# Corex 800c +ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0005", ENV{libsane_matched}="yes" +# Xerox Phaser 6110MFP +ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3d5d", ENV{libsane_matched}="yes" +# Xerox Phaser 3200MFP +ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3da4", ENV{libsane_matched}="yes" +# Xerox WorkCentre 4118 Series +ATTRS{idVendor}=="0924", ATTRS{idProduct}=="420c", ENV{libsane_matched}="yes" +# Xerox WorkCentre 3119 Series +ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4265", ENV{libsane_matched}="yes" +# Xerox WorkCentre 3210 +ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4293", ENV{libsane_matched}="yes" +# Xerox WorkCentre 3220 +ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4294", ENV{libsane_matched}="yes" +# Pentax DSmobile 600 +ATTRS{idVendor}=="0a17", ATTRS{idProduct}=="3210", ENV{libsane_matched}="yes" +# Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) +ATTRS{idVendor}=="0a53", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" +# Syscan TravelScan 460/464 | Ambir Visigo A4 +ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4600", ENV{libsane_matched}="yes" +# Syscan DocketPort 465 +ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4802", ENV{libsane_matched}="yes" +# Syscan DocketPort 665 +ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4803", ENV{libsane_matched}="yes" +# Syscan DocketPort 685/ Ambir DS685 +ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="480c", ENV{libsane_matched}="yes" +# Syscan DocketPort 485 +ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4810", ENV{libsane_matched}="yes" +# Syscan TravelScan 662 +ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="6620", ENV{libsane_matched}="yes" +# Canon CR-55 +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160c", ENV{libsane_matched}="yes" +# Canon DR-1210C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160f", ENV{libsane_matched}="yes" +# Canon DR-4010C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1614", ENV{libsane_matched}="yes" +# Canon DR-2510C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1617", ENV{libsane_matched}="yes" +# Canon DR-X10C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1618", ENV{libsane_matched}="yes" +# Canon CR-25 +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161a", ENV{libsane_matched}="yes" +# Canon DR-2010C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161b", ENV{libsane_matched}="yes" +# Canon DR-3010C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161d", ENV{libsane_matched}="yes" +# Canon DR-7090C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1620", ENV{libsane_matched}="yes" +# Canon DR-9050C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1622", ENV{libsane_matched}="yes" +# Canon DR-7550C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1623", ENV{libsane_matched}="yes" +# Canon DR-6050C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1624", ENV{libsane_matched}="yes" +# Canon DR-6010C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1626", ENV{libsane_matched}="yes" +# Canon CR-190i +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="162b", ENV{libsane_matched}="yes" +# Canon DR-6030C +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1638", ENV{libsane_matched}="yes" +# Canon CR-135i +ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1639", ENV{libsane_matched}="yes" +# Digital Dream l' espion XS +ATTRS{idVendor}=="1183", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" +# KONICA MINOLTA magicolor 1690MF +ATTRS{idVendor}=="132b", ATTRS{idProduct}=="2089", ENV{libsane_matched}="yes" +# UMAX Astra 1220U +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" +# UMAX Astra 1600U | UMAX Astra 2000U +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0030", ENV{libsane_matched}="yes" +# Umax UMAX 3400 +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0050", ENV{libsane_matched}="yes" +# Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes" +# UMAX Astra 4400 | UMAX Astra 4450 +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0070", ENV{libsane_matched}="yes" +# UMAX Astra 2100U +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0130", ENV{libsane_matched}="yes" +# Umax UMAX 5400 +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0160", ENV{libsane_matched}="yes" +# UMAX Astra 2200 (SU) +ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0230", ENV{libsane_matched}="yes" +# DCT DocketPort 487 +ATTRS{idVendor}=="1dcc", ATTRS{idProduct}=="4810", ENV{libsane_matched}="yes" +# Dell A920 +ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5105", ENV{libsane_matched}="yes" +# Dell Dell MFP Laser Printer 1815dn +ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5124", ENV{libsane_matched}="yes" +# Dell 1600n +ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5250", ENV{libsane_matched}="yes" + epson = g_list_append (epson, g_strdup("0101")); epson = g_list_append (epson, g_strdup("0103")); epson = g_list_append (epson, g_strdup("0104")); -- cgit v1.2.3 From 8abccb8353d0fb473956e6967e345eacc4d6c812 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 1 Aug 2011 12:05:19 +0100 Subject: usb scanner rules almost there --- src/sane-rules.h | 919 +++++++++++++++++++------------------------------------ 1 file changed, 318 insertions(+), 601 deletions(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index 92c7ad7..ae361b8 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -1,9 +1,7 @@ void populate_usb_scanners (GHashTable* scanners) { - GList* epson = NULL; GList* hp = NULL; - hp = g_list_append (hp, g_strdup ("0101")); hp = g_list_append (hp, g_strdup ("0105")); hp = g_list_append (hp, g_strdup ("0201")); @@ -201,593 +199,325 @@ void populate_usb_scanners (GHashTable* scanners) g_hash_table_insert (scanners, g_strdup("04a7"), g_list_copy(visioneer)); + GList* canon = NULL; + canon = g_list_append (canon, g_strdup("1601")); + canon = g_list_append (canon, g_strdup("1602")); + canon = g_list_append (canon, g_strdup("1603")); + canon = g_list_append (canon, g_strdup("1604")); + canon = g_list_append (canon, g_strdup("1606")); + canon = g_list_append (canon, g_strdup("1607")); + canon = g_list_append (canon, g_strdup("1608")); + canon = g_list_append (canon, g_strdup("1609")); + canon = g_list_append (canon, g_strdup("160a")); + canon = g_list_append (canon, g_strdup("160b")); + canon = g_list_append (canon, g_strdup("1706")); + canon = g_list_append (canon, g_strdup("1707")); + canon = g_list_append (canon, g_strdup("1708")); + canon = g_list_append (canon, g_strdup("1709")); + canon = g_list_append (canon, g_strdup("170a")); + canon = g_list_append (canon, g_strdup("170b")); + canon = g_list_append (canon, g_strdup("170c")); + canon = g_list_append (canon, g_strdup("170d")); + canon = g_list_append (canon, g_strdup("170e")); + canon = g_list_append (canon, g_strdup("1712")); + canon = g_list_append (canon, g_strdup("1713")); + canon = g_list_append (canon, g_strdup("1714")); + canon = g_list_append (canon, g_strdup("1715")); + canon = g_list_append (canon, g_strdup("1716")); + canon = g_list_append (canon, g_strdup("1717")); + canon = g_list_append (canon, g_strdup("1718")); + canon = g_list_append (canon, g_strdup("1719")); + canon = g_list_append (canon, g_strdup("171a")); + canon = g_list_append (canon, g_strdup("171b")); + canon = g_list_append (canon, g_strdup("171c")); + canon = g_list_append (canon, g_strdup("1721")); + canon = g_list_append (canon, g_strdup("1722")); + canon = g_list_append (canon, g_strdup("1723")); + canon = g_list_append (canon, g_strdup("1724")); + canon = g_list_append (canon, g_strdup("1725")); + canon = g_list_append (canon, g_strdup("1726")); + canon = g_list_append (canon, g_strdup("1727")); + canon = g_list_append (canon, g_strdup("1728")); + canon = g_list_append (canon, g_strdup("1729")); + canon = g_list_append (canon, g_strdup("172b")); + canon = g_list_append (canon, g_strdup("172c")); + canon = g_list_append (canon, g_strdup("172d")); + canon = g_list_append (canon, g_strdup("172e")); + canon = g_list_append (canon, g_strdup("172f")); + canon = g_list_append (canon, g_strdup("1730")); + canon = g_list_append (canon, g_strdup("1731")); + canon = g_list_append (canon, g_strdup("1732")); + canon = g_list_append (canon, g_strdup("1733")); + canon = g_list_append (canon, g_strdup("1734")); + canon = g_list_append (canon, g_strdup("1735")); + canon = g_list_append (canon, g_strdup("1736")); + canon = g_list_append (canon, g_strdup("173a")); + canon = g_list_append (canon, g_strdup("173b")); + canon = g_list_append (canon, g_strdup("173c")); + canon = g_list_append (canon, g_strdup("173d")); + canon = g_list_append (canon, g_strdup("173e")); + canon = g_list_append (canon, g_strdup("173f")); + canon = g_list_append (canon, g_strdup("1740")); + canon = g_list_append (canon, g_strdup("1741")); + canon = g_list_append (canon, g_strdup("1742")); + canon = g_list_append (canon, g_strdup("1901")); + canon = g_list_append (canon, g_strdup("1904")); + canon = g_list_append (canon, g_strdup("1905")); + canon = g_list_append (canon, g_strdup("1909")); + canon = g_list_append (canon, g_strdup("190a")); + canon = g_list_append (canon, g_strdup("2204")); + canon = g_list_append (canon, g_strdup("2206")); + canon = g_list_append (canon, g_strdup("2207")); + canon = g_list_append (canon, g_strdup("2208")); + canon = g_list_append (canon, g_strdup("220d")); + canon = g_list_append (canon, g_strdup("220e")); + canon = g_list_append (canon, g_strdup("2213")); + canon = g_list_append (canon, g_strdup("221c")); + canon = g_list_append (canon, g_strdup("2220")); + canon = g_list_append (canon, g_strdup("2222")); + canon = g_list_append (canon, g_strdup("262f")); + canon = g_list_append (canon, g_strdup("2630")); + canon = g_list_append (canon, g_strdup("263c")); + canon = g_list_append (canon, g_strdup("263d")); + canon = g_list_append (canon, g_strdup("263e")); + canon = g_list_append (canon, g_strdup("263f")); + canon = g_list_append (canon, g_strdup("264c")); + canon = g_list_append (canon, g_strdup("264d")); + canon = g_list_append (canon, g_strdup("264e")); + canon = g_list_append (canon, g_strdup("264f")); + canon = g_list_append (canon, g_strdup("2659")); + canon = g_list_append (canon, g_strdup("265d")); + canon = g_list_append (canon, g_strdup("265e")); + canon = g_list_append (canon, g_strdup("265f")); + canon = g_list_append (canon, g_strdup("2660")); + canon = g_list_append (canon, g_strdup("2684")); + canon = g_list_append (canon, g_strdup("2686")); + canon = g_list_append (canon, g_strdup("26a3")); + canon = g_list_append (canon, g_strdup("26b0")); + canon = g_list_append (canon, g_strdup("26b4")); + canon = g_list_append (canon, g_strdup("26b5")); + canon = g_list_append (canon, g_strdup("26ec")); + canon = g_list_append (canon, g_strdup("26ed")); + canon = g_list_append (canon, g_strdup("26ee")); + g_hash_table_insert (scanners, + g_strdup("04a9"), + g_list_copy(canon)); + + GList* nikon = NULL; + nikon = g_list_append (nikon, g_strdup ("4000")); + nikon = g_list_append (nikon, g_strdup ("4001")); + nikon = g_list_append (nikon, g_strdup ("4002")); + g_hash_table_insert (scanners, + g_strdup("04b0"), + g_list_copy(nikon)); + + GList* epson = NULL; + epson = g_list_append (epson, g_strdup("0101")); + epson = g_list_append (epson, g_strdup("0103")); + epson = g_list_append (epson, g_strdup("0104")); + epson = g_list_append (epson, g_strdup("0105")); + epson = g_list_append (epson, g_strdup("0106")); + epson = g_list_append (epson, g_strdup("0107")); + epson = g_list_append (epson, g_strdup("0109")); + epson = g_list_append (epson, g_strdup("010a")); + epson = g_list_append (epson, g_strdup("010b")); + epson = g_list_append (epson, g_strdup("010c")); + epson = g_list_append (epson, g_strdup("010e")); + epson = g_list_append (epson, g_strdup("010f")); + epson = g_list_append (epson, g_strdup("0110")); + epson = g_list_append (epson, g_strdup("0112")); + epson = g_list_append (epson, g_strdup("0114")); + epson = g_list_append (epson, g_strdup("011b")); + epson = g_list_append (epson, g_strdup("011c")); + epson = g_list_append (epson, g_strdup("011d")); + epson = g_list_append (epson, g_strdup("011e")); + epson = g_list_append (epson, g_strdup("011f")); + epson = g_list_append (epson, g_strdup("0120")); + epson = g_list_append (epson, g_strdup("0121")); + epson = g_list_append (epson, g_strdup("0122")); + epson = g_list_append (epson, g_strdup("0126")); + epson = g_list_append (epson, g_strdup("0128")); + epson = g_list_append (epson, g_strdup("0129")); + epson = g_list_append (epson, g_strdup("012a")); + epson = g_list_append (epson, g_strdup("012b")); + epson = g_list_append (epson, g_strdup("012c")); + epson = g_list_append (epson, g_strdup("0135")); + epson = g_list_append (epson, g_strdup("0801")); + epson = g_list_append (epson, g_strdup("0802")); + epson = g_list_append (epson, g_strdup("0805")); + epson = g_list_append (epson, g_strdup("0806")); + epson = g_list_append (epson, g_strdup("0807")); + epson = g_list_append (epson, g_strdup("0808")); + epson = g_list_append (epson, g_strdup("080c")); + epson = g_list_append (epson, g_strdup("080d")); + epson = g_list_append (epson, g_strdup("080e")); + epson = g_list_append (epson, g_strdup("080f")); + epson = g_list_append (epson, g_strdup("0810")); + epson = g_list_append (epson, g_strdup("0811")); + epson = g_list_append (epson, g_strdup("0813")); + epson = g_list_append (epson, g_strdup("0814")); + epson = g_list_append (epson, g_strdup("0815")); + epson = g_list_append (epson, g_strdup("0817")); + epson = g_list_append (epson, g_strdup("0818")); + epson = g_list_append (epson, g_strdup("0819")); + epson = g_list_append (epson, g_strdup("081a")); + epson = g_list_append (epson, g_strdup("081c")); + epson = g_list_append (epson, g_strdup("081d")); + epson = g_list_append (epson, g_strdup("081f")); + epson = g_list_append (epson, g_strdup("0820")); + epson = g_list_append (epson, g_strdup("0827")); + epson = g_list_append (epson, g_strdup("0828")); + epson = g_list_append (epson, g_strdup("0829")); + epson = g_list_append (epson, g_strdup("082a")); + epson = g_list_append (epson, g_strdup("082b")); + epson = g_list_append (epson, g_strdup("082e")); + epson = g_list_append (epson, g_strdup("082f")); + epson = g_list_append (epson, g_strdup("0830")); + epson = g_list_append (epson, g_strdup("0833")); + epson = g_list_append (epson, g_strdup("0834")); + epson = g_list_append (epson, g_strdup("0835")); + epson = g_list_append (epson, g_strdup("0836")); + epson = g_list_append (epson, g_strdup("0837")); + epson = g_list_append (epson, g_strdup("0838")); + epson = g_list_append (epson, g_strdup("0839")); + epson = g_list_append (epson, g_strdup("083a")); + epson = g_list_append (epson, g_strdup("083c")); + epson = g_list_append (epson, g_strdup("0841")); + epson = g_list_append (epson, g_strdup("0843")); + epson = g_list_append (epson, g_strdup("0844")); + epson = g_list_append (epson, g_strdup("0846")); + epson = g_list_append (epson, g_strdup("0847")); + epson = g_list_append (epson, g_strdup("0848")); + epson = g_list_append (epson, g_strdup("0849")); + epson = g_list_append (epson, g_strdup("084a")); + epson = g_list_append (epson, g_strdup("084c")); + epson = g_list_append (epson, g_strdup("084d")); + epson = g_list_append (epson, g_strdup("084f")); + epson = g_list_append (epson, g_strdup("0851")); + epson = g_list_append (epson, g_strdup("0854")); + epson = g_list_append (epson, g_strdup("0856")); + g_hash_table_insert (scanners, + g_strdup("04b8"), + g_list_copy(epson)); + + GList* fujitsu = NULL; + fujitsu = g_list_append (fujitsu, g_strdup ("1029")); + fujitsu = g_list_append (fujitsu, g_strdup ("1041")); + fujitsu = g_list_append (fujitsu, g_strdup ("1042")); + fujitsu = g_list_append (fujitsu, g_strdup ("1078")); + fujitsu = g_list_append (fujitsu, g_strdup ("1095")); + fujitsu = g_list_append (fujitsu, g_strdup ("1096")); + fujitsu = g_list_append (fujitsu, g_strdup ("1097")); + fujitsu = g_list_append (fujitsu, g_strdup ("10ad")); + fujitsu = g_list_append (fujitsu, g_strdup ("10ae")); + fujitsu = g_list_append (fujitsu, g_strdup ("10af")); + fujitsu = g_list_append (fujitsu, g_strdup ("10c7")); + fujitsu = g_list_append (fujitsu, g_strdup ("10cf")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e0")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e1")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e2")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e6")); + fujitsu = g_list_append (fujitsu, g_strdup ("10e7")); + fujitsu = g_list_append (fujitsu, g_strdup ("10ef")); + fujitsu = g_list_append (fujitsu, g_strdup ("10f2")); + fujitsu = g_list_append (fujitsu, g_strdup ("10fe")); + fujitsu = g_list_append (fujitsu, g_strdup ("1135")); + fujitsu = g_list_append (fujitsu, g_strdup ("114a")); + fujitsu = g_list_append (fujitsu, g_strdup ("114d")); + fujitsu = g_list_append (fujitsu, g_strdup ("114e")); + fujitsu = g_list_append (fujitsu, g_strdup ("114f")); + fujitsu = g_list_append (fujitsu, g_strdup ("1150")); + fujitsu = g_list_append (fujitsu, g_strdup ("1155")); + fujitsu = g_list_append (fujitsu, g_strdup ("1156")); + fujitsu = g_list_append (fujitsu, g_strdup ("116f")); + fujitsu = g_list_append (fujitsu, g_strdup ("1174")); + fujitsu = g_list_append (fujitsu, g_strdup ("1175")); + fujitsu = g_list_append (fujitsu, g_strdup ("1176")); + fujitsu = g_list_append (fujitsu, g_strdup ("1177")); + fujitsu = g_list_append (fujitsu, g_strdup ("1178")); + fujitsu = g_list_append (fujitsu, g_strdup ("117f")); + fujitsu = g_list_append (fujitsu, g_strdup ("119d")); + fujitsu = g_list_append (fujitsu, g_strdup ("119e")); + fujitsu = g_list_append (fujitsu, g_strdup ("119f")); + fujitsu = g_list_append (fujitsu, g_strdup ("11a0")); + fujitsu = g_list_append (fujitsu, g_strdup ("11a2")); + fujitsu = g_list_append (fujitsu, g_strdup ("11ed")); + fujitsu = g_list_append (fujitsu, g_strdup ("11ee")); + fujitsu = g_list_append (fujitsu, g_strdup ("11ef")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f1")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f2")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f3")); + fujitsu = g_list_append (fujitsu, g_strdup ("11f4")); + fujitsu = g_list_append (fujitsu, g_strdup ("11fc")); + g_hash_table_insert (scanners, + g_strdup("04c5"), + g_list_copy(fujitsu)); + GList* konica = NULL; + konica = g_list_append (konica, g_strdup ("0722")); + g_hash_table_insert (scanners, + g_strdup("04c8"), + g_list_copy(konica)); + GList* panasonic = NULL; + panasonic = g_list_append (panasonic, g_strdup ("1000")); + panasonic = g_list_append (panasonic, g_strdup ("1001")); + panasonic = g_list_append (panasonic, g_strdup ("1006")); + panasonic = g_list_append (panasonic, g_strdup ("1007")); + panasonic = g_list_append (panasonic, g_strdup ("1009")); + panasonic = g_list_append (panasonic, g_strdup ("100a")); + panasonic = g_list_append (panasonic, g_strdup ("100f")); + panasonic = g_list_append (panasonic, g_strdup ("1010")); + g_hash_table_insert (scanners, + g_strdup("04da"), + g_list_copy(panasonic)); + + GList* samsung = NULL; + + samsung = g_list_append (samsung, g_strdup ("341b")); + samsung = g_list_append (samsung, g_strdup ("341f")); + samsung = g_list_append (samsung, g_strdup ("3426")); + samsung = g_list_append (samsung, g_strdup ("342a")); + samsung = g_list_append (samsung, g_strdup ("342b")); + samsung = g_list_append (samsung, g_strdup ("342c")); + samsung = g_list_append (samsung, g_strdup ("3433")); + samsung = g_list_append (samsung, g_strdup ("3434")); + samsung = g_list_append (samsung, g_strdup ("343c")); + samsung = g_list_append (samsung, g_strdup ("3434")); + g_hash_table_insert (scanners, + g_strdup("04e8"), + g_list_copy(samsung)); + + GList* pentax; + pentax = g_list_append (pentax, g_strdup ("2038")); + g_hash_table_insert (scanners, + g_strdup("04f9"), + g_list_copy(pentax)); + + GList* apitek; + apitek = g_list_append (apitek, g_strdup ("0202")); + g_hash_table_insert (scanners, + g_strdup("0553"), + g_list_copy(apitek)); + + GList* mustek; + mustek = g_list_append (mustek, g_strdup ("0001")); + mustek = g_list_append (mustek, g_strdup ("0002")); + mustek = g_list_append (mustek, g_strdup ("0006")); + mustek = g_list_append (mustek, g_strdup ("0008")); + mustek = g_list_append (mustek, g_strdup ("0010")); + mustek = g_list_append (mustek, g_strdup ("0210")); + mustek = g_list_append (mustek, g_strdup ("0218")); + mustek = g_list_append (mustek, g_strdup ("0219")); + mustek = g_list_append (mustek, g_strdup ("021a")); + mustek = g_list_append (mustek, g_strdup ("021b")); + mustek = g_list_append (mustek, g_strdup ("021c")); + mustek = g_list_append (mustek, g_strdup ("021d")); + mustek = g_list_append (mustek, g_strdup ("021e")); + mustek = g_list_append (mustek, g_strdup ("021f")); + mustek = g_list_append (mustek, g_strdup ("0409")); + g_hash_table_insert (scanners, + g_strdup("055f"), + g_list_copy(mustek)); -# Canon DR-2080C -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1601", ENV{libsane_matched}="yes" -# Canon CR-180 | Canon CR-180II -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1602", ENV{libsane_matched}="yes" -# Canon DR-9080C -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1603", ENV{libsane_matched}="yes" -# Canon DR-7080C -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1604", ENV{libsane_matched}="yes" -# Canon DR-5010C -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1606", ENV{libsane_matched}="yes" -# Canon DR-6080 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1607", ENV{libsane_matched}="yes" -# Canon DR-2580C -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1608", ENV{libsane_matched}="yes" -# Canon DR-3080CII -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1609", ENV{libsane_matched}="yes" -# Canon DR-2050C | Canon DR-2050SP -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160a", ENV{libsane_matched}="yes" -# Canon DR-7580 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160b", ENV{libsane_matched}="yes" -# Canon PIXMA MP750 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1706", ENV{libsane_matched}="yes" -# Canon PIXMA MP780 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1707", ENV{libsane_matched}="yes" -# Canon PIXMA MP760 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1708", ENV{libsane_matched}="yes" -# Canon PIXMA MP150 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1709", ENV{libsane_matched}="yes" -# Canon PIXMA MP170 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170a", ENV{libsane_matched}="yes" -# Canon PIXMA MP450 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170b", ENV{libsane_matched}="yes" -# Canon PIXMA MP500 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170c", ENV{libsane_matched}="yes" -# Canon PIXMA MP800 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170d", ENV{libsane_matched}="yes" -# Canon PIXMA MP800R -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170e", ENV{libsane_matched}="yes" -# Canon PIXMA MP530 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1712", ENV{libsane_matched}="yes" -# Canon PIXMA MP830 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1713", ENV{libsane_matched}="yes" -# Canon PIXMA MP160 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1714", ENV{libsane_matched}="yes" -# Canon PIXMA MP180 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1715", ENV{libsane_matched}="yes" -# Canon PIXMA MP460 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1716", ENV{libsane_matched}="yes" -# Canon PIXMA MP510 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1717", ENV{libsane_matched}="yes" -# Canon PIXMA MP600 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1718", ENV{libsane_matched}="yes" -# Canon PIXMA MP600R -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1719", ENV{libsane_matched}="yes" -# Canon PIXMA MP810 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171a", ENV{libsane_matched}="yes" -# Canon PIXMA MP960 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171b", ENV{libsane_matched}="yes" -# Canon PIXMA MX7600 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171c", ENV{libsane_matched}="yes" -# Canon PIXMA MP210 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1721", ENV{libsane_matched}="yes" -# Canon PIXMA MP220 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1722", ENV{libsane_matched}="yes" -# Canon PIXMA MP470 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1723", ENV{libsane_matched}="yes" -# Canon PIXMA MP520 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1724", ENV{libsane_matched}="yes" -# Canon PIXMA MP610 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1725", ENV{libsane_matched}="yes" -# Canon PIXMA MP970 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1726", ENV{libsane_matched}="yes" -# Canon PIXMA MX300 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1727", ENV{libsane_matched}="yes" -# Canon PIXMA MX310 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1728", ENV{libsane_matched}="yes" -# Canon PIXMA MX700 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1729", ENV{libsane_matched}="yes" -# Canon PIXMA MP140 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172b", ENV{libsane_matched}="yes" -# Canon PIXMA MX850 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172c", ENV{libsane_matched}="yes" -# Canon PIXMA MP980 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172d", ENV{libsane_matched}="yes" -# Canon PIXMA MP630 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172e", ENV{libsane_matched}="yes" -# Canon PIXMA MP620 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172f", ENV{libsane_matched}="yes" -# Canon PIXMA MP540 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1730", ENV{libsane_matched}="yes" -# Canon PIXMA MP480 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1731", ENV{libsane_matched}="yes" -# Canon PIXMA MP240 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1732", ENV{libsane_matched}="yes" -# Canon PIXMA MP260 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1733", ENV{libsane_matched}="yes" -# Canon PIXMA MP190 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1734", ENV{libsane_matched}="yes" -# Canon PIXMA MX860 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1735", ENV{libsane_matched}="yes" -# Canon PIXMA MX320 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1736", ENV{libsane_matched}="yes" -# Canon PIXMA MX330 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1737", ENV{libsane_matched}="yes" -# Canon PIXMA MP250 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173a", ENV{libsane_matched}="yes" -# Canon PIXMA MP270 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173b", ENV{libsane_matched}="yes" -# Canon PIXMA MP490 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173c", ENV{libsane_matched}="yes" -# Canon PIXMA MP550 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173d", ENV{libsane_matched}="yes" -# Canon PIXMA MP560 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", ENV{libsane_matched}="yes" -# Canon PIXMA MP640 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173f", ENV{libsane_matched}="yes" -# Canon PIXMA MP990 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1740", ENV{libsane_matched}="yes" -# Canon PIXMA MX340 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1741", ENV{libsane_matched}="yes" -# Canon PIXMA MX350 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1742", ENV{libsane_matched}="yes" -# Canon PIXMA MX870 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1743", ENV{libsane_matched}="yes" -# Canon CanoScan 8800F -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1901", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE 100 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1904", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE 200 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1905", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE 110 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1909", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE 210 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190a", ENV{libsane_matched}="yes" -# Canon CanoScan fb630u | Canon CanoScan fb636u -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2204", ENV{libsane_matched}="yes" -# Canon CanoScan N650U/N656U -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2206", ENV{libsane_matched}="yes" -# Canon CanoScan N1220U -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2207", ENV{libsane_matched}="yes" -# Canon CanoScan D660U -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2208", ENV{libsane_matched}="yes" -# Canon CanoScan N670U/N676U/LiDE20 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220d", ENV{libsane_matched}="yes" -# Canon CanoScan N1240U/LiDE30 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220e", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2213", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE 60 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="221c", ENV{libsane_matched}="yes" -# Canon CanoScan LiDE25 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2220", ENV{libsane_matched}="yes" -# Canon DR-1210C -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2222", ENV{libsane_matched}="yes" -# Canon PIXMA MP730 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="262f", ENV{libsane_matched}="yes" -# Canon PIXMA MP700 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2630", ENV{libsane_matched}="yes" -# Canon PIXMA MP360 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263c", ENV{libsane_matched}="yes" -# Canon PIXMA MP370 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263d", ENV{libsane_matched}="yes" -# Canon PIXMA MP390 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263e", ENV{libsane_matched}="yes" -# Canon PIXMA MP375R -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263f", ENV{libsane_matched}="yes" -# Canon PIXMA MP740 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264c", ENV{libsane_matched}="yes" -# Canon PIXMA MP710 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264d", ENV{libsane_matched}="yes" -# Canon imageCLASS MF5630 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264e", ENV{libsane_matched}="yes" -# Canon laserBase MF5650 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264f", ENV{libsane_matched}="yes" -# Canon imageCLASS MF8170c -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2659", ENV{libsane_matched}="yes" -# Canon imageCLASS MF5730 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265d", ENV{libsane_matched}="yes" -# Canon imageCLASS MF5750 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265e", ENV{libsane_matched}="yes" -# Canon imageCLASS MF5770 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265f", ENV{libsane_matched}="yes" -# Canon imageCLASS MF3110 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2660", ENV{libsane_matched}="yes" -# Canon imageCLASS MF3240 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2684", ENV{libsane_matched}="yes" -# Canon imageCLASS MF6500 series -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2686", ENV{libsane_matched}="yes" -# Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 -# Canon imageCLASS MF4150 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26a3", ENV{libsane_matched}="yes" -# Canon imageCLASS MF4690 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b0", ENV{libsane_matched}="yes" -# Canon imageCLASS MF4010 | Canon imageCLASS MF4018 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b4", ENV{libsane_matched}="yes" -# Canon imageCLASS MF4270 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b5", ENV{libsane_matched}="yes" -# Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ec", ENV{libsane_matched}="yes" -# Canon imageCLASS D480 -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ed", ENV{libsane_matched}="yes" -# Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d -ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ee", ENV{libsane_matched}="yes" -# Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV -ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4000", ENV{libsane_matched}="yes" -# Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED -# Nikon Coolscan V ED -ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4001", ENV{libsane_matched}="yes" -# Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED -ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4002", ENV{libsane_matched}="yes" -# Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0101", ENV{libsane_matched}="yes" -# Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0103", ENV{libsane_matched}="yes" -# Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U -# Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0104", ENV{libsane_matched}="yes" -# Epson Stylus Scan 2000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0105", ENV{libsane_matched}="yes" -# Epson Stylus Scan 2500 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0106", ENV{libsane_matched}="yes" -# Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0107", ENV{libsane_matched}="yes" -# Epson ES-8500 | Epson Expression 1640XL -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0109", ENV{libsane_matched}="yes" -# Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F -# Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010a", ENV{libsane_matched}="yes" -# Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010b", ENV{libsane_matched}="yes" -# Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010c", ENV{libsane_matched}="yes" -# Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010e", ENV{libsane_matched}="yes" -# Epson Perfection 1250 | Epson Perfection 1250Photo -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010f", ENV{libsane_matched}="yes" -# Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF -# Epson Perfection 1650 | Epson Perfection 1650 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0110", ENV{libsane_matched}="yes" -# Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0112", ENV{libsane_matched}="yes" -# Epson Perfection 660 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0114", ENV{libsane_matched}="yes" -# Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011b", ENV{libsane_matched}="yes" -# Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011c", ENV{libsane_matched}="yes" -# Epson Perfection 1260 | Epson Perfection 1260Photo -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011d", ENV{libsane_matched}="yes" -# Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011e", ENV{libsane_matched}="yes" -# Epson Perfection 1670 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011f", ENV{libsane_matched}="yes" -# Epson Perfection 1270 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0120", ENV{libsane_matched}="yes" -# Epson Perfection 2480 | Epson Perfection 2580 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0121", ENV{libsane_matched}="yes" -# Epson Perfection 3490 | Epson Perfection 3590 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0122", ENV{libsane_matched}="yes" -# Epson ES-7000H | Epson GT-15000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0126", ENV{libsane_matched}="yes" -# Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0128", ENV{libsane_matched}="yes" -# Epson ES-10000G | Epson Expression 10000XL -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0129", ENV{libsane_matched}="yes" -# Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012a", ENV{libsane_matched}="yes" -# Epson ES-H300 | Epson GT-2500 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012b", ENV{libsane_matched}="yes" -# Epson V700 | Epson V750 | Epson GT-X900 -# Epson Perfection V700 Photo | Epson Perfection V750 Photo -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012c", ENV{libsane_matched}="yes" -# Epson GT-X970 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0135", ENV{libsane_matched}="yes" -# Epson CX-5200 | Epson CX-5400 | Epson CC-600PX -# Epson Stylus CX5100 | Epson Stylus CX5200 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0801", ENV{libsane_matched}="yes" -# Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 -# Epson Stylus CX3200 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0802", ENV{libsane_matched}="yes" -# Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 -# Epson Stylus CX6400 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0805", ENV{libsane_matched}="yes" -# Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0806", ENV{libsane_matched}="yes" -# Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0807", ENV{libsane_matched}="yes" -# Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0808", ENV{libsane_matched}="yes" -# Epson Stylus CX-1500 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080c", ENV{libsane_matched}="yes" -# Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080d", ENV{libsane_matched}="yes" -# Epson CX-3600 | Epson CX-3650 | Epson PX-A550 -# Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080e", ENV{libsane_matched}="yes" -# Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 -# Epson Stylus Photo RX430 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080f", ENV{libsane_matched}="yes" -# Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0810", ENV{libsane_matched}="yes" -# Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 -# Epson Stylus Photo RX630 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0811", ENV{libsane_matched}="yes" -# Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 -# Epson Stylus CX6600 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0813", ENV{libsane_matched}="yes" -# Epson PM-A700 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0814", ENV{libsane_matched}="yes" -# Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 -# Epson AcuLaser CX11NF | Epson LP-A500 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0815", ENV{libsane_matched}="yes" -# Epson LP-M5500 | Epson LP-M5500F -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0817", ENV{libsane_matched}="yes" -# Epson DX-3850 | Epson CX-3700 | Epson CX-3800 -# Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 -# Epson Stylus DX3800 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0818", ENV{libsane_matched}="yes" -# Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 -# Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0819", ENV{libsane_matched}="yes" -# Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081a", ENV{libsane_matched}="yes" -# Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081c", ENV{libsane_matched}="yes" -# Epson PM-A950 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081d", ENV{libsane_matched}="yes" -# Epson Stylus CX7700 | Epson Stylus CX7800 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081f", ENV{libsane_matched}="yes" -# Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 -# Epson Stylus DX4200 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0820", ENV{libsane_matched}="yes" -# Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 -# Epson Stylus Photo RX590 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0827", ENV{libsane_matched}="yes" -# Epson PM-A970 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0828", ENV{libsane_matched}="yes" -# Epson PM-T990 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0829", ENV{libsane_matched}="yes" -# Epson PM-A920 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082a", ENV{libsane_matched}="yes" -# Epson CX-5000 | Epson DX-5000 | Epson DX-5050 -# Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082b", ENV{libsane_matched}="yes" -# Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 -# Epson Stylus CX6000 | Epson Stylus DX6000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082e", ENV{libsane_matched}="yes" -# Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 -# Epson Stylus DX4000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082f", ENV{libsane_matched}="yes" -# Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0830", ENV{libsane_matched}="yes" -# Epson LP-M5600 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0833", ENV{libsane_matched}="yes" -# Epson LP-M6000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0834", ENV{libsane_matched}="yes" -# Epson AcuLaser CX21 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0835", ENV{libsane_matched}="yes" -# Epson PM-T960 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0836", ENV{libsane_matched}="yes" -# Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 -# Epson Stylus Photo RX690 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0837", ENV{libsane_matched}="yes" -# Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 -# Epson Stylus CX7400 | Epson Stylus DX7400 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0838", ENV{libsane_matched}="yes" -# Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 -# Epson Stylus DX8400 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0839", ENV{libsane_matched}="yes" -# Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax -# Epson Stylus DX9400F -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083a", ENV{libsane_matched}="yes" -# Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 -# Epson Stylus Photo RX595 | Epson Stylus Photo RX610 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083c", ENV{libsane_matched}="yes" -# Epson ME 300 | Epson PX-401A | Epson Stylus NX100 -# Epson Stylus SX100 | Epson Stylus TX100 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0841", ENV{libsane_matched}="yes" -# Epson LP-M5000 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0843", ENV{libsane_matched}="yes" -# Epson Artisan 800 | Epson EP-901A | Epson EP-901F -# Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0844", ENV{libsane_matched}="yes" -# Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W -# Epson Stylus Photo TX700W -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0846", ENV{libsane_matched}="yes" -# Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW -# Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0847", ENV{libsane_matched}="yes" -# Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F -# Epson Stylus NX300 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0848", ENV{libsane_matched}="yes" -# Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 -# Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0849", ENV{libsane_matched}="yes" -# Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 -# Epson Stylus SX405 | Epson Stylus TX400 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084a", ENV{libsane_matched}="yes" -# Epson WorkForce 500 -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084c", ENV{libsane_matched}="yes" -# Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series -# Epson Stylus TX110 Series -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084d", ENV{libsane_matched}="yes" -# Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series -# Epson Stylus TX210 Series -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084f", ENV{libsane_matched}="yes" -# Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0851", ENV{libsane_matched}="yes" -# Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series -# Epson WorkForce 310 Series -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0854", ENV{libsane_matched}="yes" -# Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series -# Epson Stylus TX550W Series -ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0856", ENV{libsane_matched}="yes" -# Fujitsu fi-4010CU -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1029", ENV{libsane_matched}="yes" -# Fujitsu fi-4120C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1041", ENV{libsane_matched}="yes" -# Fujitsu fi-4220C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1042", ENV{libsane_matched}="yes" -# Fujitsu fi-4530C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1078", ENV{libsane_matched}="yes" -# Fujitsu fi-5750C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1095", ENV{libsane_matched}="yes" -# Fujitsu fi-5110EOX/2 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1096", ENV{libsane_matched}="yes" -# Fujitsu fi-5110C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1097", ENV{libsane_matched}="yes" -# Fujitsu fi-5650C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ad", ENV{libsane_matched}="yes" -# Fujitsu fi-4120C2 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ae", ENV{libsane_matched}="yes" -# Fujitsu fi-4220C2 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10af", ENV{libsane_matched}="yes" -# Fujitsu fi-60F -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10c7", ENV{libsane_matched}="yes" -# Fujitsu fi-4340C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10cf", ENV{libsane_matched}="yes" -# Fujitsu fi-5120C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e0", ENV{libsane_matched}="yes" -# Fujitsu fi-5220C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e1", ENV{libsane_matched}="yes" -# Fujitsu fi-5530C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e2", ENV{libsane_matched}="yes" -# Fujitsu fi-5110EOX3 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e6", ENV{libsane_matched}="yes" -# Fujitsu fi-5900C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e7", ENV{libsane_matched}="yes" -# Fujitsu fi-5015C -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ef", ENV{libsane_matched}="yes" -# Fujitsu fi-5110EOXM -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10f2", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S500 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10fe", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S500M -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1135", ENV{libsane_matched}="yes" -# Fujitsu fi-5530C2 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114a", ENV{libsane_matched}="yes" -# Fujitsu fi-6140 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114d", ENV{libsane_matched}="yes" -# Fujitsu fi-6240 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114e", ENV{libsane_matched}="yes" -# Fujitsu fi-6130 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114f", ENV{libsane_matched}="yes" -# Fujitsu fi-6230 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1150", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S510 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1155", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S300 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1156", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S510M -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="116f", ENV{libsane_matched}="yes" -# Fujitsu fi-6770 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1174", ENV{libsane_matched}="yes" -# Fujitsu fi-6770A -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1175", ENV{libsane_matched}="yes" -# Fujitsu fi-6670 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1176", ENV{libsane_matched}="yes" -# Fujitsu fi-6670A -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1177", ENV{libsane_matched}="yes" -# Fujitsu fi-6750S -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1178", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S300M -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="117f", ENV{libsane_matched}="yes" -# Fujitsu fi-6800 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119d", ENV{libsane_matched}="yes" -# Fujitsu fi-6800-CGA -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119e", ENV{libsane_matched}="yes" -# Fujitsu fi-6900 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119f", ENV{libsane_matched}="yes" -# Fujitsu fi-6900-CGA -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11a0", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11a2", ENV{libsane_matched}="yes" -# Fujitsu ScanSnap S1300 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ed", ENV{libsane_matched}="yes" -# Fujitsu fi-6125 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ee", ENV{libsane_matched}="yes" -# Fujitsu fi-6225 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ef", ENV{libsane_matched}="yes" -# Fujitsu fi-6145 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f1", ENV{libsane_matched}="yes" -# Fujitsu fi-6245 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f2", ENV{libsane_matched}="yes" -# Fujitsu fi-6135 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f3", ENV{libsane_matched}="yes" -# Fujitsu fi-6235 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f4", ENV{libsane_matched}="yes" -# Fujitsu fi-6110 -ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11fc", ENV{libsane_matched}="yes" -# Konica e-mini -ATTRS{idVendor}=="04c8", ATTRS{idProduct}=="0722", ENV{libsane_matched}="yes" -# Panasonic KV-S2026C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" -# Panasonic KV-S2046C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1001", ENV{libsane_matched}="yes" -# Panasonic KV-S1025C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1006", ENV{libsane_matched}="yes" -# Panasonic KV-S1020C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1007", ENV{libsane_matched}="yes" -# Panasonic KV-S2048C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1009", ENV{libsane_matched}="yes" -# Panasonic KV-S2028C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100a", ENV{libsane_matched}="yes" -# Panasonic KV-SS080 -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100f", ENV{libsane_matched}="yes" -# Panasonic KV-S1045C -ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1010", ENV{libsane_matched}="yes" -# Samsung SCX-4200 -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341b", ENV{libsane_matched}="yes" -# Samsung SCX4725-FN -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341f", ENV{libsane_matched}="yes" -# Samsung SCX-4500 -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3426", ENV{libsane_matched}="yes" -# Samsung CLX-3170fn | Samsung CLX-3175FW -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342a", ENV{libsane_matched}="yes" -# Samsung SCX-4500W -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", ENV{libsane_matched}="yes" -# Samsung SCX-4824 -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342c", ENV{libsane_matched}="yes" -# Samsung SCX-4300 -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342e", ENV{libsane_matched}="yes" -# Samsung SCX-4600 -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3433", ENV{libsane_matched}="yes" -# Samsung SCX-4623 -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3434", ENV{libsane_matched}="yes" -# Samsung SCX-4825FN -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343c", ENV{libsane_matched}="yes" -# Samsung SCX-4623FW -ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3440", ENV{libsane_matched}="yes" -# Pentax DSmobile 600 -ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="2038", ENV{libsane_matched}="yes" -# Aiptek Aiptek Pencam -ATTRS{idVendor}=="0553", ATTRS{idProduct}=="0202", ENV{libsane_matched}="yes" -# Mustek ScanExpress 1200 CU -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" -# Mustek ScanExpress 600 CU -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" -# Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0006", ENV{libsane_matched}="yes" -# Mustek ScanExpress 1200 CU Plus -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0008", ENV{libsane_matched}="yes" -# Mustek BearPaw 1200 F -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" -# Mustek ScanExpress A3 USB -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0210", ENV{libsane_matched}="yes" -# Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0218", ENV{libsane_matched}="yes" -# Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT -# Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0219", ENV{libsane_matched}="yes" -# Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021a", ENV{libsane_matched}="yes" -# Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021b", ENV{libsane_matched}="yes" -# Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus -# Trust Direct WebScan 19200 -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021c", ENV{libsane_matched}="yes" -# Mustek BearPaw 2400 CU Plus -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021d", ENV{libsane_matched}="yes" -# Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021e", ENV{libsane_matched}="yes" -# Mustek ScanExpress 1248 UB -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021f", ENV{libsane_matched}="yes" -# Mustek BearPaw 2448TA Pro -ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0409", ENV{libsane_matched}="yes" # Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition # Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 # Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 @@ -1076,17 +806,4 @@ ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5124", ENV{libsane_matched}="yes" # Dell 1600n ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5250", ENV{libsane_matched}="yes" - epson = g_list_append (epson, g_strdup("0101")); - epson = g_list_append (epson, g_strdup("0103")); - epson = g_list_append (epson, g_strdup("0104")); - epson = g_list_append (epson, g_strdup("0105")); - epson = g_list_append (epson, g_strdup("0106")); - epson = g_list_append (epson, g_strdup("0107")); - epson = g_list_append (epson, g_strdup("0109")); - epson = g_list_append (epson, g_strdup("010a")); - epson = g_list_append (epson, g_strdup("010b")); - - g_hash_table_insert (scanners, - g_strdup("04b8"), - g_list_copy(epson)); } -- cgit v1.2.3 From 3469e378ef4d34e5efd10549b499cd35a865c5f4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 1 Aug 2011 15:53:28 +0100 Subject: usb scanners in place --- src/sane-rules.h | 532 ++++++++++++++++++++++++------------------------------- 1 file changed, 234 insertions(+), 298 deletions(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index ae361b8..4c36698 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -47,23 +47,19 @@ void populate_usb_scanners (GHashTable* scanners) g_strdup("03f0"), g_list_copy(hp)); - GList* mustek = NULL; - - mustek = g_list_append (mustek, g_strdup ("1000")); - mustek = g_list_append (mustek, g_strdup ("1001")); - + GList* mustek_2 = NULL; + mustek_2 = g_list_append (mustek_2, g_strdup ("1000")); + mustek_2 = g_list_append (mustek_2, g_strdup ("1001")); g_hash_table_insert (scanners, g_strdup("03f0"), - g_list_copy(mustek)); + g_list_copy(mustek_2)); GList* kodak = NULL; - kodak = g_list_append (kodak, g_strdup ("6001")); kodak = g_list_append (kodak, g_strdup ("6002")); kodak = g_list_append (kodak, g_strdup ("6003")); kodak = g_list_append (kodak, g_strdup ("6004")); kodak = g_list_append (kodak, g_strdup ("6005")); - g_hash_table_insert (scanners, g_strdup("040a"), g_list_copy(kodak)); @@ -486,19 +482,19 @@ void populate_usb_scanners (GHashTable* scanners) g_strdup("04e8"), g_list_copy(samsung)); - GList* pentax; + GList* pentax = NULL; pentax = g_list_append (pentax, g_strdup ("2038")); g_hash_table_insert (scanners, g_strdup("04f9"), g_list_copy(pentax)); - GList* apitek; + GList* apitek = NULL; apitek = g_list_append (apitek, g_strdup ("0202")); g_hash_table_insert (scanners, g_strdup("0553"), g_list_copy(apitek)); - GList* mustek; + GList* mustek = NULL; mustek = g_list_append (mustek, g_strdup ("0001")); mustek = g_list_append (mustek, g_strdup ("0002")); mustek = g_list_append (mustek, g_strdup ("0006")); @@ -517,293 +513,233 @@ void populate_usb_scanners (GHashTable* scanners) g_hash_table_insert (scanners, g_strdup("055f"), g_list_copy(mustek)); + GList* artec = NULL; + artec = g_list_append (artec, g_strdup ("4002")); + artec = g_list_append (artec, g_strdup ("4003")); + artec = g_list_append (artec, g_strdup ("4004")); + artec = g_list_append (artec, g_strdup ("4005")); + artec = g_list_append (artec, g_strdup ("4006")); + artec = g_list_append (artec, g_strdup ("4007")); + artec = g_list_append (artec, g_strdup ("4009")); + artec = g_list_append (artec, g_strdup ("4010")); + artec = g_list_append (artec, g_strdup ("4011")); + g_hash_table_insert (scanners, + g_strdup("05d8"), + g_list_copy(artec)); + + GList* microtek = NULL; + microtek = g_list_append (microtek, g_strdup ("0099")); + microtek = g_list_append (microtek, g_strdup ("009a")); + microtek = g_list_append (microtek, g_strdup ("00a3")); + microtek = g_list_append (microtek, g_strdup ("00b6")); + microtek = g_list_append (microtek, g_strdup ("30cf")); + microtek = g_list_append (microtek, g_strdup ("30d4")); + microtek = g_list_append (microtek, g_strdup ("40b3")); + microtek = g_list_append (microtek, g_strdup ("40b8")); + microtek = g_list_append (microtek, g_strdup ("40ca")); + microtek = g_list_append (microtek, g_strdup ("40cb")); + microtek = g_list_append (microtek, g_strdup ("40dd")); + microtek = g_list_append (microtek, g_strdup ("40ff")); + microtek = g_list_append (microtek, g_strdup ("80a3")); + g_hash_table_insert (scanners, + g_strdup("05da"), + g_list_copy(microtek)); + + GList* avision = NULL; + avision = g_list_append (avision, g_strdup ("0268")); + avision = g_list_append (avision, g_strdup ("026a")); + avision = g_list_append (avision, g_strdup ("0a13")); + avision = g_list_append (avision, g_strdup ("0a15")); + avision = g_list_append (avision, g_strdup ("0a16")); + avision = g_list_append (avision, g_strdup ("0a18")); + avision = g_list_append (avision, g_strdup ("0a19")); + avision = g_list_append (avision, g_strdup ("0a23")); + avision = g_list_append (avision, g_strdup ("0a24")); + avision = g_list_append (avision, g_strdup ("0a25")); + avision = g_list_append (avision, g_strdup ("0a27")); + avision = g_list_append (avision, g_strdup ("0a2a")); + avision = g_list_append (avision, g_strdup ("0a2b")); + avision = g_list_append (avision, g_strdup ("0a2c")); + avision = g_list_append (avision, g_strdup ("0a2d")); + avision = g_list_append (avision, g_strdup ("0a2e")); + avision = g_list_append (avision, g_strdup ("0a2f")); + avision = g_list_append (avision, g_strdup ("0a33")); + avision = g_list_append (avision, g_strdup ("0a3a")); + avision = g_list_append (avision, g_strdup ("0a3c")); + avision = g_list_append (avision, g_strdup ("0a40")); + avision = g_list_append (avision, g_strdup ("0a41")); + avision = g_list_append (avision, g_strdup ("0a45")); + avision = g_list_append (avision, g_strdup ("0a4d")); + avision = g_list_append (avision, g_strdup ("0a4e")); + avision = g_list_append (avision, g_strdup ("0a4f")); + avision = g_list_append (avision, g_strdup ("0a5e")); + avision = g_list_append (avision, g_strdup ("0a61")); + avision = g_list_append (avision, g_strdup ("0a65")); + avision = g_list_append (avision, g_strdup ("0a66")); + avision = g_list_append (avision, g_strdup ("0a68")); + avision = g_list_append (avision, g_strdup ("0a82")); + avision = g_list_append (avision, g_strdup ("0a84")); + avision = g_list_append (avision, g_strdup ("0a93")); + avision = g_list_append (avision, g_strdup ("0a94")); + avision = g_list_append (avision, g_strdup ("0aa1")); + avision = g_list_append (avision, g_strdup ("1a35")); + g_hash_table_insert (scanners, + g_strdup("0638"), + g_list_copy(avision)); + GList* minolta = NULL; + minolta = g_list_append (minolta, g_strdup ("4004")); + minolta = g_list_append (minolta, g_strdup ("400d")); + minolta = g_list_append (minolta, g_strdup ("400e")); + g_hash_table_insert (scanners, + g_strdup("0686"), + g_list_copy(minolta)); + + GList* agfa = NULL; + agfa = g_list_append (agfa, g_strdup ("0001")); + agfa = g_list_append (agfa, g_strdup ("0002")); + agfa = g_list_append (agfa, g_strdup ("0100")); + agfa = g_list_append (agfa, g_strdup ("2061")); + agfa = g_list_append (agfa, g_strdup ("208d")); + agfa = g_list_append (agfa, g_strdup ("208f")); + agfa = g_list_append (agfa, g_strdup ("2091")); + agfa = g_list_append (agfa, g_strdup ("2093")); + agfa = g_list_append (agfa, g_strdup ("2095")); + agfa = g_list_append (agfa, g_strdup ("2097")); + agfa = g_list_append (agfa, g_strdup ("20fd")); + agfa = g_list_append (agfa, g_strdup ("20ff")); + g_hash_table_insert (scanners, + g_strdup("06bd"), + g_list_copy(minolta)); + + GList* umax_2 = NULL; + umax_2 = g_list_append (umax_2, g_strdup ("0020")); + g_hash_table_insert (scanners, + g_strdup("06dc"), + g_list_copy(umax_2)); + + GList* plustek = NULL; + + plustek = g_list_append (plustek, g_strdup ("0001")); + plustek = g_list_append (plustek, g_strdup ("0010")); + plustek = g_list_append (plustek, g_strdup ("0011")); + plustek = g_list_append (plustek, g_strdup ("0013")); + plustek = g_list_append (plustek, g_strdup ("0015")); + plustek = g_list_append (plustek, g_strdup ("0017")); + plustek = g_list_append (plustek, g_strdup ("0400")); + plustek = g_list_append (plustek, g_strdup ("0401")); + plustek = g_list_append (plustek, g_strdup ("0402")); + plustek = g_list_append (plustek, g_strdup ("0403")); + plustek = g_list_append (plustek, g_strdup ("040b")); + plustek = g_list_append (plustek, g_strdup ("040e")); + plustek = g_list_append (plustek, g_strdup ("0412")); + plustek = g_list_append (plustek, g_strdup ("0413")); + plustek = g_list_append (plustek, g_strdup ("0422")); + plustek = g_list_append (plustek, g_strdup ("0454")); + plustek = g_list_append (plustek, g_strdup ("045f")); + plustek = g_list_append (plustek, g_strdup ("0462")); + plustek = g_list_append (plustek, g_strdup ("0900")); + g_hash_table_insert (scanners, + g_strdup("07b3"), + g_list_copy(plustek)); -# Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition -# Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 -# Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 -# Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU -# Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus -# Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4002", ENV{libsane_matched}="yes" -# Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 -# Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4003", ENV{libsane_matched}="yes" -# Artec/Ultima E+ Pro -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4004", ENV{libsane_matched}="yes" -# Memorex MEM 48U -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4005", ENV{libsane_matched}="yes" -# Trust Easy Webscan 19200 -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4006", ENV{libsane_matched}="yes" -# Trust 240H Easy Webscan Gold -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4007", ENV{libsane_matched}="yes" -# UMAX AstraSlim SE -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4009", ENV{libsane_matched}="yes" -# UMAX AstraSlim 1200 SE -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4010", ENV{libsane_matched}="yes" -# Yakumo Scan50 -ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4011", ENV{libsane_matched}="yes" -# Microtek ScanMaker X6USB -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="0099", ENV{libsane_matched}="yes" -# Microtek SlimScan C6 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="009a", ENV{libsane_matched}="yes" -# Microtek ScanMaker V6USL -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00a3", ENV{libsane_matched}="yes" -# Microtek ScanMaker V6UPL -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00b6", ENV{libsane_matched}="yes" -# Microtek ScanMaker 4800 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30cf", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3840 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30d4", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3600 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b3", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3700 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b8", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3600 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ca", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3700 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40cb", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3750 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40dd", ENV{libsane_matched}="yes" -# Microtek ScanMaker 3600 -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ff", ENV{libsane_matched}="yes" -# Microtek ScanMaker V6USL -ATTRS{idVendor}=="05da", ATTRS{idProduct}=="80a3", ENV{libsane_matched}="yes" -# iVina 1200U -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0268", ENV{libsane_matched}="yes" -# Minolta Dimage Scan Dual II -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="026a", ENV{libsane_matched}="yes" -# Avision AV600U -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a13", ENV{libsane_matched}="yes" -# Minolta-QMS SC-110 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a15", ENV{libsane_matched}="yes" -# Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a16", ENV{libsane_matched}="yes" -# Avision AV600U Plus -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a18", ENV{libsane_matched}="yes" -# Avision AV610 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a19", ENV{libsane_matched}="yes" -# Avision AV220 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a23", ENV{libsane_matched}="yes" -# Avision AV210 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a24", ENV{libsane_matched}="yes" -# Avision AV210 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a25", ENV{libsane_matched}="yes" -# Avision AV120 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a27", ENV{libsane_matched}="yes" -# Avision AV220C2 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2a", ENV{libsane_matched}="yes" -# Avision AV220D2 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2b", ENV{libsane_matched}="yes" -# Avision AV220+ -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2c", ENV{libsane_matched}="yes" -# Avision AV220C2-G -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2d", ENV{libsane_matched}="yes" -# Avision AV220C2-B -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2e", ENV{libsane_matched}="yes" -# Avision AV210C2-G -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2f", ENV{libsane_matched}="yes" -# Avision AV122 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a33", ENV{libsane_matched}="yes" -# Avision AV210C2 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3a", ENV{libsane_matched}="yes" -# Avision AV121 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3c", ENV{libsane_matched}="yes" -# Avision AV8300 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a40", ENV{libsane_matched}="yes" -# Avision AM3000 Series -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a41", ENV{libsane_matched}="yes" -# Avision @V5100 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a45", ENV{libsane_matched}="yes" -# Avision AV8050U -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4d", ENV{libsane_matched}="yes" -# Avision AV3200SU -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4e", ENV{libsane_matched}="yes" -# Avision AV3730SU -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4f", ENV{libsane_matched}="yes" -# Avision AV610C2 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a5e", ENV{libsane_matched}="yes" -# Avision IT8300 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a61", ENV{libsane_matched}="yes" -# Avision AV3750SU -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a65", ENV{libsane_matched}="yes" -# Avision AV3850SU -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a66", ENV{libsane_matched}="yes" -# Avision AV8350 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a68", ENV{libsane_matched}="yes" -# Avision FB6080E -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a82", ENV{libsane_matched}="yes" -# Avision FB2080E -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a84", ENV{libsane_matched}="yes" -# Avision AV122 C2 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a93", ENV{libsane_matched}="yes" -# Avision AV220-G -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a94", ENV{libsane_matched}="yes" -# Avision @V2500 -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0aa1", ENV{libsane_matched}="yes" -# Avision AV210D2+ -ATTRS{idVendor}=="0638", ATTRS{idProduct}=="1a35", ENV{libsane_matched}="yes" -# Minolta Elite II -ATTRS{idVendor}=="0686", ATTRS{idProduct}=="4004", ENV{libsane_matched}="yes" -# Minolta Dimage Scan Dual III -ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400d", ENV{libsane_matched}="yes" -# Minolta Dimage Scan Elite 5400 -ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400e", ENV{libsane_matched}="yes" -# AGFA SnapScan 1212U -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" -# AGFA SnapScan 1236u -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" -# Agfa Snapscan Touch -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0100", ENV{libsane_matched}="yes" -# AGFA SnapScan 1212U_2 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2061", ENV{libsane_matched}="yes" -# AGFA SnapScan e40 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208d", ENV{libsane_matched}="yes" -# AGFA SnapScan e50 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208f", ENV{libsane_matched}="yes" -# AGFA SnapScan e20 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2091", ENV{libsane_matched}="yes" -# AGFA SnapScan e10 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2093", ENV{libsane_matched}="yes" -# AGFA SnapScan e25 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2095", ENV{libsane_matched}="yes" -# AGFA SnapScan e26 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2097", ENV{libsane_matched}="yes" -# AGFA SnapScan e52 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20fd", ENV{libsane_matched}="yes" -# AGFA SnapScan e42 -ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20ff", ENV{libsane_matched}="yes" -# UMAX Astra 4900 -ATTRS{idVendor}=="06dc", ATTRS{idProduct}=="0020", ENV{libsane_matched}="yes" -# Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U -# RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" -# Plustek OpticPro U12 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" -# Plustek OpticPro U24 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0011", ENV{libsane_matched}="yes" -# Plustek OpticPro UT12 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0013", ENV{libsane_matched}="yes" -# Plustek OpticPro U24 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0015", ENV{libsane_matched}="yes" -# Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0017", ENV{libsane_matched}="yes" -# Plustek OpticPro 1248U | RevScan 19200i -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0400", ENV{libsane_matched}="yes" -# Plustek OpticPro 1248U -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0401", ENV{libsane_matched}="yes" -# Plustek OpticPro U16B -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0402", ENV{libsane_matched}="yes" -# Plustek OpticPro U16B+ | Plustek OpticPro UT16B -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0403", ENV{libsane_matched}="yes" -# Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040b", ENV{libsane_matched}="yes" -# Plustek OpticPro S24 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040e", ENV{libsane_matched}="yes" -# NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0412", ENV{libsane_matched}="yes" -# Plustek OpticSlim 1200 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0413", ENV{libsane_matched}="yes" -# Plustek OpticSlim 2400 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0422", ENV{libsane_matched}="yes" -# Plustek OpticSlim 2400 plus -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0454", ENV{libsane_matched}="yes" -# Plustek Iriscan Express 2 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="045f", ENV{libsane_matched}="yes" -# NeatReceipts Mobile Scanner -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0462", ENV{libsane_matched}="yes" -# Plustek OpticBook 3600 -ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0900", ENV{libsane_matched}="yes" -# Corex 600c -ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" -# Corex 800c -ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0005", ENV{libsane_matched}="yes" -# Xerox Phaser 6110MFP -ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3d5d", ENV{libsane_matched}="yes" -# Xerox Phaser 3200MFP -ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3da4", ENV{libsane_matched}="yes" -# Xerox WorkCentre 4118 Series -ATTRS{idVendor}=="0924", ATTRS{idProduct}=="420c", ENV{libsane_matched}="yes" -# Xerox WorkCentre 3119 Series -ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4265", ENV{libsane_matched}="yes" -# Xerox WorkCentre 3210 -ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4293", ENV{libsane_matched}="yes" -# Xerox WorkCentre 3220 -ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4294", ENV{libsane_matched}="yes" -# Pentax DSmobile 600 -ATTRS{idVendor}=="0a17", ATTRS{idProduct}=="3210", ENV{libsane_matched}="yes" -# Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) -ATTRS{idVendor}=="0a53", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" -# Syscan TravelScan 460/464 | Ambir Visigo A4 -ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4600", ENV{libsane_matched}="yes" -# Syscan DocketPort 465 -ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4802", ENV{libsane_matched}="yes" -# Syscan DocketPort 665 -ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4803", ENV{libsane_matched}="yes" -# Syscan DocketPort 685/ Ambir DS685 -ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="480c", ENV{libsane_matched}="yes" -# Syscan DocketPort 485 -ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4810", ENV{libsane_matched}="yes" -# Syscan TravelScan 662 -ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="6620", ENV{libsane_matched}="yes" -# Canon CR-55 -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160c", ENV{libsane_matched}="yes" -# Canon DR-1210C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160f", ENV{libsane_matched}="yes" -# Canon DR-4010C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1614", ENV{libsane_matched}="yes" -# Canon DR-2510C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1617", ENV{libsane_matched}="yes" -# Canon DR-X10C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1618", ENV{libsane_matched}="yes" -# Canon CR-25 -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161a", ENV{libsane_matched}="yes" -# Canon DR-2010C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161b", ENV{libsane_matched}="yes" -# Canon DR-3010C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161d", ENV{libsane_matched}="yes" -# Canon DR-7090C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1620", ENV{libsane_matched}="yes" -# Canon DR-9050C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1622", ENV{libsane_matched}="yes" -# Canon DR-7550C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1623", ENV{libsane_matched}="yes" -# Canon DR-6050C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1624", ENV{libsane_matched}="yes" -# Canon DR-6010C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1626", ENV{libsane_matched}="yes" -# Canon CR-190i -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="162b", ENV{libsane_matched}="yes" -# Canon DR-6030C -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1638", ENV{libsane_matched}="yes" -# Canon CR-135i -ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1639", ENV{libsane_matched}="yes" -# Digital Dream l' espion XS -ATTRS{idVendor}=="1183", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" -# KONICA MINOLTA magicolor 1690MF -ATTRS{idVendor}=="132b", ATTRS{idProduct}=="2089", ENV{libsane_matched}="yes" -# UMAX Astra 1220U -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" -# UMAX Astra 1600U | UMAX Astra 2000U -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0030", ENV{libsane_matched}="yes" -# Umax UMAX 3400 -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0050", ENV{libsane_matched}="yes" -# Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes" -# UMAX Astra 4400 | UMAX Astra 4450 -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0070", ENV{libsane_matched}="yes" -# UMAX Astra 2100U -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0130", ENV{libsane_matched}="yes" -# Umax UMAX 5400 -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0160", ENV{libsane_matched}="yes" -# UMAX Astra 2200 (SU) -ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0230", ENV{libsane_matched}="yes" -# DCT DocketPort 487 -ATTRS{idVendor}=="1dcc", ATTRS{idProduct}=="4810", ENV{libsane_matched}="yes" -# Dell A920 -ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5105", ENV{libsane_matched}="yes" -# Dell Dell MFP Laser Printer 1815dn -ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5124", ENV{libsane_matched}="yes" -# Dell 1600n -ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5250", ENV{libsane_matched}="yes" + GList* corex = NULL; + corex = g_list_append (corex, g_strdup ("0002")); + corex = g_list_append (corex, g_strdup ("0005")); + g_hash_table_insert (scanners, + g_strdup("08f0"), + g_list_copy(corex)); + + GList* xerox = NULL; + xerox = g_list_append (xerox, g_strdup ("3d5d")); + xerox = g_list_append (xerox, g_strdup ("3da4")); + xerox = g_list_append (xerox, g_strdup ("420c")); + xerox = g_list_append (xerox, g_strdup ("4265")); + xerox = g_list_append (xerox, g_strdup ("4293")); + xerox = g_list_append (xerox, g_strdup ("4294")); + g_hash_table_insert (scanners, + g_strdup("0924"), + g_list_copy(xerox)); + + GList* pentax_2 = NULL; + pentax_2 = g_list_append (pentax_2, g_strdup ("3210")); + g_hash_table_insert (scanners, + g_strdup("0a17"), + g_list_copy(pentax_2)); + + GList* portable = NULL; + portable = g_list_append (portable, g_strdup ("1000")); + g_hash_table_insert (scanners, + g_strdup("0a53"), + g_list_copy(portable)); + + GList* syscan = NULL; + syscan = g_list_append (syscan, g_strdup ("4600")); + syscan = g_list_append (syscan, g_strdup ("4802")); + syscan = g_list_append (syscan, g_strdup ("4803")); + syscan = g_list_append (syscan, g_strdup ("480c")); + syscan = g_list_append (syscan, g_strdup ("4810")); + syscan = g_list_append (syscan, g_strdup ("6620")); + g_hash_table_insert (scanners, + g_strdup("0a82"), + g_list_copy(syscan)); + + GList* canon_2 = NULL; + canon_2 = g_list_append (canon_2, g_strdup ("160c")); + canon_2 = g_list_append (canon_2, g_strdup ("160f")); + canon_2 = g_list_append (canon_2, g_strdup ("1614")); + canon_2 = g_list_append (canon_2, g_strdup ("1617")); + canon_2 = g_list_append (canon_2, g_strdup ("1618")); + canon_2 = g_list_append (canon_2, g_strdup ("161a")); + canon_2 = g_list_append (canon_2, g_strdup ("161b")); + canon_2 = g_list_append (canon_2, g_strdup ("161d")); + canon_2 = g_list_append (canon_2, g_strdup ("1620")); + canon_2 = g_list_append (canon_2, g_strdup ("1622")); + canon_2 = g_list_append (canon_2, g_strdup ("1623")); + canon_2 = g_list_append (canon_2, g_strdup ("1624")); + canon_2 = g_list_append (canon_2, g_strdup ("1626")); + canon_2 = g_list_append (canon_2, g_strdup ("162b")); + canon_2 = g_list_append (canon_2, g_strdup ("1638")); + canon_2 = g_list_append (canon_2, g_strdup ("1639")); + g_hash_table_insert (scanners, + g_strdup("1083"), + g_list_copy(canon_2)); + + GList* digital = NULL; + digital = g_list_append (digital, g_strdup ("0001")); + g_hash_table_insert (scanners, + g_strdup("1183"), + g_list_copy(digital)); + + GList* konica_2 = NULL; + konica_2 = g_list_append (konica_2, g_strdup ("2089")); + g_hash_table_insert (scanners, + g_strdup("132b"), + g_list_copy(konica_2)); + GList* umax = NULL; + umax = g_list_append (umax, g_strdup ("0010")); + umax = g_list_append (umax, g_strdup ("0030")); + umax = g_list_append (umax, g_strdup ("0050")); + umax = g_list_append (umax, g_strdup ("0060")); + umax = g_list_append (umax, g_strdup ("0070")); + umax = g_list_append (umax, g_strdup ("0130")); + umax = g_list_append (umax, g_strdup ("0160")); + umax = g_list_append (umax, g_strdup ("0230")); + g_hash_table_insert (scanners, + g_strdup("1606"), + g_list_copy(umax)); + + GList* docketport = NULL; + docketport = g_list_append (docketport, g_strdup ("4810")); + g_hash_table_insert (scanners, + g_strdup("1dcc"), + g_list_copy(docketport)); + + GList* dell = NULL; + dell = g_list_append (dell, g_strdup ("5105")); + dell = g_list_append (dell, g_strdup ("5124")); + dell = g_list_append (dell, g_strdup ("5250")); + g_hash_table_insert (scanners, + g_strdup("413c"), + g_list_copy(dell)); } -- cgit v1.2.3 From f3e3f6173c6782b7fe8bfaa181477cb6b4bd672d Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Tue, 2 Aug 2011 12:19:10 -0400 Subject: use correct printers command --- src/device-menu-mgr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 324b3f1..986d151 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -440,6 +440,19 @@ show_session_properties (DbusmenuMenuitem * mi, } } +static void +show_printer_properties (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("system-config-printer", &error)) + { + g_warning("Unable to show dialog: %s", error->message); + g_error_free(error); + } +} + static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, @@ -539,7 +552,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) _("Printers")); g_signal_connect (G_OBJECT(printers_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), + G_CALLBACK(show_printer_properties), "printers"); dbusmenu_menuitem_child_add_position(self->root_item, printers_menuitem, -- cgit v1.2.3 From 933bbfd1c0ea8b59c9d40ad85584e97fcfe8f874 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 2 Aug 2011 18:14:54 +0100 Subject: certain usb webcams sorted --- src/udev-mgr.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 16 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index f4b357d..5a455d1 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -35,17 +35,21 @@ static void udev_mgr_uevent_cb (GUdevClient *client, GUdevDevice *device, gpointer user_data); static void udev_mgr_update_menuitems (UdevMgr* self); -static void udev_mgr_check_if_device_is_supported (UdevMgr* self, - GUdevDevice *device, - UdevMgrDeviceAction action); - +static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action); + +static void udev_mgr_check_if_scsi_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action); + struct _UdevMgr { GObject parent_instance; DbusmenuMenuitem* scanner_item; DbusmenuMenuitem* webcam_item; GUdevClient* client; - GHashTable* supported_scanners; + GHashTable* supported_usb_scanners; GHashTable* scanners_present; }; @@ -65,14 +69,14 @@ static void udev_mgr_init (UdevMgr* self) { self->client = NULL; - self->supported_scanners = NULL; + self->supported_usb_scanners = NULL; self->scanners_present = NULL; self->client = g_udev_client_new (subsystems); - self->supported_scanners = g_hash_table_new (g_str_hash, g_str_equal); + self->supported_usb_scanners = g_hash_table_new (g_str_hash, g_str_equal); self->scanners_present = g_hash_table_new (g_str_hash, g_str_equal); - populate_usb_scanners(self->supported_scanners); + populate_usb_scanners(self->supported_usb_scanners); g_signal_connect (G_OBJECT (self->client), "uevent", G_CALLBACK (udev_mgr_uevent_cb), @@ -102,7 +106,7 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) UdevMgr* self = UDEV_MGR (userdata); GUdevDevice* device = G_UDEV_DEVICE (data); - udev_mgr_check_if_device_is_supported (self, device, ADD); + udev_mgr_check_if_usb_device_is_supported (self, device, ADD); /*const gchar* vendor = NULL; const gchar* product = NULL; @@ -149,6 +153,8 @@ static void udev_mgr_uevent_cb (GUdevClient *client, { g_return_if_fail (UDEV_IS_MGR (user_data)); UdevMgr* self = UDEV_MGR (user_data); + g_return_if_fail (device != NULL); + g_debug ("just received a UEVENT with an action : %s", action); UdevMgrDeviceAction udev_mgr_action = ADD; @@ -156,7 +162,56 @@ static void udev_mgr_uevent_cb (GUdevClient *client, if (g_strcmp0 (action, "remove") == 0){ udev_mgr_action = REMOVE; } - udev_mgr_check_if_device_is_supported (self, device, udev_mgr_action); + const gchar* subsystem = NULL; + const gchar* device_type = NULL; + + device_type = g_udev_device_get_devtype (device); + subsystem = g_udev_device_get_subsystem (device); + + g_debug ("And the subsystem is %s", subsystem); + g_debug ("And the device_type is %s", device_type); + + if (g_strcmp0 (subsystem, "usb") == 0){ + if ( g_udev_device_has_property (device, "ID_USB_INTERFACES")){ + const gchar* id_usb_interfaces = NULL; + id_usb_interfaces = g_udev_device_get_property (device, "ID_USB_INTERFACES"); + + GError* error = NULL; + GMatchInfo *match_info = NULL; + GRegex* webcam_regex = NULL; + + webcam_regex = g_regex_new (":0e[0-9]{4}:*", + 0, + 0, + &error); + // This seems to be case with certain webcams + //#":ff[f|0]{4} + if (error != NULL){ + g_debug ("Errors creating the regex : %s", error->message); + } + gboolean result = g_regex_match (webcam_regex, + id_usb_interfaces, + 0, + & match_info); + + g_debug ("we have found the id usb interfaces : %s", id_usb_interfaces); + + if (result == TRUE){ + g_debug ("SUCCESSFUL MATCH"); + } + else { + g_debug ("NO MATCH"); + } + } + + udev_mgr_check_if_usb_device_is_supported (self, device, udev_mgr_action); + } + else if (g_strcmp0 (subsystem, "scsi") == 0){ + udev_mgr_check_if_scsi_device_is_supported (self, device, udev_mgr_action); + } + + return; + const gchar* vendor; const gchar* product; const gchar* number; @@ -193,19 +248,31 @@ static void udev_mgr_uevent_cb (GUdevClient *client, } } + +static void +udev_mgr_check_if_scsi_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action) +{ +} + static void -udev_mgr_check_if_device_is_supported (UdevMgr* self, - GUdevDevice *device, - UdevMgrDeviceAction action) +udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, + GUdevDevice *device, + UdevMgrDeviceAction action) { + g_debug ("got a uevent"); const gchar* vendor = NULL; + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); if (vendor == NULL) return; + g_debug ("vendor = %s", vendor); + GList* vendor_list = NULL; - vendor_list = g_hash_table_lookup (self->supported_scanners, + vendor_list = g_hash_table_lookup (self->supported_usb_scanners, (gpointer)vendor); if (vendor_list == NULL) return; @@ -223,8 +290,10 @@ udev_mgr_check_if_device_is_supported (UdevMgr* self, if (action == REMOVE){ // TODO handle the case where its removed // remove it if present from the hash and call update_menuitems - } + } else{ + // TODO: populate it with the name of the device + // this will be needed for the menuitem g_hash_table_insert (self->scanners_present, g_strdup(vendor), g_strdup(model_id)); @@ -248,7 +317,6 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, GList* devices_available = g_udev_client_query_by_subsystem (mgr->client, usb_subsystem); - g_list_foreach (devices_available, udevice_mgr_device_list_iterator, mgr); -- cgit v1.2.3 From c09a09f1ad35f5a6ac1333f99cdcbf5369b97691 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 3 Aug 2011 11:31:25 -0400 Subject: when used in a greeter, don't show settings links, the user switcher, or log out links --- src/device-menu-mgr.c | 126 +++++++++++++++++++++++++++++--------------------- src/device-menu-mgr.h | 2 +- src/session-service.c | 24 ++++++++-- 3 files changed, 93 insertions(+), 59 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 324b3f1..e58bdab 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -461,9 +461,8 @@ show_system_settings_with_context (DbusmenuMenuitem * mi, } static void -device_menu_mgr_build_static_items (DeviceMenuMgr* self) +device_menu_mgr_build_settings_items (DeviceMenuMgr* self) { - // Static Setting items system_settings_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (system_settings_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -520,8 +519,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_add_position (self->root_item, separator1, 5); +} - // Devices control +static void +device_menu_mgr_build_devices_items (DeviceMenuMgr* self) +{ DbusmenuMenuitem * device_heading = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (device_heading, DBUSMENU_MENUITEM_PROP_LABEL, @@ -581,58 +583,74 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_add_position (self->root_item, separator3, 11); - +} + +static void +device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) +{ + // Static Setting items + if (!greeter_mode) { + device_menu_mgr_build_settings_items (self); + } + + // Devices control + if (!greeter_mode) { + device_menu_mgr_build_devices_items (self); + } + // Session control - gboolean can_lockscreen; - - /* Make sure we have a valid GConf client, and build one - if needed */ - device_menu_mgr_ensure_gconf_client (self); - can_lockscreen = !gconf_client_get_bool ( gconf_client, - LOCKDOWN_KEY_SCREENSAVER, - NULL); - /* Lock screen item */ - if (can_lockscreen) { - lock_menuitem = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (lock_menuitem, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Lock Screen")); + if (!greeter_mode) { + gboolean can_lockscreen; + + /* Make sure we have a valid GConf client, and build one + if needed */ + device_menu_mgr_ensure_gconf_client (self); + can_lockscreen = !gconf_client_get_bool ( gconf_client, + LOCKDOWN_KEY_SCREENSAVER, + NULL); + /* Lock screen item */ + if (can_lockscreen) { + lock_menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (lock_menuitem, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Lock Screen")); + + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); + } + else { + g_debug("Unable to get lock screen shortcut."); + } + + g_signal_connect (G_OBJECT(lock_menuitem), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(lock_screen), NULL); + dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); + } - gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); - if (shortcut != NULL) { - g_debug("Lock screen shortcut: %s", shortcut); - dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); - g_free(shortcut); + logout_mi = dbusmenu_menuitem_new(); + + if (supress_confirmations()) { + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out")); } else { - g_debug("Unable to get lock screen shortcut."); + dbusmenu_menuitem_property_set (logout_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Log Out\342\200\246")); } - - g_signal_connect (G_OBJECT(lock_menuitem), + dbusmenu_menuitem_property_set_bool (logout_mi, + DBUSMENU_MENUITEM_PROP_VISIBLE, + show_logout()); + dbusmenu_menuitem_child_append(self->root_item, logout_mi); + g_signal_connect( G_OBJECT(logout_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(lock_screen), NULL); - dbusmenu_menuitem_child_append(self->root_item, lock_menuitem); - } - - logout_mi = dbusmenu_menuitem_new(); - - if (supress_confirmations()) { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out")); - } - else { - dbusmenu_menuitem_property_set (logout_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Log Out\342\200\246")); - } - dbusmenu_menuitem_property_set_bool (logout_mi, - DBUSMENU_MENUITEM_PROP_VISIBLE, - show_logout()); - dbusmenu_menuitem_child_append(self->root_item, logout_mi); - g_signal_connect( G_OBJECT(logout_mi), - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_dialog), "logout"); + G_CALLBACK(show_dialog), "logout"); + } if (can_suspend && allow_suspend) { suspend_mi = dbusmenu_menuitem_new(); @@ -787,12 +805,14 @@ device_mgr_get_root_item (DeviceMenuMgr* self) /* * Clean Entry Point */ -DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus) +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode) { DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); device_mgr->session_dbus_interface = session_dbus; - device_menu_mgr_build_static_items (device_mgr); - device_mgr->apt_watcher = apt_watcher_new (session_dbus, - software_updates_menuitem); + device_menu_mgr_build_static_items (device_mgr, greeter_mode); + if (software_updates_menuitem != NULL) { + device_mgr->apt_watcher = apt_watcher_new (session_dbus, + software_updates_menuitem); + } return device_mgr; } diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h index 503b36a..d3c3a5a 100644 --- a/src/device-menu-mgr.h +++ b/src/device-menu-mgr.h @@ -44,7 +44,7 @@ struct _DeviceMenuMgrClass GType device_menu_mgr_get_type (void) G_GNUC_CONST; -DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus); +DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode); DbusmenuMenuitem* device_mgr_get_root_item (DeviceMenuMgr* self); diff --git a/src/session-service.c b/src/session-service.c index bb473e9..fa212fd 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -78,11 +78,21 @@ service_shutdown (IndicatorService * service, gpointer user_data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /* Main, is well, main. It brings everything up and throws us into the mainloop of no return. */ int main (int argc, char ** argv) { + gboolean greeter_mode; + g_type_init(); /* Setting up i18n and gettext. Apparently, we need @@ -99,15 +109,19 @@ main (int argc, char ** argv) session_dbus = session_dbus_new(); + greeter_mode = get_greeter_mode(); + // Devices - DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus); + DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus, greeter_mode); DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT); dbusmenu_server_set_root(server, device_mgr_get_root_item (device_mgr)); - // Users - UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); - DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); - dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); + if (!greeter_mode) { + // Users + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); + DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); + dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); + } mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 88d74cf2b768eda753cd2bc85013203be6d9ca3b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Aug 2011 17:26:12 +0100 Subject: webcams working nicely --- src/udev-mgr.c | 211 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 113 insertions(+), 98 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 5a455d1..5c650b6 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -42,6 +42,14 @@ static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, static void udev_mgr_check_if_scsi_device_is_supported (UdevMgr* self, GUdevDevice *device, UdevMgrDeviceAction action); +static void udev_mgr_handle_webcam (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action); + +static void debug_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action); + struct _UdevMgr { @@ -51,19 +59,15 @@ struct _UdevMgr GUdevClient* client; GHashTable* supported_usb_scanners; GHashTable* scanners_present; + GHashTable* webcams_present; }; -const char *subsystems[2] = {"usb", "scsi"}; +const char *subsystems[3] = {"usb", "scsi", "video4linux"}; const gchar* usb_subsystem = "usb"; +const gchar* video4linux_subsystem = "video4linux"; -G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); -/*static void -test_usb_scanners(gpointer data, gpointer user_data) -{ - gchar* model = (gchar*)data; - g_debug ("in hash table for epsom model %s was found", model); -}*/ +G_DEFINE_TYPE (UdevMgr, udev_mgr, G_TYPE_OBJECT); static void udev_mgr_init (UdevMgr* self) @@ -71,12 +75,16 @@ udev_mgr_init (UdevMgr* self) self->client = NULL; self->supported_usb_scanners = NULL; self->scanners_present = NULL; - + self->webcams_present = NULL; + self->client = g_udev_client_new (subsystems); self->supported_usb_scanners = g_hash_table_new (g_str_hash, g_str_equal); self->scanners_present = g_hash_table_new (g_str_hash, g_str_equal); + self->webcams_present = g_hash_table_new (g_str_hash, g_str_equal); + // load into memory all supported scanners ... populate_usb_scanners(self->supported_usb_scanners); + g_signal_connect (G_OBJECT (self->client), "uevent", G_CALLBACK (udev_mgr_uevent_cb), @@ -106,35 +114,16 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) UdevMgr* self = UDEV_MGR (userdata); GUdevDevice* device = G_UDEV_DEVICE (data); - udev_mgr_check_if_usb_device_is_supported (self, device, ADD); - /*const gchar* vendor = NULL; - const gchar* product = NULL; - GList* vendor_list = NULL; - - vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); - - if (vendor == NULL){ - g_object_unref (device); - return; - } + const gchar* subsystem = NULL; + subsystem = g_udev_device_get_subsystem (device); - product = g_udev_device_get_property (device, "ID_MODEL_ID"); - vendor_list = g_hash_table_lookup(self->supported_scanners, (gpointer)vendor); - - GList* model = NULL; - - if (vendor_list != NULL){ - model = g_list_find_custom(vendor_list, product, (GCompareFunc)g_strcmp0); - if (model == NULL){ - g_debug ("CANT FIND THE MODEL %s FOR VENDOR %s", product, vendor); - } - else{ - self->scanners_present += 1; - g_debug ("WE HAVE A SUCCESSFUL MATCH!"); - } + if (g_strcmp0 (subsystem, "usb") == 0){ + udev_mgr_check_if_usb_device_is_supported (self, device, ADD); + } + else if (g_strcmp0 (subsystem, "video4linux") == 0){ + udev_mgr_handle_webcam (self, device, ADD); } - g_debug ("JUST SET SCANNERS TO TRUE");*/ g_object_unref (device); } @@ -144,6 +133,11 @@ static void udev_mgr_update_menuitems (UdevMgr* self) dbusmenu_menuitem_property_set_bool (self->scanner_item, DBUSMENU_MENUITEM_PROP_VISIBLE, g_hash_table_size (self->scanners_present) > 0); + + dbusmenu_menuitem_property_set_bool (self->webcam_item, + DBUSMENU_MENUITEM_PROP_VISIBLE, + g_hash_table_size (self->webcams_present) > 0); + } static void udev_mgr_uevent_cb (GUdevClient *client, @@ -162,68 +156,79 @@ static void udev_mgr_uevent_cb (GUdevClient *client, if (g_strcmp0 (action, "remove") == 0){ udev_mgr_action = REMOVE; } - const gchar* subsystem = NULL; - const gchar* device_type = NULL; - device_type = g_udev_device_get_devtype (device); + const gchar* subsystem = NULL; subsystem = g_udev_device_get_subsystem (device); - g_debug ("And the subsystem is %s", subsystem); - g_debug ("And the device_type is %s", device_type); - if (g_strcmp0 (subsystem, "usb") == 0){ - if ( g_udev_device_has_property (device, "ID_USB_INTERFACES")){ - const gchar* id_usb_interfaces = NULL; - id_usb_interfaces = g_udev_device_get_property (device, "ID_USB_INTERFACES"); - - GError* error = NULL; - GMatchInfo *match_info = NULL; - GRegex* webcam_regex = NULL; - - webcam_regex = g_regex_new (":0e[0-9]{4}:*", - 0, - 0, - &error); - // This seems to be case with certain webcams - //#":ff[f|0]{4} - if (error != NULL){ - g_debug ("Errors creating the regex : %s", error->message); - } - gboolean result = g_regex_match (webcam_regex, - id_usb_interfaces, - 0, - & match_info); - - g_debug ("we have found the id usb interfaces : %s", id_usb_interfaces); - - if (result == TRUE){ - g_debug ("SUCCESSFUL MATCH"); - } - else { - g_debug ("NO MATCH"); - } - } - - udev_mgr_check_if_usb_device_is_supported (self, device, udev_mgr_action); + udev_mgr_check_if_usb_device_is_supported (self, + device, + udev_mgr_action); + } + else if (g_strcmp0 (subsystem, "video4linux") == 0){ + udev_mgr_handle_webcam (self, device, udev_mgr_action); } else if (g_strcmp0 (subsystem, "scsi") == 0){ udev_mgr_check_if_scsi_device_is_supported (self, device, udev_mgr_action); } +} + +static void +udev_mgr_handle_webcam (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action) +{ + if (FALSE) + debug_device (self, device, action); + + const gchar* vendor; + const gchar* product; - return; + vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); + product = g_udev_device_get_property (device, "ID_MODEL_ID"); + if (action == REMOVE){ + if (g_hash_table_lookup (self->webcams_present, product) == NULL){ + g_warning ("Got a remove event on a webcam device but we don't have that device in our webcam cache"); + return; + } + g_hash_table_remove (self->webcams_present, + g_strdup (product)); + + } + 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; + } + g_hash_table_insert (self->webcams_present, + g_strdup (product), + g_strdup (vendor)); + + } + udev_mgr_update_menuitems (self); +} + +static void +debug_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action) +{ const gchar* vendor; const gchar* product; const gchar* number; + const gchar* name; vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); product = g_udev_device_get_property (device, "ID_MODEL_ID"); number = g_udev_device_get_number (device); - - g_debug ("device vendor id %s and product id of %s and number of %s", + 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_strdup(vendor), g_strdup(product), - g_strdup(number)); + g_strdup(number), + g_strdup(name)); const gchar *const *list; const gchar *const *iter; @@ -245,7 +250,7 @@ static void udev_mgr_uevent_cb (GUdevClient *client, strcat(propstr, " "); strcat(propstr, g_udev_device_get_property(device, *iter)); g_debug("%s", propstr); - } + } } @@ -261,7 +266,6 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, GUdevDevice *device, UdevMgrDeviceAction action) { - g_debug ("got a uevent"); const gchar* vendor = NULL; vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); @@ -288,24 +292,25 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, if (model_entry != NULL){ if (action == REMOVE){ - // TODO handle the case where its removed - // remove it if present from the hash and call update_menuitems + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){ + g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); + } + else{ + g_hash_table_remove (self->scanners_present, g_strdup(vendor)); + } } else{ - // TODO: populate it with the name of the device - // this will be needed for the menuitem - g_hash_table_insert (self->scanners_present, - g_strdup(vendor), - g_strdup(model_id)); + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){ + g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); + } + else{ + g_hash_table_insert (self->scanners_present, + g_strdup(vendor), + g_strdup(model_id)); + } } + udev_mgr_update_menuitems (self); } - // DEBUG purposes. - if (model_entry == NULL){ - g_debug ("CANT FIND THE MODEL %s FOR VENDOR %s", model_id, vendor); - } - else{ - g_debug ("WE HAVE A SUCCESSFUL MATCH!"); - } } UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, @@ -315,12 +320,22 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, mgr->scanner_item = scanner; mgr->webcam_item = webcam; - GList* devices_available = g_udev_client_query_by_subsystem (mgr->client, + GList* usb_devices_available = g_udev_client_query_by_subsystem (mgr->client, usb_subsystem); - g_list_foreach (devices_available, + g_list_foreach (usb_devices_available, + udevice_mgr_device_list_iterator, + mgr); + + g_list_free (usb_devices_available); + + GList* video_devices_available = g_udev_client_query_by_subsystem (mgr->client, + video4linux_subsystem); + g_list_foreach (video_devices_available, udevice_mgr_device_list_iterator, mgr); - g_list_free (devices_available); - udev_mgr_update_menuitems (mgr); + + g_list_free (video_devices_available); + + //udev_mgr_update_menuitems (mgr); return mgr; } -- cgit v1.2.3 From 85e9bcfb399e489eaa6fbf467f940baa69239bf2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Aug 2011 18:01:32 +0100 Subject: refactor of the udev mgr - working nicely --- src/device-menu-mgr.c | 6 +++--- src/sane-rules.h | 5 +++++ src/udev-mgr.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 2c559ee..1be113c 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -547,7 +547,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) scanners_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (scanners_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, - _("HP Scanners")); + _("Scanners")); g_signal_connect (G_OBJECT(scanners_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_system_settings_with_context), @@ -562,11 +562,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) webcam_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (webcam_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, - _("HP Webcam")); + _("Webcam")); g_signal_connect (G_OBJECT(webcam_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_system_settings_with_context), - "HP Webcam"); + "Webcam"); dbusmenu_menuitem_child_add_position (self->root_item, webcam_menuitem, 10); diff --git a/src/sane-rules.h b/src/sane-rules.h index 4c36698..871565b 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -2,6 +2,7 @@ void populate_usb_scanners (GHashTable* scanners) { GList* hp = NULL; + hp = g_list_append (hp, g_strdup ("0101")); hp = g_list_append (hp, g_strdup ("0105")); hp = g_list_append (hp, g_strdup ("0201")); @@ -308,6 +309,10 @@ void populate_usb_scanners (GHashTable* scanners) g_list_copy(nikon)); GList* epson = NULL; + + // for testing (its a printer not a scanner!) + //epson = g_list_append (epson, g_strdup ("0001")); + epson = g_list_append (epson, g_strdup("0101")); epson = g_list_append (epson, g_strdup("0103")); epson = g_list_append (epson, g_strdup("0104")); diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 5c650b6..6ddd97d 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -203,8 +203,7 @@ udev_mgr_handle_webcam (UdevMgr* self, } g_hash_table_insert (self->webcams_present, g_strdup (product), - g_strdup (vendor)); - + g_strdup (vendor)); } udev_mgr_update_menuitems (self); } @@ -267,6 +266,7 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, UdevMgrDeviceAction action) { const gchar* vendor = NULL; + debug_device (self, device, action); vendor = g_udev_device_get_property (device, "ID_VENDOR_ID"); -- cgit v1.2.3 From 6ec15c2d51f83a10f81d94ad1be2da8761c9553c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Aug 2011 11:59:50 +0100 Subject: add scsi scanner detection support --- src/sane-rules.h | 26 ++++++++++++ src/udev-mgr.c | 127 +++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 125 insertions(+), 28 deletions(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index 871565b..5483b28 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -1,3 +1,29 @@ +void populate_scsi_scanners (GHashTable* scanners) +{ + GList* epson = NULL; + epson = g_list_append (epson, g_strdup ("GT-9700")); + epson = g_list_append (epson, g_strdup ("GT-9800")); + epson = g_list_append (epson, g_strdup ("Perfection1200")); + epson = g_list_append (epson, g_strdup ("Perfection636")); + epson = g_list_append (epson, g_strdup ("SCANNER GT-7000")); + g_hash_table_insert (scanners, + g_strdup("EPSON"), + g_list_copy(epson)); + + + GList* hp = NULL; + hp = g_list_append (hp, g_strdup ("C1130A")); + hp = g_list_append (hp, g_strdup ("C1750A")); + hp = g_list_append (hp, g_strdup ("C1790A")); + hp = g_list_append (hp, g_strdup ("C2500A")); + hp = g_list_append (hp, g_strdup ("C2520A")); + hp = g_list_append (hp, g_strdup ("C5110A")); + hp = g_list_append (hp, g_strdup ("C6270A")); + hp = g_list_append (hp, g_strdup ("C7670A")); + g_hash_table_insert (scanners, + g_strdup("HP"), + g_list_copy(hp)); +} void populate_usb_scanners (GHashTable* scanners) { diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 6ddd97d..d110304 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -37,19 +37,17 @@ static void udev_mgr_uevent_cb (GUdevClient *client, static void udev_mgr_update_menuitems (UdevMgr* self); static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, GUdevDevice *device, - UdevMgrDeviceAction action); - -static void udev_mgr_check_if_scsi_device_is_supported (UdevMgr* self, - GUdevDevice *device, - UdevMgrDeviceAction action); + UdevMgrDeviceAction action); static void udev_mgr_handle_webcam (UdevMgr* self, GUdevDevice* device, - UdevMgrDeviceAction action); - + UdevMgrDeviceAction action); +static void udev_mgr_handle_scsi_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action); + static void debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action); - struct _UdevMgr { @@ -58,12 +56,14 @@ struct _UdevMgr DbusmenuMenuitem* webcam_item; GUdevClient* client; GHashTable* supported_usb_scanners; + GHashTable* supported_scsi_scanners; GHashTable* scanners_present; GHashTable* webcams_present; }; const char *subsystems[3] = {"usb", "scsi", "video4linux"}; const gchar* usb_subsystem = "usb"; +const gchar* scsi_subsystem = "scsi"; const gchar* video4linux_subsystem = "video4linux"; @@ -76,15 +76,29 @@ udev_mgr_init (UdevMgr* self) self->supported_usb_scanners = NULL; self->scanners_present = NULL; self->webcams_present = NULL; - + g_debug ("About to create hash tables"); self->client = g_udev_client_new (subsystems); - self->supported_usb_scanners = g_hash_table_new (g_str_hash, g_str_equal); - self->scanners_present = g_hash_table_new (g_str_hash, g_str_equal); - self->webcams_present = g_hash_table_new (g_str_hash, g_str_equal); + self->supported_usb_scanners = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + self->scanners_present = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + self->webcams_present = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + g_debug ("After creating hash tables"); // load into memory all supported scanners ... - populate_usb_scanners(self->supported_usb_scanners); - + populate_usb_scanners (self->supported_usb_scanners); + populate_scsi_scanners (self->supported_scsi_scanners); g_signal_connect (G_OBJECT (self->client), "uevent", G_CALLBACK (udev_mgr_uevent_cb), @@ -124,6 +138,10 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) else if (g_strcmp0 (subsystem, "video4linux") == 0){ udev_mgr_handle_webcam (self, device, ADD); } + else if (g_strcmp0 (subsystem, "scsi") == 0){ + udev_mgr_handle_scsi_device (self, device, ADD); + } + g_object_unref (device); } @@ -169,10 +187,11 @@ static void udev_mgr_uevent_cb (GUdevClient *client, udev_mgr_handle_webcam (self, device, udev_mgr_action); } else if (g_strcmp0 (subsystem, "scsi") == 0){ - udev_mgr_check_if_scsi_device_is_supported (self, device, udev_mgr_action); + udev_mgr_handle_scsi_device (self, device, udev_mgr_action); } } + static void udev_mgr_handle_webcam (UdevMgr* self, GUdevDevice* device, @@ -193,7 +212,7 @@ udev_mgr_handle_webcam (UdevMgr* self, return; } g_hash_table_remove (self->webcams_present, - g_strdup (product)); + product); } else { @@ -252,13 +271,55 @@ debug_device (UdevMgr* self, } } - -static void -udev_mgr_check_if_scsi_device_is_supported (UdevMgr* self, - GUdevDevice *device, - UdevMgrDeviceAction action) +static void udev_mgr_handle_scsi_device (UdevMgr* self, + GUdevDevice* device, + UdevMgrDeviceAction action) { -} + const gchar* vendor = NULL; + vendor = g_udev_device_get_property (device, "VENDOR"); + + if (vendor == NULL) + return; + + GList* vendor_list = NULL; + vendor_list = g_hash_table_lookup (self->supported_scsi_scanners, + (gpointer)vendor); + if (vendor_list == NULL) + return; + + const gchar* model_id = NULL; + model_id = g_udev_device_get_property (device, "MODEL"); + + if (model_id == NULL) + return; + + GList* model_entry = NULL; + model_entry = g_list_find_custom (vendor_list, + model_id, + (GCompareFunc)g_strcmp0); + + if (model_entry != NULL){ + if (action == REMOVE){ + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) == NULL){ + g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); + } + else{ + g_hash_table_remove (self->scanners_present, vendor); + } + } + else{ + if (g_hash_table_lookup (self->scanners_present, g_strdup(vendor)) != NULL){ + g_warning ("Got an ADD event on a scanner device but we already have that device in our scanners cache"); + } + else{ + g_hash_table_insert (self->scanners_present, + g_strdup(vendor), + g_strdup(model_id)); + } + } + udev_mgr_update_menuitems (self); + } +} static void udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, @@ -273,7 +334,7 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, if (vendor == NULL) return; - g_debug ("vendor = %s", vendor); + //g_debug ("vendor = %s", vendor); GList* vendor_list = NULL; vendor_list = g_hash_table_lookup (self->supported_usb_scanners, @@ -296,7 +357,7 @@ udev_mgr_check_if_usb_device_is_supported (UdevMgr* self, g_warning ("Got an REMOVE event on a scanner device but we dont have that device in our scanners cache"); } else{ - g_hash_table_remove (self->scanners_present, g_strdup(vendor)); + g_hash_table_remove (self->scanners_present, vendor); } } else{ @@ -319,15 +380,17 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, UdevMgr* mgr = g_object_new (UDEV_TYPE_MGR, NULL); mgr->scanner_item = scanner; mgr->webcam_item = webcam; - + + // Check for USB devices GList* usb_devices_available = g_udev_client_query_by_subsystem (mgr->client, - usb_subsystem); + usb_subsystem); g_list_foreach (usb_devices_available, udevice_mgr_device_list_iterator, mgr); g_list_free (usb_devices_available); - + + // Check for webcams GList* video_devices_available = g_udev_client_query_by_subsystem (mgr->client, video4linux_subsystem); g_list_foreach (video_devices_available, @@ -335,7 +398,15 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, mgr); g_list_free (video_devices_available); + + // Check for SCSI devices + GList* scsi_devices_available = g_udev_client_query_by_subsystem (mgr->client, + scsi_subsystem); + g_list_foreach (scsi_devices_available, + udevice_mgr_device_list_iterator, + mgr); + + g_list_free (usb_devices_available); - //udev_mgr_update_menuitems (mgr); return mgr; } -- cgit v1.2.3 From c6d97d1fae6783d5b671de8b7af4ae23116f46a0 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Aug 2011 12:32:50 +0100 Subject: duplicate key input error --- src/sane-rules.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index 5483b28..4d6c7cc 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -25,6 +25,8 @@ void populate_scsi_scanners (GHashTable* scanners) g_list_copy(hp)); } + + void populate_usb_scanners (GHashTable* scanners) { GList* hp = NULL; @@ -78,7 +80,7 @@ void populate_usb_scanners (GHashTable* scanners) mustek_2 = g_list_append (mustek_2, g_strdup ("1000")); mustek_2 = g_list_append (mustek_2, g_strdup ("1001")); g_hash_table_insert (scanners, - g_strdup("03f0"), + g_strdup("0400"), g_list_copy(mustek_2)); GList* kodak = NULL; -- cgit v1.2.3 From 9cf6aa224e626832f2b4c1e4e53d5fd604484396 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Aug 2011 13:05:39 +0100 Subject: stop leaking tonnes of glists --- src/sane-rules.h | 84 ++++++++++++++++++++++++++++---------------------------- src/udev-mgr.c | 4 +-- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/sane-rules.h b/src/sane-rules.h index 4d6c7cc..0b72e52 100644 --- a/src/sane-rules.h +++ b/src/sane-rules.h @@ -8,7 +8,7 @@ void populate_scsi_scanners (GHashTable* scanners) epson = g_list_append (epson, g_strdup ("SCANNER GT-7000")); g_hash_table_insert (scanners, g_strdup("EPSON"), - g_list_copy(epson)); + epson); GList* hp = NULL; @@ -22,7 +22,7 @@ void populate_scsi_scanners (GHashTable* scanners) hp = g_list_append (hp, g_strdup ("C7670A")); g_hash_table_insert (scanners, g_strdup("HP"), - g_list_copy(hp)); + hp); } @@ -74,14 +74,14 @@ void populate_usb_scanners (GHashTable* scanners) g_hash_table_insert (scanners, g_strdup("03f0"), - g_list_copy(hp)); + hp); GList* mustek_2 = NULL; mustek_2 = g_list_append (mustek_2, g_strdup ("1000")); mustek_2 = g_list_append (mustek_2, g_strdup ("1001")); g_hash_table_insert (scanners, g_strdup("0400"), - g_list_copy(mustek_2)); + mustek_2); GList* kodak = NULL; kodak = g_list_append (kodak, g_strdup ("6001")); @@ -91,7 +91,7 @@ void populate_usb_scanners (GHashTable* scanners) kodak = g_list_append (kodak, g_strdup ("6005")); g_hash_table_insert (scanners, g_strdup("040a"), - g_list_copy(kodak)); + kodak); GList* creative = NULL; @@ -99,7 +99,7 @@ void populate_usb_scanners (GHashTable* scanners) g_hash_table_insert (scanners, g_strdup("041e"), - g_list_copy(creative)); + creative); GList* lexmark = NULL; @@ -110,7 +110,7 @@ void populate_usb_scanners (GHashTable* scanners) g_hash_table_insert (scanners, g_strdup("043d"), - g_list_copy(lexmark)); + lexmark); GList* genius = NULL; @@ -132,32 +132,32 @@ void populate_usb_scanners (GHashTable* scanners) genius = g_list_append (genius, g_strdup("20c1")); g_hash_table_insert (scanners, g_strdup("0458"), - g_list_copy(genius)); + genius); GList* medion = NULL; medion = g_list_append (medion, g_strdup("0377")); g_hash_table_insert (scanners, g_strdup("0461"), - g_list_copy(medion)); + medion); GList* trust = NULL; trust = g_list_append (trust, g_strdup("1000")); trust = g_list_append (trust, g_strdup("1002")); g_hash_table_insert (scanners, g_strdup("047b"), - g_list_copy(trust)); + trust); GList* kyocera = NULL; kyocera = g_list_append (kyocera, g_strdup("0335")); g_hash_table_insert (scanners, g_strdup("0482"), - g_list_copy(kyocera)); + kyocera); GList* compaq = NULL; compaq = g_list_append (compaq, g_strdup("001a")); g_hash_table_insert (scanners, g_strdup("049f"), - g_list_copy(compaq)); + compaq); GList* benq = NULL; benq = g_list_append (benq, g_strdup("1a20")); benq = g_list_append (benq, g_strdup("1a2a")); @@ -176,7 +176,7 @@ void populate_usb_scanners (GHashTable* scanners) benq = g_list_append (benq, g_strdup("2211")); g_hash_table_insert (scanners, g_strdup("04a5"), - g_list_copy(benq)); + benq); GList* visioneer = NULL; visioneer = g_list_append (visioneer, g_strdup("0229")); @@ -223,7 +223,7 @@ void populate_usb_scanners (GHashTable* scanners) visioneer = g_list_append (visioneer, g_strdup("04ac")); g_hash_table_insert (scanners, g_strdup("04a7"), - g_list_copy(visioneer)); + visioneer); GList* canon = NULL; canon = g_list_append (canon, g_strdup("1601")); canon = g_list_append (canon, g_strdup("1602")); @@ -326,7 +326,7 @@ void populate_usb_scanners (GHashTable* scanners) canon = g_list_append (canon, g_strdup("26ee")); g_hash_table_insert (scanners, g_strdup("04a9"), - g_list_copy(canon)); + canon); GList* nikon = NULL; nikon = g_list_append (nikon, g_strdup ("4000")); @@ -334,7 +334,7 @@ void populate_usb_scanners (GHashTable* scanners) nikon = g_list_append (nikon, g_strdup ("4002")); g_hash_table_insert (scanners, g_strdup("04b0"), - g_list_copy(nikon)); + nikon); GList* epson = NULL; @@ -427,7 +427,7 @@ void populate_usb_scanners (GHashTable* scanners) epson = g_list_append (epson, g_strdup("0856")); g_hash_table_insert (scanners, g_strdup("04b8"), - g_list_copy(epson)); + epson); GList* fujitsu = NULL; fujitsu = g_list_append (fujitsu, g_strdup ("1029")); @@ -480,12 +480,12 @@ void populate_usb_scanners (GHashTable* scanners) fujitsu = g_list_append (fujitsu, g_strdup ("11fc")); g_hash_table_insert (scanners, g_strdup("04c5"), - g_list_copy(fujitsu)); + fujitsu); GList* konica = NULL; konica = g_list_append (konica, g_strdup ("0722")); g_hash_table_insert (scanners, g_strdup("04c8"), - g_list_copy(konica)); + konica); GList* panasonic = NULL; panasonic = g_list_append (panasonic, g_strdup ("1000")); panasonic = g_list_append (panasonic, g_strdup ("1001")); @@ -497,7 +497,7 @@ void populate_usb_scanners (GHashTable* scanners) panasonic = g_list_append (panasonic, g_strdup ("1010")); g_hash_table_insert (scanners, g_strdup("04da"), - g_list_copy(panasonic)); + panasonic); GList* samsung = NULL; @@ -513,19 +513,19 @@ void populate_usb_scanners (GHashTable* scanners) samsung = g_list_append (samsung, g_strdup ("3434")); g_hash_table_insert (scanners, g_strdup("04e8"), - g_list_copy(samsung)); + samsung); GList* pentax = NULL; pentax = g_list_append (pentax, g_strdup ("2038")); g_hash_table_insert (scanners, g_strdup("04f9"), - g_list_copy(pentax)); + pentax); GList* apitek = NULL; apitek = g_list_append (apitek, g_strdup ("0202")); g_hash_table_insert (scanners, g_strdup("0553"), - g_list_copy(apitek)); + apitek); GList* mustek = NULL; mustek = g_list_append (mustek, g_strdup ("0001")); @@ -545,7 +545,7 @@ void populate_usb_scanners (GHashTable* scanners) mustek = g_list_append (mustek, g_strdup ("0409")); g_hash_table_insert (scanners, g_strdup("055f"), - g_list_copy(mustek)); + mustek); GList* artec = NULL; artec = g_list_append (artec, g_strdup ("4002")); artec = g_list_append (artec, g_strdup ("4003")); @@ -558,7 +558,7 @@ void populate_usb_scanners (GHashTable* scanners) artec = g_list_append (artec, g_strdup ("4011")); g_hash_table_insert (scanners, g_strdup("05d8"), - g_list_copy(artec)); + artec); GList* microtek = NULL; microtek = g_list_append (microtek, g_strdup ("0099")); @@ -576,7 +576,7 @@ void populate_usb_scanners (GHashTable* scanners) microtek = g_list_append (microtek, g_strdup ("80a3")); g_hash_table_insert (scanners, g_strdup("05da"), - g_list_copy(microtek)); + microtek); GList* avision = NULL; avision = g_list_append (avision, g_strdup ("0268")); @@ -618,14 +618,14 @@ void populate_usb_scanners (GHashTable* scanners) avision = g_list_append (avision, g_strdup ("1a35")); g_hash_table_insert (scanners, g_strdup("0638"), - g_list_copy(avision)); + avision); GList* minolta = NULL; minolta = g_list_append (minolta, g_strdup ("4004")); minolta = g_list_append (minolta, g_strdup ("400d")); minolta = g_list_append (minolta, g_strdup ("400e")); g_hash_table_insert (scanners, g_strdup("0686"), - g_list_copy(minolta)); + minolta); GList* agfa = NULL; agfa = g_list_append (agfa, g_strdup ("0001")); @@ -642,13 +642,13 @@ void populate_usb_scanners (GHashTable* scanners) agfa = g_list_append (agfa, g_strdup ("20ff")); g_hash_table_insert (scanners, g_strdup("06bd"), - g_list_copy(minolta)); + minolta); GList* umax_2 = NULL; umax_2 = g_list_append (umax_2, g_strdup ("0020")); g_hash_table_insert (scanners, g_strdup("06dc"), - g_list_copy(umax_2)); + umax_2); GList* plustek = NULL; @@ -673,14 +673,14 @@ void populate_usb_scanners (GHashTable* scanners) plustek = g_list_append (plustek, g_strdup ("0900")); g_hash_table_insert (scanners, g_strdup("07b3"), - g_list_copy(plustek)); + plustek); GList* corex = NULL; corex = g_list_append (corex, g_strdup ("0002")); corex = g_list_append (corex, g_strdup ("0005")); g_hash_table_insert (scanners, g_strdup("08f0"), - g_list_copy(corex)); + corex); GList* xerox = NULL; xerox = g_list_append (xerox, g_strdup ("3d5d")); @@ -691,19 +691,19 @@ void populate_usb_scanners (GHashTable* scanners) xerox = g_list_append (xerox, g_strdup ("4294")); g_hash_table_insert (scanners, g_strdup("0924"), - g_list_copy(xerox)); + xerox); GList* pentax_2 = NULL; pentax_2 = g_list_append (pentax_2, g_strdup ("3210")); g_hash_table_insert (scanners, g_strdup("0a17"), - g_list_copy(pentax_2)); + pentax_2); GList* portable = NULL; portable = g_list_append (portable, g_strdup ("1000")); g_hash_table_insert (scanners, g_strdup("0a53"), - g_list_copy(portable)); + portable); GList* syscan = NULL; syscan = g_list_append (syscan, g_strdup ("4600")); @@ -714,7 +714,7 @@ void populate_usb_scanners (GHashTable* scanners) syscan = g_list_append (syscan, g_strdup ("6620")); g_hash_table_insert (scanners, g_strdup("0a82"), - g_list_copy(syscan)); + syscan); GList* canon_2 = NULL; canon_2 = g_list_append (canon_2, g_strdup ("160c")); @@ -735,19 +735,19 @@ void populate_usb_scanners (GHashTable* scanners) canon_2 = g_list_append (canon_2, g_strdup ("1639")); g_hash_table_insert (scanners, g_strdup("1083"), - g_list_copy(canon_2)); + canon_2); GList* digital = NULL; digital = g_list_append (digital, g_strdup ("0001")); g_hash_table_insert (scanners, g_strdup("1183"), - g_list_copy(digital)); + digital); GList* konica_2 = NULL; konica_2 = g_list_append (konica_2, g_strdup ("2089")); g_hash_table_insert (scanners, g_strdup("132b"), - g_list_copy(konica_2)); + konica_2); GList* umax = NULL; umax = g_list_append (umax, g_strdup ("0010")); @@ -760,13 +760,13 @@ void populate_usb_scanners (GHashTable* scanners) umax = g_list_append (umax, g_strdup ("0230")); g_hash_table_insert (scanners, g_strdup("1606"), - g_list_copy(umax)); + umax); GList* docketport = NULL; docketport = g_list_append (docketport, g_strdup ("4810")); g_hash_table_insert (scanners, g_strdup("1dcc"), - g_list_copy(docketport)); + docketport); GList* dell = NULL; dell = g_list_append (dell, g_strdup ("5105")); @@ -774,5 +774,5 @@ void populate_usb_scanners (GHashTable* scanners) dell = g_list_append (dell, g_strdup ("5250")); g_hash_table_insert (scanners, g_strdup("413c"), - g_list_copy(dell)); + dell); } diff --git a/src/udev-mgr.c b/src/udev-mgr.c index d110304..6749157 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -81,11 +81,11 @@ udev_mgr_init (UdevMgr* self) self->supported_usb_scanners = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - g_free); + (GDestroyNotify)g_list_free); self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - g_free); + (GDestroyNotify)g_list_free); self->scanners_present = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, -- cgit v1.2.3 From 5ba9266a7798e03013af14d4e5003725151e665e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Aug 2011 13:33:06 +0100 Subject: destroying hash tables in finalize --- src/udev-mgr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 6749157..df491aa 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -76,7 +76,6 @@ udev_mgr_init (UdevMgr* self) self->supported_usb_scanners = NULL; self->scanners_present = NULL; self->webcams_present = NULL; - g_debug ("About to create hash tables"); self->client = g_udev_client_new (subsystems); self->supported_usb_scanners = g_hash_table_new_full (g_str_hash, g_str_equal, @@ -94,7 +93,6 @@ udev_mgr_init (UdevMgr* self) g_str_equal, g_free, g_free); - g_debug ("After creating hash tables"); // load into memory all supported scanners ... populate_usb_scanners (self->supported_usb_scanners); @@ -108,7 +106,11 @@ udev_mgr_init (UdevMgr* self) static void udev_mgr_finalize (GObject *object) { - // TODO tidy up hashtables. + UdevMgr* self = UDEV_MGR (object); + g_hash_table_destroy (self->supported_scsi_scanners); + g_hash_table_destroy (self->supported_usb_scanners); + g_hash_table_destroy (self->scanners_present); + g_hash_table_destroy (self->webcams_present); G_OBJECT_CLASS (udev_mgr_parent_class)->finalize (object); } -- cgit v1.2.3 From c1ee13d61894607f7e916d1041c1db0b2c99c93a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Aug 2011 17:25:19 +0100 Subject: trace around this seg fault --- src/device-menu-mgr.c | 25 ++++++++++++++++++++----- src/user-menu-mgr.c | 20 ++++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 1be113c..9706598 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -81,8 +81,11 @@ static void machine_sleep_with_context (DeviceMenuMgr* self, gchar* type); static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, - gchar * type); - + gchar * type); + +static void show_simple_scan (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, guint timestamp, @@ -460,6 +463,18 @@ show_system_settings_with_context (DbusmenuMenuitem * mi, g_free(control_centre_command); } +static void show_simple_scan (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("simple-scan", &error)) + { + g_warning("Unable to launch simple-scan: %s", error->message); + g_error_free(error); + } +} + static void device_menu_mgr_build_static_items (DeviceMenuMgr* self) { @@ -550,14 +565,14 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) _("Scanners")); g_signal_connect (G_OBJECT(scanners_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), - "scanners"); + G_CALLBACK(show_simple_scan), + NULL); dbusmenu_menuitem_child_add_position (self->root_item, scanners_menuitem, 8); dbusmenu_menuitem_property_set_bool (scanners_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, - FALSE); + TRUE); webcam_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (webcam_menuitem, diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 611bcc7..bf3b77f 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -149,10 +149,9 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) for (u = users; u != NULL; u = g_list_next (u)) { user = u->data; + g_debug ("%p: %s", user, user->real_name); user->service = self->users_dbus_interface; - g_debug ("%i %s", (gint)user->uid, user->user_name); - if (g_strcmp0(user->user_name, "guest") == 0) { /* Check to see if the guest has sessions and so therefore should get a check mark. */ @@ -171,13 +170,26 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { mi = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (mi, + DBUSMENU_MENUITEM_PROP_TYPE, + USER_ITEM_TYPE); if (user->real_name_conflict) { gchar * conflictedname = g_strdup_printf("%s (%s)", user->real_name, user->user_name); dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, conflictedname); g_free(conflictedname); } else { - dbusmenu_menuitem_property_set (mi, USER_ITEM_PROP_NAME, user->real_name); + //g_debug ("%i %s", (gint)user->uid, user->real_name); + //g_debug ("users uid = %i", (gint)user->uid); + //g_debug ("users real name = %s", user->real_name); + if (user == NULL){ + g_debug ("USER pointer is NULL"); + return; + } + g_debug ("%p: %s", user, user->real_name); + + dbusmenu_menuitem_property_set (mi, + USER_ITEM_PROP_NAME, + user->real_name); } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, -- cgit v1.2.3 From 8cf9d6a47573502d4f32b002129c81a3026447f0 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 4 Aug 2011 17:53:28 +0100 Subject: correct callbacks in place for scanners and webcams --- src/device-menu-mgr.c | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 9706598..e9143f7 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -83,9 +83,13 @@ static void show_system_settings_with_context (DbusmenuMenuitem * mi, guint timestamp, gchar * type); -static void show_simple_scan (DbusmenuMenuitem * mi, - guint timestamp, - gchar * type); +static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); +static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type); + static void machine_sleep_from_hibernate (DbusmenuMenuitem * mi, guint timestamp, @@ -463,15 +467,40 @@ show_system_settings_with_context (DbusmenuMenuitem * mi, g_free(control_centre_command); } -static void show_simple_scan (DbusmenuMenuitem * mi, - guint timestamp, - gchar * type) +// TODO: refactor both of these down to the one method. +static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) { GError * error = NULL; if (!g_spawn_command_line_async("simple-scan", &error)) { g_warning("Unable to launch simple-scan: %s", error->message); g_error_free(error); + if (!g_spawn_command_line_async("software-center simple-scan", &error)) + { + g_warning ("Unable to launch software-centre simple-scan: %s", + error->message); + g_error_free(error); + } + } +} + +static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, + guint timestamp, + gchar * type) +{ + GError * error = NULL; + if (!g_spawn_command_line_async("cheese", &error)) + { + g_warning("Unable to launch cheese: %s", error->message); + g_error_free(error); + if (!g_spawn_command_line_async("software-center cheese", &error)) + { + g_warning ("Unable to launch software-centre cheese: %s", + error->message); + g_error_free(error); + } } } @@ -565,14 +594,14 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) _("Scanners")); g_signal_connect (G_OBJECT(scanners_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_simple_scan), + G_CALLBACK(device_menu_mgr_show_simple_scan), NULL); dbusmenu_menuitem_child_add_position (self->root_item, scanners_menuitem, 8); dbusmenu_menuitem_property_set_bool (scanners_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, - TRUE); + FALSE); webcam_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (webcam_menuitem, @@ -580,12 +609,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self) _("Webcam")); g_signal_connect (G_OBJECT(webcam_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_system_settings_with_context), - "Webcam"); + G_CALLBACK(device_menu_mgr_show_cheese), + NULL); dbusmenu_menuitem_child_add_position (self->root_item, webcam_menuitem, 10); - //tmp dbusmenu_menuitem_property_set_bool (webcam_menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); -- cgit v1.2.3 From 7ccf396039ca441059913c9caa407d4662ed7b19 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 5 Aug 2011 10:20:17 +0100 Subject: cater for scsi type 3 and 6 devices --- src/udev-mgr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index df491aa..cbb7dcb 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -277,6 +277,24 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action) { + 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){ + gchar* random_scanner_name = g_strdup_printf("%p--scanner", self); + g_hash_table_insert (self->scanners_present, + g_strdup(random_scanner_name), + g_strdup("Scanner")); + g_free (random_scanner_name); + udev_mgr_update_menuitems (self); + return; + } + + // We only care about type 3 for the special cases below + if (g_strcmp0 (type, "3") != 0){ + return; + } + const gchar* vendor = NULL; vendor = g_udev_device_get_property (device, "VENDOR"); -- cgit v1.2.3 From 3edbdc147bcf6ce1b94e6156e318728c41abea2a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 5 Aug 2011 16:09:59 +0100 Subject: watch for the restart flag and change the menuitem's title --- src/apt-transaction.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index 78a0ff2..647f4ba 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -185,8 +185,6 @@ apt_transaction_receive_signal (GDBusProxy * proxy, g_variant_get (value, "(asasasasasasas)", &install, &reinstall, &remove, &purge, &upgrade, &downgrade, &keep); - //g_debug ("Seemed to uppack dependencies without any warnings"); - //g_debug ("Upgrade quantity : %u", g_strv_length(upgrade)); gboolean upgrade_needed = (g_strv_length(upgrade) > 0) || (g_strv_length(install) > 0) || (g_strv_length(reinstall) > 0) || -- cgit v1.2.3 From 853ad495b863c179792044f1a74e8556d04e32db Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 9 Aug 2011 09:59:20 +0100 Subject: and the actual code --- src/apt-watcher.c | 20 ++++++++++++++++---- src/indicator-session.c | 5 +++++ src/session-dbus.c | 22 ++++++++++++++++++++++ src/session-dbus.h | 2 +- src/session-dbus.xml | 3 +-- 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 285eb81..72a63ac 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -266,11 +266,23 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, _("Updates Installing…")); } else if (state == FINISHED){ - dbusmenu_menuitem_property_set (self->apt_item, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Software Up to Date")); + GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy, + "RebootRequired"); + gboolean reboot; + g_variant_get (reboot_result, "b", &reboot); + if (reboot == FALSE){ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Software Up to Date")); + } + else{ + dbusmenu_menuitem_property_set (self->apt_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Reboot Required")); + session_dbus_restart_required (self->session_dbus_interface); + } g_object_unref (G_OBJECT(self->current_transaction)); - self->current_transaction = NULL; + self->current_transaction = NULL; } self->current_state = state; } diff --git a/src/indicator-session.c b/src/indicator-session.c index d7155f6..bfe0b75 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -491,6 +491,7 @@ receive_signal (GDBusProxy * proxy, g_signal_emit_by_name ((gpointer)self, "entry-added", &self->users); + } else{ g_signal_emit_by_name ((gpointer)self, @@ -498,6 +499,10 @@ receive_signal (GDBusProxy * proxy, &self->users); } } + else if (g_strcmp0(signal_name, "RebootRequired") == 0) { + // TODO waiting on design to give me a name. + self->devices.image = indicator_image_helper (ICON_DEFAULT); + } } diff --git a/src/session-dbus.c b/src/session-dbus.c index 9aa75ef..1cf73ac 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -293,3 +293,25 @@ session_dbus_set_user_menu_visibility (SessionDbus* session, } } } + +void session_dbus_restart_required (SessionDbus* session) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); + GError * error = NULL; + + if (priv->bus != NULL) { + g_dbus_connection_emit_signal (priv->bus, + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "RebootRequired", + NULL, + &error); + + if (error != NULL) { + g_warning("Unable to send reboot-required signal: %s", error->message); + g_error_free(error); + } + } + +} diff --git a/src/session-dbus.h b/src/session-dbus.h index 45ebae2..4dc340a 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -51,7 +51,7 @@ SessionDbus * session_dbus_new (void); void session_dbus_set_name (SessionDbus * session, const gchar * name); void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name); void session_dbus_set_user_menu_visibility (SessionDbus* session, gboolean visible); - +void session_dbus_restart_required (SessionDbus* session); G_END_DECLS #endif diff --git a/src/session-dbus.xml b/src/session-dbus.xml index c42aca8..fd1859f 100644 --- a/src/session-dbus.xml +++ b/src/session-dbus.xml @@ -17,8 +17,7 @@ - - + -- cgit v1.2.3 From 014e2b2a3582f3e823e61e23d391c68b474e16b4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 9 Aug 2011 11:32:05 +0100 Subject: fixed memory leaks --- src/udev-mgr.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index cbb7dcb..5ac286e 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -45,9 +45,14 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action); +static void udev_mgr_cleanup_lists(gpointer data, gpointer self); +static void udev_mgr_cleanup_entries(gpointer data, gpointer self); + + static void debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action); + struct _UdevMgr { @@ -80,11 +85,11 @@ udev_mgr_init (UdevMgr* self) self->supported_usb_scanners = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - (GDestroyNotify)g_list_free); + (GDestroyNotify)udev_mgr_cleanup_lists); self->supported_scsi_scanners = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - (GDestroyNotify)g_list_free); + (GDestroyNotify)udev_mgr_cleanup_lists); self->scanners_present = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, @@ -103,6 +108,21 @@ udev_mgr_init (UdevMgr* self) self); } +static void +udev_mgr_cleanup_lists(gpointer data, gpointer self) +{ + GList* scanners = (GList*)data; + g_list_foreach (scanners, udev_mgr_cleanup_entries, NULL); + g_list_free(scanners); +} + +static void +udev_mgr_cleanup_entries(gpointer data, gpointer self) +{ + gchar* entry = (gchar*)data; + g_free(entry); +} + static void udev_mgr_finalize (GObject *object) { @@ -283,9 +303,8 @@ static void udev_mgr_handle_scsi_device (UdevMgr* self, if (g_strcmp0 (type, "6") == 0){ gchar* random_scanner_name = g_strdup_printf("%p--scanner", self); g_hash_table_insert (self->scanners_present, - g_strdup(random_scanner_name), + random_scanner_name, g_strdup("Scanner")); - g_free (random_scanner_name); udev_mgr_update_menuitems (self); return; } -- cgit v1.2.3 From ddd4474c7cf18706f5ea43e0319488f4d0358226 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 9 Aug 2011 12:35:18 +0100 Subject: segfault found and fixed --- src/udev-mgr.c | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index 5ac286e..e3328ec 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -151,7 +151,7 @@ udevice_mgr_device_list_iterator (gpointer data, gpointer userdata) GUdevDevice* device = G_UDEV_DEVICE (data); - const gchar* subsystem = NULL; + const gchar* subsystem = NULL; subsystem = g_udev_device_get_subsystem (device); if (g_strcmp0 (subsystem, "usb") == 0){ @@ -421,31 +421,36 @@ UdevMgr* udev_mgr_new (DbusmenuMenuitem* scanner, mgr->webcam_item = webcam; // Check for USB devices - GList* usb_devices_available = g_udev_client_query_by_subsystem (mgr->client, - usb_subsystem); - g_list_foreach (usb_devices_available, - udevice_mgr_device_list_iterator, - mgr); - - g_list_free (usb_devices_available); - + GList* usb_devices_available = NULL; + usb_devices_available = g_udev_client_query_by_subsystem (mgr->client, + usb_subsystem); + if (usb_devices_available != NULL){ + g_list_foreach (usb_devices_available, + udevice_mgr_device_list_iterator, + mgr); + + g_list_free (usb_devices_available); + } // Check for webcams - GList* video_devices_available = g_udev_client_query_by_subsystem (mgr->client, - video4linux_subsystem); - g_list_foreach (video_devices_available, - udevice_mgr_device_list_iterator, - mgr); - - g_list_free (video_devices_available); - + GList* video_devices_available = NULL; + video_devices_available = g_udev_client_query_by_subsystem (mgr->client, + video4linux_subsystem); + if (video_devices_available != NULL){ + g_list_foreach (video_devices_available, + udevice_mgr_device_list_iterator, + mgr); + + g_list_free (video_devices_available); + } // Check for SCSI devices - GList* scsi_devices_available = g_udev_client_query_by_subsystem (mgr->client, - scsi_subsystem); - g_list_foreach (scsi_devices_available, - udevice_mgr_device_list_iterator, - mgr); - - g_list_free (usb_devices_available); - + GList* scsi_devices_available = NULL; + scsi_devices_available = g_udev_client_query_by_subsystem (mgr->client, + scsi_subsystem); + if (scsi_devices_available != NULL){ + g_list_foreach (scsi_devices_available, + udevice_mgr_device_list_iterator, + mgr); + g_list_free (scsi_devices_available); + } return mgr; } -- cgit v1.2.3 From 66ea570beda05cf7c494198f7c1d51d4c4f73a98 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Aug 2011 18:11:27 +0100 Subject: updated the ignores --- .bzrignore | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/.bzrignore b/.bzrignore index b9fc0bc..2985cbf 100644 --- a/.bzrignore +++ b/.bzrignore @@ -59,3 +59,143 @@ src/gen-session-dbus.xml.h src/upower-client.h src/display-manager-client.h src/consolekit-session-client.h +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +indicator-session-0.2.93.tar.gz +indicator-session-0.2.93.tar.gz.asc +indicator-session-0.2.94.tar.gz +install-sh +libtool +ltmain.sh +missing +mkinstalldirs +stamp-h1 +data/Makefile +data/Makefile.in +data/extra-sessions/Makefile +data/extra-sessions/Makefile.in +data/extra-sessions/classic-desktop.desktop +data/icons/Makefile +data/icons/Makefile.in +data/icons/16x16/Makefile +data/icons/16x16/Makefile.in +data/icons/16x16/actions/Makefile +data/icons/16x16/actions/Makefile.in +data/icons/16x16/status/Makefile +data/icons/16x16/status/Makefile.in +data/icons/22x22/Makefile +data/icons/22x22/Makefile.in +data/icons/22x22/actions/Makefile +data/icons/22x22/actions/Makefile.in +data/icons/22x22/status/Makefile +data/icons/22x22/status/Makefile.in +data/icons/24x24/Makefile +data/icons/24x24/Makefile.in +data/icons/24x24/actions/Makefile +data/icons/24x24/actions/Makefile.in +data/icons/24x24/status/Makefile +data/icons/24x24/status/Makefile.in +data/icons/32x32/Makefile +data/icons/32x32/Makefile.in +data/icons/32x32/actions/Makefile +data/icons/32x32/actions/Makefile.in +data/icons/32x32/status/Makefile +data/icons/32x32/status/Makefile.in +data/icons/scalable/Makefile +data/icons/scalable/Makefile.in +data/icons/scalable/actions/Makefile +data/icons/scalable/actions/Makefile.in +data/icons/scalable/status/Makefile +data/icons/scalable/status/Makefile.in +po/.intltool-merge-cache +po/Makefile +po/Makefile.in +po/Makefile.in.in +po/POTFILES +po/am.gmo +po/ar.gmo +po/ast.gmo +po/az.gmo +po/be.gmo +po/bg.gmo +po/bn.gmo +po/br.gmo +po/bs.gmo +po/ca.gmo +po/crh.gmo +po/cs.gmo +po/csb.gmo +po/cv.gmo +po/da.gmo +po/de.gmo +po/el.gmo +po/en_AU.gmo +po/en_CA.gmo +po/en_GB.gmo +po/eo.gmo +po/es.gmo +po/et.gmo +po/eu.gmo +po/fa.gmo +po/fi.gmo +po/fr.gmo +po/gl.gmo +po/gu.gmo +po/he.gmo +po/hi.gmo +po/hr.gmo +po/hu.gmo +po/id.gmo +po/is.gmo +po/it.gmo +po/ja.gmo +po/kk.gmo +po/kn.gmo +po/ko.gmo +po/ku.gmo +po/lb.gmo +po/lt.gmo +po/lv.gmo +po/mr.gmo +po/ms.gmo +po/nb.gmo +po/nl.gmo +po/nn.gmo +po/oc.gmo +po/pa.gmo +po/pl.gmo +po/pt.gmo +po/pt_BR.gmo +po/ro.gmo +po/ru.gmo +po/si.gmo +po/sk.gmo +po/sl.gmo +po/sq.gmo +po/sr.gmo +po/stamp-it +po/sv.gmo +po/te.gmo +po/th.gmo +po/tr.gmo +po/ug.gmo +po/uk.gmo +po/vi.gmo +po/zh_CN.gmo +po/zh_HK.gmo +po/zh_TW.gmo +src/Makefile +modified: +.bzrignore +src/libsession_la-user-widget.lo -- cgit v1.2.3 From e0e129c43f2e10c465ea88cc3f95c615e4610dc5 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Aug 2011 19:10:55 +0100 Subject: add the restart to the shutdown dialog --- src/dialog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dialog.c b/src/dialog.c index d38f8bf..299f954 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -225,6 +225,12 @@ logout_dialog_new (LogoutDialogType type) button_text, GTK_RESPONSE_OK, NULL); } + + if (type == LOGOUT_DIALOG_TYPE_SHUTDOWN){ + const gchar * restart_text; + restart_text = g_dpgettext2 (NULL, "button", button_strings[LOGOUT_DIALOG_TYPE_RESTART]); + gtk_dialog_add_button (GTK_DIALOG(dialog), restart_text, GTK_RESPONSE_HELP); + } gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); -- cgit v1.2.3 From fb32494de9b55663cec088ade6967da349c0cac7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Aug 2011 19:15:18 +0100 Subject: bumped for new release --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e32ac4a..19cc4bc 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.3.0) +AM_INIT_AUTOMAKE(indicator-session, 0.3.1) AM_MAINTAINER_MODE -- cgit v1.2.3 From 7ef5e38e753b2201a6a44be1f760715c129cd7f8 Mon Sep 17 00:00:00 2001 From: Ken VanDine Date: Wed, 10 Aug 2011 16:41:57 -0400 Subject: releasing version 0.3.1-0ubuntu1 --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a52a395..3d23d59 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -indicator-session (0.3.1-0ubuntu1) UNRELEASED; urgency=low +indicator-session (0.3.1-0ubuntu1) oneiric; urgency=low * New upstream release. - restart is missing from SessionMenu (LP: #815077) -- cgit v1.2.3 From f3210466e73e951530ce0996dbfebdfec523a201 Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Thu, 11 Aug 2011 17:09:03 +0200 Subject: debian/rules: run intltool-update to update the translations template (lp: #820705) --- debian/changelog | 7 +++++++ debian/rules | 2 ++ 2 files changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 3d23d59..5a6d3bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +indicator-session (0.3.1-0ubuntu2) UNRELEASED; urgency=low + + * debian/rules: run intltool-update to update the translations template + (lp: #820705) + + -- Sebastien Bacher Thu, 11 Aug 2011 17:05:25 +0200 + indicator-session (0.3.1-0ubuntu1) oneiric; urgency=low * New upstream release. diff --git a/debian/rules b/debian/rules index 8d716bc..bee840d 100755 --- a/debian/rules +++ b/debian/rules @@ -22,3 +22,5 @@ common-install-arch:: find debian/tmp -name \*.la -delete find debian/tmp -name \*.a -delete find debian/tmp -name classic-desktop.sh | xargs chmod +x + cd po; intltool-update --pot --verbose + -- cgit v1.2.3 From 7d476f1a4e0717678d5b1d86f022948f8959fa57 Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Thu, 11 Aug 2011 17:09:16 +0200 Subject: releasing version 0.3.1-0ubuntu2 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5a6d3bc..8d44081 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -indicator-session (0.3.1-0ubuntu2) UNRELEASED; urgency=low +indicator-session (0.3.1-0ubuntu2) oneiric; urgency=low * debian/rules: run intltool-update to update the translations template (lp: #820705) - -- Sebastien Bacher Thu, 11 Aug 2011 17:05:25 +0200 + -- Sebastien Bacher Thu, 11 Aug 2011 17:09:08 +0200 indicator-session (0.3.1-0ubuntu1) oneiric; urgency=low -- cgit v1.2.3 From 95b5c6328bbee9bda1473d8c8af3bbed8eba67f8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Aug 2011 13:23:35 +0100 Subject: fixed the misguided software available flag --- src/apt-transaction.c | 17 ++++++++++++----- src/apt-watcher.c | 7 +++---- src/indicator-session.c | 6 ++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/apt-transaction.c b/src/apt-transaction.c index 647f4ba..be1c57b 100644 --- a/src/apt-transaction.c +++ b/src/apt-transaction.c @@ -185,11 +185,18 @@ apt_transaction_receive_signal (GDBusProxy * proxy, g_variant_get (value, "(asasasasasasas)", &install, &reinstall, &remove, &purge, &upgrade, &downgrade, &keep); - gboolean upgrade_needed = (g_strv_length(upgrade) > 0) || - (g_strv_length(install) > 0) || - (g_strv_length(reinstall) > 0) || - (g_strv_length(remove) > 0) || - (g_strv_length(purge) > 0); + /* + g_debug ("upgrade package length %i", g_strv_length(upgrade)); + g_debug ("install package length %i", g_strv_length(install)); + g_debug ("reinstall package length %i", g_strv_length(reinstall)); + g_debug ("remove package length %i", g_strv_length(remove)); + g_debug ("purge package length %i", g_strv_length(purge)); + */ + gboolean upgrade_needed = (g_strv_length(upgrade) > 1) || + (g_strv_length(install) > 1) || + (g_strv_length(reinstall) > 1) || + (g_strv_length(remove) > 1) || + (g_strv_length(purge) > 1); if (upgrade_needed == TRUE){ current_state = UPDATES_AVAILABLE; } diff --git a/src/apt-watcher.c b/src/apt-watcher.c index 72a63ac..7d706a0 100644 --- a/src/apt-watcher.c +++ b/src/apt-watcher.c @@ -281,8 +281,9 @@ apt_watcher_transaction_state_update_cb (AptTransaction* trans, _("Reboot Required")); session_dbus_restart_required (self->session_dbus_interface); } + g_debug ("Finished with a reboot value of %i", reboot); g_object_unref (G_OBJECT(self->current_transaction)); - self->current_transaction = NULL; + self->current_transaction = NULL; } self->current_state = state; } @@ -327,9 +328,7 @@ static void apt_watcher_signal_cb ( GDBusProxy* proxy, self->current_transaction = apt_transaction_new (input, REAL); g_signal_connect (G_OBJECT(self->current_transaction), "state-update", - G_CALLBACK(apt_watcher_transaction_state_update_cb), self); - - + G_CALLBACK(apt_watcher_transaction_state_update_cb), self); } } g_variant_unref (parameters); diff --git a/src/indicator-session.c b/src/indicator-session.c index bfe0b75..f6727d9 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -163,13 +163,11 @@ indicator_session_init (IndicatorSession *self) } self->users.label = GTK_LABEL (gtk_label_new (NULL)); - // Only show once we have a valid username - // gtk_widget_hide (GTK_WIDGET(self->users.label)); // devices self->devices.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); - self->devices.image = indicator_image_helper (ICON_DEFAULT); + self->devices.image = indicator_image_helper ("system-devices-panel"); gtk_widget_show (GTK_WIDGET(self->devices.menu)); gtk_widget_show (GTK_WIDGET(self->devices.image)); @@ -501,7 +499,7 @@ receive_signal (GDBusProxy * proxy, } else if (g_strcmp0(signal_name, "RebootRequired") == 0) { // TODO waiting on design to give me a name. - self->devices.image = indicator_image_helper (ICON_DEFAULT); + self->devices.image = indicator_image_helper ("system-devices-alert-panel"); } } -- cgit v1.2.3 From 25abede4d0251f965b5f8b879d26c86129a11453 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Aug 2011 13:48:51 +0100 Subject: put guest item in place and fixed ticked icon on user menu --- src/udev-mgr.c | 6 ++-- src/user-menu-mgr.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/user-widget.c | 26 +++++++++-------- 3 files changed, 96 insertions(+), 17 deletions(-) diff --git a/src/udev-mgr.c b/src/udev-mgr.c index e3328ec..f66d862 100644 --- a/src/udev-mgr.c +++ b/src/udev-mgr.c @@ -254,7 +254,7 @@ debug_device (UdevMgr* self, GUdevDevice* device, UdevMgrDeviceAction action) { - const gchar* vendor; + /*const gchar* vendor; const gchar* product; const gchar* number; const gchar* name; @@ -269,7 +269,7 @@ debug_device (UdevMgr* self, g_strdup(product), g_strdup(number), g_strdup(name)); - + const gchar *const *list; const gchar *const *iter; char propstr[500]; @@ -290,7 +290,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, diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index bf3b77f..6f9f53a 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -26,9 +26,12 @@ with this program. If not, see . #include "lock-helper.h" #include "users-service-dbus.h" +#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch" + static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; + struct _UserMenuMgr { GObject parent_instance; @@ -56,6 +59,11 @@ static void user_change (UsersServiceDbus *service, gpointer user_data); static void ensure_gconf_client (); +static gboolean check_guest_session (void); +static void activate_guest_session (DbusmenuMenuitem * mi, + guint timestamp, + gpointer user_data); + G_DEFINE_TYPE (UserMenuMgr, user_menu_mgr, G_TYPE_OBJECT); @@ -121,6 +129,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) /* Build all of the user switching items */ if (can_activate == TRUE) { + if (check_new_session ()){ switch_menuitem = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (switch_menuitem, @@ -134,8 +143,33 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_new_session), self->users_dbus_interface); + } + + if (check_guest_session ()) + { + g_debug ("ADDING GUEST SESSION"); + guest_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (guest_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + USER_ITEM_TYPE); + dbusmenu_menuitem_property_set (guest_mi, + USER_ITEM_PROP_NAME, + _("Guest Session")); + dbusmenu_menuitem_property_set_bool (guest_mi, + USER_ITEM_PROP_LOGGED_IN, + FALSE); + dbusmenu_menuitem_child_append (self->root_item, guest_mi); + g_signal_connect (G_OBJECT (guest_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (activate_guest_session), + self); + users_service_dbus_set_guest_item (self->users_dbus_interface, + guest_mi); } - + else{ + g_debug ("NOT ADDING GUEST SESSION"); + } + GList * users = NULL; users = users_service_dbus_get_user_list (self->users_dbus_interface); self->user_count = g_list_length(users); @@ -193,7 +227,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) } dbusmenu_menuitem_property_set_bool (mi, USER_ITEM_PROP_LOGGED_IN, - user->sessions != NULL); + /*user->sessions != NULL*/FALSE); if (user->icon_file != NULL && user->icon_file[0] != '\0') { dbusmenu_menuitem_property_set(mi, USER_ITEM_PROP_ICON, user->icon_file); } else { @@ -354,6 +388,49 @@ user_mgr_get_root_item (UserMenuMgr* self) return self->root_item; } +/* Checks to see if we should show the guest suession item */ +static gboolean +check_guest_session (void) +{ + if (geteuid() < 500) { + /* System users shouldn't have guest account shown. Mosly + this would be the case of the guest user itself. */ + return FALSE; + } + if (!g_file_test(GUEST_SESSION_LAUNCHER, G_FILE_TEST_IS_EXECUTABLE)) { + /* It doesn't appear that the Guest session stuff is + installed. So let's not use it then! */ + return FALSE; + } + + return TRUE; +} + +/* Called when someone clicks on the guest session item. */ +static void +activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data) +{ + GError * error = NULL; + UserData *user = (UserData *)user_data; + UsersServiceDbus *service = user->service; + + lock_if_possible(); + + if (dbusmenu_menuitem_property_get_bool(mi, USER_ITEM_PROP_LOGGED_IN)) { + if (users_service_dbus_activate_guest_session(service)) { + return; + } + g_warning("Unable to activate guest session, falling back to command line activation."); + } + + if (!g_spawn_command_line_async(GUEST_SESSION_LAUNCHER " --no-lock", &error)) { + g_warning("Unable to start guest session: %s", error->message); + g_error_free(error); + } + + return; +} + /* * Clean Entry Point diff --git a/src/user-widget.c b/src/user-widget.c index 9b046c5..6495e80 100644 --- a/src/user-widget.c +++ b/src/user-widget.c @@ -126,8 +126,6 @@ user_widget_init (UserWidget *self) priv->user_name = gtk_label_new (""); priv->container = gtk_hbox_new (FALSE, 0); - // TODO: - // Delete tick icon and draw primitively. priv->tick_icon = gtk_image_new_from_icon_name ("account-logged-in", GTK_ICON_SIZE_MENU); gtk_misc_set_alignment(GTK_MISC(priv->tick_icon), 1.0, 0.5); @@ -151,6 +149,10 @@ user_widget_init (UserWidget *self) gtk_widget_show_all (priv->container); gtk_container_add (GTK_CONTAINER (self), priv->container); + gtk_widget_show_all (priv->tick_icon); + gtk_widget_set_no_show_all (priv->tick_icon, TRUE); + gtk_widget_hide (priv->tick_icon); + // Fetch the drawing context. #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect_after (GTK_WIDGET(self), "draw", @@ -178,11 +180,6 @@ user_widget_finalize (GObject *object) G_OBJECT_CLASS (user_widget_parent_class)->finalize (object); } -/** - * We override the expose method to enable primitive drawing of the - * empty album art image and rounded rectangles on the album art. - */ - #if GTK_CHECK_VERSION(3, 0, 0) // Draw the radio dot and/or green check mark @@ -317,11 +314,16 @@ user_widget_set_twin_item (UserWidget* self, gtk_label_set_label (GTK_LABEL (priv->user_name), dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); - //if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { - // gtk_widget_show(priv->tick_icon); - //} else { - gtk_widget_show(priv->tick_icon); - //} + if (dbusmenu_menuitem_property_get_bool (twin_item, USER_ITEM_PROP_LOGGED_IN)) { + g_debug ("%s USER HAS ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_show(priv->tick_icon); + } + else { + g_debug ("%s USER DOESN'T HAVE ACTIVE SESSIONS", + dbusmenu_menuitem_property_get (twin_item, USER_ITEM_PROP_NAME)); + gtk_widget_hide(priv->tick_icon); + } g_debug("Using user icon for '%s' from file: %s", dbusmenu_menuitem_property_get(twin_item, USER_ITEM_PROP_NAME), icon_name); -- cgit v1.2.3 From ce792a6c67408779b7741194a8aa19caa86e0ef8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Aug 2011 18:41:49 +0100 Subject: added some trace to the add sessions for user method --- src/users-service-dbus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 83edaa3..07de28e 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -556,7 +556,11 @@ static void add_sessions_for_user (UsersServiceDbus *self, UserData *user) { - g_return_if_fail(IS_USERS_SERVICE_DBUS(self)); + g_return_if_fail (IS_USERS_SERVICE_DBUS(self)); + + g_debug ("!!!!!!!!!! - add_sessions_for_user %i %s", + (int)user->uid, user->user_name); + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); GError *error; GPtrArray *sessions; -- cgit v1.2.3 From 4e71b293536e2b3091d323bd92f24538bb41d1a9 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 17 Aug 2011 16:21:53 -0400 Subject: don't start/lock the screensaver from the login screen --- src/lock-helper.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/lock-helper.c b/src/lock-helper.c index 9b15070..4c91aa5 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -20,12 +20,12 @@ with this program. If not, see . */ #include -#include +#include #include #include "lock-helper.h" -#define GCONF_DIR "/apps/gnome-screensaver" -#define GCONF_KEY GCONF_DIR "/lock_enabled" +#define SCREENSAVER_SCHEMA "org.gnome.desktop.screensaver" +#define SCREENSAVER_LOCK_ENABLED_KEY "lock-enabled" static DBusGProxy * gss_proxy = NULL; static GMainLoop * gss_mainloop = NULL; @@ -34,7 +34,7 @@ static DBusGProxyCall * cookie_call = NULL; static gboolean is_guest = FALSE; -static GConfClient * gconf_client = NULL; +static GSettings * settings = NULL; void build_gss_proxy (void); @@ -131,11 +131,11 @@ will_lock_screen (void) return FALSE; } - if (gconf_client == NULL) { - gconf_client = gconf_client_get_default(); + if (settings == NULL) { + settings = g_settings_new (SCREENSAVER_SCHEMA); } - return gconf_client_get_bool (gconf_client, GCONF_KEY, NULL); + return g_settings_get_boolean (settings, SCREENSAVER_LOCK_ENABLED_KEY); } /* When the screensave go active, if we've got a mainloop @@ -150,11 +150,22 @@ gss_active_changed (DBusGProxy * proxy, gboolean active, gpointer data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /* Build the gss proxy and set up it's signals */ void build_gss_proxy (void) { if (gss_proxy == NULL) { + if (get_greeter_mode ()) + return; /* Don't start/lock the screensaver from the login screen */ + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); g_return_if_fail(session_bus != NULL); -- cgit v1.2.3 From f964233610d587af1ef67dd7fa5db84d7cc9ae3c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Aug 2011 15:53:51 -0500 Subject: Updated to DBus interface files currently in ConsoleKit and added the seat files as well --- src/Makefile.am | 21 +- src/consolekit-manager.xml | 353 ----------------------- src/consolekit-session.xml | 435 ----------------------------- src/org.freedesktop.ConsoleKit.Manager.xml | 353 +++++++++++++++++++++++ src/org.freedesktop.ConsoleKit.Seat.xml | 164 +++++++++++ src/org.freedesktop.ConsoleKit.Session.xml | 435 +++++++++++++++++++++++++++++ 6 files changed, 967 insertions(+), 794 deletions(-) delete mode 100644 src/consolekit-manager.xml delete mode 100644 src/consolekit-session.xml create mode 100644 src/org.freedesktop.ConsoleKit.Manager.xml create mode 100644 src/org.freedesktop.ConsoleKit.Seat.xml create mode 100644 src/org.freedesktop.ConsoleKit.Session.xml diff --git a/src/Makefile.am b/src/Makefile.am index 36a1d1f..3bfd790 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,19 +25,26 @@ libsession_la_CFLAGS = \ libsession_la_LIBADD = $(APPLET_LIBS) libsession_la_LDFLAGS = -module -avoid-version -consolekit-manager-client.h: $(srcdir)/consolekit-manager.xml +consolekit-manager-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml dbus-binding-tool \ --prefix=_consolekit_manager_client \ --mode=glib-client \ --output=consolekit-manager-client.h \ - $(srcdir)/consolekit-manager.xml + $(srcdir)/org.freedesktop.ConsoleKit.Manager.xml -consolekit-session-client.h: $(srcdir)/consolekit-session.xml +consolekit-seat-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + dbus-binding-tool \ + --prefix=_consolekit_seat_client \ + --mode=glib-client \ + --output=consolekit-seat-client.h \ + $(srcdir)/org.freedesktop.ConsoleKit.Seat.xml + +consolekit-session-client.h: $(srcdir)/org.freedesktop.ConsoleKit.Session.xml dbus-binding-tool \ --prefix=_consolekit_session_client \ --mode=glib-client \ --output=consolekit-session-client.h \ - $(srcdir)/consolekit-session.xml + $(srcdir)/org.freedesktop.ConsoleKit.Session.xml display-manager-client.h: $(srcdir)/display-manager.xml dbus-binding-tool \ @@ -143,6 +150,7 @@ gtk_logout_helper_LDADD = \ BUILT_SOURCES = \ consolekit-manager-client.h \ + consolekit-seat-client.h \ consolekit-session-client.h \ display-manager-client.h \ gen-session-dbus.xml.c \ @@ -152,8 +160,9 @@ BUILT_SOURCES = \ accounts-service-user-client.h EXTRA_DIST = \ - consolekit-manager.xml \ - consolekit-session.xml \ + org.freedesktop.ConsoleKit.Manager.xml \ + org.freedesktop.ConsoleKit.Seat.xml \ + org.freedesktop.ConsoleKit.Session.xml \ display-manager.xml \ session-dbus.xml \ upower.xml \ diff --git a/src/consolekit-manager.xml b/src/consolekit-manager.xml deleted file mode 100644 index f903b55..0000000 --- a/src/consolekit-manager.xml +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - This method initiates a request to restart (ie. reboot) the computer system. - - - - - - - - - - - - - - This method initiates a request to stop (ie. shutdown) the computer system. - - - - - - - - - - - - - - The secret cookie that is used to identify the new session - - - - - This method requests that a new Session - be created for the calling process. The properties of this new Session are set automatically - from information collected about the calling process. - - This new session exists until the calling process disconnects from the system bus or - calls CloseSession(). - - It is the responsibility of the calling process to set the environment variable - XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only - be made available to child processes of the caller so that they may be identified - as members of this session. - - See this simple example: - - DBusError error; - DBusMessage *message; - DBusMessage *reply; - - message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", - "/org/freedesktop/ConsoleKit/Manager", - "org.freedesktop.ConsoleKit.Manager", - "OpenSession"); - if (message == NULL) { - goto out; - } - - dbus_error_init (&error); - reply = dbus_connection_send_with_reply_and_block (connector->connection, - message, - -1, - &error); - if (reply == NULL) { - goto out; - } - - dbus_error_init (&error); - if (! dbus_message_get_args (reply, - &error, - DBUS_TYPE_STRING, &cookie, - DBUS_TYPE_INVALID)) { - goto out; - } - - - - OpenSessionWithParameters() - - - - - - - An array of sets of property names and values - - - - - The secret cookie that is used to identify the new session - - - - - This method requests that a new Session - be created for the calling process. The properties of this new Session are from the - parameters provided. - - This new session exists until the calling process disconnects from the system bus or - calls CloseSession(). - - It is the responsibility of the calling process to set the environment variable - XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only - be made available to child processes of the caller so that they may be identified - as members of this session. - - See the Session properties for a list of valid parameters. - - org.freedesktop.ConsoleKit.Session - This method is restricted to privileged users by D-Bus policy. - - - - - - - The secret cookie that is used to identify the session - - - - - Whether the session was successfully closed - - - - - This method is used to close the session identified by the supplied cookie. - - The session can only be closed by the same process that opened the session. - - - - - - - - - an array of Seat IDs - - - - - This gets a list of all the Seats - that are currently present on the system. - Each Seat ID is an D-Bus object path for the object that implements the - Seat interface. - - org.freedesktop.ConsoleKit.Seat - - - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently present on the system. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - org.freedesktop.ConsoleKit.Session - - - - - - - - The secret cookie that is used to identify the session - - - - - The object identifier for the current session - - - - - Returns the session ID that is associated with the specified cookie. - - - - - - - - - The POSIX process ID - - - - - The object identifier for the current session - - - - - Attempts to determine the session ID for the specified - POSIX process ID (pid). - - - - - - - - - The object identifier for the current session - - - - - Attempts to determine the session ID that the caller belongs to. - - See this example of using dbus-send: - - dbus-send --system --dest=org.freedesktop.ConsoleKit \ - --type=method_call --print-reply --reply-timeout=2000 \ - /org/freedesktop/ConsoleKit/Manager \ - org.freedesktop.ConsoleKit.Manager.GetCurrentSession - - - - - - - - - POSIX User identification - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently open for the specified user. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - - - - - - - User identification - - - - - an array of Session IDs - - - - - This gets a list of all the Sessions - that are currently open for the specified user. - Each Session ID is an D-Bus object path for the object that implements the - Session interface. - - - - - - - - - The value of the system-idle-hint - - - - - Returns TRUE if the idle-hint - property of every open session is TRUE or if there are no open sessions. - - - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time of the last change of the system-idle-hint. - - - - - - - - - The Seat ID for the added seat - - - - - Emitted when a Seat has been added to the system. - - - - - - - - The Seat ID for the removed seat - - - - - Emitted when a Seat has been removed from the system. - - - - - - - - The value of the system-idle-hint - - - - - Emitted when the value of the system-idle-hint has changed. - - - - - - diff --git a/src/consolekit-session.xml b/src/consolekit-session.xml deleted file mode 100644 index b6e1cdb..0000000 --- a/src/consolekit-session.xml +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - - Session objects represent and store information - related to a user session. - - The properties associated with the Session - specifically refer to the properties of the "session leader". - - - - - - - Session ID - - - - Returns the ID for Session. - - - - - - - Seat ID - - - - Returns the ID for the Seat the Session is - attached to. - - org.freedesktop.ConsoleKit.Seat - - - - - - Session type - - - - - Returns the type of the session. - Warning: we haven't yet defined the allowed values for this property. - It is probably best to avoid this until we do. - - - session-type - - - - - - User ID - - - - Returns the user that the session belongs to. - - - user - - - - - - POSIX User ID - - - - Returns the POSIX user ID that the session belongs to. - - unix-user - - - - - - The value of the X11 display - - - - Returns the value of the X11 DISPLAY for this session - if one is present. - - x11-display - - - - - - The value of the X11 display device - - - - Returns the value of the display device (aka TTY) that the - X11 display for the session is connected to. If there is no x11-display set then this value - is undefined. - - x11-display-device - - - - - - The value of the display device - - - - Returns the value of the display device (aka TTY) that the - session is connected to. - - display-device - - - - - - The remote host name - - - - Returns the value of the remote host name for the session. - - - remote-host-name - - - - - - The value of the native system login session ID - - - - Returns the value of the login session ID that the - underlying system uses to enforce session boundaries. If there is no login session ID - set then this value is an empty string. - - - - - - - TRUE if the session is active, otherwise FALSE - - - - Returns whether the session is active on the Seat that - it is attached to. - If the session is not attached to a seat this value is undefined. - - - active - - - - - - TRUE if the session is local, otherwise FALSE - - - - Returns whether the session is local - FIXME: we need to come up with a concrete definition for this value. - It was originally used as a way to identify XDMCP sessions that originate - from a remote system. - - - is-local - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time that the session was opened. - - - - - - - - - - Attempt to activate the this session. In most - cases, if successful, this will cause the session to - become visible and become active on the seat that it - is attached to. - - Seat.ActivateSession() - - - - - - - This will cause a Lock - signal to be emitted for this session. - - - This method is restricted to privileged users by D-Bus policy. - Lock signal - - - - - - - This will cause an Unlock - signal to be emitted for this session. - - This can be used by login managers to unlock a session before it is - re-activated during fast-user-switching. - - - This method is restricted to privileged users by D-Bus policy. - Unlock signal - - - - - - - The value of the idle-hint - - - - - Gets the value of the idle-hint - property. - - - idle-hint - - - - - - An ISO 8601 format date-type string - - - - - Returns an ISO 8601 date-time string that corresponds to - the time of the last change of the idle-hint. - - - - - - - - - boolean value to set the idle-hint to - - - - - This may be used by the session to indicate that - it is idle. - - Use of this method is restricted to the user - that owns the session. - - - - - - - - TRUE if the session is active, otherwise FALSE - - - - - Emitted when the active property has changed. - - - - - - - the new value of idle-hint - - - - - Emitted when the idle-hint property has changed. - - - - - - - Emitted in response to a call to the Lock() method. - It is intended that the screensaver for the session should lock the screen in response to this signal. - - - - - - - Emitted in response to a call to the Unlock() method. - It is intended that the screensaver for the session should unlock the screen in response to this signal. - - - - - - - - The user assigned to the session. - - - - - - - The user assigned to the session. - - - - - - - - The type of the session. - Warning: we haven't yet defined the allowed values for this property. - It is probably best to avoid this until we do. - - - - - - - - The remote host name for the session. - - This will be set in situations where the session is - opened and controlled from a remote system. - - For example, this value will be set when the - session is created from an SSH or XDMCP connection. - - - - - - - - The display device (aka TTY) that the - session is connected to. - - - - - - - - Value of the X11 DISPLAY for this session - if one is present. - - - - - - - - - The display device (aka TTY) that the X11 display for the - session is connected to. If there is no x11-display set then - this value is undefined. - - - - - - - - - Whether the session is active on the Seat that - it is attached to. - If the session is not attached to a seat this value is undefined. - - - - - - - - - Whether the session is local - FIXME: we need to come up with a concrete definition for this value. - It was originally used as a way to identify XDMCP sessions that originate - from a remote system. - - - - - - - - - This is a hint used to indicate that the session may be idle. - - - For sessions with a x11-display set (ie. graphical - sessions), it is up to each session to delegate the - responsibility for updating this value. Typically, the - screensaver will set this. - - However, for non-graphical sessions with a display-device set - the Session object itself will periodically update this value based - on the activity detected on the display-device itself. - - - This should not be considered authoritative. - - - - - - - diff --git a/src/org.freedesktop.ConsoleKit.Manager.xml b/src/org.freedesktop.ConsoleKit.Manager.xml new file mode 100644 index 0000000..f903b55 --- /dev/null +++ b/src/org.freedesktop.ConsoleKit.Manager.xml @@ -0,0 +1,353 @@ + + + + + + + + + This method initiates a request to restart (ie. reboot) the computer system. + + + + + + + + + + + + + + This method initiates a request to stop (ie. shutdown) the computer system. + + + + + + + + + + + + + + The secret cookie that is used to identify the new session + + + + + This method requests that a new Session + be created for the calling process. The properties of this new Session are set automatically + from information collected about the calling process. + + This new session exists until the calling process disconnects from the system bus or + calls CloseSession(). + + It is the responsibility of the calling process to set the environment variable + XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only + be made available to child processes of the caller so that they may be identified + as members of this session. + + See this simple example: + + DBusError error; + DBusMessage *message; + DBusMessage *reply; + + message = dbus_message_new_method_call ("org.freedesktop.ConsoleKit", + "/org/freedesktop/ConsoleKit/Manager", + "org.freedesktop.ConsoleKit.Manager", + "OpenSession"); + if (message == NULL) { + goto out; + } + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connector->connection, + message, + -1, + &error); + if (reply == NULL) { + goto out; + } + + dbus_error_init (&error); + if (! dbus_message_get_args (reply, + &error, + DBUS_TYPE_STRING, &cookie, + DBUS_TYPE_INVALID)) { + goto out; + } + + + + OpenSessionWithParameters() + + + + + + + An array of sets of property names and values + + + + + The secret cookie that is used to identify the new session + + + + + This method requests that a new Session + be created for the calling process. The properties of this new Session are from the + parameters provided. + + This new session exists until the calling process disconnects from the system bus or + calls CloseSession(). + + It is the responsibility of the calling process to set the environment variable + XDG_SESSION_COOKIE to the value of the returned cookie. This cookie should only + be made available to child processes of the caller so that they may be identified + as members of this session. + + See the Session properties for a list of valid parameters. + + org.freedesktop.ConsoleKit.Session + This method is restricted to privileged users by D-Bus policy. + + + + + + + The secret cookie that is used to identify the session + + + + + Whether the session was successfully closed + + + + + This method is used to close the session identified by the supplied cookie. + + The session can only be closed by the same process that opened the session. + + + + + + + + + an array of Seat IDs + + + + + This gets a list of all the Seats + that are currently present on the system. + Each Seat ID is an D-Bus object path for the object that implements the + Seat interface. + + org.freedesktop.ConsoleKit.Seat + + + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently present on the system. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + org.freedesktop.ConsoleKit.Session + + + + + + + + The secret cookie that is used to identify the session + + + + + The object identifier for the current session + + + + + Returns the session ID that is associated with the specified cookie. + + + + + + + + + The POSIX process ID + + + + + The object identifier for the current session + + + + + Attempts to determine the session ID for the specified + POSIX process ID (pid). + + + + + + + + + The object identifier for the current session + + + + + Attempts to determine the session ID that the caller belongs to. + + See this example of using dbus-send: + + dbus-send --system --dest=org.freedesktop.ConsoleKit \ + --type=method_call --print-reply --reply-timeout=2000 \ + /org/freedesktop/ConsoleKit/Manager \ + org.freedesktop.ConsoleKit.Manager.GetCurrentSession + + + + + + + + + POSIX User identification + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently open for the specified user. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + + + + + + + User identification + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently open for the specified user. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + + + + + + + + The value of the system-idle-hint + + + + + Returns TRUE if the idle-hint + property of every open session is TRUE or if there are no open sessions. + + + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time of the last change of the system-idle-hint. + + + + + + + + + The Seat ID for the added seat + + + + + Emitted when a Seat has been added to the system. + + + + + + + + The Seat ID for the removed seat + + + + + Emitted when a Seat has been removed from the system. + + + + + + + + The value of the system-idle-hint + + + + + Emitted when the value of the system-idle-hint has changed. + + + + + + diff --git a/src/org.freedesktop.ConsoleKit.Seat.xml b/src/org.freedesktop.ConsoleKit.Seat.xml new file mode 100644 index 0000000..d95990b --- /dev/null +++ b/src/org.freedesktop.ConsoleKit.Seat.xml @@ -0,0 +1,164 @@ + + + + + + + A seat is a collection of sessions and a set of hardware (usually at +least a keyboard and mouse). Only one session may be active on a +seat at a time. + + + + + + + Seat ID + + + + + Returns the ID for Seat. + + + + + + + + an array of Session IDs + + + + + This gets a list of all the Sessions + that are currently attached to this seat. + Each Session ID is an D-Bus object path for the object that implements the + Session interface. + + + + + + + + an array of devices + + + + + This gets a list of all the devices + that are currently associated with this seat. + Each device is an D-Bus structure that represents + the device type and the device id. + + + + + + + + + Session ID + + + + + Gets the Session ID that is currently active on this Seat. + Returns NULL if there is no active session. + + + + + + + + TRUE if seat supports session activation + + + + Used to determine whether the seat supports session activation. + + + + + + + + + Session ID + + + + + Attempt to activate the specified session. In most + cases, if successful, this will cause the session to + become visible and take control of the hardware that is + associated with this seat. + + Activate() + + + + + + + Session ID + + + + + Emitted when the active session has changed. + + + + + + + Session ID + + + + + Emitted when a session has been added to the seat. + + + + + + + Session ID + + + + + Emitted when a session has been removed from the seat. + + + + + + + Device structure + + + + + Emitted when a device has been associated with the seat. + + + + + + + Device structure + + + + + Emitted when a device has been dissociated from the seat. + + + + + diff --git a/src/org.freedesktop.ConsoleKit.Session.xml b/src/org.freedesktop.ConsoleKit.Session.xml new file mode 100644 index 0000000..b6e1cdb --- /dev/null +++ b/src/org.freedesktop.ConsoleKit.Session.xml @@ -0,0 +1,435 @@ + + + + + + + Session objects represent and store information + related to a user session. + + The properties associated with the Session + specifically refer to the properties of the "session leader". + + + + + + + Session ID + + + + Returns the ID for Session. + + + + + + + Seat ID + + + + Returns the ID for the Seat the Session is + attached to. + + org.freedesktop.ConsoleKit.Seat + + + + + + Session type + + + + + Returns the type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + session-type + + + + + + User ID + + + + Returns the user that the session belongs to. + + + user + + + + + + POSIX User ID + + + + Returns the POSIX user ID that the session belongs to. + + unix-user + + + + + + The value of the X11 display + + + + Returns the value of the X11 DISPLAY for this session + if one is present. + + x11-display + + + + + + The value of the X11 display device + + + + Returns the value of the display device (aka TTY) that the + X11 display for the session is connected to. If there is no x11-display set then this value + is undefined. + + x11-display-device + + + + + + The value of the display device + + + + Returns the value of the display device (aka TTY) that the + session is connected to. + + display-device + + + + + + The remote host name + + + + Returns the value of the remote host name for the session. + + + remote-host-name + + + + + + The value of the native system login session ID + + + + Returns the value of the login session ID that the + underlying system uses to enforce session boundaries. If there is no login session ID + set then this value is an empty string. + + + + + + + TRUE if the session is active, otherwise FALSE + + + + Returns whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + active + + + + + + TRUE if the session is local, otherwise FALSE + + + + Returns whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + is-local + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time that the session was opened. + + + + + + + + + + Attempt to activate the this session. In most + cases, if successful, this will cause the session to + become visible and become active on the seat that it + is attached to. + + Seat.ActivateSession() + + + + + + + This will cause a Lock + signal to be emitted for this session. + + + This method is restricted to privileged users by D-Bus policy. + Lock signal + + + + + + + This will cause an Unlock + signal to be emitted for this session. + + This can be used by login managers to unlock a session before it is + re-activated during fast-user-switching. + + + This method is restricted to privileged users by D-Bus policy. + Unlock signal + + + + + + + The value of the idle-hint + + + + + Gets the value of the idle-hint + property. + + + idle-hint + + + + + + An ISO 8601 format date-type string + + + + + Returns an ISO 8601 date-time string that corresponds to + the time of the last change of the idle-hint. + + + + + + + + + boolean value to set the idle-hint to + + + + + This may be used by the session to indicate that + it is idle. + + Use of this method is restricted to the user + that owns the session. + + + + + + + + TRUE if the session is active, otherwise FALSE + + + + + Emitted when the active property has changed. + + + + + + + the new value of idle-hint + + + + + Emitted when the idle-hint property has changed. + + + + + + + Emitted in response to a call to the Lock() method. + It is intended that the screensaver for the session should lock the screen in response to this signal. + + + + + + + Emitted in response to a call to the Unlock() method. + It is intended that the screensaver for the session should unlock the screen in response to this signal. + + + + + + + + The user assigned to the session. + + + + + + + The user assigned to the session. + + + + + + + + The type of the session. + Warning: we haven't yet defined the allowed values for this property. + It is probably best to avoid this until we do. + + + + + + + + The remote host name for the session. + + This will be set in situations where the session is + opened and controlled from a remote system. + + For example, this value will be set when the + session is created from an SSH or XDMCP connection. + + + + + + + + The display device (aka TTY) that the + session is connected to. + + + + + + + + Value of the X11 DISPLAY for this session + if one is present. + + + + + + + + + The display device (aka TTY) that the X11 display for the + session is connected to. If there is no x11-display set then + this value is undefined. + + + + + + + + + Whether the session is active on the Seat that + it is attached to. + If the session is not attached to a seat this value is undefined. + + + + + + + + + Whether the session is local + FIXME: we need to come up with a concrete definition for this value. + It was originally used as a way to identify XDMCP sessions that originate + from a remote system. + + + + + + + + + This is a hint used to indicate that the session may be idle. + + + For sessions with a x11-display set (ie. graphical + sessions), it is up to each session to delegate the + responsibility for updating this value. Typically, the + screensaver will set this. + + However, for non-graphical sessions with a display-device set + the Session object itself will periodically update this value based + on the activity detected on the display-device itself. + + + This should not be considered authoritative. + + + + + + + -- cgit v1.2.3 From 381110b4d8fac1a5d557711c348bb3324624c9ae Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Aug 2011 15:59:40 -0500 Subject: After setting up the signals get the initial list of sessions --- src/users-service-dbus.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 83edaa3..f87d381 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -36,6 +36,7 @@ #include "accounts-service-client.h" #include "consolekit-manager-client.h" #include "consolekit-session-client.h" +#include "consolekit-seat-client.h" #define CK_ADDR "org.freedesktop.ConsoleKit" #define CK_SESSION_IFACE "org.freedesktop.ConsoleKit.Session" @@ -315,6 +316,23 @@ create_ck_proxy (UsersServiceDbus *self) } } +/* Get the initial sessions when starting up */ +static void +get_cksessions_cb (DBusGProxy *proxy, GPtrArray * sessions, GError * error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to get initial sessions: %s", error->message); + return; + } + + int i; + for (i = 0; i < sessions->len; i++) { + seat_proxy_session_added(proxy, g_ptr_array_index(sessions, i), USERS_SERVICE_DBUS(userdata)); + } + + return; +} + static void create_seat_proxy (UsersServiceDbus *self) { @@ -363,6 +381,10 @@ create_seat_proxy (UsersServiceDbus *self) G_CALLBACK (seat_proxy_session_removed), self, NULL); + + org_freedesktop_ConsoleKit_Seat_get_sessions_async (priv->seat_proxy, get_cksessions_cb, self); + + return; } static void -- cgit v1.2.3 From c2266fe6e875f30b409b97755aeca512fc2be690 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Aug 2011 16:12:01 -0500 Subject: Debugging info and a protection --- src/users-service-dbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index f87d381..ec52771 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -325,6 +325,11 @@ get_cksessions_cb (DBusGProxy *proxy, GPtrArray * sessions, GError * error, gpoi return; } + /* If there's no error we should at least get an + array of zero entries */ + g_return_if_fail(sessions != NULL); + g_debug("Got %d initial sessions", sessions->len); + int i; for (i = 0; i < sessions->len; i++) { seat_proxy_session_added(proxy, g_ptr_array_index(sessions, i), USERS_SERVICE_DBUS(userdata)); -- cgit v1.2.3 From dce6ee5caccdf9f9683bad26d062671a889792ee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 18 Aug 2011 12:45:50 +0100 Subject: greeter mode uses to flag whether we are showing the user menu or not --- src/session-service.c | 2 +- src/user-menu-mgr.c | 24 +++++++++++++----------- src/user-menu-mgr.h | 3 ++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/session-service.c b/src/session-service.c index fa212fd..753e304 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -118,7 +118,7 @@ main (int argc, char ** argv) if (!greeter_mode) { // Users - UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus); + UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus, greeter_mode); DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT); dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr)); } diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index f2757ad..72b5802 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -29,7 +29,6 @@ with this program. If not, see . static GConfClient * gconf_client = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; - struct _UserMenuMgr { GObject parent_instance; @@ -50,7 +49,8 @@ static gint compare_users_by_username (const gchar *a, static void activate_online_accounts (DbusmenuMenuitem *mi, guint timestamp, gpointer user_data); -static void user_menu_mgr_rebuild_items (UserMenuMgr *self); +static void user_menu_mgr_rebuild_items (UserMenuMgr *self, + gboolean greeter_mode); static gboolean check_new_session (); static void user_change (UsersServiceDbus *service, const gchar *user_id, @@ -99,7 +99,7 @@ user_menu_mgr_class_init (UserMenuMgrClass *klass) /* Builds up the menu for us */ static void -user_menu_mgr_rebuild_items (UserMenuMgr *self) +user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) { DbusmenuMenuitem *mi = NULL; DbusmenuMenuitem *guest_mi = NULL; @@ -145,7 +145,6 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) if (check_guest_session ()) { - g_debug ("ADDING GUEST SESSION"); guest_mi = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (guest_mi, DBUSMENU_MENUITEM_PROP_TYPE, @@ -164,16 +163,19 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self) users_service_dbus_set_guest_item (self->users_dbus_interface, guest_mi); } - else{ - g_debug ("NOT ADDING GUEST SESSION"); - } GList * users = NULL; users = users_service_dbus_get_user_list (self->users_dbus_interface); self->user_count = g_list_length(users); - g_debug ("USER COUNT = %i", self->user_count); - session_dbus_set_user_menu_visibility (self->session_dbus_interface, self->user_count > 1); + gboolean user_menu_is_visible = FALSE; + + if (!greeter_mode){ + user_menu_is_visible = self->user_count > 1; + } + + session_dbus_set_user_menu_visibility (self->session_dbus_interface, + user_menu_is_visible); if (self->user_count > MINIMUM_USERS && self->user_count < MAXIMUM_USERS) { users = g_list_sort (users, (GCompareFunc)compare_users_by_username); @@ -418,11 +420,11 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da /* * Clean Entry Point */ -UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus) +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode) { UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL); user_mgr->session_dbus_interface = session_dbus; - user_menu_mgr_rebuild_items (user_mgr); + user_menu_mgr_rebuild_items (user_mgr, greeter_mode); return user_mgr; } diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h index ff2cb77..01823e7 100644 --- a/src/user-menu-mgr.h +++ b/src/user-menu-mgr.h @@ -45,7 +45,8 @@ struct _UserMenuMgrClass }; GType user_menu_mgr_get_type (void) G_GNUC_CONST; -UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus); +UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, + gboolean greeter_mode); DbusmenuMenuitem* user_mgr_get_root_item (UserMenuMgr* self); G_END_DECLS -- cgit v1.2.3