2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-10-02 19:26:26 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* 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"
|
|
|
|
|
2004-04-27 20:28:27 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "gui-types.h"
|
|
|
|
|
2003-11-12 07:56:00 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
#include "core/gimp.h"
|
2004-07-11 06:25:02 +08:00
|
|
|
#include "core/gimp-utils.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
#include "core/gimpgradient.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
#include "core/gimpimage.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
#include "core/gimppalette.h"
|
|
|
|
#include "core/gimppattern.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
|
|
|
|
#include "text/gimpfont.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
|
2004-04-26 23:01:00 +08:00
|
|
|
#include "widgets/gimpactiongroup.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
#include "widgets/gimpbrushselect.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
2006-06-26 16:09:23 +08:00
|
|
|
#include "widgets/gimpdocked.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
#include "widgets/gimpfontselect.h"
|
|
|
|
#include "widgets/gimpgradientselect.h"
|
2004-07-11 04:29:11 +08:00
|
|
|
#include "widgets/gimphelp.h"
|
2004-07-10 03:14:59 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
#include "widgets/gimpmenufactory.h"
|
|
|
|
#include "widgets/gimppaletteselect.h"
|
|
|
|
#include "widgets/gimppatternselect.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "widgets/gimpprogressdialog.h"
|
2004-04-22 00:33:17 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2005-09-10 02:07:31 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
#include "display/gimpdisplay-foreach.h"
|
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
|
2004-04-26 23:01:00 +08:00
|
|
|
#include "actions/plug-in-actions.h"
|
|
|
|
|
2004-05-06 15:41:53 +08:00
|
|
|
#include "menus/menus.h"
|
|
|
|
|
2006-07-19 14:50:34 +08:00
|
|
|
#include "gui-message.h"
|
2006-10-30 18:13:06 +08:00
|
|
|
#include "gui-vtable.h"
|
2003-11-10 23:13:29 +08:00
|
|
|
#include "themes.h"
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2006-09-10 00:36:15 +08:00
|
|
|
static void gui_ungrab (Gimp *gimp);
|
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
static void gui_threads_enter (Gimp *gimp);
|
|
|
|
static void gui_threads_leave (Gimp *gimp);
|
|
|
|
static void gui_set_busy (Gimp *gimp);
|
|
|
|
static void gui_unset_busy (Gimp *gimp);
|
|
|
|
static void gui_help (Gimp *gimp,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_id);
|
|
|
|
static const gchar * gui_get_program_class (Gimp *gimp);
|
|
|
|
static gchar * gui_get_display_name (Gimp *gimp,
|
|
|
|
gint display_ID,
|
|
|
|
gint *monitor_number);
|
|
|
|
static const gchar * gui_get_theme_dir (Gimp *gimp);
|
|
|
|
static GimpObject * gui_display_get_by_ID (Gimp *gimp,
|
|
|
|
gint ID);
|
|
|
|
static gint gui_display_get_ID (GimpObject *display);
|
|
|
|
static guint32 gui_display_get_window (GimpObject *display);
|
2008-03-19 05:22:21 +08:00
|
|
|
static GimpObject * gui_display_create (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpUnit unit,
|
|
|
|
gdouble scale);
|
|
|
|
static void gui_display_delete (GimpObject *display);
|
|
|
|
static void gui_displays_reconnect (Gimp *gimp,
|
|
|
|
GimpImage *old_image,
|
|
|
|
GimpImage *new_image);
|
2008-03-21 04:08:40 +08:00
|
|
|
static GimpDisplay * gui_get_empty_display (Gimp *gimp);
|
2006-04-05 16:38:33 +08:00
|
|
|
static GimpProgress * gui_new_progress (Gimp *gimp,
|
|
|
|
GimpObject *display);
|
|
|
|
static void gui_free_progress (Gimp *gimp,
|
|
|
|
GimpProgress *progress);
|
|
|
|
static gboolean gui_pdb_dialog_new (Gimp *gimp,
|
|
|
|
GimpContext *context,
|
2006-09-22 17:24:41 +08:00
|
|
|
GimpProgress *progress,
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpContainer *container,
|
|
|
|
const gchar *title,
|
|
|
|
const gchar *callback_name,
|
|
|
|
const gchar *object_name,
|
|
|
|
va_list args);
|
|
|
|
static gboolean gui_pdb_dialog_set (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
const gchar *callback_name,
|
|
|
|
const gchar *object_name,
|
|
|
|
va_list args);
|
|
|
|
static gboolean gui_pdb_dialog_close (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
const gchar *callback_name);
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
static gboolean gui_recent_list_add_uri (Gimp *gimp,
|
|
|
|
const gchar *uri,
|
|
|
|
const gchar *mime_type);
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
gui_vtable_init (Gimp *gimp)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2006-09-10 00:36:15 +08:00
|
|
|
gimp->gui.ungrab = gui_ungrab;
|
2005-03-25 00:08:04 +08:00
|
|
|
gimp->gui.threads_enter = gui_threads_enter;
|
|
|
|
gimp->gui.threads_leave = gui_threads_leave;
|
|
|
|
gimp->gui.set_busy = gui_set_busy;
|
|
|
|
gimp->gui.unset_busy = gui_unset_busy;
|
2006-08-09 02:18:40 +08:00
|
|
|
gimp->gui.show_message = gui_message;
|
2005-03-25 00:08:04 +08:00
|
|
|
gimp->gui.help = gui_help;
|
|
|
|
gimp->gui.get_program_class = gui_get_program_class;
|
|
|
|
gimp->gui.get_display_name = gui_get_display_name;
|
|
|
|
gimp->gui.get_theme_dir = gui_get_theme_dir;
|
|
|
|
gimp->gui.display_get_by_id = gui_display_get_by_ID;
|
|
|
|
gimp->gui.display_get_id = gui_display_get_ID;
|
2005-09-06 04:47:12 +08:00
|
|
|
gimp->gui.display_get_window = gui_display_get_window;
|
2005-03-25 00:08:04 +08:00
|
|
|
gimp->gui.display_create = gui_display_create;
|
|
|
|
gimp->gui.display_delete = gui_display_delete;
|
|
|
|
gimp->gui.displays_reconnect = gui_displays_reconnect;
|
|
|
|
gimp->gui.progress_new = gui_new_progress;
|
|
|
|
gimp->gui.progress_free = gui_free_progress;
|
|
|
|
gimp->gui.pdb_dialog_new = gui_pdb_dialog_new;
|
|
|
|
gimp->gui.pdb_dialog_set = gui_pdb_dialog_set;
|
|
|
|
gimp->gui.pdb_dialog_close = gui_pdb_dialog_close;
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
gimp->gui.recent_list_add_uri = gui_recent_list_add_uri;
|
2003-10-02 19:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2006-09-10 00:36:15 +08:00
|
|
|
static void
|
|
|
|
gui_ungrab (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_display_get_default ();
|
|
|
|
|
2006-09-10 19:39:24 +08:00
|
|
|
if (display)
|
|
|
|
{
|
|
|
|
gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
|
|
|
|
gdk_display_keyboard_ungrab (display, GDK_CURRENT_TIME);
|
|
|
|
}
|
2006-09-10 00:36:15 +08:00
|
|
|
}
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
static void
|
|
|
|
gui_threads_enter (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GDK_THREADS_ENTER ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_threads_leave (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GDK_THREADS_LEAVE ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_set_busy (Gimp *gimp)
|
|
|
|
{
|
|
|
|
gimp_displays_set_busy (gimp);
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factories_set_busy ();
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_unset_busy (Gimp *gimp)
|
|
|
|
{
|
|
|
|
gimp_displays_unset_busy (gimp);
|
2003-10-13 19:57:50 +08:00
|
|
|
gimp_dialog_factories_unset_busy ();
|
2003-10-02 19:26:26 +08:00
|
|
|
|
|
|
|
gdk_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-07-11 04:29:11 +08:00
|
|
|
gui_help (Gimp *gimp,
|
|
|
|
const gchar *help_domain,
|
|
|
|
const gchar *help_id)
|
2003-10-02 19:26:26 +08:00
|
|
|
{
|
2004-07-11 04:29:11 +08:00
|
|
|
gimp_help_show (gimp, help_domain, help_id);
|
2003-10-02 19:26:26 +08:00
|
|
|
}
|
|
|
|
|
2004-07-12 19:41:19 +08:00
|
|
|
static const gchar *
|
|
|
|
gui_get_program_class (Gimp *gimp)
|
|
|
|
{
|
|
|
|
return gdk_get_program_class ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gui_get_display_name (Gimp *gimp,
|
2006-03-29 01:55:52 +08:00
|
|
|
gint display_ID,
|
2004-07-12 19:41:19 +08:00
|
|
|
gint *monitor_number)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display = NULL;
|
2004-07-12 19:41:19 +08:00
|
|
|
GdkScreen *screen;
|
|
|
|
gint monitor;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display_ID > 0)
|
|
|
|
display = gimp_display_get_by_ID (gimp, display_ID);
|
2004-07-12 19:41:19 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (display)
|
2004-07-12 19:41:19 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
screen = gtk_widget_get_screen (display->shell);
|
2004-07-12 19:41:19 +08:00
|
|
|
monitor = gdk_screen_get_monitor_at_window (screen,
|
2006-03-29 01:55:52 +08:00
|
|
|
display->shell->window);
|
2004-07-12 19:41:19 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
|
|
|
|
gdk_display_get_pointer (gdk_display_get_default (),
|
|
|
|
&screen, &x, &y, NULL);
|
|
|
|
monitor = gdk_screen_get_monitor_at_point (screen, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
*monitor_number = monitor;
|
|
|
|
|
|
|
|
if (screen)
|
|
|
|
return gdk_screen_make_display_name (screen);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
gui_get_theme_dir (Gimp *gimp)
|
|
|
|
{
|
|
|
|
return themes_get_theme_dir (gimp, GIMP_GUI_CONFIG (gimp->config)->theme);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpObject *
|
|
|
|
gui_display_get_by_ID (Gimp *gimp,
|
|
|
|
gint ID)
|
|
|
|
{
|
|
|
|
return (GimpObject *) gimp_display_get_by_ID (gimp, ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gui_display_get_ID (GimpObject *display)
|
|
|
|
{
|
|
|
|
return gimp_display_get_ID (GIMP_DISPLAY (display));
|
|
|
|
}
|
|
|
|
|
2005-09-06 04:47:12 +08:00
|
|
|
static guint32
|
|
|
|
gui_display_get_window (GimpObject *display)
|
|
|
|
{
|
2005-09-10 02:07:31 +08:00
|
|
|
GimpDisplay *disp = GIMP_DISPLAY (display);
|
|
|
|
|
|
|
|
if (disp->shell)
|
|
|
|
return (guint32) gimp_window_get_native (GTK_WINDOW (disp->shell));
|
|
|
|
|
2005-09-06 04:47:12 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-07-12 19:41:19 +08:00
|
|
|
static GimpObject *
|
2008-03-19 05:22:21 +08:00
|
|
|
gui_display_create (Gimp *gimp,
|
|
|
|
GimpImage *image,
|
2004-07-12 19:41:19 +08:00
|
|
|
GimpUnit unit,
|
|
|
|
gdouble scale)
|
|
|
|
{
|
2008-03-19 05:22:21 +08:00
|
|
|
GimpContext *context = gimp_get_user_context (gimp);
|
|
|
|
GimpDisplay *display = NULL;
|
|
|
|
|
2008-03-21 04:05:45 +08:00
|
|
|
if (gui_get_empty_display (gimp) != NULL)
|
2008-03-19 05:22:21 +08:00
|
|
|
{
|
2008-03-21 04:05:45 +08:00
|
|
|
display = gui_get_empty_display (gimp);
|
2004-07-12 19:41:19 +08:00
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
gimp_display_fill (display, image, unit, scale);
|
2008-03-19 05:22:21 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GList *image_managers = gimp_ui_managers_from_name ("<Image>");
|
2004-07-12 19:41:19 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
g_return_val_if_fail (image_managers != NULL, NULL);
|
2008-02-27 16:20:54 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
display = gimp_display_new (gimp, image, unit, scale,
|
|
|
|
global_menu_factory,
|
|
|
|
image_managers->data);
|
|
|
|
}
|
2004-07-12 19:41:19 +08:00
|
|
|
|
2008-03-21 04:05:45 +08:00
|
|
|
gimp_context_set_display (context, display);
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_ui_manager_update (GIMP_DISPLAY_SHELL (display->shell)->menubar_manager,
|
|
|
|
display);
|
2004-07-12 19:41:19 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
return GIMP_OBJECT (display);
|
2004-07-12 19:41:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_display_delete (GimpObject *display)
|
|
|
|
{
|
|
|
|
gimp_display_delete (GIMP_DISPLAY (display));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gui_displays_reconnect (Gimp *gimp,
|
|
|
|
GimpImage *old_image,
|
|
|
|
GimpImage *new_image)
|
|
|
|
{
|
|
|
|
gimp_displays_reconnect (gimp, old_image, new_image);
|
|
|
|
}
|
|
|
|
|
2008-03-21 04:08:40 +08:00
|
|
|
static GimpDisplay *
|
2008-03-21 04:05:45 +08:00
|
|
|
gui_get_empty_display (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpDisplay *display = NULL;
|
|
|
|
|
|
|
|
if (gimp_container_num_children (gimp->displays) == 1)
|
|
|
|
{
|
|
|
|
display = (GimpDisplay *) gimp_container_get_child_by_index (gimp->displays, 0);
|
|
|
|
|
|
|
|
if (display->image != NULL)
|
|
|
|
{
|
|
|
|
/* The display was not empty */
|
|
|
|
display = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
2003-10-02 19:26:26 +08:00
|
|
|
static GimpProgress *
|
2006-03-24 05:56:13 +08:00
|
|
|
gui_new_progress (Gimp *gimp,
|
|
|
|
GimpObject *display)
|
2003-10-02 19:26:26 +08:00
|
|
|
{
|
2006-03-24 05:56:13 +08:00
|
|
|
g_return_val_if_fail (display == NULL || GIMP_IS_DISPLAY (display), NULL);
|
2004-08-11 17:36:51 +08:00
|
|
|
|
|
|
|
if (display)
|
|
|
|
return GIMP_PROGRESS (display);
|
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
return GIMP_PROGRESS (gimp_progress_dialog_new ());
|
2003-10-02 19:26:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-08-11 02:47:21 +08:00
|
|
|
gui_free_progress (Gimp *gimp,
|
|
|
|
GimpProgress *progress)
|
2003-10-02 19:26:26 +08:00
|
|
|
{
|
2004-08-11 02:47:21 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROGRESS_DIALOG (progress));
|
2003-10-02 19:26:26 +08:00
|
|
|
|
2004-08-11 17:36:51 +08:00
|
|
|
if (GIMP_IS_PROGRESS_DIALOG (progress))
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (progress));
|
2003-10-02 19:26:26 +08:00
|
|
|
}
|
|
|
|
|
2007-08-07 21:15:47 +08:00
|
|
|
static gboolean
|
|
|
|
gui_pdb_dialog_present (GtkWindow *window)
|
|
|
|
{
|
|
|
|
gtk_window_present (window);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-07-10 03:14:59 +08:00
|
|
|
static gboolean
|
|
|
|
gui_pdb_dialog_new (Gimp *gimp,
|
|
|
|
GimpContext *context,
|
2006-09-22 17:24:41 +08:00
|
|
|
GimpProgress *progress,
|
2004-07-10 03:14:59 +08:00
|
|
|
GimpContainer *container,
|
|
|
|
const gchar *title,
|
|
|
|
const gchar *callback_name,
|
|
|
|
const gchar *object_name,
|
|
|
|
va_list args)
|
|
|
|
{
|
2004-09-27 18:45:49 +08:00
|
|
|
GType dialog_type = G_TYPE_NONE;
|
|
|
|
const gchar *dialog_role = NULL;
|
|
|
|
const gchar *help_id = NULL;
|
2004-07-10 03:14:59 +08:00
|
|
|
|
|
|
|
if (container->children_type == GIMP_TYPE_BRUSH)
|
|
|
|
{
|
|
|
|
dialog_type = GIMP_TYPE_BRUSH_SELECT;
|
|
|
|
dialog_role = "gimp-brush-selection";
|
|
|
|
help_id = GIMP_HELP_BRUSH_DIALOG;
|
|
|
|
}
|
|
|
|
else if (container->children_type == GIMP_TYPE_FONT)
|
|
|
|
{
|
|
|
|
dialog_type = GIMP_TYPE_FONT_SELECT;
|
|
|
|
dialog_role = "gimp-font-selection";
|
|
|
|
help_id = GIMP_HELP_FONT_DIALOG;
|
|
|
|
}
|
|
|
|
else if (container->children_type == GIMP_TYPE_GRADIENT)
|
|
|
|
{
|
|
|
|
dialog_type = GIMP_TYPE_GRADIENT_SELECT;
|
|
|
|
dialog_role = "gimp-gradient-selection";
|
|
|
|
help_id = GIMP_HELP_GRADIENT_DIALOG;
|
|
|
|
}
|
|
|
|
else if (container->children_type == GIMP_TYPE_PALETTE)
|
|
|
|
{
|
|
|
|
dialog_type = GIMP_TYPE_PALETTE_SELECT;
|
|
|
|
dialog_role = "gimp-palette-selection";
|
|
|
|
help_id = GIMP_HELP_PALETTE_DIALOG;
|
|
|
|
}
|
|
|
|
else if (container->children_type == GIMP_TYPE_PATTERN)
|
|
|
|
{
|
|
|
|
dialog_type = GIMP_TYPE_PATTERN_SELECT;
|
|
|
|
dialog_role = "gimp-pattern-selection";
|
|
|
|
help_id = GIMP_HELP_PATTERN_DIALOG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog_type != G_TYPE_NONE)
|
|
|
|
{
|
|
|
|
GimpObject *object = NULL;
|
|
|
|
|
|
|
|
if (object_name && strlen (object_name))
|
|
|
|
object = gimp_container_get_child_by_name (container, object_name);
|
|
|
|
|
|
|
|
if (! object)
|
|
|
|
object = gimp_context_get_by_type (context, container->children_type);
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
{
|
2004-07-11 06:25:02 +08:00
|
|
|
GParameter *params = NULL;
|
|
|
|
gint n_params = 0;
|
|
|
|
GtkWidget *dialog;
|
2006-06-26 16:09:23 +08:00
|
|
|
GtkWidget *view;
|
2004-07-11 06:25:02 +08:00
|
|
|
|
|
|
|
params = gimp_parameters_append (dialog_type, params, &n_params,
|
|
|
|
"title", title,
|
|
|
|
"role", dialog_role,
|
|
|
|
"help-func", gimp_standard_help_func,
|
|
|
|
"help-id", help_id,
|
2006-04-26 17:13:47 +08:00
|
|
|
"pdb", gimp->pdb,
|
2004-07-11 06:25:02 +08:00
|
|
|
"context", context,
|
|
|
|
"select-type", container->children_type,
|
|
|
|
"initial-object", object,
|
|
|
|
"callback-name", callback_name,
|
|
|
|
"menu-factory", global_menu_factory,
|
|
|
|
NULL);
|
2004-07-10 03:14:59 +08:00
|
|
|
|
2004-07-11 06:25:02 +08:00
|
|
|
params = gimp_parameters_append_valist (dialog_type,
|
|
|
|
params, &n_params,
|
|
|
|
args);
|
2004-07-10 03:14:59 +08:00
|
|
|
|
|
|
|
dialog = g_object_newv (dialog_type, n_params, params);
|
|
|
|
|
2004-07-11 06:25:02 +08:00
|
|
|
gimp_parameters_free (params, n_params);
|
2004-07-10 03:14:59 +08:00
|
|
|
|
2006-06-26 16:09:23 +08:00
|
|
|
view = GIMP_PDB_DIALOG (dialog)->view;
|
|
|
|
if (view)
|
|
|
|
gimp_docked_set_show_button_bar (GIMP_DOCKED (view), FALSE);
|
|
|
|
|
2006-09-22 17:24:41 +08:00
|
|
|
if (progress)
|
|
|
|
{
|
|
|
|
guint32 window = gimp_progress_get_window (progress);
|
|
|
|
|
|
|
|
if (window)
|
|
|
|
gimp_window_set_transient_for (GTK_WINDOW (dialog), window);
|
|
|
|
}
|
|
|
|
|
2004-07-10 03:14:59 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
2007-08-07 21:15:47 +08:00
|
|
|
/* workaround for bug #360106 */
|
|
|
|
{
|
2007-08-13 15:08:50 +08:00
|
|
|
GSource *source = g_timeout_source_new (100);
|
|
|
|
GClosure *closure;
|
|
|
|
|
|
|
|
closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present),
|
|
|
|
G_OBJECT (dialog));
|
2007-08-07 21:15:47 +08:00
|
|
|
|
|
|
|
g_source_set_closure (source, closure);
|
|
|
|
g_source_attach (source, NULL);
|
|
|
|
g_source_unref (source);
|
|
|
|
}
|
|
|
|
|
2004-07-10 03:14:59 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gui_pdb_dialog_set (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
const gchar *callback_name,
|
|
|
|
const gchar *object_name,
|
|
|
|
va_list args)
|
|
|
|
{
|
|
|
|
GimpPdbDialogClass *klass = NULL;
|
|
|
|
|
|
|
|
if (container->children_type == GIMP_TYPE_BRUSH)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_FONT)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_GRADIENT)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_PALETTE)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_PATTERN)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);
|
|
|
|
|
|
|
|
if (klass)
|
|
|
|
{
|
|
|
|
GimpPdbDialog *dialog;
|
|
|
|
|
|
|
|
dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);
|
|
|
|
|
|
|
|
if (dialog && dialog->select_type == container->children_type)
|
|
|
|
{
|
|
|
|
GimpObject *object;
|
|
|
|
|
|
|
|
object = gimp_container_get_child_by_name (container, object_name);
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
{
|
2005-11-24 23:33:42 +08:00
|
|
|
const gchar *prop_name = va_arg (args, const gchar *);
|
2004-07-10 03:14:59 +08:00
|
|
|
|
|
|
|
gimp_context_set_by_type (dialog->context, dialog->select_type,
|
|
|
|
object);
|
|
|
|
|
|
|
|
if (prop_name)
|
|
|
|
g_object_set_valist (G_OBJECT (dialog), prop_name, args);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2005-11-24 23:33:42 +08:00
|
|
|
|
2004-07-10 03:14:59 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gui_pdb_dialog_close (Gimp *gimp,
|
|
|
|
GimpContainer *container,
|
|
|
|
const gchar *callback_name)
|
|
|
|
{
|
|
|
|
GimpPdbDialogClass *klass = NULL;
|
|
|
|
|
|
|
|
if (container->children_type == GIMP_TYPE_BRUSH)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_FONT)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_GRADIENT)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_PALETTE)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
|
|
|
|
else if (container->children_type == GIMP_TYPE_PATTERN)
|
|
|
|
klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);
|
|
|
|
|
|
|
|
if (klass)
|
|
|
|
{
|
|
|
|
GimpPdbDialog *dialog;
|
|
|
|
|
|
|
|
dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);
|
|
|
|
|
|
|
|
if (dialog && dialog->select_type == container->children_type)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
|
|
|
|
static gboolean
|
2007-09-14 00:55:55 +08:00
|
|
|
gui_recent_list_add_uri (Gimp *gimp,
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
const gchar *uri,
|
|
|
|
const gchar *mime_type)
|
|
|
|
{
|
2007-09-21 03:28:39 +08:00
|
|
|
GtkRecentManager *manager;
|
2007-09-14 00:55:55 +08:00
|
|
|
GtkRecentData recent;
|
2007-09-14 23:17:48 +08:00
|
|
|
const gchar *groups[2] = { "Graphics", NULL };
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (uri != NULL, FALSE);
|
|
|
|
|
2007-09-21 03:28:39 +08:00
|
|
|
manager = gtk_recent_manager_get_default ();
|
2007-09-14 00:55:55 +08:00
|
|
|
|
2007-09-21 03:28:39 +08:00
|
|
|
g_return_val_if_fail (manager != NULL, FALSE);
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
|
|
|
|
/* use last part of the URI */
|
|
|
|
recent.display_name = NULL;
|
2007-09-14 00:55:55 +08:00
|
|
|
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
/* no special description */
|
2007-09-14 00:55:55 +08:00
|
|
|
recent.description = NULL;
|
2007-09-21 03:28:39 +08:00
|
|
|
recent.mime_type = (mime_type ?
|
|
|
|
(gchar *) mime_type : "application/octet-stream");
|
2007-09-14 23:17:48 +08:00
|
|
|
recent.app_name = "GNU Image Manipulation Program";
|
2007-09-14 00:55:55 +08:00
|
|
|
recent.app_exec = GIMP_COMMAND " %u";
|
2007-09-21 03:28:39 +08:00
|
|
|
recent.groups = (gchar **) groups;
|
2007-09-14 00:55:55 +08:00
|
|
|
recent.is_private = FALSE;
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
|
2007-09-21 03:28:39 +08:00
|
|
|
return gtk_recent_manager_add_full (manager, uri, &recent);
|
drop own recently used files code in favour of GtkRecentManager:
* app/core/gimp-gui.c (gimp_recent_list_add_uri), app/core/gimp-gui.h,
app/gui/gui-vtable.c (gui_recent_list_add_uri): add
{gimp,gui}_recent_list_add_uri(), gui_recent_list_add_uri() dispatches to
GtkRecentManager
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image),
app/actions/file-commands.c (file_save_cmd_callback),
app/widgets/gimpdnd-xds.c (gimp_dnd_xds_save_image): pass Gimp instance to
file_save() calls
* app/file/file-open.c (file_open_with_proc_and_display,
file_open_layers), app/file/file-save.c (file_save), app/file/file-save.h:
pass Gimp instance to gimp_recent_list_add_uri() calls
* app/file/gimprecentitem.c, app/file/gimprecentitem.h,
app/file/gimprecentlist.c, app/file/gimprecentlist.h: removed
* app/file/Makefile.am: drop reference to removed files
svn path=/trunk/; revision=23526
2007-09-13 22:19:30 +08:00
|
|
|
}
|