2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-04-14 23:21:45 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-04-22 08:38:56 +08:00
|
|
|
* gimpdialogfactory.c
|
2001-10-18 00:11:28 +08:00
|
|
|
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
2001-04-22 08:38:56 +08:00
|
|
|
*
|
2001-04-14 23:21:45 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-24 00:25:01 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2001-07-23 06:18:01 +08:00
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2008-05-11 03:11:18 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
#include "gimpcursor.h"
|
2001-04-14 23:21:45 +08:00
|
|
|
#include "gimpdialogfactory.h"
|
2001-04-16 00:16:13 +08:00
|
|
|
#include "gimpdock.h"
|
2001-04-17 02:49:29 +08:00
|
|
|
#include "gimpdockbook.h"
|
|
|
|
#include "gimpdockable.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2003-10-10 23:59:12 +08:00
|
|
|
#include "gimpsessioninfo.h"
|
2001-04-16 00:16:13 +08:00
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
#include "gimp-log.h"
|
2002-04-17 07:03:23 +08:00
|
|
|
|
|
|
|
|
2008-05-11 03:11:18 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DOCK_ADDED,
|
|
|
|
DOCK_REMOVED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
static void gimp_dialog_factory_dispose (GObject *object);
|
|
|
|
static void gimp_dialog_factory_finalize (GObject *object);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2004-09-27 02:41:29 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_dialog_factory_default_constructor (GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry,
|
|
|
|
GimpContext *context,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size);
|
2003-10-13 19:57:50 +08:00
|
|
|
static void gimp_dialog_factory_set_widget_data (GtkWidget *dialog,
|
|
|
|
GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry);
|
2008-03-23 21:33:19 +08:00
|
|
|
static void gimp_dialog_factory_unset_widget_data (GtkWidget *dialog);
|
2003-05-04 07:02:26 +08:00
|
|
|
static gboolean gimp_dialog_factory_set_user_pos (GtkWidget *dialog,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
gpointer data);
|
2003-05-03 02:43:15 +08:00
|
|
|
static gboolean gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
GimpDialogFactory *factory);
|
2003-07-09 00:24:00 +08:00
|
|
|
static void gimp_dialog_factories_save_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
GimpConfigWriter *writer);
|
2003-07-09 00:24:00 +08:00
|
|
|
static void gimp_dialog_factories_restore_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data);
|
2003-07-09 00:24:00 +08:00
|
|
|
static void gimp_dialog_factories_clear_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data);
|
2003-07-09 00:24:00 +08:00
|
|
|
static void gimp_dialog_factories_hide_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data);
|
2003-07-09 00:24:00 +08:00
|
|
|
static void gimp_dialog_factories_show_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data);
|
2003-10-13 19:57:50 +08:00
|
|
|
static void gimp_dialog_factories_set_busy_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data);
|
2003-10-13 19:57:50 +08:00
|
|
|
static void gimp_dialog_factories_unset_busy_foreach(gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data);
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2005-05-13 05:21:38 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_dialog_factory_get_toolbox (GimpDialogFactory *toolbox_factory);
|
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpDialogFactory, gimp_dialog_factory, GIMP_TYPE_OBJECT)
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_dialog_factory_parent_class
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2008-05-11 03:11:18 +08:00
|
|
|
static guint factory_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2007-03-14 06:55:07 +08:00
|
|
|
static gboolean dialogs_shown = TRUE; /* FIXME */
|
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_factory_class_init (GimpDialogFactoryClass *klass)
|
|
|
|
{
|
2005-12-20 06:37:49 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
object_class->dispose = gimp_dialog_factory_dispose;
|
2001-08-14 22:54:22 +08:00
|
|
|
object_class->finalize = gimp_dialog_factory_finalize;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
|
|
|
klass->factories = g_hash_table_new (g_str_hash, g_str_equal);
|
2008-05-11 03:11:18 +08:00
|
|
|
|
|
|
|
factory_signals[DOCK_ADDED] =
|
|
|
|
g_signal_new ("dock-added",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpDialogFactoryClass, dock_added),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_DOCK);
|
|
|
|
|
|
|
|
factory_signals[DOCK_REMOVED] =
|
|
|
|
g_signal_new ("dock-removed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpDialogFactoryClass, dock_removed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_DOCK);
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_factory_init (GimpDialogFactory *factory)
|
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
factory->menu_factory = NULL;
|
2001-04-22 08:38:56 +08:00
|
|
|
factory->new_dock_func = NULL;
|
2004-09-27 02:41:29 +08:00
|
|
|
factory->constructor = gimp_dialog_factory_default_constructor;
|
2001-04-14 23:21:45 +08:00
|
|
|
factory->registered_dialogs = NULL;
|
2001-04-22 08:38:56 +08:00
|
|
|
factory->session_infos = NULL;
|
2001-04-17 02:49:29 +08:00
|
|
|
factory->open_dialogs = NULL;
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_factory_dispose (GObject *object)
|
|
|
|
{
|
2005-12-20 06:37:49 +08:00
|
|
|
GimpDialogFactory *factory = GIMP_DIALOG_FACTORY (object);
|
2002-03-11 02:31:42 +08:00
|
|
|
GList *list;
|
2006-05-21 23:32:20 +08:00
|
|
|
gpointer key;
|
2002-03-11 02:31:42 +08:00
|
|
|
|
2002-03-11 20:58:59 +08:00
|
|
|
/* start iterating from the beginning each time we destroyed a
|
|
|
|
* toplevel because destroying a dock may cause lots of items
|
|
|
|
* to be removed from factory->open_dialogs
|
|
|
|
*/
|
2002-03-11 02:31:42 +08:00
|
|
|
while (factory->open_dialogs)
|
|
|
|
{
|
|
|
|
for (list = factory->open_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_TOPLEVEL (list->data))
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (list->data));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-11 20:58:59 +08:00
|
|
|
/* the list being non-empty without any toplevel is an error,
|
|
|
|
* so eek and chain up
|
|
|
|
*/
|
2002-03-11 02:31:42 +08:00
|
|
|
if (! list)
|
|
|
|
{
|
2002-03-11 20:58:59 +08:00
|
|
|
g_warning ("%s: stale non-toplevel entries in factory->open_dialogs",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC);
|
2002-03-11 02:31:42 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-21 23:32:20 +08:00
|
|
|
if (factory->open_dialogs)
|
|
|
|
{
|
|
|
|
g_list_free (factory->open_dialogs);
|
|
|
|
factory->open_dialogs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (factory->session_infos)
|
|
|
|
{
|
2008-05-14 05:17:11 +08:00
|
|
|
g_list_foreach (factory->session_infos, (GFunc) g_object_unref, NULL);
|
2006-05-21 23:32:20 +08:00
|
|
|
g_list_free (factory->session_infos);
|
|
|
|
factory->session_infos = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (GIMP_OBJECT (factory)->name, "toolbox") == 0)
|
|
|
|
key = "";
|
|
|
|
else
|
|
|
|
key = GIMP_OBJECT (factory)->name;
|
|
|
|
|
|
|
|
g_hash_table_remove (GIMP_DIALOG_FACTORY_GET_CLASS (object)->factories,
|
|
|
|
key);
|
|
|
|
|
2002-03-11 02:31:42 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
static void
|
2001-08-14 22:54:22 +08:00
|
|
|
gimp_dialog_factory_finalize (GObject *object)
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
2005-12-20 06:37:49 +08:00
|
|
|
GimpDialogFactory *factory = GIMP_DIALOG_FACTORY (object);
|
2001-04-14 23:21:45 +08:00
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = factory->registered_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
2005-12-20 06:37:49 +08:00
|
|
|
GimpDialogFactoryEntry *entry = list->data;
|
2001-04-14 23:21:45 +08:00
|
|
|
|
|
|
|
g_free (entry->identifier);
|
2004-09-27 02:41:29 +08:00
|
|
|
g_free (entry->name);
|
|
|
|
g_free (entry->blurb);
|
|
|
|
g_free (entry->stock_id);
|
|
|
|
g_free (entry->help_id);
|
2007-05-23 02:08:42 +08:00
|
|
|
|
|
|
|
g_slice_free (GimpDialogFactoryEntry, entry);
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:54:22 +08:00
|
|
|
if (factory->registered_dialogs)
|
|
|
|
{
|
|
|
|
g_list_free (factory->registered_dialogs);
|
|
|
|
factory->registered_dialogs = NULL;
|
|
|
|
}
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2001-08-14 22:54:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpDialogFactory *
|
2001-04-22 08:38:56 +08:00
|
|
|
gimp_dialog_factory_new (const gchar *name,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpContext *context,
|
|
|
|
GimpMenuFactory *menu_factory,
|
|
|
|
GimpDialogNewFunc new_dock_func)
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
2003-07-09 00:24:00 +08:00
|
|
|
GimpDialogFactory *factory;
|
|
|
|
gpointer key;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2001-04-16 00:16:13 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_val_if_fail (! menu_factory || GIMP_IS_MENU_FACTORY (menu_factory),
|
2004-08-29 19:58:05 +08:00
|
|
|
NULL);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2003-07-09 00:24:00 +08:00
|
|
|
if (gimp_dialog_factory_from_name (name))
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2002-03-11 02:31:42 +08:00
|
|
|
g_warning ("%s: dialog factory \"%s\" already exists",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC, name);
|
2001-04-17 02:49:29 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
factory = g_object_new (GIMP_TYPE_DIALOG_FACTORY, NULL);
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
gimp_object_set_name (GIMP_OBJECT (factory), name);
|
|
|
|
|
2003-07-09 00:24:00 +08:00
|
|
|
/* hack to keep the toolbox on the pool position */
|
|
|
|
if (strcmp (name, "toolbox") == 0)
|
|
|
|
key = "";
|
|
|
|
else
|
|
|
|
key = GIMP_OBJECT (factory)->name;
|
|
|
|
|
|
|
|
g_hash_table_insert (GIMP_DIALOG_FACTORY_GET_CLASS (factory)->factories,
|
2004-08-29 19:58:05 +08:00
|
|
|
key, factory);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-04-22 08:38:56 +08:00
|
|
|
factory->context = context;
|
2003-01-11 01:55:53 +08:00
|
|
|
factory->menu_factory = menu_factory;
|
2001-04-22 08:38:56 +08:00
|
|
|
factory->new_dock_func = new_dock_func;
|
2001-04-14 23:21:45 +08:00
|
|
|
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
GimpDialogFactory *
|
|
|
|
gimp_dialog_factory_from_name (const gchar *name)
|
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
GimpDialogFactory *factory;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
2003-07-09 00:24:00 +08:00
|
|
|
if (! factory_class)
|
|
|
|
return NULL;
|
2003-09-09 19:35:27 +08:00
|
|
|
|
2003-07-09 00:24:00 +08:00
|
|
|
/* hack to keep the toolbox on the pool position */
|
|
|
|
if (strcmp (name, "toolbox") == 0)
|
|
|
|
name = "";
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2003-07-09 00:24:00 +08:00
|
|
|
factory =
|
|
|
|
(GimpDialogFactory *) g_hash_table_lookup (factory_class->factories, name);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
2004-09-27 02:41:29 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_set_constructor (GimpDialogFactory *factory,
|
|
|
|
GimpDialogConstructor constructor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
|
|
|
|
|
|
|
if (! constructor)
|
|
|
|
constructor = gimp_dialog_factory_default_constructor;
|
|
|
|
|
|
|
|
factory->constructor = constructor;
|
|
|
|
}
|
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
void
|
2001-07-02 22:58:02 +08:00
|
|
|
gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
|
2004-08-29 19:58:05 +08:00
|
|
|
const gchar *identifier,
|
2004-09-27 02:41:29 +08:00
|
|
|
const gchar *name,
|
|
|
|
const gchar *blurb,
|
|
|
|
const gchar *stock_id,
|
|
|
|
const gchar *help_id,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogNewFunc new_func,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size,
|
2004-08-29 19:58:05 +08:00
|
|
|
gboolean singleton,
|
|
|
|
gboolean session_managed,
|
|
|
|
gboolean remember_size,
|
|
|
|
gboolean remember_if_open)
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
|
|
|
g_return_if_fail (identifier != NULL);
|
|
|
|
|
2007-05-23 02:08:42 +08:00
|
|
|
entry = g_slice_new0 (GimpDialogFactoryEntry);
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2001-07-18 04:50:01 +08:00
|
|
|
entry->identifier = g_strdup (identifier);
|
2004-09-27 02:41:29 +08:00
|
|
|
entry->name = g_strdup (name);
|
|
|
|
entry->blurb = g_strdup (blurb);
|
|
|
|
entry->stock_id = g_strdup (stock_id);
|
|
|
|
entry->help_id = g_strdup (help_id);
|
2001-07-18 04:50:01 +08:00
|
|
|
entry->new_func = new_func;
|
2006-01-17 18:08:50 +08:00
|
|
|
entry->view_size = view_size;
|
2001-07-18 04:50:01 +08:00
|
|
|
entry->singleton = singleton ? TRUE : FALSE;
|
|
|
|
entry->session_managed = session_managed ? TRUE : FALSE;
|
|
|
|
entry->remember_size = remember_size ? TRUE : FALSE;
|
|
|
|
entry->remember_if_open = remember_if_open ? TRUE : FALSE;
|
2001-04-14 23:21:45 +08:00
|
|
|
|
|
|
|
factory->registered_dialogs = g_list_prepend (factory->registered_dialogs,
|
2004-08-29 19:58:05 +08:00
|
|
|
entry);
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
GimpDialogFactoryEntry *
|
|
|
|
gimp_dialog_factory_find_entry (GimpDialogFactory *factory,
|
2004-08-29 19:58:05 +08:00
|
|
|
const gchar *identifier)
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
|
|
|
|
for (list = factory->registered_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
2004-11-05 05:02:34 +08:00
|
|
|
GimpDialogFactoryEntry *entry = list->data;
|
2001-04-14 23:21:45 +08:00
|
|
|
|
|
|
|
if (! strcmp (identifier, entry->identifier))
|
2003-10-10 23:59:12 +08:00
|
|
|
return entry;
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpSessionInfo *
|
|
|
|
gimp_dialog_factory_find_session_info (GimpDialogFactory *factory,
|
2004-08-29 19:58:05 +08:00
|
|
|
const gchar *identifier)
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
|
|
|
|
for (list = factory->session_infos; list; list = g_list_next (list))
|
|
|
|
{
|
2004-11-05 05:02:34 +08:00
|
|
|
GimpSessionInfo *info = list->data;
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
if ((info->toplevel_entry &&
|
2004-08-29 19:58:05 +08:00
|
|
|
! strcmp (identifier, info->toplevel_entry->identifier)) ||
|
|
|
|
(info->dockable_entry &&
|
|
|
|
! strcmp (identifier, info->dockable_entry->identifier)))
|
|
|
|
{
|
|
|
|
return info;
|
|
|
|
}
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-04-24 00:58:18 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
|
2003-11-08 23:32:38 +08:00
|
|
|
GdkScreen *screen,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpContext *context,
|
|
|
|
const gchar *identifier,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size,
|
2004-09-09 17:02:26 +08:00
|
|
|
gboolean return_existing,
|
|
|
|
gboolean present)
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
GtkWidget *dialog = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
|
|
|
|
entry = gimp_dialog_factory_find_entry (factory, identifier);
|
|
|
|
|
|
|
|
if (! entry)
|
|
|
|
{
|
2002-08-27 22:53:15 +08:00
|
|
|
g_warning ("%s: no entry registered for \"%s\"",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC, identifier);
|
2001-04-18 00:00:27 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! entry->new_func)
|
|
|
|
{
|
2002-03-11 02:31:42 +08:00
|
|
|
g_warning ("%s: entry for \"%s\" has no constructor",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC, identifier);
|
2001-04-18 00:00:27 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-09 17:02:26 +08:00
|
|
|
/* a singleton dialog is always returned if it already exisits */
|
|
|
|
if (return_existing || entry->singleton)
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
|
|
|
GimpSessionInfo *info;
|
|
|
|
|
|
|
|
info = gimp_dialog_factory_find_session_info (factory, identifier);
|
|
|
|
|
|
|
|
if (info)
|
2004-08-29 19:58:05 +08:00
|
|
|
dialog = info->widget;
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/* create the dialog if it was not found */
|
2001-04-18 00:00:27 +08:00
|
|
|
if (! dialog)
|
|
|
|
{
|
2001-06-30 03:25:03 +08:00
|
|
|
GtkWidget *dock = NULL;
|
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/* If the dialog will be a dockable (factory->new_dock_func) and
|
|
|
|
* we are called from gimp_dialog_factory_dialog_raise() (! context),
|
|
|
|
* create a new dock _before_ creating the dialog.
|
|
|
|
* We do this because the new dockable needs to be created in it's
|
|
|
|
* dock's context.
|
|
|
|
*/
|
2001-06-30 03:25:03 +08:00
|
|
|
if (factory->new_dock_func && ! context)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2003-01-11 01:55:53 +08:00
|
|
|
GtkWidget *dockbook;
|
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
dock = gimp_dialog_factory_dock_new (factory, screen);
|
2003-01-11 01:55:53 +08:00
|
|
|
dockbook = gimp_dockbook_new (factory->menu_factory);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
gimp_dock_add_book (GIMP_DOCK (dock),
|
|
|
|
GIMP_DOCKBOOK (dockbook),
|
2003-01-11 01:55:53 +08:00
|
|
|
0);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/* Create the new dialog in the appropriate context which is
|
|
|
|
* - the passed context if not NULL
|
|
|
|
* - the newly created dock's context if we just created it
|
|
|
|
* - the factory's context, which happens when raising a toplevel
|
|
|
|
* dialog was the original request.
|
|
|
|
*/
|
2006-01-17 18:08:50 +08:00
|
|
|
if (view_size < GIMP_VIEW_SIZE_TINY)
|
|
|
|
view_size = entry->view_size;
|
2001-11-24 00:25:01 +08:00
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
if (context)
|
2004-09-27 02:41:29 +08:00
|
|
|
dialog = factory->constructor (factory, entry,
|
|
|
|
context,
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size);
|
2001-06-30 03:25:03 +08:00
|
|
|
else if (dock)
|
2004-09-27 02:41:29 +08:00
|
|
|
dialog = factory->constructor (factory, entry,
|
|
|
|
GIMP_DOCK (dock)->context,
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size);
|
2001-06-30 03:25:03 +08:00
|
|
|
else
|
2004-09-27 02:41:29 +08:00
|
|
|
dialog = factory->constructor (factory, entry,
|
|
|
|
factory->context,
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
if (dialog)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factory_set_widget_data (dialog, factory, entry);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
/* If we created a dock before, the newly created dialog is
|
|
|
|
* supposed to be a GimpDockable.
|
|
|
|
*/
|
|
|
|
if (dock)
|
|
|
|
{
|
|
|
|
if (GIMP_IS_DOCKABLE (dialog))
|
|
|
|
{
|
|
|
|
gimp_dock_add (GIMP_DOCK (dock), GIMP_DOCKABLE (dialog),
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
gtk_widget_show (dock);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: GimpDialogFactory is a dockable factory "
|
|
|
|
"but constructor for \"%s\" did not return a "
|
|
|
|
"GimpDockable",
|
|
|
|
G_STRFUNC, identifier);
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
2002-08-27 22:53:15 +08:00
|
|
|
gtk_widget_destroy (dock);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
dialog = NULL;
|
2002-08-27 22:53:15 +08:00
|
|
|
dock = NULL;
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-30 03:25:03 +08:00
|
|
|
else if (dock)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
|
|
|
g_warning ("%s: constructor for \"%s\" returned NULL",
|
|
|
|
G_STRFUNC, identifier);
|
2001-07-02 22:58:02 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
gtk_widget_destroy (dock);
|
2001-07-02 22:58:02 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
dock = NULL;
|
|
|
|
}
|
2001-07-02 22:58:02 +08:00
|
|
|
|
|
|
|
if (dialog)
|
2004-08-29 19:58:05 +08:00
|
|
|
gimp_dialog_factory_add_dialog (factory, dialog);
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
/* Finally, if we found an existing dialog or created a new one, raise it.
|
2001-07-02 22:58:02 +08:00
|
|
|
*/
|
2006-05-30 00:41:18 +08:00
|
|
|
if (! dialog)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_TOPLEVEL (dialog))
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
2006-05-30 00:41:18 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (dialog), screen);
|
2004-09-01 06:41:15 +08:00
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
if (present)
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_DOCKABLE (dialog))
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (dialog);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
if (dockable->dockbook && dockable->dockbook->dock)
|
|
|
|
{
|
|
|
|
GtkNotebook *notebook = GTK_NOTEBOOK (dockable->dockbook);
|
|
|
|
gint num = gtk_notebook_page_num (notebook, dialog);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
if (num != -1)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2006-05-30 00:41:18 +08:00
|
|
|
gtk_notebook_set_current_page (notebook, num);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
gimp_dockable_blink (dockable);
|
|
|
|
}
|
|
|
|
}
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
if (present)
|
|
|
|
{
|
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (dialog);
|
2005-01-18 23:18:35 +08:00
|
|
|
|
2006-05-30 00:41:18 +08:00
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
|
|
|
gtk_window_present (GTK_WINDOW (toplevel));
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return dialog;
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
2001-04-16 00:16:13 +08:00
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_dialog_new:
|
2003-11-18 20:28:15 +08:00
|
|
|
* @factory: a #GimpDialogFactory
|
|
|
|
* @screen: the #GdkScreen the dialog should appear on
|
|
|
|
* @identifier: the identifier of the dialog as registered with
|
|
|
|
* gimp_dialog_factory_register_entry()
|
2006-01-17 18:08:50 +08:00
|
|
|
* @view_size:
|
2004-09-01 06:41:15 +08:00
|
|
|
* @present: whether gtk_window_present() should be called
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2001-07-02 22:58:02 +08:00
|
|
|
* Creates a new toplevel dialog or a #GimpDockable, depending on whether
|
|
|
|
* %factory is a toplevel of dockable factory.
|
|
|
|
*
|
|
|
|
* Return value: the newly created dialog or an already existing singleton
|
|
|
|
* dialog.
|
|
|
|
**/
|
2001-04-24 00:58:18 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_factory_dialog_new (GimpDialogFactory *factory,
|
2003-11-08 23:32:38 +08:00
|
|
|
GdkScreen *screen,
|
2004-08-29 19:58:05 +08:00
|
|
|
const gchar *identifier,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size,
|
2004-09-01 06:41:15 +08:00
|
|
|
gboolean present)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
2003-11-08 23:32:38 +08:00
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
2001-04-24 00:58:18 +08:00
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
|
|
|
|
return gimp_dialog_factory_dialog_new_internal (factory,
|
2003-11-08 23:32:38 +08:00
|
|
|
screen,
|
2004-08-29 19:58:05 +08:00
|
|
|
factory->context,
|
|
|
|
identifier,
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size,
|
2004-09-09 17:02:26 +08:00
|
|
|
FALSE,
|
2004-09-01 06:41:15 +08:00
|
|
|
present);
|
2001-06-30 03:25:03 +08:00
|
|
|
}
|
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_dialog_raise:
|
2003-11-18 20:28:15 +08:00
|
|
|
* @factory: a #GimpDialogFactory
|
|
|
|
* @screen: the #GdkScreen the dialog should appear on
|
|
|
|
* @identifiers: a '|' separated list of identifiers of dialogs as
|
|
|
|
* registered with gimp_dialog_factory_register_entry()
|
2006-01-17 18:08:50 +08:00
|
|
|
* @view_size:
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2003-11-18 20:28:15 +08:00
|
|
|
* Raises any of a list of already existing toplevel dialog or
|
|
|
|
* #GimpDockable if it was already created by this %facory.
|
2001-07-02 22:58:02 +08:00
|
|
|
*
|
2003-11-18 20:28:15 +08:00
|
|
|
* Implicitly creates the first dialog in the list if none of the dialogs
|
|
|
|
* were found.
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2001-07-02 22:58:02 +08:00
|
|
|
* Return value: the raised or newly created dialog.
|
|
|
|
**/
|
2001-06-30 03:25:03 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_factory_dialog_raise (GimpDialogFactory *factory,
|
2003-11-08 23:32:38 +08:00
|
|
|
GdkScreen *screen,
|
2004-08-29 19:58:05 +08:00
|
|
|
const gchar *identifiers,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size)
|
2001-06-30 03:25:03 +08:00
|
|
|
{
|
2003-11-18 20:28:15 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
2003-11-08 23:32:38 +08:00
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
2003-11-18 20:28:15 +08:00
|
|
|
g_return_val_if_fail (identifiers != NULL, NULL);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2003-11-18 20:28:15 +08:00
|
|
|
/* If the identifier is a list, try to find a matching dialog and
|
|
|
|
* raise it. If there's no match, use the first list item.
|
|
|
|
*/
|
|
|
|
if (strchr (identifiers, '|'))
|
|
|
|
{
|
|
|
|
gchar **ids = g_strsplit (identifiers, "|", 0);
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; ids[i]; i++)
|
|
|
|
{
|
|
|
|
GimpSessionInfo *info;
|
|
|
|
|
|
|
|
info = gimp_dialog_factory_find_session_info (factory, ids[i]);
|
|
|
|
if (info && info->widget)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog = gimp_dialog_factory_dialog_new_internal (factory,
|
|
|
|
screen,
|
|
|
|
NULL,
|
|
|
|
ids[i] ? ids[i] : ids[0],
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size,
|
2004-09-09 17:02:26 +08:00
|
|
|
TRUE,
|
2003-11-18 20:28:15 +08:00
|
|
|
TRUE);
|
|
|
|
g_strfreev (ids);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialog = gimp_dialog_factory_dialog_new_internal (factory,
|
|
|
|
screen,
|
|
|
|
NULL,
|
|
|
|
identifiers,
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size,
|
2004-09-09 17:02:26 +08:00
|
|
|
TRUE,
|
2003-11-18 20:28:15 +08:00
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dialog;
|
2001-04-24 00:58:18 +08:00
|
|
|
}
|
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_dockable_new:
|
2003-11-18 20:28:15 +08:00
|
|
|
* @factory: a #GimpDialogFactory
|
|
|
|
* @dock: a #GimpDock crated by this %factory.
|
|
|
|
* @identifier: the identifier of the dialog as registered with
|
|
|
|
* gimp_dialog_factory_register_entry()
|
2006-01-17 18:08:50 +08:00
|
|
|
* @view_size:
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2001-07-02 22:58:02 +08:00
|
|
|
* Creates a new #GimpDockable in the context of the #GimpDock it will be
|
|
|
|
* added to.
|
|
|
|
*
|
|
|
|
* Implicitly raises & returns an already existing singleton dockable,
|
|
|
|
* so callers should check that dockable->dockbook is NULL before trying
|
|
|
|
* to add it to it's #GimpDockbook.
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2001-07-02 22:58:02 +08:00
|
|
|
* Return value: the newly created #GimpDockable or an already existing
|
|
|
|
* singleton dockable.
|
|
|
|
**/
|
2001-04-24 00:58:18 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_factory_dockable_new (GimpDialogFactory *factory,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDock *dock,
|
|
|
|
const gchar *identifier,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
|
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
|
|
|
|
return gimp_dialog_factory_dialog_new_internal (factory,
|
2003-11-08 23:32:38 +08:00
|
|
|
gtk_widget_get_screen (GTK_WIDGET (dock)),
|
2004-08-29 19:58:05 +08:00
|
|
|
dock->context,
|
|
|
|
identifier,
|
2006-01-17 18:08:50 +08:00
|
|
|
view_size,
|
2004-09-09 17:02:26 +08:00
|
|
|
FALSE,
|
2004-08-29 19:58:05 +08:00
|
|
|
FALSE);
|
2001-04-24 00:58:18 +08:00
|
|
|
}
|
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_dock_new:
|
|
|
|
* @factory: a #GimpDialogFacotry
|
2003-11-18 20:28:15 +08:00
|
|
|
* @screen: the #GdkScreen the dock should appear on
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2001-07-02 22:58:02 +08:00
|
|
|
* Returns a new #GimpDock in this %factory's context. We use a function
|
|
|
|
* pointer passed to this %factory's constructor instead of simply
|
|
|
|
* gimp_dock_new() because we may want different instances of
|
|
|
|
* #GimpDialogFactory create different subclasses of #GimpDock.
|
2003-09-09 19:35:27 +08:00
|
|
|
*
|
2001-07-02 22:58:02 +08:00
|
|
|
* Return value: the newly created #GimpDock.
|
|
|
|
**/
|
2001-04-22 08:38:56 +08:00
|
|
|
GtkWidget *
|
2003-11-08 23:32:38 +08:00
|
|
|
gimp_dialog_factory_dock_new (GimpDialogFactory *factory,
|
|
|
|
GdkScreen *screen)
|
2001-04-22 08:38:56 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dock;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
2003-11-08 23:32:38 +08:00
|
|
|
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
2001-04-22 08:38:56 +08:00
|
|
|
g_return_val_if_fail (factory->new_dock_func != NULL, NULL);
|
|
|
|
|
2001-11-24 00:25:01 +08:00
|
|
|
dock = factory->new_dock_func (factory, factory->context, 0);
|
2001-04-22 08:38:56 +08:00
|
|
|
|
|
|
|
if (dock)
|
2001-07-02 22:58:02 +08:00
|
|
|
{
|
2003-11-08 23:32:38 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (dock), screen);
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factory_set_widget_data (dock, factory, NULL);
|
2001-07-02 22:58:02 +08:00
|
|
|
|
|
|
|
gimp_dialog_factory_add_dialog (factory, dock);
|
|
|
|
}
|
2001-04-22 08:38:56 +08:00
|
|
|
|
|
|
|
return dock;
|
|
|
|
}
|
|
|
|
|
2001-04-16 00:16:13 +08:00
|
|
|
void
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_dialog_factory_add_dialog (GimpDialogFactory *factory,
|
2004-08-29 19:58:05 +08:00
|
|
|
GtkWidget *dialog)
|
2001-04-16 00:16:13 +08:00
|
|
|
{
|
2001-06-30 03:25:03 +08:00
|
|
|
GimpDialogFactory *dialog_factory;
|
2001-04-17 02:49:29 +08:00
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
GList *list;
|
2003-12-22 05:51:58 +08:00
|
|
|
gboolean toplevel;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-04-16 00:16:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
2001-06-30 03:25:03 +08:00
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
2001-04-16 00:16:13 +08:00
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
if (g_list_find (factory->open_dialogs, dialog))
|
2001-04-16 00:16:13 +08:00
|
|
|
{
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: dialog already registered", G_STRFUNC);
|
2001-04-16 00:16:13 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
|
2001-07-02 22:58:02 +08:00
|
|
|
{
|
2002-03-11 02:31:42 +08:00
|
|
|
g_warning ("%s: dialog was not created by a GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2001-07-02 22:58:02 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog_factory != factory)
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2002-03-11 02:31:42 +08:00
|
|
|
g_warning ("%s: dialog was created by a different GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2001-04-17 02:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-12-22 05:51:58 +08:00
|
|
|
toplevel = GTK_WIDGET_TOPLEVEL (dialog);
|
|
|
|
|
2001-07-28 00:08:05 +08:00
|
|
|
if (entry) /* dialog is a toplevel (but not a GimpDock) or a GimpDockable */
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY, "adding %s \"%s\"",
|
|
|
|
toplevel ? "toplevel" : "dockable",
|
|
|
|
entry->identifier);
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
for (list = factory->session_infos; list; list = g_list_next (list))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *info = list->data;
|
2004-08-29 19:58:05 +08:00
|
|
|
|
|
|
|
if ((info->toplevel_entry == entry) ||
|
|
|
|
(info->dockable_entry == entry))
|
|
|
|
{
|
|
|
|
if (info->widget)
|
|
|
|
{
|
|
|
|
if (entry->singleton)
|
|
|
|
{
|
|
|
|
g_warning ("%s: singleton dialog \"%s\" created twice",
|
|
|
|
G_STRFUNC, entry->identifier);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"corrupt session info: %p (widget %p)",
|
|
|
|
info, info->widget);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
return;
|
|
|
|
}
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
continue;
|
|
|
|
}
|
2001-04-19 00:39:34 +08:00
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
info->widget = dialog;
|
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"updating session info %p (widget %p) for %s \"%s\"",
|
|
|
|
info, info->widget,
|
|
|
|
toplevel ? "toplevel" : "dockable",
|
|
|
|
entry->identifier);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2008-03-24 02:36:16 +08:00
|
|
|
if (toplevel && entry->session_managed &&
|
|
|
|
! GTK_WIDGET_VISIBLE (dialog))
|
|
|
|
{
|
|
|
|
gimp_session_info_set_geometry (info);
|
|
|
|
}
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
|
|
|
|
if (! list) /* didn't find a session info */
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *info = gimp_session_info_new ();
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
info->widget = dialog;
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"creating session info %p (widget %p) for %s \"%s\"",
|
|
|
|
info, info->widget,
|
|
|
|
toplevel ? "toplevel" : "dockable",
|
|
|
|
entry->identifier);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
if (toplevel)
|
2003-05-04 07:02:26 +08:00
|
|
|
{
|
|
|
|
info->toplevel_entry = entry;
|
|
|
|
|
|
|
|
/* if we create a new session info, we never call
|
2003-11-24 20:07:29 +08:00
|
|
|
* gimp_session_info_set_geometry(), but still the
|
|
|
|
* dialog needs GDK_HINT_USER_POS so it keeps its
|
2003-05-04 07:02:26 +08:00
|
|
|
* position when hidden/shown within this(!) session.
|
|
|
|
*/
|
|
|
|
if (entry->session_managed)
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (dialog, "configure-event",
|
2003-05-04 07:02:26 +08:00
|
|
|
G_CALLBACK (gimp_dialog_factory_set_user_pos),
|
|
|
|
NULL);
|
|
|
|
}
|
2004-08-29 19:58:05 +08:00
|
|
|
else
|
2003-05-04 07:02:26 +08:00
|
|
|
{
|
|
|
|
info->dockable_entry = entry;
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
factory->session_infos = g_list_append (factory->session_infos, info);
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
2002-03-10 23:05:58 +08:00
|
|
|
else /* dialog is a GimpDock */
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY, "adding dock");
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
for (list = factory->session_infos; list; list = g_list_next (list))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *info = list->data;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
/* take the first empty slot */
|
|
|
|
if (! info->toplevel_entry &&
|
|
|
|
! info->dockable_entry &&
|
|
|
|
! info->widget)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
|
|
|
info->widget = dialog;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"updating session info %p (widget %p) for dock",
|
|
|
|
info, info->widget);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
gimp_session_info_set_geometry (info);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
|
|
|
|
if (! list) /* didn't find a session info */
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *info = gimp_session_info_new ();
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
info->widget = dialog;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"creating session info %p (widget %p) for dock",
|
|
|
|
info, info->widget);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-11-24 20:07:29 +08:00
|
|
|
/* if we create a new session info, we never call
|
|
|
|
* gimp_session_info_set_geometry(), but still the
|
|
|
|
* dialog needs GDK_HINT_USER_POS so it keeps its
|
|
|
|
* position when hidden/shown within this(!) session.
|
|
|
|
*/
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (dialog, "configure-event",
|
2003-11-24 20:07:29 +08:00
|
|
|
G_CALLBACK (gimp_dialog_factory_set_user_pos),
|
|
|
|
NULL);
|
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
factory->session_infos = g_list_append (factory->session_infos, info);
|
|
|
|
}
|
2008-05-11 03:11:18 +08:00
|
|
|
|
|
|
|
g_signal_emit (factory, factory_signals[DOCK_ADDED], 0, dialog);
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
factory->open_dialogs = g_list_prepend (factory->open_dialogs, dialog);
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_object (dialog, "destroy",
|
2001-07-25 07:11:30 +08:00
|
|
|
G_CALLBACK (gimp_dialog_factory_remove_dialog),
|
2002-08-27 22:53:15 +08:00
|
|
|
factory,
|
|
|
|
G_CONNECT_SWAPPED);
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2003-12-22 05:51:58 +08:00
|
|
|
if (entry && entry->session_managed && toplevel)
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect_object (dialog, "configure-event",
|
2003-12-22 05:51:58 +08:00
|
|
|
G_CALLBACK (gimp_dialog_factory_dialog_configure),
|
|
|
|
factory,
|
|
|
|
0);
|
2003-05-03 02:43:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_dialog_factory_add_foreign (GimpDialogFactory *factory,
|
|
|
|
const gchar *identifier,
|
|
|
|
GtkWidget *dialog)
|
|
|
|
{
|
|
|
|
GimpDialogFactory *dialog_factory;
|
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
|
|
|
g_return_if_fail (identifier != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
|
|
|
g_return_if_fail (GTK_WIDGET_TOPLEVEL (dialog));
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
|
2003-05-03 02:43:15 +08:00
|
|
|
|
|
|
|
if (dialog_factory || entry)
|
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was created by a GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2003-05-03 02:43:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = gimp_dialog_factory_find_entry (factory, identifier);
|
|
|
|
|
|
|
|
if (! entry)
|
|
|
|
{
|
|
|
|
g_warning ("%s: no entry registered for \"%s\"",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC, identifier);
|
2003-05-03 02:43:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry->new_func)
|
|
|
|
{
|
|
|
|
g_warning ("%s: entry for \"%s\" has a constructor (is not foreign)",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC, identifier);
|
2003-05-03 02:43:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factory_set_widget_data (dialog, factory, entry);
|
2003-05-03 02:43:15 +08:00
|
|
|
|
|
|
|
gimp_dialog_factory_add_dialog (factory, dialog);
|
2001-04-16 00:16:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_dialog_factory_remove_dialog (GimpDialogFactory *factory,
|
2004-08-29 19:58:05 +08:00
|
|
|
GtkWidget *dialog)
|
2001-04-16 00:16:13 +08:00
|
|
|
{
|
2002-03-10 23:05:58 +08:00
|
|
|
GimpDialogFactory *dialog_factory;
|
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
GList *list;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-04-16 00:16:13 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
2001-06-30 03:25:03 +08:00
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
2001-04-16 00:16:13 +08:00
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
if (! g_list_find (factory->open_dialogs, dialog))
|
2001-04-16 00:16:13 +08:00
|
|
|
{
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: dialog not registered", G_STRFUNC);
|
2001-04-16 00:16:13 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
factory->open_dialogs = g_list_remove (factory->open_dialogs, dialog);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
if (! (dialog_factory && (entry || GIMP_IS_DOCK (dialog))))
|
2001-07-02 22:58:02 +08:00
|
|
|
{
|
2002-03-11 02:31:42 +08:00
|
|
|
g_warning ("%s: dialog was not created by a GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2001-07-02 22:58:02 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog_factory != factory)
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2002-03-11 02:31:42 +08:00
|
|
|
g_warning ("%s: dialog was created by a different GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2001-04-17 02:49:29 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY, "removing \"%s\"",
|
|
|
|
entry ? entry->identifier : "dock");
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
for (list = factory->session_infos; list; list = g_list_next (list))
|
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *session_info = list->data;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
if (session_info->widget == dialog)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"clearing session info %p (widget %p) for \"%s\"",
|
|
|
|
session_info, session_info->widget,
|
|
|
|
entry ? entry->identifier : "dock");
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
session_info->widget = NULL;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2008-03-23 21:33:19 +08:00
|
|
|
gimp_dialog_factory_unset_widget_data (dialog);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gimp_dialog_factory_set_user_pos,
|
|
|
|
NULL);
|
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gimp_dialog_factory_remove_dialog,
|
|
|
|
factory);
|
|
|
|
|
|
|
|
if (entry && entry->session_managed && GTK_WIDGET_TOPLEVEL (dialog))
|
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gimp_dialog_factory_dialog_configure,
|
|
|
|
factory);
|
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
if (GIMP_IS_DOCK (dialog))
|
|
|
|
{
|
2008-05-11 03:11:18 +08:00
|
|
|
/* don't save session info for empty docks */
|
2004-08-29 19:58:05 +08:00
|
|
|
factory->session_infos = g_list_remove (factory->session_infos,
|
|
|
|
session_info);
|
2008-05-14 05:17:11 +08:00
|
|
|
g_object_unref (session_info);
|
2008-05-11 03:11:18 +08:00
|
|
|
|
|
|
|
g_signal_emit (factory, factory_signals[DOCK_REMOVED], 0,
|
|
|
|
dialog);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-30 04:47:29 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_show_toolbox (GimpDialogFactory *toolbox_factory)
|
|
|
|
{
|
|
|
|
GtkWidget *toolbox;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (toolbox_factory));
|
|
|
|
|
|
|
|
toolbox = gimp_dialog_factory_get_toolbox (toolbox_factory);
|
|
|
|
|
|
|
|
if (toolbox)
|
|
|
|
gtk_window_present (GTK_WINDOW (toolbox));
|
|
|
|
}
|
|
|
|
|
2007-03-14 06:55:07 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_hide_dialog (GtkWidget *dialog)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
|
|
|
g_return_if_fail (GTK_WIDGET_TOPLEVEL (dialog));
|
|
|
|
|
|
|
|
if (! gimp_dialog_factory_from_widget (dialog, NULL))
|
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was not created by a GimpDialogFactory",
|
|
|
|
G_STRFUNC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_hide (dialog);
|
|
|
|
|
|
|
|
if (! dialogs_shown)
|
|
|
|
g_object_set_data (G_OBJECT (dialog), GIMP_DIALOG_VISIBILITY_KEY,
|
|
|
|
GINT_TO_POINTER (GIMP_DIALOG_VISIBILITY_INVISIBLE));
|
|
|
|
}
|
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
void
|
2003-03-11 03:01:07 +08:00
|
|
|
gimp_dialog_factories_session_save (GimpConfigWriter *writer)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
|
2003-03-11 03:01:07 +08:00
|
|
|
g_return_if_fail (writer != NULL);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
|
|
|
g_hash_table_foreach (factory_class->factories,
|
2004-08-29 19:58:05 +08:00
|
|
|
(GHFunc) gimp_dialog_factories_save_foreach,
|
|
|
|
writer);
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_dialog_factories_session_restore (void)
|
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
|
|
|
g_hash_table_foreach (factory_class->factories,
|
2004-08-29 19:58:05 +08:00
|
|
|
(GHFunc) gimp_dialog_factories_restore_foreach,
|
|
|
|
NULL);
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factories_session_clear (void)
|
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
|
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
|
|
|
|
|
|
|
g_hash_table_foreach (factory_class->factories,
|
2004-08-29 19:58:05 +08:00
|
|
|
(GHFunc) gimp_dialog_factories_clear_foreach,
|
|
|
|
NULL);
|
2002-11-24 06:22:21 +08:00
|
|
|
}
|
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
void
|
2005-12-30 04:47:29 +08:00
|
|
|
gimp_dialog_factories_toggle (void)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2007-03-14 06:55:07 +08:00
|
|
|
if (dialogs_shown)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2007-03-14 06:55:07 +08:00
|
|
|
dialogs_shown = FALSE;
|
2001-07-20 18:07:51 +08:00
|
|
|
g_hash_table_foreach (factory_class->factories,
|
2004-08-29 19:58:05 +08:00
|
|
|
(GHFunc) gimp_dialog_factories_hide_foreach,
|
|
|
|
NULL);
|
2005-12-30 04:47:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-14 06:55:07 +08:00
|
|
|
dialogs_shown = TRUE;
|
2001-07-20 18:07:51 +08:00
|
|
|
g_hash_table_foreach (factory_class->factories,
|
2004-08-29 19:58:05 +08:00
|
|
|
(GHFunc) gimp_dialog_factories_show_foreach,
|
|
|
|
NULL);
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factories_set_busy (void)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2006-05-21 23:32:20 +08:00
|
|
|
if (factory_class)
|
|
|
|
g_hash_table_foreach (factory_class->factories,
|
|
|
|
(GHFunc) gimp_dialog_factories_set_busy_foreach,
|
|
|
|
NULL);
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factories_unset_busy (void)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GimpDialogFactoryClass *factory_class;
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2006-05-21 23:32:20 +08:00
|
|
|
if (factory_class)
|
|
|
|
g_hash_table_foreach (factory_class->factories,
|
|
|
|
(GHFunc) gimp_dialog_factories_unset_busy_foreach,
|
|
|
|
NULL);
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
static GQuark gimp_dialog_factory_key = 0;
|
|
|
|
static GQuark gimp_dialog_factory_entry_key = 0;
|
|
|
|
|
|
|
|
GimpDialogFactory *
|
|
|
|
gimp_dialog_factory_from_widget (GtkWidget *dialog,
|
|
|
|
GimpDialogFactoryEntry **entry)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (dialog), NULL);
|
|
|
|
|
|
|
|
if (! gimp_dialog_factory_key)
|
|
|
|
{
|
|
|
|
gimp_dialog_factory_key =
|
|
|
|
g_quark_from_static_string ("gimp-dialog-factory");
|
|
|
|
|
|
|
|
gimp_dialog_factory_entry_key =
|
|
|
|
g_quark_from_static_string ("gimp-dialog-factory-entry");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
*entry = g_object_get_qdata (G_OBJECT (dialog),
|
|
|
|
gimp_dialog_factory_entry_key);
|
|
|
|
|
|
|
|
return g_object_get_qdata (G_OBJECT (dialog), gimp_dialog_factory_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
/* private functions */
|
|
|
|
|
2004-09-27 02:41:29 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_dialog_factory_default_constructor (GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry,
|
|
|
|
GimpContext *context,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint view_size)
|
2004-09-27 02:41:29 +08:00
|
|
|
{
|
2006-01-17 18:08:50 +08:00
|
|
|
return entry->new_func (factory, context, view_size);
|
2004-09-27 02:41:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factory_set_widget_data (GtkWidget *dialog,
|
|
|
|
GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
|
|
|
|
|
|
|
if (! gimp_dialog_factory_key)
|
|
|
|
{
|
|
|
|
gimp_dialog_factory_key =
|
|
|
|
g_quark_from_static_string ("gimp-dialog-factory");
|
|
|
|
|
|
|
|
gimp_dialog_factory_entry_key =
|
|
|
|
g_quark_from_static_string ("gimp-dialog-factory-entry");
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_qdata (G_OBJECT (dialog), gimp_dialog_factory_key, factory);
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
g_object_set_qdata (G_OBJECT (dialog), gimp_dialog_factory_entry_key,
|
|
|
|
entry);
|
|
|
|
}
|
|
|
|
|
2008-03-23 21:33:19 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_factory_unset_widget_data (GtkWidget *dialog)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
|
|
|
|
|
|
|
if (! gimp_dialog_factory_key)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_object_set_qdata (G_OBJECT (dialog), gimp_dialog_factory_key, NULL);
|
|
|
|
g_object_set_qdata (G_OBJECT (dialog), gimp_dialog_factory_entry_key, NULL);
|
|
|
|
}
|
|
|
|
|
2003-05-04 07:02:26 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dialog_factory_set_user_pos (GtkWidget *dialog,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2003-12-22 05:51:58 +08:00
|
|
|
#ifdef DEBUG_FACTORY
|
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
|
|
|
|
gimp_dialog_factory_from_widget (dialog, &entry);
|
|
|
|
|
|
|
|
if (entry)
|
|
|
|
g_print ("%s: setting GDK_HINT_USER_POS for \"%s\"\n",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, entry->identifier);
|
2003-12-22 05:51:58 +08:00
|
|
|
#endif /* DEBUG_FACTORY */
|
|
|
|
|
2003-05-04 07:02:26 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gimp_dialog_factory_set_user_pos,
|
|
|
|
data);
|
|
|
|
|
|
|
|
gtk_window_set_geometry_hints (GTK_WINDOW (dialog), NULL, NULL,
|
2008-04-08 16:26:48 +08:00
|
|
|
GDK_HINT_MIN_SIZE |
|
2003-05-04 07:02:26 +08:00
|
|
|
GDK_HINT_USER_POS);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
GimpDialogFactory *factory)
|
|
|
|
{
|
|
|
|
GimpDialogFactory *dialog_factory;
|
|
|
|
GimpDialogFactoryEntry *entry;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
if (! g_list_find (factory->open_dialogs, dialog))
|
|
|
|
{
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: dialog not registered", G_STRFUNC);
|
2003-05-03 02:43:15 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
dialog_factory = gimp_dialog_factory_from_widget (dialog, &entry);
|
2003-05-03 02:43:15 +08:00
|
|
|
|
|
|
|
if (! dialog_factory || ! entry)
|
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was not created by a GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2003-05-03 02:43:15 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog_factory != factory)
|
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was created by a different GimpDialogFactory",
|
2004-08-29 19:58:05 +08:00
|
|
|
G_STRFUNC);
|
2003-05-03 02:43:15 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list = factory->session_infos; list; list = g_list_next (list))
|
|
|
|
{
|
2003-10-13 19:57:50 +08:00
|
|
|
GimpSessionInfo *session_info = list->data;
|
2003-05-03 02:43:15 +08:00
|
|
|
|
|
|
|
if (session_info->widget == dialog)
|
|
|
|
{
|
2003-10-10 23:59:12 +08:00
|
|
|
gimp_session_info_get_geometry (session_info);
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2008-03-23 21:33:19 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"updated session info for \"%s\" from window geometry "
|
|
|
|
"(x=%d y=%d %dx%d)",
|
|
|
|
entry->identifier,
|
|
|
|
session_info->x, session_info->y,
|
|
|
|
session_info->width, session_info->height);
|
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
break;
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2003-05-03 02:43:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-04-17 02:49:29 +08:00
|
|
|
static void
|
2003-07-09 00:24:00 +08:00
|
|
|
gimp_dialog_factories_save_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
GimpConfigWriter *writer)
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2003-10-10 23:59:12 +08:00
|
|
|
GList *infos;
|
2003-07-08 23:07:56 +08:00
|
|
|
|
2003-10-10 23:59:12 +08:00
|
|
|
for (infos = factory->session_infos; infos; infos = g_list_next (infos))
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2003-10-10 23:59:12 +08:00
|
|
|
GimpSessionInfo *info = infos->data;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2001-07-02 22:58:02 +08:00
|
|
|
/* we keep session info entries for all toplevel dialogs created
|
|
|
|
* by the factory but don't save them if they don't want to be
|
|
|
|
* managed
|
|
|
|
*/
|
2001-06-30 03:25:03 +08:00
|
|
|
if (info->dockable_entry ||
|
2004-08-29 19:58:05 +08:00
|
|
|
(info->toplevel_entry && ! info->toplevel_entry->session_managed))
|
|
|
|
continue;
|
2001-04-19 00:39:34 +08:00
|
|
|
|
2008-05-14 07:43:57 +08:00
|
|
|
if (info->widget)
|
|
|
|
gimp_session_info_get_info (info);
|
|
|
|
|
2007-05-25 04:06:34 +08:00
|
|
|
gimp_session_info_serialize (writer, info, GIMP_OBJECT (factory)->name);
|
2008-05-14 07:43:57 +08:00
|
|
|
|
|
|
|
if (info->widget)
|
|
|
|
gimp_session_info_clear_info (info);
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-09 00:24:00 +08:00
|
|
|
gimp_dialog_factories_restore_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data)
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2003-10-10 23:59:12 +08:00
|
|
|
GList *infos;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2003-10-10 23:59:12 +08:00
|
|
|
for (infos = factory->session_infos; infos; infos = g_list_next (infos))
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2003-10-10 23:59:12 +08:00
|
|
|
GimpSessionInfo *info = infos->data;
|
2001-07-02 22:58:02 +08:00
|
|
|
|
2003-10-10 23:59:12 +08:00
|
|
|
if (info->open)
|
2008-05-14 07:43:57 +08:00
|
|
|
{
|
|
|
|
gimp_session_info_restore (info, factory);
|
|
|
|
gimp_session_info_clear_info (info);
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
static void
|
2003-07-09 00:24:00 +08:00
|
|
|
gimp_dialog_factories_clear_foreach (gconstpointer key,
|
2002-11-24 06:22:21 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = factory->session_infos; list; list = g_list_next (list))
|
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *info = list->data;
|
2002-11-24 06:22:21 +08:00
|
|
|
|
|
|
|
if (info->widget)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: implement session info deletion
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
static void
|
2003-07-09 00:24:00 +08:00
|
|
|
gimp_dialog_factories_hide_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = factory->open_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
if (GTK_IS_WIDGET (list->data) && GTK_WIDGET_TOPLEVEL (list->data))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
|
|
|
GimpDialogVisibilityState visibility = GIMP_DIALOG_VISIBILITY_UNKNOWN;
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (list->data))
|
|
|
|
{
|
|
|
|
visibility = GIMP_DIALOG_VISIBILITY_VISIBLE;
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
gtk_widget_hide (GTK_WIDGET (list->data));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visibility = GIMP_DIALOG_VISIBILITY_INVISIBLE;
|
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
g_object_set_data (G_OBJECT (list->data),
|
2003-10-13 19:57:50 +08:00
|
|
|
GIMP_DIALOG_VISIBILITY_KEY,
|
2001-07-25 07:11:30 +08:00
|
|
|
GINT_TO_POINTER (visibility));
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-09 00:24:00 +08:00
|
|
|
gimp_dialog_factories_show_foreach (gconstpointer key,
|
2004-08-29 19:58:05 +08:00
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = factory->open_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
if (GTK_IS_WIDGET (list->data) && GTK_WIDGET_TOPLEVEL (list->data))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
|
|
|
GimpDialogVisibilityState visibility;
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
visibility =
|
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (list->data),
|
2003-10-13 19:57:50 +08:00
|
|
|
GIMP_DIALOG_VISIBILITY_KEY));
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2004-08-29 19:58:05 +08:00
|
|
|
if (! GTK_WIDGET_VISIBLE (list->data) &&
|
|
|
|
visibility == GIMP_DIALOG_VISIBILITY_VISIBLE)
|
|
|
|
{
|
2008-03-25 18:00:33 +08:00
|
|
|
GtkWindow *window = GTK_WINDOW (list->data);
|
2005-12-30 05:32:46 +08:00
|
|
|
|
2008-03-25 18:00:33 +08:00
|
|
|
/* Don't use gtk_window_present() here, we don't want the
|
|
|
|
* keyboard focus to move.
|
|
|
|
*/
|
2005-12-30 06:05:12 +08:00
|
|
|
gtk_widget_show (GTK_WIDGET (window));
|
2005-12-30 05:32:46 +08:00
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (window))
|
|
|
|
gdk_window_raise (GTK_WIDGET (window)->window);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factories_set_busy_foreach (gconstpointer key,
|
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2003-11-02 04:53:18 +08:00
|
|
|
GdkDisplay *display = NULL;
|
|
|
|
GdkCursor *cursor = NULL;
|
|
|
|
GList *list;
|
2001-07-20 18:07:51 +08:00
|
|
|
|
|
|
|
for (list = factory->open_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
2004-07-12 19:47:54 +08:00
|
|
|
GtkWidget *widget = list->data;
|
2003-11-02 04:53:18 +08:00
|
|
|
|
2004-07-12 19:47:54 +08:00
|
|
|
if (GTK_IS_WIDGET (widget) && GTK_WIDGET_TOPLEVEL (widget))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2003-11-02 04:53:18 +08:00
|
|
|
if (!display || display != gtk_widget_get_display (widget))
|
|
|
|
{
|
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
|
|
|
if (cursor)
|
|
|
|
gdk_cursor_unref (cursor);
|
|
|
|
|
|
|
|
cursor = gimp_cursor_new (display,
|
2004-06-13 10:08:54 +08:00
|
|
|
GIMP_CURSOR_FORMAT_BITMAP,
|
2003-11-02 04:53:18 +08:00
|
|
|
GDK_WATCH,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
|
|
|
}
|
|
|
|
|
2004-07-12 19:47:54 +08:00
|
|
|
if (widget->window)
|
|
|
|
gdk_window_set_cursor (widget->window, cursor);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
|
2003-11-02 04:53:18 +08:00
|
|
|
if (cursor)
|
|
|
|
gdk_cursor_unref (cursor);
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factories_unset_busy_foreach (gconstpointer key,
|
|
|
|
GimpDialogFactory *factory,
|
|
|
|
gpointer data)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = factory->open_dialogs; list; list = g_list_next (list))
|
|
|
|
{
|
2004-07-12 19:47:54 +08:00
|
|
|
GtkWidget *widget = list->data;
|
|
|
|
|
|
|
|
if (GTK_IS_WIDGET (widget) && GTK_WIDGET_TOPLEVEL (widget))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2004-07-12 19:47:54 +08:00
|
|
|
if (widget->window)
|
|
|
|
gdk_window_set_cursor (widget->window, NULL);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
}
|
2005-05-13 05:21:38 +08:00
|
|
|
|
|
|
|
/* The only toplevel widget in the toolbox factory is the toolbox */
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_dialog_factory_get_toolbox (GimpDialogFactory *toolbox_factory)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = toolbox_factory->open_dialogs; list; list = list->next)
|
|
|
|
{
|
|
|
|
if (GTK_IS_WIDGET (list->data) && GTK_WIDGET_TOPLEVEL (list->data))
|
|
|
|
return list->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|