antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright doc/TODO gtkshell/Makefile gtkshell/a...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright doc/TODO gtkshell/Makefile gtkshell/a...
Date: Thu, 13 Dec 2007 17:20:25 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/12/13 17:20:25

Modified files:
        doc            : TODO 
        gtkshell       : Makefile add_options.c arguments.c 
                         dialog_options.c dialog_options.h main.c 
                         option_options.c option_options.h options.c 
                         options.h updated_options.c 

Log message:
        Switch from switch-based command line option handling to
        hash table callback dictionary.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/doc/TODO?cvsroot=antiright&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/add_options.c?cvsroot=antiright&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/arguments.c?cvsroot=antiright&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog_options.c?cvsroot=antiright&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog_options.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/main.c?cvsroot=antiright&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.c?cvsroot=antiright&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.h?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.h?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_options.c?cvsroot=antiright&r1=1.22&r2=1.23

Patches:
Index: doc/TODO
===================================================================
RCS file: /sources/antiright/antiright/doc/TODO,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- doc/TODO    11 Jun 2007 21:32:37 -0000      1.17
+++ doc/TODO    13 Dec 2007 17:20:24 -0000      1.18
@@ -1,6 +1,9 @@
 TODO
 ----
 
+Use new dictionary callback mechanism for direct translation from
+GUIDL source to widgets, eliminating the options parsing step.  
+
 Implement button selection support, where a regular expression can be
 applied to button titles for selection.  Test if it is possible to
 drag this entire selection, else compile the titles into a string for passing.

Index: gtkshell/Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- gtkshell/Makefile   11 Dec 2007 18:05:36 -0000      1.49
+++ gtkshell/Makefile   13 Dec 2007 17:20:24 -0000      1.50
@@ -33,7 +33,7 @@
 
 objects=y.tab.o lex.yy.o gtkshell.o arguments.o options.o callbacks.o\
        label.o button.o text.o updated_label.o updated_progress.o\
-       updated_options.o add_options.o option_options.o dialog_options.o\
+       dialog_options.o\
        row.o containers.o geometry.o font.o dragdrop.o\
        image_button.o terminal.o terminal_options.o menu.o updated.o\
        guidl_util.o about_dialog.o init.o guidl_dialog.o guidl_dictionary.o\

Index: gtkshell/add_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/add_options.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- gtkshell/add_options.c      10 Dec 2007 15:14:31 -0000      1.54
+++ gtkshell/add_options.c      13 Dec 2007 17:20:24 -0000      1.55
@@ -140,116 +140,3 @@
 }
 
 
