Commit 2e635336 authored by Michael Natterer's avatar Michael Natterer 😴

app: add GimpDockContainer::get_dialog_factory()

and use it where possible instead of gimp_dialog_factory_get_singleton().
Also reduce using this function in some other places.
parent ecc49ed9
......@@ -526,7 +526,7 @@ dialogs_init (Gimp *gimp,
gimp_dialog_factory_set_singleton (factory);
for (i = 0; i < G_N_ELEMENTS (entries); i++)
gimp_dialog_factory_register_entry (gimp_dialog_factory_get_singleton (),
gimp_dialog_factory_register_entry (factory,
entries[i].identifier,
gettext (entries[i].name),
gettext (entries[i].blurb),
......
......@@ -28,6 +28,7 @@
#include "widgets/gimpcursor.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockcontainer.h"
#include "widgets/gimpsessioninfo.h"
#include "gimpcanvascursor.h"
......@@ -124,9 +125,11 @@ gimp_display_shell_update_software_cursor (GimpDisplayShell *shell,
gdouble image_x,
gdouble image_y)
{
GimpStatusbar *statusbar;
GtkWidget *widget;
GimpImage *image;
GimpImageWindow *image_window;
GimpDialogFactory *factory;
GimpStatusbar *statusbar;
GtkWidget *widget;
GimpImage *image;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -158,13 +161,14 @@ gimp_display_shell_update_software_cursor (GimpDisplayShell *shell,
gimp_statusbar_update_cursor (statusbar, precision, image_x, image_y);
widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
"gimp-cursor-view");
image_window = gimp_display_shell_get_window (shell);
factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
widget = gimp_dialog_factory_find_widget (factory, "gimp-cursor-view");
if (widget)
{
GtkWidget *cursor_view;
cursor_view = gtk_bin_get_child (GTK_BIN (widget));
GtkWidget *cursor_view = gtk_bin_get_child (GTK_BIN (widget));
if (cursor_view)
{
......@@ -186,8 +190,10 @@ gimp_display_shell_update_software_cursor (GimpDisplayShell *shell,
void
gimp_display_shell_clear_software_cursor (GimpDisplayShell *shell)
{
GimpStatusbar *statusbar;
GtkWidget *widget;
GimpImageWindow *image_window;
GimpDialogFactory *factory;
GimpStatusbar *statusbar;
GtkWidget *widget;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -197,13 +203,14 @@ gimp_display_shell_clear_software_cursor (GimpDisplayShell *shell)
gimp_statusbar_clear_cursor (statusbar);
widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
"gimp-cursor-view");
image_window = gimp_display_shell_get_window (shell);
factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
widget = gimp_dialog_factory_find_widget (factory, "gimp-cursor-view");
if (widget)
{
GtkWidget *cursor_view;
cursor_view = gtk_bin_get_child (GTK_BIN (widget));
GtkWidget *cursor_view = gtk_bin_get_child (GTK_BIN (widget));
if (cursor_view)
gimp_cursor_view_clear_cursor (GIMP_CURSOR_VIEW (cursor_view));
......
......@@ -185,6 +185,9 @@ static void gimp_image_window_monitor_changed (GimpWindow *win
gint monitor);
static GList * gimp_image_window_get_docks (GimpDockContainer *dock_container);
static GimpDialogFactory *
gimp_image_window_dock_container_get_dialog_factory
(GimpDockContainer *dock_container);
static GimpUIManager *
gimp_image_window_dock_container_get_ui_manager
(GimpDockContainer *dock_container);
......@@ -347,10 +350,11 @@ gimp_image_window_init (GimpImageWindow *window)
static void
gimp_image_window_dock_container_iface_init (GimpDockContainerInterface *iface)
{
iface->get_docks = gimp_image_window_get_docks;
iface->get_ui_manager = gimp_image_window_dock_container_get_ui_manager;
iface->add_dock = gimp_image_window_add_dock;
iface->get_dock_side = gimp_image_window_get_dock_side;
iface->get_docks = gimp_image_window_get_docks;
iface->get_dialog_factory = gimp_image_window_dock_container_get_dialog_factory;
iface->get_ui_manager = gimp_image_window_dock_container_get_ui_manager;
iface->add_dock = gimp_image_window_add_dock;
iface->get_dock_side = gimp_image_window_get_dock_side;
}
static void
......@@ -851,14 +855,18 @@ gimp_image_window_get_docks (GimpDockContainer *dock_container)
return all_docks;
}
static GimpUIManager *
gimp_image_window_dock_container_get_ui_manager (GimpDockContainer *dock_container)
static GimpDialogFactory *
gimp_image_window_dock_container_get_dialog_factory (GimpDockContainer *dock_container)
{
GimpImageWindow *window;
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (dock_container);
g_return_val_if_fail (GIMP_IS_IMAGE_WINDOW (dock_container), FALSE);
return private->dialog_factory;
}
window = GIMP_IMAGE_WINDOW (dock_container);
static GimpUIManager *
gimp_image_window_dock_container_get_ui_manager (GimpDockContainer *dock_container)
{
GimpImageWindow *window = GIMP_IMAGE_WINDOW (dock_container);
return gimp_image_window_get_ui_manager (window);
}
......
......@@ -38,6 +38,7 @@
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockcontainer.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimpsessioninfo.h"
#include "widgets/gimpwidgets-utils.h"
......@@ -444,8 +445,14 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
gpointer pixel,
const GimpRGB *color)
{
GimpTool *tool = GIMP_TOOL (color_tool);
GimpContext *context;
GimpTool *tool = GIMP_TOOL (color_tool);
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GimpImageWindow *image_window;
GimpDialogFactory *dialog_factory;
GimpContext *context;
image_window = gimp_display_shell_get_window (shell);
dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
/* use this tool's own options here (NOT color_tool->options) */
context = GIMP_CONTEXT (gimp_tool_get_options (tool));
......@@ -457,7 +464,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
if (babl_format_is_palette (sample_format))
{
widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
widget = gimp_dialog_factory_find_widget (dialog_factory,
"gimp-indexed-palette");
if (widget)
{
......@@ -469,7 +476,7 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
}
}
widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
widget = gimp_dialog_factory_find_widget (dialog_factory,
"gimp-palette-editor");
if (widget)
{
......@@ -499,15 +506,14 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
case GIMP_COLOR_PICK_MODE_PALETTE:
{
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
gint monitor = gimp_widget_get_monitor (GTK_WIDGET (shell));
GtkWidget *dockable;
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
gint monitor = gimp_widget_get_monitor (GTK_WIDGET (shell));
GtkWidget *dockable;
dockable =
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (tool->display->gimp)),
tool->display->gimp,
gimp_dialog_factory_get_singleton (),
dialog_factory,
screen,
monitor,
"gimp-palette-editor");
......
......@@ -38,6 +38,7 @@
#include "text/gimptextlayout.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockcontainer.h"
#include "widgets/gimpoverlaybox.h"
#include "widgets/gimpoverlayframe.h"
#include "widgets/gimptextbuffer.h"
......@@ -1264,6 +1265,8 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
{
GimpTool *tool = GIMP_TOOL (text_tool);
GimpTextOptions *options = GIMP_TEXT_TOOL_GET_OPTIONS (text_tool);
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GimpImageWindow *image_window;
GimpDialogFactory *dialog_factory;
GtkWindow *parent = NULL;
gdouble xres = 1.0;
......@@ -1275,14 +1278,8 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
return;
}
dialog_factory = gimp_dialog_factory_get_singleton ();
if (tool->display)
{
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (shell)));
}
image_window = gimp_display_shell_get_window (shell);
dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
if (text_tool->image)
gimp_image_get_resolution (text_tool->image, &xres, &yres);
......@@ -1300,12 +1297,8 @@ gimp_text_tool_editor_dialog (GimpTextTool *text_tool)
gimp_dialog_factory_add_foreign (dialog_factory,
"gimp-text-tool-dialog",
text_tool->editor_dialog,
parent ?
gtk_widget_get_screen (GTK_WIDGET (parent)) :
gdk_screen_get_default (), /* FIXME monitor */
parent ?
gimp_widget_get_monitor (GTK_WIDGET (parent)) :
0 /* FIXME monitor */);
gtk_widget_get_screen (GTK_WIDGET (image_window)),
gimp_widget_get_monitor (GTK_WIDGET (image_window)));
g_signal_connect (text_tool->editor_dialog, "destroy",
G_CALLBACK (gimp_text_tool_editor_destroy),
......
......@@ -51,6 +51,7 @@
#include "vectors/gimpvectors-warp.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockcontainer.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpmenufactory.h"
#include "widgets/gimptextbuffer.h"
......@@ -768,11 +769,14 @@ gimp_text_tool_get_popup (GimpTool *tool,
{
if (! text_tool->ui_manager)
{
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GimpImageWindow *image_window;
GimpDialogFactory *dialog_factory;
GtkWidget *im_menu;
GList *children;
dialog_factory = gimp_dialog_factory_get_singleton ();
image_window = gimp_display_shell_get_window (shell);
dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (image_window));
text_tool->ui_manager =
gimp_menu_factory_manager_new (gimp_dialog_factory_get_menu_factory (dialog_factory),
......
......@@ -540,7 +540,7 @@ gimp_dock_get_dialog_factory (GimpDock *dock)
GimpDockWindow *dock_window = gimp_dock_window_from_dock (dock);
if (dock_window)
dialog_factory = gimp_dock_window_get_dialog_factory (dock_window);
dialog_factory = gimp_dock_container_get_dialog_factory (GIMP_DOCK_CONTAINER (dock_window));
}
return dialog_factory;
......
......@@ -27,7 +27,7 @@
#include "gimpdockcontainer.h"
static void gimp_dock_container_iface_base_init (GimpDockContainerInterface *container_iface);
static void gimp_dock_container_iface_base_init (GimpDockContainerInterface *container_iface);
GType
......@@ -90,6 +90,27 @@ gimp_dock_container_get_docks (GimpDockContainer *container)
return NULL;
}
/**
* gimp_dock_container_get_dialog_factory:
* @container: A #GimpDockContainer
*
* Returns: The #GimpDialogFactory of the #GimpDockContainer
**/
GimpDialogFactory *
gimp_dock_container_get_dialog_factory (GimpDockContainer *container)
{
GimpDockContainerInterface *iface;
g_return_val_if_fail (GIMP_IS_DOCK_CONTAINER (container), NULL);
iface = GIMP_DOCK_CONTAINER_GET_INTERFACE (container);
if (iface->get_dialog_factory)
return iface->get_dialog_factory (container);
return NULL;
}
/**
* gimp_dock_container_get_ui_manager:
* @container: A #GimpDockContainer
......
......@@ -35,24 +35,27 @@ struct _GimpDockContainerInterface
GTypeInterface base_iface;
/* virtual functions */
GList * (* get_docks) (GimpDockContainer *container);
GimpUIManager * (* get_ui_manager) (GimpDockContainer *container);
void (* add_dock) (GimpDockContainer *container,
GimpDock *dock,
GimpSessionInfoDock *dock_info);
GimpAlignmentType (* get_dock_side) (GimpDockContainer *container,
GimpDock *dock);
GList * (* get_docks) (GimpDockContainer *container);
GimpDialogFactory * (* get_dialog_factory) (GimpDockContainer *container);
GimpUIManager * (* get_ui_manager) (GimpDockContainer *container);
void (* add_dock) (GimpDockContainer *container,
GimpDock *dock,
GimpSessionInfoDock *dock_info);
GimpAlignmentType (* get_dock_side) (GimpDockContainer *container,
GimpDock *dock);
};
GType gimp_dock_container_interface_get_type (void) G_GNUC_CONST;
GList * gimp_dock_container_get_docks (GimpDockContainer *container);
GimpUIManager * gimp_dock_container_get_ui_manager (GimpDockContainer *container);
void gimp_dock_container_add_dock (GimpDockContainer *container,
GimpDock *dock,
GimpSessionInfoDock *dock_info);
GimpAlignmentType gimp_dock_container_get_dock_side (GimpDockContainer *container,
GimpDock *dock);
GType gimp_dock_container_interface_get_type (void) G_GNUC_CONST;
GList * gimp_dock_container_get_docks (GimpDockContainer *container);
GimpDialogFactory * gimp_dock_container_get_dialog_factory (GimpDockContainer *container);
GimpUIManager * gimp_dock_container_get_ui_manager (GimpDockContainer *container);
void gimp_dock_container_add_dock (GimpDockContainer *container,
GimpDock *dock,
GimpSessionInfoDock *dock_info);
GimpAlignmentType gimp_dock_container_get_dock_side (GimpDockContainer *container,
GimpDock *dock);
#endif /* __GIMP_DOCK_CONTAINER_H__ */
......@@ -126,6 +126,7 @@ static void gimp_dock_window_style_set (GtkWidget
static gboolean gimp_dock_window_delete_event (GtkWidget *widget,
GdkEventAny *event);
static GList * gimp_dock_window_get_docks (GimpDockContainer *dock_container);
static GimpDialogFactory * gimp_dock_window_get_dialog_factory (GimpDockContainer *dock_container);
static GimpUIManager * gimp_dock_window_get_ui_manager (GimpDockContainer *dock_container);
static void gimp_dock_window_add_dock_from_session (GimpDockContainer *dock_container,
GimpDock *dock,
......@@ -269,10 +270,11 @@ gimp_dock_window_init (GimpDockWindow *dock_window)
static void
gimp_dock_window_dock_container_iface_init (GimpDockContainerInterface *iface)
{
iface->get_docks = gimp_dock_window_get_docks;
iface->get_ui_manager = gimp_dock_window_get_ui_manager;
iface->add_dock = gimp_dock_window_add_dock_from_session;
iface->get_dock_side = gimp_dock_window_get_dock_side;
iface->get_docks = gimp_dock_window_get_docks;
iface->get_dialog_factory = gimp_dock_window_get_dialog_factory;
iface->get_ui_manager = gimp_dock_window_get_ui_manager;
iface->add_dock = gimp_dock_window_add_dock_from_session;
iface->get_dock_side = gimp_dock_window_get_dock_side;
}
static void
......@@ -693,7 +695,8 @@ gimp_dock_window_delete_event (GtkWidget *widget,
entry_name = (gimp_dock_window_has_toolbox (dock_window) ?
"gimp-toolbox-window" :
"gimp-dock-window");
entry = gimp_dialog_factory_find_entry (gimp_dialog_factory_get_singleton (), entry_name);
entry = gimp_dialog_factory_find_entry (dock_window->p->dialog_factory,
entry_name);
gimp_session_info_set_factory_entry (info, entry);
gimp_container_add (global_recent_docks, GIMP_OBJECT (info));
......@@ -705,23 +708,23 @@ gimp_dock_window_delete_event (GtkWidget *widget,
static GList *
gimp_dock_window_get_docks (GimpDockContainer *dock_container)
{
GimpDockWindow *dock_window;
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (dock_container);
g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_container), NULL);
return g_list_copy (gimp_dock_columns_get_docks (dock_window->p->dock_columns));
}
dock_window = GIMP_DOCK_WINDOW (dock_container);
static GimpDialogFactory *
gimp_dock_window_get_dialog_factory (GimpDockContainer *dock_container)
{
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (dock_container);
return g_list_copy (gimp_dock_columns_get_docks (dock_window->p->dock_columns));
return dock_window->p->dialog_factory;
}
static GimpUIManager *
gimp_dock_window_get_ui_manager (GimpDockContainer *dock_container)
{
GimpDockWindow *dock_window;
g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_container), NULL);
dock_window = GIMP_DOCK_WINDOW (dock_container);
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (dock_container);
return dock_window->p->ui_manager;
}
......@@ -731,11 +734,7 @@ gimp_dock_window_add_dock_from_session (GimpDockContainer *dock_container,
GimpDock *dock,
GimpSessionInfoDock *dock_info)
{
GimpDockWindow *dock_window;
g_return_if_fail (GIMP_IS_DOCK_WINDOW (dock_container));
dock_window = GIMP_DOCK_WINDOW (dock_container);
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (dock_container);
gimp_dock_window_add_dock (dock_window,
dock,
......@@ -745,14 +744,10 @@ gimp_dock_window_add_dock_from_session (GimpDockContainer *dock_container,
static GList *
gimp_dock_window_get_aux_info (GimpSessionManaged *session_managed)
{
GimpDockWindow *dock_window;
GList *aux_info = NULL;
GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (session_managed);
GList *aux_info = NULL;
GimpSessionInfoAux *aux;
g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (session_managed), NULL);
dock_window = GIMP_DOCK_WINDOW (session_managed);
if (dock_window->p->allow_dockbook_absence)
{
/* Assume it is the toolbox; it does not have aux info */
......@@ -1087,7 +1082,11 @@ gimp_dock_window_auto_clicked (GtkWidget *widget,
if (dock_window->p->auto_follow_active)
{
gimp_context_copy_properties (gimp_dialog_factory_get_context (dock_window->p->dialog_factory),
GimpContext *context;
context = gimp_dialog_factory_get_context (dock_window->p->dialog_factory);
gimp_context_copy_properties (context,
dock_window->p->context,
GIMP_CONTEXT_PROP_MASK_DISPLAY |
GIMP_CONTEXT_PROP_MASK_IMAGE);
......@@ -1171,14 +1170,6 @@ gimp_dock_window_get_context (GimpDockWindow *dock_window)
return dock_window->p->context;
}
GimpDialogFactory *
gimp_dock_window_get_dialog_factory (GimpDockWindow *dock_window)
{
g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_window), NULL);
return dock_window->p->dialog_factory;
}
gboolean
gimp_dock_window_get_auto_follow_active (GimpDockWindow *dock_window)
{
......
......@@ -68,7 +68,6 @@ void gimp_dock_window_add_dock (GimpDockWindow *
void gimp_dock_window_remove_dock (GimpDockWindow *dock_window,
GimpDock *dock);
GimpContext * gimp_dock_window_get_context (GimpDockWindow *dock);
GimpDialogFactory * gimp_dock_window_get_dialog_factory (GimpDockWindow *dock);
gboolean gimp_dock_window_get_auto_follow_active (GimpDockWindow *menu_dock);
void gimp_dock_window_set_auto_follow_active (GimpDockWindow *menu_dock,
gboolean show);
......
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