[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright gtkshell/button.c gtkshell/color.c gt...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright gtkshell/button.c gtkshell/color.c gt... |
Date: |
Fri, 03 Sep 2010 09:17:41 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 10/09/03 09:17:41
Modified files:
gtkshell : button.c color.c gtkshell.c menu.h
ptk-app-menu.c text.c
libantiright : util.h
Log message:
Various refactorings. Use toolbar for managing undo and redo buttons
in text
editor.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/color.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/ptk-app-menu.c?cvsroot=antiright&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.c?cvsroot=antiright&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/util.h?cvsroot=antiright&r1=1.19&r2=1.20
Patches:
Index: gtkshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- gtkshell/button.c 27 Aug 2010 20:35:23 -0000 1.67
+++ gtkshell/button.c 3 Sep 2010 09:17:41 -0000 1.68
@@ -154,12 +154,14 @@
{
if(!is_image_button(gsh, command))
{
- GtkWidget *vrow = gsh->rows->v;
GtkWidget *button;
+ {
+ GtkWidget *vrow = gsh->rows->v;
button=gsh->widgets.button
= (!GTK_IS_MENU (vrow) && !GTK_IS_MENU_BAR (vrow))
? gtk_button_new () : gtk_image_menu_item_new ();
+ }
setup_label (button = gsh->widgets.button, command);
gsh_setup_drag_drop (gsh, button);
setup_callback (gsh, button, command);
Index: gtkshell/color.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/color.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gtkshell/color.c 25 Aug 2010 20:50:49 -0000 1.5
+++ gtkshell/color.c 3 Sep 2010 09:17:41 -0000 1.6
@@ -30,12 +30,12 @@
if (!gdk_color_parse (color_string, &color))
gdk_color_parse (is_fg
- ? GSH_FALLBACK_FGCOLOR : GSH_FALLBACK_BGCOLOR, &color);
+ ? GSH_FALLBACK_FGCOLOR : GSH_FALLBACK_BGCOLOR,
+ &color);
return color;
}
-
void
gsh_widget_set_color (GtkWidget * widget,
const gchar * color_string, bool is_fg_color)
@@ -49,3 +49,4 @@
else
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &color);
}
+
Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- gtkshell/gtkshell.c 31 Aug 2010 19:57:20 -0000 1.59
+++ gtkshell/gtkshell.c 3 Sep 2010 09:17:41 -0000 1.60
@@ -24,72 +24,105 @@
#include "gtkshell.h"
static void
-gsh_delete_GSH (GSH * gsh)
+delete_child_classes(GSH *gsh)
{
- /* Delete atomic members. */
- GSH_FREE_IF (gsh->geometry);
- /* Delete child classes. */
ARDELETE (gsh->rows);
ARDELETE (gsh->terminal);
ARDELETE (gsh->update);
+}
+
+static void
+gsh_delete_GSH (GSH * gsh)
+{
+ /* Delete atomic members. */
+ GSH_FREE_IF (gsh->geometry);
+ delete_child_classes(gsh);
arfree(gsh);
}
static inline void
-gsh_manage_generic (GSH * gsh, GtkWidget * widget)
+manage_generic (GSH * gsh, GtkWidget * widget)
{
gsh->rows->current++;
gsh->widgets.last_managed = widget;
}
static void
-gsh_manage (GSH * gsh, GtkWidget * widget)
+manage_regular_widget(GSH *gsh, GtkWidget *container, GtkWidget *widget)
{
- if (G_LIKELY (!GSH_FLAG (GSH_PANE_NEXT)))
- {
- struct GSHRows *rows = gsh->rows;
- GtkWidget *container = rows->v;
-
- if (GTK_IS_MENU (container) || GTK_IS_MENU_BAR (container)
- || GTK_IS_MENU_ITEM (container))
- {
- gtk_menu_shell_append (GTK_MENU_SHELL (container), widget);
- return;
- }
- gsh_manage_generic (gsh, widget);
- $ (rows, check);
+ manage_generic (gsh, widget);
+ $ (gsh->rows, check);
if (G_UNLIKELY(GSH_FLAG (GSH_NO_EXPAND)))
GSHCA_TIGHT (container, widget);
else
GSHCA (container, widget);
- }
+}
+
+static void
+manage_in_current_pane(GSH *gsh, GtkWidget *widget)
+{
+ GtkWidget *container = gsh->rows->v;
+
+ if (!(GTK_IS_MENU (container) || GTK_IS_MENU_BAR (container)
+ || GTK_IS_MENU_ITEM (container)))
+ manage_regular_widget(gsh, container, widget);
else
- {
+ gtk_menu_shell_append (GTK_MENU_SHELL (container), widget);
+}
+
+static void
+manage_in_other_pane(GSH *gsh, GtkWidget *widget)
+{
gsh_pane_previous (gsh, widget);
- gsh_manage_generic (gsh, widget);
- }
+ manage_generic (gsh, widget);
}
-void
-gsh_GSH (GSH * gsh)
+static void
+gsh_manage (GSH * gsh, GtkWidget * widget)
+{
+ if(!GSH_FLAG(GSH_PANE_NEXT))
+ manage_in_current_pane(gsh, widget);
+ else
+ manage_in_other_pane(gsh, widget);
+}
+
+static void
+assign_add_methods(GSH *gsh)
+{
+ gsh->add.window = &gsh_GSH_add_window;
+ gsh->add.button = &gsh_add_button;
+ gsh->add.label = &gsh_add_label;
+}
+
+static void
+assign_methods(GSH *gsh)
{
- /* setup child classes */
- gsh->update=NULL;
- gsh->rows = ARNEW (gsh, GSHRows, gsh);
- gsh->terminal=NULL;
/* setup methods */
gsh->delete = &gsh_delete_GSH;
gsh->parse = &gsh_parse_arguments;
gsh->finalize = &gsh_GSH_finalize;
gsh->manage = &gsh_manage;
- gsh->add.window = &gsh_GSH_add_window;
- gsh->add.button = &gsh_add_button;
- gsh->add.label = &gsh_add_label;
+ assign_add_methods(gsh);
+}
+
+static void
+initialize_app_mode_fields(GSH *gsh)
+{
/* setup app mode fields */
#define GWA gsh->widgets.app
GWA.menubar=GWA.toolbar=GWA.status=GWA.frame=GWA.row=NULL;
#define GWAM GWA.menus
GWAM.file=GWAM.edit=GWAM.view=GWAM.tools=GWAM.help=NULL;
+}
+
+static void
+initialize_fields(GSH *gsh)
+{
+ /* setup child classes */
+ gsh->update=NULL;
+ gsh->rows = ARNEW (gsh, GSHRows, gsh);
+ gsh->terminal=NULL;
+ /* initialize fields */
gsh->widgets.last_managed = NULL;
gsh->editor.widget=NULL;
gsh->command_dictionary = NULL;
@@ -97,6 +130,14 @@
= gsh->geometry = gsh->usage = (gchar *) NULL;
gsh->bflags = 0;
gsh->icon_size = GTK_ICON_SIZE_DND;
+ initialize_app_mode_fields(gsh);
+}
+
+void
+gsh_GSH (GSH * gsh)
+{
+ assign_methods(gsh);
+ initialize_fields(gsh);
/* Add initial window. */
$ (gsh, add.window);
}
Index: gtkshell/menu.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/menu.h 25 Aug 2010 20:50:50 -0000 1.7
+++ gtkshell/menu.h 3 Sep 2010 09:17:41 -0000 1.8
@@ -36,6 +36,10 @@
GSHMenuType gsh_is_menubar_item (const gchar * label);
-void gsh_menubutton_parse (struct GSH *gsh, gchar ** tokens);
+void
+gsh_add_tearoff(GtkWidget *submenu);
+
+void
+gsh_menubutton_parse (struct GSH *gsh, gchar ** tokens);
#endif /* GSH_MENU_H */
Index: gtkshell/ptk-app-menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/ptk-app-menu.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- gtkshell/ptk-app-menu.c 31 Aug 2010 19:57:20 -0000 1.14
+++ gtkshell/ptk-app-menu.c 3 Sep 2010 09:17:41 -0000 1.15
@@ -40,16 +40,6 @@
#include <alloca.h>
#include "gtkshell.h"
-/* Compatibility macros for older versions of glib */
-#if ! GLIB_CHECK_VERSION(2, 10, 0)
-/* older versions of glib don't provde g_slice API */
-#define g_slice_alloc(size) g_malloc(size)
-#define g_slice_alloc0(size) g_malloc0(size)
-#define g_slice_new(type) g_new(type, 1)
-#define g_slice_new0(type) g_new0(type, 1)
-#define g_slice_free(type, mem) g_free(mem)
-#define g_slice_free1(size, mem) g_free(mem)
-#endif
//#include "misc.h" /* Misc functions for lxpanel */
@@ -263,7 +253,7 @@
/* Skip other */
while (++i < G_N_ELEMENTS (known_cats))
{
- const char **sub_cats = known_cats[i].sub_cats;
+ register char **sub_cats = (char**)known_cats[i].sub_cats;
while (*sub_cats)
{
if (0 == strncmp (*cat, "X-", 2)) /* Desktop specific */
@@ -277,7 +267,8 @@
return -1;
}
-static void app_dirs_foreach (GFunc func, gpointer user_data);
+static void
+app_dirs_foreach (GFunc func, gpointer user_data);
static int
compare_menu_item_titles (gpointer a, gpointer b)
@@ -602,12 +593,30 @@
Passing -1 in this parameter means append all items
at the end of menu.
*/
+
+static GtkMenu *
+setup_submenu(GList *sub_items)
+{
+ GtkMenu *sub_menu;
+
+ sub_menu = GTK_MENU (gtk_menu_new ());
+ {
+ GList *l;
+
+ for (l = sub_items; l; l = l->next)
+ gtk_menu_shell_append (GTK_MENU_SHELL (sub_menu),
+ GTK_WIDGET (l->data));
+ }
+ g_list_free (sub_items);
+
+ return sub_menu;
+}
+
void
ptk_app_menu_insert_items (GtkMenu * menu, int position)
{
GList *sub_menus[G_N_ELEMENTS (known_cats)] = { 0 };
unsigned int i = 0;
- GList *sub_items, *l;
if (G_UNLIKELY (PTK_APP_MENU_ITEM_ID == 0))
PTK_APP_MENU_ITEM_ID = g_quark_from_static_string ("PtkAppMenuItem");
@@ -617,35 +626,39 @@
while (++i < G_N_ELEMENTS (known_cats))
{
GtkMenu *sub_menu;
- GtkWidget *menu_item;
- PtkAppMenuItem *data;
+ {
+ GList *sub_items;
if (!(sub_items = sub_menus[i]))
continue;
- sub_menu = GTK_MENU (gtk_menu_new ());
+ sub_menu=setup_submenu(sub_items);
+ }
+ {
+ GtkWidget *menu_item;
- for (l = sub_items; l; l = l->next)
- gtk_menu_shell_append (GTK_MENU_SHELL (sub_menu),
- GTK_WIDGET (l->data));
- g_list_free (sub_items);
menu_item = new_menu_item_with_title (i);
+ {
+ PtkAppMenuItem *data;
data = alloca (sizeof (PtkAppMenuItem));
data->icon = g_strdup (known_cats[i].icon);
- g_object_set_qdata_full (G_OBJECT (menu_item), PTK_APP_MENU_ITEM_ID,
+ g_object_set_qdata_full (G_OBJECT (menu_item),
+ PTK_APP_MENU_ITEM_ID,
data, NULL);
-
SETUP_MENU_ITEM_SIGNALS (menu_item, data);
on_menu_item_expose (menu_item, NULL, data);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item),
+ gtk_menu_item_set_submenu ( GTK_MENU_ITEM (menu_item),
GTK_WIDGET (sub_menu));
- gsh_add_tearoff(sub_menu);
+ gsh_add_tearoff(GTK_WIDGET(sub_menu));
if (position >= 0)
- gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menu_item, position);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu),
+ menu_item, position);
else
GSHCA (menu, menu_item);
g_free(data->icon);
}
+ }
+ }
gtk_widget_show_all (GTK_WIDGET (menu));
}
Index: gtkshell/text.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- gtkshell/text.c 31 Aug 2010 19:57:20 -0000 1.52
+++ gtkshell/text.c 3 Sep 2010 09:17:41 -0000 1.53
@@ -97,6 +97,8 @@
set_options (gsh, text);
setup_text_scroller (gsh, text);
setup_undo (gsh);
+ if(!(gsh->geometry))
+ gsh->geometry=g_strdup("640x389");
return text;
}
@@ -130,21 +132,27 @@
return button;
}
+static GtkWidget *
+setup_toolbar (GSH *gsh)
+{
+ GtkWidget *toolbar;
+
+ GSH_SET (GSH_NO_EXPAND);
+ GSH_ADD_MANAGED (gsh, toolbar, toolbar);
+ gsh->widgets.app.toolbar=toolbar;
+
+ return toolbar;
+}
+
static void
setup_undo (GSH * gsh)
{
GtkWidget *text_widget = gsh->editor.widget;
GtkWidget *destination;
- const bool has_toolbar=(gsh->widgets.app.toolbar);
+ GtkWidget *gsh_toolbar = gsh->widgets.app.toolbar;
+ const bool has_toolbar=(gsh_toolbar);
- if(has_toolbar)
- destination = gsh->widgets.app.toolbar;
- else
- { /* Set up a horizontal container
- for undo and redo buttons. */
- GSH_SET (GSH_NO_EXPAND);
- GSH_ADD_MANAGED (gsh, destination, hbox, TRUE, 0);
- }
+ destination = has_toolbar ? gsh->widgets.app.toolbar : setup_toolbar(gsh);
gsh_undo_init(text_widget,
setup_unredo_button(destination, has_toolbar, "gtk-undo",
(GCallback)gsh_undo_undo, text_widget),
@@ -285,7 +293,5 @@
gsh_text_area (gsh);
gsh->editor.filename = (gchar *) filename;
open_in_editor (gsh);
- if(!(gsh->geometry))
- gsh->geometry=g_strdup("640x480");
}
Index: libantiright/util.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/util.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- libantiright/util.h 26 Aug 2010 18:50:20 -0000 1.19
+++ libantiright/util.h 3 Sep 2010 09:17:41 -0000 1.20
@@ -30,12 +30,20 @@
#define armalloc(size) GC_MALLOC(size)
#define arfree(data) GC_FREE(data)
#else /* not LIBGC */
+/* Compatibility macros for older versions of glib */
#if GLIB_CHECK_VERSION(2, 10, 0)
#define armalloc(size) g_slice_alloc(size)
#define arfree(ptr) g_slice_free1(sizeof(*ptr), ptr)
#else /* glib is less than 2.10.0 */
#define armalloc(size) g_malloc(size)
#define arfree(data) g_free(data)
+/* older versions of glib don't provde g_slice API */
+#define g_slice_alloc(size) g_malloc(size)
+#define g_slice_alloc0(size) g_malloc0(size)
+#define g_slice_new(type) g_new(type, 1)
+#define g_slice_new0(type) g_new0(type, 1)
+#define g_slice_free(type, mem) g_free(mem)
+#define g_slice_free1(size, mem) g_free(mem)
#endif /* GLIB_CHECK_VERSION */
#endif /* LIBGC */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright gtkshell/button.c gtkshell/color.c gt...,
Jeffrey Bedard <=