r461 - trunk

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jan 24 05:32:03 EST 2008


Author: icculus
Date: 2008-01-24 05:31:53 -0500 (Thu, 24 Jan 2008)
New Revision: 461

Modified:
   trunk/gui.h
   trunk/gui_gtkplus2.c
   trunk/gui_macosx.c
   trunk/gui_ncurses.c
   trunk/gui_stdio.c
   trunk/gui_www.c
   trunk/lua_glue.c
Log:
UI interface needs to be able to disable the cancel button in the progress
 page, so people can't cancel uninstalls in progress.


Modified: trunk/gui.h
===================================================================
--- trunk/gui.h	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/gui.h	2008-01-24 10:31:53 UTC (rev 461)
@@ -80,7 +80,7 @@
 #define MOJOGUI_ENTRY_POINT_STR DEFINE_TO_STR(MOJOGUI_ENTRY_POINT)
 
 // Increment this value when MojoGui's structure changes.
-#define MOJOGUI_INTERFACE_REVISION 3
+#define MOJOGUI_INTERFACE_REVISION 4
 
 typedef struct MojoGui MojoGui;
 struct MojoGui
@@ -102,7 +102,7 @@
                           int *command, boolean can_back, boolean can_fwd);
     boolean (*insertmedia)(const char *medianame);
     boolean (*progress)(const char *type, const char *component,
-                        int percent, const char *item);
+                        int percent, const char *item, boolean can_cancel);
     void (*final)(const char *msg);
 };
 
@@ -146,7 +146,8 @@
                             int *command, boolean can_back, boolean can_fwd); \
 static boolean MojoGui_##module##_insertmedia(const char *medianame); \
 static boolean MojoGui_##module##_progress(const char *typ, const char *comp, \
-                                           int percent, const char *item); \
+                                           int percent, const char *item, \
+                                           boolean can_cancel); \
 static void MojoGui_##module##_final(const char *msg); \
 const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
 { \

Modified: trunk/gui_gtkplus2.c
===================================================================
--- trunk/gui_gtkplus2.c	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/gui_gtkplus2.c	2008-01-24 10:31:53 UTC (rev 461)
@@ -67,7 +67,8 @@
 
 
 static void prepare_wizard(const char *name, WizardPages page,
-                           boolean can_back, boolean can_fwd)
+                           boolean can_back, boolean can_fwd,
+                           boolean can_cancel)
 {
     char *markup = g_markup_printf_escaped(
                         "<span size='large' weight='bold'>%s</span>",
@@ -81,6 +82,7 @@
 
     gtk_widget_set_sensitive(back, can_back);
     gtk_widget_set_sensitive(next, can_fwd);
+    gtk_widget_set_sensitive(cancel, can_cancel);
     gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), (gint) page);
 
     assert(click_value == CLICK_NONE);
@@ -122,10 +124,10 @@
 
 
 static int run_wizard(const char *name, WizardPages page,
-                      boolean can_back, boolean can_fwd)
+                      boolean can_back, boolean can_fwd, boolean can_cancel)
 {
     int retval = CLICK_NONE;
-    prepare_wizard(name, page, can_back, can_fwd);
+    prepare_wizard(name, page, can_back, can_fwd, can_cancel);
     while (retval == ((int) CLICK_NONE))
         retval = wait_event();
 
@@ -589,7 +591,7 @@
 {
     GtkTextBuffer *textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(readme));
     gtk_text_buffer_set_text(textbuf, (const gchar *) data, datalen);
-    return run_wizard(name, PAGE_README, can_back, can_fwd);
+    return run_wizard(name, PAGE_README, can_back, can_fwd, true);
 } // MojoGui_gtkplus2_readme
 
 
@@ -735,7 +737,9 @@
 
     build_options(opts, box, TRUE);
 
-    retval = run_wizard(entry->_("Options"), PAGE_OPTIONS, can_back, can_fwd);
+    retval = run_wizard(entry->_("Options"), PAGE_OPTIONS,
+                        can_back, can_fwd, true);
+
     gtk_widget_destroy(box);
     return retval;
 } // MojoGui_gtkplus2_options
@@ -755,7 +759,7 @@
     gtk_combo_box_set_active (combo, 0);
 
     *command = run_wizard(entry->_("Destination"), PAGE_DESTINATION,
-                          can_back, can_fwd);
+                          can_back, can_fwd, true);
 
     str = gtk_combo_box_get_active_text(combo);
 
@@ -791,7 +795,8 @@
 
 
 static boolean MojoGui_gtkplus2_progress(const char *type, const char *component,
-                                         int percent, const char *item)
+                                         int percent, const char *item,
+                                         boolean can_cancel)
 {
     static uint32 lastTicks = 0;
     const uint32 ticks = entry->ticks();
@@ -810,7 +815,7 @@
         lastTicks = ticks;
     } // if
 
-    prepare_wizard(type, PAGE_PROGRESS, false, false);
+    prepare_wizard(type, PAGE_PROGRESS, false, false, can_cancel);
     rc = pump_events();
     assert( (rc == ((int) CLICK_CANCEL)) || (rc == ((int) CLICK_NONE)) );
     return (rc != CLICK_CANCEL);
