Commits

jjacky committed d1212b4

Preferences: kalu's updater: added option for confirmation before starting PostSysUpgrade processes (ConfirmPostSysUpgrade)

Comments (0)

Files changed (5)

                         strdup (value));
                     debug ("config: postsysupgrade: %s", value);
                 }
+                else if (strcmp (key, "ConfirmPostSysUpgrade") == 0)
+                {
+                    config->confirm_post = (*value == '1');
+                    debug ("config: confirm postsysupgrade: %d", config->confirm_post);
+                }
                 #endif
                 else if (strcmp (key, "AurIgnore") == 0)
                 {
     char            *cmdline_aur;
     #ifndef DISBALE_UPDATER
     alpm_list_t     *cmdline_post;
+    gboolean         confirm_post;
     #endif
     gboolean         sane_sort_order;
     gboolean         check_pacman_conflict;
                             | CHECK_WATCHED_AUR | CHECK_NEWS;
     #ifndef DISABLE_UPDATER
     config->action = UPGRADE_ACTION_KALU;
+    config->confirm_post = TRUE;
     #else
     config->action = UPGRADE_NO_ACTION;
     #endif
 #ifndef DISABLE_UPDATER
 static GtkWidget *cmdline_post_hbox         = NULL;
 static GtkListStore *cmdline_post_store     = NULL;
+static GtkWidget *confirm_post              = NULL;
 #endif
 static GtkWidget *upg_title_entry           = NULL;
 static GtkWidget *upg_package_entry         = NULL;
     gtk_widget_set_sensitive (cmdline_entry, is_active);
     #ifndef DISABLE_UPDATER
     gtk_widget_set_sensitive (cmdline_post_hbox, is_active);
+    gtk_widget_set_sensitive (confirm_post, is_active);
     #endif
 }
 
         gtk_widget_hide (cmdline_entry);
         #ifndef DISABLE_UPDATER
         gtk_widget_show (cmdline_post_hbox);
+        gtk_widget_show (confirm_post);
         #endif
     }
     else if (choice == 1)
         gtk_widget_show (cmdline_entry);
         #ifndef DISABLE_UPDATER
         gtk_widget_hide (cmdline_post_hbox);
+        gtk_widget_hide (confirm_post);
         #endif
     }
 }
             }
         } while (gtk_tree_model_iter_next (model, &iter));
     }
+    new_config.confirm_post = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (confirm_post));
+    add_to_conf ("ConfirmPostSysUpgrade = %d\n", new_config.confirm_post);
     #endif
     
     /* AUR */
     /* a scrolledwindow for the tree */
     GtkWidget *scrolled;
     scrolled = gtk_scrolled_window_new (
-        gtk_tree_view_get_hadjustment (GTK_TREE_VIEW (tree)),
-        gtk_tree_view_get_vadjustment (GTK_TREE_VIEW (tree)));
+        gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (tree)),
+        gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree)));
     gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
         GTK_SHADOW_OUT);
     gtk_widget_show (scrolled);
     ++top;
     /* PostSysUpgrade */
     add_list (grid, top, &cmdline_post_store, &cmdline_post_hbox,
-              "After completing a system upgrade, ask whether to start the following :",
+              "After completing a system upgrade, start the following :",
               "Add a new command-line",
               "Edit selected command-line",
               "Remove selected command-line",
               config->cmdline_post);
     gtk_widget_set_sensitive (cmdline_post_hbox, config->action != UPGRADE_NO_ACTION);
