antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/gtkshell dialog_options.c guidl_dicti...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell dialog_options.c guidl_dicti...
Date: Wed, 09 May 2007 17:20:53 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/05/09 17:20:53

Modified files:
        gtkshell       : dialog_options.c guidl_dictionary.c 
                         guidl_util.c image_button.c updated.c 
                         updated_options.c updated_progress.c 

Log message:
        Continued removal of stub static functions in favor of macros, where
        such functions are only used once and waste symbol table space.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog_options.c?cvsroot=antiright&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_dictionary.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_util.c?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/image_button.c?cvsroot=antiright&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.c?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_options.c?cvsroot=antiright&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_progress.c?cvsroot=antiright&r1=1.13&r2=1.14

Patches:
Index: dialog_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/dialog_options.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- dialog_options.c    5 May 2007 23:38:07 -0000       1.16
+++ dialog_options.c    9 May 2007 17:20:53 -0000       1.17
@@ -28,12 +28,6 @@
                   char *text) __attribute__((noreturn));
 
 static void
-gsh_setup_message_dialog(struct GSH * gsh, 
-                        int argc, char **argv,
-                        int *counter, 
-                        GtkMessageType type) __attribute__((noreturn));
-
-static void
 gsh_font_dialog() __attribute__((noreturn));
 
 static void
@@ -54,13 +48,14 @@
        exit(0);
 }
 
-static void
-gsh_setup_message_dialog(struct GSH * gsh, int argc, char **argv,
-                        int *counter, GtkMessageType type)
-{
-       GSH_COUNT(argc, counter);
-       gsh_message_dialog(gsh, type, argv[(*counter)]);
-}
+#define GMD gsh_message_dialog
+
+#define ERROR_DIALOG(gsh, message) \
+       GMD(gsh, GTK_MESSAGE_ERROR, message)
+#define INFO_DIALOG(gsh, message) \
+       GMD(gsh, GTK_MESSAGE_INFO, message)
+#define WARNING_DIALOG(gsh, message) \
+       GMD(gsh, GTK_MESSAGE_WARNING, message)
 
 static void
 select_font(GtkWidget * dialog)
@@ -133,8 +128,8 @@
                gsh_folder_open_dialog(gsh);
                break;
        case 'e':               /* Error Message */
-               gsh_setup_message_dialog(gsh, argc, argv,
-                                        counter, GTK_MESSAGE_ERROR);
+               GSH_COUNT(argc, counter);
+               ERROR_DIALOG(gsh, argv[*counter]);
                break;
        case 'F':               /* Font Selection */
                gsh_font_dialog();
@@ -143,16 +138,15 @@
                gsh_file_open_dialog(gsh);
                break;
        case 'i':               /* Information */
-               gsh_setup_message_dialog(gsh, argc, argv,
-                                        counter, GTK_MESSAGE_INFO);
+               GSH_COUNT(argc, counter);
+               INFO_DIALOG(gsh, argv[*counter]);
                break;
        case 's':               /* Filename Selection for Saving */
                gsh_file_save_dialog(gsh);
                break;
        case 'w':               /* Warning */
-               gsh_setup_message_dialog(gsh, argc, argv,
-                                        counter,
-                                        GTK_MESSAGE_WARNING);
+               GSH_COUNT(argc, counter);
+               WARNING_DIALOG(gsh, argv[*counter]);
                break;
 
        }

Index: guidl_dictionary.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_dictionary.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- guidl_dictionary.c  6 May 2007 05:00:11 -0000       1.4
+++ guidl_dictionary.c  9 May 2007 17:20:53 -0000       1.5
@@ -33,28 +33,35 @@
        }\
 }
 
