Commit 947e2859 authored by Martin Nordholts's avatar Martin Nordholts
Browse files

app: Remove gimp_dialog_factory_from_name()

We only have one dialog factory now, and
gimp_dialog_factory_from_name() doesn't provide compile-time type
safety, so use global_dialog_factory directly instead.
parent 2a51c69e
......@@ -33,6 +33,8 @@
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimpdialogfactory.h"
#include "dialogs/dialogs.h"
#include "actions.h"
#include "colormap-commands.h"
......@@ -81,7 +83,7 @@ colormap_edit_color_cmd_callback (GtkAction *action,
GIMP_STOCK_COLORMAP,
desc,
GTK_WIDGET (editor),
gimp_dialog_factory_from_name ("toplevel"),
global_dialog_factory,
"gimp-colormap-editor-color-dialog",
(const GimpRGB *) &color,
FALSE, FALSE);
......
......@@ -41,6 +41,8 @@
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimpcolormapeditor.h"
#include "dialogs/dialogs.h"
#include "actions.h"
#include "context-commands.h"
......@@ -868,14 +870,11 @@ context_set_color_index (gint index,
static GimpPaletteEditor *
context_get_palette_editor (void)
{
GimpDialogFactory *dialog_factory;
GimpSessionInfo *info;
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
GimpSessionInfo *info = NULL;
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (global_dialog_factory), NULL);
info = gimp_dialog_factory_find_session_info (dialog_factory,
info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-palette-editor");
if (info && gimp_session_info_get_widget (info))
return GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
......@@ -886,14 +885,11 @@ context_get_palette_editor (void)
static GimpColormapEditor *
context_get_colormap_editor (void)
{
GimpDialogFactory *dialog_factory;
GimpSessionInfo *info;
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
GimpSessionInfo *info = NULL;
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (global_dialog_factory), NULL);
info = gimp_dialog_factory_find_session_info (dialog_factory,
info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-indexed-palette");
if (info && gimp_session_info_get_widget (info))
return GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
......
......@@ -32,6 +32,8 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimppaletteeditor.h"
#include "dialogs/dialogs.h"
#include "palette-editor-commands.h"
#include "gimp-intl.h"
......@@ -69,7 +71,7 @@ palette_editor_edit_color_cmd_callback (GtkAction *action,
GIMP_STOCK_PALETTE,
_("Edit Color Palette Entry"),
GTK_WIDGET (editor),
gimp_dialog_factory_from_name ("toplevel"),
global_dialog_factory,
"gimp-palette-editor-color-dialog",
&editor->color->color,
FALSE, FALSE);
......
......@@ -59,6 +59,8 @@
#include "gui/session.h"
#include "gui/themes.h"
#include "dialogs/dialogs.h"
#include "preferences-dialog.h"
#include "resolution-calibrate-dialog.h"
......@@ -491,7 +493,7 @@ static void
prefs_input_devices_dialog (GtkWidget *widget,
Gimp *gimp)
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_from_name ("toplevel"),
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-input-devices-dialog", 0);
}
......@@ -500,7 +502,7 @@ static void
prefs_keyboard_shortcuts_dialog (GtkWidget *widget,
Gimp *gimp)
{
gimp_dialog_factory_dialog_raise (gimp_dialog_factory_from_name ("toplevel"),
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-keyboard-shortcuts-dialog", 0);
}
......
......@@ -31,6 +31,8 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpsessioninfo.h"
#include "dialogs/dialogs.h"
#include "gimpdisplay.h"
#include "gimpcursorview.h"
#include "gimpdisplayshell.h"
......@@ -126,7 +128,6 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gdouble image_y)
{
GimpStatusbar *statusbar;
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
GimpImage *image;
gboolean new_cursor;
......@@ -165,8 +166,7 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gimp_statusbar_update_cursor (statusbar, precision, image_x, image_y);
factory = gimp_dialog_factory_from_name ("toplevel");
session_info = gimp_dialog_factory_find_session_info (factory,
session_info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-cursor-view");
if (session_info && gimp_session_info_get_widget (session_info))
{
......@@ -195,7 +195,6 @@ void
gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
{
GimpStatusbar *statusbar;
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -204,8 +203,7 @@ gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
gimp_statusbar_clear_cursor (statusbar);
factory = gimp_dialog_factory_from_name ("toplevel");
session_info = gimp_dialog_factory_find_session_info (factory,
session_info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-cursor-view");
if (session_info && gimp_session_info_get_widget (session_info))
{
......
......@@ -139,18 +139,10 @@ session_init (Gimp *gimp)
/* In versions <= GIMP 2.6 there was a "toolbox", a
* "dock", a "display" and a "toplevel" factory. These
* are now merged so if the factory name is "toolbox",
* "dock" or "display", get the "toplevel" factory
* instead. We don't change factory_name though because
* we need it below
* are now merged to a single global_dialog_factory. We
* need the legacy name though, so keep it around.
*/
factory = gimp_dialog_factory_from_name ((strcmp ("toolbox", factory_name) == 0 ||
strcmp ("dock", factory_name) == 0 ||
strcmp ("display", factory_name) == 0) ?
"toplevel" :
factory_name);
if (! factory)
break;
factory = global_dialog_factory;
info = gimp_session_info_new ();
......
......@@ -181,8 +181,7 @@ gimp_ui_tool_options_editor_updates (GimpTestFixture *fixture,
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *image_window = GIMP_IMAGE_WINDOW (toplevel);
GimpUIManager *ui_manager = gimp_image_window_get_ui_manager (image_window);
GimpDialogFactory *dock_factory = gimp_dialog_factory_from_name ("toplevel");
GtkWidget *dockable = gimp_dialog_factory_dialog_new (dock_factory,
GtkWidget *dockable = gimp_dialog_factory_dialog_new (global_dialog_factory,
gtk_widget_get_screen (toplevel),
"gimp-tool-options",
-1 /*view_size*/,
......@@ -222,7 +221,6 @@ gimp_ui_create_new_image_via_dialog (GimpTestFixture *fixture,
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
GimpImageWindow *image_window = GIMP_IMAGE_WINDOW (toplevel);
GimpUIManager *ui_manager = gimp_image_window_get_ui_manager (image_window);
GimpDialogFactory *dialog_factory = gimp_dialog_factory_from_name ("toplevel");
GtkWidget *new_image_dialog = NULL;
guint n_initial_images = g_list_length (gimp_get_image_iter (gimp));
guint n_images = -1;
......@@ -236,7 +234,7 @@ gimp_ui_create_new_image_via_dialog (GimpTestFixture *fixture,
/* Get the GtkWindow of the dialog */
new_image_dialog =
gimp_dialog_factory_dialog_raise (dialog_factory,
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (GTK_WIDGET (shell)),
"gimp-image-new-dialog",
-1 /*view_size*/);
......
......@@ -50,6 +50,8 @@
#include "display/gimpdisplayshell-selection.h"
#include "display/gimpdisplayshell-transform.h"
#include "dialogs/dialogs.h"
#include "gimpcoloroptions.h"
#include "gimpcolortool.h"
#include "gimptoolcontrol.h"
......@@ -633,13 +635,10 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
{
GimpTool *tool = GIMP_TOOL (color_tool);
GimpContext *context;
GimpDialogFactory *dialog_factory;
/* use this tool's own options here (NOT color_tool->options) */
context = GIMP_CONTEXT (gimp_tool_get_options (tool));
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND ||
color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND)
{
......@@ -647,7 +646,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
if (GIMP_IMAGE_TYPE_IS_INDEXED (sample_type))
{
info = gimp_dialog_factory_find_session_info (dialog_factory,
info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-indexed-palette");
if (info && gimp_session_info_get_widget (info))
{
......@@ -661,7 +660,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
if (TRUE)
{
info = gimp_dialog_factory_find_session_info (dialog_factory,
info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-palette-editor");
if (info && gimp_session_info_get_widget (info))
{
......@@ -697,7 +696,8 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
GtkWidget *dockable;
screen = gtk_widget_get_screen (GTK_WIDGET (shell));
dockable = gimp_dialog_factory_dialog_raise (dialog_factory, screen,
dockable = gimp_dialog_factory_dialog_raise (global_dialog_factory,
screen,
"gimp-palette-editor",
-1);
if (dockable)
......
......@@ -45,6 +45,8 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "dialogs/dialogs.h"
#include "gimprectangletool.h"
#include "gimptextoptions.h"
#include "gimptexttool.h"
......@@ -1137,7 +1139,7 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
return;
}
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
dialog_factory = global_dialog_factory;
if (tool->display)
{
......
......@@ -58,6 +58,8 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "dialogs/dialogs.h"
#include "gimprectangletool.h"
#include "gimptextoptions.h"
#include "gimptexttool.h"
......@@ -660,7 +662,7 @@ gimp_text_tool_get_popup (GimpTool *tool,
GtkWidget *im_menu;
GList *children;
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
dialog_factory = global_dialog_factory;
text_tool->ui_manager =
gimp_menu_factory_manager_new (gimp_dialog_factory_get_menu_factory (dialog_factory),
......
......@@ -33,6 +33,8 @@
#include "core/gimpcontext.h"
#include "dialogs/dialogs.h"
#include "gimpactioneditor.h"
#include "gimpactionview.h"
#include "gimpcontrollereditor.h"
......@@ -681,7 +683,7 @@ gimp_controller_editor_edit_clicked (GtkWidget *button,
g_object_add_weak_pointer (G_OBJECT (editor->edit_dialog),
(gpointer) &editor->edit_dialog);
gimp_dialog_factory_add_foreign (gimp_dialog_factory_from_name ("toplevel"),
gimp_dialog_factory_add_foreign (global_dialog_factory,
"gimp-controller-action-dialog",
editor->edit_dialog);
......
......@@ -34,6 +34,8 @@
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "dialogs/dialogs.h"
#include "gimpcontainertreeview.h"
#include "gimpcontainerview.h"
#include "gimpcontrollereditor.h"
......@@ -634,7 +636,7 @@ gimp_controller_list_edit_clicked (GtkWidget *button,
NULL);
gimp_dialog_factory_add_foreign (gimp_dialog_factory_from_name ("toplevel"),
gimp_dialog_factory_add_foreign (global_dialog_factory,
"gimp-controller-editor-dialog",
dialog);
......
......@@ -35,6 +35,8 @@
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "dialogs/dialogs.h"
#include "gimpdnd.h"
#include "gimpdeviceinfo.h"
#include "gimpdevices.h"
......@@ -469,7 +471,7 @@ gimp_device_status_view_clicked (GtkWidget *widget,
{
GimpDialogFactory *dialog_factory;
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
dialog_factory = global_dialog_factory;
gimp_dialog_factory_dialog_raise (dialog_factory,
gtk_widget_get_screen (widget),
......
......@@ -233,13 +233,6 @@ gimp_dialog_factory_new (const gchar *name,
g_return_val_if_fail (! menu_factory || GIMP_IS_MENU_FACTORY (menu_factory),
NULL);
if (gimp_dialog_factory_from_name (name))
{
g_warning ("%s: dialog factory \"%s\" already exists",
G_STRFUNC, name);
return NULL;
}
factory = g_object_new (GIMP_TYPE_DIALOG_FACTORY, NULL);
gimp_object_set_name (GIMP_OBJECT (factory), name);
......@@ -255,24 +248,6 @@ gimp_dialog_factory_new (const gchar *name,
return factory;
}
GimpDialogFactory *
gimp_dialog_factory_from_name (const gchar *name)
{
GimpDialogFactoryClass *factory_class;
GimpDialogFactory *factory;
g_return_val_if_fail (name != NULL, NULL);
factory_class = g_type_class_peek (GIMP_TYPE_DIALOG_FACTORY);
if (! factory_class)
return NULL;
factory =
(GimpDialogFactory *) g_hash_table_lookup (factory_class->factories, name);
return factory;
}
void
gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
const gchar *identifier,
......
......@@ -111,7 +111,6 @@ GType gimp_dialog_factory_get_type (void) G_GNUC_CONST
GimpDialogFactory * gimp_dialog_factory_new (const gchar *name,
GimpContext *context,
GimpMenuFactory *menu_factory);
GimpDialogFactory * gimp_dialog_factory_from_name (const gchar *name);
void gimp_dialog_factory_register_entry (GimpDialogFactory *factory,
const gchar *identifier,
const gchar *name,
......
......@@ -264,7 +264,7 @@ gimp_session_info_deserialize (GimpConfig *config,
if (! gimp_scanner_parse_string (scanner, &identifier))
goto error;
entry = gimp_dialog_factory_find_entry (gimp_dialog_factory_from_name ("toplevel"),
entry = gimp_dialog_factory_find_entry (global_dialog_factory,
identifier);
if (! entry)
goto error;
......
......@@ -26,6 +26,8 @@
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "dialogs/dialogs.h"
#include "gimpcolordialog.h"
#include "gimpdialogfactory.h"
#include "gimpfgbgeditor.h"
......@@ -149,14 +151,10 @@ color_area_color_clicked (GimpFgBgEditor *editor,
if (! color_dialog)
{
GimpDialogFactory *toplevel_factory;
toplevel_factory = gimp_dialog_factory_from_name ("toplevel");
color_dialog = gimp_color_dialog_new (NULL, context,
NULL, NULL, NULL,
GTK_WIDGET (editor),
toplevel_factory,
global_dialog_factory,
"gimp-toolbox-color-dialog",
&color,
TRUE, FALSE);
......
......@@ -29,6 +29,8 @@
#include "core/gimpobject.h"
#include "core/gimptoolinfo.h"
#include "dialogs/dialogs.h"
#include "gimpdialogfactory.h"
#include "gimptooldialog.h"
......@@ -94,7 +96,7 @@ gimp_tool_dialog_new (GimpToolInfo *tool_info,
identifier = g_strconcat (gimp_object_get_name (tool_info), "-dialog", NULL);
gimp_dialog_factory_add_foreign (gimp_dialog_factory_from_name ("toplevel"),
gimp_dialog_factory_add_foreign (global_dialog_factory,
identifier,
dialog);
......
......@@ -30,6 +30,8 @@
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "dialogs/dialogs.h"
#include "gimpcontainerentry.h"
#include "gimpdialogfactory.h"
#include "gimppropwidgets.h"
......@@ -197,7 +199,7 @@ gradient_box_new (GimpContainer *container,
button = gimp_viewable_button_new (container, context,
view_type,
GIMP_VIEW_SIZE_LARGE, view_size, 1,
gimp_dialog_factory_from_name ("toplevel"),
global_dialog_factory,
"gimp-gradient-list|gimp-gradient-grid",
GIMP_STOCK_GRADIENT,
_("Open the gradient selection dialog"));
......@@ -423,7 +425,7 @@ gimp_viewable_box_new (GimpContainer *container,
button = gimp_viewable_button_new (container, context,
view_type, button_view_size, view_size, 1,
gimp_dialog_factory_from_name ("toplevel"),
global_dialog_factory,
dialog_identifier,
dialog_stock_id,
dialog_tooltip);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment