[Xfce4-commits] [xfce/xfce4-power-manager] 02/02: Select first device on the devices tab on launch

noreply at xfce.org noreply at xfce.org
Sun Jul 13 21:18:55 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit f496c7f24a48f84b7d8f1def50aef3c8aaf2316c
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Jul 13 22:15:40 2014 +0300

    Select first device on the devices tab on launch
    
    ...when the user doesn't select a device from the plugin.
---
 settings/xfpm-settings.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index eacbdbf..a8f9c53 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -1798,6 +1798,7 @@ add_device (UpDevice *device)
     const gchar *object_path = up_device_get_object_path(device);
     gulong signal_id;
     guint index;
+    static gboolean first_run = TRUE;
 
     TRACE("entering for %s", object_path);
 
@@ -1858,18 +1859,22 @@ add_device (UpDevice *device)
     /* Add the icon and description for the device */
     update_device_details (device);
 
-    /* See if we're to select this device */
-    if (g_strcmp0 (object_path, starting_device_id) == 0)
+    /* See if we're to select this device, for it to be selected,
+     * the starting_device_id must be unset and the this is the first
+     * time add_device is called (i.e. select the first device) or
+     * our current device matches starting_device_id. */
+    if ((starting_device_id == NULL && first_run == TRUE) ||
+        (g_strcmp0 (object_path, starting_device_id) == 0))
     {
 	GtkTreeSelection *selection;
 
-	DBG("object_path == starting_device_id, selecting device");
-
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sideview));
 
 	gtk_tree_selection_select_iter (selection, &iter);
 	view_cursor_changed_cb (GTK_TREE_VIEW (sideview), NULL);
     }
+
+    first_run = FALSE;
 }
 
 static void
@@ -2182,7 +2187,8 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean auth_suspend,
     /* If we passed in a device to display, show the devices tab now */
     if (device_id != NULL)
     {
-	gtk_notebook_set_current_page (GTK_NOTEBOOK (nt), 3);
+	/* Assuming the last page is the devices tab */
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (nt), gtk_notebook_get_n_pages (GTK_NOTEBOOK(nt)) - 1);
     }
 
     return dialog;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list