-void
-gsh_handle_add_arguments(GSH * gsh, const gint argc, const gchar **argv, 
-       gint *counter)
-{
-       g_assert(strlen(argv[(*counter)]) > 1);
-       switch (argv[(*counter)][2])
-       {
-       case 'A': /* Add an internally updated applet.  */
-               handle_applet_arguments(gsh, argv, counter);
-               break;
-
-       case 'b': /* Add a horizontal pane between previous widgets
-                    and following widgets.  */
-               GSH_COUNT(argc, counter);
-               gsh_setup_hpaned(gsh, argv[*counter]);
-               break;
-
-       case 'C': /* Add a command execution widget.  This is primarily
-                    for systems failing to support VTE.  */
-               add_command_shell(gsh, NULL);
-               break;
-
-       case 'c': /* Add a widget with value initialized by execution
-                    of command, specified by option argument.  */
-               handle_commanded_add_arguments(gsh, argc, argv, counter);
-               break;
-
-       case 'e':
-               GSH_COUNT(argc, counter);
-               GSH_SET(GSH_APP_MODE);
-               gsh_text_editor(gsh, argv[*counter]);
-               break;
-
-       case 'f': /* Add a form with check boxes or radio buttons.  */
-               GSH_COUNT(argc, counter);
-               gsh_add_form(gsh, argv[(*counter)]);
-               break;
-
-       case 'L': /* Add a list.  */
-               GSH_COUNT(argc, counter);
-               $(gsh, manage, gsh_tree_view_new(gsh, argv[*counter]));
-               break;
-
-       case 'l': /* Add a label.  */
-               GSH_COUNT(argc, counter);
-               $(gsh, add.label, argv[(*counter)]);
-               break;
-
-       case 'P':
-               ADD_PIPED_GENERIC(gsh, add_piped_text);
-               break;
-
-       case 'p':
-               ADD_PIPED_GENERIC(gsh, add_piped_label);
-               break;
-
-       case 'Q':
-#ifdef GSH_USE_QUICKSTART
-       { /* FIXME: make it useful.  */
-               GSHQuickStart * quickstart;
-               quickstart=ARNEW(gsh, GSHQuickStart);
-               GSH_COUNT(argc, counter);
-               $(quickstart, add, gsh, argv[*counter], argv[(*counter)+1]);
-               GSH_COUNT(argc, counter);
-               $(gsh, manage, quickstart->__column);
-       }
-#else /* ! GSH_USE_QUICKSTART */
-               ARWARN("The quickstart feature is disabled.  ");
-#endif /* GSH_USE_QUICKSTART */
-               break;
-
-       case 'r': /* Force creation of a new row.  */
-               $(gsh->rows, new);
-               break;
-
-       case 'S': /* Add a separator.  */
-               add_separator(gsh);
-               break;
-
-       case 's': /* Add a shell.  */
-               GSH_COUNT(argc, counter);
-#ifdef HAVE_VTE
-               add_shell(gsh, argv[*counter]);
-#else /* not HAVE_VTE */
-               add_command_shell(gsh, argv[*counter]);
-#endif /* HAVE_VTE */
-               break;
-
-       case 't':
-               if (argc != *counter)
-                       GSH_COUNT(argc, counter);
-
-               gsh_setup_command_entry(gsh, argv[(*counter)]);
-
-               break;
-       case 'T':
-               gsh_text_area(gsh);
-               break;
-
-       case 'u':
-               gsh_handle_updated_arguments(gsh, argc, argv, counter);
-               break;
-
-       case 'w':
-               add_new_window(gsh);
-               break;
-       case 'X':
-               gsh_add_embedded(gsh, (char *)argv[++(*counter)]);
-               break;
-       default:
-               ARWARN("invalid add option");
-       }
-}

Index: gtkshell/arguments.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/arguments.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- gtkshell/arguments.c        8 Nov 2007 06:41:53 -0000       1.32
+++ gtkshell/arguments.c        13 Dec 2007 17:20:24 -0000      1.33
@@ -100,7 +100,7 @@
 
        for (counter = 1; counter < argc; counter++)
                (argv[counter][0] == '-') ?
-                       gsh_handle_switch_arguments(gsh, argc, argv, &counter)
+                       gsh_handle_switch_argument(gsh, argc, argv, &counter)
                        : button_parse(gsh, argv[counter]);
 #ifdef LIBGC
        GC_gcollect();

Index: gtkshell/dialog_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/dialog_options.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- gtkshell/dialog_options.c   10 Dec 2007 15:14:32 -0000      1.24
+++ gtkshell/dialog_options.c   13 Dec 2007 17:20:24 -0000      1.25
@@ -23,50 +23,62 @@
 #include "gtkshell.h"
 
 void
-gsh_handle_dialog_arguments(GSH * gsh, const gint argc, const gchar **argv,
-                           gint *counter)
+gsh_dialog_about_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       g_assert(strlen(argv[(*counter)]) > 2);
-#ifdef DEBUG
-       ARPASSERT(gsh);
-#endif /* DEBUG */
-       switch (argv[(*counter)][2])
-       {
-       case 'a':
                gsh_about_dialog();
-               break;
-       case 'c':               /* Color Selection */
+}
+ 
+void
+gsh_dialog_color_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
                GSH_COLOR_DIALOG(gsh);
-               break;
-       case 'D':               /* Folder Creation Selector */
+}
+ 
+void
+gsh_dialog_folder_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
                GSH_FOLDER_CREATE_DIALOG(gsh);
-               break;
-       case 'd':               /* Folder Selector */
+}
+ 
+void
+gsh_dialog_folder_open_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
                GSH_FOLDER_OPEN_DIALOG(gsh);
-               break;
-       case 'e':               /* Error Message */
-               GSH_COUNT(argc, counter);
-               GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_ERROR, argv[*counter]);
-               break;
-       case 'F':               /* Font Selection */
+}
+ 
+void
+gsh_dialog_error_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
+       GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_ERROR, argv[++(*counter)]);
+}
+ 
+void
+gsh_dialog_font_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
                GSH_FONT_DIALOG(gsh);
-               break;
-       case 'f':
-               /* File Selection */
+}
+ 
+void
+gsh_dialog_file_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
                GSH_FILE_OPEN_DIALOG(gsh);
-               break;
-       case 'i':               /* Information */
-               GSH_COUNT(argc, counter);
-               GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_INFO, argv[*counter]);
-               break;
-       case 's':               /* Filename Selection for Saving */
+}
+ 
+void
+gsh_dialog_information_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
+       GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_INFO, argv[++(*counter)]);
+}
+ 
+void
+gsh_dialog_warning_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
+       GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_WARNING, argv[++(*counter)]);
+}
+ 
+void
+gsh_dialog_save_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
                GSH_FILE_SAVE_DIALOG(gsh);
-               break;
-       case 'w':               /* Warning */
-               GSH_COUNT(argc, counter);
-               GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_WARNING, argv[*counter]);
-               break;
-       default:
-               ARWARN("invalid dialog option");
-       }
 }
+ 

Index: gtkshell/dialog_options.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/dialog_options.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/dialog_options.h   11 Jun 2007 21:32:39 -0000      1.7
+++ gtkshell/dialog_options.h   13 Dec 2007 17:20:24 -0000      1.8
@@ -24,7 +24,33 @@
 #define GSH_DIALOG_OPTIONS
 
 void
-gsh_handle_dialog_arguments(GSH * gsh, const gint argc, const gchar **argv,
-                           gint *counter);
+gsh_dialog_about_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_color_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_folder_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_folder_open_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_error_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_font_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_file_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_information_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_warning_cb(GSH * gsh, gint * counter, const gchar ** argv);
+ 
+void
+gsh_dialog_save_cb(GSH * gsh, gint * counter, const gchar ** argv);
 
 #endif

Index: gtkshell/main.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/main.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- gtkshell/main.c     7 Dec 2007 20:00:25 -0000       1.31
+++ gtkshell/main.c     13 Dec 2007 17:20:24 -0000      1.32
@@ -78,7 +78,16 @@
        }
        make_window_for_args((const gint)argset->argc, 
                (const gchar **)argset->argv);
-       //$(argset, delete);
+       /*$(argset, delete);
+       if(gsh->command_dictionary)
+               $(gsh->command_dictionary, delete); */
+
+       /*
+               The following cause segmentation faults, so the hash
+               table cannot be freed.  
+               g_hash_table_destroy((gsh->command_dictionary->__hash));
+               g_assert(gsh->command_dictionary->__hash);
+               g_free(gsh->command_dictionary); */
 
        gtk_main(); /* application main loop  */
 

Index: gtkshell/option_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- gtkshell/option_options.c   10 Dec 2007 15:13:24 -0000      1.38
+++ gtkshell/option_options.c   13 Dec 2007 17:20:24 -0000      1.39
@@ -23,171 +23,4 @@
 
 #include "gtkshell.h"
 
