antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/gtkshell Makefile arguments.c button....


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell Makefile arguments.c button....
Date: Fri, 06 Apr 2007 15:05:28 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/04/06 15:05:28

Modified files:
        gtkshell       : Makefile arguments.c button.c button.h 
                         gtkshell.h 
Added files:
        gtkshell       : menu.c menu.h 

Log message:
        Split button and menu code from arguments.c.
        Created menu.[ch].  Added gsh_new_button function
        for generic button creation using a comma-separated
        pair.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/arguments.c?cvsroot=antiright&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.h?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.h?cvsroot=antiright&rev=1.1

Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- Makefile    2 Apr 2007 18:31:41 -0000       1.19
+++ Makefile    6 Apr 2007 15:05:28 -0000       1.20
@@ -36,7 +36,7 @@
        label.o button.o text.o updated_label.o updated_progress.o\
        updated_options.o add_options.o option_options.o dialog_options.o\
        file_dialog.o row.o containers.o geometry.o font.o dragdrop.o\
-       image_button.o terminal.o terminal_options.o\
+       image_button.o terminal.o terminal_options.o menu.o\
        guidl_util.o about_dialog.o
 
 program=main.o 

Index: arguments.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/arguments.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- arguments.c 2 Apr 2007 18:42:52 -0000       1.16
+++ arguments.c 6 Apr 2007 15:05:28 -0000       1.17
@@ -1,6 +1,6 @@
 /*
   AntiRight
-  (c) 2002-2006 Jeffrey Bedard
+  (c) 2002-2007 Jeffrey Bedard
   address@hidden
 
   This file is part of AntiRight.
@@ -24,103 +24,7 @@
 #include "gtkshell.h"
 
 #define SPLIT_ALL -1
-
-static void
-new_button(struct GSH * gsh, gchar * string)
-{
-       /address@hidden@*/ gchar **pair;
-
-       pair=g_strsplit(string, ",", 2);
-
-
-       if(ARPBOOL(pair[0]) && ARPBOOL(pair[1]))
-       {
-               gchar * command;
-               gint return_value;
-
-               return_value=ar_asprintf(&command, 
-                                        "%s", pair[0]);
-               if(return_value != -1)
-                       gsh_image_button(gsh, command, pair[1]);
-               else
-                       ARWARN("cannot create button");
-       }
-       else
-               gsh_command_button(gsh, string);
-
-       g_strfreev(pair);
-}
-
-static void
-menuitem_parse(struct GSH * gsh, gchar * string)
-{
-       gchar **pair;
-       gchar * command;
-
-       pair=g_strsplit(string, ",", 2);
-
-       if(ar_asprintf(&command, "%s", pair[0]) == -1)
-       {
-               ARWARN("could not construct command string");
-               return;
-       }
-
-       ARPASSERT(command);
-
-       if(ARPBOOL(pair[0]) && ARPBOOL(pair[1]))
-               gsh_image_button(gsh, command, pair[1]);
-       else
-               gsh_command_button(gsh, command);
-
-       g_strfreev(pair);
-}
-
-static gint
-popup_handler(GtkWidget * widget, GdkEvent * event)
-{
-       GdkEventButton *event_button;
-
-       event_button=(GdkEventButton *)event;
-       gtk_menu_popup(GTK_MENU(widget), 
-               NULL, NULL, NULL, NULL, 
-               event_button->button, event_button->time);
-
-       return TRUE;
-}
-
-static void
-add_menu_items(struct GSH * gsh, gchar **tokens)
-{
-       gint i;
-
-       for(i=1; ARPBOOL(tokens[i]); i++)
-               menuitem_parse(gsh, tokens[i]);
-}
-
-static void
-menubutton_parse(struct GSH * gsh, gchar **tokens)
-
-{
-       GtkWidget * oldrow;
-
-       oldrow=gsh->rows.v;
-
-       /* Set gsh->rows.v to a row within a menu.
-        * Create the menu before overwriting, then
-        * set back at end.  */
-       gsh->bflags |= GSH_MENU_BUTTON;
-       /* Add menu launcher button.  */
-       new_button(gsh, tokens[0]);
-       gsh->rows.v=gtk_menu_new(); 
-       gtk_widget_show(gsh->rows.v);
-       g_signal_connect_swapped(gsh->button, "clicked",
-                       G_CALLBACK(popup_handler), gsh->rows.v);
-
-       add_menu_items(gsh, tokens);
-
-       gsh->rows.v=oldrow;
-}
-
+/* Decide whether to use a regular button or a menu button.  */
 static void
 button_parse(struct GSH * gsh, const gchar * string)
 {
@@ -130,7 +34,7 @@
        if(ARPBOOL(tokens[1]))
                menubutton_parse(gsh, tokens);
        else
-               new_button(gsh, (char *)string);
+               gsh_new_button(gsh, (char *)string);
 
        g_strfreev(tokens);
 }

Index: button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- button.c    5 Mar 2007 01:05:42 -0000       1.20
+++ button.c    6 Apr 2007 15:05:28 -0000       1.21
@@ -123,3 +123,31 @@
 }
 
 
+void
+gsh_new_button(struct GSH * gsh, gchar * string)
+{
+       gchar **pair;
+
+       pair=g_strsplit(string, ",", 2);
+
+
+       if(ARPBOOL(pair[0]) && ARPBOOL(pair[1]))
+       {
+               gchar * command;
+               gint return_value;
+
+               return_value=ar_asprintf(&command, 
+                                        "%s", pair[0]);
+               if(return_value != -1)
+                       gsh_image_button(gsh, command, pair[1]);
+               else
+                       ARWARN("cannot create button");
+       }
+       else
+               gsh_command_button(gsh, string);
+
+       g_strfreev(pair);
+}
+
+
+

Index: button.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- button.h    2 Mar 2007 03:56:07 -0000       1.5
+++ button.h    6 Apr 2007 15:05:28 -0000       1.6
@@ -26,4 +26,7 @@
 void
 gsh_command_button(struct GSH * gsh, char *command);
 
+void 
+gsh_new_button(struct GSH * gsh, gchar * string);
+
 #endif

Index: gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- gtkshell.h  2 Apr 2007 18:31:41 -0000       1.29
+++ gtkshell.h  6 Apr 2007 15:05:28 -0000       1.30
@@ -93,6 +93,7 @@
 #include "terminal.h"
 #include "guidl_util.h"
 #include "about_dialog.h"
+#include "menu.h"
 
 void
 gsh_stack_init(struct GSH * gsh, int *argc, char ***argv);

Index: menu.c
===================================================================
RCS file: menu.c
diff -N menu.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ menu.c      6 Apr 2007 15:05:28 -0000       1.1
@@ -0,0 +1,98 @@
+/*
+  AntiRight
+  (c) 2006-2007 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+  Boston, MA  02110-1301  USA
+*/
+
+#include "gtkshell.h"
+
+#define SPLIT_ALL -1
+
+static void
+menuitem_parse(struct GSH * gsh, gchar * string)
+{
+       gchar **pair;
+       gchar * command;
+
+       pair=g_strsplit(string, ",", 2);
+
+       if(ar_asprintf(&command, "%s", pair[0]) == -1)
+       {
+               ARWARN("could not construct command string");
+               return;
+       }
+
+       ARPASSERT(command);
+
+       if(ARPBOOL(pair[0]) && ARPBOOL(pair[1]))
+               gsh_image_button(gsh, command, pair[1]);
+       else
+               gsh_command_button(gsh, command);
+
+       g_strfreev(pair);
+}
+
+static gint
+popup_handler(GtkWidget * widget, GdkEvent * event)
+{
+       GdkEventButton *event_button;
+
+       event_button=(GdkEventButton *)event;
+       gtk_menu_popup(GTK_MENU(widget), 
+               NULL, NULL, NULL, NULL, 
+               event_button->button, event_button->time);
+
+       return TRUE;
+}
+
+static void
+add_menu_items(struct GSH * gsh, gchar **tokens)
+{
+       gint i;
+
+       for(i=1; ARPBOOL(tokens[i]); i++)
+               menuitem_parse(gsh, tokens[i]);
+}
+
+void
+menubutton_parse(struct GSH * gsh, gchar **tokens)
+
+{
+       GtkWidget * oldrow;
+
+       oldrow=gsh->rows.v;
+
+       /* Set gsh->rows.v to a row within a menu.
+        * Create the menu before overwriting, then
+        * set back at end.  */
+       gsh->bflags |= GSH_MENU_BUTTON;
+       /* Add menu launcher button.  */
+       gsh_new_button(gsh, tokens[0]);
+       gsh->rows.v=gtk_menu_new(); 
+       gtk_widget_show(gsh->rows.v);
+       g_signal_connect_swapped(gsh->button, "clicked",
+                       G_CALLBACK(popup_handler), gsh->rows.v);
+
+       add_menu_items(gsh, tokens);
+
+       gsh->rows.v=oldrow;
+}
+
+

Index: menu.h
===================================================================
RCS file: menu.h
diff -N menu.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ menu.h      6 Apr 2007 15:05:28 -0000       1.1
@@ -0,0 +1,30 @@
+/*
+  AntiRight
+  (c) 2006-2007 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+  Boston, MA  02110-1301  USA
+*/
+
+#ifndef GSH_MENU_H
+#define GSH_MENU_H
+
+void
+menubutton_parse(struct GSH * gsh, gchar **tokens);
+
+#endif /* GSH_MENU_H */




reply via email to

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