Commits

jjacky committed b4825ae

Menuitem "System upgrade" now works as button "Upgrade system" from notifications; bump to 0.1.0

- The menu "System upgrade" was always present and running kalu's system updater. It now relies on the preferences for Upgrade notifications: only visible if enabled, and starts either kalu's updater or the specified command line. IOW those two (notifications' button & menu item) are 2 GUI elements of the same feature.
- Version bump to 0.1.0 (i.e. kalu is out of devel period (0.0.x), this is considered a stable version)

Comments (0)

Files changed (4)

-.TH kalu 1 "2012-02-22" 0.0.5 "Keeping Arch Linux Up-to-date"
+.TH kalu 1 "2012-03-06" 0.1.0 "Keeping Arch Linux Up-to-date"
 
 .SH NAME
 kalu \- Keeping Arch Linux Up-to-date
 .P
 \fBUpgrades\fR
 .RS 4
-\fIShow a button "Upgrade system" on notifications\fR
+\fIShow a button "Upgrade system" on notifications (and on kalu's menu)\fR
 .RS 4
-Whether or not notifications should feature a button "Upgrade system"
+Whether or not notifications should feature a button "Upgrade system" and kalu's
+menu (right-click on its systray icon) feature an item "System upgrade"
 .RE
 .RE
 .P
 
 
 .SH SYSTEM UPGRADE
-When a notification is shown for available upgrades, a button "Upgrade system"
-can be featured. This button can start a process of your choice, or kalu's own
-system upgrader. (See \fBPREFERENCES\fR above.)
+An item "System Upgrade" on kalu's menu, as well as a button "Upgrade system"
+on notifications for available upgrades, can be featured. This button can start
+a process of your choice, or kalu's own system upgrader. (See \fBPREFERENCES\fR
+above.)
 .P
 The later will first synchronize your databases, then upgrade all packages that
 are out of date. In other words, it does what a `pacman -Syu` would do, only
 
 #define _UNUSED_            __attribute__ ((unused)) 
 
-#define KALU_VERSION       "0.0.6"
+#define KALU_VERSION       "0.1.0"
 #define KALU_TAG            "Keeping Arch Linux Up-to-date"
 
 #define MAX_PATH            255
 /* global variable */
 config_t *config = NULL;
 
+#define run_updater()   do {                \
+        set_kalpm_busy (TRUE);              \
+        updater_run (config->cmdline_post); \
+    } while (0)
+
 
 static void action_upgrade (NotifyNotification *notification, const char *action, gpointer data);
 static void action_watched (NotifyNotification *notification, char *action, alpm_list_t *packages);
 static kalpm_state_t kalpm_state = { FALSE, 0, 0, NULL, 0, 0, 0, 0, 0 };
 
 static void
+run_cmdline (const char *cmdline)
+{
+    GError *error = NULL;
+    
+    if (!g_spawn_command_line_async (cmdline, &error))
+    {
+        GtkWidget *dialog;
+        
+        dialog = gtk_message_dialog_new (NULL,
+                                         GTK_DIALOG_DESTROY_WITH_PARENT,
+                                         GTK_MESSAGE_ERROR,
+                                         GTK_BUTTONS_OK,
+                                         "%s",
+                                         "Unable to start process");
+        gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
+                "Error while trying to run command line: %s\n\nThe error was: <b>%s</b>",
+                cmdline, error->message);
+        gtk_window_set_title (GTK_WINDOW (dialog), "kalu: Unable to start process");
+        gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE);
+        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
+        gtk_window_set_skip_pager_hint (GTK_WINDOW (dialog), FALSE);
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+        g_error_free (error);
+    }
+}
+
+static void
 action_upgrade (NotifyNotification *notification, const char *action, gpointer data _UNUSED_)
 {
-    GError *error = NULL;
     char *cmdline = NULL;
     
     notify_notification_close (notification, NULL);
     {
         if (config->action == UPGRADE_ACTION_KALU)
         {
-            menu_updater_cb (NULL, NULL);
+            run_updater ();
         }
         else /* if (config->action == UPGRADE_ACTION_CMDLINE) */
         {
     
     if (cmdline)
     {
-        if (!g_spawn_command_line_async (cmdline, &error))
-        {
-            GtkWidget *dialog;
-            
-            dialog = gtk_message_dialog_new (NULL,
-                                             GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             GTK_MESSAGE_ERROR,
-                                             GTK_BUTTONS_OK,
-                                             "%s",
-                                             "Unable to start Update process");
-            gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
-                    "Error while trying to run command line: %s\n\nThe error was: <b>%s</b>",
-                    cmdline, error->message);
-            gtk_window_set_title (GTK_WINDOW (dialog), "kalu: Unable to start Update process");
-            gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE);
-            gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
-            gtk_window_set_skip_pager_hint (GTK_WINDOW (dialog), FALSE);
-            gtk_dialog_run (GTK_DIALOG (dialog));
-            gtk_widget_destroy (dialog);
-            g_error_free (error);
-        }
+        run_cmdline (cmdline);
     }
 }
 
     {
         return;
     }
