From aaa3ef21611a166581f05447851c3433097fa5f2 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 17 Jun 1999 19:13:08 +0000 Subject: [PATCH] app/Makefile.am new files. Does nothing yet. Checked in because I found 1999-06-17 Michael Natterer * app/Makefile.am * app/gimpcontext.[ch]: new files. Does nothing yet. Checked in because I found some bugs while hacking it: * libgimp/gimpchainbutton.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch]: fixed some cut & paste bugs and some gtk 1.0 artefacts in the object class initialisation code. --- ChangeLog | 13 ++ app/Makefile.am | 2 + app/core/gimpcontext.c | 185 +++++++++++++++++++++++++++++ app/core/gimpcontext.h | 66 ++++++++++ app/gimpcontext.c | 185 +++++++++++++++++++++++++++++ app/gimpcontext.h | 66 ++++++++++ libgimp/gimpchainbutton.c | 4 +- libgimp/gimpchainbutton.h | 2 - libgimp/gimpfileselection.c | 100 +++++++--------- libgimp/gimpfileselection.h | 4 +- libgimp/gimppatheditor.c | 38 ++---- libgimp/gimppatheditor.h | 11 +- libgimp/gimpsizeentry.c | 44 +++---- libgimp/gimpsizeentry.h | 19 +-- libgimp/gimpunitmenu.c | 46 ++++--- libgimp/gimpunitmenu.h | 4 +- libgimpwidgets/gimpchainbutton.c | 4 +- libgimpwidgets/gimpchainbutton.h | 2 - libgimpwidgets/gimpfileentry.c | 100 +++++++--------- libgimpwidgets/gimpfileentry.h | 4 +- libgimpwidgets/gimpfileselection.c | 100 +++++++--------- libgimpwidgets/gimpfileselection.h | 4 +- libgimpwidgets/gimppatheditor.c | 38 ++---- libgimpwidgets/gimppatheditor.h | 11 +- libgimpwidgets/gimpsizeentry.c | 44 +++---- libgimpwidgets/gimpsizeentry.h | 19 +-- libgimpwidgets/gimpunitmenu.c | 46 ++++--- libgimpwidgets/gimpunitmenu.h | 4 +- 28 files changed, 809 insertions(+), 356 deletions(-) create mode 100644 app/core/gimpcontext.c create mode 100644 app/core/gimpcontext.h create mode 100644 app/gimpcontext.c create mode 100644 app/gimpcontext.h diff --git a/ChangeLog b/ChangeLog index b3b5f6984a..61400a46d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +1999-06-17 Michael Natterer + + * app/Makefile.am + * app/gimpcontext.[ch]: new files. Does nothing yet. Checked in + because I found some bugs while hacking it: + + * libgimp/gimpchainbutton.[ch] + * libgimp/gimpfileselection.[ch] + * libgimp/gimppatheditor.[ch] + * libgimp/gimpsizeentry.[ch] + * libgimp/gimpunitmenu.[ch]: fixed some cut & paste bugs and some + gtk 1.0 artefacts in the object class initialisation code. + 1999-06-17 Michael Natterer * app/preferences_dialog.c: the tree title doesn't behave like a diff --git a/app/Makefile.am b/app/Makefile.am index aeccf8a2e0..86422df6f7 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -181,6 +181,8 @@ gimp_SOURCES = \ gimpbrushlist.h \ gimpbrushlistF.h \ gimpbrushlistP.h \ + gimpcontext.c \ + gimpcontext.h \ gimphistogram.c \ gimphistogram.h \ gimphistogramP.h \ diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c new file mode 100644 index 0000000000..77e3eca3b1 --- /dev/null +++ b/app/core/gimpcontext.c @@ -0,0 +1,185 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include "gimpcontext.h" +#include "gimpsignal.h" + +#define CONTEXT_CHECK_CURRENT(context) \ + ((context) = (context) ? (context) : current_context) + +enum { + OPACITY_CHANGED, + PAINT_MODE_CHANGED, + LAST_SIGNAL +}; + +static guint gimp_context_signals[LAST_SIGNAL] = { 0 }; + +static GimpObjectClass* parent_class = NULL; + +/* the currently active context */ +static GimpContext * current_context = NULL; + +/* for later use +static void +gimp_context_destroy (GtkObject *object) +{ + GimpContext *context; + + g_return_if_fail (object != NULL); + g_return_if_fail (GIMP_IS_CONTEXT (object)); + + context = GIMP_CONTEXT (object); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} +*/ + +static void +gimp_context_class_init (GimpContextClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + + parent_class = gtk_type_class (gimp_object_get_type ()); + + gimp_context_signals[OPACITY_CHANGED] = + gimp_signal_new ("opacity_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContextClass, + opacity_changed), + gimp_sigtype_void); + + gimp_context_signals[PAINT_MODE_CHANGED] = + gimp_signal_new ("paint_mode_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContextClass, + paint_mode_changed), + gimp_sigtype_void); + + gtk_object_class_add_signals (object_class, gimp_context_signals, + LAST_SIGNAL); + + klass->opacity_changed = NULL; + klass->paint_mode_changed = NULL; + + /* object_class->destroy = gimp_context_destroy; */ +} + +static void +gimp_context_init (GimpContext *context) +{ + context->opacity = 1.0; + context->paint_mode = 0; +} + +GtkType +gimp_context_get_type (void) +{ + static GtkType type = 0; + + if(!type) + { + GtkTypeInfo info = + { + "GimpContext", + sizeof(GimpContext), + sizeof(GimpContextClass), + (GtkClassInitFunc) gimp_context_class_init, + (GtkObjectInitFunc) gimp_context_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (gimp_object_get_type (), &info); + } + + return type; +} + +GimpContext * +gimp_context_new (void) +{ + GimpContext *context; + + context = gtk_type_new (gimp_context_get_type ()); + + return context; +} + +GimpContext * +gimp_context_get_current (void) +{ + return current_context; +} + +void +gimp_context_set_current (GimpContext *context) +{ + current_context = context; +} + +gdouble +gimp_context_get_opacity (GimpContext *context) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_val_if_fail (context != NULL, 1.0); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), 1.0); + + return context->opacity; +} + +void +gimp_context_set_opacity (GimpContext *context, + gdouble opacity) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_if_fail (context != NULL); + g_return_if_fail (GIMP_IS_CONTEXT (context)); + + context->opacity = opacity; + gtk_signal_emit (GTK_OBJECT (context), + gimp_context_signals[OPACITY_CHANGED]); +} + +gint +gimp_context_get_paint_mode (GimpContext *context) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_val_if_fail (context != NULL, 0); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), 0); + + return context->paint_mode; +} + +void +gimp_context_set_paint_mode (GimpContext *context, + gint paint_mode) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_if_fail (context != NULL); + g_return_if_fail (GIMP_IS_CONTEXT (context)); + + context->paint_mode = paint_mode; + gtk_signal_emit (GTK_OBJECT(context), + gimp_context_signals[PAINT_MODE_CHANGED]); +} diff --git a/app/core/gimpcontext.h b/app/core/gimpcontext.h new file mode 100644 index 0000000000..a58f57636f --- /dev/null +++ b/app/core/gimpcontext.h @@ -0,0 +1,66 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMP_CONTEXT_H__ +#define __GIMP_CONTEXT_H__ + +#include "gimpobjectP.h" + +#define GIMP_TYPE_CONTEXT (gimp_context_get_type ()) +#define GIMP_CONTEXT(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_CONTEXT, GimpContext)) +#define GIMP_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_CAST (klass, GIMP_TYPE_CONTEXT, GimpContextClass)) +#define GIMP_IS_CONTEXT(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_CONTEXT)) +#define GIMP_IS_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTEXT)) + +typedef struct _GimpContext GimpContext; +typedef struct _GimpContextClass GimpContextClass; + +struct _GimpContext +{ + GimpObject object; + + gdouble opacity; + gint paint_mode; +}; + +struct _GimpContextClass +{ + GimpObjectClass parent_class; + + void (* opacity_changed) (GimpContext *context); + void (* paint_mode_changed) (GimpContext *context); +}; + +GtkType gimp_context_get_type (void); +GimpContext * gimp_context_new (void); + +/* to be used by the context management system only + */ +GimpContext * gimp_context_get_current (void); +void gimp_context_set_current (GimpContext *context); + +/* functions for manipulating a single context + */ +gdouble gimp_context_get_opacity (GimpContext *context); +void gimp_context_set_opacity (GimpContext *context, + gdouble opacity); + +gint gimp_context_get_paint_mode (GimpContext *context); +void gimp_context_set_paint_mode (GimpContext *context, + gint paint_mode); + +#endif /* __GIMP_CONTEXT_H__ */ diff --git a/app/gimpcontext.c b/app/gimpcontext.c new file mode 100644 index 0000000000..77e3eca3b1 --- /dev/null +++ b/app/gimpcontext.c @@ -0,0 +1,185 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include "gimpcontext.h" +#include "gimpsignal.h" + +#define CONTEXT_CHECK_CURRENT(context) \ + ((context) = (context) ? (context) : current_context) + +enum { + OPACITY_CHANGED, + PAINT_MODE_CHANGED, + LAST_SIGNAL +}; + +static guint gimp_context_signals[LAST_SIGNAL] = { 0 }; + +static GimpObjectClass* parent_class = NULL; + +/* the currently active context */ +static GimpContext * current_context = NULL; + +/* for later use +static void +gimp_context_destroy (GtkObject *object) +{ + GimpContext *context; + + g_return_if_fail (object != NULL); + g_return_if_fail (GIMP_IS_CONTEXT (object)); + + context = GIMP_CONTEXT (object); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} +*/ + +static void +gimp_context_class_init (GimpContextClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + + parent_class = gtk_type_class (gimp_object_get_type ()); + + gimp_context_signals[OPACITY_CHANGED] = + gimp_signal_new ("opacity_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContextClass, + opacity_changed), + gimp_sigtype_void); + + gimp_context_signals[PAINT_MODE_CHANGED] = + gimp_signal_new ("paint_mode_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (GimpContextClass, + paint_mode_changed), + gimp_sigtype_void); + + gtk_object_class_add_signals (object_class, gimp_context_signals, + LAST_SIGNAL); + + klass->opacity_changed = NULL; + klass->paint_mode_changed = NULL; + + /* object_class->destroy = gimp_context_destroy; */ +} + +static void +gimp_context_init (GimpContext *context) +{ + context->opacity = 1.0; + context->paint_mode = 0; +} + +GtkType +gimp_context_get_type (void) +{ + static GtkType type = 0; + + if(!type) + { + GtkTypeInfo info = + { + "GimpContext", + sizeof(GimpContext), + sizeof(GimpContextClass), + (GtkClassInitFunc) gimp_context_class_init, + (GtkObjectInitFunc) gimp_context_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (gimp_object_get_type (), &info); + } + + return type; +} + +GimpContext * +gimp_context_new (void) +{ + GimpContext *context; + + context = gtk_type_new (gimp_context_get_type ()); + + return context; +} + +GimpContext * +gimp_context_get_current (void) +{ + return current_context; +} + +void +gimp_context_set_current (GimpContext *context) +{ + current_context = context; +} + +gdouble +gimp_context_get_opacity (GimpContext *context) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_val_if_fail (context != NULL, 1.0); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), 1.0); + + return context->opacity; +} + +void +gimp_context_set_opacity (GimpContext *context, + gdouble opacity) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_if_fail (context != NULL); + g_return_if_fail (GIMP_IS_CONTEXT (context)); + + context->opacity = opacity; + gtk_signal_emit (GTK_OBJECT (context), + gimp_context_signals[OPACITY_CHANGED]); +} + +gint +gimp_context_get_paint_mode (GimpContext *context) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_val_if_fail (context != NULL, 0); + g_return_val_if_fail (GIMP_IS_CONTEXT (context), 0); + + return context->paint_mode; +} + +void +gimp_context_set_paint_mode (GimpContext *context, + gint paint_mode) +{ + CONTEXT_CHECK_CURRENT (context); + g_return_if_fail (context != NULL); + g_return_if_fail (GIMP_IS_CONTEXT (context)); + + context->paint_mode = paint_mode; + gtk_signal_emit (GTK_OBJECT(context), + gimp_context_signals[PAINT_MODE_CHANGED]); +} diff --git a/app/gimpcontext.h b/app/gimpcontext.h new file mode 100644 index 0000000000..a58f57636f --- /dev/null +++ b/app/gimpcontext.h @@ -0,0 +1,66 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMP_CONTEXT_H__ +#define __GIMP_CONTEXT_H__ + +#include "gimpobjectP.h" + +#define GIMP_TYPE_CONTEXT (gimp_context_get_type ()) +#define GIMP_CONTEXT(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_CONTEXT, GimpContext)) +#define GIMP_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_CAST (klass, GIMP_TYPE_CONTEXT, GimpContextClass)) +#define GIMP_IS_CONTEXT(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_CONTEXT)) +#define GIMP_IS_CONTEXT_CLASS(klass) (GIMP_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTEXT)) + +typedef struct _GimpContext GimpContext; +typedef struct _GimpContextClass GimpContextClass; + +struct _GimpContext +{ + GimpObject object; + + gdouble opacity; + gint paint_mode; +}; + +struct _GimpContextClass +{ + GimpObjectClass parent_class; + + void (* opacity_changed) (GimpContext *context); + void (* paint_mode_changed) (GimpContext *context); +}; + +GtkType gimp_context_get_type (void); +GimpContext * gimp_context_new (void); + +/* to be used by the context management system only + */ +GimpContext * gimp_context_get_current (void); +void gimp_context_set_current (GimpContext *context); + +/* functions for manipulating a single context + */ +gdouble gimp_context_get_opacity (GimpContext *context); +void gimp_context_set_opacity (GimpContext *context, + gdouble opacity); + +gint gimp_context_get_paint_mode (GimpContext *context); +void gimp_context_set_paint_mode (GimpContext *context, + gint paint_mode); + +#endif /* __GIMP_CONTEXT_H__ */ diff --git a/libgimp/gimpchainbutton.c b/libgimp/gimpchainbutton.c index 276506cc9a..5a12673c8c 100644 --- a/libgimp/gimpchainbutton.c +++ b/libgimp/gimpchainbutton.c @@ -37,6 +37,8 @@ static void gimp_chain_button_draw_lines (GtkWidget *widget, GdkEvent* event, GimpChainButton *gcb); +static GtkWidgetClass *parent_class = NULL; + static void gimp_chain_button_class_init (GimpChainButtonClass *class) { @@ -44,7 +46,7 @@ gimp_chain_button_class_init (GimpChainButtonClass *class) object_class = (GtkObjectClass*) class; - class->gimp_chain_button = NULL; + parent_class = gtk_type_class (gtk_widget_get_type ()); } static void diff --git a/libgimp/gimpchainbutton.h b/libgimp/gimpchainbutton.h index e6db0fcd87..a54c062489 100644 --- a/libgimp/gimpchainbutton.h +++ b/libgimp/gimpchainbutton.h @@ -70,8 +70,6 @@ struct _GimpChainButton struct _GimpChainButtonClass { GtkButtonClass parent_class; - - void (* gimp_chain_button) (GimpChainButton *gcb); }; diff --git a/libgimp/gimpfileselection.c b/libgimp/gimpfileselection.c index 234ffbd109..02f7625194 100644 --- a/libgimp/gimpfileselection.c +++ b/libgimp/gimpfileselection.c @@ -47,25 +47,18 @@ # endif #endif -/* callbacks - */ -static void gimp_file_selection_realize (GtkWidget *widget, - gpointer data); -static void gimp_file_selection_entry_callback (GtkWidget *widget, - gpointer data); -static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static void gimp_file_selection_browse_callback (GtkWidget *widget, - gpointer data); +/* callbacks */ +static void gimp_file_selection_realize (GtkWidget *, gpointer); +static void gimp_file_selection_entry_callback (GtkWidget *, gpointer); +static int gimp_file_selection_entry_focus_out_callback (GtkWidget *, + GdkEvent *, gpointer); +static void gimp_file_selection_browse_callback (GtkWidget *, gpointer); -/* private functions - */ +/* private functions */ static void gimp_file_selection_check_filename (GimpFileSelection *gfs); - enum { - GFS_FILENAME_CHANGED_SIGNAL, + FILENAME_CHANGED, LAST_SIGNAL }; @@ -74,7 +67,7 @@ static gint gimp_file_selection_signals[LAST_SIGNAL] = { 0 }; static GtkHBoxClass *parent_class = NULL; static void -gimp_file_selection_class_destroy (GtkObject *object) +gimp_file_selection_destroy (GtkObject *object) { GimpFileSelection *gfs; @@ -102,18 +95,20 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class) parent_class = gtk_type_class (gtk_hbox_get_type ()); - gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL] = + gimp_file_selection_signals[FILENAME_CHANGED] = gtk_signal_new ("filename_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpFileSelectionClass, - gimp_file_selection), + filename_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_file_selection_signals, LAST_SIGNAL); - object_class->destroy = gimp_file_selection_class_destroy; - class->gimp_file_selection = NULL; + class->filename_changed = NULL; + + object_class->destroy = gimp_file_selection_destroy; } static void @@ -141,16 +136,15 @@ gimp_file_selection_init (GimpFileSelection *gfs) (GdkEventFunc) gimp_file_selection_entry_focus_out_callback, gfs); gtk_widget_show (gfs->entry); - /* this callback does the rest (pixmap creation etc.) - */ + /* this callback does the rest (pixmap creation etc.) */ gtk_signal_connect (GTK_OBJECT(gfs), "realize", GTK_SIGNAL_FUNC(gimp_file_selection_realize), gfs); } -guint +GtkType gimp_file_selection_get_type () { - static guint gfs_type = 0; + static GtkType gfs_type = 0; if (!gfs_type) { @@ -172,7 +166,6 @@ gimp_file_selection_get_type () return gfs_type; } - GtkWidget* gimp_file_selection_new (gchar *title, gchar *filename, @@ -191,7 +184,6 @@ gimp_file_selection_new (gchar *title, return GTK_WIDGET (gfs); } - static void gimp_file_selection_realize (GtkWidget *widget, gpointer data) @@ -226,7 +218,6 @@ gimp_file_selection_realize (GtkWidget *widget, gtk_widget_show (gfs->file_exists); } - gchar* gimp_file_selection_get_filename (GimpFileSelection *gfs) { @@ -236,7 +227,6 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs) return gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); } - void gimp_file_selection_set_filename (GimpFileSelection *gfs, gchar *filename) @@ -251,7 +241,6 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs, gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); } - static void gimp_file_selection_entry_callback (GtkWidget *widget, gpointer data) @@ -286,10 +275,9 @@ gimp_file_selection_entry_callback (GtkWidget *widget, gtk_entry_set_position (GTK_ENTRY (gfs->entry), -1); gtk_signal_emit (GTK_OBJECT (gfs), - gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL]); + gimp_file_selection_signals[FILENAME_CHANGED]); } - static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, GdkEvent *event, @@ -300,9 +288,7 @@ gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, return TRUE; } - -/* these are local callbacks of gimp_file_selection_browse_callback() - */ +/* local callbacks of gimp_file_selection_browse_callback() */ static void gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gpointer data) @@ -316,8 +302,7 @@ gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); - /* update everything - */ + /* update everything */ gimp_file_selection_entry_callback (gfs->entry, data); } @@ -370,25 +355,29 @@ gimp_file_selection_browse_callback (GtkWidget *widget, gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->ok_button)->child), _("Select")); gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button)->child), _("Close")); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), - "clicked", - (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), - "activate", - (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), - "clicked", - (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (gfs), "unmap", - (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (gfs->file_selection), - "delete_event", - (GdkEventFunc)gimp_file_selection_filesel_delete_callback, - gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), + "clicked", + (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), + "activate", + (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), + "clicked", + (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (gfs), "unmap", + (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (gfs->file_selection), "delete_event", + (GdkEventFunc)gimp_file_selection_filesel_delete_callback, + gfs); } gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), @@ -399,7 +388,6 @@ gimp_file_selection_browse_callback (GtkWidget *widget, gdk_window_raise (gfs->file_selection->window); } - static void gimp_file_selection_check_filename (GimpFileSelection *gfs) { diff --git a/libgimp/gimpfileselection.h b/libgimp/gimpfileselection.h index 4f9c84305c..bfd4f45e52 100644 --- a/libgimp/gimpfileselection.h +++ b/libgimp/gimpfileselection.h @@ -62,10 +62,10 @@ struct _GimpFileSelectionClass { GtkHBoxClass parent_class; - void (* gimp_file_selection) (GimpFileSelection *gfs); + void (* filename_changed) (GimpFileSelection *gfs); }; -guint gimp_file_selection_get_type (void); +GtkType gimp_file_selection_get_type (void); /* creates a new GimpFileSelection widget * diff --git a/libgimp/gimppatheditor.c b/libgimp/gimppatheditor.c index 44681e4ab8..c9451361c6 100644 --- a/libgimp/gimppatheditor.c +++ b/libgimp/gimppatheditor.c @@ -19,7 +19,6 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - #include "gimppatheditor.h" #include "libgimp/gimpfileselection.h" @@ -32,8 +31,7 @@ #include "pixmaps/raise.xpm" #include "pixmaps/lower.xpm" -/* callbacks - */ +/* forward declaration */ static void gimp_path_editor_realize (GtkWidget *widget, gpointer data); static void gimp_path_editor_select_callback (GtkWidget *widget, gpointer data); static void gimp_path_editor_deselect_callback (GtkWidget *widget, @@ -51,7 +49,7 @@ static void gimp_path_editor_check_path (GimpPathEditor *gpe, */ enum { - GPE_PATH_CHANGED_SIGNAL, + PATH_CHANGED, LAST_SIGNAL }; @@ -68,17 +66,18 @@ gimp_path_editor_class_init (GimpPathEditorClass *class) parent_class = gtk_type_class (gtk_vbox_get_type ()); - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL] = + gimp_path_editor_signals[PATH_CHANGED] = gtk_signal_new ("path_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpPathEditorClass, - gimp_path_editor), + path_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_path_editor_signals, LAST_SIGNAL); - class->gimp_path_editor = NULL; + class->path_changed = NULL; } static void @@ -138,16 +137,15 @@ gimp_path_editor_init (GimpPathEditor *gpe) gpe->dir_list); gtk_widget_show (gpe->dir_list); - /* this callback does the rest (pixmap creation etc.) - */ + /* this callback does the rest (pixmap creation etc.) */ gtk_signal_connect (GTK_OBJECT(gpe), "realize", GTK_SIGNAL_FUNC(gimp_path_editor_realize), gpe); } -guint +GtkType gimp_path_editor_get_type () { - static guint gpe_type = 0; + static GtkType gpe_type = 0; if (!gpe_type) { @@ -195,8 +193,7 @@ gimp_path_editor_new (gchar *filesel_title, directory_list = NULL; directory = path = g_strdup (path); - /* split up the path - */ + /* split up the path */ while (strlen (directory)) { gchar *current_dir; @@ -236,7 +233,6 @@ gimp_path_editor_new (gchar *filesel_title, return GTK_WIDGET (gpe); } - static void gimp_path_editor_realize (GtkWidget *widget, gpointer data) @@ -301,7 +297,6 @@ gimp_path_editor_realize (GtkWidget *widget, */ } - gchar* gimp_path_editor_get_path (GimpPathEditor *gpe) { @@ -337,7 +332,6 @@ gimp_path_editor_get_path (GimpPathEditor *gpe) return path; } - static void gimp_path_editor_select_callback (GtkWidget *widget, gpointer data) @@ -384,7 +378,6 @@ gimp_path_editor_deselect_callback (GtkWidget *widget, gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->selected_item), gpe); } - static void gimp_path_editor_new_callback (GtkWidget *widget, gpointer data) @@ -411,7 +404,6 @@ gimp_path_editor_new_callback (GtkWidget *widget, gtk_widget_grab_focus (GTK_WIDGET (GIMP_FILE_SELECTION (gpe->file_selection)->entry)); } - static void gimp_path_editor_move_callback (GtkWidget *widget, gpointer data) @@ -435,10 +427,9 @@ gimp_path_editor_move_callback (GtkWidget *widget, gtk_list_select_item (GTK_LIST (gpe->dir_list), pos + distance); gtk_signal_emit (GTK_OBJECT (gpe), - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL]); + gimp_path_editor_signals[PATH_CHANGED]); } - static void gimp_path_editor_delete_callback (GtkWidget *widget, gpointer data) @@ -473,10 +464,9 @@ gimp_path_editor_delete_callback (GtkWidget *widget, gtk_list_select_item (GTK_LIST (gpe->dir_list), pos); gtk_signal_emit (GTK_OBJECT (gpe), - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL]); + gimp_path_editor_signals[PATH_CHANGED]); } - static void gimp_path_editor_filesel_callback (GtkWidget *widget, gpointer data) @@ -521,17 +511,15 @@ gimp_path_editor_filesel_callback (GtkWidget *widget, /* gimp_path_editor_check_path (gpe, gpe->selected_item); */ gtk_signal_emit (GTK_OBJECT (gpe), - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL]); + gimp_path_editor_signals[PATH_CHANGED]); } - static void gimp_path_editor_data_destroy_callback (gpointer *data) { g_free (data); } - /* static void gimp_path_editor_check_path (GimpPathEditor *gpe, GtkWidget *list_item) diff --git a/libgimp/gimppatheditor.h b/libgimp/gimppatheditor.h index ee7b6a731d..8fe382d359 100644 --- a/libgimp/gimppatheditor.h +++ b/libgimp/gimppatheditor.h @@ -19,7 +19,6 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - #ifndef __GIMP_PATH_EDITOR_H__ #define __GIMP_PATH_EDITOR_H__ @@ -61,19 +60,19 @@ struct _GimpPathEditorClass { GtkVBoxClass parent_class; - void (* gimp_path_editor) (GimpPathEditor *gpe); + void (* path_changed) (GimpPathEditor *gpe); }; -guint gimp_path_editor_get_type (void); +GtkType gimp_path_editor_get_type (void); /* creates a new GimpPathEditor widget */ -GtkWidget* gimp_path_editor_new (gchar *filesel_title, - gchar *path); +GtkWidget * gimp_path_editor_new (gchar *filesel_title, + gchar *path); /* it's up to the caller to g_free() the returned string */ -gchar* gimp_path_editor_get_path (GimpPathEditor *gpe); +gchar * gimp_path_editor_get_path (GimpPathEditor *gpe); #ifdef __cplusplus } diff --git a/libgimp/gimpsizeentry.c b/libgimp/gimpsizeentry.c index 9089d6298a..82a94fcfdf 100644 --- a/libgimp/gimpsizeentry.c +++ b/libgimp/gimpsizeentry.c @@ -37,9 +37,9 @@ static int gimp_size_entry_focus_out_callback (GtkWidget *widget, */ enum { - GSE_VALUE_CHANGED_SIGNAL, - GSE_REFVAL_CHANGED_SIGNAL, - GSE_UNIT_CHANGED_SIGNAL, + VALUE_CHANGED, + REFVAL_CHANGED, + UNIT_CHANGED, LAST_SIGNAL }; @@ -67,14 +67,12 @@ struct _GimpSizeEntryField gint stop_recursion; }; - static gint gimp_size_entry_signals[LAST_SIGNAL] = { 0 }; static GtkTableClass *parent_class = NULL; - static void -gimp_size_entry_class_destroy (GtkObject *object) +gimp_size_entry_destroy (GtkObject *object) { GimpSizeEntry *gse; GSList *list; @@ -102,32 +100,38 @@ gimp_size_entry_class_init (GimpSizeEntryClass *class) parent_class = gtk_type_class (gtk_table_get_type ()); - gimp_size_entry_signals[GSE_VALUE_CHANGED_SIGNAL] = + gimp_size_entry_signals[VALUE_CHANGED] = gtk_signal_new ("value_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpSizeEntryClass, - gimp_size_entry), + value_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gimp_size_entry_signals[GSE_REFVAL_CHANGED_SIGNAL] = + + gimp_size_entry_signals[REFVAL_CHANGED] = gtk_signal_new ("refval_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpSizeEntryClass, - gimp_size_entry), + refval_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gimp_size_entry_signals[GSE_UNIT_CHANGED_SIGNAL] = + + gimp_size_entry_signals[UNIT_CHANGED] = gtk_signal_new ("unit_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpSizeEntryClass, - gimp_size_entry), + unit_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_size_entry_signals, LAST_SIGNAL); - object_class->destroy = gimp_size_entry_class_destroy; - class->gimp_size_entry = NULL; + class->value_changed = NULL; + class->refval_changed = NULL; + class->unit_changed = NULL; + + object_class->destroy = gimp_size_entry_destroy; } static void @@ -143,7 +147,7 @@ gimp_size_entry_init (GimpSizeEntry *gse) gse->update_policy = GIMP_SIZE_ENTRY_UPDATE_NONE; } -guint +GtkType gimp_size_entry_get_type () { static guint gse_type = 0; @@ -168,7 +172,6 @@ gimp_size_entry_get_type () return gse_type; } - GtkWidget* gimp_size_entry_new (gint number_of_fields, GUnit unit, @@ -649,7 +652,7 @@ gimp_size_entry_value_callback (GtkWidget *widget, { gimp_size_entry_update_value (gsef, new_value); gtk_signal_emit (GTK_OBJECT (gsef->gse), - gimp_size_entry_signals[GSE_VALUE_CHANGED_SIGNAL]); + gimp_size_entry_signals[VALUE_CHANGED]); } } @@ -860,7 +863,7 @@ gimp_size_entry_refval_callback (GtkWidget *widget, { gimp_size_entry_update_refval (gsef, new_refval); gtk_signal_emit (GTK_OBJECT (gsef->gse), - gimp_size_entry_signals[GSE_REFVAL_CHANGED_SIGNAL]); + gimp_size_entry_signals[REFVAL_CHANGED]); } } @@ -936,12 +939,10 @@ gimp_size_entry_unit_callback (GtkWidget *widget, gimp_size_entry_update_unit (GIMP_SIZE_ENTRY (data), gimp_unit_menu_get_unit (GIMP_UNIT_MENU(widget))); gtk_signal_emit (GTK_OBJECT (data), - gimp_size_entry_signals[GSE_UNIT_CHANGED_SIGNAL]); + gimp_size_entry_signals[UNIT_CHANGED]); } - /* focus stuff **********/ - void gimp_size_entry_grab_focus (GimpSizeEntry *gse) { @@ -956,7 +957,6 @@ gimp_size_entry_grab_focus (GimpSizeEntry *gse) gsef->refval_spinbutton : gsef->value_spinbutton); } - /* static int gimp_size_entry_focus_in_callback (GtkWidget *widget, diff --git a/libgimp/gimpsizeentry.h b/libgimp/gimpsizeentry.h index e185808bcb..af30c8cd23 100644 --- a/libgimp/gimpsizeentry.h +++ b/libgimp/gimpsizeentry.h @@ -64,10 +64,12 @@ struct _GimpSizeEntryClass { GtkTableClass parent_class; - void (* gimp_size_entry) (GimpSizeEntry *gse); + void (* value_changed) (GimpSizeEntry *gse); + void (* refval_changed) (GimpSizeEntry *gse); + void (* unit_changed) (GimpSizeEntry *gse); }; -guint gimp_size_entry_get_type (void); +GtkType gimp_size_entry_get_type (void); /* creates a new GimpSizeEntry widget * number_of_fields -- how many spinbuttons to show @@ -87,14 +89,17 @@ guint gimp_size_entry_get_type (void); * to have all automatic calculations performed correctly, set up the * widget in the following order: * 1. gimp_size_entry_new - * 2. (for each input column) gimp_size_entry_set_resolution - * 3. (for each input column) gimp_size_entry_set_value_boundaries - * (or _set_refval_boundaries) - * 4. (for each input column) gimp_size_entry_set_value (or _set_refval) + * 2. (for each additional input field) gimp_size_entry_add_field + * 3. gimp_size_entry_set_unit + * for each input field: + * 4. gimp_size_entry_set_resolution + * 5. gimp_size_entry_set_value_boundaries (or _set_refval_boundaries) + * 6. gimp_size_entry_set_size + * 7. gimp_size_entry_set_value (or _set_refval) * * the newly created GimpSizeEntry table will have an empty border * of one cell width on each side plus an empty column left of the - * unit menu to allow the caller to add his own labels + * unit menu to allow the caller to add labels */ GtkWidget* gimp_size_entry_new (gint number_of_fields, GUnit unit, diff --git a/libgimp/gimpunitmenu.c b/libgimp/gimpunitmenu.c index 78c93e9105..ef165336b6 100644 --- a/libgimp/gimpunitmenu.c +++ b/libgimp/gimpunitmenu.c @@ -32,7 +32,7 @@ static void gimp_unit_menu_callback (GtkWidget *widget, gpointer data); enum { - GUM_UNIT_CHANGED_SIGNAL, + UNIT_CHANGED, LAST_SIGNAL }; @@ -41,7 +41,7 @@ static gint gimp_unit_menu_signals[LAST_SIGNAL] = { 0 }; static GtkOptionMenuClass *parent_class = NULL; static void -gimp_unit_menu_class_destroy (GtkObject *object) +gimp_unit_menu_destroy (GtkObject *object) { GimpUnitMenu *gum; @@ -50,7 +50,8 @@ gimp_unit_menu_class_destroy (GtkObject *object) gum = GIMP_UNIT_MENU (object); - g_free (gum->format); + if (gum->format) + g_free (gum->format); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -65,20 +66,21 @@ gimp_unit_menu_class_init (GimpUnitMenuClass *class) parent_class = gtk_type_class (gtk_option_menu_get_type ()); - gimp_unit_menu_signals[GUM_UNIT_CHANGED_SIGNAL] = + gimp_unit_menu_signals[UNIT_CHANGED] = gtk_signal_new ("unit_changed", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (GimpUnitMenuClass, gimp_unit_menu), + GTK_SIGNAL_OFFSET (GimpUnitMenuClass, + unit_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, gimp_unit_menu_signals, LAST_SIGNAL); - object_class->destroy = gimp_unit_menu_class_destroy; - class->gimp_unit_menu = NULL; -} + class->unit_changed = NULL; + object_class->destroy = gimp_unit_menu_destroy; +} static void gimp_unit_menu_init (GimpUnitMenu *gum) @@ -91,11 +93,10 @@ gimp_unit_menu_init (GimpUnitMenu *gum) gum->show_percent = FALSE; } - -guint +GtkType gimp_unit_menu_get_type () { - static guint gum_type = 0; + static GtkType gum_type = 0; if (!gum_type) { @@ -117,7 +118,6 @@ gimp_unit_menu_get_type () return gum_type; } - GtkWidget* gimp_unit_menu_new (gchar *format, GUnit unit, @@ -225,7 +225,6 @@ gimp_unit_menu_new (gchar *format, return GTK_WIDGET (gum); } - void gimp_unit_menu_set_unit (GimpUnitMenu *gum, GUnit unit) @@ -296,7 +295,6 @@ gimp_unit_menu_get_unit (GimpUnitMenu *gum) return gum->unit; } - /* most of the next two functions is stolen from app/gdisplay.c */ static int print (char *buf, int len, int start, const char *fmt, ...) @@ -318,7 +316,6 @@ print (char *buf, int len, int start, const char *fmt, ...) static const gchar* gimp_unit_menu_build_string (gchar *format, GUnit unit) { - #define BUFFER_LEN 64 static gchar buffer[BUFFER_LEN]; @@ -383,12 +380,11 @@ gimp_unit_menu_build_string (gchar *format, GUnit unit) buffer[MIN(i, BUFFER_LEN - 1)] = 0; return buffer; + +#undef BUFFER_LEN } - -/* private callbacks of gimp_unit_menu_create_selection () - */ - +/* private callbacks of gimp_unit_menu_create_selection () */ static void gimp_unit_menu_selection_select_callback (GtkWidget *widget, gpointer data) @@ -404,7 +400,7 @@ gimp_unit_menu_selection_select_callback (GtkWidget *widget, (int) (GTK_CLIST (gum->clist)->selection->data)); gimp_unit_menu_set_unit (gum, unit); gtk_signal_emit (GTK_OBJECT (gum), - gimp_unit_menu_signals[GUM_UNIT_CHANGED_SIGNAL]); + gimp_unit_menu_signals[UNIT_CHANGED]); gtk_widget_destroy (gum->selection); gum->selection = NULL; @@ -438,9 +434,7 @@ gimp_unit_menu_selection_delete_callback (GtkWidget *widget, return TRUE; } -/* private function of gimp_unit_menu_callback () - */ - +/* private function of gimp_unit_menu_callback () */ static void gimp_unit_menu_create_selection (GimpUnitMenu *gum) { @@ -503,7 +497,8 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_widget_show(gum->clist); /* build the action area */ - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (gum->selection)->action_area), 2); + gtk_container_set_border_width + (GTK_CONTAINER (GTK_DIALOG (gum->selection)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (gum->selection)->action_area), FALSE); hbbox = gtk_hbutton_box_new (); @@ -556,7 +551,6 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) } } - static void gimp_unit_menu_callback (GtkWidget *widget, gpointer data) @@ -596,5 +590,5 @@ gimp_unit_menu_callback (GtkWidget *widget, gimp_unit_menu_set_unit (gum, new_unit); gtk_signal_emit (GTK_OBJECT (gum), - gimp_unit_menu_signals[GUM_UNIT_CHANGED_SIGNAL]); + gimp_unit_menu_signals[UNIT_CHANGED]); } diff --git a/libgimp/gimpunitmenu.h b/libgimp/gimpunitmenu.h index ca38701d21..db4cc5bcb4 100644 --- a/libgimp/gimpunitmenu.h +++ b/libgimp/gimpunitmenu.h @@ -59,10 +59,10 @@ struct _GimpUnitMenuClass { GtkOptionMenuClass parent_class; - void (* gimp_unit_menu) (GimpUnitMenu *gum); + void (* unit_changed) (GimpUnitMenu *gum); }; -guint gimp_unit_menu_get_type (void); +GtkType gimp_unit_menu_get_type (void); /* format -- a printf-like format string for the menu items * unit -- the unit selected on widget creation diff --git a/libgimpwidgets/gimpchainbutton.c b/libgimpwidgets/gimpchainbutton.c index 276506cc9a..5a12673c8c 100644 --- a/libgimpwidgets/gimpchainbutton.c +++ b/libgimpwidgets/gimpchainbutton.c @@ -37,6 +37,8 @@ static void gimp_chain_button_draw_lines (GtkWidget *widget, GdkEvent* event, GimpChainButton *gcb); +static GtkWidgetClass *parent_class = NULL; + static void gimp_chain_button_class_init (GimpChainButtonClass *class) { @@ -44,7 +46,7 @@ gimp_chain_button_class_init (GimpChainButtonClass *class) object_class = (GtkObjectClass*) class; - class->gimp_chain_button = NULL; + parent_class = gtk_type_class (gtk_widget_get_type ()); } static void diff --git a/libgimpwidgets/gimpchainbutton.h b/libgimpwidgets/gimpchainbutton.h index e6db0fcd87..a54c062489 100644 --- a/libgimpwidgets/gimpchainbutton.h +++ b/libgimpwidgets/gimpchainbutton.h @@ -70,8 +70,6 @@ struct _GimpChainButton struct _GimpChainButtonClass { GtkButtonClass parent_class; - - void (* gimp_chain_button) (GimpChainButton *gcb); }; diff --git a/libgimpwidgets/gimpfileentry.c b/libgimpwidgets/gimpfileentry.c index 234ffbd109..02f7625194 100644 --- a/libgimpwidgets/gimpfileentry.c +++ b/libgimpwidgets/gimpfileentry.c @@ -47,25 +47,18 @@ # endif #endif -/* callbacks - */ -static void gimp_file_selection_realize (GtkWidget *widget, - gpointer data); -static void gimp_file_selection_entry_callback (GtkWidget *widget, - gpointer data); -static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static void gimp_file_selection_browse_callback (GtkWidget *widget, - gpointer data); +/* callbacks */ +static void gimp_file_selection_realize (GtkWidget *, gpointer); +static void gimp_file_selection_entry_callback (GtkWidget *, gpointer); +static int gimp_file_selection_entry_focus_out_callback (GtkWidget *, + GdkEvent *, gpointer); +static void gimp_file_selection_browse_callback (GtkWidget *, gpointer); -/* private functions - */ +/* private functions */ static void gimp_file_selection_check_filename (GimpFileSelection *gfs); - enum { - GFS_FILENAME_CHANGED_SIGNAL, + FILENAME_CHANGED, LAST_SIGNAL }; @@ -74,7 +67,7 @@ static gint gimp_file_selection_signals[LAST_SIGNAL] = { 0 }; static GtkHBoxClass *parent_class = NULL; static void -gimp_file_selection_class_destroy (GtkObject *object) +gimp_file_selection_destroy (GtkObject *object) { GimpFileSelection *gfs; @@ -102,18 +95,20 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class) parent_class = gtk_type_class (gtk_hbox_get_type ()); - gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL] = + gimp_file_selection_signals[FILENAME_CHANGED] = gtk_signal_new ("filename_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpFileSelectionClass, - gimp_file_selection), + filename_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_file_selection_signals, LAST_SIGNAL); - object_class->destroy = gimp_file_selection_class_destroy; - class->gimp_file_selection = NULL; + class->filename_changed = NULL; + + object_class->destroy = gimp_file_selection_destroy; } static void @@ -141,16 +136,15 @@ gimp_file_selection_init (GimpFileSelection *gfs) (GdkEventFunc) gimp_file_selection_entry_focus_out_callback, gfs); gtk_widget_show (gfs->entry); - /* this callback does the rest (pixmap creation etc.) - */ + /* this callback does the rest (pixmap creation etc.) */ gtk_signal_connect (GTK_OBJECT(gfs), "realize", GTK_SIGNAL_FUNC(gimp_file_selection_realize), gfs); } -guint +GtkType gimp_file_selection_get_type () { - static guint gfs_type = 0; + static GtkType gfs_type = 0; if (!gfs_type) { @@ -172,7 +166,6 @@ gimp_file_selection_get_type () return gfs_type; } - GtkWidget* gimp_file_selection_new (gchar *title, gchar *filename, @@ -191,7 +184,6 @@ gimp_file_selection_new (gchar *title, return GTK_WIDGET (gfs); } - static void gimp_file_selection_realize (GtkWidget *widget, gpointer data) @@ -226,7 +218,6 @@ gimp_file_selection_realize (GtkWidget *widget, gtk_widget_show (gfs->file_exists); } - gchar* gimp_file_selection_get_filename (GimpFileSelection *gfs) { @@ -236,7 +227,6 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs) return gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); } - void gimp_file_selection_set_filename (GimpFileSelection *gfs, gchar *filename) @@ -251,7 +241,6 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs, gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); } - static void gimp_file_selection_entry_callback (GtkWidget *widget, gpointer data) @@ -286,10 +275,9 @@ gimp_file_selection_entry_callback (GtkWidget *widget, gtk_entry_set_position (GTK_ENTRY (gfs->entry), -1); gtk_signal_emit (GTK_OBJECT (gfs), - gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL]); + gimp_file_selection_signals[FILENAME_CHANGED]); } - static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, GdkEvent *event, @@ -300,9 +288,7 @@ gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, return TRUE; } - -/* these are local callbacks of gimp_file_selection_browse_callback() - */ +/* local callbacks of gimp_file_selection_browse_callback() */ static void gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gpointer data) @@ -316,8 +302,7 @@ gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); - /* update everything - */ + /* update everything */ gimp_file_selection_entry_callback (gfs->entry, data); } @@ -370,25 +355,29 @@ gimp_file_selection_browse_callback (GtkWidget *widget, gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->ok_button)->child), _("Select")); gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button)->child), _("Close")); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), - "clicked", - (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), - "activate", - (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), - "clicked", - (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (gfs), "unmap", - (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (gfs->file_selection), - "delete_event", - (GdkEventFunc)gimp_file_selection_filesel_delete_callback, - gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), + "clicked", + (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), + "activate", + (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), + "clicked", + (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (gfs), "unmap", + (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (gfs->file_selection), "delete_event", + (GdkEventFunc)gimp_file_selection_filesel_delete_callback, + gfs); } gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), @@ -399,7 +388,6 @@ gimp_file_selection_browse_callback (GtkWidget *widget, gdk_window_raise (gfs->file_selection->window); } - static void gimp_file_selection_check_filename (GimpFileSelection *gfs) { diff --git a/libgimpwidgets/gimpfileentry.h b/libgimpwidgets/gimpfileentry.h index 4f9c84305c..bfd4f45e52 100644 --- a/libgimpwidgets/gimpfileentry.h +++ b/libgimpwidgets/gimpfileentry.h @@ -62,10 +62,10 @@ struct _GimpFileSelectionClass { GtkHBoxClass parent_class; - void (* gimp_file_selection) (GimpFileSelection *gfs); + void (* filename_changed) (GimpFileSelection *gfs); }; -guint gimp_file_selection_get_type (void); +GtkType gimp_file_selection_get_type (void); /* creates a new GimpFileSelection widget * diff --git a/libgimpwidgets/gimpfileselection.c b/libgimpwidgets/gimpfileselection.c index 234ffbd109..02f7625194 100644 --- a/libgimpwidgets/gimpfileselection.c +++ b/libgimpwidgets/gimpfileselection.c @@ -47,25 +47,18 @@ # endif #endif -/* callbacks - */ -static void gimp_file_selection_realize (GtkWidget *widget, - gpointer data); -static void gimp_file_selection_entry_callback (GtkWidget *widget, - gpointer data); -static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static void gimp_file_selection_browse_callback (GtkWidget *widget, - gpointer data); +/* callbacks */ +static void gimp_file_selection_realize (GtkWidget *, gpointer); +static void gimp_file_selection_entry_callback (GtkWidget *, gpointer); +static int gimp_file_selection_entry_focus_out_callback (GtkWidget *, + GdkEvent *, gpointer); +static void gimp_file_selection_browse_callback (GtkWidget *, gpointer); -/* private functions - */ +/* private functions */ static void gimp_file_selection_check_filename (GimpFileSelection *gfs); - enum { - GFS_FILENAME_CHANGED_SIGNAL, + FILENAME_CHANGED, LAST_SIGNAL }; @@ -74,7 +67,7 @@ static gint gimp_file_selection_signals[LAST_SIGNAL] = { 0 }; static GtkHBoxClass *parent_class = NULL; static void -gimp_file_selection_class_destroy (GtkObject *object) +gimp_file_selection_destroy (GtkObject *object) { GimpFileSelection *gfs; @@ -102,18 +95,20 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class) parent_class = gtk_type_class (gtk_hbox_get_type ()); - gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL] = + gimp_file_selection_signals[FILENAME_CHANGED] = gtk_signal_new ("filename_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpFileSelectionClass, - gimp_file_selection), + filename_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_file_selection_signals, LAST_SIGNAL); - object_class->destroy = gimp_file_selection_class_destroy; - class->gimp_file_selection = NULL; + class->filename_changed = NULL; + + object_class->destroy = gimp_file_selection_destroy; } static void @@ -141,16 +136,15 @@ gimp_file_selection_init (GimpFileSelection *gfs) (GdkEventFunc) gimp_file_selection_entry_focus_out_callback, gfs); gtk_widget_show (gfs->entry); - /* this callback does the rest (pixmap creation etc.) - */ + /* this callback does the rest (pixmap creation etc.) */ gtk_signal_connect (GTK_OBJECT(gfs), "realize", GTK_SIGNAL_FUNC(gimp_file_selection_realize), gfs); } -guint +GtkType gimp_file_selection_get_type () { - static guint gfs_type = 0; + static GtkType gfs_type = 0; if (!gfs_type) { @@ -172,7 +166,6 @@ gimp_file_selection_get_type () return gfs_type; } - GtkWidget* gimp_file_selection_new (gchar *title, gchar *filename, @@ -191,7 +184,6 @@ gimp_file_selection_new (gchar *title, return GTK_WIDGET (gfs); } - static void gimp_file_selection_realize (GtkWidget *widget, gpointer data) @@ -226,7 +218,6 @@ gimp_file_selection_realize (GtkWidget *widget, gtk_widget_show (gfs->file_exists); } - gchar* gimp_file_selection_get_filename (GimpFileSelection *gfs) { @@ -236,7 +227,6 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs) return gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); } - void gimp_file_selection_set_filename (GimpFileSelection *gfs, gchar *filename) @@ -251,7 +241,6 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs, gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); } - static void gimp_file_selection_entry_callback (GtkWidget *widget, gpointer data) @@ -286,10 +275,9 @@ gimp_file_selection_entry_callback (GtkWidget *widget, gtk_entry_set_position (GTK_ENTRY (gfs->entry), -1); gtk_signal_emit (GTK_OBJECT (gfs), - gimp_file_selection_signals[GFS_FILENAME_CHANGED_SIGNAL]); + gimp_file_selection_signals[FILENAME_CHANGED]); } - static int gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, GdkEvent *event, @@ -300,9 +288,7 @@ gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, return TRUE; } - -/* these are local callbacks of gimp_file_selection_browse_callback() - */ +/* local callbacks of gimp_file_selection_browse_callback() */ static void gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gpointer data) @@ -316,8 +302,7 @@ gimp_file_selection_filesel_ok_callback (GtkWidget *widget, gtk_entry_set_text (GTK_ENTRY (gfs->entry), filename); - /* update everything - */ + /* update everything */ gimp_file_selection_entry_callback (gfs->entry, data); } @@ -370,25 +355,29 @@ gimp_file_selection_browse_callback (GtkWidget *widget, gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->ok_button)->child), _("Select")); gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button)->child), _("Close")); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), - "clicked", - (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), - "activate", - (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), - "clicked", - (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (gfs), "unmap", - (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, - gfs); - gtk_signal_connect (GTK_OBJECT (gfs->file_selection), - "delete_event", - (GdkEventFunc)gimp_file_selection_filesel_delete_callback, - gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->ok_button), + "clicked", + (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->selection_entry), + "activate", + (GtkSignalFunc)gimp_file_selection_filesel_ok_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (GTK_FILE_SELECTION (gfs->file_selection)->cancel_button), + "clicked", + (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (gfs), "unmap", + (GtkSignalFunc)gimp_file_selection_filesel_cancel_callback, + gfs); + gtk_signal_connect + (GTK_OBJECT (gfs->file_selection), "delete_event", + (GdkEventFunc)gimp_file_selection_filesel_delete_callback, + gfs); } gtk_file_selection_set_filename (GTK_FILE_SELECTION (gfs->file_selection), @@ -399,7 +388,6 @@ gimp_file_selection_browse_callback (GtkWidget *widget, gdk_window_raise (gfs->file_selection->window); } - static void gimp_file_selection_check_filename (GimpFileSelection *gfs) { diff --git a/libgimpwidgets/gimpfileselection.h b/libgimpwidgets/gimpfileselection.h index 4f9c84305c..bfd4f45e52 100644 --- a/libgimpwidgets/gimpfileselection.h +++ b/libgimpwidgets/gimpfileselection.h @@ -62,10 +62,10 @@ struct _GimpFileSelectionClass { GtkHBoxClass parent_class; - void (* gimp_file_selection) (GimpFileSelection *gfs); + void (* filename_changed) (GimpFileSelection *gfs); }; -guint gimp_file_selection_get_type (void); +GtkType gimp_file_selection_get_type (void); /* creates a new GimpFileSelection widget * diff --git a/libgimpwidgets/gimppatheditor.c b/libgimpwidgets/gimppatheditor.c index 44681e4ab8..c9451361c6 100644 --- a/libgimpwidgets/gimppatheditor.c +++ b/libgimpwidgets/gimppatheditor.c @@ -19,7 +19,6 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - #include "gimppatheditor.h" #include "libgimp/gimpfileselection.h" @@ -32,8 +31,7 @@ #include "pixmaps/raise.xpm" #include "pixmaps/lower.xpm" -/* callbacks - */ +/* forward declaration */ static void gimp_path_editor_realize (GtkWidget *widget, gpointer data); static void gimp_path_editor_select_callback (GtkWidget *widget, gpointer data); static void gimp_path_editor_deselect_callback (GtkWidget *widget, @@ -51,7 +49,7 @@ static void gimp_path_editor_check_path (GimpPathEditor *gpe, */ enum { - GPE_PATH_CHANGED_SIGNAL, + PATH_CHANGED, LAST_SIGNAL }; @@ -68,17 +66,18 @@ gimp_path_editor_class_init (GimpPathEditorClass *class) parent_class = gtk_type_class (gtk_vbox_get_type ()); - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL] = + gimp_path_editor_signals[PATH_CHANGED] = gtk_signal_new ("path_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpPathEditorClass, - gimp_path_editor), + path_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_path_editor_signals, LAST_SIGNAL); - class->gimp_path_editor = NULL; + class->path_changed = NULL; } static void @@ -138,16 +137,15 @@ gimp_path_editor_init (GimpPathEditor *gpe) gpe->dir_list); gtk_widget_show (gpe->dir_list); - /* this callback does the rest (pixmap creation etc.) - */ + /* this callback does the rest (pixmap creation etc.) */ gtk_signal_connect (GTK_OBJECT(gpe), "realize", GTK_SIGNAL_FUNC(gimp_path_editor_realize), gpe); } -guint +GtkType gimp_path_editor_get_type () { - static guint gpe_type = 0; + static GtkType gpe_type = 0; if (!gpe_type) { @@ -195,8 +193,7 @@ gimp_path_editor_new (gchar *filesel_title, directory_list = NULL; directory = path = g_strdup (path); - /* split up the path - */ + /* split up the path */ while (strlen (directory)) { gchar *current_dir; @@ -236,7 +233,6 @@ gimp_path_editor_new (gchar *filesel_title, return GTK_WIDGET (gpe); } - static void gimp_path_editor_realize (GtkWidget *widget, gpointer data) @@ -301,7 +297,6 @@ gimp_path_editor_realize (GtkWidget *widget, */ } - gchar* gimp_path_editor_get_path (GimpPathEditor *gpe) { @@ -337,7 +332,6 @@ gimp_path_editor_get_path (GimpPathEditor *gpe) return path; } - static void gimp_path_editor_select_callback (GtkWidget *widget, gpointer data) @@ -384,7 +378,6 @@ gimp_path_editor_deselect_callback (GtkWidget *widget, gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->selected_item), gpe); } - static void gimp_path_editor_new_callback (GtkWidget *widget, gpointer data) @@ -411,7 +404,6 @@ gimp_path_editor_new_callback (GtkWidget *widget, gtk_widget_grab_focus (GTK_WIDGET (GIMP_FILE_SELECTION (gpe->file_selection)->entry)); } - static void gimp_path_editor_move_callback (GtkWidget *widget, gpointer data) @@ -435,10 +427,9 @@ gimp_path_editor_move_callback (GtkWidget *widget, gtk_list_select_item (GTK_LIST (gpe->dir_list), pos + distance); gtk_signal_emit (GTK_OBJECT (gpe), - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL]); + gimp_path_editor_signals[PATH_CHANGED]); } - static void gimp_path_editor_delete_callback (GtkWidget *widget, gpointer data) @@ -473,10 +464,9 @@ gimp_path_editor_delete_callback (GtkWidget *widget, gtk_list_select_item (GTK_LIST (gpe->dir_list), pos); gtk_signal_emit (GTK_OBJECT (gpe), - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL]); + gimp_path_editor_signals[PATH_CHANGED]); } - static void gimp_path_editor_filesel_callback (GtkWidget *widget, gpointer data) @@ -521,17 +511,15 @@ gimp_path_editor_filesel_callback (GtkWidget *widget, /* gimp_path_editor_check_path (gpe, gpe->selected_item); */ gtk_signal_emit (GTK_OBJECT (gpe), - gimp_path_editor_signals[GPE_PATH_CHANGED_SIGNAL]); + gimp_path_editor_signals[PATH_CHANGED]); } - static void gimp_path_editor_data_destroy_callback (gpointer *data) { g_free (data); } - /* static void gimp_path_editor_check_path (GimpPathEditor *gpe, GtkWidget *list_item) diff --git a/libgimpwidgets/gimppatheditor.h b/libgimpwidgets/gimppatheditor.h index ee7b6a731d..8fe382d359 100644 --- a/libgimpwidgets/gimppatheditor.h +++ b/libgimpwidgets/gimppatheditor.h @@ -19,7 +19,6 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - #ifndef __GIMP_PATH_EDITOR_H__ #define __GIMP_PATH_EDITOR_H__ @@ -61,19 +60,19 @@ struct _GimpPathEditorClass { GtkVBoxClass parent_class; - void (* gimp_path_editor) (GimpPathEditor *gpe); + void (* path_changed) (GimpPathEditor *gpe); }; -guint gimp_path_editor_get_type (void); +GtkType gimp_path_editor_get_type (void); /* creates a new GimpPathEditor widget */ -GtkWidget* gimp_path_editor_new (gchar *filesel_title, - gchar *path); +GtkWidget * gimp_path_editor_new (gchar *filesel_title, + gchar *path); /* it's up to the caller to g_free() the returned string */ -gchar* gimp_path_editor_get_path (GimpPathEditor *gpe); +gchar * gimp_path_editor_get_path (GimpPathEditor *gpe); #ifdef __cplusplus } diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index 9089d6298a..82a94fcfdf 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -37,9 +37,9 @@ static int gimp_size_entry_focus_out_callback (GtkWidget *widget, */ enum { - GSE_VALUE_CHANGED_SIGNAL, - GSE_REFVAL_CHANGED_SIGNAL, - GSE_UNIT_CHANGED_SIGNAL, + VALUE_CHANGED, + REFVAL_CHANGED, + UNIT_CHANGED, LAST_SIGNAL }; @@ -67,14 +67,12 @@ struct _GimpSizeEntryField gint stop_recursion; }; - static gint gimp_size_entry_signals[LAST_SIGNAL] = { 0 }; static GtkTableClass *parent_class = NULL; - static void -gimp_size_entry_class_destroy (GtkObject *object) +gimp_size_entry_destroy (GtkObject *object) { GimpSizeEntry *gse; GSList *list; @@ -102,32 +100,38 @@ gimp_size_entry_class_init (GimpSizeEntryClass *class) parent_class = gtk_type_class (gtk_table_get_type ()); - gimp_size_entry_signals[GSE_VALUE_CHANGED_SIGNAL] = + gimp_size_entry_signals[VALUE_CHANGED] = gtk_signal_new ("value_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpSizeEntryClass, - gimp_size_entry), + value_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gimp_size_entry_signals[GSE_REFVAL_CHANGED_SIGNAL] = + + gimp_size_entry_signals[REFVAL_CHANGED] = gtk_signal_new ("refval_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpSizeEntryClass, - gimp_size_entry), + refval_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gimp_size_entry_signals[GSE_UNIT_CHANGED_SIGNAL] = + + gimp_size_entry_signals[UNIT_CHANGED] = gtk_signal_new ("unit_changed", GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (GimpSizeEntryClass, - gimp_size_entry), + unit_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_size_entry_signals, LAST_SIGNAL); - object_class->destroy = gimp_size_entry_class_destroy; - class->gimp_size_entry = NULL; + class->value_changed = NULL; + class->refval_changed = NULL; + class->unit_changed = NULL; + + object_class->destroy = gimp_size_entry_destroy; } static void @@ -143,7 +147,7 @@ gimp_size_entry_init (GimpSizeEntry *gse) gse->update_policy = GIMP_SIZE_ENTRY_UPDATE_NONE; } -guint +GtkType gimp_size_entry_get_type () { static guint gse_type = 0; @@ -168,7 +172,6 @@ gimp_size_entry_get_type () return gse_type; } - GtkWidget* gimp_size_entry_new (gint number_of_fields, GUnit unit, @@ -649,7 +652,7 @@ gimp_size_entry_value_callback (GtkWidget *widget, { gimp_size_entry_update_value (gsef, new_value); gtk_signal_emit (GTK_OBJECT (gsef->gse), - gimp_size_entry_signals[GSE_VALUE_CHANGED_SIGNAL]); + gimp_size_entry_signals[VALUE_CHANGED]); } } @@ -860,7 +863,7 @@ gimp_size_entry_refval_callback (GtkWidget *widget, { gimp_size_entry_update_refval (gsef, new_refval); gtk_signal_emit (GTK_OBJECT (gsef->gse), - gimp_size_entry_signals[GSE_REFVAL_CHANGED_SIGNAL]); + gimp_size_entry_signals[REFVAL_CHANGED]); } } @@ -936,12 +939,10 @@ gimp_size_entry_unit_callback (GtkWidget *widget, gimp_size_entry_update_unit (GIMP_SIZE_ENTRY (data), gimp_unit_menu_get_unit (GIMP_UNIT_MENU(widget))); gtk_signal_emit (GTK_OBJECT (data), - gimp_size_entry_signals[GSE_UNIT_CHANGED_SIGNAL]); + gimp_size_entry_signals[UNIT_CHANGED]); } - /* focus stuff **********/ - void gimp_size_entry_grab_focus (GimpSizeEntry *gse) { @@ -956,7 +957,6 @@ gimp_size_entry_grab_focus (GimpSizeEntry *gse) gsef->refval_spinbutton : gsef->value_spinbutton); } - /* static int gimp_size_entry_focus_in_callback (GtkWidget *widget, diff --git a/libgimpwidgets/gimpsizeentry.h b/libgimpwidgets/gimpsizeentry.h index e185808bcb..af30c8cd23 100644 --- a/libgimpwidgets/gimpsizeentry.h +++ b/libgimpwidgets/gimpsizeentry.h @@ -64,10 +64,12 @@ struct _GimpSizeEntryClass { GtkTableClass parent_class; - void (* gimp_size_entry) (GimpSizeEntry *gse); + void (* value_changed) (GimpSizeEntry *gse); + void (* refval_changed) (GimpSizeEntry *gse); + void (* unit_changed) (GimpSizeEntry *gse); }; -guint gimp_size_entry_get_type (void); +GtkType gimp_size_entry_get_type (void); /* creates a new GimpSizeEntry widget * number_of_fields -- how many spinbuttons to show @@ -87,14 +89,17 @@ guint gimp_size_entry_get_type (void); * to have all automatic calculations performed correctly, set up the * widget in the following order: * 1. gimp_size_entry_new - * 2. (for each input column) gimp_size_entry_set_resolution - * 3. (for each input column) gimp_size_entry_set_value_boundaries - * (or _set_refval_boundaries) - * 4. (for each input column) gimp_size_entry_set_value (or _set_refval) + * 2. (for each additional input field) gimp_size_entry_add_field + * 3. gimp_size_entry_set_unit + * for each input field: + * 4. gimp_size_entry_set_resolution + * 5. gimp_size_entry_set_value_boundaries (or _set_refval_boundaries) + * 6. gimp_size_entry_set_size + * 7. gimp_size_entry_set_value (or _set_refval) * * the newly created GimpSizeEntry table will have an empty border * of one cell width on each side plus an empty column left of the - * unit menu to allow the caller to add his own labels + * unit menu to allow the caller to add labels */ GtkWidget* gimp_size_entry_new (gint number_of_fields, GUnit unit, diff --git a/libgimpwidgets/gimpunitmenu.c b/libgimpwidgets/gimpunitmenu.c index 78c93e9105..ef165336b6 100644 --- a/libgimpwidgets/gimpunitmenu.c +++ b/libgimpwidgets/gimpunitmenu.c @@ -32,7 +32,7 @@ static void gimp_unit_menu_callback (GtkWidget *widget, gpointer data); enum { - GUM_UNIT_CHANGED_SIGNAL, + UNIT_CHANGED, LAST_SIGNAL }; @@ -41,7 +41,7 @@ static gint gimp_unit_menu_signals[LAST_SIGNAL] = { 0 }; static GtkOptionMenuClass *parent_class = NULL; static void -gimp_unit_menu_class_destroy (GtkObject *object) +gimp_unit_menu_destroy (GtkObject *object) { GimpUnitMenu *gum; @@ -50,7 +50,8 @@ gimp_unit_menu_class_destroy (GtkObject *object) gum = GIMP_UNIT_MENU (object); - g_free (gum->format); + if (gum->format) + g_free (gum->format); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -65,20 +66,21 @@ gimp_unit_menu_class_init (GimpUnitMenuClass *class) parent_class = gtk_type_class (gtk_option_menu_get_type ()); - gimp_unit_menu_signals[GUM_UNIT_CHANGED_SIGNAL] = + gimp_unit_menu_signals[UNIT_CHANGED] = gtk_signal_new ("unit_changed", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (GimpUnitMenuClass, gimp_unit_menu), + GTK_SIGNAL_OFFSET (GimpUnitMenuClass, + unit_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, gimp_unit_menu_signals, LAST_SIGNAL); - object_class->destroy = gimp_unit_menu_class_destroy; - class->gimp_unit_menu = NULL; -} + class->unit_changed = NULL; + object_class->destroy = gimp_unit_menu_destroy; +} static void gimp_unit_menu_init (GimpUnitMenu *gum) @@ -91,11 +93,10 @@ gimp_unit_menu_init (GimpUnitMenu *gum) gum->show_percent = FALSE; } - -guint +GtkType gimp_unit_menu_get_type () { - static guint gum_type = 0; + static GtkType gum_type = 0; if (!gum_type) { @@ -117,7 +118,6 @@ gimp_unit_menu_get_type () return gum_type; } - GtkWidget* gimp_unit_menu_new (gchar *format, GUnit unit, @@ -225,7 +225,6 @@ gimp_unit_menu_new (gchar *format, return GTK_WIDGET (gum); } - void gimp_unit_menu_set_unit (GimpUnitMenu *gum, GUnit unit) @@ -296,7 +295,6 @@ gimp_unit_menu_get_unit (GimpUnitMenu *gum) return gum->unit; } - /* most of the next two functions is stolen from app/gdisplay.c */ static int print (char *buf, int len, int start, const char *fmt, ...) @@ -318,7 +316,6 @@ print (char *buf, int len, int start, const char *fmt, ...) static const gchar* gimp_unit_menu_build_string (gchar *format, GUnit unit) { - #define BUFFER_LEN 64 static gchar buffer[BUFFER_LEN]; @@ -383,12 +380,11 @@ gimp_unit_menu_build_string (gchar *format, GUnit unit) buffer[MIN(i, BUFFER_LEN - 1)] = 0; return buffer; + +#undef BUFFER_LEN } - -/* private callbacks of gimp_unit_menu_create_selection () - */ - +/* private callbacks of gimp_unit_menu_create_selection () */ static void gimp_unit_menu_selection_select_callback (GtkWidget *widget, gpointer data) @@ -404,7 +400,7 @@ gimp_unit_menu_selection_select_callback (GtkWidget *widget, (int) (GTK_CLIST (gum->clist)->selection->data)); gimp_unit_menu_set_unit (gum, unit); gtk_signal_emit (GTK_OBJECT (gum), - gimp_unit_menu_signals[GUM_UNIT_CHANGED_SIGNAL]); + gimp_unit_menu_signals[UNIT_CHANGED]); gtk_widget_destroy (gum->selection); gum->selection = NULL; @@ -438,9 +434,7 @@ gimp_unit_menu_selection_delete_callback (GtkWidget *widget, return TRUE; } -/* private function of gimp_unit_menu_callback () - */ - +/* private function of gimp_unit_menu_callback () */ static void gimp_unit_menu_create_selection (GimpUnitMenu *gum) { @@ -503,7 +497,8 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) gtk_widget_show(gum->clist); /* build the action area */ - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (gum->selection)->action_area), 2); + gtk_container_set_border_width + (GTK_CONTAINER (GTK_DIALOG (gum->selection)->action_area), 2); gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (gum->selection)->action_area), FALSE); hbbox = gtk_hbutton_box_new (); @@ -556,7 +551,6 @@ gimp_unit_menu_create_selection (GimpUnitMenu *gum) } } - static void gimp_unit_menu_callback (GtkWidget *widget, gpointer data) @@ -596,5 +590,5 @@ gimp_unit_menu_callback (GtkWidget *widget, gimp_unit_menu_set_unit (gum, new_unit); gtk_signal_emit (GTK_OBJECT (gum), - gimp_unit_menu_signals[GUM_UNIT_CHANGED_SIGNAL]); + gimp_unit_menu_signals[UNIT_CHANGED]); } diff --git a/libgimpwidgets/gimpunitmenu.h b/libgimpwidgets/gimpunitmenu.h index ca38701d21..db4cc5bcb4 100644 --- a/libgimpwidgets/gimpunitmenu.h +++ b/libgimpwidgets/gimpunitmenu.h @@ -59,10 +59,10 @@ struct _GimpUnitMenuClass { GtkOptionMenuClass parent_class; - void (* gimp_unit_menu) (GimpUnitMenu *gum); + void (* unit_changed) (GimpUnitMenu *gum); }; -guint gimp_unit_menu_get_type (void); +GtkType gimp_unit_menu_get_type (void); /* format -- a printf-like format string for the menu items * unit -- the unit selected on widget creation