diff --git a/ChangeLog b/ChangeLog index 61fcd62074..b4636dbdb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2000-11-18 Michael Natterer + + * app/fileops.c + * libgimp/gimpquerybox.[ch]: Make sure that we don't try to destroy + query_boxes twice or try to disconnect not-any-more connected + handlers. + + * app/color_notebook.c + * app/gimpcontext.[ch] + * app/gimphelp.[ch] + * app/lc_dialog.[ch] + * app/menus.h + * app/preferences_dialog.c + * app/tools.[ch] + * libgimp/gimpcolorbutton.[ch] + * libgimp/gimpdialog.[ch] + * libgimp/gimpexport.[ch] + * libgimp/gimpfileselection.[ch] + * libgimp/gimphelpui.[ch] + * libgimp/gimppatheditor.[ch] + * libgimp/gimppixmap.[ch] + * libgimp/gimpsizeentry.[ch] + * libgimp/gimpui.[ch] + * libgimp/gimpunitmenu.[ch] + * libgimp/gimpwidgets.[ch]: in a coding attack, changed help_data + and many other strings passed to UI functions to (const gchar *). + As a consequence, I had to fix lots of warnings ;) + + * plug-ins/common/tga.c + * plug-ins/imagemap/imap_main.c: fixed warnings. + + Code cleanup and indentation all over the place. + 2000-11-16 Sven Neumann * plug-ins/print/Makefile.am diff --git a/app/color_notebook.c b/app/color_notebook.c index 7b6e68fa1a..131e324cf0 100644 --- a/app/color_notebook.c +++ b/app/color_notebook.c @@ -35,19 +35,6 @@ #include "libgimp/gimpintl.h" -static void color_notebook_ok_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_cancel_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_update_callback (gpointer, - gint, - gint, - gint); -static void color_notebook_page_switch (GtkWidget *, - GtkNotebookPage *, - guint); -static void color_notebook_help_func (gchar *help_data); - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo ColorSelectorInfo; @@ -72,7 +59,21 @@ struct _ColorSelectorInstance ColorSelectorInstance *next; }; -static void selector_death (ColorSelectorInfo *info); + +static void color_notebook_ok_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_update_callback (gpointer data, + gint red, + gint green, + gint blue); +static void color_notebook_page_switch (GtkWidget *widget, + GtkNotebookPage *page, + guint page_num); +static void color_notebook_help_func (const gchar *help_data); + +static void color_notebook_selector_death (ColorSelectorInfo *info); /* master list of all registered colour selectors */ @@ -116,7 +117,7 @@ color_notebook_new (gint red, cnp->shell = gimp_dialog_new (_("Color Selection"), "color_selection", - color_notebook_help_func, (gchar *) cnp, + color_notebook_help_func, (const gchar *) cnp, GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, @@ -235,7 +236,7 @@ color_notebook_free (ColorNotebook *cnp) csel->info->refs--; if (csel->info->refs == 0 && !csel->info->active) - selector_death (csel->info); + color_notebook_selector_death (csel->info); g_free (csel); csel = next; @@ -352,7 +353,7 @@ color_notebook_page_switch (GtkWidget *widget, } static void -color_notebook_help_func (gchar *data) +color_notebook_help_func (const gchar *data) { ColorNotebook *cnp; gchar *help_path; @@ -418,7 +419,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, info->death_callback = callback; info->death_data = data; if (info->refs == 0) - selector_death (info); + color_notebook_selector_death (info); return TRUE; } info = info->next; @@ -429,7 +430,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, } static void -selector_death (ColorSelectorInfo *info) +color_notebook_selector_death (ColorSelectorInfo *info) { ColorSelectorInfo *here, *prev; diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index 76613d3c44..7f970ed0d7 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -575,7 +575,7 @@ gimp_context_get_type (void) } GimpContext * -gimp_context_new (gchar *name, +gimp_context_new (const gchar *name, GimpContext *template) { GimpContext *context; @@ -663,7 +663,7 @@ gimp_context_get_name (GimpContext *context) void gimp_context_set_name (GimpContext *context, - gchar *name) + const gchar *name) { context_check_current (context); context_return_if_fail (context); diff --git a/app/core/gimpcontext.h b/app/core/gimpcontext.h index 1ed9e554cb..852816d63b 100644 --- a/app/core/gimpcontext.h +++ b/app/core/gimpcontext.h @@ -147,7 +147,7 @@ struct _GimpContextClass }; GtkType gimp_context_get_type (void); -GimpContext * gimp_context_new (gchar *name, +GimpContext * gimp_context_new (const gchar *name, GimpContext *template); /* TODO: - gimp_context_find () @@ -179,7 +179,7 @@ GimpContext * gimp_context_get_standard (void); */ gchar * gimp_context_get_name (GimpContext *context); void gimp_context_set_name (GimpContext *context, - gchar *name); + const gchar *name); GimpContext * gimp_context_get_parent (GimpContext *context); void gimp_context_set_parent (GimpContext *context, diff --git a/app/dialogs/color-dialog.c b/app/dialogs/color-dialog.c index 7b6e68fa1a..131e324cf0 100644 --- a/app/dialogs/color-dialog.c +++ b/app/dialogs/color-dialog.c @@ -35,19 +35,6 @@ #include "libgimp/gimpintl.h" -static void color_notebook_ok_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_cancel_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_update_callback (gpointer, - gint, - gint, - gint); -static void color_notebook_page_switch (GtkWidget *, - GtkNotebookPage *, - guint); -static void color_notebook_help_func (gchar *help_data); - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo ColorSelectorInfo; @@ -72,7 +59,21 @@ struct _ColorSelectorInstance ColorSelectorInstance *next; }; -static void selector_death (ColorSelectorInfo *info); + +static void color_notebook_ok_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_update_callback (gpointer data, + gint red, + gint green, + gint blue); +static void color_notebook_page_switch (GtkWidget *widget, + GtkNotebookPage *page, + guint page_num); +static void color_notebook_help_func (const gchar *help_data); + +static void color_notebook_selector_death (ColorSelectorInfo *info); /* master list of all registered colour selectors */ @@ -116,7 +117,7 @@ color_notebook_new (gint red, cnp->shell = gimp_dialog_new (_("Color Selection"), "color_selection", - color_notebook_help_func, (gchar *) cnp, + color_notebook_help_func, (const gchar *) cnp, GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, @@ -235,7 +236,7 @@ color_notebook_free (ColorNotebook *cnp) csel->info->refs--; if (csel->info->refs == 0 && !csel->info->active) - selector_death (csel->info); + color_notebook_selector_death (csel->info); g_free (csel); csel = next; @@ -352,7 +353,7 @@ color_notebook_page_switch (GtkWidget *widget, } static void -color_notebook_help_func (gchar *data) +color_notebook_help_func (const gchar *data) { ColorNotebook *cnp; gchar *help_path; @@ -418,7 +419,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, info->death_callback = callback; info->death_data = data; if (info->refs == 0) - selector_death (info); + color_notebook_selector_death (info); return TRUE; } info = info->next; @@ -429,7 +430,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, } static void -selector_death (ColorSelectorInfo *info) +color_notebook_selector_death (ColorSelectorInfo *info) { ColorSelectorInfo *here, *prev; diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 60826f41d0..db265b5e7d 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1,5 +1,5 @@ /* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * Copyright (C) 1995-1997 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 @@ -54,23 +54,39 @@ typedef enum /* preferences local functions */ static PrefsState prefs_check_settings (void); -static void prefs_ok_callback (GtkWidget *, GtkWidget *); -static void prefs_save_callback (GtkWidget *, GtkWidget *); -static void prefs_cancel_callback (GtkWidget *, GtkWidget *); +static void prefs_ok_callback (GtkWidget *widget, + GtkWidget *dlg); +static void prefs_save_callback (GtkWidget *widget, + GtkWidget *dlg); +static void prefs_cancel_callback (GtkWidget *widget, + GtkWidget *dlg); -static void prefs_toggle_callback (GtkWidget *widget, gpointer data); -static void prefs_preview_size_callback (GtkWidget *widget, gpointer data); -static void prefs_nav_preview_size_callback (GtkWidget *widget, gpointer data); -static void prefs_string_callback (GtkWidget *widget, gpointer data); -static void prefs_text_callback (GtkWidget *widget, gpointer data); -static void prefs_filename_callback (GtkWidget *widget, gpointer data); -static void prefs_path_callback (GtkWidget *widget, gpointer data); -static void prefs_clear_session_info_callback (GtkWidget *widget, gpointer data); -static void prefs_default_size_callback (GtkWidget *widget, gpointer data); -static void prefs_default_resolution_callback (GtkWidget *widget, gpointer data); -static void prefs_res_source_callback (GtkWidget *widget, gpointer data); -static void prefs_monitor_resolution_callback (GtkWidget *widget, gpointer data); -static void prefs_resolution_calibrate_callback (GtkWidget *widget, gpointer data); +static void prefs_toggle_callback (GtkWidget *widget, + gpointer data); +static void prefs_preview_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_nav_preview_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_string_callback (GtkWidget *widget, + gpointer data); +static void prefs_text_callback (GtkWidget *widget, + gpointer data); +static void prefs_filename_callback (GtkWidget *widget, + gpointer data); +static void prefs_path_callback (GtkWidget *widget, + gpointer data); +static void prefs_clear_session_info_callback (GtkWidget *widget, + gpointer data); +static void prefs_default_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_default_resolution_callback (GtkWidget *widget, + gpointer data); +static void prefs_res_source_callback (GtkWidget *widget, + gpointer data); +static void prefs_monitor_resolution_callback (GtkWidget *widget, + gpointer data); +static void prefs_resolution_calibrate_callback (GtkWidget *widget, + gpointer data); static void prefs_restart_notification (void); @@ -1295,7 +1311,7 @@ prefs_frame_new (gchar *label, } static void -prefs_help_func (gchar *help_data) +prefs_help_func (const gchar *help_data) { GtkWidget *notebook; GtkWidget *event_box; diff --git a/app/fileops.c b/app/fileops.c index 813838bec7..b284978921 100644 --- a/app/fileops.c +++ b/app/fileops.c @@ -629,18 +629,14 @@ file_revert_callback (GtkWidget *widget, FALSE, text, _("Yes"), _("No"), - NULL, NULL, + GTK_OBJECT (gimage), "destroy", file_revert_confirm_callback, gimage); - gtk_object_set_data (GTK_OBJECT (gimage), REVERT_DATA_KEY, query_box); - - gtk_signal_connect_object_while_alive (GTK_OBJECT (gimage), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (query_box)); - g_free (text); + gtk_object_set_data (GTK_OBJECT (gimage), REVERT_DATA_KEY, query_box); + gtk_widget_show (query_box); } } diff --git a/app/gimpcontext.c b/app/gimpcontext.c index 76613d3c44..7f970ed0d7 100644 --- a/app/gimpcontext.c +++ b/app/gimpcontext.c @@ -575,7 +575,7 @@ gimp_context_get_type (void) } GimpContext * -gimp_context_new (gchar *name, +gimp_context_new (const gchar *name, GimpContext *template) { GimpContext *context; @@ -663,7 +663,7 @@ gimp_context_get_name (GimpContext *context) void gimp_context_set_name (GimpContext *context, - gchar *name) + const gchar *name) { context_check_current (context); context_return_if_fail (context); diff --git a/app/gimpcontext.h b/app/gimpcontext.h index 1ed9e554cb..852816d63b 100644 --- a/app/gimpcontext.h +++ b/app/gimpcontext.h @@ -147,7 +147,7 @@ struct _GimpContextClass }; GtkType gimp_context_get_type (void); -GimpContext * gimp_context_new (gchar *name, +GimpContext * gimp_context_new (const gchar *name, GimpContext *template); /* TODO: - gimp_context_find () @@ -179,7 +179,7 @@ GimpContext * gimp_context_get_standard (void); */ gchar * gimp_context_get_name (GimpContext *context); void gimp_context_set_name (GimpContext *context, - gchar *name); + const gchar *name); GimpContext * gimp_context_get_parent (GimpContext *context); void gimp_context_set_parent (GimpContext *context, diff --git a/app/gimphelp.c b/app/gimphelp.c index fe501bf1ac..02f6b51b9c 100644 --- a/app/gimphelp.c +++ b/app/gimphelp.c @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimphelp.c - * Copyright (C) 1999 Michael Natterer + * Copyright (C) 1999-2000 Michael Natterer * * 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 @@ -53,13 +53,13 @@ struct _GimpIdleHelp }; /* local function prototypes */ -static gint gimp_idle_help (gpointer data); -static gboolean gimp_help_internal (gchar *help_path, - gchar *current_locale, - gchar *help_data); -static void gimp_help_netscape (gchar *help_path, - gchar *current_locale, - gchar *help_data); +static gint gimp_idle_help (gpointer data); +static gboolean gimp_help_internal (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data); +static void gimp_help_netscape (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data); /**********************/ /* public functions */ @@ -67,15 +67,15 @@ static void gimp_help_netscape (gchar *help_path, /* The standard help function */ void -gimp_standard_help_func (gchar *help_data) +gimp_standard_help_func (const gchar *help_data) { gimp_help (NULL, help_data); } /* the main help function */ void -gimp_help (gchar *help_path, - gchar *help_data) +gimp_help (const gchar *help_path, + const gchar *help_data) { if (use_help) { @@ -169,9 +169,9 @@ gimp_help_internal_not_found_callback (GtkWidget *widget, } static gboolean -gimp_help_internal (gchar *help_path, - gchar *current_locale, - gchar *help_data) +gimp_help_internal (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data) { ProcRecord *proc_rec; @@ -207,11 +207,11 @@ gimp_help_internal (gchar *help_path, args[0].arg_type = PDB_INT32; args[0].value.pdb_int = RUN_INTERACTIVE; args[1].arg_type = PDB_STRING; - args[1].value.pdb_pointer = help_path; + args[1].value.pdb_pointer = (gpointer) help_path; args[2].arg_type = PDB_STRING; - args[2].value.pdb_pointer = current_locale; + args[2].value.pdb_pointer = (gpointer) current_locale; args[3].arg_type = PDB_STRING; - args[3].value.pdb_pointer = help_data; + args[3].value.pdb_pointer = (gpointer) help_data; plug_in_run (proc_rec, args, 4, FALSE, TRUE, 0); @@ -237,9 +237,9 @@ gimp_help_internal (gchar *help_path, } static void -gimp_help_netscape (gchar *help_path, - gchar *current_locale, - gchar *help_data) +gimp_help_netscape (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data) { Argument *return_vals; gint nreturn_vals; diff --git a/app/gimphelp.h b/app/gimphelp.h index ac87fa082b..ad36fc7456 100644 --- a/app/gimphelp.h +++ b/app/gimphelp.h @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimphelp.h - * Copyright (C) 1999 Michael Natterer + * Copyright (C) 1999-2000 Michael Natterer * * 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 @@ -18,21 +18,26 @@ * 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_HELP_H__ #define __GIMP_HELP_H__ + #include #include "libgimp/gimphelpui.h" + enum { HELP_BROWSER_GIMP, HELP_BROWSER_NETSCAPE }; + /* the main help function */ -void gimp_help (gchar *help_path, - gchar *help_data); +void gimp_help (const gchar *help_path, + const gchar *help_data); + #endif /* __GIMP_HELP_H__ */ diff --git a/app/gui/color-notebook.c b/app/gui/color-notebook.c index 7b6e68fa1a..131e324cf0 100644 --- a/app/gui/color-notebook.c +++ b/app/gui/color-notebook.c @@ -35,19 +35,6 @@ #include "libgimp/gimpintl.h" -static void color_notebook_ok_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_cancel_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_update_callback (gpointer, - gint, - gint, - gint); -static void color_notebook_page_switch (GtkWidget *, - GtkNotebookPage *, - guint); -static void color_notebook_help_func (gchar *help_data); - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo ColorSelectorInfo; @@ -72,7 +59,21 @@ struct _ColorSelectorInstance ColorSelectorInstance *next; }; -static void selector_death (ColorSelectorInfo *info); + +static void color_notebook_ok_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_update_callback (gpointer data, + gint red, + gint green, + gint blue); +static void color_notebook_page_switch (GtkWidget *widget, + GtkNotebookPage *page, + guint page_num); +static void color_notebook_help_func (const gchar *help_data); + +static void color_notebook_selector_death (ColorSelectorInfo *info); /* master list of all registered colour selectors */ @@ -116,7 +117,7 @@ color_notebook_new (gint red, cnp->shell = gimp_dialog_new (_("Color Selection"), "color_selection", - color_notebook_help_func, (gchar *) cnp, + color_notebook_help_func, (const gchar *) cnp, GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, @@ -235,7 +236,7 @@ color_notebook_free (ColorNotebook *cnp) csel->info->refs--; if (csel->info->refs == 0 && !csel->info->active) - selector_death (csel->info); + color_notebook_selector_death (csel->info); g_free (csel); csel = next; @@ -352,7 +353,7 @@ color_notebook_page_switch (GtkWidget *widget, } static void -color_notebook_help_func (gchar *data) +color_notebook_help_func (const gchar *data) { ColorNotebook *cnp; gchar *help_path; @@ -418,7 +419,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, info->death_callback = callback; info->death_data = data; if (info->refs == 0) - selector_death (info); + color_notebook_selector_death (info); return TRUE; } info = info->next; @@ -429,7 +430,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, } static void -selector_death (ColorSelectorInfo *info) +color_notebook_selector_death (ColorSelectorInfo *info) { ColorSelectorInfo *here, *prev; diff --git a/app/gui/menus.h b/app/gui/menus.h index 21ec9aa85b..3cac7aceb6 100644 --- a/app/gui/menus.h +++ b/app/gui/menus.h @@ -26,8 +26,8 @@ struct _GimpItemFactoryEntry { GtkItemFactoryEntry entry; - gchar *help_page; - gchar *description; + const gchar *help_page; + gchar *description; }; void menus_get_toolbox_menubar (GtkWidget **menubar, diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index 60826f41d0..db265b5e7d 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -1,5 +1,5 @@ /* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * Copyright (C) 1995-1997 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 @@ -54,23 +54,39 @@ typedef enum /* preferences local functions */ static PrefsState prefs_check_settings (void); -static void prefs_ok_callback (GtkWidget *, GtkWidget *); -static void prefs_save_callback (GtkWidget *, GtkWidget *); -static void prefs_cancel_callback (GtkWidget *, GtkWidget *); +static void prefs_ok_callback (GtkWidget *widget, + GtkWidget *dlg); +static void prefs_save_callback (GtkWidget *widget, + GtkWidget *dlg); +static void prefs_cancel_callback (GtkWidget *widget, + GtkWidget *dlg); -static void prefs_toggle_callback (GtkWidget *widget, gpointer data); -static void prefs_preview_size_callback (GtkWidget *widget, gpointer data); -static void prefs_nav_preview_size_callback (GtkWidget *widget, gpointer data); -static void prefs_string_callback (GtkWidget *widget, gpointer data); -static void prefs_text_callback (GtkWidget *widget, gpointer data); -static void prefs_filename_callback (GtkWidget *widget, gpointer data); -static void prefs_path_callback (GtkWidget *widget, gpointer data); -static void prefs_clear_session_info_callback (GtkWidget *widget, gpointer data); -static void prefs_default_size_callback (GtkWidget *widget, gpointer data); -static void prefs_default_resolution_callback (GtkWidget *widget, gpointer data); -static void prefs_res_source_callback (GtkWidget *widget, gpointer data); -static void prefs_monitor_resolution_callback (GtkWidget *widget, gpointer data); -static void prefs_resolution_calibrate_callback (GtkWidget *widget, gpointer data); +static void prefs_toggle_callback (GtkWidget *widget, + gpointer data); +static void prefs_preview_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_nav_preview_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_string_callback (GtkWidget *widget, + gpointer data); +static void prefs_text_callback (GtkWidget *widget, + gpointer data); +static void prefs_filename_callback (GtkWidget *widget, + gpointer data); +static void prefs_path_callback (GtkWidget *widget, + gpointer data); +static void prefs_clear_session_info_callback (GtkWidget *widget, + gpointer data); +static void prefs_default_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_default_resolution_callback (GtkWidget *widget, + gpointer data); +static void prefs_res_source_callback (GtkWidget *widget, + gpointer data); +static void prefs_monitor_resolution_callback (GtkWidget *widget, + gpointer data); +static void prefs_resolution_calibrate_callback (GtkWidget *widget, + gpointer data); static void prefs_restart_notification (void); @@ -1295,7 +1311,7 @@ prefs_frame_new (gchar *label, } static void -prefs_help_func (gchar *help_data) +prefs_help_func (const gchar *help_data) { GtkWidget *notebook; GtkWidget *event_box; diff --git a/app/lc_dialog.c b/app/lc_dialog.c index ab2e2fb515..e922f78f3a 100644 --- a/app/lc_dialog.c +++ b/app/lc_dialog.c @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "config.h" #include "appenv.h" @@ -32,48 +33,65 @@ #include "libgimp/gimpintl.h" #include "libgimp/gimplimits.h" +#include "libgimp/gimpmath.h" -#define MENU_THUMBNAIL_WIDTH 24 + +#define MENU_THUMBNAIL_WIDTH 24 #define MENU_THUMBNAIL_HEIGHT 24 -/* local function prototypes */ -static void lc_dialog_update (GimpImage *); -static void lc_dialog_image_menu_callback (GtkWidget *, gpointer); -static void lc_dialog_auto_callback (GtkWidget *, gpointer); -static gint lc_dialog_close_callback (GtkWidget *, gpointer); -static void lc_dialog_add_callback (GimpSet *, GimpImage *, gpointer); -static void lc_dialog_remove_callback (GimpSet *, GimpImage *, gpointer); -static void lc_dialog_change_image (GimpContext *, GimpImage *, - gpointer); -static void lc_dialog_help_func (gchar *); -static void lc_dialog_image_menu_preview_update_callback (GtkWidget *, - gpointer); -static void lc_dialog_fill_preview_with_thumb (GtkWidget *, GimpImage *, - gint, gint); +/* local function prototypes */ +static void lc_dialog_update (GimpImage *gimage); +static void lc_dialog_image_menu_callback (GtkWidget *widget, + gpointer data); +static void lc_dialog_auto_callback (GtkWidget *widget, + gpointer data); +static gint lc_dialog_close_callback (GtkWidget *widget, + gpointer data); +static void lc_dialog_add_callback (GimpSet *set, + GimpImage *gimage, + gpointer data); +static void lc_dialog_remove_callback (GimpSet *set, + GimpImage *gimage, + gpointer data); +static void lc_dialog_change_image (GimpContext *context, + GimpImage *gimage, + gpointer data); +static void lc_dialog_help_func (const gchar *help_data); + +static void lc_dialog_image_menu_preview_update_callback (GtkWidget *widget, + gpointer data); +static void lc_dialog_fill_preview_with_thumb (GtkWidget *widget, + GimpImage *gimage, + gint width, + gint height); /* FIXME: move these to a better place */ -static GtkWidget * lc_dialog_create_image_menu (GimpImage **, gint *, - GtkSignalFunc); -static void lc_dialog_create_image_menu_callback (gpointer, gpointer); +static GtkWidget * lc_dialog_create_image_menu (GimpImage **def, + gint *default_index, + GtkSignalFunc callback); +static void lc_dialog_create_image_menu_callback (gpointer image, + gpointer data); + /* the main dialog structure */ LCDialog * lc_dialog = NULL; + /*********************************/ /* Public L&C dialog functions */ /*********************************/ void -lc_dialog_create (GimpImage* gimage) +lc_dialog_create (GimpImage *gimage) { GtkWidget *util_box; GtkWidget *auto_button; GtkWidget *button; GtkWidget *label; GtkWidget *separator; - gint default_index; + gint default_index; if (lc_dialog) { @@ -240,8 +258,8 @@ lc_dialog_free (void) void lc_dialog_rebuild (gint new_preview_size) { - GimpImage* gimage; - gboolean flag; + GimpImage *gimage; + gboolean flag; gimage = NULL; flag = FALSE; @@ -341,8 +359,8 @@ lc_dialog_image_menu_preview_update_callback (GtkWidget *widget, void lc_dialog_update_image_list (void) { - GimpImage* default_gimage; - gint default_index; + GimpImage *default_gimage; + gint default_index; if (lc_dialog == NULL) return; @@ -382,7 +400,7 @@ lc_dialog_update_image_list (void) /**********************************/ static void -lc_dialog_update (GimpImage* gimage) +lc_dialog_update (GimpImage *gimage) { if (! lc_dialog || lc_dialog->gimage == gimage) return; @@ -429,13 +447,13 @@ lc_dialog_fill_preview_with_thumb (GtkWidget *widget, /* Get right aspect ratio */ if (dwidth > dheight) { - height = (gint)(((gdouble)width * (gdouble)dheight) / (gdouble)dwidth + 0.5); - width = (gint)(((gdouble)dwidth * (gdouble)height) / (gdouble)dheight + 0.5); + height = RINT (((gdouble)width * (gdouble)dheight) / (gdouble)dwidth); + width = RINT (((gdouble)dwidth * (gdouble)height) / (gdouble)dheight); } else { - width = (gint)(((gdouble)height * (gdouble)dwidth) / (gdouble)dheight + 0.5); - height = (gint)(((gdouble)dheight * (gdouble)width) / (gdouble)dwidth + 0.5); + width = RINT (((gdouble)height * (gdouble)dwidth) / (gdouble)dheight); + height = RINT (((gdouble)dheight * (gdouble)width) / (gdouble)dwidth); } buf = gimp_image_construct_composite_preview (gimage, width, height); @@ -459,16 +477,16 @@ lc_dialog_fill_preview_with_thumb (GtkWidget *widget, { if (bpp == 4) { - r = ((gdouble)src[x*4+0])/255.0; - g = ((gdouble)src[x*4+1])/255.0; - b = ((gdouble)src[x*4+2])/255.0; - a = ((gdouble)src[x*4+3])/255.0; + r = ((gdouble) src[x * 4 + 0]) / 255.0; + g = ((gdouble) src[x * 4 + 1]) / 255.0; + b = ((gdouble) src[x * 4 + 2]) / 255.0; + a = ((gdouble) src[x * 4 + 3]) / 255.0; } else { - r = ((gdouble)src[x*bpp+0])/255.0; + r = ((gdouble) src[x * bpp + 0]) / 255.0; g = b = r; - a = ((gdouble)src[x*bpp+1])/255.0; + a = ((gdouble) src[x * bpp + 1]) / 255.0; } if ((x / GIMP_CHECK_SIZE_SM) & 1) @@ -710,7 +728,7 @@ lc_dialog_change_image (GimpContext *context, } static void -lc_dialog_help_func (gchar *help_data) +lc_dialog_help_func (const gchar *help_data) { gchar *help_page; gint page_num; diff --git a/app/lc_dialog.h b/app/lc_dialog.h index 3b8676abfd..d7830c2e1a 100644 --- a/app/lc_dialog.h +++ b/app/lc_dialog.h @@ -15,15 +15,20 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #ifndef __LC_DIALOG_H__ #define __LC_DIALOG_H__ + #include "gimpimageF.h" + void lc_dialog_create (GimpImage *gimage); void lc_dialog_free (void); -void lc_dialog_rebuild (int); /* implies free & create */ +/* implies free & create + */ +void lc_dialog_rebuild (gint new_preview_size); void lc_dialog_flush (void); diff --git a/app/menus.h b/app/menus.h index 21ec9aa85b..3cac7aceb6 100644 --- a/app/menus.h +++ b/app/menus.h @@ -26,8 +26,8 @@ struct _GimpItemFactoryEntry { GtkItemFactoryEntry entry; - gchar *help_page; - gchar *description; + const gchar *help_page; + gchar *description; }; void menus_get_toolbox_menubar (GtkWidget **menubar, diff --git a/app/menus/menus.h b/app/menus/menus.h index 21ec9aa85b..3cac7aceb6 100644 --- a/app/menus/menus.h +++ b/app/menus/menus.h @@ -26,8 +26,8 @@ struct _GimpItemFactoryEntry { GtkItemFactoryEntry entry; - gchar *help_page; - gchar *description; + const gchar *help_page; + gchar *description; }; void menus_get_toolbox_menubar (GtkWidget **menubar, diff --git a/app/preferences_dialog.c b/app/preferences_dialog.c index 60826f41d0..db265b5e7d 100644 --- a/app/preferences_dialog.c +++ b/app/preferences_dialog.c @@ -1,5 +1,5 @@ /* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * Copyright (C) 1995-1997 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 @@ -54,23 +54,39 @@ typedef enum /* preferences local functions */ static PrefsState prefs_check_settings (void); -static void prefs_ok_callback (GtkWidget *, GtkWidget *); -static void prefs_save_callback (GtkWidget *, GtkWidget *); -static void prefs_cancel_callback (GtkWidget *, GtkWidget *); +static void prefs_ok_callback (GtkWidget *widget, + GtkWidget *dlg); +static void prefs_save_callback (GtkWidget *widget, + GtkWidget *dlg); +static void prefs_cancel_callback (GtkWidget *widget, + GtkWidget *dlg); -static void prefs_toggle_callback (GtkWidget *widget, gpointer data); -static void prefs_preview_size_callback (GtkWidget *widget, gpointer data); -static void prefs_nav_preview_size_callback (GtkWidget *widget, gpointer data); -static void prefs_string_callback (GtkWidget *widget, gpointer data); -static void prefs_text_callback (GtkWidget *widget, gpointer data); -static void prefs_filename_callback (GtkWidget *widget, gpointer data); -static void prefs_path_callback (GtkWidget *widget, gpointer data); -static void prefs_clear_session_info_callback (GtkWidget *widget, gpointer data); -static void prefs_default_size_callback (GtkWidget *widget, gpointer data); -static void prefs_default_resolution_callback (GtkWidget *widget, gpointer data); -static void prefs_res_source_callback (GtkWidget *widget, gpointer data); -static void prefs_monitor_resolution_callback (GtkWidget *widget, gpointer data); -static void prefs_resolution_calibrate_callback (GtkWidget *widget, gpointer data); +static void prefs_toggle_callback (GtkWidget *widget, + gpointer data); +static void prefs_preview_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_nav_preview_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_string_callback (GtkWidget *widget, + gpointer data); +static void prefs_text_callback (GtkWidget *widget, + gpointer data); +static void prefs_filename_callback (GtkWidget *widget, + gpointer data); +static void prefs_path_callback (GtkWidget *widget, + gpointer data); +static void prefs_clear_session_info_callback (GtkWidget *widget, + gpointer data); +static void prefs_default_size_callback (GtkWidget *widget, + gpointer data); +static void prefs_default_resolution_callback (GtkWidget *widget, + gpointer data); +static void prefs_res_source_callback (GtkWidget *widget, + gpointer data); +static void prefs_monitor_resolution_callback (GtkWidget *widget, + gpointer data); +static void prefs_resolution_calibrate_callback (GtkWidget *widget, + gpointer data); static void prefs_restart_notification (void); @@ -1295,7 +1311,7 @@ prefs_frame_new (gchar *label, } static void -prefs_help_func (gchar *help_data) +prefs_help_func (const gchar *help_data) { GtkWidget *notebook; GtkWidget *event_box; diff --git a/app/tools.c b/app/tools.c index acb2374843..b318ece52c 100644 --- a/app/tools.c +++ b/app/tools.c @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "config.h" #include "appenv.h" @@ -1487,7 +1488,7 @@ tools_new_tool (ToolType tool_type) } void -tools_help_func (gchar *help_data) +tools_help_func (const gchar *help_data) { gimp_standard_help_func (tool_info[(gint) active_tool->type].private_tip); } diff --git a/app/tools.h b/app/tools.h index 3bb2542606..3dae66ecef 100644 --- a/app/tools.h +++ b/app/tools.h @@ -94,19 +94,19 @@ struct _ToolInfo { ToolOptions *tool_options; - gchar *tool_name; + gchar *tool_name; - gchar *menu_path; - gchar *menu_accel; + gchar *menu_path; + gchar *menu_accel; - gchar **icon_data; - GdkPixmap *icon_pixmap; - GdkBitmap *icon_mask; + gchar **icon_data; + GdkPixmap *icon_pixmap; + GdkBitmap *icon_mask; - gchar *tool_desc; - gchar *private_tip; + gchar *tool_desc; + const gchar *private_tip; - ToolType tool_id; + ToolType tool_id; ToolInfoNewFunc new_func; ToolInfoFreeFunc free_func; @@ -135,7 +135,7 @@ void tools_initialize (ToolType tool_type, void active_tool_control (ToolAction action, void *gdisp_ptr); -void tools_help_func (gchar *help_data); +void tools_help_func (const gchar *help_data); void tools_register (ToolType tool_type, ToolOptions *tool_options); diff --git a/app/tools/tools.c b/app/tools/tools.c index acb2374843..b318ece52c 100644 --- a/app/tools/tools.c +++ b/app/tools/tools.c @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "config.h" #include "appenv.h" @@ -1487,7 +1488,7 @@ tools_new_tool (ToolType tool_type) } void -tools_help_func (gchar *help_data) +tools_help_func (const gchar *help_data) { gimp_standard_help_func (tool_info[(gint) active_tool->type].private_tip); } diff --git a/app/tools/tools.h b/app/tools/tools.h index 3bb2542606..3dae66ecef 100644 --- a/app/tools/tools.h +++ b/app/tools/tools.h @@ -94,19 +94,19 @@ struct _ToolInfo { ToolOptions *tool_options; - gchar *tool_name; + gchar *tool_name; - gchar *menu_path; - gchar *menu_accel; + gchar *menu_path; + gchar *menu_accel; - gchar **icon_data; - GdkPixmap *icon_pixmap; - GdkBitmap *icon_mask; + gchar **icon_data; + GdkPixmap *icon_pixmap; + GdkBitmap *icon_mask; - gchar *tool_desc; - gchar *private_tip; + gchar *tool_desc; + const gchar *private_tip; - ToolType tool_id; + ToolType tool_id; ToolInfoNewFunc new_func; ToolInfoFreeFunc free_func; @@ -135,7 +135,7 @@ void tools_initialize (ToolType tool_type, void active_tool_control (ToolAction action, void *gdisp_ptr); -void tools_help_func (gchar *help_data); +void tools_help_func (const gchar *help_data); void tools_register (ToolType tool_type, ToolOptions *tool_options); diff --git a/app/widgets/gimpcolordialog.c b/app/widgets/gimpcolordialog.c index 7b6e68fa1a..131e324cf0 100644 --- a/app/widgets/gimpcolordialog.c +++ b/app/widgets/gimpcolordialog.c @@ -35,19 +35,6 @@ #include "libgimp/gimpintl.h" -static void color_notebook_ok_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_cancel_callback (GtkWidget *widget, - gpointer data); -static void color_notebook_update_callback (gpointer, - gint, - gint, - gint); -static void color_notebook_page_switch (GtkWidget *, - GtkNotebookPage *, - guint); -static void color_notebook_help_func (gchar *help_data); - /* information we keep on each registered colour selector */ typedef struct _ColorSelectorInfo ColorSelectorInfo; @@ -72,7 +59,21 @@ struct _ColorSelectorInstance ColorSelectorInstance *next; }; -static void selector_death (ColorSelectorInfo *info); + +static void color_notebook_ok_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_cancel_callback (GtkWidget *widget, + gpointer data); +static void color_notebook_update_callback (gpointer data, + gint red, + gint green, + gint blue); +static void color_notebook_page_switch (GtkWidget *widget, + GtkNotebookPage *page, + guint page_num); +static void color_notebook_help_func (const gchar *help_data); + +static void color_notebook_selector_death (ColorSelectorInfo *info); /* master list of all registered colour selectors */ @@ -116,7 +117,7 @@ color_notebook_new (gint red, cnp->shell = gimp_dialog_new (_("Color Selection"), "color_selection", - color_notebook_help_func, (gchar *) cnp, + color_notebook_help_func, (const gchar *) cnp, GTK_WIN_POS_NONE, FALSE, FALSE, FALSE, @@ -235,7 +236,7 @@ color_notebook_free (ColorNotebook *cnp) csel->info->refs--; if (csel->info->refs == 0 && !csel->info->active) - selector_death (csel->info); + color_notebook_selector_death (csel->info); g_free (csel); csel = next; @@ -352,7 +353,7 @@ color_notebook_page_switch (GtkWidget *widget, } static void -color_notebook_help_func (gchar *data) +color_notebook_help_func (const gchar *data) { ColorNotebook *cnp; gchar *help_path; @@ -418,7 +419,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, info->death_callback = callback; info->death_data = data; if (info->refs == 0) - selector_death (info); + color_notebook_selector_death (info); return TRUE; } info = info->next; @@ -429,7 +430,7 @@ gimp_color_selector_unregister (GimpColorSelectorID id, } static void -selector_death (ColorSelectorInfo *info) +color_notebook_selector_death (ColorSelectorInfo *info) { ColorSelectorInfo *here, *prev; diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c index fe501bf1ac..02f6b51b9c 100644 --- a/app/widgets/gimphelp.c +++ b/app/widgets/gimphelp.c @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimphelp.c - * Copyright (C) 1999 Michael Natterer + * Copyright (C) 1999-2000 Michael Natterer * * 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 @@ -53,13 +53,13 @@ struct _GimpIdleHelp }; /* local function prototypes */ -static gint gimp_idle_help (gpointer data); -static gboolean gimp_help_internal (gchar *help_path, - gchar *current_locale, - gchar *help_data); -static void gimp_help_netscape (gchar *help_path, - gchar *current_locale, - gchar *help_data); +static gint gimp_idle_help (gpointer data); +static gboolean gimp_help_internal (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data); +static void gimp_help_netscape (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data); /**********************/ /* public functions */ @@ -67,15 +67,15 @@ static void gimp_help_netscape (gchar *help_path, /* The standard help function */ void -gimp_standard_help_func (gchar *help_data) +gimp_standard_help_func (const gchar *help_data) { gimp_help (NULL, help_data); } /* the main help function */ void -gimp_help (gchar *help_path, - gchar *help_data) +gimp_help (const gchar *help_path, + const gchar *help_data) { if (use_help) { @@ -169,9 +169,9 @@ gimp_help_internal_not_found_callback (GtkWidget *widget, } static gboolean -gimp_help_internal (gchar *help_path, - gchar *current_locale, - gchar *help_data) +gimp_help_internal (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data) { ProcRecord *proc_rec; @@ -207,11 +207,11 @@ gimp_help_internal (gchar *help_path, args[0].arg_type = PDB_INT32; args[0].value.pdb_int = RUN_INTERACTIVE; args[1].arg_type = PDB_STRING; - args[1].value.pdb_pointer = help_path; + args[1].value.pdb_pointer = (gpointer) help_path; args[2].arg_type = PDB_STRING; - args[2].value.pdb_pointer = current_locale; + args[2].value.pdb_pointer = (gpointer) current_locale; args[3].arg_type = PDB_STRING; - args[3].value.pdb_pointer = help_data; + args[3].value.pdb_pointer = (gpointer) help_data; plug_in_run (proc_rec, args, 4, FALSE, TRUE, 0); @@ -237,9 +237,9 @@ gimp_help_internal (gchar *help_path, } static void -gimp_help_netscape (gchar *help_path, - gchar *current_locale, - gchar *help_data) +gimp_help_netscape (const gchar *help_path, + const gchar *current_locale, + const gchar *help_data) { Argument *return_vals; gint nreturn_vals; diff --git a/app/widgets/gimphelp.h b/app/widgets/gimphelp.h index ac87fa082b..ad36fc7456 100644 --- a/app/widgets/gimphelp.h +++ b/app/widgets/gimphelp.h @@ -2,7 +2,7 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * gimphelp.h - * Copyright (C) 1999 Michael Natterer + * Copyright (C) 1999-2000 Michael Natterer * * 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 @@ -18,21 +18,26 @@ * 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_HELP_H__ #define __GIMP_HELP_H__ + #include #include "libgimp/gimphelpui.h" + enum { HELP_BROWSER_GIMP, HELP_BROWSER_NETSCAPE }; + /* the main help function */ -void gimp_help (gchar *help_path, - gchar *help_data); +void gimp_help (const gchar *help_path, + const gchar *help_data); + #endif /* __GIMP_HELP_H__ */ diff --git a/app/widgets/gimpitemfactory.h b/app/widgets/gimpitemfactory.h index 21ec9aa85b..3cac7aceb6 100644 --- a/app/widgets/gimpitemfactory.h +++ b/app/widgets/gimpitemfactory.h @@ -26,8 +26,8 @@ struct _GimpItemFactoryEntry { GtkItemFactoryEntry entry; - gchar *help_page; - gchar *description; + const gchar *help_page; + gchar *description; }; void menus_get_toolbox_menubar (GtkWidget **menubar, diff --git a/help/C/filters/Makefile.am b/help/C/filters/Makefile.am index 9203d20cc5..429d2455ae 100644 --- a/help/C/filters/Makefile.am +++ b/help/C/filters/Makefile.am @@ -56,7 +56,6 @@ helpdata_DATA = \ gauss_rle.html \ gbr.html \ gdyntext.html \ - gee.html \ gfig.html \ gflare.html \ gfli.html \ diff --git a/help/C/filters/gee.html b/help/C/filters/gee.html deleted file mode 100644 index accf140464..0000000000 --- a/help/C/filters/gee.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - Help Page for gee - - - - - - - - - - - -
- gee help page -
-