-    set_kalpm_busy (TRUE);
     
-    updater_run (config->cmdline_post);
+    if (config->action == UPGRADE_ACTION_KALU)
+    {
+        run_updater ();
+    }
+    else /* if (config->action == UPGRADE_ACTION_CMDLINE) */
+    {
+        run_cmdline (config->cmdline);
+    }
 }
 
 static void
     gtk_widget_show (item);
     gtk_menu_attach (GTK_MENU (menu), item, 0, 1, pos, pos + 1); ++pos;
     
-    item = gtk_image_menu_item_new_with_label ("System upgrade...");
-    gtk_widget_set_sensitive (item, !kalpm_state.is_busy);
-    image = gtk_image_new_from_stock ("kalu-logo", GTK_ICON_SIZE_MENU);
-    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-    gtk_widget_set_tooltip_text (item, "Perform a system upgrade");
-    g_signal_connect (G_OBJECT (item), "activate",
-                      G_CALLBACK (menu_updater_cb), NULL);
-    gtk_widget_show (item);
-    gtk_menu_attach (GTK_MENU (menu), item, 0, 1, pos, pos + 1); ++pos;
+    if (config->action != UPGRADE_NO_ACTION)
+    {
+        item = gtk_image_menu_item_new_with_label ("System upgrade...");
+        gtk_widget_set_sensitive (item, !kalpm_state.is_busy);
+        image = gtk_image_new_from_stock ("kalu-logo", GTK_ICON_SIZE_MENU);
+        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+        gtk_widget_set_tooltip_text (item, "Perform a system upgrade");
+        g_signal_connect (G_OBJECT (item), "activate",
+                          G_CALLBACK (menu_updater_cb), NULL);
+        gtk_widget_show (item);
+        gtk_menu_attach (GTK_MENU (menu), item, 0, 1, pos, pos + 1); ++pos;
+    }
     
     item = gtk_image_menu_item_new_with_label ("Show recent Arch Linux news...");
     gtk_widget_set_sensitive (item, !kalpm_state.is_busy);
     lbl_page = gtk_label_new ("Upgrades");
     
     /* UpgradeAction */
-    button_upg_action = gtk_check_button_new_with_label ("Show a button \"Upgrade system\" on notifications");
+    button_upg_action = gtk_check_button_new_with_label ("Show a button \"Upgrade system\" on notifications (and on kalu's menu)");
+    gtk_widget_set_tooltip_text (button_upg_action, "Whether or not to show a button \"Upgrade system\" on notifications, as well as an item \"System upgrade\" on kalu's menu");
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_upg_action),
         config->action != UPGRADE_NO_ACTION);
     gtk_grid_attach (GTK_GRID (grid), button_upg_action, 0, top, 4, 1);
                       G_CALLBACK (upg_action_toggled_cb), NULL);
     
     ++top;
-    label = gtk_label_new ("When clicking the button :");
+    label = gtk_label_new ("When clicking the button/menu :");
+    gtk_widget_set_tooltip_text (label, "When clicking the button \"Upgrade system\" on notifications, or the menu \"System upgrade\"");
     gtk_grid_attach (GTK_GRID (grid), label, 0, top, 2, 1);
     gtk_widget_show (label);
     
     upg_action_combo = gtk_combo_box_text_new ();
+    gtk_widget_set_tooltip_text (upg_action_combo, "When clicking the button \"Upgrade system\" on notifications, or the menu \"System upgrade\"");
     gtk_widget_set_sensitive (upg_action_combo, config->action != UPGRADE_NO_ACTION);
     gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (upg_action_combo), "1",
         "Run kalu's system updater");