-/* This is for windows that should not be touched by the window manager,
-   such as the ACE Deskbar panel.  */
-static void
-set_no_decorations(GSH * gsh)
-{
-       /* Alias to minimize dereferences through GSH.  */
-       GtkWindow * window;
-
-       /* Recreate main window as popup type.  This is not recommended, but is
-          necessary when using window managers that do not decorate according
-          to hints, such as evilwm.  */
-       gsh->widgets.window=gtk_window_new(GTK_WINDOW_POPUP);
-       window=GTK_WINDOW(gsh->widgets.window);
-
-       /* GTK WINDOW SET */
-#define GWS(attr, ...) gtk_window_set_##attr(window, __VA_ARGS__)
-       GWS(type_hint, GDK_WINDOW_TYPE_HINT_DESKTOP);
-       GWS(decorated, FALSE);
-       GWS(skip_taskbar_hint, TRUE);
-       /* Show window on all desktops.  */
-       gtk_window_stick(window);
-       /* Window does not seem to really accept focus when this is set, most
-          likely because of the POPUP option's side effect of overriding
-          window manager redirection. */
-       GWS(accept_focus, TRUE);
-}
-
-static void
-set_icon_size(GSH * gsh, const gchar * arg)
-{
-       /* Define some shortcuts.  */
-#define GIS gsh->icon_size
-       /* GTK_ICON_SIZE_ */
-#define GTKIS(size) GTK_ICON_SIZE_##size
-       /* Test for gsh->icon_size equality.  */
-#define GISCMP(text) !strcmp(text, arg)
-
-#define IFGISCMP(str, siz) if(GISCMP(str)) GIS=GTKIS(MENU);
-
-
-       if(GISCMP("menu"))
-               GIS=GTKIS(MENU);
-       else if(GISCMP("small toolbar"))
-               GIS=GTKIS(SMALL_TOOLBAR);
-       else if(GISCMP("large toolbar") || GISCMP("toolbar"))
-               GIS=GTKIS(LARGE_TOOLBAR);
-       else if(GISCMP("button"))
-               GIS=GTKIS(BUTTON);
-       else if(GISCMP("dialog"))       
-               GIS=GTKIS(DIALOG);
-       else /* default */
-               GIS=GTKIS(DND);
-
-       GSH_SET(GSH_ICON_SIZE_IS_CUSTOM);
-}
-
-void
-gsh_handle_option_arguments(GSH * gsh, const gint argc, const gchar **argv,
-       gint *counter)
-{
-       switch (argv[(*counter)][2])
-       {
-       case 'a':
-               /* Run in application mode.  Here, a menu bar and status
-                  bar encloses the application.  This option may also affect
-                  other gtkshell properties in the future.  */
-               GSH_SET(GSH_APP_MODE);
-               break;
-       case 'C': 
-               /* Check for the existance of a widget's command before
-                  displaying an item for it.  */
-               GSH_SET(GSH_CHECK_COMMANDS);
-               break;
-       case 'c':
-               /* Set text widget background and foreground colors.  */
-               GSH_COUNT(argc, counter);
-               gsh->editor.bgcolor=(gchar *)argv[*counter];
-               GSH_COUNT(argc, counter);
-               gsh->editor.fgcolor=(gchar *)argv[*counter];
-               break;
-       case 'D':
-               /* Do not insert the dummy "guidl" string before the
-                  arguments passed by means of a guidl definition.  
-                  It is not necessary to include this as an option
-                  within the guidl description itself, as the dummy
-                  option is inserted prior to parsing.  */
-               GSH_SET(GSH_GUIDL_NO_DUMMY);
-               break;
-
-       case 'E':               /* Make a text entry simply print the
-                                * text.  */
-               GSH_SET(GSH_PROMPT_ECHOES);
-               break;
-
-       case 'e':
-               GSH_SET(GSH_CBEXIT);
-               break;
-
-       case 'F':
-               GSH_SET(GSH_NO_BASE_FRAME);
-               break;
-
-       case 'f':
-               GSH_SET(GSH_FRAMED_LABELS);
-               break;
-
-       case 'g':
-               GSH_COUNT(argc, counter);
-
-               ARIFP(gsh->geometry)
-                       free(gsh->geometry);
-
-               ar_asprintf(&gsh->geometry, "%s", argv[(*counter)]);
-
-               break;
-       case 'H':
-               GSH_SET(GSH_HORIZ_CLOCK);
-               break;
-       case 'h':
-               GSH_SET(GSH_HORIZONTAL_LABELS);
-               break;
-       case 'i':
-               GSH_COUNT(argc, counter);
-               set_icon_size(gsh, argv[*counter]);
-               break;
-       case 'l':
-               GSH_SET(GSH_NO_EXPAND);
-               break;
-
-       case 'L':
-               GSH_UNSET(GSH_NO_EXPAND);
-               break;
-
-       case 'n': /* no decorations, desktop panel not to be touched by the
-                  * window manager.  */
-               set_no_decorations(gsh);
-               break;
-
-       case 'p': /* Pane next widget with previous.  */
-               GSH_SET(GSH_PANE_NEXT);
-               break;
-
-       case 'r': /* Set number of rows per column.  */
-               GSH_COUNT(argc, counter);
-               gsh->rows->total=(unsigned int)atoi(argv[(*counter)]);
-               break;
-
-       case 's': /* Use scrolling parent container.  */
-               GSH_SET(GSH_SCROLL);
-               break;
-
-       case 'T': /* Set the window title.  */
-               GSH_COUNT(argc, counter);
-               gtk_window_set_title(GTK_WINDOW(gsh->widgets.window),
-                               argv[*counter]);
-               break;
-
-       case 't':
-               gsh_handle_terminal_options(gsh, argc, argv, counter);
-               break;
-
-       case 'u': /* Set time for updating widgets' timer, in miliseconds.  */
-               GSH_COUNT(argc, counter);
-               gsh->update->period = atoi(argv[*counter]);
-               break;
-       }
-}
 

