antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/gtkshell add_options.c image_button.c...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell add_options.c image_button.c...
Date: Fri, 02 Mar 2007 15:40:02 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/03/02 15:40:02

Modified files:
        gtkshell       : add_options.c image_button.c image_button.h 

Log message:
        Added stock icon support with -aS.  Use generic argument handler
        for image button.  Add functions implemented using pointer function
        to the button type.  Use generic image button creation function, with
        image widget passed.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/add_options.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/image_button.c?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/image_button.h?cvsroot=antiright&r1=1.1&r2=1.2

Patches:
Index: add_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/add_options.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- add_options.c       2 Mar 2007 03:56:07 -0000       1.11
+++ add_options.c       2 Mar 2007 15:40:01 -0000       1.12
@@ -73,7 +73,9 @@
        case 'r': /* Force creation of a new row.  */
                gsh_new_row(gsh);
                break;
-
+       case 'S': /* Add stock icon.  */
+               gsh_handle_add_stock_button(gsh, argc, argv, counter);
+               break;
        case 't':
                if (argc != *counter)
                        gsh_count(argc, counter);

Index: image_button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/image_button.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- image_button.c      2 Mar 2007 15:04:14 -0000       1.1
+++ image_button.c      2 Mar 2007 15:40:01 -0000       1.2
@@ -22,26 +22,58 @@
 
 #include "gtkshell.h"
 
+
+static void 
+generic_image_button(struct GSH * gsh, char *command, 
+                    GtkWidget * image)
+{
+       gsh_command_button(gsh, command);
+       gtk_button_set_image(GTK_BUTTON(gsh->button), image);
+       gtk_button_set_relief(GTK_BUTTON(gsh->button), GTK_RELIEF_NONE);
+}
+
+void
+gsh_stock_image_button(struct GSH * gsh, char *command, char *stock_id)
+{
+       GtkWidget *image;
+
+       image=gtk_image_new_from_stock((const gchar *)stock_id,
+                                      GTK_ICON_SIZE_LARGE_TOOLBAR);
+       generic_image_button(gsh, command, image);
+}
+
 void
 gsh_image_button(struct GSH * gsh, char *command, char *filename)
 {
        GtkWidget *image;
 
        image = gtk_image_new_from_file(filename);
-       gsh_command_button(gsh, command);
-       gtk_button_set_image(GTK_BUTTON(gsh->button), image);
-       gtk_button_set_relief(GTK_BUTTON(gsh->button), GTK_RELIEF_NONE);
+       generic_image_button(gsh, command, image);
+}
+
+static void
+generic_add(struct GSH * gsh, int argc, char **argv, int *counter,
+           void (*button_func)(struct GSH *, char *, char *))
+{
+       gsh_count(argc, counter);
+       (*button_func)(gsh, argv[(*counter)], argv[(*counter) + 1]);
+       gsh_count(argc, counter);
 }
 
 void
 gsh_handle_add_image_button(struct GSH * gsh, int argc, 
                            char **argv, int *counter)
 {
-       gsh_count(argc, counter);
-       gsh_image_button(gsh, argv[(*counter)],
-                        argv[(*counter) + 1]);
-       gsh_count(argc, counter);
+       generic_add(gsh, argc, argv, counter, &gsh_image_button);
 }
+
+void
+gsh_handle_add_stock_button(struct GSH * gsh, int argc, char **argv, 
+                           int * counter)
+{
+       generic_add(gsh, argc, argv, counter, &gsh_stock_image_button);
+}
+
 void
 gsh_handle_add_unlabeled_image_button(struct GSH * gsh, int argc, 
                                      char **argv, int *counter)

Index: image_button.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/image_button.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- image_button.h      2 Mar 2007 15:04:14 -0000       1.1
+++ image_button.h      2 Mar 2007 15:40:01 -0000       1.2
@@ -34,4 +34,9 @@
 gsh_handle_add_unlabeled_image_button(struct GSH * gsh, int argc, 
                                      char **argv, int *counter);
 
+void
+gsh_stock_image_button(struct GSH * gsh, char *command, 
+                      char *stock_id);
+
 #endif /* GSH_IMAGE_BUTTON_H */
+




reply via email to

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