- Index

- (/filters/gee.html)

- Sorry but the help file for gee is not yet done. -

- /Karin & Olof -

-

- - - diff --git a/libgimp/gimpcolorbutton.c b/libgimp/gimpcolorbutton.c index 1aeed7db9a..02363f07a6 100644 --- a/libgimp/gimpcolorbutton.c +++ b/libgimp/gimpcolorbutton.c @@ -63,8 +63,10 @@ static void gimp_color_button_drag_handle (GtkWidget *widget, guint info, guint time, gpointer data); + static const GtkTargetEntry targets[] = { { "application/x-color", 0 } }; + /* end of DND */ struct _GimpColorButton @@ -89,48 +91,50 @@ struct _GimpColorButton }; -static void gimp_color_button_destroy (GtkObject *object); -static void gimp_color_button_clicked (GtkButton *button); +static void gimp_color_button_destroy (GtkObject *object); +static void gimp_color_button_clicked (GtkButton *button); static void gimp_color_button_paint (GimpColorButton *gcb); -static void gimp_color_button_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gimp_color_button_state_changed (GtkWidget *widget, + GtkStateType previous_state); -static void gimp_color_button_dialog_ok (GtkWidget *widget, - gpointer data); -static void gimp_color_button_dialog_cancel (GtkWidget *widget, - gpointer data); +static void gimp_color_button_dialog_ok (GtkWidget *widget, + gpointer data); +static void gimp_color_button_dialog_cancel (GtkWidget *widget, + gpointer data); -static void gimp_color_button_use_fg (gpointer callback_data, - guint callback_action, - GtkWidget *widget); -static void gimp_color_button_use_bg (gpointer callback_data, - guint callback_action, - GtkWidget *widget); +static void gimp_color_button_use_fg (gpointer callback_data, + guint callback_action, + GtkWidget *widget); +static void gimp_color_button_use_bg (gpointer callback_data, + guint callback_action, + GtkWidget *widget); -static gint gimp_color_button_menu_popup (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static gchar* gimp_color_button_menu_translate (const gchar *path, - gpointer func_data); +static gint gimp_color_button_menu_popup (GtkWidget *widget, + GdkEvent *event, + gpointer data); +static gchar* gimp_color_button_menu_translate (const gchar *path, + gpointer func_data); -static GtkItemFactoryEntry menu_items[] = { +static GtkItemFactoryEntry menu_items[] = +{ { N_("/Use Foreground Color"), NULL, gimp_color_button_use_fg, 2, NULL }, { N_("/Use Background Color"), NULL, gimp_color_button_use_bg, 2, NULL } }; static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); -enum { +enum +{ COLOR_CHANGED, LAST_SIGNAL }; static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 }; - static GtkWidgetClass *parent_class = NULL; + static void gimp_color_button_destroy (GtkObject *object) { @@ -148,7 +152,7 @@ gimp_color_button_destroy (GtkObject *object) g_free (gcb->odd); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } @@ -156,12 +160,12 @@ static void gimp_color_button_class_init (GimpColorButtonClass *class) { GtkObjectClass *object_class; - GtkButtonClass *button_class; GtkWidgetClass *widget_class; + GtkButtonClass *button_class; object_class = (GtkObjectClass*) class; - button_class = (GtkButtonClass*) class; widget_class = (GtkWidgetClass*) class; + button_class = (GtkButtonClass*) class; parent_class = gtk_type_class (gtk_widget_get_type ()); @@ -172,13 +176,15 @@ gimp_color_button_class_init (GimpColorButtonClass *class) GTK_SIGNAL_OFFSET (GimpColorButtonClass, color_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_color_button_signals, LAST_SIGNAL); + class->color_changed = NULL; object_class->destroy = gimp_color_button_destroy; - button_class->clicked = gimp_color_button_clicked; widget_class->state_changed = gimp_color_button_state_changed; + button_class->clicked = gimp_color_button_clicked; } @@ -225,12 +231,12 @@ gimp_color_button_get_type (void) } static GtkWidget * -_gimp_color_button_new (gboolean double_color, - gchar *title, - gint width, - gint height, - gpointer color, - gint bpp) +_gimp_color_button_new (gboolean double_color, + const gchar *title, + gint width, + gint height, + gpointer color, + gint bpp) { GimpColorButton *gcb; gint i; @@ -297,25 +303,21 @@ _gimp_color_button_new (gboolean double_color, targets, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_begin", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_begin", GTK_SIGNAL_FUNC (gimp_color_button_drag_begin), gcb); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_end", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_end", GTK_SIGNAL_FUNC (gimp_color_button_drag_end), gcb); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_data_get", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_get", GTK_SIGNAL_FUNC (gimp_color_button_drag_handle), gcb); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_data_received", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_received", GTK_SIGNAL_FUNC (gimp_color_button_drop_handle), gcb); /* end of DND */ - return (GTK_WIDGET (gcb)); + return GTK_WIDGET (gcb); } /** @@ -335,13 +337,13 @@ _gimp_color_button_new (gboolean double_color, * signal is emitted. * * Returns: Pointer to the new #GimpColorButton widget. - */ + **/ GtkWidget * -gimp_color_button_new (gchar *title, - gint width, - gint height, - guchar *color, - gint bpp) +gimp_color_button_new (const gchar *title, + gint width, + gint height, + guchar *color, + gint bpp) { return _gimp_color_button_new (FALSE, title, width, height, (gpointer) color, bpp); @@ -364,13 +366,13 @@ gimp_color_button_new (gchar *title, * signal is emitted. * * Returns: Pointer to the new GimpColorButton widget. - */ + **/ GtkWidget * -gimp_color_button_double_new (gchar *title, - gint width, - gint height, - gdouble *color, - gint bpp) +gimp_color_button_double_new (const gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp) { return _gimp_color_button_new (TRUE, title, width, height, (gpointer) color, bpp); @@ -383,12 +385,13 @@ gimp_color_button_double_new (gchar *title, * Should be used after the color controlled by a #GimpColorButton * was changed. The color is then reread and the change is propagated * to the preview and the GtkColorSelectionDialog if one is open. - */ + **/ void gimp_color_button_update (GimpColorButton *gcb) { gint i; + g_return_if_fail (gcb != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); if (gcb->double_color) @@ -413,13 +416,14 @@ static void gimp_color_button_state_changed (GtkWidget *widget, GtkStateType previous_state) { + g_return_if_fail (widget != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget)); if (!GTK_WIDGET_IS_SENSITIVE (widget) && GIMP_COLOR_BUTTON (widget)->dialog) gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog); if (GTK_WIDGET_CLASS (parent_class)->state_changed) - (* GTK_WIDGET_CLASS (parent_class)->state_changed) (widget, previous_state); + GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state); } static gint @@ -432,7 +436,9 @@ gimp_color_button_menu_popup (GtkWidget *widget, gint x; gint y; + g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (data), FALSE); + gcb = GIMP_COLOR_BUTTON (data); if (event->type != GDK_BUTTON_PRESS) @@ -457,7 +463,9 @@ gimp_color_button_clicked (GtkButton *button) GimpColorButton *gcb; GtkColorSelection *colorsel; + g_return_if_fail (button != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (button)); + gcb = GIMP_COLOR_BUTTON (button); if (!gcb->dialog) @@ -479,6 +487,7 @@ gimp_color_button_clicked (GtkButton *button) (GtkSignalFunc) gimp_color_button_dialog_cancel, gcb); gtk_window_set_position (GTK_WINDOW (gcb->dialog), GTK_WIN_POS_MOUSE); } + gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor); gtk_widget_show (gcb->dialog); @@ -491,6 +500,7 @@ gimp_color_button_paint (GimpColorButton *gcb) gdouble c0, c1; guchar *p0, *p1; + g_return_if_fail (gcb != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); p0 = gcb->even; @@ -548,8 +558,10 @@ gimp_color_button_dialog_ok (GtkWidget *widget, GimpColorButton *gcb; gboolean color_changed = FALSE; gint i; - + + g_return_if_fail (data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (data)); + gcb = GIMP_COLOR_BUTTON (data); gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor); @@ -592,7 +604,9 @@ gimp_color_button_dialog_cancel (GtkWidget *widget, { GimpColorButton *gcb; + g_return_if_fail (data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (data)); + gcb = GIMP_COLOR_BUTTON (data); gtk_widget_hide (gcb->dialog); @@ -608,7 +622,9 @@ gimp_color_button_use_fg (gpointer callback_data, guchar fg_color[3]; gint i; + g_return_if_fail (callback_data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); + gcb = GIMP_COLOR_BUTTON (callback_data); gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]); @@ -640,7 +656,9 @@ gimp_color_button_use_bg (gpointer callback_data, guchar bg_color[3]; gint i; + g_return_if_fail (callback_data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); + gcb = GIMP_COLOR_BUTTON (callback_data); gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]); @@ -662,7 +680,7 @@ gimp_color_button_use_bg (gpointer callback_data, gimp_color_button_signals[COLOR_CHANGED]); } -static gchar * +static gchar * gimp_color_button_menu_translate (const gchar *path, gpointer func_data) { diff --git a/libgimp/gimpcolorbutton.h b/libgimp/gimpcolorbutton.h index 124cbf954b..2289a87e57 100644 --- a/libgimp/gimpcolorbutton.h +++ b/libgimp/gimpcolorbutton.h @@ -52,16 +52,16 @@ struct _GimpColorButtonClass GtkType gimp_color_button_get_type (void); -GtkWidget * gimp_color_button_new (gchar *title, - gint width, - gint height, - guchar *color, - gint bpp); -GtkWidget * gimp_color_button_double_new (gchar *title, - gint width, - gint height, - gdouble *color, - gint bpp); +GtkWidget * gimp_color_button_new (const gchar *title, + gint width, + gint height, + guchar *color, + gint bpp); +GtkWidget * gimp_color_button_double_new (const gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp); void gimp_color_button_update (GimpColorButton *gcb); diff --git a/libgimp/gimpdialog.c b/libgimp/gimpdialog.c index c76d897680..baf8676309 100644 --- a/libgimp/gimpdialog.c +++ b/libgimp/gimpdialog.c @@ -99,14 +99,14 @@ GtkWidget * gimp_dialog_new (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, gint auto_shrink, /* specify action area buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, @@ -167,7 +167,7 @@ GtkWidget * gimp_dialog_newv (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, @@ -237,7 +237,7 @@ void gimp_dialog_create_action_area (GtkDialog *dialog, /* specify action area buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, @@ -272,7 +272,7 @@ gimp_dialog_create_action_areav (GtkDialog *dialog, GtkWidget *button; /* action area variables */ - gchar *label; + const gchar *label; GtkSignalFunc callback; gpointer data; GtkObject *slot_object; @@ -286,7 +286,7 @@ gimp_dialog_create_action_areav (GtkDialog *dialog, g_return_if_fail (GTK_IS_DIALOG (dialog)); /* prepare the action_area */ - label = va_arg (args, gchar *); + label = va_arg (args, const gchar *); if (label) { diff --git a/libgimp/gimpdialog.h b/libgimp/gimpdialog.h index 003d81601b..cb291aad7e 100644 --- a/libgimp/gimpdialog.h +++ b/libgimp/gimpdialog.h @@ -35,7 +35,7 @@ extern "C" { GtkWidget * gimp_dialog_new (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, @@ -43,7 +43,7 @@ GtkWidget * gimp_dialog_new (const gchar *title, /* specify action area buttons * as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, @@ -57,7 +57,7 @@ GtkWidget * gimp_dialog_new (const gchar *title, GtkWidget * gimp_dialog_newv (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, @@ -70,7 +70,7 @@ void gimp_dialog_create_action_area (GtkDialog *dialog, /* specify action area buttons * as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c index 4a92373901..1d1a304224 100644 --- a/libgimp/gimpexport.c +++ b/libgimp/gimpexport.c @@ -30,7 +30,9 @@ #include "libgimp-intl.h" -typedef void (* ExportFunc) (gint32 imageID, gint32 *drawable_ID); +typedef void (* ExportFunc) (gint32 imageID, + gint32 *drawable_ID); + /* the export action structure */ typedef struct @@ -307,8 +309,8 @@ export_toggle_callback (GtkWidget *widget, } static gint -export_dialog (GSList *actions, - gchar *format) +export_dialog (GSList *actions, + const gchar *format) { GtkWidget *frame; GtkWidget *vbox; @@ -451,11 +453,11 @@ export_dialog (GSList *actions, * save_plugin should quit itself with status #STATUS_CANCEL. * * Returns: An enum of #GimpExportReturnType describing the user_action. - */ + **/ GimpExportReturnType gimp_export_image (gint32 *image_ID, gint32 *drawable_ID, - gchar *format_name, + const gchar *format_name, GimpExportCapabilities capabilities) { GSList *actions = NULL; diff --git a/libgimp/gimpexport.h b/libgimp/gimpexport.h index 5eb968f7e7..9158466bea 100644 --- a/libgimp/gimpexport.h +++ b/libgimp/gimpexport.h @@ -50,7 +50,7 @@ typedef enum GimpExportReturnType gimp_export_image (gint32 *image_ID, gint32 *drawable_ID, - gchar *format_name, + const gchar *format_name, GimpExportCapabilities capabilities); diff --git a/libgimp/gimpfileselection.c b/libgimp/gimpfileselection.c index cd1ded4482..ffcb26bf6c 100644 --- a/libgimp/gimpfileselection.c +++ b/libgimp/gimpfileselection.c @@ -99,7 +99,7 @@ gimp_file_selection_destroy (GtkObject *object) gdk_bitmap_unref (gfs->no_mask); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } static void @@ -127,7 +127,6 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class) class->filename_changed = NULL; object_class->destroy = gimp_file_selection_destroy; - widget_class->realize = gimp_file_selection_realize; } @@ -201,13 +200,12 @@ gimp_file_selection_get_type (void) * Creates a new #GimpFileSelection widget. * * Returns: A pointer to the new #GimpFileSelection widget. - * - */ + **/ GtkWidget * -gimp_file_selection_new (gchar *title, - gchar *filename, - gboolean dir_only, - gboolean check_valid) +gimp_file_selection_new (const gchar *title, + const gchar *filename, + gboolean dir_only, + gboolean check_valid) { GimpFileSelection *gfs; @@ -229,8 +227,7 @@ gimp_file_selection_new (gchar *title, * Note that you have to g_free() the returned string. * * Returns: The file or directory the user has entered. - * - */ + **/ gchar * gimp_file_selection_get_filename (GimpFileSelection *gfs) { @@ -252,7 +249,7 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs) */ void gimp_file_selection_set_filename (GimpFileSelection *gfs, - gchar *filename) + const gchar *filename) { g_return_if_fail (gfs != NULL); g_return_if_fail (GIMP_IS_FILE_SELECTION (gfs)); @@ -441,6 +438,7 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs) if (! gfs->check_valid) return; + if (gfs->file_exists == NULL) return; diff --git a/libgimp/gimpfileselection.h b/libgimp/gimpfileselection.h index d09b01f0c8..432b75d2f3 100644 --- a/libgimp/gimpfileselection.h +++ b/libgimp/gimpfileselection.h @@ -69,15 +69,15 @@ struct _GimpFileSelectionClass GtkType gimp_file_selection_get_type (void); -GtkWidget* gimp_file_selection_new (gchar *title, - gchar *filename, +GtkWidget* gimp_file_selection_new (const gchar *title, + const gchar *filename, gboolean dir_only, gboolean check_valid); gchar* gimp_file_selection_get_filename (GimpFileSelection *gfs); void gimp_file_selection_set_filename (GimpFileSelection *gfs, - gchar *filename); + const gchar *filename); #ifdef __cplusplus diff --git a/libgimp/gimphelpui.c b/libgimp/gimphelpui.c index 17913137d2..5864cfa832 100644 --- a/libgimp/gimphelpui.c +++ b/libgimp/gimphelpui.c @@ -56,8 +56,7 @@ static GtkWidget * tips_query = NULL; * * Currently it only creates a #GtkTooltips object with gtk_tooltips_new() * which will be used by gimp_help_set_help_data(). - * - */ + **/ void gimp_help_init (void) { @@ -69,8 +68,7 @@ gimp_help_init (void) * * This function frees the memory used by the #GtkTooltips created by * gimp_help_init(). - * - */ + **/ void gimp_help_free (void) { @@ -82,8 +80,7 @@ gimp_help_free (void) * gimp_help_enable_tooltips: * * This function calls gtk_tooltips_enable(). - * - */ + **/ void gimp_help_enable_tooltips (void) { @@ -94,8 +91,7 @@ gimp_help_enable_tooltips (void) * gimp_help_disable_tooltips: * * This function calls gtk_tooltips_disable(). - * - */ + **/ void gimp_help_disable_tooltips (void) { @@ -116,12 +112,11 @@ gimp_help_disable_tooltips (void) * For convenience, gimp_help_connect_help_accel() calls * gimp_dialog_set_icon() if the passed widget is a #GtkWindow, so you * don't have to worry about this. - * - */ + **/ void gimp_help_connect_help_accel (GtkWidget *widget, GimpHelpFunc help_func, - gchar *help_data) + const gchar *help_data) { GtkAccelGroup *accel_group; @@ -134,7 +129,8 @@ gimp_help_connect_help_accel (GtkWidget *widget, if (GTK_IS_WINDOW (widget)) gimp_dialog_set_icon (GTK_WINDOW (widget)); - /* set up the help signals and tips query widget */ + /* set up the help signals and tips query widget + */ if (!tips_query) { tips_query = gtk_tips_query_new (); @@ -229,20 +225,25 @@ gimp_help_connect_help_accel (GtkWidget *widget, * help system will automatically ascend the widget hierarchy until it * finds another widget with @help_data attached and concatenates both * to a complete help path. - * - */ + **/ void gimp_help_set_help_data (GtkWidget *widget, const gchar *tooltip, - gchar *help_data) + const gchar *help_data) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); if (tooltip) - gtk_tooltips_set_tip (tool_tips, widget, tooltip, help_data); + { + gtk_tooltips_set_tip (tool_tips, widget, tooltip, + (gpointer) help_data); + } else if (help_data) - gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", help_data); + { + gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", + (gpointer) help_data); + } } /** @@ -258,8 +259,7 @@ gimp_help_set_help_data (GtkWidget *widget, * be displayed. Otherwise the help system will ascend the widget hierarchy * until it finds an attached @help_data string (which should be the * case at least for every window/dialog). - * - */ + **/ void gimp_context_help (void) { @@ -275,12 +275,12 @@ static void gimp_help_callback (GtkWidget *widget, gpointer data) { - GimpHelpFunc help_function; - gchar *help_data; + GimpHelpFunc help_function; + const gchar *help_data; help_function = (GimpHelpFunc) data; - help_data = (gchar *) gtk_object_get_data (GTK_OBJECT (widget), - "gimp_help_data"); + help_data = (const gchar *) gtk_object_get_data (GTK_OBJECT (widget), + "gimp_help_data"); if (help_function) (* help_function) (help_data); diff --git a/libgimp/gimphelpui.h b/libgimp/gimphelpui.h index 2f4e295d0b..678b84eec8 100644 --- a/libgimp/gimphelpui.h +++ b/libgimp/gimphelpui.h @@ -27,10 +27,12 @@ extern "C" { #endif /* __cplusplus */ + /* For information look into the C source or the html documentation */ -typedef void (* GimpHelpFunc) (gchar *help_data); +typedef void (* GimpHelpFunc) (const gchar *help_data); + void gimp_help_init (void); void gimp_help_free (void); @@ -41,17 +43,17 @@ void gimp_help_disable_tooltips (void); /* the standard gimp help function * (has different implementations in the main app and in libgimp) */ -void gimp_standard_help_func (gchar *help_data); +void gimp_standard_help_func (const gchar *help_data); /* connect the "F1" accelerator of a window */ void gimp_help_connect_help_accel (GtkWidget *widget, GimpHelpFunc help_func, - gchar *help_data); + const gchar *help_data); /* set help data for non-window widgets */ void gimp_help_set_help_data (GtkWidget *widget, const gchar *tooltip, - gchar *help_data); + const gchar *help_data); /* activate the context help inspector */ void gimp_context_help (void); diff --git a/libgimp/gimppatheditor.c b/libgimp/gimppatheditor.c index 1c95808c4a..b0fec3ce8f 100644 --- a/libgimp/gimppatheditor.c +++ b/libgimp/gimppatheditor.c @@ -89,8 +89,8 @@ gimp_path_editor_init (GimpPathEditor *gpe) GtkWidget *button; GtkWidget *scrolled_window; - gpe->file_selection = NULL; - gpe->selected_item = NULL; + gpe->file_selection = NULL; + gpe->selected_item = NULL; gpe->number_of_items = 0; gpe->upper_hbox = gtk_hbox_new (FALSE, 2); @@ -183,16 +183,16 @@ gimp_path_editor_get_type (void) * #G_SEARCHPATH_SEPARATOR character. * * Returns: A pointer to the new #GimpPathEditor widget. - * - */ + **/ GtkWidget * -gimp_path_editor_new (gchar *filesel_title, - gchar *path) +gimp_path_editor_new (const gchar *filesel_title, + const gchar *path) { GimpPathEditor *gpe; GtkWidget *list_item; GList *directory_list; gchar *directory; + gchar *mypath; g_return_val_if_fail ((filesel_title != NULL), NULL); g_return_val_if_fail ((path != NULL), NULL); @@ -209,7 +209,7 @@ gimp_path_editor_new (gchar *filesel_title, gtk_widget_show (gpe->file_selection); directory_list = NULL; - directory = path = g_strdup (path); + directory = mypath = g_strdup (path); /* split up the path */ while (strlen (directory)) @@ -243,7 +243,7 @@ gimp_path_editor_new (gchar *filesel_title, break; } - g_free (path); + g_free (mypath); if (directory_list) gtk_list_append_items (GTK_LIST (gpe->dir_list), directory_list); @@ -261,8 +261,7 @@ gimp_path_editor_new (gchar *filesel_title, * Note that you have to g_free() the returned string. * * Returns: The search path the user has selected in the path editor. - * - */ + **/ gchar * gimp_path_editor_get_path (GimpPathEditor *gpe) { diff --git a/libgimp/gimppatheditor.h b/libgimp/gimppatheditor.h index dcdedb6463..a1c50030e2 100644 --- a/libgimp/gimppatheditor.h +++ b/libgimp/gimppatheditor.h @@ -69,8 +69,8 @@ struct _GimpPathEditorClass GtkType gimp_path_editor_get_type (void); -GtkWidget * gimp_path_editor_new (gchar *filesel_title, - gchar *path); +GtkWidget * gimp_path_editor_new (const gchar *filesel_title, + const gchar *path); gchar * gimp_path_editor_get_path (GimpPathEditor *gpe); diff --git a/libgimp/gimppixmap.c b/libgimp/gimppixmap.c index c35259593f..a08b6cbe81 100644 --- a/libgimp/gimppixmap.c +++ b/libgimp/gimppixmap.c @@ -31,8 +31,10 @@ static void gimp_pixmap_destroy (GtkObject *object); static void gimp_pixmap_realize (GtkWidget *widget); static void gimp_pixmap_create_from_xpm_d (GimpPixmap *pixmap); + static GtkPixmapClass *parent_class = NULL; + static void gimp_pixmap_destroy (GtkObject *object) { @@ -41,7 +43,7 @@ gimp_pixmap_destroy (GtkObject *object) g_return_if_fail (pixmap = GIMP_PIXMAP (object)); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } static void @@ -56,7 +58,6 @@ gimp_pixmap_class_init (GimpPixmapClass *class) parent_class = gtk_type_class (gtk_pixmap_get_type ()); object_class->destroy = gimp_pixmap_destroy; - widget_class->realize = gimp_pixmap_realize; } @@ -98,8 +99,7 @@ gimp_pixmap_get_type (void) * Creates a new #GimpPixmap widget. * * Returns: A pointer to the new #GimpPixmap widget. - * - */ + **/ GtkWidget * gimp_pixmap_new (gchar **xpm_data) { @@ -119,8 +119,7 @@ gimp_pixmap_new (gchar **xpm_data) * @xpm_data: A pointer to a XPM data structure as found in XPM files. * * Sets a new image for an existing #GimpPixmap widget. - * - */ + **/ void gimp_pixmap_set (GimpPixmap *pixmap, gchar **xpm_data) @@ -162,7 +161,7 @@ static void gimp_pixmap_realize (GtkWidget *widget) { if (GTK_WIDGET_CLASS (parent_class)->realize) - (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); + GTK_WIDGET_CLASS (parent_class)->realize (widget); gimp_pixmap_create_from_xpm_d (GIMP_PIXMAP (widget)); } diff --git a/libgimp/gimppixmap.h b/libgimp/gimppixmap.h index ca10019d74..4cc9b48ae9 100644 --- a/libgimp/gimppixmap.h +++ b/libgimp/gimppixmap.h @@ -43,7 +43,7 @@ struct _GimpPixmap { GtkPixmap pixmap; - gchar **xpm_data; + gchar **xpm_data; }; struct _GimpPixmapClass diff --git a/libgimp/gimpquerybox.c b/libgimp/gimpquerybox.c index 06e2db30bb..2e5c26d433 100644 --- a/libgimp/gimpquerybox.c +++ b/libgimp/gimpquerybox.c @@ -51,50 +51,54 @@ struct _QueryBox gpointer data; }; -static QueryBox * create_query_box (gchar *title, + +static QueryBox * create_query_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkSignalFunc ok_callback, GtkSignalFunc cancel_callback, - gchar *message, - gchar *ok_button, - gchar *cancel_button, + const gchar *message, + const gchar *ok_button, + const gchar *cancel_button, GtkObject *object, - gchar *signal, + const gchar *signal, GtkSignalFunc callback, gpointer data); -static QueryBox * query_box_disconnect (gpointer data); +static QueryBox * query_box_disconnect (gpointer data); -static void string_query_box_ok_callback (GtkWidget *widget, - gpointer data); -static void int_query_box_ok_callback (GtkWidget *widget, - gpointer data); -static void double_query_box_ok_callback (GtkWidget *widget, - gpointer data); -static void size_query_box_ok_callback (GtkWidget *widget, - gpointer data); - -static void query_box_cancel_callback (GtkWidget *widget, - gpointer data); +static void string_query_box_ok_callback (GtkWidget *widget, + gpointer data); +static void int_query_box_ok_callback (GtkWidget *widget, + gpointer data); +static void double_query_box_ok_callback (GtkWidget *widget, + gpointer data); +static void size_query_box_ok_callback (GtkWidget *widget, + gpointer data); static void boolean_query_box_true_callback (GtkWidget *widget, gpointer data); static void boolean_query_box_false_callback (GtkWidget *widget, gpointer data); -/* create a generic query box without any entry widget */ +static void query_box_cancel_callback (GtkWidget *widget, + gpointer data); + + +/* + * create a generic query box without any entry widget + */ static QueryBox * -create_query_box (gchar *title, +create_query_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkSignalFunc ok_callback, GtkSignalFunc cancel_callback, - gchar *message, - gchar *ok_button, - gchar *cancel_button, + const gchar *message, + const gchar *ok_button, + const gchar *cancel_button, GtkObject *object, - gchar *signal, + const gchar *signal, GtkSignalFunc callback, gpointer data) { @@ -103,6 +107,11 @@ create_query_box (gchar *title, GtkWidget *vbox = NULL; GtkWidget *label; + /* make sure the object / signal passed are valid + */ + g_return_val_if_fail (object == NULL || GTK_IS_OBJECT (object), NULL); + g_return_val_if_fail (object == NULL || signal != NULL, NULL); + query_box = g_new (QueryBox, 1); qbox = gimp_dialog_new (title, "query_box", @@ -117,13 +126,26 @@ create_query_box (gchar *title, NULL); - /* if we are associated with an object, connect to the provided signal */ - if (object && GTK_IS_OBJECT (object) && signal) - gtk_signal_connect (GTK_OBJECT (object), signal, - GTK_SIGNAL_FUNC (query_box_cancel_callback), - query_box); + gtk_signal_connect (GTK_OBJECT (qbox), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &query_box->qbox); + + /* if we are associated with an object, connect to the provided signal + */ + if (object) + { + gtk_signal_connect (GTK_OBJECT (object), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &query_box->object); + + gtk_signal_connect (GTK_OBJECT (object), signal, + GTK_SIGNAL_FUNC (query_box_cancel_callback), + query_box); + } else - object = NULL; + { + object = NULL; + } if (message) { @@ -160,16 +182,15 @@ create_query_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_string_box (gchar *title, +gimp_query_string_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, - gchar *initial, + const gchar *help_data, + const gchar *message, + const gchar *initial, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryStringCallback callback, gpointer data) { @@ -184,6 +205,9 @@ gimp_query_string_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); if (initial) @@ -211,18 +235,17 @@ gimp_query_string_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_int_box (gchar *title, +gimp_query_int_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gint initial, gint lower, gint upper, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryIntCallback callback, gpointer data) { @@ -238,6 +261,9 @@ gimp_query_int_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + spinbutton = gimp_spin_button_new (&adjustment, initial, lower, upper, 1, 10, 0, 1, 0); @@ -266,19 +292,18 @@ gimp_query_int_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_double_box (gchar *title, +gimp_query_double_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, gint digits, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryDoubleCallback callback, gpointer data) { @@ -294,6 +319,9 @@ gimp_query_double_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + spinbutton = gimp_spin_button_new (&adjustment, initial, lower, upper, 1, 10, 0, 1, digits); @@ -327,13 +355,12 @@ gimp_query_double_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_size_box (gchar *title, +gimp_query_size_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, @@ -342,7 +369,7 @@ gimp_query_size_box (gchar *title, gdouble resolution, gboolean dot_for_dot, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQuerySizeCallback callback, gpointer data) { @@ -357,6 +384,9 @@ gimp_query_size_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, GIMP_SIZE_ENTRY_UPDATE_SIZE); if (dot_for_dot) @@ -394,18 +424,17 @@ gimp_query_size_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_boolean_box (gchar *title, +gimp_query_boolean_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, gboolean eek, - gchar *message, - gchar *true_button, - gchar *false_button, + const gchar *message, + const gchar *true_button, + const gchar *false_button, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryBooleanCallback callback, gpointer data) { @@ -422,7 +451,10 @@ gimp_query_boolean_box (gchar *title, object, signal, callback, data); - if (!eek) + if (! query_box) + return NULL; + + if (! eek) return query_box->qbox; hbox = gtk_hbox_new (FALSE, 10); @@ -441,6 +473,11 @@ gimp_query_boolean_box (gchar *title, return query_box->qbox; } + +/* + * private functions + */ + static QueryBox * query_box_disconnect (gpointer data) { @@ -474,7 +511,8 @@ string_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -497,7 +535,8 @@ int_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -520,7 +559,8 @@ double_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -544,21 +584,8 @@ size_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -query_box_cancel_callback (GtkWidget *widget, - gpointer data) -{ - QueryBox *query_box; - - query_box = query_box_disconnect (data); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -576,7 +603,8 @@ boolean_query_box_true_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -594,7 +622,23 @@ boolean_query_box_false_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +query_box_cancel_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + + query_box = query_box_disconnect (data); + + /* Destroy the box */ + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } diff --git a/libgimp/gimpquerybox.h b/libgimp/gimpquerybox.h index 0ffe60b128..78d2efb79c 100644 --- a/libgimp/gimpquerybox.h +++ b/libgimp/gimpquerybox.h @@ -55,45 +55,45 @@ typedef void (* GimpQueryBooleanCallback) (GtkWidget *query_box, gpointer data); /* some simple query dialogs */ -GtkWidget * gimp_query_string_box (gchar *title, +GtkWidget * gimp_query_string_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, - gchar *initial, + const gchar *help_data, + const gchar *message, + const gchar *initial, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryStringCallback callback, gpointer data); -GtkWidget * gimp_query_int_box (gchar *title, +GtkWidget * gimp_query_int_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - char *message, + const gchar *help_data, + const gchar *message, gint initial, gint lower, gint upper, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryIntCallback callback, gpointer data); -GtkWidget * gimp_query_double_box (gchar *title, +GtkWidget * gimp_query_double_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, gint digits, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryDoubleCallback callback, gpointer data); -GtkWidget * gimp_query_size_box (gchar *title, +GtkWidget * gimp_query_size_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, @@ -102,19 +102,19 @@ GtkWidget * gimp_query_size_box (gchar *title, gdouble resolution, gboolean dot_for_dot, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQuerySizeCallback callback, gpointer data); -GtkWidget * gimp_query_boolean_box (gchar *title, +GtkWidget * gimp_query_boolean_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, gboolean eek, - gchar *message, - gchar *true_button, - gchar *false_button, + const gchar *message, + const gchar *true_button, + const gchar *false_button, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryBooleanCallback callback, gpointer data); diff --git a/libgimp/gimpsizeentry.c b/libgimp/gimpsizeentry.c index 52e46cc29e..ccc548ac4d 100644 --- a/libgimp/gimpsizeentry.c +++ b/libgimp/gimpsizeentry.c @@ -237,7 +237,7 @@ gimp_size_entry_get_type (void) GtkWidget * gimp_size_entry_new (gint number_of_fields, GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, @@ -457,7 +457,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, */ void gimp_size_entry_attach_label (GimpSizeEntry *gse, - gchar *text, + const gchar *text, gint row, gint column, gfloat alignment) diff --git a/libgimp/gimpsizeentry.h b/libgimp/gimpsizeentry.h index d3b5935c12..29d7aab1d3 100644 --- a/libgimp/gimpsizeentry.h +++ b/libgimp/gimpsizeentry.h @@ -82,7 +82,7 @@ GtkType gimp_size_entry_get_type (void); GtkWidget * gimp_size_entry_new (gint number_of_fields, GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, @@ -94,7 +94,7 @@ void gimp_size_entry_add_field (GimpSizeEntry *gse, GtkSpinButton *refval_spinbutton); void gimp_size_entry_attach_label (GimpSizeEntry *gse, - gchar *text, + const gchar *text, gint row, gint column, gfloat alignment); diff --git a/libgimp/gimpui.c b/libgimp/gimpui.c index bddaf6cf84..4c348fa9f8 100644 --- a/libgimp/gimpui.c +++ b/libgimp/gimpui.c @@ -37,11 +37,10 @@ * * The GIMP's colormap policy can be determinded by the user with the * gimprc variables @min_colors and @install_cmap. - * - */ + **/ void -gimp_ui_init (gchar *prog_name, - gboolean preview) +gimp_ui_init (const gchar *prog_name, + gboolean preview) { gint argc; gchar **argv; diff --git a/libgimp/gimpui.h b/libgimp/gimpui.h index 1851e1b411..297473a26a 100644 --- a/libgimp/gimpui.h +++ b/libgimp/gimpui.h @@ -36,6 +36,7 @@ #include #include + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -43,8 +44,8 @@ extern "C" { /* For information look into the C source or the html documentation */ -void gimp_ui_init (gchar *prog_name, - gboolean preview); +void gimp_ui_init (const gchar *prog_name, + gboolean preview); #ifdef __cplusplus diff --git a/libgimp/gimpunitmenu.c b/libgimp/gimpunitmenu.c index b61ee26b3b..2e60a3ed88 100644 --- a/libgimp/gimpunitmenu.c +++ b/libgimp/gimpunitmenu.c @@ -31,10 +31,10 @@ /* private functions */ -static const gchar * gimp_unit_menu_build_string (gchar *format, - GimpUnit unit); -static void gimp_unit_menu_callback (GtkWidget *widget, - gpointer data); +static const gchar * gimp_unit_menu_build_string (const gchar *format, + GimpUnit unit); +static void gimp_unit_menu_callback (GtkWidget *widget, + gpointer data); enum { @@ -144,11 +144,11 @@ gimp_unit_menu_get_type (void) * */ GtkWidget * -gimp_unit_menu_new (gchar *format, - GimpUnit unit, - gboolean show_pixels, - gboolean show_percent, - gboolean show_custom) +gimp_unit_menu_new (const gchar *format, + GimpUnit unit, + gboolean show_pixels, + gboolean show_percent, + gboolean show_custom) { GimpUnitMenu *gum; GtkWidget *menu; @@ -375,8 +375,8 @@ print (gchar *buf, } static const gchar * -gimp_unit_menu_build_string (gchar *format, - GimpUnit unit) +gimp_unit_menu_build_string (const gchar *format, + GimpUnit unit) { static gchar buffer[64]; gint i = 0; diff --git a/libgimp/gimpunitmenu.h b/libgimp/gimpunitmenu.h index 1b688bbad1..50aed98fad 100644 --- a/libgimp/gimpunitmenu.h +++ b/libgimp/gimpunitmenu.h @@ -67,7 +67,7 @@ struct _GimpUnitMenuClass GtkType gimp_unit_menu_get_type (void); -GtkWidget * gimp_unit_menu_new (gchar *format, +GtkWidget * gimp_unit_menu_new (const gchar *format, GimpUnit unit, gboolean show_pixels, gboolean show_percent, diff --git a/libgimp/gimpwidgets.c b/libgimp/gimpwidgets.c index 4a35b4023d..ba42dc51ab 100644 --- a/libgimp/gimpwidgets.c +++ b/libgimp/gimpwidgets.c @@ -1,5 +1,5 @@ /* LIBGIMP - The GIMP Library - * Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * * gimpwidgets.c * Copyright (C) 2000 Michael Natterer @@ -44,13 +44,12 @@ * @...: A #NULL terminated @va_list describing the menu items. * * Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only). - * - */ + **/ GtkWidget * gimp_option_menu_new (gboolean menu_only, /* specify menu items as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * gpointer user_data, @@ -64,7 +63,7 @@ gimp_option_menu_new (gboolean menu_only, GtkWidget *menuitem; /* menu item variables */ - gchar *label; + const gchar *label; GtkSignalFunc callback; gpointer data; gpointer user_data; @@ -79,8 +78,10 @@ gimp_option_menu_new (gboolean menu_only, /* create the menu items */ initial_index = 0; + va_start (args, menu_only); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); + for (i = 0; label; i++) { callback = va_arg (args, GtkSignalFunc); @@ -116,7 +117,7 @@ gimp_option_menu_new (gboolean menu_only, if (active) initial_index = i; - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -146,18 +147,17 @@ gimp_option_menu_new (gboolean menu_only, * @...: A #NULL terminated @va_list describing the menu items. * * Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only). - * - */ + **/ GtkWidget * -gimp_option_menu_new2 (gboolean menu_only, - GtkSignalFunc menu_item_callback, - gpointer data, - gpointer initial, /* user_data */ +gimp_option_menu_new2 (gboolean menu_only, + GtkSignalFunc menu_item_callback, + gpointer data, + gpointer initial, /* user_data */ /* specify menu items as va_list: - * gchar *label, - * gpointer user_data, - * GtkWidget **widget_ptr, + * const gchar *label, + * gpointer user_data, + * GtkWidget **widget_ptr, */ ...) @@ -166,9 +166,9 @@ gimp_option_menu_new2 (gboolean menu_only, GtkWidget *menuitem; /* menu item variables */ - gchar *label; - gpointer user_data; - GtkWidget **widget_ptr; + const gchar *label; + gpointer user_data; + GtkWidget **widget_ptr; va_list args; gint i; @@ -178,8 +178,10 @@ gimp_option_menu_new2 (gboolean menu_only, /* create the menu items */ initial_index = 0; + va_start (args, initial); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); + for (i = 0; label; i++) { user_data = va_arg (args, gpointer); @@ -212,7 +214,7 @@ gimp_option_menu_new2 (gboolean menu_only, if (user_data == initial) initial_index = i; - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -237,8 +239,7 @@ gimp_option_menu_new2 (gboolean menu_only, * @option_menu: A #GtkOptionMenu as returned by gimp_option_menu_new() or * gimp_option_menu_new2(). * @user_data: The @user_data of the menu item you want to select. - * - */ + **/ void gimp_option_menu_set_history (GtkOptionMenu *option_menu, gpointer user_data) @@ -276,14 +277,13 @@ gimp_option_menu_set_history (GtkOptionMenu *option_menu, * @...: A #NULL terminated @va_list describing the radio buttons. * * Returns: A #GtkFrame or #GtkVbox (depending on @in_frame). - * - */ + **/ GtkWidget * gimp_radio_group_new (gboolean in_frame, - gchar *frame_title, + const gchar *frame_title, /* specify radio buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * gpointer user_data, @@ -298,7 +298,7 @@ gimp_radio_group_new (gboolean in_frame, GSList *group; /* radio button variables */ - gchar *label; + const gchar *label; GtkSignalFunc callback; gpointer data; gpointer user_data; @@ -313,7 +313,7 @@ gimp_radio_group_new (gboolean in_frame, /* create the radio buttons */ va_start (args, frame_title); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); while (label) { callback = va_arg (args, GtkSignalFunc); @@ -345,7 +345,7 @@ gimp_radio_group_new (gboolean in_frame, gtk_widget_show (button); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -376,19 +376,18 @@ gimp_radio_group_new (gboolean in_frame, * @...: A #NULL terminated @va_list describing the radio buttons. * * Returns: A #GtkFrame or #GtkVbox (depending on @in_frame). - * - */ + **/ GtkWidget * -gimp_radio_group_new2 (gboolean in_frame, - gchar *frame_title, - GtkSignalFunc radio_button_callback, - gpointer data, - gpointer initial, /* user_data */ +gimp_radio_group_new2 (gboolean in_frame, + const gchar *frame_title, + GtkSignalFunc radio_button_callback, + gpointer data, + gpointer initial, /* user_data */ /* specify radio buttons as va_list: - * gchar *label, - * gpointer user_data, - * GtkWidget **widget_ptr, + * const gchar *label, + * gpointer user_data, + * GtkWidget **widget_ptr, */ ...) @@ -398,9 +397,9 @@ gimp_radio_group_new2 (gboolean in_frame, GSList *group; /* radio button variables */ - gchar *label; - gpointer user_data; - GtkWidget **widget_ptr; + const gchar *label; + gpointer user_data; + GtkWidget **widget_ptr; va_list args; @@ -410,7 +409,8 @@ gimp_radio_group_new2 (gboolean in_frame, /* create the radio buttons */ va_start (args, initial); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); + while (label) { user_data = va_arg (args, gpointer); @@ -439,7 +439,7 @@ gimp_radio_group_new2 (gboolean in_frame, gtk_widget_show (button); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -476,8 +476,7 @@ gimp_radio_group_new2 (gboolean in_frame, * setting a standard minimun horizontal size. * * Returns: A #GtkSpinbutton and it's #GtkAdjustment. - * - */ + **/ GtkWidget * gimp_spin_button_new (GtkObject **adjustment, /* return value */ gfloat value, @@ -545,26 +544,25 @@ gimp_scale_entry_unconstrained_adjustment_callback (GtkAdjustment *adjustment, * have to initialize GIMP's help system with gimp_help_init() before using it. * * Returns: The #GtkSpinButton's #GtkAdjustment. - * - */ + **/ GtkObject * -gimp_scale_entry_new (GtkTable *table, - gint column, - gint row, - gchar *text, - gint scale_usize, - gint spinbutton_usize, - gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - guint digits, - gboolean constrain, - gfloat unconstrained_lower, - gfloat unconstrained_upper, - gchar *tooltip, - gchar *help_data) +gimp_scale_entry_new (GtkTable *table, + gint column, + gint row, + const gchar *text, + gint scale_usize, + gint spinbutton_usize, + gfloat value, + gfloat lower, + gfloat upper, + gfloat step_increment, + gfloat page_increment, + guint digits, + gboolean constrain, + gfloat unconstrained_lower, + gfloat unconstrained_upper, + const gchar *tooltip, + const gchar *help_data) { GtkWidget *label; GtkWidget *scale; @@ -682,8 +680,7 @@ gimp_random_seed_toggle_update (GtkWidget *widget, * * Returns: A #GtkHBox containing a #GtkSpinButton for the random seed and * a #GtkToggleButton for toggling the @use_time behaviour. - * - */ + **/ GtkWidget * gimp_random_seed_new (gint *seed, gint *use_time, @@ -845,11 +842,10 @@ gimp_coordinates_callback (GtkWidget *widget, * Returns: A #GimpSizeEntry with two fields for x/y coordinates/sizes with * a #GimpChainButton attached to constrain either the two fields' * values or the ratio between them. - * - */ + **/ GtkWidget * gimp_coordinates_new (GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, @@ -858,7 +854,7 @@ gimp_coordinates_new (GimpUnit unit, gboolean chainbutton_active, gboolean chain_constrains_ratio, - gchar *xlabel, + const gchar *xlabel, gdouble x, gdouble xres, gdouble lower_boundary_x, @@ -866,7 +862,7 @@ gimp_coordinates_new (GimpUnit unit, gdouble xsize_0, /* % */ gdouble xsize_100, /* % */ - gchar *ylabel, + const gchar *ylabel, gdouble y, gdouble yres, gdouble lower_boundary_y, @@ -993,7 +989,7 @@ gimp_mem_size_unit_callback (GtkWidget *widget, * @adjustment: The adjustment containing the memsize and it's limits. * * Returns: A #GtkHBox with a #GtkSpinButton and a #GtkOptionMenu. - */ + **/ GtkWidget * gimp_mem_size_entry_new (GtkAdjustment *adjustment) { @@ -1063,11 +1059,10 @@ gimp_mem_size_entry_new (GtkAdjustment *adjustment) * @text: An optional text which will appear right of the pixmap. * * Returns: A #GtkButton with a #GimpPixmap and an optional #GtkLabel. - * - */ + **/ GtkWidget * -gimp_pixmap_button_new (gchar **xpm_data, - gchar *text) +gimp_pixmap_button_new (gchar **xpm_data, + const gchar *text) { GtkWidget *button; GtkWidget *pixmap; @@ -1126,8 +1121,7 @@ gimp_pixmap_button_new (gchar **xpm_data, * This function can also set the sensitive state according to the toggle * button's inverse "active" state by attaching widgets with the * "inverse_sensitive" key. - * - */ + **/ void gimp_toggle_button_sensitive_update (GtkToggleButton *toggle_button) { @@ -1162,8 +1156,7 @@ gimp_toggle_button_sensitive_update (GtkToggleButton *toggle_button) * gtk_toggle_button_get_active(). * * Note that this function calls gimp_toggle_button_sensitive_update(). - * - */ + **/ void gimp_toggle_button_update (GtkWidget *widget, gpointer data) @@ -1187,8 +1180,7 @@ gimp_toggle_button_update (GtkWidget *widget, * (#gint) gtk_object_get_user_data(). * * Note that this function calls gimp_toggle_button_sensitive_update(). - * - */ + **/ void gimp_radio_button_update (GtkWidget *widget, gpointer data) @@ -1210,8 +1202,7 @@ gimp_radio_button_update (GtkWidget *widget, * @widget: A #GtkMenuItem. * @data: A pointer to a #gint variable which will store the value of * (#gint) gtk_object_get_user_data(). - * - */ + **/ void gimp_menu_item_update (GtkWidget *widget, gpointer data) @@ -1231,8 +1222,7 @@ gimp_menu_item_update (GtkWidget *widget, * * Note that the #GtkAdjustment's value (which is a #gfloat) will be rounded * with (#gint) (value + 0.5). - * - */ + **/ void gimp_int_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1251,8 +1241,7 @@ gimp_int_adjustment_update (GtkAdjustment *adjustment, * * Note that the #GtkAdjustment's value (which is a #gfloat) will be rounded * with (#guint) (value + 0.5). - * - */ + **/ void gimp_uint_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1268,8 +1257,7 @@ gimp_uint_adjustment_update (GtkAdjustment *adjustment, * @adjustment: A #GtkAdjustment. * @data: A pointer to a #gfloat varaiable which willl store the adjustment's * value. - * - */ + **/ void gimp_float_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1285,8 +1273,7 @@ gimp_float_adjustment_update (GtkAdjustment *adjustment, * @adjustment: A #GtkAdjustment. * @data: A pointer to a #gdouble variable which will store the adjustment's * value. - * - */ + **/ void gimp_double_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1310,8 +1297,7 @@ gimp_double_adjustment_update (GtkAdjustment *adjustment, * * See gimp_toggle_button_sensitive_update() for a description of how * to set up the list. - * - */ + **/ void gimp_unit_menu_update (GtkWidget *widget, gpointer data) @@ -1355,18 +1341,17 @@ gimp_unit_menu_update (GtkWidget *widget, * * Note that the @label_text can be #NULL and that the widget will be attached * starting at (@column + 1) in this case, too. - * - */ + **/ void -gimp_table_attach_aligned (GtkTable *table, - gint column, - gint row, - gchar *label_text, - gfloat xalign, - gfloat yalign, - GtkWidget *widget, - gint colspan, - gboolean left_align) +gimp_table_attach_aligned (GtkTable *table, + gint column, + gint row, + const gchar *label_text, + gfloat xalign, + gfloat yalign, + GtkWidget *widget, + gint colspan, + gboolean left_align) { if (label_text) { diff --git a/libgimp/gimpwidgets.h b/libgimp/gimpwidgets.h index 8e818637a4..d629581591 100644 --- a/libgimp/gimpwidgets.h +++ b/libgimp/gimpwidgets.h @@ -65,10 +65,10 @@ void gimp_option_menu_set_history (GtkOptionMenu *option_menu, gpointer user_data); GtkWidget * gimp_radio_group_new (gboolean in_frame, - gchar *frame_title, + const gchar *frame_title, /* specify radio buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * gpointer user_data, @@ -79,13 +79,13 @@ GtkWidget * gimp_radio_group_new (gboolean in_frame, ...); GtkWidget * gimp_radio_group_new2 (gboolean in_frame, - gchar *frame_title, + const gchar *frame_title, GtkSignalFunc radio_button_callback, gpointer data, gpointer initial, /* user_data */ /* specify radio buttons as va_list: - * gchar *label, + * const gchar *label, * gpointer user_data, * GtkWidget **widget_ptr, */ @@ -122,7 +122,7 @@ GtkWidget * gimp_spin_button_new (/* return value: */ GtkObject * gimp_scale_entry_new (GtkTable *table, gint column, gint row, - gchar *text, + const gchar *text, gint scale_usize, gint spinbutton_usize, gfloat value, @@ -134,8 +134,8 @@ GtkObject * gimp_scale_entry_new (GtkTable *table, gboolean constrain, gfloat unconstrained_lower, gfloat unconstrained_upper, - gchar *tooltip, - gchar *help_data); + const gchar *tooltip, + const gchar *help_data); #define GIMP_RANDOM_SEED_SPINBUTTON(hbox) \ GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT( hbox), "spinbutton")) @@ -157,7 +157,7 @@ GtkWidget * gimp_random_seed_new (gint *seed, "chainbutton")) GtkWidget * gimp_coordinates_new (GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, @@ -166,7 +166,7 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit, gboolean chainbutton_active, gboolean chain_constrains_ratio, - gchar *xlabel, + const gchar *xlabel, gdouble x, gdouble xres, gdouble lower_boundary_x, @@ -174,7 +174,7 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit, gdouble xsize_0, /* % */ gdouble xsize_100, /* % */ - gchar *ylabel, + const gchar *ylabel, gdouble y, gdouble yres, gdouble lower_boundary_y, @@ -197,7 +197,7 @@ GtkWidget * gimp_mem_size_entry_new (GtkAdjustment *adjustment); GtkWidget * gimp_pixmap_button_new (gchar **xpm_data, - gchar *text); + const gchar *text); /* * Standard Callbacks @@ -236,7 +236,7 @@ void gimp_unit_menu_update (GtkWidget *widget, void gimp_table_attach_aligned (GtkTable *table, gint column, gint row, - gchar *label_text, + const gchar *label_text, gfloat xalign, gfloat yalign, GtkWidget *widget, diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c index 1aeed7db9a..02363f07a6 100644 --- a/libgimpwidgets/gimpcolorbutton.c +++ b/libgimpwidgets/gimpcolorbutton.c @@ -63,8 +63,10 @@ static void gimp_color_button_drag_handle (GtkWidget *widget, guint info, guint time, gpointer data); + static const GtkTargetEntry targets[] = { { "application/x-color", 0 } }; + /* end of DND */ struct _GimpColorButton @@ -89,48 +91,50 @@ struct _GimpColorButton }; -static void gimp_color_button_destroy (GtkObject *object); -static void gimp_color_button_clicked (GtkButton *button); +static void gimp_color_button_destroy (GtkObject *object); +static void gimp_color_button_clicked (GtkButton *button); static void gimp_color_button_paint (GimpColorButton *gcb); -static void gimp_color_button_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gimp_color_button_state_changed (GtkWidget *widget, + GtkStateType previous_state); -static void gimp_color_button_dialog_ok (GtkWidget *widget, - gpointer data); -static void gimp_color_button_dialog_cancel (GtkWidget *widget, - gpointer data); +static void gimp_color_button_dialog_ok (GtkWidget *widget, + gpointer data); +static void gimp_color_button_dialog_cancel (GtkWidget *widget, + gpointer data); -static void gimp_color_button_use_fg (gpointer callback_data, - guint callback_action, - GtkWidget *widget); -static void gimp_color_button_use_bg (gpointer callback_data, - guint callback_action, - GtkWidget *widget); +static void gimp_color_button_use_fg (gpointer callback_data, + guint callback_action, + GtkWidget *widget); +static void gimp_color_button_use_bg (gpointer callback_data, + guint callback_action, + GtkWidget *widget); -static gint gimp_color_button_menu_popup (GtkWidget *widget, - GdkEvent *event, - gpointer data); -static gchar* gimp_color_button_menu_translate (const gchar *path, - gpointer func_data); +static gint gimp_color_button_menu_popup (GtkWidget *widget, + GdkEvent *event, + gpointer data); +static gchar* gimp_color_button_menu_translate (const gchar *path, + gpointer func_data); -static GtkItemFactoryEntry menu_items[] = { +static GtkItemFactoryEntry menu_items[] = +{ { N_("/Use Foreground Color"), NULL, gimp_color_button_use_fg, 2, NULL }, { N_("/Use Background Color"), NULL, gimp_color_button_use_bg, 2, NULL } }; static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); -enum { +enum +{ COLOR_CHANGED, LAST_SIGNAL }; static guint gimp_color_button_signals[LAST_SIGNAL] = { 0 }; - static GtkWidgetClass *parent_class = NULL; + static void gimp_color_button_destroy (GtkObject *object) { @@ -148,7 +152,7 @@ gimp_color_button_destroy (GtkObject *object) g_free (gcb->odd); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } @@ -156,12 +160,12 @@ static void gimp_color_button_class_init (GimpColorButtonClass *class) { GtkObjectClass *object_class; - GtkButtonClass *button_class; GtkWidgetClass *widget_class; + GtkButtonClass *button_class; object_class = (GtkObjectClass*) class; - button_class = (GtkButtonClass*) class; widget_class = (GtkWidgetClass*) class; + button_class = (GtkButtonClass*) class; parent_class = gtk_type_class (gtk_widget_get_type ()); @@ -172,13 +176,15 @@ gimp_color_button_class_init (GimpColorButtonClass *class) GTK_SIGNAL_OFFSET (GimpColorButtonClass, color_changed), gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, gimp_color_button_signals, LAST_SIGNAL); + class->color_changed = NULL; object_class->destroy = gimp_color_button_destroy; - button_class->clicked = gimp_color_button_clicked; widget_class->state_changed = gimp_color_button_state_changed; + button_class->clicked = gimp_color_button_clicked; } @@ -225,12 +231,12 @@ gimp_color_button_get_type (void) } static GtkWidget * -_gimp_color_button_new (gboolean double_color, - gchar *title, - gint width, - gint height, - gpointer color, - gint bpp) +_gimp_color_button_new (gboolean double_color, + const gchar *title, + gint width, + gint height, + gpointer color, + gint bpp) { GimpColorButton *gcb; gint i; @@ -297,25 +303,21 @@ _gimp_color_button_new (gboolean double_color, targets, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_begin", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_begin", GTK_SIGNAL_FUNC (gimp_color_button_drag_begin), gcb); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_end", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_end", GTK_SIGNAL_FUNC (gimp_color_button_drag_end), gcb); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_data_get", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_get", GTK_SIGNAL_FUNC (gimp_color_button_drag_handle), gcb); - gtk_signal_connect (GTK_OBJECT (gcb->preview), - "drag_data_received", + gtk_signal_connect (GTK_OBJECT (gcb->preview), "drag_data_received", GTK_SIGNAL_FUNC (gimp_color_button_drop_handle), gcb); /* end of DND */ - return (GTK_WIDGET (gcb)); + return GTK_WIDGET (gcb); } /** @@ -335,13 +337,13 @@ _gimp_color_button_new (gboolean double_color, * signal is emitted. * * Returns: Pointer to the new #GimpColorButton widget. - */ + **/ GtkWidget * -gimp_color_button_new (gchar *title, - gint width, - gint height, - guchar *color, - gint bpp) +gimp_color_button_new (const gchar *title, + gint width, + gint height, + guchar *color, + gint bpp) { return _gimp_color_button_new (FALSE, title, width, height, (gpointer) color, bpp); @@ -364,13 +366,13 @@ gimp_color_button_new (gchar *title, * signal is emitted. * * Returns: Pointer to the new GimpColorButton widget. - */ + **/ GtkWidget * -gimp_color_button_double_new (gchar *title, - gint width, - gint height, - gdouble *color, - gint bpp) +gimp_color_button_double_new (const gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp) { return _gimp_color_button_new (TRUE, title, width, height, (gpointer) color, bpp); @@ -383,12 +385,13 @@ gimp_color_button_double_new (gchar *title, * Should be used after the color controlled by a #GimpColorButton * was changed. The color is then reread and the change is propagated * to the preview and the GtkColorSelectionDialog if one is open. - */ + **/ void gimp_color_button_update (GimpColorButton *gcb) { gint i; + g_return_if_fail (gcb != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); if (gcb->double_color) @@ -413,13 +416,14 @@ static void gimp_color_button_state_changed (GtkWidget *widget, GtkStateType previous_state) { + g_return_if_fail (widget != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget)); if (!GTK_WIDGET_IS_SENSITIVE (widget) && GIMP_COLOR_BUTTON (widget)->dialog) gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog); if (GTK_WIDGET_CLASS (parent_class)->state_changed) - (* GTK_WIDGET_CLASS (parent_class)->state_changed) (widget, previous_state); + GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state); } static gint @@ -432,7 +436,9 @@ gimp_color_button_menu_popup (GtkWidget *widget, gint x; gint y; + g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (data), FALSE); + gcb = GIMP_COLOR_BUTTON (data); if (event->type != GDK_BUTTON_PRESS) @@ -457,7 +463,9 @@ gimp_color_button_clicked (GtkButton *button) GimpColorButton *gcb; GtkColorSelection *colorsel; + g_return_if_fail (button != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (button)); + gcb = GIMP_COLOR_BUTTON (button); if (!gcb->dialog) @@ -479,6 +487,7 @@ gimp_color_button_clicked (GtkButton *button) (GtkSignalFunc) gimp_color_button_dialog_cancel, gcb); gtk_window_set_position (GTK_WINDOW (gcb->dialog), GTK_WIN_POS_MOUSE); } + gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor); gtk_widget_show (gcb->dialog); @@ -491,6 +500,7 @@ gimp_color_button_paint (GimpColorButton *gcb) gdouble c0, c1; guchar *p0, *p1; + g_return_if_fail (gcb != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); p0 = gcb->even; @@ -548,8 +558,10 @@ gimp_color_button_dialog_ok (GtkWidget *widget, GimpColorButton *gcb; gboolean color_changed = FALSE; gint i; - + + g_return_if_fail (data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (data)); + gcb = GIMP_COLOR_BUTTON (data); gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor); @@ -592,7 +604,9 @@ gimp_color_button_dialog_cancel (GtkWidget *widget, { GimpColorButton *gcb; + g_return_if_fail (data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (data)); + gcb = GIMP_COLOR_BUTTON (data); gtk_widget_hide (gcb->dialog); @@ -608,7 +622,9 @@ gimp_color_button_use_fg (gpointer callback_data, guchar fg_color[3]; gint i; + g_return_if_fail (callback_data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); + gcb = GIMP_COLOR_BUTTON (callback_data); gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]); @@ -640,7 +656,9 @@ gimp_color_button_use_bg (gpointer callback_data, guchar bg_color[3]; gint i; + g_return_if_fail (callback_data != NULL); g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); + gcb = GIMP_COLOR_BUTTON (callback_data); gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]); @@ -662,7 +680,7 @@ gimp_color_button_use_bg (gpointer callback_data, gimp_color_button_signals[COLOR_CHANGED]); } -static gchar * +static gchar * gimp_color_button_menu_translate (const gchar *path, gpointer func_data) { diff --git a/libgimpwidgets/gimpcolorbutton.h b/libgimpwidgets/gimpcolorbutton.h index 124cbf954b..2289a87e57 100644 --- a/libgimpwidgets/gimpcolorbutton.h +++ b/libgimpwidgets/gimpcolorbutton.h @@ -52,16 +52,16 @@ struct _GimpColorButtonClass GtkType gimp_color_button_get_type (void); -GtkWidget * gimp_color_button_new (gchar *title, - gint width, - gint height, - guchar *color, - gint bpp); -GtkWidget * gimp_color_button_double_new (gchar *title, - gint width, - gint height, - gdouble *color, - gint bpp); +GtkWidget * gimp_color_button_new (const gchar *title, + gint width, + gint height, + guchar *color, + gint bpp); +GtkWidget * gimp_color_button_double_new (const gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp); void gimp_color_button_update (GimpColorButton *gcb); diff --git a/libgimpwidgets/gimpdialog.c b/libgimpwidgets/gimpdialog.c index c76d897680..baf8676309 100644 --- a/libgimpwidgets/gimpdialog.c +++ b/libgimpwidgets/gimpdialog.c @@ -99,14 +99,14 @@ GtkWidget * gimp_dialog_new (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, gint auto_shrink, /* specify action area buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, @@ -167,7 +167,7 @@ GtkWidget * gimp_dialog_newv (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, @@ -237,7 +237,7 @@ void gimp_dialog_create_action_area (GtkDialog *dialog, /* specify action area buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, @@ -272,7 +272,7 @@ gimp_dialog_create_action_areav (GtkDialog *dialog, GtkWidget *button; /* action area variables */ - gchar *label; + const gchar *label; GtkSignalFunc callback; gpointer data; GtkObject *slot_object; @@ -286,7 +286,7 @@ gimp_dialog_create_action_areav (GtkDialog *dialog, g_return_if_fail (GTK_IS_DIALOG (dialog)); /* prepare the action_area */ - label = va_arg (args, gchar *); + label = va_arg (args, const gchar *); if (label) { diff --git a/libgimpwidgets/gimpdialog.h b/libgimpwidgets/gimpdialog.h index 003d81601b..cb291aad7e 100644 --- a/libgimpwidgets/gimpdialog.h +++ b/libgimpwidgets/gimpdialog.h @@ -35,7 +35,7 @@ extern "C" { GtkWidget * gimp_dialog_new (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, @@ -43,7 +43,7 @@ GtkWidget * gimp_dialog_new (const gchar *title, /* specify action area buttons * as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, @@ -57,7 +57,7 @@ GtkWidget * gimp_dialog_new (const gchar *title, GtkWidget * gimp_dialog_newv (const gchar *title, const gchar *wmclass_name, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkWindowPosition position, gint allow_shrink, gint allow_grow, @@ -70,7 +70,7 @@ void gimp_dialog_create_action_area (GtkDialog *dialog, /* specify action area buttons * as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * GtkObject *slot_object, diff --git a/libgimpwidgets/gimpfileentry.c b/libgimpwidgets/gimpfileentry.c index cd1ded4482..ffcb26bf6c 100644 --- a/libgimpwidgets/gimpfileentry.c +++ b/libgimpwidgets/gimpfileentry.c @@ -99,7 +99,7 @@ gimp_file_selection_destroy (GtkObject *object) gdk_bitmap_unref (gfs->no_mask); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } static void @@ -127,7 +127,6 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class) class->filename_changed = NULL; object_class->destroy = gimp_file_selection_destroy; - widget_class->realize = gimp_file_selection_realize; } @@ -201,13 +200,12 @@ gimp_file_selection_get_type (void) * Creates a new #GimpFileSelection widget. * * Returns: A pointer to the new #GimpFileSelection widget. - * - */ + **/ GtkWidget * -gimp_file_selection_new (gchar *title, - gchar *filename, - gboolean dir_only, - gboolean check_valid) +gimp_file_selection_new (const gchar *title, + const gchar *filename, + gboolean dir_only, + gboolean check_valid) { GimpFileSelection *gfs; @@ -229,8 +227,7 @@ gimp_file_selection_new (gchar *title, * Note that you have to g_free() the returned string. * * Returns: The file or directory the user has entered. - * - */ + **/ gchar * gimp_file_selection_get_filename (GimpFileSelection *gfs) { @@ -252,7 +249,7 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs) */ void gimp_file_selection_set_filename (GimpFileSelection *gfs, - gchar *filename) + const gchar *filename) { g_return_if_fail (gfs != NULL); g_return_if_fail (GIMP_IS_FILE_SELECTION (gfs)); @@ -441,6 +438,7 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs) if (! gfs->check_valid) return; + if (gfs->file_exists == NULL) return; diff --git a/libgimpwidgets/gimpfileentry.h b/libgimpwidgets/gimpfileentry.h index d09b01f0c8..432b75d2f3 100644 --- a/libgimpwidgets/gimpfileentry.h +++ b/libgimpwidgets/gimpfileentry.h @@ -69,15 +69,15 @@ struct _GimpFileSelectionClass GtkType gimp_file_selection_get_type (void); -GtkWidget* gimp_file_selection_new (gchar *title, - gchar *filename, +GtkWidget* gimp_file_selection_new (const gchar *title, + const gchar *filename, gboolean dir_only, gboolean check_valid); gchar* gimp_file_selection_get_filename (GimpFileSelection *gfs); void gimp_file_selection_set_filename (GimpFileSelection *gfs, - gchar *filename); + const gchar *filename); #ifdef __cplusplus diff --git a/libgimpwidgets/gimpfileselection.c b/libgimpwidgets/gimpfileselection.c index cd1ded4482..ffcb26bf6c 100644 --- a/libgimpwidgets/gimpfileselection.c +++ b/libgimpwidgets/gimpfileselection.c @@ -99,7 +99,7 @@ gimp_file_selection_destroy (GtkObject *object) gdk_bitmap_unref (gfs->no_mask); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } static void @@ -127,7 +127,6 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class) class->filename_changed = NULL; object_class->destroy = gimp_file_selection_destroy; - widget_class->realize = gimp_file_selection_realize; } @@ -201,13 +200,12 @@ gimp_file_selection_get_type (void) * Creates a new #GimpFileSelection widget. * * Returns: A pointer to the new #GimpFileSelection widget. - * - */ + **/ GtkWidget * -gimp_file_selection_new (gchar *title, - gchar *filename, - gboolean dir_only, - gboolean check_valid) +gimp_file_selection_new (const gchar *title, + const gchar *filename, + gboolean dir_only, + gboolean check_valid) { GimpFileSelection *gfs; @@ -229,8 +227,7 @@ gimp_file_selection_new (gchar *title, * Note that you have to g_free() the returned string. * * Returns: The file or directory the user has entered. - * - */ + **/ gchar * gimp_file_selection_get_filename (GimpFileSelection *gfs) { @@ -252,7 +249,7 @@ gimp_file_selection_get_filename (GimpFileSelection *gfs) */ void gimp_file_selection_set_filename (GimpFileSelection *gfs, - gchar *filename) + const gchar *filename) { g_return_if_fail (gfs != NULL); g_return_if_fail (GIMP_IS_FILE_SELECTION (gfs)); @@ -441,6 +438,7 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs) if (! gfs->check_valid) return; + if (gfs->file_exists == NULL) return; diff --git a/libgimpwidgets/gimpfileselection.h b/libgimpwidgets/gimpfileselection.h index d09b01f0c8..432b75d2f3 100644 --- a/libgimpwidgets/gimpfileselection.h +++ b/libgimpwidgets/gimpfileselection.h @@ -69,15 +69,15 @@ struct _GimpFileSelectionClass GtkType gimp_file_selection_get_type (void); -GtkWidget* gimp_file_selection_new (gchar *title, - gchar *filename, +GtkWidget* gimp_file_selection_new (const gchar *title, + const gchar *filename, gboolean dir_only, gboolean check_valid); gchar* gimp_file_selection_get_filename (GimpFileSelection *gfs); void gimp_file_selection_set_filename (GimpFileSelection *gfs, - gchar *filename); + const gchar *filename); #ifdef __cplusplus diff --git a/libgimpwidgets/gimphelpui.c b/libgimpwidgets/gimphelpui.c index 17913137d2..5864cfa832 100644 --- a/libgimpwidgets/gimphelpui.c +++ b/libgimpwidgets/gimphelpui.c @@ -56,8 +56,7 @@ static GtkWidget * tips_query = NULL; * * Currently it only creates a #GtkTooltips object with gtk_tooltips_new() * which will be used by gimp_help_set_help_data(). - * - */ + **/ void gimp_help_init (void) { @@ -69,8 +68,7 @@ gimp_help_init (void) * * This function frees the memory used by the #GtkTooltips created by * gimp_help_init(). - * - */ + **/ void gimp_help_free (void) { @@ -82,8 +80,7 @@ gimp_help_free (void) * gimp_help_enable_tooltips: * * This function calls gtk_tooltips_enable(). - * - */ + **/ void gimp_help_enable_tooltips (void) { @@ -94,8 +91,7 @@ gimp_help_enable_tooltips (void) * gimp_help_disable_tooltips: * * This function calls gtk_tooltips_disable(). - * - */ + **/ void gimp_help_disable_tooltips (void) { @@ -116,12 +112,11 @@ gimp_help_disable_tooltips (void) * For convenience, gimp_help_connect_help_accel() calls * gimp_dialog_set_icon() if the passed widget is a #GtkWindow, so you * don't have to worry about this. - * - */ + **/ void gimp_help_connect_help_accel (GtkWidget *widget, GimpHelpFunc help_func, - gchar *help_data) + const gchar *help_data) { GtkAccelGroup *accel_group; @@ -134,7 +129,8 @@ gimp_help_connect_help_accel (GtkWidget *widget, if (GTK_IS_WINDOW (widget)) gimp_dialog_set_icon (GTK_WINDOW (widget)); - /* set up the help signals and tips query widget */ + /* set up the help signals and tips query widget + */ if (!tips_query) { tips_query = gtk_tips_query_new (); @@ -229,20 +225,25 @@ gimp_help_connect_help_accel (GtkWidget *widget, * help system will automatically ascend the widget hierarchy until it * finds another widget with @help_data attached and concatenates both * to a complete help path. - * - */ + **/ void gimp_help_set_help_data (GtkWidget *widget, const gchar *tooltip, - gchar *help_data) + const gchar *help_data) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); if (tooltip) - gtk_tooltips_set_tip (tool_tips, widget, tooltip, help_data); + { + gtk_tooltips_set_tip (tool_tips, widget, tooltip, + (gpointer) help_data); + } else if (help_data) - gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", help_data); + { + gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", + (gpointer) help_data); + } } /** @@ -258,8 +259,7 @@ gimp_help_set_help_data (GtkWidget *widget, * be displayed. Otherwise the help system will ascend the widget hierarchy * until it finds an attached @help_data string (which should be the * case at least for every window/dialog). - * - */ + **/ void gimp_context_help (void) { @@ -275,12 +275,12 @@ static void gimp_help_callback (GtkWidget *widget, gpointer data) { - GimpHelpFunc help_function; - gchar *help_data; + GimpHelpFunc help_function; + const gchar *help_data; help_function = (GimpHelpFunc) data; - help_data = (gchar *) gtk_object_get_data (GTK_OBJECT (widget), - "gimp_help_data"); + help_data = (const gchar *) gtk_object_get_data (GTK_OBJECT (widget), + "gimp_help_data"); if (help_function) (* help_function) (help_data); diff --git a/libgimpwidgets/gimphelpui.h b/libgimpwidgets/gimphelpui.h index 2f4e295d0b..678b84eec8 100644 --- a/libgimpwidgets/gimphelpui.h +++ b/libgimpwidgets/gimphelpui.h @@ -27,10 +27,12 @@ extern "C" { #endif /* __cplusplus */ + /* For information look into the C source or the html documentation */ -typedef void (* GimpHelpFunc) (gchar *help_data); +typedef void (* GimpHelpFunc) (const gchar *help_data); + void gimp_help_init (void); void gimp_help_free (void); @@ -41,17 +43,17 @@ void gimp_help_disable_tooltips (void); /* the standard gimp help function * (has different implementations in the main app and in libgimp) */ -void gimp_standard_help_func (gchar *help_data); +void gimp_standard_help_func (const gchar *help_data); /* connect the "F1" accelerator of a window */ void gimp_help_connect_help_accel (GtkWidget *widget, GimpHelpFunc help_func, - gchar *help_data); + const gchar *help_data); /* set help data for non-window widgets */ void gimp_help_set_help_data (GtkWidget *widget, const gchar *tooltip, - gchar *help_data); + const gchar *help_data); /* activate the context help inspector */ void gimp_context_help (void); diff --git a/libgimpwidgets/gimppatheditor.c b/libgimpwidgets/gimppatheditor.c index 1c95808c4a..b0fec3ce8f 100644 --- a/libgimpwidgets/gimppatheditor.c +++ b/libgimpwidgets/gimppatheditor.c @@ -89,8 +89,8 @@ gimp_path_editor_init (GimpPathEditor *gpe) GtkWidget *button; GtkWidget *scrolled_window; - gpe->file_selection = NULL; - gpe->selected_item = NULL; + gpe->file_selection = NULL; + gpe->selected_item = NULL; gpe->number_of_items = 0; gpe->upper_hbox = gtk_hbox_new (FALSE, 2); @@ -183,16 +183,16 @@ gimp_path_editor_get_type (void) * #G_SEARCHPATH_SEPARATOR character. * * Returns: A pointer to the new #GimpPathEditor widget. - * - */ + **/ GtkWidget * -gimp_path_editor_new (gchar *filesel_title, - gchar *path) +gimp_path_editor_new (const gchar *filesel_title, + const gchar *path) { GimpPathEditor *gpe; GtkWidget *list_item; GList *directory_list; gchar *directory; + gchar *mypath; g_return_val_if_fail ((filesel_title != NULL), NULL); g_return_val_if_fail ((path != NULL), NULL); @@ -209,7 +209,7 @@ gimp_path_editor_new (gchar *filesel_title, gtk_widget_show (gpe->file_selection); directory_list = NULL; - directory = path = g_strdup (path); + directory = mypath = g_strdup (path); /* split up the path */ while (strlen (directory)) @@ -243,7 +243,7 @@ gimp_path_editor_new (gchar *filesel_title, break; } - g_free (path); + g_free (mypath); if (directory_list) gtk_list_append_items (GTK_LIST (gpe->dir_list), directory_list); @@ -261,8 +261,7 @@ gimp_path_editor_new (gchar *filesel_title, * Note that you have to g_free() the returned string. * * Returns: The search path the user has selected in the path editor. - * - */ + **/ gchar * gimp_path_editor_get_path (GimpPathEditor *gpe) { diff --git a/libgimpwidgets/gimppatheditor.h b/libgimpwidgets/gimppatheditor.h index dcdedb6463..a1c50030e2 100644 --- a/libgimpwidgets/gimppatheditor.h +++ b/libgimpwidgets/gimppatheditor.h @@ -69,8 +69,8 @@ struct _GimpPathEditorClass GtkType gimp_path_editor_get_type (void); -GtkWidget * gimp_path_editor_new (gchar *filesel_title, - gchar *path); +GtkWidget * gimp_path_editor_new (const gchar *filesel_title, + const gchar *path); gchar * gimp_path_editor_get_path (GimpPathEditor *gpe); diff --git a/libgimpwidgets/gimppixmap.c b/libgimpwidgets/gimppixmap.c index c35259593f..a08b6cbe81 100644 --- a/libgimpwidgets/gimppixmap.c +++ b/libgimpwidgets/gimppixmap.c @@ -31,8 +31,10 @@ static void gimp_pixmap_destroy (GtkObject *object); static void gimp_pixmap_realize (GtkWidget *widget); static void gimp_pixmap_create_from_xpm_d (GimpPixmap *pixmap); + static GtkPixmapClass *parent_class = NULL; + static void gimp_pixmap_destroy (GtkObject *object) { @@ -41,7 +43,7 @@ gimp_pixmap_destroy (GtkObject *object) g_return_if_fail (pixmap = GIMP_PIXMAP (object)); if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } static void @@ -56,7 +58,6 @@ gimp_pixmap_class_init (GimpPixmapClass *class) parent_class = gtk_type_class (gtk_pixmap_get_type ()); object_class->destroy = gimp_pixmap_destroy; - widget_class->realize = gimp_pixmap_realize; } @@ -98,8 +99,7 @@ gimp_pixmap_get_type (void) * Creates a new #GimpPixmap widget. * * Returns: A pointer to the new #GimpPixmap widget. - * - */ + **/ GtkWidget * gimp_pixmap_new (gchar **xpm_data) { @@ -119,8 +119,7 @@ gimp_pixmap_new (gchar **xpm_data) * @xpm_data: A pointer to a XPM data structure as found in XPM files. * * Sets a new image for an existing #GimpPixmap widget. - * - */ + **/ void gimp_pixmap_set (GimpPixmap *pixmap, gchar **xpm_data) @@ -162,7 +161,7 @@ static void gimp_pixmap_realize (GtkWidget *widget) { if (GTK_WIDGET_CLASS (parent_class)->realize) - (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); + GTK_WIDGET_CLASS (parent_class)->realize (widget); gimp_pixmap_create_from_xpm_d (GIMP_PIXMAP (widget)); } diff --git a/libgimpwidgets/gimppixmap.h b/libgimpwidgets/gimppixmap.h index ca10019d74..4cc9b48ae9 100644 --- a/libgimpwidgets/gimppixmap.h +++ b/libgimpwidgets/gimppixmap.h @@ -43,7 +43,7 @@ struct _GimpPixmap { GtkPixmap pixmap; - gchar **xpm_data; + gchar **xpm_data; }; struct _GimpPixmapClass diff --git a/libgimpwidgets/gimpquerybox.c b/libgimpwidgets/gimpquerybox.c index 06e2db30bb..2e5c26d433 100644 --- a/libgimpwidgets/gimpquerybox.c +++ b/libgimpwidgets/gimpquerybox.c @@ -51,50 +51,54 @@ struct _QueryBox gpointer data; }; -static QueryBox * create_query_box (gchar *title, + +static QueryBox * create_query_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkSignalFunc ok_callback, GtkSignalFunc cancel_callback, - gchar *message, - gchar *ok_button, - gchar *cancel_button, + const gchar *message, + const gchar *ok_button, + const gchar *cancel_button, GtkObject *object, - gchar *signal, + const gchar *signal, GtkSignalFunc callback, gpointer data); -static QueryBox * query_box_disconnect (gpointer data); +static QueryBox * query_box_disconnect (gpointer data); -static void string_query_box_ok_callback (GtkWidget *widget, - gpointer data); -static void int_query_box_ok_callback (GtkWidget *widget, - gpointer data); -static void double_query_box_ok_callback (GtkWidget *widget, - gpointer data); -static void size_query_box_ok_callback (GtkWidget *widget, - gpointer data); - -static void query_box_cancel_callback (GtkWidget *widget, - gpointer data); +static void string_query_box_ok_callback (GtkWidget *widget, + gpointer data); +static void int_query_box_ok_callback (GtkWidget *widget, + gpointer data); +static void double_query_box_ok_callback (GtkWidget *widget, + gpointer data); +static void size_query_box_ok_callback (GtkWidget *widget, + gpointer data); static void boolean_query_box_true_callback (GtkWidget *widget, gpointer data); static void boolean_query_box_false_callback (GtkWidget *widget, gpointer data); -/* create a generic query box without any entry widget */ +static void query_box_cancel_callback (GtkWidget *widget, + gpointer data); + + +/* + * create a generic query box without any entry widget + */ static QueryBox * -create_query_box (gchar *title, +create_query_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, GtkSignalFunc ok_callback, GtkSignalFunc cancel_callback, - gchar *message, - gchar *ok_button, - gchar *cancel_button, + const gchar *message, + const gchar *ok_button, + const gchar *cancel_button, GtkObject *object, - gchar *signal, + const gchar *signal, GtkSignalFunc callback, gpointer data) { @@ -103,6 +107,11 @@ create_query_box (gchar *title, GtkWidget *vbox = NULL; GtkWidget *label; + /* make sure the object / signal passed are valid + */ + g_return_val_if_fail (object == NULL || GTK_IS_OBJECT (object), NULL); + g_return_val_if_fail (object == NULL || signal != NULL, NULL); + query_box = g_new (QueryBox, 1); qbox = gimp_dialog_new (title, "query_box", @@ -117,13 +126,26 @@ create_query_box (gchar *title, NULL); - /* if we are associated with an object, connect to the provided signal */ - if (object && GTK_IS_OBJECT (object) && signal) - gtk_signal_connect (GTK_OBJECT (object), signal, - GTK_SIGNAL_FUNC (query_box_cancel_callback), - query_box); + gtk_signal_connect (GTK_OBJECT (qbox), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &query_box->qbox); + + /* if we are associated with an object, connect to the provided signal + */ + if (object) + { + gtk_signal_connect (GTK_OBJECT (object), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &query_box->object); + + gtk_signal_connect (GTK_OBJECT (object), signal, + GTK_SIGNAL_FUNC (query_box_cancel_callback), + query_box); + } else - object = NULL; + { + object = NULL; + } if (message) { @@ -160,16 +182,15 @@ create_query_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_string_box (gchar *title, +gimp_query_string_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, - gchar *initial, + const gchar *help_data, + const gchar *message, + const gchar *initial, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryStringCallback callback, gpointer data) { @@ -184,6 +205,9 @@ gimp_query_string_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + entry = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0); if (initial) @@ -211,18 +235,17 @@ gimp_query_string_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_int_box (gchar *title, +gimp_query_int_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gint initial, gint lower, gint upper, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryIntCallback callback, gpointer data) { @@ -238,6 +261,9 @@ gimp_query_int_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + spinbutton = gimp_spin_button_new (&adjustment, initial, lower, upper, 1, 10, 0, 1, 0); @@ -266,19 +292,18 @@ gimp_query_int_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_double_box (gchar *title, +gimp_query_double_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, gint digits, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryDoubleCallback callback, gpointer data) { @@ -294,6 +319,9 @@ gimp_query_double_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + spinbutton = gimp_spin_button_new (&adjustment, initial, lower, upper, 1, 10, 0, 1, digits); @@ -327,13 +355,12 @@ gimp_query_double_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_size_box (gchar *title, +gimp_query_size_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, @@ -342,7 +369,7 @@ gimp_query_size_box (gchar *title, gdouble resolution, gboolean dot_for_dot, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQuerySizeCallback callback, gpointer data) { @@ -357,6 +384,9 @@ gimp_query_size_box (gchar *title, object, signal, callback, data); + if (! query_box) + return NULL; + sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 100, GIMP_SIZE_ENTRY_UPDATE_SIZE); if (dot_for_dot) @@ -394,18 +424,17 @@ gimp_query_size_box (gchar *title, * @data: The callback's user data. * * Returns: A pointer to the new #GtkDialog. - * - */ + **/ GtkWidget * -gimp_query_boolean_box (gchar *title, +gimp_query_boolean_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, gboolean eek, - gchar *message, - gchar *true_button, - gchar *false_button, + const gchar *message, + const gchar *true_button, + const gchar *false_button, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryBooleanCallback callback, gpointer data) { @@ -422,7 +451,10 @@ gimp_query_boolean_box (gchar *title, object, signal, callback, data); - if (!eek) + if (! query_box) + return NULL; + + if (! eek) return query_box->qbox; hbox = gtk_hbox_new (FALSE, 10); @@ -441,6 +473,11 @@ gimp_query_boolean_box (gchar *title, return query_box->qbox; } + +/* + * private functions + */ + static QueryBox * query_box_disconnect (gpointer data) { @@ -474,7 +511,8 @@ string_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -497,7 +535,8 @@ int_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -520,7 +559,8 @@ double_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -544,21 +584,8 @@ size_query_box_ok_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); - - g_free (query_box); -} - -static void -query_box_cancel_callback (GtkWidget *widget, - gpointer data) -{ - QueryBox *query_box; - - query_box = query_box_disconnect (data); - - /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -576,7 +603,8 @@ boolean_query_box_true_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } @@ -594,7 +622,23 @@ boolean_query_box_false_callback (GtkWidget *widget, query_box->data); /* Destroy the box */ - gtk_widget_destroy (query_box->qbox); + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); + + g_free (query_box); +} + +static void +query_box_cancel_callback (GtkWidget *widget, + gpointer data) +{ + QueryBox *query_box; + + query_box = query_box_disconnect (data); + + /* Destroy the box */ + if (query_box->qbox) + gtk_widget_destroy (query_box->qbox); g_free (query_box); } diff --git a/libgimpwidgets/gimpquerybox.h b/libgimpwidgets/gimpquerybox.h index 0ffe60b128..78d2efb79c 100644 --- a/libgimpwidgets/gimpquerybox.h +++ b/libgimpwidgets/gimpquerybox.h @@ -55,45 +55,45 @@ typedef void (* GimpQueryBooleanCallback) (GtkWidget *query_box, gpointer data); /* some simple query dialogs */ -GtkWidget * gimp_query_string_box (gchar *title, +GtkWidget * gimp_query_string_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, - gchar *initial, + const gchar *help_data, + const gchar *message, + const gchar *initial, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryStringCallback callback, gpointer data); -GtkWidget * gimp_query_int_box (gchar *title, +GtkWidget * gimp_query_int_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - char *message, + const gchar *help_data, + const gchar *message, gint initial, gint lower, gint upper, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryIntCallback callback, gpointer data); -GtkWidget * gimp_query_double_box (gchar *title, +GtkWidget * gimp_query_double_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, gint digits, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryDoubleCallback callback, gpointer data); -GtkWidget * gimp_query_size_box (gchar *title, +GtkWidget * gimp_query_size_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, - gchar *message, + const gchar *help_data, + const gchar *message, gdouble initial, gdouble lower, gdouble upper, @@ -102,19 +102,19 @@ GtkWidget * gimp_query_size_box (gchar *title, gdouble resolution, gboolean dot_for_dot, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQuerySizeCallback callback, gpointer data); -GtkWidget * gimp_query_boolean_box (gchar *title, +GtkWidget * gimp_query_boolean_box (const gchar *title, GimpHelpFunc help_func, - gchar *help_data, + const gchar *help_data, gboolean eek, - gchar *message, - gchar *true_button, - gchar *false_button, + const gchar *message, + const gchar *true_button, + const gchar *false_button, GtkObject *object, - gchar *signal, + const gchar *signal, GimpQueryBooleanCallback callback, gpointer data); diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index 52e46cc29e..ccc548ac4d 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -237,7 +237,7 @@ gimp_size_entry_get_type (void) GtkWidget * gimp_size_entry_new (gint number_of_fields, GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, @@ -457,7 +457,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse, */ void gimp_size_entry_attach_label (GimpSizeEntry *gse, - gchar *text, + const gchar *text, gint row, gint column, gfloat alignment) diff --git a/libgimpwidgets/gimpsizeentry.h b/libgimpwidgets/gimpsizeentry.h index d3b5935c12..29d7aab1d3 100644 --- a/libgimpwidgets/gimpsizeentry.h +++ b/libgimpwidgets/gimpsizeentry.h @@ -82,7 +82,7 @@ GtkType gimp_size_entry_get_type (void); GtkWidget * gimp_size_entry_new (gint number_of_fields, GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gboolean show_refval, @@ -94,7 +94,7 @@ void gimp_size_entry_add_field (GimpSizeEntry *gse, GtkSpinButton *refval_spinbutton); void gimp_size_entry_attach_label (GimpSizeEntry *gse, - gchar *text, + const gchar *text, gint row, gint column, gfloat alignment); diff --git a/libgimpwidgets/gimpunitmenu.c b/libgimpwidgets/gimpunitmenu.c index b61ee26b3b..2e60a3ed88 100644 --- a/libgimpwidgets/gimpunitmenu.c +++ b/libgimpwidgets/gimpunitmenu.c @@ -31,10 +31,10 @@ /* private functions */ -static const gchar * gimp_unit_menu_build_string (gchar *format, - GimpUnit unit); -static void gimp_unit_menu_callback (GtkWidget *widget, - gpointer data); +static const gchar * gimp_unit_menu_build_string (const gchar *format, + GimpUnit unit); +static void gimp_unit_menu_callback (GtkWidget *widget, + gpointer data); enum { @@ -144,11 +144,11 @@ gimp_unit_menu_get_type (void) * */ GtkWidget * -gimp_unit_menu_new (gchar *format, - GimpUnit unit, - gboolean show_pixels, - gboolean show_percent, - gboolean show_custom) +gimp_unit_menu_new (const gchar *format, + GimpUnit unit, + gboolean show_pixels, + gboolean show_percent, + gboolean show_custom) { GimpUnitMenu *gum; GtkWidget *menu; @@ -375,8 +375,8 @@ print (gchar *buf, } static const gchar * -gimp_unit_menu_build_string (gchar *format, - GimpUnit unit) +gimp_unit_menu_build_string (const gchar *format, + GimpUnit unit) { static gchar buffer[64]; gint i = 0; diff --git a/libgimpwidgets/gimpunitmenu.h b/libgimpwidgets/gimpunitmenu.h index 1b688bbad1..50aed98fad 100644 --- a/libgimpwidgets/gimpunitmenu.h +++ b/libgimpwidgets/gimpunitmenu.h @@ -67,7 +67,7 @@ struct _GimpUnitMenuClass GtkType gimp_unit_menu_get_type (void); -GtkWidget * gimp_unit_menu_new (gchar *format, +GtkWidget * gimp_unit_menu_new (const gchar *format, GimpUnit unit, gboolean show_pixels, gboolean show_percent, diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c index 4a35b4023d..ba42dc51ab 100644 --- a/libgimpwidgets/gimpwidgets.c +++ b/libgimpwidgets/gimpwidgets.c @@ -1,5 +1,5 @@ /* LIBGIMP - The GIMP Library - * Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * * gimpwidgets.c * Copyright (C) 2000 Michael Natterer @@ -44,13 +44,12 @@ * @...: A #NULL terminated @va_list describing the menu items. * * Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only). - * - */ + **/ GtkWidget * gimp_option_menu_new (gboolean menu_only, /* specify menu items as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * gpointer user_data, @@ -64,7 +63,7 @@ gimp_option_menu_new (gboolean menu_only, GtkWidget *menuitem; /* menu item variables */ - gchar *label; + const gchar *label; GtkSignalFunc callback; gpointer data; gpointer user_data; @@ -79,8 +78,10 @@ gimp_option_menu_new (gboolean menu_only, /* create the menu items */ initial_index = 0; + va_start (args, menu_only); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); + for (i = 0; label; i++) { callback = va_arg (args, GtkSignalFunc); @@ -116,7 +117,7 @@ gimp_option_menu_new (gboolean menu_only, if (active) initial_index = i; - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -146,18 +147,17 @@ gimp_option_menu_new (gboolean menu_only, * @...: A #NULL terminated @va_list describing the menu items. * * Returns: A #GtkOptionMenu or a #GtkMenu (depending on @menu_only). - * - */ + **/ GtkWidget * -gimp_option_menu_new2 (gboolean menu_only, - GtkSignalFunc menu_item_callback, - gpointer data, - gpointer initial, /* user_data */ +gimp_option_menu_new2 (gboolean menu_only, + GtkSignalFunc menu_item_callback, + gpointer data, + gpointer initial, /* user_data */ /* specify menu items as va_list: - * gchar *label, - * gpointer user_data, - * GtkWidget **widget_ptr, + * const gchar *label, + * gpointer user_data, + * GtkWidget **widget_ptr, */ ...) @@ -166,9 +166,9 @@ gimp_option_menu_new2 (gboolean menu_only, GtkWidget *menuitem; /* menu item variables */ - gchar *label; - gpointer user_data; - GtkWidget **widget_ptr; + const gchar *label; + gpointer user_data; + GtkWidget **widget_ptr; va_list args; gint i; @@ -178,8 +178,10 @@ gimp_option_menu_new2 (gboolean menu_only, /* create the menu items */ initial_index = 0; + va_start (args, initial); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); + for (i = 0; label; i++) { user_data = va_arg (args, gpointer); @@ -212,7 +214,7 @@ gimp_option_menu_new2 (gboolean menu_only, if (user_data == initial) initial_index = i; - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -237,8 +239,7 @@ gimp_option_menu_new2 (gboolean menu_only, * @option_menu: A #GtkOptionMenu as returned by gimp_option_menu_new() or * gimp_option_menu_new2(). * @user_data: The @user_data of the menu item you want to select. - * - */ + **/ void gimp_option_menu_set_history (GtkOptionMenu *option_menu, gpointer user_data) @@ -276,14 +277,13 @@ gimp_option_menu_set_history (GtkOptionMenu *option_menu, * @...: A #NULL terminated @va_list describing the radio buttons. * * Returns: A #GtkFrame or #GtkVbox (depending on @in_frame). - * - */ + **/ GtkWidget * gimp_radio_group_new (gboolean in_frame, - gchar *frame_title, + const gchar *frame_title, /* specify radio buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * gpointer user_data, @@ -298,7 +298,7 @@ gimp_radio_group_new (gboolean in_frame, GSList *group; /* radio button variables */ - gchar *label; + const gchar *label; GtkSignalFunc callback; gpointer data; gpointer user_data; @@ -313,7 +313,7 @@ gimp_radio_group_new (gboolean in_frame, /* create the radio buttons */ va_start (args, frame_title); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); while (label) { callback = va_arg (args, GtkSignalFunc); @@ -345,7 +345,7 @@ gimp_radio_group_new (gboolean in_frame, gtk_widget_show (button); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -376,19 +376,18 @@ gimp_radio_group_new (gboolean in_frame, * @...: A #NULL terminated @va_list describing the radio buttons. * * Returns: A #GtkFrame or #GtkVbox (depending on @in_frame). - * - */ + **/ GtkWidget * -gimp_radio_group_new2 (gboolean in_frame, - gchar *frame_title, - GtkSignalFunc radio_button_callback, - gpointer data, - gpointer initial, /* user_data */ +gimp_radio_group_new2 (gboolean in_frame, + const gchar *frame_title, + GtkSignalFunc radio_button_callback, + gpointer data, + gpointer initial, /* user_data */ /* specify radio buttons as va_list: - * gchar *label, - * gpointer user_data, - * GtkWidget **widget_ptr, + * const gchar *label, + * gpointer user_data, + * GtkWidget **widget_ptr, */ ...) @@ -398,9 +397,9 @@ gimp_radio_group_new2 (gboolean in_frame, GSList *group; /* radio button variables */ - gchar *label; - gpointer user_data; - GtkWidget **widget_ptr; + const gchar *label; + gpointer user_data; + GtkWidget **widget_ptr; va_list args; @@ -410,7 +409,8 @@ gimp_radio_group_new2 (gboolean in_frame, /* create the radio buttons */ va_start (args, initial); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); + while (label) { user_data = va_arg (args, gpointer); @@ -439,7 +439,7 @@ gimp_radio_group_new2 (gboolean in_frame, gtk_widget_show (button); - label = va_arg (args, gchar*); + label = va_arg (args, const gchar *); } va_end (args); @@ -476,8 +476,7 @@ gimp_radio_group_new2 (gboolean in_frame, * setting a standard minimun horizontal size. * * Returns: A #GtkSpinbutton and it's #GtkAdjustment. - * - */ + **/ GtkWidget * gimp_spin_button_new (GtkObject **adjustment, /* return value */ gfloat value, @@ -545,26 +544,25 @@ gimp_scale_entry_unconstrained_adjustment_callback (GtkAdjustment *adjustment, * have to initialize GIMP's help system with gimp_help_init() before using it. * * Returns: The #GtkSpinButton's #GtkAdjustment. - * - */ + **/ GtkObject * -gimp_scale_entry_new (GtkTable *table, - gint column, - gint row, - gchar *text, - gint scale_usize, - gint spinbutton_usize, - gfloat value, - gfloat lower, - gfloat upper, - gfloat step_increment, - gfloat page_increment, - guint digits, - gboolean constrain, - gfloat unconstrained_lower, - gfloat unconstrained_upper, - gchar *tooltip, - gchar *help_data) +gimp_scale_entry_new (GtkTable *table, + gint column, + gint row, + const gchar *text, + gint scale_usize, + gint spinbutton_usize, + gfloat value, + gfloat lower, + gfloat upper, + gfloat step_increment, + gfloat page_increment, + guint digits, + gboolean constrain, + gfloat unconstrained_lower, + gfloat unconstrained_upper, + const gchar *tooltip, + const gchar *help_data) { GtkWidget *label; GtkWidget *scale; @@ -682,8 +680,7 @@ gimp_random_seed_toggle_update (GtkWidget *widget, * * Returns: A #GtkHBox containing a #GtkSpinButton for the random seed and * a #GtkToggleButton for toggling the @use_time behaviour. - * - */ + **/ GtkWidget * gimp_random_seed_new (gint *seed, gint *use_time, @@ -845,11 +842,10 @@ gimp_coordinates_callback (GtkWidget *widget, * Returns: A #GimpSizeEntry with two fields for x/y coordinates/sizes with * a #GimpChainButton attached to constrain either the two fields' * values or the ratio between them. - * - */ + **/ GtkWidget * gimp_coordinates_new (GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, @@ -858,7 +854,7 @@ gimp_coordinates_new (GimpUnit unit, gboolean chainbutton_active, gboolean chain_constrains_ratio, - gchar *xlabel, + const gchar *xlabel, gdouble x, gdouble xres, gdouble lower_boundary_x, @@ -866,7 +862,7 @@ gimp_coordinates_new (GimpUnit unit, gdouble xsize_0, /* % */ gdouble xsize_100, /* % */ - gchar *ylabel, + const gchar *ylabel, gdouble y, gdouble yres, gdouble lower_boundary_y, @@ -993,7 +989,7 @@ gimp_mem_size_unit_callback (GtkWidget *widget, * @adjustment: The adjustment containing the memsize and it's limits. * * Returns: A #GtkHBox with a #GtkSpinButton and a #GtkOptionMenu. - */ + **/ GtkWidget * gimp_mem_size_entry_new (GtkAdjustment *adjustment) { @@ -1063,11 +1059,10 @@ gimp_mem_size_entry_new (GtkAdjustment *adjustment) * @text: An optional text which will appear right of the pixmap. * * Returns: A #GtkButton with a #GimpPixmap and an optional #GtkLabel. - * - */ + **/ GtkWidget * -gimp_pixmap_button_new (gchar **xpm_data, - gchar *text) +gimp_pixmap_button_new (gchar **xpm_data, + const gchar *text) { GtkWidget *button; GtkWidget *pixmap; @@ -1126,8 +1121,7 @@ gimp_pixmap_button_new (gchar **xpm_data, * This function can also set the sensitive state according to the toggle * button's inverse "active" state by attaching widgets with the * "inverse_sensitive" key. - * - */ + **/ void gimp_toggle_button_sensitive_update (GtkToggleButton *toggle_button) { @@ -1162,8 +1156,7 @@ gimp_toggle_button_sensitive_update (GtkToggleButton *toggle_button) * gtk_toggle_button_get_active(). * * Note that this function calls gimp_toggle_button_sensitive_update(). - * - */ + **/ void gimp_toggle_button_update (GtkWidget *widget, gpointer data) @@ -1187,8 +1180,7 @@ gimp_toggle_button_update (GtkWidget *widget, * (#gint) gtk_object_get_user_data(). * * Note that this function calls gimp_toggle_button_sensitive_update(). - * - */ + **/ void gimp_radio_button_update (GtkWidget *widget, gpointer data) @@ -1210,8 +1202,7 @@ gimp_radio_button_update (GtkWidget *widget, * @widget: A #GtkMenuItem. * @data: A pointer to a #gint variable which will store the value of * (#gint) gtk_object_get_user_data(). - * - */ + **/ void gimp_menu_item_update (GtkWidget *widget, gpointer data) @@ -1231,8 +1222,7 @@ gimp_menu_item_update (GtkWidget *widget, * * Note that the #GtkAdjustment's value (which is a #gfloat) will be rounded * with (#gint) (value + 0.5). - * - */ + **/ void gimp_int_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1251,8 +1241,7 @@ gimp_int_adjustment_update (GtkAdjustment *adjustment, * * Note that the #GtkAdjustment's value (which is a #gfloat) will be rounded * with (#guint) (value + 0.5). - * - */ + **/ void gimp_uint_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1268,8 +1257,7 @@ gimp_uint_adjustment_update (GtkAdjustment *adjustment, * @adjustment: A #GtkAdjustment. * @data: A pointer to a #gfloat varaiable which willl store the adjustment's * value. - * - */ + **/ void gimp_float_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1285,8 +1273,7 @@ gimp_float_adjustment_update (GtkAdjustment *adjustment, * @adjustment: A #GtkAdjustment. * @data: A pointer to a #gdouble variable which will store the adjustment's * value. - * - */ + **/ void gimp_double_adjustment_update (GtkAdjustment *adjustment, gpointer data) @@ -1310,8 +1297,7 @@ gimp_double_adjustment_update (GtkAdjustment *adjustment, * * See gimp_toggle_button_sensitive_update() for a description of how * to set up the list. - * - */ + **/ void gimp_unit_menu_update (GtkWidget *widget, gpointer data) @@ -1355,18 +1341,17 @@ gimp_unit_menu_update (GtkWidget *widget, * * Note that the @label_text can be #NULL and that the widget will be attached * starting at (@column + 1) in this case, too. - * - */ + **/ void -gimp_table_attach_aligned (GtkTable *table, - gint column, - gint row, - gchar *label_text, - gfloat xalign, - gfloat yalign, - GtkWidget *widget, - gint colspan, - gboolean left_align) +gimp_table_attach_aligned (GtkTable *table, + gint column, + gint row, + const gchar *label_text, + gfloat xalign, + gfloat yalign, + GtkWidget *widget, + gint colspan, + gboolean left_align) { if (label_text) { diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h index 8e818637a4..d629581591 100644 --- a/libgimpwidgets/gimpwidgets.h +++ b/libgimpwidgets/gimpwidgets.h @@ -65,10 +65,10 @@ void gimp_option_menu_set_history (GtkOptionMenu *option_menu, gpointer user_data); GtkWidget * gimp_radio_group_new (gboolean in_frame, - gchar *frame_title, + const gchar *frame_title, /* specify radio buttons as va_list: - * gchar *label, + * const gchar *label, * GtkSignalFunc callback, * gpointer data, * gpointer user_data, @@ -79,13 +79,13 @@ GtkWidget * gimp_radio_group_new (gboolean in_frame, ...); GtkWidget * gimp_radio_group_new2 (gboolean in_frame, - gchar *frame_title, + const gchar *frame_title, GtkSignalFunc radio_button_callback, gpointer data, gpointer initial, /* user_data */ /* specify radio buttons as va_list: - * gchar *label, + * const gchar *label, * gpointer user_data, * GtkWidget **widget_ptr, */ @@ -122,7 +122,7 @@ GtkWidget * gimp_spin_button_new (/* return value: */ GtkObject * gimp_scale_entry_new (GtkTable *table, gint column, gint row, - gchar *text, + const gchar *text, gint scale_usize, gint spinbutton_usize, gfloat value, @@ -134,8 +134,8 @@ GtkObject * gimp_scale_entry_new (GtkTable *table, gboolean constrain, gfloat unconstrained_lower, gfloat unconstrained_upper, - gchar *tooltip, - gchar *help_data); + const gchar *tooltip, + const gchar *help_data); #define GIMP_RANDOM_SEED_SPINBUTTON(hbox) \ GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT( hbox), "spinbutton")) @@ -157,7 +157,7 @@ GtkWidget * gimp_random_seed_new (gint *seed, "chainbutton")) GtkWidget * gimp_coordinates_new (GimpUnit unit, - gchar *unit_format, + const gchar *unit_format, gboolean menu_show_pixels, gboolean menu_show_percent, gint spinbutton_usize, @@ -166,7 +166,7 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit, gboolean chainbutton_active, gboolean chain_constrains_ratio, - gchar *xlabel, + const gchar *xlabel, gdouble x, gdouble xres, gdouble lower_boundary_x, @@ -174,7 +174,7 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit, gdouble xsize_0, /* % */ gdouble xsize_100, /* % */ - gchar *ylabel, + const gchar *ylabel, gdouble y, gdouble yres, gdouble lower_boundary_y, @@ -197,7 +197,7 @@ GtkWidget * gimp_mem_size_entry_new (GtkAdjustment *adjustment); GtkWidget * gimp_pixmap_button_new (gchar **xpm_data, - gchar *text); + const gchar *text); /* * Standard Callbacks @@ -236,7 +236,7 @@ void gimp_unit_menu_update (GtkWidget *widget, void gimp_table_attach_aligned (GtkTable *table, gint column, gint row, - gchar *label_text, + const gchar *label_text, gfloat xalign, gfloat yalign, GtkWidget *widget, diff --git a/plug-ins/common/tga.c b/plug-ins/common/tga.c index 8f963f72c1..36d3b528cc 100644 --- a/plug-ins/common/tga.c +++ b/plug-ins/common/tga.c @@ -113,8 +113,11 @@ static TgaSaveInterface tsint = /* TRUEVISION-XFILE magic signature string */ -static guchar magic[18] = { 0x54, 0x52, 0x55, 0x45, 0x56, 0x49, 0x53, - 0x49, 0x4f, 0x4e, 0x2d, 0x58, 0x46, 0x49, 0x4c, 0x45, 0x2e, 0x0 }; +static guchar magic[18] = +{ + 0x54, 0x52, 0x55, 0x45, 0x56, 0x49, 0x53, 0x49, 0x4f, + 0x4e, 0x2d, 0x58, 0x46, 0x49, 0x4c, 0x45, 0x2e, 0x0 +}; typedef struct tga_info_struct { @@ -172,22 +175,24 @@ typedef struct tga_info_struct /* Declare some local functions. */ static void query (void); -static void run (gchar *name, - gint nparams, +static void run (gchar *name, + gint nparams, GimpParam *param, - gint *nreturn_vals, + gint *nreturn_vals, GimpParam **return_vals); -static gint32 load_image (gchar *filename); -static gint save_image (gchar *filename, - gint32 image_ID, - gint32 drawable_ID); +static gint32 load_image (gchar *filename); +static gint save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID); static gint save_dialog (void); static void save_ok_callback (GtkWidget *widget, gpointer data); -static gint32 ReadImage (FILE *fp, tga_info *info, gchar *filename); +static gint32 ReadImage (FILE *fp, + tga_info *info, + gchar *filename); GimpPlugInInfo PLUG_IN_INFO = @@ -261,17 +266,17 @@ query (void) } static void -run (gchar *name, - gint nparams, +run (gchar *name, + gint nparams, GimpParam *param, - gint *nreturn_vals, + gint *nreturn_vals, GimpParam **return_vals) { - static GimpParam values[2]; - GimpRunModeType run_mode; - GimpPDBStatusType status = GIMP_PDB_SUCCESS; - gint32 image_ID; - gint32 drawable_ID; + static GimpParam values[2]; + GimpRunModeType run_mode; + GimpPDBStatusType status = GIMP_PDB_SUCCESS; + gint32 image_ID; + gint32 drawable_ID; GimpExportReturnType export = GIMP_EXPORT_CANCEL; #ifdef PROFILE @@ -404,11 +409,13 @@ run (gchar *name, static gint32 load_image (gchar *filename) { - FILE *fp; - gchar *name_buf; - tga_info info; - guchar header[18], footer[26], extension[495]; - long offset; + FILE *fp; + gchar *name_buf; + tga_info info; + guchar header[18]; + guchar footer[26]; + guchar extension[495]; + long offset; gint32 image_ID = -1; @@ -424,21 +431,21 @@ load_image (gchar *filename) g_free (name_buf); /* Check the footer. */ - if (fseek (fp, -26L, SEEK_END) - || fread (footer, sizeof (footer), 1, fp) != 1) + if (fseek (fp, -26L, SEEK_END) || + fread (footer, sizeof (footer), 1, fp) != 1) { g_message (_("TGA: Cannot read footer from \"%s\"\n"), filename); return -1; } /* Check the signature. */ - if (memcmp (footer + 8, magic, sizeof(magic)) == 0) + if (memcmp (footer + 8, magic, sizeof (magic)) == 0) { offset= footer[0] + (footer[1] * 256) + (footer[2] * 65536) + (footer[3] * 16777216); if (fseek (fp, offset, SEEK_SET) || - fread (extension, sizeof (extension), 1, fp) != 1) + fread (extension, sizeof (extension), 1, fp) != 1) { g_message (_("TGA: Cannot read extension from \"%s\"\n"), filename); return -1; @@ -454,54 +461,55 @@ load_image (gchar *filename) return -1; } - switch (header[2]) { + switch (header[2]) + { case 1: - info.imageType= TGA_TYPE_MAPPED; - info.imageCompression= TGA_COMP_NONE; + info.imageType = TGA_TYPE_MAPPED; + info.imageCompression = TGA_COMP_NONE; break; case 2: - info.imageType= TGA_TYPE_COLOR; - info.imageCompression= TGA_COMP_NONE; + info.imageType = TGA_TYPE_COLOR; + info.imageCompression = TGA_COMP_NONE; break; case 3: - info.imageType= TGA_TYPE_GRAY; - info.imageCompression= TGA_COMP_NONE; + info.imageType = TGA_TYPE_GRAY; + info.imageCompression = TGA_COMP_NONE; break; case 9: - info.imageType= TGA_TYPE_MAPPED; - info.imageCompression= TGA_COMP_RLE; + info.imageType = TGA_TYPE_MAPPED; + info.imageCompression = TGA_COMP_RLE; break; case 10: - info.imageType= TGA_TYPE_COLOR; - info.imageCompression= TGA_COMP_RLE; + info.imageType = TGA_TYPE_COLOR; + info.imageCompression = TGA_COMP_RLE; break; case 11: - info.imageType= TGA_TYPE_GRAY; - info.imageCompression= TGA_COMP_RLE; + info.imageType = TGA_TYPE_GRAY; + info.imageCompression = TGA_COMP_RLE; break; default: - info.imageType= 0; - } + info.imageType = 0; + } - info.idLength= header[0]; - info.colorMapType= header[1]; + info.idLength = header[0]; + info.colorMapType = header[1]; - info.colorMapIndex= header[3] + header[4] * 256; - info.colorMapLength= header[5] + header[6] * 256; - info.colorMapSize= header[7]; + info.colorMapIndex = header[3] + header[4] * 256; + info.colorMapLength = header[5] + header[6] * 256; + info.colorMapSize = header[7]; - info.xOrigin= header[8] + header[9] * 256; - info.yOrigin= header[10] + header[11] * 256; - info.width= header[12] + header[13] * 256; - info.height= header[14] + header[15] * 256; + info.xOrigin = header[8] + header[9] * 256; + info.yOrigin = header[10] + header[11] * 256; + info.width = header[12] + header[13] * 256; + info.height = header[14] + header[15] * 256; - info.bpp= header[16]; - info.bytes= (info.bpp + 7) / 8; - info.alphaBits= header[17] & 0x0f; /* Just the low 4 bits */ - info.flipHoriz= (header[17] & 0x10) ? 1 : 0; - info.flipVert= (header[17] & 0x20) ? 0 : 1; + info.bpp = header[16]; + info.bytes = (info.bpp + 7) / 8; + info.alphaBits = header[17] & 0x0f; /* Just the low 4 bits */ + info.flipHoriz = (header[17] & 0x10) ? 1 : 0; + info.flipVert = (header[17] & 0x20) ? 0 : 1; switch (info.imageType) { @@ -576,201 +584,283 @@ load_image (gchar *filename) return image_ID; } -static void rle_write(FILE *fp, guchar *buffer, guint width, guint bytes) { - int repeat= 0, direct= 0; - guchar *from= buffer; - int x; +static void +rle_write (FILE *fp, + guchar *buffer, + guint width, + guint bytes) +{ + gint repeat = 0; + gint direct = 0; + guchar *from = buffer; + gint x; - for (x= 1; x < width; ++x) { - if (memcmp(buffer, buffer + bytes, bytes)) { - /* next pixel is different */ - if (repeat) { - putc(128 + repeat, fp); - fwrite(from, bytes, 1, fp); - from= buffer+ bytes; /* point to first different pixel */ - repeat= 0; direct= 0; - } else { - direct+= 1; - } - } else { - /* next pixel is the same */ - if (direct) { - putc(direct - 1, fp); - fwrite(from, bytes, direct, fp); - from= buffer; /* point to first identical pixel */ - direct= 0; repeat= 1; - } else { - repeat+= 1; - } - } - if (repeat == 128) { - putc(255, fp); - fwrite(from, bytes, 1, fp); - from= buffer+ bytes; - direct= 0; repeat= 0; - } else if (direct == 128) { - putc(127, fp); - fwrite(from, bytes, direct, fp); - from= buffer+ bytes; - direct= 0; repeat= 0; - } - buffer+= bytes; - } + for (x = 1; x < width; ++x) + { + if (memcmp (buffer, buffer + bytes, bytes)) + { + /* next pixel is different */ + if (repeat) + { + putc (128 + repeat, fp); + fwrite (from, bytes, 1, fp); + from = buffer+ bytes; /* point to first different pixel */ + repeat = 0; + direct = 0; + } + else + { + direct += 1; + } + } + else + { + /* next pixel is the same */ + if (direct) + { + putc (direct - 1, fp); + fwrite (from, bytes, direct, fp); + from = buffer; /* point to first identical pixel */ + direct = 0; + repeat = 1; + } + else + { + repeat += 1; + } + } - if (repeat > 0) { - putc(128 + repeat, fp); - fwrite(from, bytes, 1, fp); - } else { - putc(direct, fp); - fwrite(from, bytes, direct + 1, fp); - } + if (repeat == 128) + { + putc (255, fp); + fwrite (from, bytes, 1, fp); + from = buffer+ bytes; + direct = 0; + repeat = 0; + } + else if (direct == 128) + { + putc (127, fp); + fwrite (from, bytes, direct, fp); + from = buffer+ bytes; + direct = 0; + repeat = 0; + } + buffer += bytes; + } + + if (repeat > 0) + { + putc (128 + repeat, fp); + fwrite (from, bytes, 1, fp); + } + else + { + putc (direct, fp); + fwrite (from, bytes, direct + 1, fp); + } } -static int rle_read(FILE *fp, guchar *buffer, tga_info *info) { - - static int repeat= 0, direct= 0; +static gint +rle_read (FILE *fp, + guchar *buffer, + tga_info *info) +{ + static gint repeat = 0; + static gint direct = 0; static guchar sample[4]; - int head; - int x, k; + gint head; + gint x, k; - for (x= 0; x < info->width; x++) { + for (x = 0; x < info->width; x++) + { + if (repeat == 0 && direct == 0) + { + head = getc (fp); - if (repeat == 0 && direct == 0) { - head= getc(fp); - if (head == EOF) { - return EOF; - } else if (head >= 128) { - repeat= head - 127; - if (fread(sample, info->bytes, 1, fp) < 1) - return EOF; - } else { - direct= head + 1; - } + if (head == EOF) + { + return EOF; + } + else if (head >= 128) + { + repeat = head - 127; + + if (fread (sample, info->bytes, 1, fp) < 1) + return EOF; + } + else + { + direct = head + 1; + } + } + + if (repeat > 0) + { + for (k = 0; k < info->bytes; ++k) + { + buffer[k] = sample[k]; + } + + repeat--; + } + else /* direct > 0 */ + { + if (fread (buffer, info->bytes, 1, fp) < 1) + return EOF; + + direct--; + } + + buffer += info->bytes; } - if (repeat > 0) { - for (k = 0; k < info->bytes; ++k) { - buffer[k]= sample[k]; - } - repeat--; - } else /* direct > 0 */ { - if (fread(buffer, info->bytes, 1, fp) < 1) - return EOF; - direct--; - } - - buffer+= info->bytes; - } - return 0; } -static void flip_line(guchar *buffer, tga_info *info) { - guchar temp, *alt; - int x, s; +static void +flip_line (guchar *buffer, + tga_info *info) +{ + guchar temp; + guchar *alt; + gint x, s; - alt= buffer + (info->bytes * (info->width - 1)); - for (x= 0; x * 2 <= info->width; x++) { - for (s= 0; s < info->bytes; ++s) { - temp= buffer[s]; - buffer[s]= alt[s]; - alt[s]= temp; + alt = buffer + (info->bytes * (info->width - 1)); + + for (x = 0; x * 2 <= info->width; x++) + { + for (s = 0; s < info->bytes; ++s) + { + temp = buffer[s]; + buffer[s] = alt[s]; + alt[s] = temp; + } + + buffer += info->bytes; + alt -= info->bytes; } - - buffer+= info->bytes; - alt-= info->bytes; - } - } /* Some people write 16-bit RGB TGA files. The spec would probably allow 27-bit RGB too, for what it's worth, but I won't fix that unless someone actually provides an existence proof */ -static void upsample(guchar *dest, guchar *src, guint width, guint bytes) { - int x; - - for (x= 0; x < width; x++) { +static void +upsample (guchar *dest, + guchar *src, + guint width, + guint bytes) +{ + gint x; - dest[0]= ((src[1] << 1) & 0xf8); - dest[0]+= (dest[0] >> 5); + for (x = 0; x < width; x++) + { + dest[0] = ((src[1] << 1) & 0xf8); + dest[0] += (dest[0] >> 5); - dest[1]= ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6); - dest[1]+= (dest[1] >> 5); + dest[1] = ((src[0] & 0xe0) >> 2) + ((src[1] & 0x03) << 6); + dest[1] += (dest[1] >> 5); - dest[2]= ((src[0] << 3) & 0xf8); - dest[2]+= (dest[2] >> 5); + dest[2] = ((src[0] << 3) & 0xf8); + dest[2] += (dest[2] >> 5); - dest+= 3; - src+= bytes; - } + dest += 3; + src += bytes; + } } -static void bgr2rgb(guchar *dest, guchar *src, - guint width, guint bytes, guint alpha) { +static void +bgr2rgb (guchar *dest, + guchar *src, + guint width, + guint bytes, + guint alpha) +{ guint x; - if (alpha) { - for (x= 0; x < width; x++) { - *(dest++)= src[2]; - *(dest++)= src[1]; - *(dest++)= src[0]; - *(dest++)= src[3]; + if (alpha) + { + for (x = 0; x < width; x++) + { + *(dest++) = src[2]; + *(dest++) = src[1]; + *(dest++) = src[0]; + *(dest++) = src[3]; - src+= bytes; + src += bytes; + } } - } else { - for (x= 0; x < width; x++) { - *(dest++)= src[2]; - *(dest++)= src[1]; - *(dest++)= src[0]; + else + { + for (x = 0; x < width; x++) + { + *(dest++) = src[2]; + *(dest++) = src[1]; + *(dest++) = src[0]; - src+= bytes; + src += bytes; + } } - } } -static void read_line(FILE *fp, guchar *row, guchar *buffer, - tga_info *info, GimpDrawable *drawable) { - - if (info->imageCompression == TGA_COMP_RLE) { - rle_read(fp, buffer, info); - } else { - fread(buffer, info->bytes, info->width, fp); - } - - if (info->flipHoriz) { - flip_line(buffer, info); - } - - if (info->imageType == TGA_TYPE_COLOR) { - if (info->bpp == 16) { - upsample(row, buffer, info->width, info->bytes); - } else { - bgr2rgb(row, buffer,info->width,info->bytes,info->alphaBits); +static void +read_line (FILE *fp, + guchar *row, + guchar *buffer, + tga_info *info, + GimpDrawable *drawable) +{ + if (info->imageCompression == TGA_COMP_RLE) + { + rle_read (fp, buffer, info); + } + else + { + fread (buffer, info->bytes, info->width, fp); + } + + if (info->flipHoriz) + { + flip_line (buffer, info); + } + + if (info->imageType == TGA_TYPE_COLOR) + { + if (info->bpp == 16) + { + upsample (row, buffer, info->width, info->bytes); + } + else + { + bgr2rgb (row, buffer,info->width,info->bytes,info->alphaBits); + } + } + else + { + memcpy (row, buffer, info->width * drawable->bpp); } - } else { - memcpy(row, buffer, info->width * drawable->bpp); - } } static gint32 -ReadImage (FILE *fp, tga_info *info, char *filename) +ReadImage (FILE *fp, + tga_info *info, + gchar *filename) { static gint32 image_ID; - gint32 layer_ID; + gint32 layer_ID; - GimpPixelRgn pixel_rgn; - GimpDrawable *drawable; - guchar *data, *buffer, *row; - GimpImageType dtype; - GimpImageBaseType itype; - int i, y; + GimpPixelRgn pixel_rgn; + GimpDrawable *drawable; + guchar *data, *buffer, *row; + GimpImageType dtype = 0; + GimpImageBaseType itype = 0; + gint i, y; - int max_tileheight, tileheight; + gint max_tileheight, tileheight; - guint cmap_bytes; + guint cmap_bytes; guchar tga_cmap[4 * 256], gimp_cmap[3 * 256]; switch (info->imageType) @@ -901,148 +991,182 @@ ReadImage (FILE *fp, tga_info *info, char *filename) static gint -save_image (gchar *filename, gint32 image_ID, gint32 drawable_ID) +save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID) { - GimpPixelRgn pixel_rgn; - GimpDrawable *drawable; - GimpImageType dtype; - int width, height; + GimpPixelRgn pixel_rgn; + GimpDrawable *drawable; + GimpImageType dtype; + gint width; + gint height; - FILE *fp; - guchar *name_buf; - int tileheight, out_bpp, status= TRUE; - int i, row; + FILE *fp; + guchar *name_buf; + gint tileheight; + gint out_bpp = 0; + gboolean status = TRUE; + gint i, row; - guchar header[18], footer[26]; - guchar *pixels, *data; + guchar header[18]; + guchar footer[26]; + guchar *pixels; + guchar *data; - guint num_colors; - guchar *gimp_cmap; + guint num_colors; + guchar *gimp_cmap = NULL; - drawable = gimp_drawable_get(drawable_ID); - dtype = gimp_drawable_type(drawable_ID); - width = drawable->width; + drawable = gimp_drawable_get (drawable_ID); + dtype = gimp_drawable_type (drawable_ID); + + width = drawable->width; height = drawable->height; - name_buf = g_strdup_printf( _("Saving %s:"), filename); - gimp_progress_init((char *)name_buf); - g_free(name_buf); + name_buf = g_strdup_printf (_("Saving %s:"), filename); + gimp_progress_init ((gchar *)name_buf); + g_free (name_buf); - if((fp = fopen(filename, "wb")) == NULL) + if ((fp = fopen (filename, "wb")) == NULL) { g_message ("TGA: can't create \"%s\"\n", filename); return FALSE; } - header[0]= 0; /* No image identifier / description */ + header[0] = 0; /* No image identifier / description */ - if (dtype == GIMP_INDEXED_IMAGE || dtype == GIMP_INDEXEDA_IMAGE) { - gimp_cmap= gimp_image_get_cmap(image_ID, &num_colors); - header[1]= 1; /* cmap type */ - header[2]= (tsvals.rle) ? 9 : 1; - header[3]= header[4]= 0; /* no offset */ - header[5]= num_colors % 256; - header[6]= num_colors / 256; - header[7]= 24; /* cmap size / bits */ - } else { - header[1]= 0; - if (dtype == GIMP_RGB_IMAGE || dtype == GIMP_RGBA_IMAGE) { - header[2]= (tsvals.rle) ? 10 : 2; - } else { - header[2]= (tsvals.rle) ? 11 : 3; + if (dtype == GIMP_INDEXED_IMAGE || dtype == GIMP_INDEXEDA_IMAGE) + { + gimp_cmap = gimp_image_get_cmap (image_ID, &num_colors); + + header[1] = 1; /* cmap type */ + header[2] = (tsvals.rle) ? 9 : 1; + header[3] = header[4]= 0; /* no offset */ + header[5] = num_colors % 256; + header[6] = num_colors / 256; + header[7] = 24; /* cmap size / bits */ + } + else + { + header[1]= 0; + + if (dtype == GIMP_RGB_IMAGE || dtype == GIMP_RGBA_IMAGE) + { + header[2]= (tsvals.rle) ? 10 : 2; + } + else + { + header[2]= (tsvals.rle) ? 11 : 3; + } + + header[3] = header[4] = header[5] = header[6] = header[7] = 0; } - header[3]= header[4]= header[5]= header[6]= header[7]= 0; - } + header[8] = header[9] = 0; /* xorigin */ + header[10] = header[11] = 0; /* yorigin */ - header[8]= header[9]= 0; /* xorigin */ - header[10]= header[11]= 0; /* yorigin */ + header[12] = width % 256; + header[13] = width / 256; - header[12]= width % 256; - header[13]= width / 256; + header[14] = height % 256; + header[15] = height / 256; - header[14]= height % 256; - header[15]= height / 256; + switch (dtype) + { + case GIMP_INDEXED_IMAGE: + case GIMP_GRAY_IMAGE: + case GIMP_INDEXEDA_IMAGE: + out_bpp = 1; + header[16] = 8; /* bpp */ + header[17] = 0x20; /* alpha + orientation */ + break; - switch (dtype) { - case GIMP_INDEXED_IMAGE: - case GIMP_GRAY_IMAGE: - case GIMP_INDEXEDA_IMAGE: - out_bpp= 1; - header[16]= 8; /* bpp */ - header[17]= 0x20; /* alpha + orientation */ - break; + case GIMP_GRAYA_IMAGE: + out_bpp = 2; + header[16] = 16; /* bpp */ + header[17] = 0x28; /* alpha + orientation */ + break; - case GIMP_GRAYA_IMAGE: - out_bpp= 2; - header[16]= 16; /* bpp */ - header[17]= 0x28; /* alpha + orientation */ - break; - case GIMP_RGB_IMAGE: - out_bpp= 3; - header[16]= 24; /* bpp */ - header[17]= 0x20; /* alpha + orientation */ - break; - case GIMP_RGBA_IMAGE: - out_bpp= 4; - header[16]= 32; /* bpp */ - header[17]= 0x28; /* alpha + orientation */ - break; - } + case GIMP_RGB_IMAGE: + out_bpp = 3; + header[16] = 24; /* bpp */ + header[17] = 0x20; /* alpha + orientation */ + break; + + case GIMP_RGBA_IMAGE: + out_bpp = 4; + header[16] = 32; /* bpp */ + header[17] = 0x28; /* alpha + orientation */ + break; + } /* write header to front of file */ - fwrite(header, sizeof(header), 1, fp); + fwrite (header, sizeof (header), 1, fp); - if (dtype == GIMP_INDEXED_IMAGE || dtype == GIMP_INDEXEDA_IMAGE) { - /* write out palette */ - for (i= 0; i < num_colors; ++i) { - fputc(gimp_cmap[(i * 3) + 2], fp); - fputc(gimp_cmap[(i * 3) + 1], fp); - fputc(gimp_cmap[(i * 3) + 0], fp); + if (dtype == GIMP_INDEXED_IMAGE || dtype == GIMP_INDEXEDA_IMAGE) + { + /* write out palette */ + for (i= 0; i < num_colors; ++i) + { + fputc (gimp_cmap[(i * 3) + 2], fp); + fputc (gimp_cmap[(i * 3) + 1], fp); + fputc (gimp_cmap[(i * 3) + 0], fp); + } } - } /* Allocate a new set of pixels. */ tileheight = gimp_tile_height (); - gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, width, height, FALSE, FALSE); + gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, width, height, FALSE, FALSE); - pixels= g_new(guchar, width * drawable->bpp); - data= g_new(guchar, width * out_bpp); + pixels = g_new (guchar, width * drawable->bpp); + data = g_new (guchar, width * out_bpp); - for (row= 0; row < height; ++row) + for (row = 0; row < height; ++row) { - gimp_pixel_rgn_get_rect(&pixel_rgn, pixels, 0, row, width, 1); + gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, row, width, 1); - if (dtype == GIMP_RGB_IMAGE) { - bgr2rgb(data, pixels, width, drawable->bpp, 0); - } else if (dtype == GIMP_RGBA_IMAGE) { - bgr2rgb(data, pixels, width, drawable->bpp, 1); - } else if (dtype == GIMP_INDEXEDA_IMAGE) { - for (i= 0; i < width; ++i) { - data[i]= pixels[i*2]; - } - } else { - memcpy(data, pixels, width * drawable->bpp); - } + if (dtype == GIMP_RGB_IMAGE) + { + bgr2rgb(data, pixels, width, drawable->bpp, 0); + } + else if (dtype == GIMP_RGBA_IMAGE) + { + bgr2rgb(data, pixels, width, drawable->bpp, 1); + } + else if (dtype == GIMP_INDEXEDA_IMAGE) + { + for (i = 0; i < width; ++i) + { + data[i]= pixels[i*2]; + } + } + else + { + memcpy (data, pixels, width * drawable->bpp); + } - if (tsvals.rle) { - rle_write(fp, data, width, out_bpp); - } else { - fwrite(data, width * out_bpp, 1, fp); - } - gimp_progress_update ((double) row / (double) height); + if (tsvals.rle) + { + rle_write (fp, data, width, out_bpp); + } + else + { + fwrite (data, width * out_bpp, 1, fp); + } + + gimp_progress_update ((gdouble) row / (gdouble) height); } gimp_drawable_detach (drawable); g_free (data); /* footer must be the last thing written to file */ - memset(footer, 0, 8); /* No extensions, no developer directory */ - memcpy(footer + 8, magic, sizeof(magic)); /* magic signature */ - fwrite(footer, sizeof(footer), 1, fp); + memset (footer, 0, 8); /* No extensions, no developer directory */ + memcpy (footer + 8, magic, sizeof (magic)); /* magic signature */ + fwrite (footer, sizeof (footer), 1, fp); fclose (fp); + return status; } diff --git a/plug-ins/imagemap/imap_main.c b/plug-ins/imagemap/imap_main.c index e2c8296987..8ac04579ce 100644 --- a/plug-ins/imagemap/imap_main.c +++ b/plug-ins/imagemap/imap_main.c @@ -1251,13 +1251,13 @@ factory_menu_zoom_out(void) static Command_t* factory_zoom_in(void) { - return command_new(zoom_in); + return command_new((void (*)(void)) zoom_in); } static Command_t* factory_zoom_out(void) { - return command_new(zoom_out); + return command_new((void (*)(void)) zoom_out); } static Command_t*