Index: gtkshell/option_options.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gtkshell/option_options.h   11 Jun 2007 21:32:43 -0000      1.9
+++ gtkshell/option_options.h   13 Dec 2007 17:20:25 -0000      1.10
@@ -23,8 +23,4 @@
 #ifndef GSH_OPTION_OPTIONS_H
 #define GSH_OPTION_OPTIONS_H
 
-void
-gsh_handle_option_arguments(GSH * gsh, const gint argc, const gchar **argv, 
-       gint *counter);
-
 #endif

Index: gtkshell/options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- gtkshell/options.c  13 Dec 2007 03:31:25 -0000      1.37
+++ gtkshell/options.c  13 Dec 2007 17:20:25 -0000      1.38
@@ -142,8 +142,7 @@
 static void
 add_label_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       GSH_COUNT(argc, counter);
-       $(gsh, add.label, argv[*counter]);
+       $(gsh, add.label, argv[++(*counter)]);
 }
 
 static void
@@ -173,9 +172,9 @@
        GSHQuickStart * quickstart;
 
        quickstart=ARNEW(gsh, GSHQuickStart);
-       GSH_COUNT(argc, counter);
+       (*counter)++;
        $(quickstart, add ,gsh, argv[*counter], argv[(*counter)+1]);
-       GSH_COUNT(argc, counter);
+       (*counter)++;
        $(gsh, manage, $(quickstart, getColumn));
 #else /* ! GSH_USE_QUICKSTART */
 #endif /* GSH_USE_QUICKSTART */
@@ -253,15 +252,15 @@
 }
 
 static void
-add_updating_label_cb(GSH * gsh, gint * counter, const gchar ** argv)
+add_updating_progress_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       gsh_add_updated_label(gsh, argv[++(*counter)]);
+       gsh_add_updated_progress(gsh, argv[++(*counter)]);
 }
 
 static void
-add_updating_progress_cb(GSH * gsh, gint * counter, const gchar ** argv)
+add_updating_label_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       gsh_add_updated_progress(gsh, argv[++(*counter)]);
+       gsh_add_updated_label(gsh, argv[++(*counter)]);
 }
 
 static void
