Commit 8a3842bd authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed palette_inport_dialog_show() and palette_import_dialog_destroy()

2006-09-03  Michael Natterer  <mitch@gimp.org>

	* app/dialogs/palette-import-dialog.[ch]: removed
	palette_inport_dialog_show() and palette_import_dialog_destroy()
	and don't remember the created dialog internally. Instead, made
	palette_import_dialog_new() public.

	* app/dialogs/dialogs.c
	* app/dialogs/dialogs-constructors.[ch]: register it with the
	toplevel dialog factory as singleton toplevel.

	* app/actions/palettes-commands.c (palettes_import_cmd_callback):
	use the dialog factory to create the palette import dialog.
parent 6a073e68
2006-09-03 Michael Natterer <mitch@gimp.org>
* app/dialogs/palette-import-dialog.[ch]: removed
palette_inport_dialog_show() and palette_import_dialog_destroy()
and don't remember the created dialog internally. Instead, made
palette_import_dialog_new() public.
* app/dialogs/dialogs.c
* app/dialogs/dialogs-constructors.[ch]: register it with the
toplevel dialog factory as singleton toplevel.
* app/actions/palettes-commands.c (palettes_import_cmd_callback):
use the dialog factory to create the palette import dialog.
2006-09-03 Michael Natterer <mitch@gimp.org>
 