@@ -821,9 +826,8 @@
 {
     gtk_widget_hide(next);
     gtk_widget_show(finish);
-    gtk_widget_set_sensitive(cancel, FALSE);
     gtk_label_set_text(GTK_LABEL(finallabel), msg);
-    run_wizard(entry->_("Finish"), PAGE_FINAL, false, true);
+    run_wizard(entry->_("Finish"), PAGE_FINAL, false, true, false);
 } // MojoGui_gtkplus2_final
 
 // end of gui_gtkplus2.c ...

Modified: trunk/gui_macosx.c
===================================================================
--- trunk/gui_macosx.c	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/gui_macosx.c	2008-01-24 10:31:53 UTC (rev 461)
@@ -197,7 +197,8 @@
 
 
 static int MojoGui_macosx_progress(const char *type, const char *component,
-                                       int percent, const char *item)
+                                   int percent, const char *item,
+                                   boolean can_cancel)
 {
     // !!! FIXME: write me.
     STUBBED("macosx progress");

Modified: trunk/gui_ncurses.c
===================================================================
--- trunk/gui_ncurses.c	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/gui_ncurses.c	2008-01-24 10:31:53 UTC (rev 461)
@@ -81,6 +81,7 @@
 
 static char *lastProgressType = NULL;
 static char *lastComponent = NULL;
+static boolean lastCanCancel = false;
 static uint32 percentTicks = 0;
 static char *title = NULL;
 static MojoBox *progressBox = NULL;
@@ -486,7 +487,7 @@
         case '\n':
         case KEY_ENTER:
         case ' ':
-            return mojobox->hoverover;
+            return (mojobox->buttoncount <= 0) ? -1 : mojobox->hoverover;
 
         case '\e':
             return mojobox->buttoncount-1;
@@ -1357,7 +1358,8 @@
 
 
 static boolean MojoGui_ncurses_progress(const char *type, const char *component,
-                                        int percent, const char *item)
+                                        int percent, const char *item,
+                                        boolean can_cancel)
 {
     const uint32 now = entry->ticks();
     boolean rebuild = (progressBox == NULL);
@@ -1367,12 +1369,14 @@
     if ( (lastComponent == NULL) ||
          (strcmp(lastComponent, component) != 0) ||
          (lastProgressType == NULL) ||
-         (strcmp(lastProgressType, type) != 0) )
+         (strcmp(lastProgressType, type) != 0) ||
+         (lastCanCancel != can_cancel) )
     {
         free(lastProgressType);
         free(lastComponent);
         lastProgressType = entry->xstrdup(type);
         lastComponent = entry->xstrdup(component);
+        lastCanCancel = can_cancel;
         rebuild = true;
     } // if
 
@@ -1380,8 +1384,10 @@
     {
         int w, h;
         char *text = NULL;
-        char *localized_cancel = entry->xstrdup(entry->_("Cancel"));
+        char *localized_cancel =
+                    (can_cancel) ? entry->xstrdup(entry->_("Cancel")) : NULL;
         char *buttons[] = { localized_cancel };
+        const int buttoncount = (can_cancel) ? 1 : 0;
         char *spacebuf = NULL;
         getmaxyx(stdscr, h, w);
         w -= 10;
@@ -1396,7 +1402,7 @@
         strcat(text, "\n\n ");
 
         freeBox(progressBox, false);
-        progressBox = makeBox(type, text, buttons, 1, true, true);
+        progressBox = makeBox(type, text, buttons, buttoncount, true, true);
         free(text);
         free(localized_cancel);
     } // if

Modified: trunk/gui_stdio.c
===================================================================
--- trunk/gui_stdio.c	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/gui_stdio.c	2008-01-24 10:31:53 UTC (rev 461)
@@ -600,7 +600,8 @@
 
 
 static boolean MojoGui_stdio_progress(const char *type, const char *component,
-                                      int percent, const char *item)
+                                      int percent, const char *item,
+                                      boolean can_cancel)
 {
     const uint32 now = entry->ticks();
 

Modified: trunk/gui_www.c
===================================================================
--- trunk/gui_www.c	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/gui_www.c	2008-01-24 10:31:53 UTC (rev 461)
@@ -1015,7 +1015,8 @@
 
 
 static boolean MojoGui_www_progress(const char *type, const char *component,
-                                    int percent, const char *item)
+                                    int percent, const char *item,
+                                    boolean can_cancel)
 {
     return true;
 } // MojoGui_www_progress

Modified: trunk/lua_glue.c
===================================================================
--- trunk/lua_glue.c	2008-01-24 09:17:42 UTC (rev 460)
+++ trunk/lua_glue.c	2008-01-24 10:31:53 UTC (rev 461)
@@ -1465,9 +1465,11 @@
 {
     const char *type = luaL_checkstring(L, 1);
     const char *component = luaL_checkstring(L, 2);
-    int percent = luaL_checkint(L, 3);
+    const int percent = luaL_checkint(L, 3);
     const char *item = luaL_checkstring(L, 4);
-    return retvalBoolean(L, GGui->progress(type, component, percent, item));
+    const boolean canstop = lua_toboolean(L, 5);
+    const boolean rc = GGui->progress(type, component, percent, item, canstop);
+    return retvalBoolean(L, rc);
 } // luahook_gui_progress
 
 




More information about the mojosetup-commits mailing list