-static void
-gsh_delete_GDLDictionaries_contents(struct GDLDictionaries * dictionaries)
-{
-       GSH_DELETE_DICTIONARY(dictionaries, widget);
-       GSH_DELETE_DICTIONARY(dictionaries, option);
-       GSH_DELETE_DICTIONARY(dictionaries, dialog);
+#define GDD(dict) GSH_DELETE_DICTIONARY(dictionaries, dict);
+
+#define DELETE_CONTENTS()\
+{\
+       GDD(widget)\
+       GDD(option)\
+       GDD(dialog)\
 }
 
 static void
 gsh_delete_GDLDictionaries(struct GDLDictionaries * dictionaries)
 {
-       gsh_delete_GDLDictionaries_contents(dictionaries);
+       DELETE_CONTENTS();
        g_free(dictionaries);
 }
 
-static void
-gsh_GDLDictionaries_setup(struct GDLDictionaries * dictionaries)
-{
-       dictionaries->widget=NULL;
-       dictionaries->option=NULL;
-       dictionaries->dialog=NULL;
-       dictionaries->delete=&gsh_delete_GDLDictionaries;
+#define NULLIFY(dict) dictionaries->dict=NULL
+
+#define INITIALIZE_MEMBER_FIELDS() \
+{\
+       NULLIFY(widget);\
+       NULLIFY(dialog);\
+       NULLIFY(option);\
+}
+
+#define SETUP_GDLDICTIONARIES()\
+{\
+       INITIALIZE_MEMBER_FIELDS();\
+       dictionaries->delete=&gsh_delete_GDLDictionaries;\
 }
 
 struct GDLDictionaries *
@@ -63,7 +70,7 @@
        struct GDLDictionaries * dictionaries;
 
        dictionaries=g_malloc(sizeof(struct GDLDictionaries));
-       gsh_GDLDictionaries_setup(dictionaries);
+       SETUP_GDLDICTIONARIES();
 
        return dictionaries;
 }

Index: guidl_util.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_util.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- guidl_util.c        3 May 2007 22:55:10 -0000       1.15
+++ guidl_util.c        9 May 2007 17:20:53 -0000       1.16
@@ -54,13 +54,23 @@
        }
 }
 
+#define CONSTRUCT_MEMBER_CLASSES(env)\
+{\
+       env->args=ARNEW(ar, ARArguments);\
+       env->dictionaries=ARNEW(gsh, GDLDictionaries);\
+}
+
+#define ASSIGN_METHODS(env)\
+{\
+       env->delete=&gsh_delete_GDLEnvironment;\
+       env->add=&gsh_GDLEnvironment_add;\
+}
+
 static struct GDLEnvironment *
 gsh_setup_GDLEnvironment(struct GDLEnvironment * env)
 {
-       env->args=ARNEW(ar, ARArguments);
-       env->dictionaries=ARNEW(gsh, GDLDictionaries);
-       env->delete=&gsh_delete_GDLEnvironment;
-       env->add=&gsh_GDLEnvironment_add;
+       CONSTRUCT_MEMBER_CLASSES(env);
+       ASSIGN_METHODS(env);
 
        return env;
 }

Index: image_button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/image_button.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- image_button.c      6 May 2007 06:23:36 -0000       1.13
+++ image_button.c      9 May 2007 17:20:53 -0000       1.14
@@ -55,19 +55,9 @@
 generic_image_button(struct GSH * gsh, const gchar *command, 
                     GtkWidget * image)
 {
-       gsh_command_button(gsh, command);
-       ARIFP(image)
-       {
-               gtk_widget_show(image);
-               if(!GTK_IS_MENU_BAR(gsh->rows->v) 
-                  && !GTK_IS_MENU_ITEM(gsh->rows->v)
-                  && !GTK_IS_MENU(gsh->rows->v))
-                       set_button_image(gsh, image);
-               else
-                       set_menu_item_image(gsh, image);
-       }
 }
 
+
 /* Get an image from the antiright icon distribution or the GTK stock
    icon set.  */
 static GtkWidget * 
@@ -76,8 +66,10 @@
        gchar * prefixed_name;
        GtkWidget * image;
 
-       ar_asprintf(&prefixed_name, "%s/share/ACE-desktop/icons/%s", 
-                           PREFIX, name);
+       ar_asprintf(&prefixed_name, PREFIX "/share/ACE-desktop/icons/%s", 
+                       name);
+       /* Determine whether to use the file name constructed in prefixed_name
+        * or to use a stock icon (tried if the file does not exit).  */
        image = g_file_test(prefixed_name, G_FILE_TEST_EXISTS)
                ? gtk_image_new_from_file(prefixed_name)
                : gtk_image_new_from_stock(name, gsh->icon_size);