* app/paint/gimpsourceoptions.[ch] (struct GimpSourceOptions): added
......
......@@ -31,11 +31,13 @@
#include "widgets/gimpcontainertreeview.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpview.h"
#include "dialogs/palette-import-dialog.h"
#include "dialogs/dialogs.h"
#include "actions.h"
#include "palettes-commands.h"
#include "gimp-intl.h"
......@@ -54,12 +56,12 @@ void
palettes_import_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContext *context;
context = gimp_container_view_get_context (editor->view);
GtkWidget *widget;
return_if_no_widget (widget, data);
palette_import_dialog_show (context->gimp);
gimp_dialog_factory_dialog_new (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-palette-import-dialog", -1, TRUE);
}
void
......
......@@ -77,6 +77,7 @@
#include "image-new-dialog.h"
#include "keyboard-shortcuts-dialog.h"
#include "module-dialog.h"
#include "palette-import-dialog.h"
#include "preferences-dialog.h"
#include "quit-dialog.h"
#include "tips-dialog.h"
......@@ -151,6 +152,14 @@ dialogs_module_get (GimpDialogFactory *factory,
return module_dialog_new (context->gimp);
}
GtkWidget *
dialogs_palette_import_get (GimpDialogFactory *factory,
GimpContext *context,
gint view_size)
{
return palette_import_dialog_new (context);
}
GtkWidget *
dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context,
......
......@@ -43,6 +43,9 @@ GtkWidget * dialogs_keyboard_shortcuts_get (GimpDialogFactory *factory,
GtkWidget * dialogs_module_get (GimpDialogFactory *factory,
GimpContext *context,
gint view_size);
GtkWidget * dialogs_palette_import_get (GimpDialogFactory *factory,
GimpContext *context,
gint view_size);
GtkWidget * dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context,
gint view_size);
......
......@@ -96,6 +96,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
dialogs_keyboard_shortcuts_get, TRUE, TRUE, TRUE),
TOPLEVEL ("gimp-module-dialog",
dialogs_module_get, TRUE, TRUE, TRUE),
TOPLEVEL ("gimp-palette-import-dialog",
dialogs_palette_import_get, TRUE, TRUE, TRUE),
TOPLEVEL ("gimp-tips-dialog",
dialogs_tips_get, TRUE, FALSE, FALSE),
TOPLEVEL ("gimp-about-dialog",
......
......@@ -93,7 +93,7 @@ struct _ImportDialog
};
static ImportDialog * palette_import_dialog_new (Gimp *gimp);
static void palette_import_free (ImportDialog *dialog);
static void palette_import_response (GtkWidget *widget,
gint response_id,
ImportDialog *dialog);
......@@ -131,36 +131,10 @@ static void palette_import_image_remove (GimpContainer *container,
static void palette_import_make_palette (ImportDialog *dialog);
static ImportDialog *the_import_dialog = NULL;
/* public functions */
void
palette_import_dialog_show (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (! the_import_dialog)
the_import_dialog = palette_import_dialog_new (gimp);
gtk_window_present (GTK_WINDOW (the_import_dialog->dialog));
}
void
palette_import_dialog_destroy (void)
{
if (the_import_dialog)
palette_import_response (NULL, GTK_RESPONSE_CANCEL, the_import_dialog);
}
/* private functions */
/* the palette import dialog constructor ***********************************/
static ImportDialog *
palette_import_dialog_new (Gimp *gimp)
GtkWidget *
palette_import_dialog_new (GimpContext *context)
{
ImportDialog *dialog;
GimpGradient *gradient;
......@@ -173,13 +147,15 @@ palette_import_dialog_new (Gimp *gimp)
GtkSizeGroup *size_group;
GSList *group = NULL;
gradient = gimp_context_get_gradient (gimp_get_user_context (gimp));
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
gradient = gimp_context_get_gradient (context);
dialog = g_new0 (ImportDialog, 1);
dialog->import_type = GRADIENT_IMPORT;
dialog->context = gimp_context_new (gimp, "Palette Import",
gimp_get_user_context (gimp));
dialog->context = gimp_context_new (context->gimp, "Palette Import",
context);
dialog->dialog = gimp_dialog_new (_("Import a New Palette"),
"gimp-palette-import", NULL, 0,
......@@ -201,6 +177,9 @@ palette_import_dialog_new (Gimp *gimp)
GTK_RESPONSE_CANCEL,
-1);
g_object_set_data_full (G_OBJECT (dialog->dialog), "palette-import-dialog",
dialog, (GDestroyNotify) palette_import_free);
g_signal_connect (dialog->dialog, "response",
G_CALLBACK (palette_import_response),
dialog);
......@@ -260,7 +239,7 @@ palette_import_dialog_new (Gimp *gimp)
dialog);
gtk_widget_set_sensitive (dialog->image_radio,
! gimp_container_is_empty (gimp->images));
! gimp_container_is_empty (context->gimp->images));
dialog->sample_merged_toggle =
gtk_check_button_new_with_mnemonic (_("Sample _Merged"));
......@@ -301,7 +280,7 @@ palette_import_dialog_new (Gimp *gimp)
/* The gradient menu */
dialog->gradient_combo =
gimp_container_combo_box_new (gimp->gradient_factory->container,
gimp_container_combo_box_new (context->gimp->gradient_factory->container,
dialog->context, 24, 1);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
NULL, 0.0, 0.5, dialog->gradient_combo, 1, FALSE);
......@@ -309,7 +288,8 @@ palette_import_dialog_new (Gimp *gimp)
/* The image menu */
dialog->image_combo =
gimp_container_combo_box_new (gimp->images, dialog->context, 24, 1);
gimp_container_combo_box_new (context->gimp->images, dialog->context,
24, 1);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
NULL, 0.0, 0.5, dialog->image_combo, 1, FALSE);
gtk_size_group_add_widget (size_group, dialog->image_combo);
......@@ -396,7 +376,7 @@ palette_import_dialog_new (Gimp *gimp)
gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
gtk_widget_show (abox);
dialog->preview = gimp_view_new_full_by_types (gimp_get_user_context (gimp),
dialog->preview = gimp_view_new_full_by_types (dialog->context,
GIMP_TYPE_VIEW,
GIMP_TYPE_PALETTE,
192, 192, 1,
......@@ -417,10 +397,10 @@ palette_import_dialog_new (Gimp *gimp)
/* keep the dialog up-to-date */
g_signal_connect (gimp->images, "add",
g_signal_connect (context->gimp->images, "add",
G_CALLBACK (palette_import_image_add),
dialog);
g_signal_connect (gimp->images, "remove",
g_signal_connect (context->gimp->images, "remove",
G_CALLBACK (palette_import_image_remove),
dialog);
......@@ -436,21 +416,17 @@ palette_import_dialog_new (Gimp *gimp)
palette_import_grad_callback (dialog->gradient_radio, dialog);
return dialog;
return dialog->dialog;
}
/* the palette import response callback ************************************/
/* private functions */
static void
palette_import_response (GtkWidget *widget,
gint response_id,
ImportDialog *dialog)
palette_import_free (ImportDialog *dialog)
{
Gimp *gimp = dialog->context->gimp;
palette_import_image_changed (dialog->context, NULL, dialog);
g_signal_handlers_disconnect_by_func (gimp->images,
palette_import_image_add,
dialog);
......@@ -458,6 +434,26 @@ palette_import_response (GtkWidget *widget,
palette_import_image_remove,
dialog);
if (dialog->palette)
g_object_unref (dialog->palette);
g_object_unref (dialog->context);
g_free (dialog);
}
/* the palette import response callback ************************************/
static void
palette_import_response (GtkWidget *widget,
gint response_id,
ImportDialog *dialog)
{
Gimp *gimp = dialog->context->gimp;
palette_import_image_changed (dialog->context, NULL, dialog);
if (dialog->palette)
{
if (response_id == GTK_RESPONSE_OK)
......@@ -470,15 +466,9 @@ palette_import_response (GtkWidget *widget,
gimp_container_add (gimp->palette_factory->container,
GIMP_OBJECT (dialog->palette));
}
g_object_unref (dialog->palette);
}
g_object_unref (dialog->context);
gtk_widget_destroy (dialog->dialog);
g_free (dialog);
the_import_dialog = NULL;
}
......
......@@ -20,8 +20,7 @@
#define __PALETTE_IMPORT_H__
void palette_import_dialog_show (Gimp *gimp);
void palette_import_dialog_destroy (void);
GtkWidget * palette_import_dialog_new (GimpContext *context);
#endif /* __PALETTE_IMPORT_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment