app/actions/images-commands.[ch] made some public functions private or

2004-10-15  Michael Natterer  <mitch@gimp.org>

	* app/actions/images-commands.[ch]
	* app/actions/templates-commands.[ch]: made some public functions
	private or removed them entirely by folding their code into their
	callers. They used to be passed as function pointers to widgets in
	the pre action-based dialog buttons era.
This commit is contained in:
Michael Natterer 2004-10-15 15:13:53 +00:00 committed by Michael Natterer
parent 1aaa68ee7d
commit ee66d409d7
5 changed files with 106 additions and 103 deletions

View File

@ -1,3 +1,11 @@
2004-10-15 Michael Natterer <mitch@gimp.org>
* app/actions/images-commands.[ch]
* app/actions/templates-commands.[ch]: made some public functions
private or removed them entirely by folding their code into their
callers. They used to be passed as function pointers to widgets in
the pre action-based dialog buttons era.
2004-10-15 Michael Natterer <mitch@gimp.org> 2004-10-15 Michael Natterer <mitch@gimp.org>
* app/dialogs/quit-dialog.c: raise the image's displays on * app/dialogs/quit-dialog.c: raise the image's displays on

View File

@ -53,7 +53,17 @@ images_raise_views_cmd_callback (GtkAction *action,
if (image && gimp_container_have (container, GIMP_OBJECT (image))) if (image && gimp_container_have (container, GIMP_OBJECT (image)))
{ {
images_raise_views (image); GList *list;
for (list = GIMP_LIST (image->gimp->displays)->list;
list;
list = g_list_next (list))
{
GimpDisplay *display = list->data;
if (display->gimage == image)
gtk_window_present (GTK_WINDOW (display->shell));
}
} }
} }
@ -97,21 +107,3 @@ images_delete_image_cmd_callback (GtkAction *action,
g_object_unref (image); g_object_unref (image);
} }
} }
void
images_raise_views (GimpImage *gimage)
{
GList *list;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
for (list = GIMP_LIST (gimage->gimp->displays)->list;
list;
list = g_list_next (list))
{
GimpDisplay *display = list->data;
if (display->gimage == gimage)
gtk_window_present (GTK_WINDOW (display->shell));
}
}

View File