@@ -97,6 +89,17 @@
 void
 gsh_image_button(struct GSH * gsh, char *command, char *name)
 {
-       generic_image_button(gsh, command, get_image(gsh, name));
+       //generic_image_button(gsh, command, get_image(gsh, name));
+       gsh_command_button(gsh, command);
+       ARIFP(image)
+       {
+               gtk_widget_show(image);
+               if(!GTK_IS_MENU_BAR(gsh->rows->v) 
+                  && !GTK_IS_MENU_ITEM(gsh->rows->v)
+                  && !GTK_IS_MENU(gsh->rows->v))
+                       set_button_image(gsh, image);
+               else
+                       set_menu_item_image(gsh, image);
+       }
 }
 

Index: updated.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- updated.c   3 May 2007 04:36:18 -0000       1.15
+++ updated.c   9 May 2007 17:20:53 -0000       1.16
@@ -42,9 +42,13 @@
        struct GSHUpdatedWidget * updater;
 
        updater=xmalloc(sizeof(struct GSHUpdatedWidget));
+       /* Assign widget-specific update information, specifically
+        * the widget command, a pointer to the widget, and the widget's
+        * updater function.  */
        updater->command=g_strdup(command);
        updater->widget=widget;
        updater->function=function;
+       /* Assign GSHUpdatedWidget class methods.  */
        updater->update=&gsh_GSHUpdatedWidget_update;
        updater->delete=&gsh_delete_GSHUpdatedWidget;
 

Index: updated_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_options.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- updated_options.c   4 May 2007 00:59:58 -0000       1.14
+++ updated_options.c   9 May 2007 17:20:53 -0000       1.15
@@ -22,25 +22,23 @@
 
 #include "gtkshell.h"
 
-static void
-gsh_test_updating(struct GSH * gsh)
-{
-#ifdef DEBUG
-       ARPASSERT(gsh);
-#endif /* DEBUG */
-       if(!(GSH_FLAG(GSH_UPDATING)))
-       {
-               $(gsh->update, start);
-               GSH_SET(GSH_UPDATING);
-       }
-
+#define GSH_TEST_UPDATING(gsh)\
+{\
+       if(!(GSH_FLAG(GSH_UPDATING)))\
+       {\
+               $(gsh->update, start);\
+                GSH_SET(GSH_UPDATING);\
+        }\
 }
 
 static void
 gsh_updater_argument_generic(struct GSH * gsh, int argc, int *counter)
 {
+#ifdef DEBUG
+       ARPASSERT(gsh);
+#endif /* DEBUG */
        GSH_COUNT(argc, counter);
-       gsh_test_updating(gsh);
+       GSH_TEST_UPDATING(gsh);
 }
 
 static void
@@ -49,6 +47,8 @@
 {
 #ifdef DEBUG
        ARBUG("add_updater()");
+       ARPASSERT(gsh);
+       ARPASSERT(add_func);
 #endif /* DEBUG */
 
        (*add_func)(gsh, (const gchar *)argv[*counter+1]);
@@ -59,16 +59,20 @@
 gsh_handle_updated_arguments(struct GSH * gsh, int argc,
                             char **argv, int *counter)
 {
+#ifdef DEBUG
+       ARPASSERT(gsh);
+#endif /* DEBUG */
+
        g_assert(strlen(argv[(*counter)]) > 2);
        switch (argv[(*counter)][3])
        {
+#define ADD_UPDATER(func)\
+               add_updater(gsh, argc, counter, argv, &func)
        case 'l':
-               add_updater(gsh, argc, counter, argv,
-                           &gsh_add_updated_label);
+               ADD_UPDATER(gsh_add_updated_label);
                break;
        case 'p':
-               add_updater(gsh, argc, counter, argv,
-                           &gsh_add_updated_progress);
+               ADD_UPDATER(gsh_add_updated_progress);
                break;
        }
 }

Index: updated_progress.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_progress.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- updated_progress.c  3 May 2007 22:55:10 -0000       1.13
+++ updated_progress.c  9 May 2007 17:20:53 -0000       1.14
@@ -36,6 +36,7 @@
                strtod(results=antiright_pipe_read((char*)command), NULL));
        g_free(results);
 }
+
 void
 gsh_add_updated_progress(struct GSH * gsh, const gchar *command)
 {




reply via email to

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