+    ++top;
+    /* ConfirmPostSysUpgrade */
+    confirm_post = gtk_check_button_new_with_label ("Ask confirmation before starting anything");
+    gtk_widget_set_tooltip_text (confirm_post, "Confirmation will be asked before starting those processes. With multiple ones, you'll be able to select which one(s) to start.");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (confirm_post), config->confirm_post);
+    gtk_grid_attach (GTK_GRID (grid), confirm_post, 0, top, 2, 1);
+    gtk_widget_show (confirm_post);
     
     /* doing this now otherwise it's triggered with non-yet-existing widgets to hide/show */
     g_signal_connect (G_OBJECT (upg_action_combo), "changed",
     
     if (NULL != updater->cmdline_post)
     {
-        GError *error = NULL;
-        size_t count = alpm_list_count (updater->cmdline_post);
+        GError      *error = NULL;
+        size_t       count = alpm_list_count (updater->cmdline_post);
+        alpm_list_t *cmdlines = NULL, *i;
         
         if (count == 1)
         {
-            add_log (LOGTYPE_INFO, "Do you want to run the post-sysupgrade process ?");
-            if (confirm ("Do you want to run the post-sysupgrade process ?",
-                    updater->cmdline_post->data,
-                    "Yes, Start it now", NULL,
-                    "No", NULL,
-                    updater->window))
+            if (config->confirm_post)
             {
-                add_log (LOGTYPE_INFO, " Yes\n");
-                add_log (LOGTYPE_NORMAL, "Starting: '%s' ..", updater->cmdline_post->data);
-                if (!g_spawn_command_line_async (updater->cmdline_post->data, &error))
+                add_log (LOGTYPE_INFO, "Do you want to run the post-sysupgrade process ?");
+                if (confirm ("Do you want to run the post-sysupgrade process ?",
+                        updater->cmdline_post->data,
+                        "Yes, Start it now", NULL,
+                        "No", NULL,
+                        updater->window))
                 {
-                    add_log (LOGTYPE_NORMAL, " failed\n");
-                    _show_error ("Unable to start post-sysupgrade process.",
-                        "Command-line: %s\nError: %s",
-                        updater->cmdline_post->data, error->message);
-                    g_clear_error (&error);
+                    add_log (LOGTYPE_INFO, " Yes\n");
+                    cmdlines = alpm_list_add (cmdlines, updater->cmdline_post->data);
                 }
                 else
                 {
-                    add_log (LOGTYPE_NORMAL, " ok\n");
+                    add_log (LOGTYPE_INFO, " No\n");
                 }
             }
             else
             {
-                add_log (LOGTYPE_INFO, " No\n");
+                cmdlines = alpm_list_add (cmdlines, updater->cmdline_post->data);
             }
         }
         else
         {
-            alpm_list_t *cmdlines, *i;
-            add_log (LOGTYPE_INFO, "Do you want to run the post-sysupgrade processes ?");
-            cmdlines = confirm_choices (
-            "Do you want to run the following post-sysupgrade processes ?",
-                "Only checked processes will be launch.",
-                "Yes, run checked processes now", NULL,
-                "No", NULL,
-                "Run",
-                "Command-line",
-                updater->cmdline_post,
-                updater->window);
-            if (NULL != cmdlines)
+            if (config->confirm_post)
             {
-                add_log (LOGTYPE_INFO, " Yes\n");
-                for (i = cmdlines; i; i = alpm_list_next (i))
+                add_log (LOGTYPE_INFO, "Do you want to run the post-sysupgrade processes ?");
+                cmdlines = confirm_choices (
+                "Do you want to run the following post-sysupgrade processes ?",
+                    "Only checked processes will be launch.",
+                    "Yes, run checked processes now", NULL,
+                    "No", NULL,
+                    "Run",
+                    "Command-line",
+                    updater->cmdline_post,
+                    updater->window);
+                if (NULL != cmdlines)
                 {
-                    add_log (LOGTYPE_NORMAL, "Starting: '%s' ..", i->data);
-                    if (!g_spawn_command_line_async (i->data, &error))
-                    {
-                        add_log (LOGTYPE_NORMAL, " failed\n");
-                        _show_error ("Unable to start post-sysupgrade process.",
-                            "Command-line: %s\nError: %s",
-                            i->data, error->message);
-                        g_clear_error (&error);
-                    }
-                    else
-                    {
-                        add_log (LOGTYPE_NORMAL, " ok\n");
-                    }
+                    add_log (LOGTYPE_INFO, " Yes\n");
                 }
-                FREELIST (cmdlines);
+                else
+                {
+                    add_log (LOGTYPE_INFO, " No\n");
+                }
             }
             else
             {
-                add_log (LOGTYPE_INFO, " No\n");
+                cmdlines = updater->cmdline_post;
             }
         }
+        
+        for (i = cmdlines; i; i = alpm_list_next (i))
+        {
+            add_log (LOGTYPE_NORMAL, "Starting: '%s' ..", i->data);
+            if (!g_spawn_command_line_async (i->data, &error))
+            {
+                add_log (LOGTYPE_NORMAL, " failed\n");
+                _show_error ("Unable to start post-sysupgrade process.",
+                    "Command-line: %s\nError: %s",
+                    i->data, error->message);
+                g_clear_error (&error);
+            }
+            else
+            {
+                add_log (LOGTYPE_NORMAL, " ok\n");
+            }
+        }
+        if (cmdlines)
+        {
+            FREELIST (cmdlines);
+        }
     }
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.