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
|
2008-05-17 00:06:42 +08:00
|
|
|
* Copyright (C) 2001-2008 Michael Natterer <mitch@gimp.org>
|
2001-04-22 08:38:56 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-04-14 23:21:45 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-04-14 23:21:45 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-04-14 23:21:45 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-04-14 23:21:45 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2010-03-09 15:01:34 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
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"
|
2011-05-14 00:56:03 +08:00
|
|
|
#include "gimpdockcontainer.h"
|
2009-09-26 19:11:42 +08:00
|
|
|
#include "gimpdockwindow.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2003-10-10 23:59:12 +08:00
|
|
|
#include "gimpsessioninfo.h"
|
2010-02-20 23:55:35 +08:00
|
|
|
#include "gimpwidgets-utils.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
|
|
|
|
{
|
2009-09-26 19:11:42 +08:00
|
|
|
DOCK_WINDOW_ADDED,
|
|
|
|
DOCK_WINDOW_REMOVED,
|
2008-05-11 03:11:18 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-20 19:30:59 +08:00
|
|
|
struct _GimpDialogFactoryPrivate
|
|
|
|
{
|
2011-03-27 02:32:59 +08:00
|
|
|
GimpContext *context;
|
|
|
|
GimpMenuFactory *menu_factory;
|
2009-12-21 03:19:31 +08:00
|
|
|
|
2011-03-27 02:32:59 +08:00
|
|
|
GList *open_dialogs;
|
|
|
|
GList *session_infos;
|
2009-12-21 03:19:31 +08:00
|
|
|
|
2011-03-27 02:32:59 +08:00
|
|
|
GList *registered_dialogs;
|
2010-03-01 01:48:16 +08:00
|
|
|
|
2011-03-27 02:32:59 +08:00
|
|
|
GimpDialogsState dialog_state;
|
2009-12-20 19:30:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-20 19:27:50 +08:00
|
|
|
static void gimp_dialog_factory_dispose (GObject *object);
|
|
|
|
static void gimp_dialog_factory_finalize (GObject *object);
|
2010-01-17 02:43:33 +08:00
|
|
|
static GtkWidget * gimp_dialog_factory_constructor (GimpDialogFactory *factory,
|
2010-01-17 00:54:56 +08:00
|
|
|
GimpDialogFactoryEntry *entry,
|
|
|
|
GimpContext *context,
|
2010-01-17 07:00:19 +08:00
|
|
|
GimpUIManager *ui_manager,
|
2010-01-17 00:54:56 +08:00
|
|
|
gint view_size);
|
2010-03-09 15:01:34 +08:00
|
|
|
static void gimp_dialog_factory_config_notify (GimpDialogFactory *factory,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpGuiConfig *config);
|
2009-12-20 19:27:50 +08:00
|
|
|
static void gimp_dialog_factory_set_widget_data (GtkWidget *dialog,
|
|
|
|
GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry);
|
|
|
|
static void gimp_dialog_factory_unset_widget_data (GtkWidget *dialog);
|
|
|
|
static gboolean gimp_dialog_factory_set_user_pos (GtkWidget *dialog,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
gpointer data);
|
|
|
|
static gboolean gimp_dialog_factory_dialog_configure (GtkWidget *dialog,
|
|
|
|
GdkEventConfigure *cevent,
|
|
|
|
GimpDialogFactory *factory);
|
2010-03-01 01:48:16 +08:00
|
|
|
static void gimp_dialog_factory_hide (GimpDialogFactory *factory);
|
|
|
|
static void gimp_dialog_factory_show (GimpDialogFactory *factory);
|
2001-04-18 00:00:27 +08:00
|
|
|
|
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 };
|
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
/* Is set by dialogs.c to a dialog factory initialized there.
|
|
|
|
*
|
|
|
|
* FIXME: The layer above should not do this kind of initialization of
|
|
|
|
* layers below.
|
|
|
|
*/
|
|
|
|
static GimpDialogFactory *gimp_toplevel_factory = NULL;
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
factory_signals[DOCK_WINDOW_ADDED] =
|
|
|
|
g_signal_new ("dock-window-added",
|
2008-05-11 03:11:18 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2009-09-26 19:11:42 +08:00
|
|
|
G_STRUCT_OFFSET (GimpDialogFactoryClass, dock_window_added),
|
2008-05-11 03:11:18 +08:00
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
2009-09-26 19:11:42 +08:00
|
|
|
GIMP_TYPE_DOCK_WINDOW);
|
2008-05-11 03:11:18 +08:00
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
factory_signals[DOCK_WINDOW_REMOVED] =
|
|
|
|
g_signal_new ("dock-window-removed",
|
2008-05-11 03:11:18 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2009-09-26 19:11:42 +08:00
|
|
|
G_STRUCT_OFFSET (GimpDialogFactoryClass, dock_window_removed),
|
2008-05-11 03:11:18 +08:00
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__OBJECT,
|
|
|
|
G_TYPE_NONE, 1,
|
2009-09-26 19:11:42 +08:00
|
|
|
GIMP_TYPE_DOCK_WINDOW);
|
2009-12-20 19:30:59 +08:00
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (GimpDialogFactoryPrivate));
|
2001-04-14 23:21:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dialog_factory_init (GimpDialogFactory *factory)
|
|
|
|
{
|
2009-12-20 19:30:59 +08:00
|
|
|
factory->p = G_TYPE_INSTANCE_GET_PRIVATE (factory,
|
|
|
|
GIMP_TYPE_DIALOG_FACTORY,
|
|
|
|
GimpDialogFactoryPrivate);
|
2010-03-01 01:48:16 +08:00
|
|
|
factory->p->dialog_state = GIMP_DIALOGS_SHOWN;
|
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;
|
|
|
|
|
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
|
2009-12-21 03:19:31 +08:00
|
|
|
* to be removed from factory->p->open_dialogs
|
2002-03-11 20:58:59 +08:00
|
|
|
*/
|
2009-12-21 03:19:31 +08:00
|
|
|
while (factory->p->open_dialogs)
|
2002-03-11 02:31:42 +08:00
|
|
|
{
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->open_dialogs; list; list = g_list_next (list))
|
2002-03-11 02:31:42 +08:00
|
|
|
{
|
2009-10-18 02:20:39 +08:00
|
|
|
if (gtk_widget_is_toplevel (list->data))
|
2002-03-11 02:31:42 +08:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2010-06-24 18:53:28 +08:00
|
|
|
g_warning ("%s: %d stale non-toplevel entries in factory->p->open_dialogs",
|
|
|
|
G_STRFUNC, g_list_length (factory->p->open_dialogs));
|
2002-03-11 02:31:42 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
if (factory->p->open_dialogs)
|
2006-05-21 23:32:20 +08:00
|
|
|
{
|
2009-12-21 03:19:31 +08:00
|
|
|
g_list_free (factory->p->open_dialogs);
|
|
|
|
factory->p->open_dialogs = NULL;
|
2006-05-21 23:32:20 +08:00
|
|
|
}
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
if (factory->p->session_infos)
|
2006-05-21 23:32:20 +08:00
|
|
|
{
|
2011-03-08 00:10:18 +08:00
|
|
|
g_list_free_full (factory->p->session_infos,
|
|
|
|
(GDestroyNotify) g_object_unref);
|
2009-12-21 03:19:31 +08:00
|
|
|
factory->p->session_infos = NULL;
|
2006-05-21 23:32:20 +08:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2009-12-20 19:30:59 +08:00
|
|
|
for (list = factory->p->registered_dialogs; list; list = g_list_next (list))
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2009-12-20 19:30:59 +08:00
|
|
|
if (factory->p->registered_dialogs)
|
2001-08-14 22:54:22 +08:00
|
|
|
{
|
2009-12-20 19:30:59 +08:00
|
|
|
g_list_free (factory->p->registered_dialogs);
|
|
|
|
factory->p->registered_dialogs = NULL;
|
2001-08-14 22:54:22 +08:00
|
|
|
}
|
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 *
|
2009-09-26 22:21:10 +08:00
|
|
|
gimp_dialog_factory_new (const gchar *name,
|
|
|
|
GimpContext *context,
|
2010-02-20 17:32:50 +08:00
|
|
|
GimpMenuFactory *menu_factory)
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
2003-07-09 00:24:00 +08:00
|
|
|
GimpDialogFactory *factory;
|
2010-03-09 15:01:34 +08:00
|
|
|
GimpGuiConfig *config;
|
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
|
|
|
|
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);
|
|
|
|
|
2010-03-09 15:01:34 +08:00
|
|
|
config = GIMP_GUI_CONFIG (context->gimp->config);
|
|
|
|
|
|
|
|
factory->p->context = context;
|
|
|
|
factory->p->menu_factory = menu_factory;
|
|
|
|
factory->p->dialog_state = (config->hide_docks ?
|
|
|
|
GIMP_DIALOGS_HIDDEN_EXPLICITLY :
|
|
|
|
GIMP_DIALOGS_SHOWN);
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2010-03-09 15:01:34 +08:00
|
|
|
g_signal_connect_object (config, "notify::hide-docks",
|
|
|
|
G_CALLBACK (gimp_dialog_factory_config_notify),
|
|
|
|
factory, G_CONNECT_SWAPPED);
|
2011-03-27 02:32:59 +08:00
|
|
|
|
2001-04-14 23:21:45 +08:00
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-05-27 23:16:04 +08:00
|
|
|
gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
|
|
|
|
const gchar *identifier,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *blurb,
|
|
|
|
const gchar *stock_id,
|
|
|
|
const gchar *help_id,
|
|
|
|
GimpDialogNewFunc new_func,
|
|
|
|
GimpDialogRestoreFunc restore_func,
|
|
|
|
gint view_size,
|
|
|
|
gboolean singleton,
|
|
|
|
gboolean session_managed,
|
|
|
|
gboolean remember_size,
|
|
|
|
gboolean remember_if_open,
|
|
|
|
gboolean hideable,
|
|
|
|
gboolean image_window,
|
|
|
|
gboolean dockable)
|
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;
|
2011-05-27 23:16:04 +08:00
|
|
|
entry->restore_func = restore_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;
|
2010-02-20 17:32:50 +08:00
|
|
|
entry->hideable = hideable ? TRUE : FALSE;
|
2011-05-14 03:02:05 +08:00
|
|
|
entry->image_window = image_window ? TRUE : FALSE;
|
2010-01-17 02:35:26 +08:00
|
|
|
entry->dockable = dockable ? TRUE : FALSE;
|
2001-04-14 23:21:45 +08:00
|
|
|
|
2009-12-20 19:30:59 +08:00
|
|
|
factory->p->registered_dialogs = g_list_prepend (factory->p->registered_dialogs,
|
|
|
|
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);
|
|
|
|
|
2009-12-20 19:30:59 +08:00
|
|
|
for (list = factory->p->registered_dialogs; list; list = g_list_next (list))
|
2001-04-14 23:21:45 +08:00
|
|
|
{
|
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);
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->session_infos; list; list = g_list_next (list))
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
2004-11-05 05:02:34 +08:00
|
|
|
GimpSessionInfo *info = list->data;
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_factory_entry (info) &&
|
|
|
|
g_str_equal (identifier,
|
|
|
|
gimp_session_info_get_factory_entry (info)->identifier))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
|
|
|
return info;
|
|
|
|
}
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-01-11 02:33:42 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dialog_factory_find_widget (GimpDialogFactory *factory,
|
|
|
|
const gchar *identifier)
|
|
|
|
{
|
|
|
|
GimpSessionInfo *info;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (identifier != NULL, NULL);
|
|
|
|
|
|
|
|
info = gimp_dialog_factory_find_session_info (factory, identifier);
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
return gimp_session_info_get_widget (info);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-20 16:25:13 +08:00
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_dialog_sane:
|
|
|
|
* @factory:
|
|
|
|
* @widget_factory:
|
|
|
|
* @widget_entry:
|
|
|
|
* @widget:
|
|
|
|
*
|
|
|
|
* Makes sure that the @widget with the given @widget_entry that was
|
|
|
|
* created by the given @widget_factory belongs to @efactory.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if that is the case, %FALSE otherwise.
|
|
|
|
**/
|
|
|
|
static gboolean
|
|
|
|
gimp_dialog_factory_dialog_sane (GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactory *widget_factory,
|
|
|
|
GimpDialogFactoryEntry *widget_entry,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
2010-01-20 05:23:23 +08:00
|
|
|
if (! widget_factory || ! widget_entry)
|
2009-09-20 16:25:13 +08:00
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was not created by a GimpDialogFactory",
|
|
|
|
G_STRFUNC);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget_factory != factory)
|
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was created by a different GimpDialogFactory",
|
|
|
|
G_STRFUNC);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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,
|
2010-01-17 07:00:19 +08:00
|
|
|
GimpUIManager *ui_manager,
|
2004-08-29 19:58:05 +08:00
|
|
|
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
|
|
|
{
|
2010-03-03 05:15:42 +08:00
|
|
|
GimpDialogFactoryEntry *entry = NULL;
|
|
|
|
GtkWidget *dialog = NULL;
|
|
|
|
GtkWidget *toplevel = NULL;
|
2001-04-18 00:00:27 +08:00
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-01-11 02:33:42 +08:00
|
|
|
dialog = gimp_dialog_factory_find_widget (factory, identifier);
|
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)
|
|
|
|
{
|
2010-01-17 02:43:33 +08:00
|
|
|
GtkWidget *dock = NULL;
|
2010-03-03 05:31:01 +08:00
|
|
|
GtkWidget *dock_window = NULL;
|
2010-01-17 02:43:33 +08:00
|
|
|
gboolean called_from_raise = FALSE;
|
2010-01-17 00:54:56 +08:00
|
|
|
|
2010-01-17 02:43:33 +08:00
|
|
|
called_from_raise = (context == NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2010-03-03 05:31:01 +08:00
|
|
|
/* What follows is special-case code for some entires. At some
|
|
|
|
* point we might want to abstract this block of code away.
|
|
|
|
*/
|
|
|
|
if (called_from_raise)
|
|
|
|
{
|
|
|
|
if (entry->dockable)
|
|
|
|
{
|
|
|
|
GtkWidget *dockbook;
|
|
|
|
|
|
|
|
/* It doesn't make sense to have a dockable without a dock
|
|
|
|
* so create one. Create a new dock _before_ creating the
|
|
|
|
* dialog. We do this because the new dockable needs to be
|
|
|
|
* created in its dock's context.
|
|
|
|
*/
|
|
|
|
dock = gimp_dock_with_window_new (factory,
|
|
|
|
screen,
|
|
|
|
FALSE /*toolbox*/);
|
|
|
|
dockbook = gimp_dockbook_new (factory->p->menu_factory);
|
|
|
|
|
|
|
|
gimp_dock_add_book (GIMP_DOCK (dock),
|
|
|
|
GIMP_DOCKBOOK (dockbook),
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
else if (strcmp ("gimp-toolbox", entry->identifier) == 0)
|
|
|
|
{
|
2011-05-14 00:56:03 +08:00
|
|
|
GimpDockContainer *dock_container;
|
|
|
|
|
2010-03-03 05:31:01 +08:00
|
|
|
dock_window = gimp_dialog_factory_dialog_new (factory,
|
|
|
|
screen,
|
2010-05-16 18:19:18 +08:00
|
|
|
NULL /*ui_manager*/,
|
2010-03-03 05:31:01 +08:00
|
|
|
"gimp-toolbox-window",
|
|
|
|
-1 /*view_size*/,
|
|
|
|
FALSE /*present*/);
|
2010-05-16 18:19:18 +08:00
|
|
|
|
|
|
|
/* When we get a dock window, we also get a UI
|
|
|
|
* manager
|
|
|
|
*/
|
2011-05-14 00:56:03 +08:00
|
|
|
dock_container = GIMP_DOCK_CONTAINER (dock_window);
|
|
|
|
ui_manager = gimp_dock_container_get_ui_manager (dock_container);
|
2010-03-03 05:31:01 +08:00
|
|
|
}
|
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)
|
2010-01-17 02:43:33 +08:00
|
|
|
dialog = gimp_dialog_factory_constructor (factory, entry,
|
|
|
|
context,
|
2010-01-17 07:00:19 +08:00
|
|
|
ui_manager,
|
2010-01-17 02:43:33 +08:00
|
|
|
view_size);
|
2001-06-30 03:25:03 +08:00
|
|
|
else if (dock)
|
2010-01-17 02:43:33 +08:00
|
|
|
dialog = gimp_dialog_factory_constructor (factory, entry,
|
|
|
|
gimp_dock_get_context (GIMP_DOCK (dock)),
|
2010-01-17 07:00:19 +08:00
|
|
|
gimp_dock_get_ui_manager (GIMP_DOCK (dock)),
|
2010-01-17 02:43:33 +08:00
|
|
|
view_size);
|
2001-06-30 03:25:03 +08:00
|
|
|
else
|
2010-01-17 02:43:33 +08:00
|
|
|
dialog = gimp_dialog_factory_constructor (factory, entry,
|
|
|
|
factory->p->context,
|
2010-01-17 07:00:19 +08:00
|
|
|
ui_manager,
|
2010-01-17 02:43:33 +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
|
|
|
}
|
|
|
|
}
|
2010-03-03 05:31:01 +08:00
|
|
|
else if (dock_window)
|
|
|
|
{
|
|
|
|
if (GIMP_IS_DOCK (dialog))
|
|
|
|
{
|
|
|
|
gimp_dock_window_add_dock (GIMP_DOCK_WINDOW (dock_window),
|
|
|
|
GIMP_DOCK (dialog),
|
|
|
|
-1 /*index*/);
|
|
|
|
|
|
|
|
gtk_widget_set_visible (dialog, present);
|
|
|
|
gtk_widget_set_visible (dock_window, present);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: GimpDialogFactory is a dock factory entry "
|
|
|
|
"but constructor for \"%s\" did not return a "
|
|
|
|
"GimpDock",
|
|
|
|
G_STRFUNC, identifier);
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
gtk_widget_destroy (dock_window);
|
|
|
|
|
|
|
|
dialog = NULL;
|
|
|
|
dock_window = 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;
|
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (gtk_widget_is_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
|
|
|
|
2010-03-03 05:15:42 +08:00
|
|
|
toplevel = dialog;
|
2006-05-30 00:41:18 +08:00
|
|
|
}
|
2010-03-03 05:31:01 +08:00
|
|
|
else if (GIMP_IS_DOCK (dialog))
|
|
|
|
{
|
|
|
|
toplevel = gtk_widget_get_toplevel (dialog);
|
|
|
|
}
|
2006-05-30 00:41:18 +08:00
|
|
|
else if (GIMP_IS_DOCKABLE (dialog))
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (dialog);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2010-01-05 07:30:10 +08:00
|
|
|
if (gimp_dockable_get_dockbook (dockable) &&
|
|
|
|
gimp_dockbook_get_dock (gimp_dockable_get_dockbook (dockable)))
|
2006-05-30 00:41:18 +08:00
|
|
|
{
|
2010-01-05 07:30:10 +08:00
|
|
|
GtkNotebook *notebook = GTK_NOTEBOOK (gimp_dockable_get_dockbook (dockable));
|
2006-05-30 00:41:18 +08:00
|
|
|
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
|
|
|
|
2010-03-03 05:15:42 +08:00
|
|
|
toplevel = gtk_widget_get_toplevel (dialog);
|
2001-04-18 00:00:27 +08:00
|
|
|
}
|
|
|
|
|
2011-10-09 06:18:56 +08:00
|
|
|
if (present && GTK_IS_WINDOW (toplevel))
|
2010-03-03 05:15:42 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (toplevel));
|
|
|
|
|
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
|
2010-05-16 18:19:18 +08:00
|
|
|
* @ui_manager: A #GimpUIManager, if applicable.
|
2003-11-18 20:28:15 +08:00
|
|
|
* @identifier: the identifier of the dialog as registered with
|
|
|
|
* gimp_dialog_factory_register_entry()
|
2009-09-15 03:39:46 +08:00
|
|
|
* @view_size: the initial preview 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,
|
2010-05-16 18:19:18 +08:00
|
|
|
GimpUIManager *ui_manager,
|
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,
|
2009-12-21 03:19:31 +08:00
|
|
|
factory->p->context,
|
2010-05-16 18:19:18 +08:00
|
|
|
ui_manager,
|
2004-08-29 19:58:05 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
GimpContext *
|
|
|
|
gimp_dialog_factory_get_context (GimpDialogFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
|
|
|
|
return factory->p->context;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpMenuFactory *
|
|
|
|
gimp_dialog_factory_get_menu_factory (GimpDialogFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
|
|
|
|
return factory->p->menu_factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
gimp_dialog_factory_get_open_dialogs (GimpDialogFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
|
|
|
|
return factory->p->open_dialogs;
|
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
gimp_dialog_factory_get_session_infos (GimpDialogFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
|
|
|
|
return factory->p->session_infos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_dialog_factory_add_session_info (GimpDialogFactory *factory,
|
|
|
|
GimpSessionInfo *info)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
2011-05-13 03:12:59 +08:00
|
|
|
g_return_if_fail (GIMP_IS_SESSION_INFO (info));
|
2010-01-20 05:23:23 +08:00
|
|
|
|
|
|
|
/* We want to append rather than prepend so that the serialized
|
|
|
|
* order in sessionrc remains the same
|
|
|
|
*/
|
2011-05-13 03:12:59 +08:00
|
|
|
factory->p->session_infos = g_list_append (factory->p->session_infos,
|
|
|
|
g_object_ref (info));
|
2009-12-21 03:19:31 +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()
|
2009-09-15 03:39:46 +08:00
|
|
|
* @view_size: the initial preview size if a dialog needs to be created
|
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++)
|
|
|
|
{
|
2012-01-11 02:33:42 +08:00
|
|
|
if (gimp_dialog_factory_find_widget (factory, ids[i]))
|
2003-11-18 20:28:15 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog = gimp_dialog_factory_dialog_new_internal (factory,
|
|
|
|
screen,
|
|
|
|
NULL,
|
2010-01-17 07:00:19 +08:00
|
|
|
NULL,
|
2003-11-18 20:28:15 +08:00
|
|
|
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,
|
2010-01-17 07:00:19 +08:00
|
|
|
NULL,
|
2003-11-18 20:28:15 +08:00
|
|
|
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,
|
2010-01-05 07:30:10 +08:00
|
|
|
* so callers should check that gimp_dockable_get_dockbook (dockable)
|
|
|
|
* 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)),
|
2009-01-04 18:28:31 +08:00
|
|
|
gimp_dock_get_context (dock),
|
2010-01-17 07:00:19 +08:00
|
|
|
gimp_dock_get_ui_manager (dock),
|
2004-08-29 19:58:05 +08:00
|
|
|
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-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
|
|
|
{
|
2009-09-20 17:33:22 +08:00
|
|
|
GimpDialogFactory *dialog_factory = NULL;
|
|
|
|
GimpDialogFactoryEntry *entry = NULL;
|
|
|
|
GimpSessionInfo *info = NULL;
|
|
|
|
GList *list = NULL;
|
|
|
|
gboolean toplevel = FALSE;
|
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
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
if (g_list_find (factory->p->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
|
|
|
|
2009-09-20 16:25:13 +08:00
|
|
|
if (! gimp_dialog_factory_dialog_sane (factory,
|
|
|
|
dialog_factory,
|
|
|
|
entry,
|
|
|
|
dialog))
|
|
|
|
return;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
toplevel = gtk_widget_is_toplevel (dialog);
|
2003-12-22 05:51:58 +08:00
|
|
|
|
2011-03-27 02:32:59 +08:00
|
|
|
if (entry)
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2011-03-27 02:32:59 +08:00
|
|
|
/* dialog is a toplevel (but not a GimpDockWindow) or a GimpDockable */
|
|
|
|
|
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
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->session_infos; list; list = g_list_next (list))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2009-09-20 17:33:22 +08:00
|
|
|
GimpSessionInfo *current_info = list->data;
|
2004-08-29 19:58:05 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_factory_entry (current_info) == entry)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_widget (current_info))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2009-09-20 17:43:41 +08:00
|
|
|
if (gimp_session_info_is_singleton (current_info))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
|
|
|
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)",
|
2009-09-20 20:51:03 +08:00
|
|
|
current_info,
|
|
|
|
gimp_session_info_get_widget (current_info));
|
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
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
gimp_session_info_set_widget (current_info, dialog);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2007-11-19 01:40:24 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"updating session info %p (widget %p) for %s \"%s\"",
|
2011-03-27 02:32:59 +08:00
|
|
|
current_info,
|
|
|
|
gimp_session_info_get_widget (current_info),
|
2007-11-19 01:40:24 +08:00
|
|
|
toplevel ? "toplevel" : "dockable",
|
|
|
|
entry->identifier);
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2009-09-20 17:43:41 +08:00
|
|
|
if (toplevel &&
|
|
|
|
gimp_session_info_is_session_managed (current_info) &&
|
2009-10-18 02:20:39 +08:00
|
|
|
! gtk_widget_get_visible (dialog))
|
2008-03-24 02:36:16 +08:00
|
|
|
{
|
2009-09-20 19:13:50 +08:00
|
|
|
gimp_session_info_apply_geometry (current_info);
|
2008-03-24 02:36:16 +08:00
|
|
|
}
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2009-09-20 17:33:22 +08:00
|
|
|
info = current_info;
|
2004-08-29 19:58:05 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2009-09-20 17:33:22 +08:00
|
|
|
if (! info)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2009-09-20 17:33:22 +08:00
|
|
|
info = gimp_session_info_new ();
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
gimp_session_info_set_widget (info, 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\"",
|
2011-03-27 02:32:59 +08:00
|
|
|
info,
|
|
|
|
gimp_session_info_get_widget (info),
|
2007-11-19 01:40:24 +08:00
|
|
|
toplevel ? "toplevel" : "dockable",
|
|
|
|
entry->identifier);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
gimp_session_info_set_factory_entry (info, entry);
|
2009-09-20 18:17:22 +08:00
|
|
|
|
|
|
|
if (gimp_session_info_is_session_managed (info))
|
2010-02-18 14:21:20 +08:00
|
|
|
{
|
|
|
|
/* Make the dialog show up at the user position the
|
|
|
|
* first time it is shown. After it has been shown the
|
|
|
|
* first time we don't want it to show at the mouse the
|
|
|
|
* next time. Think of the use cases "hide and show with
|
|
|
|
* tab" and "change virtual desktops"
|
|
|
|
*/
|
|
|
|
GIMP_LOG (WM, "setting GTK_WIN_POS_MOUSE for %p (\"%s\")\n",
|
|
|
|
dialog, entry->identifier);
|
2011-03-27 02:32:59 +08:00
|
|
|
|
2010-02-18 14:21:20 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
|
|
|
g_signal_connect (dialog, "configure-event",
|
|
|
|
G_CALLBACK (gimp_dialog_factory_set_user_pos),
|
|
|
|
NULL);
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2011-05-13 03:12:59 +08:00
|
|
|
gimp_dialog_factory_add_session_info (factory, info);
|
|
|
|
g_object_unref (info);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
|
2010-01-20 05:23:23 +08:00
|
|
|
/* Some special logic for dock windows */
|
|
|
|
if (GIMP_IS_DOCK_WINDOW (dialog))
|
|
|
|
{
|
2009-09-26 19:11:42 +08:00
|
|
|
g_signal_emit (factory, factory_signals[DOCK_WINDOW_ADDED], 0, dialog);
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
factory->p->open_dialogs = g_list_prepend (factory->p->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
|
|
|
|
2009-09-20 17:43:41 +08:00
|
|
|
if (gimp_session_info_is_session_managed (info))
|
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));
|
2009-10-18 02:20:39 +08:00
|
|
|
g_return_if_fail (gtk_widget_is_toplevel (dialog));
|
2003-05-03 02:43:15 +08:00
|
|
|
|
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
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
if (! g_list_find (factory->p->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;
|
|
|
|
}
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
factory->p->open_dialogs = g_list_remove (factory->p->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
|
|
|
|
2009-09-20 16:25:13 +08:00
|
|
|
if (! gimp_dialog_factory_dialog_sane (factory,
|
|
|
|
dialog_factory,
|
|
|
|
entry,
|
|
|
|
dialog))
|
|
|
|
return;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2009-10-04 08:03:44 +08:00
|
|
|
GIMP_LOG (DIALOG_FACTORY, "removing \"%s\" (dialog = %p)",
|
2010-01-20 05:23:23 +08:00
|
|
|
entry->identifier,
|
2009-10-04 08:03:44 +08:00
|
|
|
dialog);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->session_infos; list; list = g_list_next (list))
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2008-03-23 21:33:19 +08:00
|
|
|
GimpSessionInfo *session_info = list->data;
|
2001-04-17 02:49:29 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_widget (session_info) == 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\"",
|
2009-09-20 20:51:03 +08:00
|
|
|
session_info, gimp_session_info_get_widget (session_info),
|
2010-01-20 05:23:23 +08:00
|
|
|
entry->identifier);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
gimp_session_info_set_widget (session_info, 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);
|
|
|
|
|
2009-09-20 17:43:41 +08:00
|
|
|
if (gimp_session_info_is_session_managed (session_info))
|
2008-03-23 21:33:19 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gimp_dialog_factory_dialog_configure,
|
|
|
|
factory);
|
|
|
|
|
2009-09-26 20:26:49 +08:00
|
|
|
if (GIMP_IS_DOCK_WINDOW (dialog))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2008-05-11 03:11:18 +08:00
|
|
|
/* don't save session info for empty docks */
|
2009-12-21 03:19:31 +08:00
|
|
|
factory->p->session_infos = g_list_remove (factory->p->session_infos,
|
2011-03-27 02:32:59 +08:00
|
|
|
session_info);
|
2008-05-14 05:17:11 +08:00
|
|
|
g_object_unref (session_info);
|
2008-05-11 03:11:18 +08:00
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
g_signal_emit (factory, factory_signals[DOCK_WINDOW_REMOVED], 0,
|
2008-05-11 03:11:18 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-14 06:55:07 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_hide_dialog (GtkWidget *dialog)
|
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
GimpDialogFactory *factory = NULL;
|
|
|
|
|
2007-03-14 06:55:07 +08:00
|
|
|
g_return_if_fail (GTK_IS_WIDGET (dialog));
|
2009-10-18 02:20:39 +08:00
|
|
|
g_return_if_fail (gtk_widget_is_toplevel (dialog));
|
2007-03-14 06:55:07 +08:00
|
|
|
|
2010-03-01 01:48:16 +08:00
|
|
|
if (! (factory = gimp_dialog_factory_from_widget (dialog, NULL)))
|
2007-03-14 06:55:07 +08:00
|
|
|
{
|
|
|
|
g_warning ("%s: dialog was not created by a GimpDialogFactory",
|
|
|
|
G_STRFUNC);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_hide (dialog);
|
|
|
|
|
2010-03-01 01:48:16 +08:00
|
|
|
if (factory->p->dialog_state != GIMP_DIALOGS_SHOWN)
|
2007-03-14 06:55:07 +08:00
|
|
|
g_object_set_data (G_OBJECT (dialog), GIMP_DIALOG_VISIBILITY_KEY,
|
|
|
|
GINT_TO_POINTER (GIMP_DIALOG_VISIBILITY_INVISIBLE));
|
|
|
|
}
|
|
|
|
|
2010-02-21 05:06:12 +08:00
|
|
|
void
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_set_state (GimpDialogFactory *factory,
|
|
|
|
GimpDialogsState state)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2010-03-01 01:48:16 +08:00
|
|
|
factory->p->dialog_state = state;
|
2008-10-23 16:39:46 +08:00
|
|
|
|
2008-10-24 14:48:56 +08:00
|
|
|
if (state == GIMP_DIALOGS_SHOWN)
|
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_show (factory);
|
2008-10-23 16:39:46 +08:00
|
|
|
}
|
2008-10-24 14:48:56 +08:00
|
|
|
else
|
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_hide (factory);
|
2008-10-24 14:48:56 +08:00
|
|
|
}
|
2008-10-23 16:39:46 +08:00
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2010-02-21 05:06:12 +08:00
|
|
|
GimpDialogsState
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_get_state (GimpDialogFactory *factory)
|
2010-02-21 05:06:12 +08:00
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), 0);
|
|
|
|
|
|
|
|
return factory->p->dialog_state;
|
2010-02-21 05:06:12 +08:00
|
|
|
}
|
|
|
|
|
2008-10-23 16:39:46 +08:00
|
|
|
void
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_show_with_display (GimpDialogFactory *factory)
|
2008-10-23 16:39:46 +08:00
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
|
|
|
|
|
|
|
if (factory->p->dialog_state == GIMP_DIALOGS_HIDDEN_WITH_DISPLAY)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_set_state (factory, GIMP_DIALOGS_SHOWN);
|
2005-12-30 04:47:29 +08:00
|
|
|
}
|
2008-10-23 16:39:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_hide_with_display (GimpDialogFactory *factory)
|
2008-10-23 16:39:46 +08:00
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));
|
|
|
|
|
|
|
|
if (factory->p->dialog_state == GIMP_DIALOGS_SHOWN)
|
2008-10-23 16:39:46 +08:00
|
|
|
{
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_set_state (factory, GIMP_DIALOGS_HIDDEN_WITH_DISPLAY);
|
2008-10-23 16:39:46 +08:00
|
|
|
}
|
2008-10-24 14:48:56 +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);
|
|
|
|
}
|
|
|
|
|
2009-03-28 21:19:53 +08:00
|
|
|
#define GIMP_DIALOG_FACTORY_MIN_SIZE_KEY "gimp-dialog-factory-min-size"
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_dialog_factory_set_has_min_size (GtkWindow *window,
|
|
|
|
gboolean has_min_size)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_WINDOW (window));
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (window), GIMP_DIALOG_FACTORY_MIN_SIZE_KEY,
|
|
|
|
GINT_TO_POINTER (has_min_size ? TRUE : FALSE));
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_dialog_factory_get_has_min_size (GtkWindow *window)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
|
|
|
|
|
|
|
|
return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
|
|
|
|
GIMP_DIALOG_FACTORY_MIN_SIZE_KEY));
|
|
|
|
}
|
|
|
|
|
2003-10-13 19:57:50 +08:00
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
/* private functions */
|
|
|
|
|
2004-09-27 02:41:29 +08:00
|
|
|
static GtkWidget *
|
2010-01-17 02:43:33 +08:00
|
|
|
gimp_dialog_factory_constructor (GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry,
|
|
|
|
GimpContext *context,
|
2010-01-17 07:00:19 +08:00
|
|
|
GimpUIManager *ui_manager,
|
2010-01-17 02:43:33 +08:00
|
|
|
gint view_size)
|
2010-01-17 00:54:56 +08:00
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
2010-01-17 07:00:19 +08:00
|
|
|
widget = entry->new_func (factory, context, ui_manager, view_size);
|
2010-01-17 00:54:56 +08:00
|
|
|
|
2010-01-17 02:43:33 +08:00
|
|
|
/* The entry is for a dockable, so we simply need to put the created
|
|
|
|
* widget in a dockable
|
2010-01-17 04:22:56 +08:00
|
|
|
*/
|
2010-01-17 02:43:33 +08:00
|
|
|
if (widget && entry->dockable)
|
2010-01-17 00:54:56 +08:00
|
|
|
{
|
2010-01-17 04:22:56 +08:00
|
|
|
GtkWidget *dockable = NULL;
|
|
|
|
|
2010-01-17 00:54:56 +08:00
|
|
|
dockable = gimp_dockable_new (entry->name, entry->blurb,
|
|
|
|
entry->stock_id, entry->help_id);
|
|
|
|
gtk_container_add (GTK_CONTAINER (dockable), widget);
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
/* EEK */
|
|
|
|
g_object_set_data (G_OBJECT (dockable), "gimp-dialog-identifier",
|
|
|
|
entry->identifier);
|
2010-01-17 04:22:56 +08:00
|
|
|
|
|
|
|
/* Return the dockable instead */
|
|
|
|
widget = dockable;
|
2010-01-17 00:54:56 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 04:22:56 +08:00
|
|
|
return widget;
|
2010-01-17 00:54:56 +08:00
|
|
|
}
|
|
|
|
|
2010-03-09 15:01:34 +08:00
|
|
|
static void
|
|
|
|
gimp_dialog_factory_config_notify (GimpDialogFactory *factory,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpGuiConfig *config)
|
|
|
|
{
|
2011-03-27 02:32:59 +08:00
|
|
|
GimpDialogsState state = gimp_dialog_factory_get_state (factory);
|
|
|
|
GimpDialogsState new_state = state;
|
2010-03-09 15:01:34 +08:00
|
|
|
|
|
|
|
/* Make sure the state and config are in sync */
|
|
|
|
if (config->hide_docks && state == GIMP_DIALOGS_SHOWN)
|
|
|
|
new_state = GIMP_DIALOGS_HIDDEN_EXPLICITLY;
|
|
|
|
else if (! config->hide_docks)
|
|
|
|
new_state = GIMP_DIALOGS_SHOWN;
|
|
|
|
|
|
|
|
if (state != new_state)
|
|
|
|
gimp_dialog_factory_set_state (factory, new_state);
|
|
|
|
}
|
|
|
|
|
2004-09-27 02:41:29 +08:00
|
|
|
static void
|
2011-03-27 02:32:59 +08:00
|
|
|
gimp_dialog_factory_set_widget_data (GtkWidget *dialog,
|
|
|
|
GimpDialogFactory *factory,
|
|
|
|
GimpDialogFactoryEntry *entry)
|
2003-10-13 19:57:50 +08:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2010-02-18 14:21:20 +08:00
|
|
|
GdkWindowHints geometry_mask;
|
2003-12-22 05:51:58 +08:00
|
|
|
|
2010-02-18 14:21:20 +08:00
|
|
|
/* Not only set geometry hints, also reset window position */
|
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_NONE);
|
2003-05-04 07:02:26 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (dialog,
|
|
|
|
gimp_dialog_factory_set_user_pos,
|
|
|
|
data);
|
|
|
|
|
2010-02-18 14:21:20 +08:00
|
|
|
GIMP_LOG (WM, "setting GDK_HINT_USER_POS for %p\n", dialog);
|
2009-03-28 21:19:53 +08:00
|
|
|
geometry_mask = GDK_HINT_USER_POS;
|
|
|
|
|
|
|
|
if (gimp_dialog_factory_get_has_min_size (GTK_WINDOW (dialog)))
|
|
|
|
geometry_mask |= GDK_HINT_MIN_SIZE;
|
|
|
|
|
2003-05-04 07:02:26 +08:00
|
|
|
gtk_window_set_geometry_hints (GTK_WINDOW (dialog), NULL, NULL,
|
2009-03-28 21:19:53 +08:00
|
|
|
geometry_mask);
|
2003-05-04 07:02:26 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
if (! g_list_find (factory->p->open_dialogs, dialog))
|
2003-05-03 02:43:15 +08:00
|
|
|
{
|
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
|
|
|
|
2009-09-20 16:25:13 +08:00
|
|
|
if (! gimp_dialog_factory_dialog_sane (factory,
|
|
|
|
dialog_factory,
|
|
|
|
entry,
|
|
|
|
dialog))
|
|
|
|
return FALSE;
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->session_infos; list; list = g_list_next (list))
|
2003-05-03 02:43:15 +08:00
|
|
|
{
|
2003-10-13 19:57:50 +08:00
|
|
|
GimpSessionInfo *session_info = list->data;
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_widget (session_info) == dialog)
|
2003-05-03 02:43:15 +08:00
|
|
|
{
|
2011-05-26 14:06:20 +08:00
|
|
|
gimp_session_info_read_geometry (session_info, cevent);
|
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)",
|
2010-01-20 05:23:23 +08:00
|
|
|
entry->identifier,
|
2009-09-20 20:51:03 +08:00
|
|
|
gimp_session_info_get_x (session_info),
|
|
|
|
gimp_session_info_get_y (session_info),
|
|
|
|
gimp_session_info_get_width (session_info),
|
|
|
|
gimp_session_info_get_height (session_info));
|
2008-03-23 21:33:19 +08:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-28 23:23:19 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_save (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
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (infos = factory->p->session_infos; infos; infos = g_list_next (infos))
|
2001-04-17 02:49:29 +08:00
|
|
|
{
|
2010-01-21 01:29:54 +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
|
|
|
|
*/
|
2010-01-20 05:23:23 +08:00
|
|
|
if (! gimp_session_info_is_session_managed (info) ||
|
|
|
|
gimp_session_info_get_factory_entry (info) == NULL)
|
2004-08-29 19:58:05 +08:00
|
|
|
continue;
|
2001-04-19 00:39:34 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_widget (info))
|
2008-05-14 07:43:57 +08:00
|
|
|
gimp_session_info_get_info (info);
|
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
gimp_config_writer_open (writer, "session-info");
|
|
|
|
gimp_config_writer_string (writer,
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (factory));
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
GIMP_CONFIG_GET_INTERFACE (info)->serialize (GIMP_CONFIG (info),
|
|
|
|
writer,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_config_writer_close (writer);
|
2008-05-14 07:43:57 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_widget (info))
|
2008-05-14 07:43:57 +08:00
|
|
|
gimp_session_info_clear_info (info);
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-28 23:23:19 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_restore (GimpDialogFactory *factory)
|
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
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (infos = factory->p->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
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
if (gimp_session_info_get_open (info))
|
2008-05-14 07:43:57 +08:00
|
|
|
{
|
|
|
|
gimp_session_info_restore (info, factory);
|
|
|
|
}
|
2009-09-21 01:08:48 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GIMP_LOG (DIALOG_FACTORY,
|
|
|
|
"skipping to restore session info %p, not open",
|
|
|
|
info);
|
|
|
|
}
|
2001-04-17 02:49:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-20 18:07:51 +08:00
|
|
|
static void
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_hide (GimpDialogFactory *factory)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->open_dialogs; list; list = g_list_next (list))
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2008-09-28 15:46:48 +08:00
|
|
|
GtkWidget *widget = list->data;
|
2008-09-29 19:08:42 +08:00
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (GTK_IS_WIDGET (widget) && gtk_widget_is_toplevel (widget))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2011-03-27 02:32:59 +08:00
|
|
|
GimpDialogFactoryEntry *entry = NULL;
|
|
|
|
GimpDialogVisibilityState visibility = GIMP_DIALOG_VISIBILITY_UNKNOWN;
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2010-02-20 17:32:50 +08:00
|
|
|
gimp_dialog_factory_from_widget (widget, &entry);
|
|
|
|
if (! entry->hideable)
|
|
|
|
continue;
|
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (gtk_widget_get_visible (widget))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2008-09-29 19:08:42 +08:00
|
|
|
gtk_widget_hide (widget);
|
2010-03-09 14:48:25 +08:00
|
|
|
visibility = GIMP_DIALOG_VISIBILITY_HIDDEN;
|
2009-07-20 17:01:56 +08:00
|
|
|
|
|
|
|
GIMP_LOG (WM, "Hiding '%s' [%p]",
|
|
|
|
gtk_window_get_title (GTK_WINDOW (widget)),
|
|
|
|
widget);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visibility = GIMP_DIALOG_VISIBILITY_INVISIBLE;
|
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2008-09-28 15:46:48 +08:00
|
|
|
g_object_set_data (G_OBJECT (widget),
|
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
|
2010-03-01 01:48:16 +08:00
|
|
|
gimp_dialog_factory_show (GimpDialogFactory *factory)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->open_dialogs; list; list = g_list_next (list))
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2008-09-28 15:46:48 +08:00
|
|
|
GtkWidget *widget = list->data;
|
2008-09-29 19:08:42 +08:00
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (GTK_IS_WIDGET (widget) && gtk_widget_is_toplevel (widget))
|
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 =
|
2008-09-28 15:46:48 +08:00
|
|
|
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
2003-10-13 19:57:50 +08:00
|
|
|
GIMP_DIALOG_VISIBILITY_KEY));
|
2001-07-20 18:07:51 +08:00
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (! gtk_widget_get_visible (widget) &&
|
2010-03-09 14:48:25 +08:00
|
|
|
visibility == GIMP_DIALOG_VISIBILITY_HIDDEN)
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2009-07-20 17:01:56 +08:00
|
|
|
GIMP_LOG (WM, "Showing '%s' [%p]",
|
|
|
|
gtk_window_get_title (GTK_WINDOW (widget)),
|
|
|
|
widget);
|
|
|
|
|
2008-03-25 18:00:33 +08:00
|
|
|
/* Don't use gtk_window_present() here, we don't want the
|
|
|
|
* keyboard focus to move.
|
|
|
|
*/
|
2008-09-29 19:08:42 +08:00
|
|
|
gtk_widget_show (widget);
|
2010-03-09 14:48:25 +08:00
|
|
|
g_object_set_data (G_OBJECT (widget),
|
|
|
|
GIMP_DIALOG_VISIBILITY_KEY,
|
|
|
|
GINT_TO_POINTER (GIMP_DIALOG_VISIBILITY_VISIBLE));
|
2005-12-30 05:32:46 +08:00
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (gtk_widget_get_visible (widget))
|
2009-03-23 00:35:53 +08:00
|
|
|
gdk_window_raise (gtk_widget_get_window (widget));
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-01 02:13:14 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_set_busy (GimpDialogFactory *factory)
|
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
|
|
|
|
2010-03-01 02:13:14 +08:00
|
|
|
if (! factory)
|
|
|
|
return;
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->open_dialogs; list; list = g_list_next (list))
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2004-07-12 19:47:54 +08:00
|
|
|
GtkWidget *widget = list->data;
|
2003-11-02 04:53:18 +08:00
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (GTK_IS_WIDGET (widget) && gtk_widget_is_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,
|
2011-07-25 04:09:21 +08:00
|
|
|
GIMP_HANDEDNESS_RIGHT,
|
2003-11-02 04:53:18 +08:00
|
|
|
GDK_WATCH,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
|
|
|
}
|
|
|
|
|
2009-03-23 00:35:53 +08:00
|
|
|
if (gtk_widget_get_window (widget))
|
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (widget), 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
|
|
|
}
|
|
|
|
|
2010-03-01 02:13:14 +08:00
|
|
|
void
|
|
|
|
gimp_dialog_factory_unset_busy (GimpDialogFactory *factory)
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
2010-03-01 02:13:14 +08:00
|
|
|
if (! factory)
|
|
|
|
return;
|
|
|
|
|
2009-12-21 03:19:31 +08:00
|
|
|
for (list = factory->p->open_dialogs; list; list = g_list_next (list))
|
2001-07-20 18:07:51 +08:00
|
|
|
{
|
2004-07-12 19:47:54 +08:00
|
|
|
GtkWidget *widget = list->data;
|
|
|
|
|
2009-10-18 02:20:39 +08:00
|
|
|
if (GTK_IS_WIDGET (widget) && gtk_widget_is_toplevel (widget))
|
2004-08-29 19:58:05 +08:00
|
|
|
{
|
2009-03-23 00:35:53 +08:00
|
|
|
if (gtk_widget_get_window (widget))
|
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
|
2004-08-29 19:58:05 +08:00
|
|
|
}
|
2001-07-20 18:07:51 +08:00
|
|
|
}
|
|
|
|
}
|
2010-03-01 06:20:57 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_get_singleton:
|
|
|
|
*
|
|
|
|
* Returns: The toplevel GimpDialogFactory instance.
|
|
|
|
**/
|
|
|
|
GimpDialogFactory *
|
|
|
|
gimp_dialog_factory_get_singleton (void)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (gimp_toplevel_factory != NULL, NULL);
|
|
|
|
|
|
|
|
return gimp_toplevel_factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_dialog_factory_set_singleton:
|
|
|
|
* @:
|
|
|
|
*
|
|
|
|
* Set the toplevel GimpDialogFactory instance. Must only be called by
|
|
|
|
* dialogs_init()!.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_dialog_factory_set_singleton (GimpDialogFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_if_fail (gimp_toplevel_factory == NULL ||
|
|
|
|
factory == NULL);
|
|
|
|
|
|
|
|
gimp_toplevel_factory = factory;
|
|
|
|
}
|