@ -27,7 +27,5 @@ void images_new_view_cmd_callback (GtkAction *action,
void images_delete_image_cmd_callback (GtkAction *action, void images_delete_image_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void images_raise_views (GimpImage *gimage);
#endif /* __IMAGES_COMMANDS_H__ */ #endif /* __IMAGES_COMMANDS_H__ */

View File

@ -50,6 +50,33 @@
#include "gimp-intl.h" #include "gimp-intl.h"
typedef struct _GimpTemplateDeleteData GimpTemplateDeleteData;
struct _GimpTemplateDeleteData
{
GimpContainer *container;
GimpTemplate *template;
};
/* local function prototypes */
static void templates_new_template_dialog (Gimp *gimp,
GtkWidget *parent);
static void templates_new_template_response (GtkWidget *widget,
gint response_id,
GtkWidget *dialog);
static void templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template,
GtkWidget *parent);
static void templates_edit_template_response (GtkWidget *widget,
gint response_id,
GtkWidget *dialog);
static void templates_delete_confirm_response (GtkWidget *dialog,
gint response_id,
GimpTemplateDeleteData *delete_data);
/* public functions */ /* public functions */
void void
@ -68,7 +95,21 @@ templates_create_image_cmd_callback (GtkAction *action,
if (template && gimp_container_have (container, GIMP_OBJECT (template))) if (template && gimp_container_have (container, GIMP_OBJECT (template)))
{ {
templates_image_new_dialog (context->gimp, template, GTK_WIDGET (editor)); GdkScreen *screen;
GtkWidget *dialog;
screen = gtk_widget_get_screen (GTK_WIDGET (editor));
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory, screen,
"gimp-image-new-dialog",
-1, FALSE);
if (dialog)
{
image_new_dialog_set (dialog, NULL, template);
gtk_window_present (GTK_WINDOW (dialog));
}
} }
} }
@ -90,7 +131,7 @@ templates_new_template_cmd_callback (GtkAction *action,
{ {
} }
templates_new_template_dialog (context->gimp, NULL, GTK_WIDGET (editor)); templates_new_template_dialog (context->gimp, GTK_WIDGET (editor));
} }
void void
@ -146,32 +187,6 @@ templates_edit_template_cmd_callback (GtkAction *action,
} }
} }
typedef struct _GimpTemplateDeleteData GimpTemplateDeleteData;
struct _GimpTemplateDeleteData
{
GimpContainer *container;
GimpTemplate *template;
};
static void
templates_delete_confirm_response (GtkWidget *dialog,
gint response_id,
GimpTemplateDeleteData *delete_data)
{
gtk_widget_destroy (dialog);
if (response_id == GTK_RESPONSE_OK)
{
if (gimp_container_have (delete_data->container,
GIMP_OBJECT (delete_data->template)))
{
gimp_container_remove (delete_data->container,
GIMP_OBJECT (delete_data->template));
}
}
}
void void
templates_delete_template_cmd_callback (GtkAction *action, templates_delete_template_cmd_callback (GtkAction *action,
gpointer data) gpointer data)
@ -223,29 +238,10 @@ templates_delete_template_cmd_callback (GtkAction *action,
} }
} }
/* private functions */
static void static void
templates_new_template_response (GtkWidget *widget,
gint response_id,
GtkWidget *dialog)
{
if (response_id == GTK_RESPONSE_OK)
{
GimpTemplate *template;
Gimp *gimp;
template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_container_add (gimp->templates, GIMP_OBJECT (template));
gimp_context_set_template (gimp_get_user_context (gimp), template);
}
gtk_widget_destroy (dialog);
}
void
templates_new_template_dialog (Gimp *gimp, templates_new_template_dialog (Gimp *gimp,
GimpTemplate *unused,
GtkWidget *parent) GtkWidget *parent)
{ {
GimpTemplate *template; GimpTemplate *template;
@ -293,28 +289,26 @@ templates_new_template_dialog (Gimp *gimp,
} }
static void static void
templates_edit_template_response (GtkWidget *widget, templates_new_template_response (GtkWidget *widget,
gint response_id, gint response_id,
GtkWidget *dialog) GtkWidget *dialog)
{ {
if (response_id == GTK_RESPONSE_OK) if (response_id == GTK_RESPONSE_OK)
{ {
GimpTemplateEditor *editor; GimpTemplate *template;
GimpTemplate *template; Gimp *gimp;
Gimp *gimp;
editor = g_object_get_data (G_OBJECT (dialog), "gimp-template-editor");
template = g_object_get_data (G_OBJECT (dialog), "gimp-template"); template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp"); gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_config_sync (GIMP_CONFIG (editor->template), gimp_container_add (gimp->templates, GIMP_OBJECT (template));
GIMP_CONFIG (template), 0); gimp_context_set_template (gimp_get_user_context (gimp), template);
} }
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
} }
void static void
templates_edit_template_dialog (Gimp *gimp, templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template, GimpTemplate *template,
GtkWidget *parent) GtkWidget *parent)
@ -363,21 +357,42 @@ templates_edit_template_dialog (Gimp *gimp,
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
void static void
templates_image_new_dialog (Gimp *gimp, templates_edit_template_response (GtkWidget *widget,
GimpTemplate *template, gint response_id,
GtkWidget *parent) GtkWidget *dialog)
{ {
GtkWidget *dialog; if (response_id == GTK_RESPONSE_OK)
dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
gtk_widget_get_screen (parent),
"gimp-image-new-dialog", -1, FALSE);
if (dialog)
{ {
image_new_dialog_set (dialog, NULL, template); GimpTemplateEditor *editor;
GimpTemplate *template;
Gimp *gimp;
gtk_window_present (GTK_WINDOW (dialog)); editor = g_object_get_data (G_OBJECT (dialog), "gimp-template-editor");
template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_config_sync (GIMP_CONFIG (editor->template),
GIMP_CONFIG (template), 0);
}
gtk_widget_destroy (dialog);
}
static void
templates_delete_confirm_response (GtkWidget *dialog,
gint response_id,
GimpTemplateDeleteData *delete_data)
{
gtk_widget_destroy (dialog);
if (response_id == GTK_RESPONSE_OK)
{
if (gimp_container_have (delete_data->container,
GIMP_OBJECT (delete_data->template)))
{
gimp_container_remove (delete_data->container,
GIMP_OBJECT (delete_data->template));
}
} }
} }

View File

@ -31,15 +31,5 @@ void templates_edit_template_cmd_callback (GtkAction *action,
void templates_delete_template_cmd_callback (GtkAction *action, void templates_delete_template_cmd_callback (GtkAction *action,
gpointer data); gpointer data);
void templates_new_template_dialog (Gimp *gimp,
GimpTemplate *unused,
GtkWidget *parent);
void templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template,
GtkWidget *parent);
void templates_image_new_dialog (Gimp *gimp,
GimpTemplate *template,
GtkWidget *parent);
#endif /* __TEMPLATES_COMMANDS_H__ */ #endif /* __TEMPLATES_COMMANDS_H__ */