@@ -316,8 +315,7 @@
 static void
 add_embedded_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       GSH_COUNT(argc, counter);
-       gsh_add_embedded(gsh, (char *)argv[*counter]);
+       gsh_add_embedded(gsh, (char *)argv[++(*counter)]);
 }
 
 
@@ -338,10 +336,8 @@
 static void
 option_color_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       GSH_COUNT(argc, counter);
-       gsh->editor.bgcolor=(gchar *)argv[*counter];
-       GSH_COUNT(argc, counter);
-       gsh->editor.fgcolor=(gchar *)argv[*counter];
+       gsh->editor.bgcolor=(gchar *)argv[++(*counter)];
+       gsh->editor.fgcolor=(gchar *)argv[++(*counter)];
 }
 
 static void
@@ -379,8 +375,7 @@
 {
        ARIFP(gsh->geometry)
                g_free(gsh->geometry);
-       GSH_COUNT(argc, counter);
-       gsh->geometry=g_strdup(argv[*counter]);
+       gsh->geometry=g_strdup(argv[++(*counter)]);
 }
 
 static void
@@ -457,8 +452,7 @@
 static void
 option_rows_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       GSH_COUNT(argc, counter);
-       gsh->rows->total=(unsigned int)atoi(argv[*counter]);
+       gsh->rows->total=(unsigned int)atoi(argv[++(*counter)]);
 }
 
 static void
@@ -470,16 +464,20 @@
 static void
 option_title_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       GSH_COUNT(argc, counter);
        gtk_window_set_title(GTK_WINDOW(gsh->widgets.window),
-               argv[*counter]);
+               argv[++(*counter)]);
 }
 
 static void
 option_update_cb(GSH * gsh, gint * counter, const gchar ** argv)
 {
-       GSH_COUNT(argc, counter);
-       gsh->update->period=atoi(argv[*counter]);
+       gsh->update->period=atoi(argv[++(*counter)]);
+}
+
+static void
+guidl_file_cb(GSH * gsh, gint * counter, const gchar ** argv)
+{
+       guidl_handler_for_file(gsh, argv[++(*counter)]);
 }
 
 ARTupleVector *
@@ -492,6 +490,7 @@
 
        dictionary=ARNEW(ar, ARTupleVector);
 
+       /* Widgets */
        ARTDEF("-aAc", add_applet_clock_cb);
        ARTDEF("-ab", add_pane_cb);
        ARTDEF("-acb", add_commanded_button_cb);
@@ -512,9 +511,11 @@
        ARTDEF("-aw", add_window_cb);
        ARTDEF("-aX", add_embedded_cb);
 
+       /* Updating widgets */
        ARTDEF("-aul", add_updating_label_cb);
        ARTDEF("-aup", add_updating_progress_cb);
 
+       /* Options */
        ARTDEF("-oa", option_app_mode_cb);
        ARTDEF("-oC", option_check_commands_cb);
        ARTDEF("-oc", option_color_cb);
@@ -536,6 +537,7 @@
        ARTDEF("-oT", option_title_cb);
        ARTDEF("-ou", option_update_cb);
 
+       /* Terminal options */
        ARTDEF("-otf", option_terminal_font_cb);
        ARTDEF("-oth", option_terminal_height_cb);
        ARTDEF("-otN", option_terminal_not_tab_cb);
@@ -543,8 +545,23 @@
        ARTDEF("-otT", option_terminal_transparent_cb);
        ARTDEF("-otw", option_terminal_width_cb);
 
+       /* Dialog options */
+       ARTDEF("-da", gsh_dialog_about_cb);
+       ARTDEF("-dc", gsh_dialog_color_cb);
+       ARTDEF("-dD", gsh_dialog_folder_cb);
+       ARTDEF("-dd", gsh_dialog_folder_open_cb);
+       ARTDEF("-de", gsh_dialog_error_cb);
+       ARTDEF("-dF", gsh_dialog_font_cb);
+       ARTDEF("-df", gsh_dialog_file_cb);
+       ARTDEF("-di", gsh_dialog_information_cb);
+       ARTDEF("-ds", gsh_dialog_save_cb);
+       ARTDEF("-dw", gsh_dialog_warning_cb);
+
+       /* Test */
        ARTDEF("-t", test_cb);
        
+       /* GUIDL file */
+       ARTDEF("-f", guidl_file_cb);
        
        return dictionary;
 }
@@ -553,39 +570,23 @@
 gsh_handle_switch_argument(GSH * gsh, const gint argc, const gchar ** argv,
        gint * counter)
 {
-       void (*callback)(GSH *, gint *, const gchar **);
+       void (*callback)(GSH *, gint *, const gchar **)=NULL;
        ARTupleVector * dict;
 
+       /* Needed for proper widget layout.  */
+       $(gsh->rows, check);
+
+       /* Define command line option dictionary if such has not already
+          been done.  */
        if(!(dict=gsh->command_dictionary))
                dict=gsh->command_dictionary=gsh_define_command_line_options();
+       /* Look up the callback per command line switch.  */
        callback=(void (*)(GSH *, gint *, const gchar **))
                $(dict, find, argv[*counter]);
+       /* Execute callback if lookup fruitful.  */
+       if(callback)
        callback(gsh, counter, argv);
-}
-
-void
-gsh_handle_switch_arguments(GSH * gsh, const gint argc, const gchar **argv, 
-       gint *counter)
-{
-       $(gsh->rows, check);
-       switch (argv[*counter][1])
-       {
-       case 'a':
-               HANDLE(add);
-               break;
-       case 'd':
-               HANDLE(dialog);
-               break;
-       case 'f':
-               GSH_COUNT(argc, counter);
-               guidl_handler_for_file(gsh, argv[*counter]);
-               break;
-       case 'o':
-               HANDLE(option);
-               break;
-       case 't': /* test area.  */
-               break;
-       default:
+       else /* Invalid option, display warning */
                gsh_invalid_option(argv, *counter);
-       }
 }
+

Index: gtkshell/options.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gtkshell/options.h  11 Jun 2007 21:32:43 -0000      1.9
+++ gtkshell/options.h  13 Dec 2007 17:20:25 -0000      1.10
@@ -39,7 +39,7 @@
 #endif /* DEBUG */
 
 void
-gsh_handle_switch_arguments(GSH * gsh, const gint argc, const gchar **argv, 
+gsh_handle_switch_argument(GSH * gsh, const gint argc, const gchar **argv, 
        gint *counter);
 
 #endif /* not GSH_OPTIONS_H */

Index: gtkshell/updated_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_options.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- gtkshell/updated_options.c  11 Jun 2007 21:32:45 -0000      1.22
+++ gtkshell/updated_options.c  13 Dec 2007 17:20:25 -0000      1.23
@@ -22,33 +22,3 @@
 
 #include "gtkshell.h"
 
-static void
-add_updater(GSH * gsh, const gint argc, gint * counter, 
-       const gchar ** argv, void (*add_func)(GSH *, const gchar *))
-{
-       GSH_COUNT(argc, counter);
-       add_func(gsh, argv[*counter]);
-}
-
-#define UADD(type) \
-       add_updater(gsh, argc, counter, argv, &gsh_add_updated_##type)
-
-void
-gsh_handle_updated_arguments(GSH * gsh, const gint argc,
-                            const gchar **argv, gint *counter)
-{
-#ifdef DEBUG
-       ARPASSERT(gsh);
-#endif /* DEBUG */
-
-       g_assert(strlen(argv[(*counter)]) > 2);
-       switch (argv[(*counter)][3])
-       {
-       case 'l':
-               UADD(label);
-               break;
-       case 'p':
-               UADD(progress);
-               break;
-       }
-}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]