[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright gtkshell/add_options.c gtkshell/butto...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright gtkshell/add_options.c gtkshell/butto... |
Date: |
Wed, 09 May 2007 19:53:37 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/05/09 19:53:37
Modified files:
gtkshell : add_options.c button.c gtkshell.c guidl_util.c
image_button.c init.c menu.c options.c
terminal.c text.c text.h updated_label.c
libantiright : macros.h
Log message:
Fixed conflicts, reduced excessive function splitting in single
use cases.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/add_options.c?cvsroot=antiright&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_util.c?cvsroot=antiright&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/image_button.c?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/init.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal.c?cvsroot=antiright&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.c?cvsroot=antiright&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_label.c?cvsroot=antiright&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/macros.h?cvsroot=antiright&r1=1.5&r2=1.6
Patches:
Index: gtkshell/add_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/add_options.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- gtkshell/add_options.c 5 May 2007 23:38:07 -0000 1.29
+++ gtkshell/add_options.c 9 May 2007 19:53:37 -0000 1.30
@@ -27,7 +27,7 @@
$(gsh, add.label, output)
#define ADD_PIPED_TEXT(gsh, output)\
- gsh_text_area_set_text(gsh_text_area(gsh), output)
+ GSH_TEXT_AREA_SET_TEXT(gsh_text_area(gsh), output)
#define GENERIC_FILE_CONTENTS(gsh, add, input)\
{\
@@ -49,12 +49,9 @@
$(gsh, init);
}
-static void
-add_separator(struct GSH * gsh)
-{
- $(gsh, manage, (gsh->rows->total == 1)
+#define ADD_SEPARATOR(gsh) \
+ $(gsh, manage, (gsh->rows->total == 1)\
? gtk_vseparator_new() : gtk_hseparator_new());
-}
#define GCA_WIDGET(func) \
GENERIC_COMMANDED_ADD(gsh, argv[*counter], func)
@@ -91,11 +88,13 @@
static void
setup_first_pane_half(struct GSH * gsh, const gchar ** pair, GtkWidget * pane)
{
+ {
GtkWidget * first;
gtk_widget_show(first=gtk_frame_new(pair[0]));
REPARENT_TO(first);
gtk_paned_add1(GTK_PANED(pane), first);
+ }
$(gsh->rows, new);
$(gsh, manage, pane);
$(gsh->rows, new);
@@ -161,7 +160,7 @@
break;
case 'S': /* Add a separator. */
- add_separator(gsh);
+ ADD_SEPARATOR(gsh);
break;
case 's': /* Add a shell. */
Index: gtkshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- gtkshell/button.c 8 May 2007 20:40:07 -0000 1.39
+++ gtkshell/button.c 9 May 2007 19:53:37 -0000 1.40
@@ -100,25 +100,21 @@
return return_value;
}
-void
-gsh_command_button(struct GSH * gsh, const gchar *command)
-{
-#ifdef DEBUG
- ARPASSERT(gsh);
-#endif /* DEBUG */
-
- create_button(gsh);
- setup_command_button(gsh, command);
- gsh_manage(gsh, gsh->widgets.button);
+#define GSH_COMMAND_BUTTON(gsh, command)\
+{\
+ create_button(gsh);\
+ setup_command_button(gsh, command);\
+ gsh_manage(gsh, gsh->widgets.button);\
}
+
/* This is just a wrapper around gsh_new_button(), to
follow the convention of returning a created widget. */
GtkWidget *
gsh_add_button(struct GSH * gsh, const gchar * string)
{
if(!test_image_button(gsh, string))
- gsh_command_button(gsh, string);
+ GSH_COMMAND_BUTTON(gsh, string);
return gsh->widgets.button;
}
Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- gtkshell/gtkshell.c 8 May 2007 20:40:07 -0000 1.35
+++ gtkshell/gtkshell.c 9 May 2007 19:53:37 -0000 1.36
@@ -23,18 +23,17 @@
#include "gtkshell.h"
-static void
-delete_child_classes(struct GSH * gsh)
-{
- $(gsh->rows, delete);
- $(gsh->terminal, delete);
- $(gsh->update, delete);
+#define GSH_DELETE_CHILD_CLASSES(gsh)\
+{\
+ ARDELETE(gsh->rows);\
+ ARDELETE(gsh->terminal);\
+ ARDELETE(gsh->update);\
}
static void
gsh_delete_GSH(struct GSH * gsh)
{
- delete_child_classes(gsh);
+ GSH_DELETE_CHILD_CLASSES(gsh);
GSH_FREE_IF(gsh->geometry);
}
@@ -63,45 +62,45 @@
setup_add_methods(gsh);
}
-static void
-setup_child_classes(struct GSH * gsh)
-{
- gsh->update = ARNEW(gsh, GSHUpdateManager);
- gsh->rows = ARNEW(gsh, GSHRows);
- gsh->terminal = ARNEW(gsh, GSH_Terminal);
+#define SETUP_CHILD_CLASSES(gsh) \
+{\
+ gsh->update = ARNEW(gsh, GSHUpdateManager);\
+ gsh->rows = ARNEW(gsh, GSHRows);\
+ gsh->terminal = ARNEW(gsh, GSH_Terminal);\
}
-static void
-setup_widget_member_fields(struct GSH * gsh)
-{
- gsh->widgets.menu_bar=NULL;
- gsh->widgets.app_frame=NULL;
+#define SETUP_WIDGET_MEMBER_FIELDS(gsh)\
+{\
+ gsh->widgets.menu_bar=NULL;\
+ gsh->widgets.app_frame=NULL;\
}
-static void
-setup_editor_member_fields(struct GSH * gsh)
-{
- gsh->editor.widget=NULL;
- gsh->editor.filename=NULL;
+#define SETUP_EDITOR_MEMBER_FIELDS(gsh)\
+{\
+ gsh->editor.widget=NULL;\
+ gsh->editor.filename=NULL;\
}
-static void
-setup_member_fields(struct GSH * gsh)
-{
- setup_widget_member_fields(gsh);
- setup_editor_member_fields(gsh);
- gsh->geometry = (gchar *)NULL;
- gsh->bflags = 0;
- gsh->icon_size=GTK_ICON_SIZE_DND;
+#define SETUP_MAIN_MEMBER_FIELDS(gsh) \
+{\
+ gsh->geometry = (gchar *)NULL;\
+ gsh->bflags = 0;\
+ gsh->icon_size=GTK_ICON_SIZE_DND;\
}
-static void
-gsh_setup_GSH(struct GSH * gsh)
-{
- setup_child_classes(gsh);
- setup_methods(gsh);
- setup_member_fields(gsh);
- $(gsh, add.window);
+#define SETUP_MEMBER_FIELDS(gsh) \
+{\
+ SETUP_WIDGET_MEMBER_FIELDS(gsh);\
+ SETUP_EDITOR_MEMBER_FIELDS(gsh);\
+ SETUP_MAIN_MEMBER_FIELDS(gsh);\
+}
+
+#define SETUP_GSH(gsh) \
+{\
+ SETUP_CHILD_CLASSES(gsh);\
+ setup_methods(gsh);\
+ SETUP_MEMBER_FIELDS(gsh);\
+ $(gsh, add.window);\
}
struct GSH *
@@ -110,7 +109,7 @@
struct GSH *gsh;
gsh = (struct GSH *) xmalloc(sizeof(struct GSH));
- gsh_setup_GSH(gsh);
+ SETUP_GSH(gsh);
return gsh;
}
Index: gtkshell/guidl_util.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_util.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- gtkshell/guidl_util.c 9 May 2007 17:20:53 -0000 1.16
+++ gtkshell/guidl_util.c 9 May 2007 19:53:37 -0000 1.17
@@ -66,19 +66,20 @@
env->add=&gsh_GDLEnvironment_add;\
}
-static struct GDLEnvironment *
-gsh_setup_GDLEnvironment(struct GDLEnvironment * env)
-{
- CONSTRUCT_MEMBER_CLASSES(env);
- ASSIGN_METHODS(env);
-
- return env;
+#define SETUP_GDLENVIRONMENT(env)\
+{\
+ CONSTRUCT_MEMBER_CLASSES(env);\
+ ASSIGN_METHODS(env);\
}
struct GDLEnvironment *
gsh_new_GDLEnvironment()
{
- return gsh_setup_GDLEnvironment(g_malloc(
- sizeof(struct GDLEnvironment)));
+ struct GDLEnvironment * env;
+
+ env = xmalloc(sizeof(struct GDLEnvironment));
+ SETUP_GDLENVIRONMENT(env);
+
+ return env;
}
Index: gtkshell/image_button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/image_button.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- gtkshell/image_button.c 9 May 2007 17:45:27 -0000 1.15
+++ gtkshell/image_button.c 9 May 2007 19:53:37 -0000 1.16
@@ -23,14 +23,9 @@
#include "gtkshell.h"
static void
-set_menu_item_image(struct GSH * gsh, GtkWidget * image)
+setup_row_for_menu_item_image(struct GSH * gsh, GtkWidget * label,
+ GtkWidget * image)
{
- GtkWidget * label;
-
- label=gtk_bin_get_child(GTK_BIN(gsh->widgets.button));
- gtk_widget_ref(label);
- gtk_container_remove(GTK_CONTAINER(gsh->widgets.button), label);
- {
GtkWidget * hrow;
hrow=gtk_hbox_new(FALSE, 2);
@@ -38,12 +33,21 @@
gtk_box_pack_start(GTK_BOX(hrow), image, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(hrow), label);
gtk_widget_show(hrow);
- }
+}
+
+static void
+set_menu_item_image(struct GSH * gsh, GtkWidget * image)
+{
+ GtkWidget * label;
+
+ label=gtk_bin_get_child(GTK_BIN(gsh->widgets.button));
+ gtk_widget_ref(label);
+ gtk_container_remove(GTK_CONTAINER(gsh->widgets.button), label);
+ setup_row_for_menu_item_image(gsh, label, image);
gtk_widget_show(image);
gtk_widget_show(label);
}
-
#define SET_BUTTON_IMAGE(gsh, image) \
{\
gtk_button_set_image(GTK_BUTTON(gsh->widgets.button), image);\
@@ -71,21 +75,18 @@
return image;
}
-static GtkWidget *
-get_image(struct GSH * gsh, const gchar * name)
-{
- return g_file_test(name, G_FILE_TEST_EXISTS)
- ? gtk_image_new_from_file(name)
- : get_default_image(gsh, name);
-}
+#define GET_IMAGE(gsh, name) \
+ g_file_test(name, G_FILE_TEST_EXISTS)\
+ ? gtk_image_new_from_file(name)\
+ : get_default_image(gsh, name)
void
gsh_image_button(struct GSH * gsh, char *command, char *name)
{
GtkWidget * image;
- image = get_image(gsh, name);
- gsh_command_button(gsh, command);
+ image = GET_IMAGE(gsh, name);
+ $(gsh, add.button, command);
ARIFP(image)
{
gtk_widget_show(image);
Index: gtkshell/init.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/init.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gtkshell/init.c 9 May 2007 16:13:49 -0000 1.6
+++ gtkshell/init.c 9 May 2007 19:53:37 -0000 1.7
@@ -23,8 +23,10 @@
#include "gtkshell.h"
#define SETUP_QUIT_SIGNAL(window, signal) \
+{\
(void) g_signal_connect(window, signal,\
- G_CALLBACK(gtk_main_quit), NULL)
+ G_CALLBACK(gtk_main_quit), NULL);\
+}
#define SETUP_QUIT_SIGNALS(window) \
{\
@@ -41,7 +43,7 @@
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
SETUP_QUIT_SIGNALS(window);
- return (window);
+ return window;
}
void
Index: gtkshell/menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gtkshell/menu.c 8 May 2007 20:40:07 -0000 1.9
+++ gtkshell/menu.c 9 May 2007 19:53:37 -0000 1.10
@@ -39,7 +39,7 @@
if(pair[1])
gsh_image_button(gsh, pair[0], pair[1]);
else
- gsh_command_button(gsh, pair[0]);
+ $(gsh, add.button, pair[0]);
g_strfreev(pair);
}
@@ -103,14 +103,9 @@
setup_app_mode_status_bar(gsh);
}
-static void
-manage_menu_bar(struct GSH * gsh)
-{
- if(GSH_FLAG(GSH_APP_MODE))
- setup_app_mode(gsh);
- else
- gsh_manage(gsh, gsh->widgets.menu_bar);
-}
+#define MANAGE_MENU_BAR(gsh) \
+ GSH_FLAG(GSH_APP_MODE) ? setup_app_mode(gsh)\
+ : gsh_manage(gsh, gsh->widgets.menu_bar);
static GtkWidget *
add_menu_bar(struct GSH * gsh)
@@ -118,7 +113,7 @@
if(!gsh->widgets.menu_bar)
{
gtk_widget_show(gsh->widgets.menu_bar=gtk_menu_bar_new());
- manage_menu_bar(gsh);
+ MANAGE_MENU_BAR(gsh);
}
return gsh->widgets.menu_bar;
Index: gtkshell/options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- gtkshell/options.c 6 May 2007 05:00:11 -0000 1.22
+++ gtkshell/options.c 9 May 2007 19:53:37 -0000 1.23
@@ -58,13 +58,13 @@
gsh_guidl_env=NULL;
}
-static void
-guidl_handler_for_file(struct GSH * gsh, const gchar * filename)
-{
- /* If the argument is "-", use stdin for yyin. */
- if(strcmp("-", filename)) /* Otherwise, use FILENAME. */
- yyin=fopen(filename, "r");
- common_guidl_handler(gsh);
+/* If the argument is "-", use stdin for yyin. */
+/* Otherwise, use FILENAME. */
+#define GUIDL_HANDLER_FOR_FILE(gsh, filename) \
+{\
+ if(strcmp("-", filename))\
+ yyin=fopen(filename, "r");\
+ common_guidl_handler(gsh);\
}
void
@@ -82,7 +82,7 @@
break;
case 'f':
GSH_COUNT(argc, counter);
- guidl_handler_for_file(gsh, argv[*counter]);
+ GUIDL_HANDLER_FOR_FILE(gsh, argv[*counter]);
break;
case 'o':
gsh_handle_option_arguments(gsh, argc, argv, counter);
Index: gtkshell/terminal.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- gtkshell/terminal.c 9 May 2007 17:45:27 -0000 1.14
+++ gtkshell/terminal.c 9 May 2007 19:53:37 -0000 1.15
@@ -67,15 +67,14 @@
return term->widget;
}
-static void
-gsh_setup_GSH_Terminal(struct GSH_Terminal * term)
-{
- term->widget=NULL;
- term->font=NULL;
- term->width=80;
- term->height=24;
- term->delete=&gsh_delete_GSH_Terminal;
- term->add=&gsh_GSH_Terminal_add;
+#define SETUP_GSH_TERMINAL(term) \
+{\
+ term->widget=NULL;\
+ term->font=NULL;\
+ term->width=80;\
+ term->height=24;\
+ term->delete=&gsh_delete_GSH_Terminal;\
+ term->add=&gsh_GSH_Terminal_add;\
}
struct GSH_Terminal *
@@ -84,7 +83,7 @@
struct GSH_Terminal * term;
term=xmalloc(sizeof(struct GSH_Terminal));
- gsh_setup_GSH_Terminal(term);
+ SETUP_GSH_TERMINAL(term);
return term;
}
Index: gtkshell/text.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- gtkshell/text.c 8 May 2007 20:40:07 -0000 1.25
+++ gtkshell/text.c 9 May 2007 19:53:37 -0000 1.26
@@ -23,18 +23,16 @@
#include "gtkshell.h"
#define ADD_ENTRY(widget, str) gtk_combo_box_prepend_text(widget, str)
-#define ENTRY(str) ADD_ENTRY(widget, str)
-static void
-append_sample_entries(GtkComboBox * widget)
-{
- /* Some sample entries to use when history is not useful, such as a
+/* Some sample entries to use when history is not useful, such as a
* dialog presentation of this field, where the window displaying the
* field closes on the first activation. */
- ENTRY("ACE -A Terminal");
- ENTRY("ACE -A Settings");
- ENTRY("ACE -A IDE");
- ENTRY("ACE");
+#define APPEND_SAMPLE_ENTRIES(widget) \
+{\
+ ADD_ENTRY(widget, "ACE -A Terminal");\
+ ADD_ENTRY(widget, "ACE -A Settings");\
+ ADD_ENTRY(widget, "ACE -A IDE");\
+ ADD_ENTRY(widget, "ACE");\
}
static void
@@ -65,7 +63,7 @@
/* Create widget and assign callback. */
setup_entry_cb(gsh, entry=gtk_combo_box_entry_new_text(), command);
- append_sample_entries(GTK_COMBO_BOX(entry));
+ APPEND_SAMPLE_ENTRIES(GTK_COMBO_BOX(entry));
/* Do not fill remaining container area. */
gsh_manage(gsh, entry);
@@ -86,13 +84,6 @@
return text;
}
-inline void
-gsh_text_area_set_text(GtkWidget * widget, const gchar * text)
-{
- gtk_text_buffer_set_text(
- gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)), text,
- strlen(text));
-}
/* This is currently just a text file viewer. */
void
@@ -105,7 +96,7 @@
{
gchar * text;
- gsh_text_area_set_text(gsh_text_area(gsh),
+ GSH_TEXT_AREA_SET_TEXT(gsh_text_area(gsh),
text=antiright_read_named_file(filename));
g_free(text);
}
Index: gtkshell/text.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/text.h 28 Apr 2007 22:26:23 -0000 1.7
+++ gtkshell/text.h 9 May 2007 19:53:37 -0000 1.8
@@ -23,6 +23,11 @@
#ifndef GSH_TEXT_H
#define GSH_TEXT_H
+#define GSH_TEXT_AREA_SET_TEXT(widget, text) \
+ gtk_text_buffer_set_text(\
+ gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)), text,\
+ strlen(text));
+
GtkWidget *
gsh_setup_command_entry(struct GSH * gsh, const gchar *command);
@@ -33,9 +38,6 @@
gsh_text_area(struct GSH * gsh);
void
-gsh_text_area_set_text(GtkWidget * widget, const gchar * text);
-
-void
gsh_text_editor(struct GSH * gsh, const gchar *filename);
#endif
Index: gtkshell/updated_label.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_label.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- gtkshell/updated_label.c 8 May 2007 20:40:07 -0000 1.18
+++ gtkshell/updated_label.c 9 May 2007 19:53:37 -0000 1.19
@@ -22,24 +22,17 @@
#include "gtkshell.h"
-static void
-gsh_check_results(gchar **results)
-{
-
- /*
- * This ensures that the result string is not empty, avoiding
+/* This ensures that the result string is not empty, avoiding
* certain formatting problems.
- */
- /* Otherwise, a GTK warning and termination occurs. */
-#ifdef DEBUG
- ARPASSERT(*results);
-#endif /* DEBUG */
+ * Otherwise, a GTK warning and termination occurs. */
- if (*results[0] == '\0')
- {
- g_free(*results);
- *results=g_strdup("(empty)");
- }
+#define CHECK_RESULTS(results) \
+{\
+ if (results[0] == '\0')\
+ {\
+ g_free(results);\
+ results=g_strdup("(empty)");\
+ }\
}
static void
@@ -54,7 +47,7 @@
ARPASSERT(widget);
#endif /* DEBUG */
results=antiright_pipe_read(command);
- gsh_check_results(&results);
+ CHECK_RESULTS(results);
gtk_label_set_text(GTK_LABEL(widget), results);
g_free(results);
}
Index: libantiright/macros.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/macros.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libantiright/macros.h 3 May 2007 03:42:31 -0000 1.5
+++ libantiright/macros.h 9 May 2007 19:53:37 -0000 1.6
@@ -80,5 +80,8 @@
#define ARNEW(package, class, ...)\
(package##_new_##class(__VA_ARGS__))
+#define ARDELETE(class)\
+ $(class, delete)
+
#endif /* not LIBAR_MACROS_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright gtkshell/add_options.c gtkshell/butto...,
Jeffrey Bedard <=