antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright/gtkshell Makefile dialog_options.c fi...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell Makefile dialog_options.c fi...
Date: Mon, 13 Aug 2007 07:12:31 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/08/13 07:12:31

Modified files:
        gtkshell       : Makefile dialog_options.c file_dialog.h 
                         macros.h module_includes.h 
Added files:
        gtkshell       : dialog.c dialog.h 
Removed files:
        gtkshell       : file_dialog.c 

Log message:
        Consolidated common functionality in dialogs to 
gsh_common_dialog_executioner.
        Wrote code using this as macros.  Use dialog.c for dialog callbacks.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog_options.c?cvsroot=antiright&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/file_dialog.h?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/macros.h?cvsroot=antiright&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/module_includes.h?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/file_dialog.c?cvsroot=antiright&r1=1.10&r2=0

Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- Makefile    22 Jul 2007 17:51:21 -0000      1.42
+++ Makefile    13 Aug 2007 07:12:30 -0000      1.43
@@ -34,11 +34,11 @@
 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\
-       file_dialog.o row.o containers.o geometry.o font.o dragdrop.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\
        guidl_options.o guidl_widgets.o update_manager.o pane.o\
-       command_shell.o app_mode.o clock.o tree.o form.o
+       command_shell.o app_mode.o clock.o tree.o form.o dialog.o
 
 program=main.o 
 

Index: dialog_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/dialog_options.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- dialog_options.c    11 Jun 2007 21:32:39 -0000      1.22
+++ dialog_options.c    13 Aug 2007 07:12:31 -0000      1.23
@@ -22,81 +22,6 @@
 
 #include "gtkshell.h"
 
-static void
-gsh_message_dialog(GSH * gsh, GtkMessageType type, const gchar *text)
-       __attribute__((noreturn));
-
-static void
-gsh_font_dialog() __attribute__((noreturn));
-
-static void
-gsh_color_dialog() __attribute__((noreturn));
-
-static void
-gsh_message_dialog(GSH * gsh, GtkMessageType type, const gchar *text)
-{
-       gtk_dialog_run(GTK_DIALOG(gtk_message_dialog_new(GTK_WINDOW(
-               gsh->widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, type,
-               GTK_BUTTONS_CLOSE, (gchar *) text)));
-
-       exit(0);
-}
-
-#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)
-{
-       gchar *font;
-
-       font = gtk_font_selection_dialog_get_font_name(
-                       GTK_FONT_SELECTION_DIALOG(dialog));
-       g_print("%s\n", font);
-       g_free(font);
-}
-
-static void
-gsh_font_dialog()
-{
-       GtkWidget *dialog;
-
-       dialog = gtk_font_selection_dialog_new("Font Selector");
-       if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
-               select_font(dialog);
-
-       exit(0);
-}
-
-static void
-color_select(GtkWidget * dialog)
-{
-       GdkColor color;
-
-       gtk_color_selection_get_current_color( GTK_COLOR_SELECTION(
-               GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel), &color);
-       g_print("#%x%x%x\n", color.red, color.green, color.blue);
-}
-
-static void
-gsh_color_dialog()
-{
-       GtkWidget *dialog;
-
-       dialog = gtk_color_selection_dialog_new("Color Selector");
-
-       if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
-               color_select(dialog);
-
-       exit(0);
-}
-
 void
 gsh_handle_dialog_arguments(GSH * gsh, const gint argc, const gchar **argv,
                            gint *counter)
@@ -114,7 +39,7 @@
                gsh_about_dialog();
                break;
        case 'c':               /* Color Selection */
-               gsh_color_dialog();
+               GSH_COLOR_DIALOG(gsh);
                break;
        case 'D':               /* Folder Creation Selector */
                GSH_FOLDER_CREATE_DIALOG(gsh);
@@ -124,10 +49,10 @@
                break;
        case 'e':               /* Error Message */
                GSH_COUNT(argc, counter);
-               ERROR_DIALOG(gsh, argv[*counter]);
+               GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_ERROR, argv[*counter]);
                break;
        case 'F':               /* Font Selection */
