Commit 8b458fb5 authored by Martin Nordholts's avatar Martin Nordholts
Browse files

app: Merge "toplevel" and "dock" dialog factories

Merge "toplevel" and "dock" dialog factories. The end goal is to have
only one dialog factory.
parent 10ff2733
......@@ -871,7 +871,7 @@ context_get_palette_editor (void)
GimpDialogFactory *dialog_factory;
GimpSessionInfo *info;
dialog_factory = gimp_dialog_factory_from_name ("dock");
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
......@@ -889,7 +889,7 @@ context_get_colormap_editor (void)
GimpDialogFactory *dialog_factory;
GimpSessionInfo *info;
dialog_factory = gimp_dialog_factory_from_name ("dock");
dialog_factory = gimp_dialog_factory_from_name ("toplevel");
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
......
......@@ -302,7 +302,7 @@ data_edit_cmd_callback (GtkAction *action,
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
GtkWidget *dockable;
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory, screen,
dockable = gimp_dialog_factory_dialog_raise (global_dialog_factory, screen,
value, -1);
gimp_data_editor_set_data (GIMP_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
......
......@@ -56,7 +56,7 @@ dialogs_create_dockable_cmd_callback (GtkAction *action,
return_if_no_widget (widget, data);
if (value)
gimp_dialog_factory_dialog_raise (global_dock_factory,
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (widget),
value, -1);
}
......@@ -449,7 +449,7 @@ edit_named_paste_cmd_callback (GtkAction *action,
GtkWidget *widget;
return_if_no_widget (widget, data);
gimp_dialog_factory_dialog_raise (global_dock_factory,
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-buffer-list|gimp-buffer-grid", -1);
}
......
......@@ -319,7 +319,7 @@ select_save_cmd_callback (GtkAction *action,
gimp_selection_save (GIMP_SELECTION (gimp_image_get_mask (image)));
gimp_image_flush (image);
gimp_dialog_factory_dialog_raise (global_dock_factory,
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (widget),
"gimp-channel-list", -1);
}
......
......@@ -338,7 +338,7 @@ view_navigation_window_cmd_callback (GtkAction *action,
shell = gimp_display_get_shell (display);
gimp_dialog_factory_dialog_raise (global_dock_factory,
gimp_dialog_factory_dialog_raise (global_dialog_factory,
gtk_widget_get_screen (GTK_WIDGET (shell)),
"gimp-navigation-view", -1);
}
......
......@@ -137,21 +137,21 @@ windows_actions_setup (GimpActionGroup *group)
windows_actions_display_add (group->gimp->displays, display, group);
}
g_signal_connect_object (global_dock_factory, "dock-window-added",
g_signal_connect_object (global_dialog_factory, "dock-window-added",
G_CALLBACK (windows_actions_dock_window_added),
group, 0);
g_signal_connect_object (global_dock_factory, "dock-window-removed",
g_signal_connect_object (global_dialog_factory, "dock-window-removed",
G_CALLBACK (windows_actions_dock_window_removed),
group, 0);
for (list = gimp_dialog_factory_get_open_dialogs (global_dock_factory);
for (list = gimp_dialog_factory_get_open_dialogs (global_dialog_factory);
list;
list = g_list_next (list))
{
GimpDockWindow *dock_window = list->data;
if (GIMP_IS_DOCK_WINDOW (dock_window))
windows_actions_dock_window_added (global_dock_factory,
windows_actions_dock_window_added (global_dialog_factory,
dock_window,
group);
}
......
......@@ -91,9 +91,9 @@ windows_open_recent_cmd_callback (GtkAction *action,
g_object_ref (info);
gimp_container_remove (global_recent_docks, GIMP_OBJECT (info));
gimp_dialog_factory_add_session_info (global_dock_factory, info);
gimp_dialog_factory_add_session_info (global_dialog_factory, info);
gimp_session_info_restore (info, global_dock_factory);
gimp_session_info_restore (info, global_dialog_factory);
gimp_session_info_clear_info (info);
}
......@@ -104,7 +104,7 @@ windows_show_toolbox (void)
if (! dialogs_get_toolbox ())
{
toolbox = gimp_dialog_factory_dock_with_window_new (global_dock_factory,
toolbox = gimp_dialog_factory_dock_with_window_new (global_dialog_factory,
gdk_screen_get_default (),
TRUE /*toolbox*/);
......
......@@ -43,7 +43,6 @@
GimpDialogFactory *global_dialog_factory = NULL;
GimpDialogFactory *global_dock_factory = NULL;
GimpDialogFactory *global_display_factory = NULL;
GimpContainer *global_recent_docks = NULL;
......@@ -160,7 +159,7 @@ GimpContainer *global_recent_docks = NULL;
TRUE /* dockable */}
static const GimpDialogFactoryEntry toplevel_entries[] =
static const GimpDialogFactoryEntry entries[] =
{
/* foreign toplevels without constructor */
FOREIGN ("gimp-brightness-contrast-tool-dialog", TRUE, FALSE),
......@@ -222,11 +221,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
TOPLEVEL ("gimp-close-all-dialog",
dialogs_close_all_get, TRUE, FALSE, FALSE),
TOPLEVEL ("gimp-quit-dialog",
dialogs_quit_get, TRUE, FALSE, FALSE)
};
dialogs_quit_get, TRUE, FALSE, FALSE),
static const GimpDialogFactoryEntry dock_entries[] =
{
/* docks */
DOCK ("gimp-dock",
dialogs_dock_new),
......@@ -364,12 +360,6 @@ dialogs_init (Gimp *gimp,
menu_factory,
TRUE);
/* Dock windows and docks */
global_dock_factory = gimp_dialog_factory_new ("dock",
gimp_get_user_context (gimp),
menu_factory,
TRUE);
/* Display */
global_display_factory = gimp_dialog_factory_new ("display",
gimp_get_user_context (gimp),
......@@ -377,35 +367,20 @@ dialogs_init (Gimp *gimp,
FALSE);
for (i = 0; i < G_N_ELEMENTS (toplevel_entries); i++)
for (i = 0; i < G_N_ELEMENTS (entries); i++)
gimp_dialog_factory_register_entry (global_dialog_factory,
toplevel_entries[i].identifier,
gettext (toplevel_entries[i].name),
gettext (toplevel_entries[i].blurb),
toplevel_entries[i].stock_id,
toplevel_entries[i].help_id,
toplevel_entries[i].new_func,
toplevel_entries[i].view_size,
toplevel_entries[i].singleton,
toplevel_entries[i].session_managed,
toplevel_entries[i].remember_size,
toplevel_entries[i].remember_if_open,
toplevel_entries[i].dockable);
for (i = 0; i < G_N_ELEMENTS (dock_entries); i++)
gimp_dialog_factory_register_entry (global_dock_factory,
dock_entries[i].identifier,
gettext (dock_entries[i].name),
gettext (dock_entries[i].blurb),
dock_entries[i].stock_id,
dock_entries[i].help_id,
dock_entries[i].new_func,
dock_entries[i].view_size,
dock_entries[i].singleton,
dock_entries[i].session_managed,
dock_entries[i].remember_size,
dock_entries[i].remember_if_open,
dock_entries[i].dockable);
entries[i].identifier,
gettext (entries[i].name),
gettext (entries[i].blurb),
entries[i].stock_id,
entries[i].help_id,
entries[i].new_func,
entries[i].view_size,
entries[i].singleton,
entries[i].session_managed,
entries[i].remember_size,
entries[i].remember_if_open,
entries[i].dockable);
gimp_dialog_factory_register_entry (global_display_factory,
"gimp-empty-image-window",
......@@ -433,12 +408,6 @@ dialogs_exit (Gimp *gimp)
global_dialog_factory = NULL;
}
if (global_dock_factory)
{
g_object_unref (global_dock_factory);
global_dock_factory = NULL;
}
if (global_display_factory)
{
g_object_unref (global_display_factory);
......@@ -511,9 +480,9 @@ dialogs_get_toolbox (void)
{
GList *list;
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (global_dock_factory), NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (global_dialog_factory), NULL);
for (list = gimp_dialog_factory_get_open_dialogs (global_dock_factory);
for (list = gimp_dialog_factory_get_open_dialogs (global_dialog_factory);
list;
list = g_list_next (list))
{
......
......@@ -20,7 +20,6 @@
extern GimpDialogFactory *global_dialog_factory;
extern GimpDialogFactory *global_dock_factory;
extern GimpDialogFactory *global_display_factory;
extern GimpContainer *global_recent_docks;
......
......@@ -165,7 +165,7 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gimp_statusbar_update_cursor (statusbar, precision, image_x, image_y);
factory = gimp_dialog_factory_from_name ("dock");
factory = gimp_dialog_factory_from_name ("toplevel");
session_info = gimp_dialog_factory_find_session_info (factory,
"gimp-cursor-view");
if (session_info && gimp_session_info_get_widget (session_info))
......@@ -204,7 +204,7 @@ gimp_display_shell_clear_cursor (GimpDisplayShell *shell)
gimp_statusbar_clear_cursor (statusbar);
factory = gimp_dialog_factory_from_name ("dock");
factory = gimp_dialog_factory_from_name ("toplevel");
session_info = gimp_dialog_factory_find_session_info (factory,
"gimp-cursor-view");
if (session_info && gimp_session_info_get_widget (session_info))
......
......@@ -161,7 +161,7 @@ gimp_ui_configurer_move_docks_to_columns (GimpUIConfigurer *ui_configurer,
GList *dialog_iter = NULL;
dialogs =
g_list_copy (gimp_dialog_factory_get_open_dialogs (global_dock_factory));
g_list_copy (gimp_dialog_factory_get_open_dialogs (global_dialog_factory));
for (dialog_iter = dialogs; dialog_iter; dialog_iter = dialog_iter->next)
{
......@@ -203,7 +203,7 @@ gimp_ui_configurer_move_docks_to_columns (GimpUIConfigurer *ui_configurer,
if (GTK_IS_WIDGET (dock_window) &&
g_list_length (gimp_dock_window_get_docks (dock_window)) == 0)
{
gimp_dialog_factory_remove_dialog (global_dock_factory,
gimp_dialog_factory_remove_dialog (global_dialog_factory,
GTK_WIDGET (dock_window));
gtk_widget_destroy (GTK_WIDGET (dock_window));
}
......@@ -283,7 +283,7 @@ gimp_ui_configurer_move_docks_to_window (GimpUIConfigurer *ui_configurer,
* toolbox
*/
dock_window =
gimp_dialog_factory_dialog_new (global_dock_factory,
gimp_dialog_factory_dialog_new (global_dialog_factory,
screen,
(GIMP_IS_TOOLBOX (dock) ?
"gimp-toolbox-window" :
......@@ -326,7 +326,7 @@ gimp_ui_configurer_separate_shells (GimpUIConfigurer *ui_configurer,
NULL,
global_menu_factory,
global_display_factory,
global_dock_factory);
global_dialog_factory);
/* Move the shell there */
shell = gimp_image_window_get_shell (source_image_window, 1);
......
......@@ -102,7 +102,7 @@ gui_message_error_console (GimpMessageSeverity severity,
{
GimpSessionInfo *info;
info = gimp_dialog_factory_find_session_info (global_dock_factory,
info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-error-console");
if (info && GIMP_IS_DOCKABLE (gimp_session_info_get_widget (info)))
......@@ -110,7 +110,7 @@ gui_message_error_console (GimpMessageSeverity severity,
}
if (! dockable)
dockable = gimp_dialog_factory_dialog_raise (global_dock_factory,
dockable = gimp_dialog_factory_dialog_raise (global_dialog_factory,
gdk_screen_get_default (),
"gimp-error-console", -1);
......
......@@ -352,7 +352,7 @@ gui_display_create (Gimp *gimp,
global_menu_factory,
image_managers->data,
global_display_factory,
global_dock_factory);
global_dialog_factory);
}
if (gimp_context_get_display (context) == display)
......
......@@ -704,7 +704,7 @@ gui_device_change_notify (Gimp *gimp)
{
GimpSessionInfo *session_info;
session_info = gimp_dialog_factory_find_session_info (global_dock_factory,
session_info = gimp_dialog_factory_find_session_info (global_dialog_factory,
"gimp-device-status");
if (session_info && gimp_session_info_get_widget (session_info))
......
......@@ -138,14 +138,15 @@ session_init (Gimp *gimp)
if (! gimp_scanner_parse_string (scanner, &factory_name))
break;
/* In versions <= GIMP 2.6 there was a "toolbox" and a
* "dock" factory. These are now merged so if the
* factory name is "toolbox", get the "dock" factory
* instead. We don't change factory_name because we need
* it below
/* In versions <= GIMP 2.6 there was a "toolbox", a
* "dock" and a "toplevel" factory. These are now merged
* so if the factory name is "toolbox" or "dock", get
* the "toplevel" factory instead. We don't change
* factory_name because we need it below
*/
factory = gimp_dialog_factory_from_name (strcmp ("toolbox", factory_name) == 0 ?
"dock" :
factory = gimp_dialog_factory_from_name ((strcmp ("toolbox", factory_name) == 0 ||
strcmp ("dock", factory_name) == 0) ?
"toplevel" :
factory_name);
if (! factory)
......
......@@ -104,21 +104,21 @@ windows_menu_setup (GimpUIManager *manager,
windows_menu_display_add (manager->gimp->displays, display, manager);
}
g_signal_connect_object (global_dock_factory, "dock-window-added",
g_signal_connect_object (global_dialog_factory, "dock-window-added",
G_CALLBACK (windows_menu_dock_window_added),
manager, 0);
g_signal_connect_object (global_dock_factory, "dock-window-removed",
g_signal_connect_object (global_dialog_factory, "dock-window-removed",
G_CALLBACK (windows_menu_dock_window_removed),
manager, 0);
for (list = gimp_dialog_factory_get_open_dialogs (global_dock_factory);
for (list = gimp_dialog_factory_get_open_dialogs (global_dialog_factory);
list;
list = g_list_next (list))
{
GimpDockWindow *dock_window = list->data;
if (GIMP_IS_DOCK_WINDOW (dock_window))
windows_menu_dock_window_added (global_dock_factory,
windows_menu_dock_window_added (global_dialog_factory,
dock_window,
manager);
}
......
......@@ -5,7 +5,7 @@
# of course you can do. The sessionrc will be entirely rewritten every time
# you quit GIMP. If this file isn't found, defaults are used.
(session-info "dock" "gimp-dock-window"
(session-info "toplevel" "gimp-dock-window"
(position 566 171)
(size 210 535)
(open-on-exit)
......@@ -25,7 +25,7 @@
(current-page 0)
(dockable "gimp-brush-grid"
(tab-style preview)))))
(session-info "dock" "gimp-dock-window"
(session-info "toplevel" "gimp-dock-window"
(position 141 291)
(size 406 300)
(open-on-exit)
......@@ -42,7 +42,7 @@
(current-page 0)
(dockable "gimp-device-status"
(tab-style icon)))))
(session-info "dock" "gimp-dock-window"
(session-info "toplevel" "gimp-dock-window"
(position 795 43)
(size 200 265)
(open-on-exit)
......@@ -56,7 +56,7 @@
(tab-style preview))
(dockable "gimp-gradient-list"
(tab-style preview)))))
(session-info "dock" "gimp-dock-window"
(session-info "toplevel" "gimp-dock-window"
(position 803 344)
(size 200 404)
(open-on-exit)
......@@ -78,7 +78,7 @@
(edit-active "true")
(current-data "Standard")
(zoom-factor "2.80"))))))
(session-info "dock" "gimp-toolbox-window"
(session-info "toplevel" "gimp-toolbox-window"
(position 13 37)
(size 96 620)
(open-on-exit)
......
......@@ -160,7 +160,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 ("dock");
GimpDialogFactory *dock_factory = gimp_dialog_factory_from_name ("toplevel");
GtkWidget *dockable = gimp_dialog_factory_dialog_new (dock_factory,
gtk_widget_get_screen (toplevel),
"gimp-tool-options",
......@@ -251,11 +251,11 @@ gimp_ui_restore_recently_closed_dock (GimpTestFixture *fixture,
GList *session_infos = NULL;
/* Find a non-toolbox dock window */
dock_window = gimp_ui_find_non_toolbox_dock_window (global_dock_factory);
dock_window = gimp_ui_find_non_toolbox_dock_window (global_dialog_factory);
g_assert (dock_window != NULL);
/* Count number of docks */
session_infos = gimp_dialog_factory_get_session_infos (global_dock_factory);
session_infos = gimp_dialog_factory_get_session_infos (global_dialog_factory);
n_session_infos_before_close = g_list_length (session_infos);
/* Close one of the dock windows */
......@@ -263,7 +263,7 @@ gimp_ui_restore_recently_closed_dock (GimpTestFixture *fixture,
gimp_test_run_mainloop_until_idle ();
/* Make sure the number of session infos went down */
session_infos = gimp_dialog_factory_get_session_infos (global_dock_factory);
session_infos = gimp_dialog_factory_get_session_infos (global_dialog_factory);
n_session_infos_after_close = g_list_length (session_infos);
g_assert_cmpint (n_session_infos_before_close,
>,
......@@ -277,7 +277,7 @@ gimp_ui_restore_recently_closed_dock (GimpTestFixture *fixture,
/* FIXME: This is severly hardcoded */
"windows-recent-0003");
gimp_test_run_mainloop_until_idle ();
session_infos = gimp_dialog_factory_get_session_infos (global_dock_factory);
session_infos = gimp_dialog_factory_get_session_infos (global_dialog_factory);
n_session_infos_after_restore = g_list_length (session_infos);
g_assert_cmpint (n_session_infos_after_close,
<,
......@@ -308,7 +308,7 @@ gimp_ui_tab_toggle_dont_change_position (GimpTestFixture *fixture,
gint h_after_show = -1;
/* Find a non-toolbox dock window */
dock_window = gimp_ui_find_non_toolbox_dock_window (global_dock_factory);
dock_window = gimp_ui_find_non_toolbox_dock_window (global_dialog_factory);
g_assert (dock_window != NULL);
g_assert (gtk_widget_get_visible (dock_window));
......
......@@ -98,10 +98,10 @@ gimp_test_window_roles (GimpTestFixture *fixture,
GimpDockWindow *dock_window = NULL;
GimpDockWindow *toolbox_window = NULL;
dock = gimp_dialog_factory_dock_with_window_new (global_dock_factory,
dock = gimp_dialog_factory_dock_with_window_new (global_dialog_factory,
gdk_screen_get_default (),
FALSE /*toolbox*/);
toolbox = gimp_dialog_factory_dock_with_window_new (global_dock_factory,
toolbox = gimp_dialog_factory_dock_with_window_new (global_dialog_factory,
gdk_screen_get_default (),
TRUE /*toolbox*/);
dock_window = gimp_dock_window_from_dock (GIMP_DOCK (dock));
......
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