From b563329c2804e5e5e87abfb51e3985e6605739f0 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 30 Sep 2003 15:48:14 +0000 Subject: [PATCH] accept a list of dialog identifiers and try to raise an existing dockable 2003-09-30 Sven Neumann * app/gui/dialogs-commands.c (dialogs_create_dockable_cmd_callback): accept a list of dialog identifiers and try to raise an existing dockable from the list. If that fails, create a new one from the first entry. * app/gui/image-menu.c * app/gui/toolbox-menu.c: specify alternative dialog identifiers where appropriate. * app/vectors/gimpstroke.c (gimp_stroke_interpolate): use NULL instead of 0. --- ChangeLog | 14 ++++++++++++ app/actions/dialogs-commands.c | 39 ++++++++++++++++++++++++++++------ app/gui/dialogs-commands.c | 39 ++++++++++++++++++++++++++++------ app/gui/image-menu.c | 20 ++++++++--------- app/gui/toolbox-menu.c | 16 +++++++------- app/menus/image-menu.c | 20 ++++++++--------- app/menus/toolbox-menu.c | 16 +++++++------- app/vectors/gimpstroke.c | 2 +- 8 files changed, 115 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 129198e9de..0e4a75b3de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2003-09-30 Sven Neumann + + * app/gui/dialogs-commands.c (dialogs_create_dockable_cmd_callback): + accept a list of dialog identifiers and try to raise an existing + dockable from the list. If that fails, create a new one from the + first entry. + + * app/gui/image-menu.c + * app/gui/toolbox-menu.c: specify alternative dialog identifiers + where appropriate. + + * app/vectors/gimpstroke.c (gimp_stroke_interpolate): use NULL + instead of 0. + 2003-09-30 Simon Budig * app/vectors/gimpbezierstroke.c: diff --git a/app/actions/dialogs-commands.c b/app/actions/dialogs-commands.c index 709a5bab6b..b914124cf8 100644 --- a/app/actions/dialogs-commands.c +++ b/app/actions/dialogs-commands.c @@ -58,9 +58,7 @@ dialogs_create_toplevel_cmd_callback (GtkWidget *widget, { if (action) { - const gchar *identifier; - - identifier = g_quark_to_string ((GQuark) action); + const gchar *identifier = g_quark_to_string ((GQuark) action); if (identifier) gimp_dialog_factory_dialog_new (global_dialog_factory, identifier, -1); @@ -74,12 +72,39 @@ dialogs_create_dockable_cmd_callback (GtkWidget *widget, { if (action) { - const gchar *identifier; + const gchar *identifier = g_quark_to_string ((GQuark) action); - identifier = g_quark_to_string ((GQuark) action); + if (!identifier) + return; - if (identifier) - gimp_dialog_factory_dialog_raise (global_dock_factory, identifier, -1); + /* 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 (identifier, '|')) + { + gchar **ids = g_strsplit (identifier, "|", 0); + gint i; + + for (i = 0; ids[i]; i++) + { + GimpSessionInfo *info; + + info = gimp_dialog_factory_find_session_info (global_dock_factory, + ids[i]); + if (info && info->widget) + break; + } + + gimp_dialog_factory_dialog_raise (global_dock_factory, + ids[i] ? ids[i] : ids[0], -1); + + g_strfreev (ids); + } + else + { + gimp_dialog_factory_dialog_raise (global_dock_factory, + identifier, -1); + } } } diff --git a/app/gui/dialogs-commands.c b/app/gui/dialogs-commands.c index 709a5bab6b..b914124cf8 100644 --- a/app/gui/dialogs-commands.c +++ b/app/gui/dialogs-commands.c @@ -58,9 +58,7 @@ dialogs_create_toplevel_cmd_callback (GtkWidget *widget, { if (action) { - const gchar *identifier; - - identifier = g_quark_to_string ((GQuark) action); + const gchar *identifier = g_quark_to_string ((GQuark) action); if (identifier) gimp_dialog_factory_dialog_new (global_dialog_factory, identifier, -1); @@ -74,12 +72,39 @@ dialogs_create_dockable_cmd_callback (GtkWidget *widget, { if (action) { - const gchar *identifier; + const gchar *identifier = g_quark_to_string ((GQuark) action); - identifier = g_quark_to_string ((GQuark) action); + if (!identifier) + return; - if (identifier) - gimp_dialog_factory_dialog_raise (global_dock_factory, identifier, -1); + /* 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 (identifier, '|')) + { + gchar **ids = g_strsplit (identifier, "|", 0); + gint i; + + for (i = 0; ids[i]; i++) + { + GimpSessionInfo *info; + + info = gimp_dialog_factory_find_session_info (global_dock_factory, + ids[i]); + if (info && info->widget) + break; + } + + gimp_dialog_factory_dialog_raise (global_dock_factory, + ids[i] ? ids[i] : ids[0], -1); + + g_strfreev (ids); + } + else + { + gimp_dialog_factory_dialog_raise (global_dock_factory, + identifier, -1); + } } } diff --git a/app/gui/image-menu.c b/app/gui/image-menu.c index 0929a055ef..be5e828fb9 100644 --- a/app/gui/image-menu.c +++ b/app/gui/image-menu.c @@ -108,7 +108,7 @@ GimpItemFactoryEntry image_menu_entries[] = { { N_("/File/Open Recent/Document _History..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, MENU_SEPARATOR ("/File/---"), @@ -985,32 +985,32 @@ GimpItemFactoryEntry image_menu_entries[] = { { N_("/Dialogs/Brus_hes..."), "B", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_PAINTBRUSH }, - "gimp-brush-grid", + "gimp-brush-grid|gimp-brush-list", GIMP_HELP_BRUSH_DIALOG, NULL }, { { N_("/Dialogs/P_atterns..."), "P", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_BUCKET_FILL }, - "gimp-pattern-grid", + "gimp-pattern-grid|gimp-pattern-list", GIMP_HELP_PATTERN_DIALOG, NULL }, { { N_("/Dialogs/_Gradients..."), "G", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_BLEND }, - "gimp-gradient-list", + "gimp-gradient-list|gimp-gradient-grid", GIMP_HELP_GRADIENT_DIALOG, NULL }, { { N_("/Dialogs/Pal_ettes..."), "P", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_COLOR }, - "gimp-palette-list", + "gimp-palette-list|gimp-palette-grid", GIMP_HELP_PALETTE_DIALOG, NULL }, { { N_("/Dialogs/_Fonts..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_FONT }, - "gimp-font-list", + "gimp-font-list|gimp-font-grid", GIMP_HELP_FONT_DIALOG, NULL }, { { N_("/Dialogs/_Buffers..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_PASTE }, - "gimp-buffer-list", + "gimp-buffer-list|gimp-buffer-grid", GIMP_HELP_BUFFER_DIALOG, NULL }, MENU_SEPARATOR ("/Dialogs/---"), @@ -1018,17 +1018,17 @@ GimpItemFactoryEntry image_menu_entries[] = { { N_("/Dialogs/I_mages..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_IMAGES }, - "gimp-image-list", + "gimp-image-list|gimp-image-grid", GIMP_HELP_IMAGE_DIALOG, NULL }, { { N_("/Dialogs/Document Histor_y..."), "", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, { { N_("/Dialogs/_Templates..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TEMPLATE }, - "gimp-template-list", + "gimp-template-list|gimp-template-grid", GIMP_HELP_TEMPLATE_DIALOG, NULL }, { { N_("/Dialogs/Error Co_nsole..."), NULL, dialogs_create_dockable_cmd_callback, 0, diff --git a/app/gui/toolbox-menu.c b/app/gui/toolbox-menu.c index 156b89f687..2a1efeec6d 100644 --- a/app/gui/toolbox-menu.c +++ b/app/gui/toolbox-menu.c @@ -71,7 +71,7 @@ GimpItemFactoryEntry toolbox_menu_entries[] = { { N_("/File/Open Recent/Document _History..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, /* /File/Acquire */ @@ -174,22 +174,22 @@ GimpItemFactoryEntry toolbox_menu_entries[] = { { N_("/File/Dialogs/_Gradients..."), "G", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_BLEND }, - "gimp-gradient-list", + "gimp-gradient-list|gimp-gradient-grid", GIMP_HELP_GRADIENT_DIALOG, NULL }, { { N_("/File/Dialogs/Pal_ettes..."), "P", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_COLOR }, - "gimp-palette-list", + "gimp-palette-list|gimp-palette-list", GIMP_HELP_PALETTE_DIALOG, NULL }, { { N_("/File/Dialogs/_Fonts..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_FONT }, - "gimp-font-list", + "gimp-font-list, gimp-font-grid", GIMP_HELP_FONT_DIALOG, NULL }, { { N_("/File/Dialogs/_Buffers..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_PASTE }, - "gimp-buffer-list", + "gimp-buffer-list|gimp-buffer-grid", GIMP_HELP_BUFFER_DIALOG, NULL }, MENU_SEPARATOR ("/File/Dialogs/---"), @@ -197,17 +197,17 @@ GimpItemFactoryEntry toolbox_menu_entries[] = { { N_("/File/Dialogs/I_mages..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_IMAGES }, - "gimp-image-list", + "gimp-image-list|gimp-image-grid", GIMP_HELP_IMAGE_DIALOG, NULL }, { { N_("/File/Dialogs/Document Histor_y..."), "", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, { { N_("/File/Dialogs/_Templates..."), "", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TEMPLATE }, - "gimp-template-list", + "gimp-template-list|gimp-template-grid", GIMP_HELP_TEMPLATE_DIALOG, NULL }, { { N_("/File/Dialogs/Error Co_nsole..."), NULL, dialogs_create_dockable_cmd_callback, 0, diff --git a/app/menus/image-menu.c b/app/menus/image-menu.c index 0929a055ef..be5e828fb9 100644 --- a/app/menus/image-menu.c +++ b/app/menus/image-menu.c @@ -108,7 +108,7 @@ GimpItemFactoryEntry image_menu_entries[] = { { N_("/File/Open Recent/Document _History..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, MENU_SEPARATOR ("/File/---"), @@ -985,32 +985,32 @@ GimpItemFactoryEntry image_menu_entries[] = { { N_("/Dialogs/Brus_hes..."), "B", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_PAINTBRUSH }, - "gimp-brush-grid", + "gimp-brush-grid|gimp-brush-list", GIMP_HELP_BRUSH_DIALOG, NULL }, { { N_("/Dialogs/P_atterns..."), "P", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_BUCKET_FILL }, - "gimp-pattern-grid", + "gimp-pattern-grid|gimp-pattern-list", GIMP_HELP_PATTERN_DIALOG, NULL }, { { N_("/Dialogs/_Gradients..."), "G", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_BLEND }, - "gimp-gradient-list", + "gimp-gradient-list|gimp-gradient-grid", GIMP_HELP_GRADIENT_DIALOG, NULL }, { { N_("/Dialogs/Pal_ettes..."), "P", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_COLOR }, - "gimp-palette-list", + "gimp-palette-list|gimp-palette-grid", GIMP_HELP_PALETTE_DIALOG, NULL }, { { N_("/Dialogs/_Fonts..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_FONT }, - "gimp-font-list", + "gimp-font-list|gimp-font-grid", GIMP_HELP_FONT_DIALOG, NULL }, { { N_("/Dialogs/_Buffers..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_PASTE }, - "gimp-buffer-list", + "gimp-buffer-list|gimp-buffer-grid", GIMP_HELP_BUFFER_DIALOG, NULL }, MENU_SEPARATOR ("/Dialogs/---"), @@ -1018,17 +1018,17 @@ GimpItemFactoryEntry image_menu_entries[] = { { N_("/Dialogs/I_mages..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_IMAGES }, - "gimp-image-list", + "gimp-image-list|gimp-image-grid", GIMP_HELP_IMAGE_DIALOG, NULL }, { { N_("/Dialogs/Document Histor_y..."), "", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, { { N_("/Dialogs/_Templates..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TEMPLATE }, - "gimp-template-list", + "gimp-template-list|gimp-template-grid", GIMP_HELP_TEMPLATE_DIALOG, NULL }, { { N_("/Dialogs/Error Co_nsole..."), NULL, dialogs_create_dockable_cmd_callback, 0, diff --git a/app/menus/toolbox-menu.c b/app/menus/toolbox-menu.c index 156b89f687..2a1efeec6d 100644 --- a/app/menus/toolbox-menu.c +++ b/app/menus/toolbox-menu.c @@ -71,7 +71,7 @@ GimpItemFactoryEntry toolbox_menu_entries[] = { { N_("/File/Open Recent/Document _History..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, /* /File/Acquire */ @@ -174,22 +174,22 @@ GimpItemFactoryEntry toolbox_menu_entries[] = { { N_("/File/Dialogs/_Gradients..."), "G", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TOOL_BLEND }, - "gimp-gradient-list", + "gimp-gradient-list|gimp-gradient-grid", GIMP_HELP_GRADIENT_DIALOG, NULL }, { { N_("/File/Dialogs/Pal_ettes..."), "P", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_COLOR }, - "gimp-palette-list", + "gimp-palette-list|gimp-palette-list", GIMP_HELP_PALETTE_DIALOG, NULL }, { { N_("/File/Dialogs/_Fonts..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_SELECT_FONT }, - "gimp-font-list", + "gimp-font-list, gimp-font-grid", GIMP_HELP_FONT_DIALOG, NULL }, { { N_("/File/Dialogs/_Buffers..."), "foo", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_PASTE }, - "gimp-buffer-list", + "gimp-buffer-list|gimp-buffer-grid", GIMP_HELP_BUFFER_DIALOG, NULL }, MENU_SEPARATOR ("/File/Dialogs/---"), @@ -197,17 +197,17 @@ GimpItemFactoryEntry toolbox_menu_entries[] = { { N_("/File/Dialogs/I_mages..."), NULL, dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_IMAGES }, - "gimp-image-list", + "gimp-image-list|gimp-image-grid", GIMP_HELP_IMAGE_DIALOG, NULL }, { { N_("/File/Dialogs/Document Histor_y..."), "", dialogs_create_dockable_cmd_callback, 0, "", GTK_STOCK_OPEN }, - "gimp-document-list", + "gimp-document-list|gimp-document-grid", GIMP_HELP_DOCUMENT_DIALOG, NULL }, { { N_("/File/Dialogs/_Templates..."), "", dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_TEMPLATE }, - "gimp-template-list", + "gimp-template-list|gimp-template-grid", GIMP_HELP_TEMPLATE_DIALOG, NULL }, { { N_("/File/Dialogs/Error Co_nsole..."), NULL, dialogs_create_dockable_cmd_callback, 0, diff --git a/app/vectors/gimpstroke.c b/app/vectors/gimpstroke.c index e28074e678..ce4859b831 100644 --- a/app/vectors/gimpstroke.c +++ b/app/vectors/gimpstroke.c @@ -894,7 +894,7 @@ gimp_stroke_interpolate (const GimpStroke *stroke, gdouble precision, gboolean *ret_closed) { - g_return_val_if_fail (GIMP_IS_STROKE (stroke), 0); + g_return_val_if_fail (GIMP_IS_STROKE (stroke), NULL); return GIMP_STROKE_GET_CLASS (stroke)->interpolate (stroke, precision, ret_closed);