-               gsh_font_dialog();
+               GSH_FONT_DIALOG(gsh);
                break;
        case 'f':
                /* File Selection */
@@ -135,15 +60,14 @@
                break;
        case 'i':               /* Information */
                GSH_COUNT(argc, counter);
-               INFO_DIALOG(gsh, argv[*counter]);
+               GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_INFO, argv[*counter]);
                break;
        case 's':               /* Filename Selection for Saving */
-               
                GSH_FILE_SAVE_DIALOG(gsh);
                break;
        case 'w':               /* Warning */
                GSH_COUNT(argc, counter);
-               WARNING_DIALOG(gsh, argv[*counter]);
+               GSH_MESSAGE_DIALOG(gsh, GTK_MESSAGE_WARNING, argv[*counter]);
                break;
        default:
                ARWARN("invalid dialog option");

Index: file_dialog.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/file_dialog.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- file_dialog.h       11 Jun 2007 21:32:40 -0000      1.8
+++ file_dialog.h       13 Aug 2007 07:12:31 -0000      1.9
@@ -20,23 +20,26 @@
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
 */
 
-#ifndef GSH_FILE_DIALOG
-#define GSH_FILE_DIALOG
+#ifndef GSH_FILE_DIALOG_H
+#define GSH_FILE_DIALOG_H
 
-void
-gsh_file_dialog(struct GSH * gsh, 
-               GtkFileChooserAction action) __attribute__((noreturn));
+#define GSH_FILE_DIALOG(gsh, action)\
+       gsh_common_dialog_executioner(gsh,\
+               gtk_file_chooser_dialog_new("File Chooser",\
+               GTK_WINDOW(gsh->widgets.window), action, GTK_STOCK_CANCEL,\
+               GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 
NULL),\
+               gsh_file_dialog_submit);
 
 #define GSH_FILE_OPEN_DIALOG(gsh)\
-       gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_OPEN)
+       GSH_FILE_DIALOG(gsh, GTK_FILE_CHOOSER_ACTION_OPEN)
 
 #define GSH_FILE_SAVE_DIALOG(gsh)\
-       gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_SAVE)
+       GSH_FILE_DIALOG(gsh, GTK_FILE_CHOOSER_ACTION_SAVE)
 
 #define GSH_FOLDER_CREATE_DIALOG(gsh)\
-       gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+       GSH_FILE_DIALOG(gsh, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
 
 #define GSH_FOLDER_OPEN_DIALOG(gsh)\
-       gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+       GSH_FILE_DIALOG(gsh, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
 
-#endif /* !GSH_FILE_DIALOG */
+#endif /* !GSH_FILE_DIALOG_H */

Index: macros.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/macros.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- macros.h    11 Jun 2007 21:32:42 -0000      1.14
+++ macros.h    13 Aug 2007 07:12:31 -0000      1.15
@@ -40,6 +40,7 @@
 #define GSH_PANE_NEXT          GSHBIT(12)
 #define GSH_FIRST_TERMINAL     GSHBIT(13)
 #define GSH_TERM_TRANSPARENT   GSHBIT(14)
+#define GSH_IN_SECONDARY_WIN   GSHBIT(15)
 
 typedef guint Bitmask;
 

Index: module_includes.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/module_includes.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- module_includes.h   9 Jul 2007 02:12:26 -0000       1.8
+++ module_includes.h   13 Aug 2007 07:12:31 -0000      1.9
@@ -59,5 +59,6 @@
 #include "applets.h"
 #include "tree.h"
 #include "form.h"
+#include "dialog.h"
 
 #endif /* not GSH_MODULE_INCLUDES_H */

Index: dialog.c
===================================================================
RCS file: dialog.c
diff -N dialog.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dialog.c    13 Aug 2007 07:12:30 -0000      1.1
@@ -0,0 +1,67 @@
+/*
+  AntiRight
+  (c) 2002-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"
+
+void
+gsh_common_dialog_executioner(GSH * gsh, GtkWidget * dialog,
+       void (*callback)(GtkWidget *))
+{
+       const gint response = gtk_dialog_run(GTK_DIALOG(dialog));
+       if(((response == GTK_RESPONSE_OK) || (response == GTK_RESPONSE_ACCEPT))
+               && callback)
+               callback(dialog);
+       if(!GSH_FLAG(GSH_IN_SECONDARY_WIN))
+               exit(0);
+}
+
+void
+gsh_file_dialog_submit(GtkWidget * dialog)
+{
+       gchar *name;
+
+       name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+       g_print("%s\n", name);
+       g_free(name);
+}
+
+void
+gsh_font_dialog_select_font(GtkWidget * dialog)
+{
+       gchar *font;
+
+       font = gtk_font_selection_dialog_get_font_name(
+                       GTK_FONT_SELECTION_DIALOG(dialog));
+       g_print("%s\n", font);
+       g_free(font);
+}
+
+void
+gsh_color_dialog_select_color(GtkWidget * dialog)
+{
+       GdkColor color;
+
+       gtk_color_selection_get_current_color( GTK_COLOR_SELECTION(
+               GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel), &color);
+       g_print("#%x%x%x\n", color.red, color.green, color.blue);
+}
+

Index: dialog.h
===================================================================
RCS file: dialog.h
diff -N dialog.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dialog.h    13 Aug 2007 07:12:31 -0000      1.1
@@ -0,0 +1,54 @@
+/*
+  AntiRight
+  (c) 2002-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_DIALOG_H
+#define GSH_DIALOG_H
+
+void
+gsh_common_dialog_executioner(GSH * gsh, GtkWidget * dialog,
+       void (*callback)(GtkWidget *));
+
+void
+gsh_file_dialog_submit(GtkWidget * dialog);
+
+void
+gsh_font_dialog_select_font(GtkWidget * dialog);
+
+void
+gsh_color_dialog_select_color(GtkWidget * dialog);
+
+#define GSH_MESSAGE_DIALOG(gsh, type, text)\
+       gsh_common_dialog_executioner(gsh, gtk_message_dialog_new(\
+               GTK_WINDOW(gsh->widgets.window), 
GTK_DIALOG_DESTROY_WITH_PARENT,\
+               type, GTK_BUTTONS_CLOSE, (gchar *) text), NULL);
+
+#define GSH_FONT_DIALOG(gsh)\
+       gsh_common_dialog_executioner(gsh, gtk_font_selection_dialog_new(\
+               "Font Selector"), &gsh_font_dialog_select_font);
+
+#define GSH_COLOR_DIALOG(gsh)\
+       gsh_common_dialog_executioner(gsh, gtk_color_selection_dialog_new(\
+               "Color Selector"), &gsh_color_dialog_select_color);
+
+#endif /* GSH_DIALOG_H */
+

Index: file_dialog.c
===================================================================
RCS file: file_dialog.c
diff -N file_dialog.c
--- file_dialog.c       11 Jun 2007 21:32:40 -0000      1.10
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,50 +0,0 @@
-/*
-  AntiRight
-  (c) 2002-2006 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
-file_dialog_submit(GtkWidget * dialog)
-{
-       gchar *name;
-
-       name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-       g_print("%s\n", name);
-       g_free(name);
-}
-
-/* Taken from the GTK+ Reference Manual */
-void
-gsh_file_dialog(struct GSH * gsh, GtkFileChooserAction action)
-{
-       GtkWidget *dialog;
-
-       dialog=gtk_file_chooser_dialog_new("File Chooser", 
-               GTK_WINDOW(gsh->widgets.window), action, GTK_STOCK_CANCEL, 
-               GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
-
-       if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
-               file_dialog_submit(dialog);
-
-       exit(0);
-}
-
-




reply via email to

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