antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/gtkshell Makefile gtkshell.h guidl.y ...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell Makefile gtkshell.h guidl.y ...
Date: Fri, 13 Apr 2007 03:59:00 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/04/13 03:59:00

Modified files:
        gtkshell       : Makefile gtkshell.h guidl.y guidl_util.c 
Added files:
        gtkshell       : guidl_dialog.c guidl_dialog.h 

Log message:
        Split out dialog specification code from guidl_util.c.  
        Made code unified by using an option lookup.
        Modified gsh_guidl_add such that it can be used for single
        options.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl.y?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_util.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_dialog.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_dialog.h?cvsroot=antiright&rev=1.1

Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Makefile    6 Apr 2007 15:32:22 -0000       1.21
+++ Makefile    13 Apr 2007 03:58:59 -0000      1.22
@@ -37,7 +37,7 @@
        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 menu.o updated.o\
-       guidl_util.o about_dialog.o init.o
+       guidl_util.o about_dialog.o init.o guidl_dialog.o
 
 program=main.o 
 

Index: gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- gtkshell.h  6 Apr 2007 15:32:22 -0000       1.31
+++ gtkshell.h  13 Apr 2007 03:59:00 -0000      1.32
@@ -95,6 +95,7 @@
 #include "about_dialog.h"
 #include "menu.h"
 #include "init.h"
+#include "guidl_dialog.h"
 
 GtkWidget *
 gsh_create_main_window();

Index: guidl.y
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl.y,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- guidl.y     13 Apr 2007 03:00:07 -0000      1.12
+++ guidl.y     13 Apr 2007 03:59:00 -0000      1.13
@@ -86,12 +86,12 @@
 dialog:
 DIALOG STRING
 {
-       gsh_guidl_string_dialog($2);
+       gsh_guidl_dialog($2, NULL);
 }
 |
 DIALOG STRING STRING
 {
-       gsh_guidl_string_dialog_argument($2, $3);
+       gsh_guidl_dialog($2, $3);
 }
 ;
 

Index: guidl_util.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- guidl_util.c        13 Apr 2007 03:00:07 -0000      1.5
+++ guidl_util.c        13 Apr 2007 03:59:00 -0000      1.6
@@ -68,53 +68,17 @@
        free(gsh_parsed_argv);
 }
 
-void
-gsh_guidl_string_dialog(gchar * string)
+static void
+add_option_to_argument_list(gchar option)
 {
-        gchar * option_string=NULL;
-
-        if(!strcmp(string, "file"))
-                option_string=g_strdup("-df");
-        else if(!strcmp(string, "font"))
-                option_string=g_strdup("-dF");
-        else if(!strcmp(string, "about"))
-                option_string=g_strdup("-da");
-        else if(!strcmp(string, "folder"))
-                option_string=g_strdup("-dd");
-        else if(!strcmp(string, "create folder"))
-                option_string=g_strdup("-dD");
-        else if(!strcmp(string, "save"))
-                option_string=g_strdup("-ds");
-        else if(!strcmp(string, "color"))
-                option_string=g_strdup("-dc");
-        else
-                ARERR("unknown dialog type");
+       char * option_string;
 
-        ARPASSERT(option_string);
+       ar_asprintf(&option_string, "-o%c", option);
         gsh_append_arg(option_string);
        g_free(option_string);
 }
 
 void
-gsh_guidl_string_dialog_argument(gchar * string, gchar * argument)
-{
-        gchar * option_string=NULL;
-
-        if(!strcmp(string, "info"))
-                option_string=g_strdup("-di");
-        else if(!strcmp(string, "warning"))
-                option_string=g_strdup("-dw");
-        else if(!strcmp(string, "error"))
-                option_string=g_strdup("-de");
-        else
-                ARERR("unknown dialog type");
-
-        ARPASSERT(option_string);
-        gsh_guidl_add(option_string, argument);
-        g_free(option_string);
-}
-
-void
 gsh_guidl_string_option(gchar * string)
 {
        gchar option;
@@ -135,19 +99,15 @@
                option='L';
        else
        {
+               /* Ensure that STRING is freed 
+                * in case of this condition.  */
+               g_free(string);
                ARWARN("invalid option");
-               return;
+               return; /* No match, so complain but do nothing.  */
        }
-
-       {
-               char * option_string;
-
-               ar_asprintf(&option_string, "-o%c", option);
-               gsh_append_arg(option_string);
-               g_free(option_string);
-       }
-
        g_free(string);
+
+       add_option_to_argument_list(option);
 }
 
 void
@@ -216,7 +176,10 @@
 gsh_guidl_add(const char * switches, gchar * argument)
 {
        gsh_append_arg((gchar *)switches);
+       if(argument != NULL)
+       {
        gsh_append_arg(argument);
        g_free(argument);
+       }
 }
 

Index: guidl_dialog.c
===================================================================
RCS file: guidl_dialog.c
diff -N guidl_dialog.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ guidl_dialog.c      13 Apr 2007 03:59:00 -0000      1.1
@@ -0,0 +1,70 @@
+/*
+  AntiRight
+  (c) 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"
+
+static void
+add_dialog(gchar * option_string, gchar * argument)
+{
+       ARPASSERT(option_string);
+        gsh_guidl_add(option_string, argument);
+               g_free(option_string);
+}
+
+/* The returned memory must be freed.  */
+static gchar *
+lookup_dialog_flag(gchar * string)
+{
+        gchar * option_string=NULL;
+
+        if(!strcmp(string, "file"))
+                option_string=g_strdup("-df");
+        else if(!strcmp(string, "font"))
+                option_string=g_strdup("-dF");
+        else if(!strcmp(string, "about"))
+                option_string=g_strdup("-da");
+        else if(!strcmp(string, "folder"))
+                option_string=g_strdup("-dd");
+        else if(!strcmp(string, "create folder"))
+                option_string=g_strdup("-dD");
+        else if(!strcmp(string, "save"))
+                option_string=g_strdup("-ds");
+        else if(!strcmp(string, "color"))
+                option_string=g_strdup("-dc");
+        else if(!strcmp(string, "info"))
+                option_string=g_strdup("-di");
+        else if(!strcmp(string, "warning"))
+                option_string=g_strdup("-dw");
+        else if(!strcmp(string, "error"))
+                option_string=g_strdup("-de");
+        else
+                ARWARN("unknown dialog type");
+       
+       return option_string;
+}
+
+void
+gsh_guidl_dialog(gchar * dialog_type, gchar * argument)
+{
+       add_dialog(lookup_dialog_flag(dialog_type), argument);
+}
+

Index: guidl_dialog.h
===================================================================
RCS file: guidl_dialog.h
diff -N guidl_dialog.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ guidl_dialog.h      13 Apr 2007 03:59:00 -0000      1.1
@@ -0,0 +1,29 @@
+/*
+  AntiRight
+  (c) 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_GUIDL_DIALOG_H
+#define GSH_GUIDL_DIALOG_H
+
+void
+gsh_guidl_dialog(gchar * dialog_type, gchar * argument);
+
+#endif /* GSH_GUIDL_DIALOG_H */




reply via email to

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