[gimp] app: get rid of including menus/ stuff from widgets/ and other places
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: get rid of including menus/ stuff from widgets/ and other places
- Date: Wed, 23 Nov 2016 18:42:08 +0000 (UTC)
commit a3c65e6d17f3a2a85f2ac8811dcfbe381ea3a722
Author: Michael Natterer <mitch gimp org>
Date: Wed Nov 23 19:16:36 2016 +0100
app: get rid of including menus/ stuff from widgets/ and other places
Add GimpMenuFactory can always be found in a GimpDialogManager, use
gimp_dialog_factory_get_menu_factory() where we have a dialog factory
instead of accessing "global_menu_factory" or redundantly passing a
menu factory around where we already pass around a dialog factory.
app/display/gimpdisplay.c | 2 --
app/display/gimpdisplay.h | 1 -
app/display/gimpimagewindow.c | 31 +++++++++----------------------
app/display/gimpimagewindow.h | 1 -
app/gui/gimpuiconfigurer.c | 3 ---
app/gui/gui-vtable.c | 1 -
app/widgets/gimpdock.c | 12 ++++++------
app/widgets/gimpdockable.c | 23 +++++++++++++----------
app/widgets/gimpdockcolumns.c | 12 +++++++-----
app/widgets/gimpdockwindow.c | 30 ++++++++++++++++--------------
app/widgets/gimpsessioninfo-book.c | 15 +++++++++------
11 files changed, 60 insertions(+), 71 deletions(-)
---
diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c
index da92e9f..2691de0 100644
--- a/app/display/gimpdisplay.c
+++ b/app/display/gimpdisplay.c
@@ -390,7 +390,6 @@ gimp_display_new (Gimp *gimp,
GimpImage *image,
GimpUnit unit,
gdouble scale,
- GimpMenuFactory *menu_factory,
GimpUIManager *popup_manager,
GimpDialogFactory *dialog_factory,
GdkScreen *screen,
@@ -444,7 +443,6 @@ gimp_display_new (Gimp *gimp,
{
window = gimp_image_window_new (gimp,
private->image,
- menu_factory,
dialog_factory,
screen,
monitor);
diff --git a/app/display/gimpdisplay.h b/app/display/gimpdisplay.h
index 21652a0..759a0ac 100644
--- a/app/display/gimpdisplay.h
+++ b/app/display/gimpdisplay.h
@@ -53,7 +53,6 @@ GimpDisplay * gimp_display_new (Gimp *gimp,
GimpImage *image,
GimpUnit unit,
gdouble scale,
- GimpMenuFactory *menu_factory,
GimpUIManager *popup_manager,
GimpDialogFactory *dialog_factory,
GdkScreen *screen,
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 734341a..577f076 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -99,7 +99,6 @@ enum
{
PROP_0,
PROP_GIMP,
- PROP_MENU_FACTORY,
PROP_DIALOG_FACTORY,
PROP_INITIAL_SCREEN,
PROP_INITIAL_MONITOR
@@ -306,12 +305,6 @@ gimp_image_window_class_init (GimpImageWindowClass *klass)
GIMP_TYPE_GIMP,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_MENU_FACTORY,
- g_param_spec_object ("menu-factory",
- NULL, NULL,
- GIMP_TYPE_MENU_FACTORY,
- GIMP_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_DIALOG_FACTORY,
g_param_spec_object ("dialog-factory",
@@ -372,12 +365,20 @@ gimp_image_window_constructed (GObject *object)
{
GimpImageWindow *window = GIMP_IMAGE_WINDOW (object);
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
+ GimpMenuFactory *menu_factory;
GimpGuiConfig *config;
G_OBJECT_CLASS (parent_class)->constructed (object);
g_assert (GIMP_IS_GIMP (private->gimp));
- g_assert (GIMP_IS_UI_MANAGER (private->menubar_manager));
+ g_assert (GIMP_IS_DIALOG_FACTORY (private->dialog_factory));
+
+ menu_factory = gimp_dialog_factory_get_menu_factory (private->dialog_factory);
+
+ private->menubar_manager = gimp_menu_factory_manager_new (menu_factory,
+ "<Image>",
+ window,
+ FALSE);
g_signal_connect_object (private->dialog_factory, "dock-window-added",
G_CALLBACK (gimp_image_window_update_ui_manager),
@@ -556,16 +557,6 @@ gimp_image_window_set_property (GObject *object,
case PROP_GIMP:
private->gimp = g_value_get_object (value);
break;
- case PROP_MENU_FACTORY:
- {
- GimpMenuFactory *factory = g_value_get_object (value);
-
- private->menubar_manager = gimp_menu_factory_manager_new (factory,
- "<Image>",
- window,
- FALSE);
- }
- break;
case PROP_DIALOG_FACTORY:
private->dialog_factory = g_value_get_object (value);
break;
@@ -606,7 +597,6 @@ gimp_image_window_get_property (GObject *object,
g_value_set_int (value, private->initial_monitor);
break;
- case PROP_MENU_FACTORY:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1121,7 +1111,6 @@ gimp_image_window_set_aux_info (GimpSessionManaged *session_managed,
GimpImageWindow *
gimp_image_window_new (Gimp *gimp,
GimpImage *image,
- GimpMenuFactory *menu_factory,
GimpDialogFactory *dialog_factory,
GdkScreen *screen,
gint monitor)
@@ -1131,13 +1120,11 @@ gimp_image_window_new (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
- g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
window = g_object_new (GIMP_TYPE_IMAGE_WINDOW,
"gimp", gimp,
- "menu-factory", menu_factory,
"dialog-factory", dialog_factory,
"initial-screen", screen,
"initial-monitor", monitor,
diff --git a/app/display/gimpimagewindow.h b/app/display/gimpimagewindow.h
index 6c6b16e..a3d8207 100644
--- a/app/display/gimpimagewindow.h
+++ b/app/display/gimpimagewindow.h
@@ -47,7 +47,6 @@ GType gimp_image_window_get_type (void) G_GNUC_CONST;
GimpImageWindow * gimp_image_window_new (Gimp *gimp,
GimpImage *image,
- GimpMenuFactory *menu_factory,
GimpDialogFactory *dialog_factory,
GdkScreen *screen,
gint monitor);
diff --git a/app/gui/gimpuiconfigurer.c b/app/gui/gimpuiconfigurer.c
index 0f65d26..ec49633 100644
--- a/app/gui/gimpuiconfigurer.c
+++ b/app/gui/gimpuiconfigurer.c
@@ -43,8 +43,6 @@
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpimagewindow.h"
-#include "menus/menus.h"
-
#include "gimpuiconfigurer.h"
@@ -450,7 +448,6 @@ gimp_ui_configurer_separate_shells (GimpUIConfigurer *ui_configurer,
/* Create a new image window */
new_image_window = gimp_image_window_new (ui_configurer->p->gimp,
NULL,
- global_menu_factory,
gimp_dialog_factory_get_singleton (),
gtk_widget_get_screen (GTK_WIDGET (source_image_window)),
gimp_widget_get_monitor (GTK_WIDGET (source_image_window)));
diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c
index 97d4c50..faad737 100644
--- a/app/gui/gui-vtable.c
+++ b/app/gui/gui-vtable.c
@@ -398,7 +398,6 @@ gui_display_create (Gimp *gimp,
g_return_val_if_fail (image_managers != NULL, NULL);
display = gimp_display_new (gimp, image, unit, scale,
- global_menu_factory,
image_managers->data,
gimp_dialog_factory_get_singleton (),
GDK_SCREEN (screen),
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index 1af97af..84eb129 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -27,8 +27,6 @@
#include "widgets-types.h"
-#include "menus/menus.h"
-
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
@@ -347,9 +345,10 @@ gimp_dock_dropped_cb (GtkWidget *source,
gint insert_index,
gpointer data)
{
- GimpDock *dock = GIMP_DOCK (data);
- GimpDockable *dockable = gimp_dockbook_drag_source_to_dockable (source);
- GtkWidget *dockbook = NULL;
+ GimpDock *dock = GIMP_DOCK (data);
+ GimpDockable *dockable = gimp_dockbook_drag_source_to_dockable (source);
+ GimpDialogFactory *factory;
+ GtkWidget *dockbook = NULL;
if (!dockable )
return FALSE;
@@ -378,7 +377,8 @@ gimp_dock_dropped_cb (GtkWidget *source,
gimp_dockbook_remove (gimp_dockable_get_dockbook (dockable), dockable);
/* Create a new dockbook */
- dockbook = gimp_dockbook_new (global_menu_factory);
+ factory = gimp_dock_get_dialog_factory (dock);
+ dockbook = gimp_dockbook_new (gimp_dialog_factory_get_menu_factory (factory));
gimp_dock_add_book (dock, GIMP_DOCKBOOK (dockbook), insert_index);
/* Add the dockable to new new dockbook */
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index 5a1fd5c..4e32e7b 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -29,8 +29,6 @@
#include "widgets-types.h"
-#include "menus/menus.h"
-
#include "core/gimpcontext.h"
#include "gimpdialogfactory.h"
@@ -845,19 +843,24 @@ gimp_dockable_set_drag_handler (GimpDockable *dockable,
void
gimp_dockable_detach (GimpDockable *dockable)
{
- GimpDockWindow *src_dock_window = NULL;
- GimpDock *src_dock = NULL;
- GtkWidget *dock = NULL;
- GimpDockWindow *dock_window = NULL;
- GtkWidget *dockbook = NULL;
+ GimpDialogFactory *dialog_factory;
+ GimpMenuFactory *menu_factory;
+ GimpDockWindow *src_dock_window;
+ GimpDock *src_dock;
+ GtkWidget *dock;
+ GimpDockWindow *dock_window;
+ GtkWidget *dockbook;
g_return_if_fail (GIMP_IS_DOCKABLE (dockable));
g_return_if_fail (GIMP_IS_DOCKBOOK (dockable->p->dockbook));
- src_dock = gimp_dockbook_get_dock (dockable->p->dockbook);
+ src_dock = gimp_dockbook_get_dock (dockable->p->dockbook);
src_dock_window = gimp_dock_window_from_dock (src_dock);
- dock = gimp_dock_with_window_new (gimp_dialog_factory_get_singleton (),
+ dialog_factory = gimp_dock_get_dialog_factory (src_dock);
+ menu_factory = gimp_dialog_factory_get_menu_factory (dialog_factory);
+
+ dock = gimp_dock_with_window_new (dialog_factory,
gtk_widget_get_screen (GTK_WIDGET (dockable)),
gimp_widget_get_monitor (GTK_WIDGET (dockable)),
FALSE /*toolbox*/);
@@ -866,7 +869,7 @@ gimp_dockable_detach (GimpDockable *dockable)
if (src_dock_window)
gimp_dock_window_setup (dock_window, src_dock_window);
- dockbook = gimp_dockbook_new (global_menu_factory);
+ dockbook = gimp_dockbook_new (menu_factory);
gimp_dock_add_book (GIMP_DOCK (dock), GIMP_DOCKBOOK (dockbook), 0);
diff --git a/app/widgets/gimpdockcolumns.c b/app/widgets/gimpdockcolumns.c
index 13c6f7a..f369d8a 100644
--- a/app/widgets/gimpdockcolumns.c
+++ b/app/widgets/gimpdockcolumns.c
@@ -25,8 +25,6 @@
#include "widgets-types.h"
-#include "menus/menus.h"
-
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpmarshal.h"
@@ -118,12 +116,14 @@ gimp_dock_columns_class_init (GimpDockColumnsClass *klass)
GIMP_TYPE_CONTEXT,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (object_class, PROP_DIALOG_FACTORY,
g_param_spec_object ("dialog-factory",
NULL, NULL,
GIMP_TYPE_DIALOG_FACTORY,
GIMP_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (object_class, PROP_UI_MANAGER,
g_param_spec_object ("ui-manager",
NULL, NULL,
@@ -409,13 +409,15 @@ gimp_dock_columns_prepare_dockbook (GimpDockColumns *dock_columns,
gint dock_index,
GtkWidget **dockbook_p)
{
- GtkWidget *dock;
- GtkWidget *dockbook;
+ GimpMenuFactory *menu_factory;
+ GtkWidget *dock;
+ GtkWidget *dockbook;
dock = gimp_menu_dock_new ();
gimp_dock_columns_add_dock (dock_columns, GIMP_DOCK (dock), dock_index);
- dockbook = gimp_dockbook_new (global_menu_factory);
+ menu_factory = gimp_dialog_factory_get_menu_factory (dock_columns->p->dialog_factory);
+ dockbook = gimp_dockbook_new (menu_factory);
gimp_dock_add_book (GIMP_DOCK (dock), GIMP_DOCKBOOK (dockbook), -1);
gtk_widget_show (GTK_WIDGET (dock));
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index f5d4fb7..ccbe637 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -31,8 +31,6 @@
#include "dialogs/dialogs.h" /* FIXME, we are in the widget layer */
-#include "menus/menus.h"
-
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
@@ -287,14 +285,15 @@ gimp_dock_window_session_managed_iface_init (GimpSessionManagedInterface *iface)
static void
gimp_dock_window_constructed (GObject *object)
{
- GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
- GimpGuiConfig *config;
- GimpContext *factory_context;
- GtkAccelGroup *accel_group;
- Gimp *gimp;
- GtkSettings *settings;
- gint menu_view_width = -1;
- gint menu_view_height = -1;
+ GimpDockWindow *dock_window = GIMP_DOCK_WINDOW (object);
+ GimpGuiConfig *config;
+ GimpContext *factory_context;
+ GimpMenuFactory *menu_factory;
+ GtkAccelGroup *accel_group;
+ Gimp *gimp;
+ GtkSettings *settings;
+ gint menu_view_width = -1;
+ gint menu_view_height = -1;
G_OBJECT_CLASS (parent_class)->constructed (object);
@@ -316,11 +315,14 @@ gimp_dock_window_constructed (GObject *object)
/* Setup hints */
gimp_window_set_hint (GTK_WINDOW (dock_window), config->dock_window_hint);
+ menu_factory =
+ gimp_dialog_factory_get_menu_factory (dock_window->p->dialog_factory);
+
/* Make image window related keyboard shortcuts work also when a
* dock window is the focused window
*/
dock_window->p->ui_manager =
- gimp_menu_factory_manager_new (global_menu_factory,
+ gimp_menu_factory_manager_new (menu_factory,
dock_window->p->ui_manager_name,
dock_window,
config->tearoff_menus);
@@ -1138,17 +1140,17 @@ GtkWidget *
gimp_dock_window_new (const gchar *role,
const gchar *ui_manager_name,
gboolean allow_dockbook_absence,
- GimpDialogFactory *factory,
+ GimpDialogFactory *dialog_factory,
GimpContext *context)
{
- g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
+ g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
return g_object_new (GIMP_TYPE_DOCK_WINDOW,
"role", role,
"ui-manager-name", ui_manager_name,
"allow-dockbook-absence", allow_dockbook_absence,
- "dialog-factory", factory,
+ "dialog-factory", dialog_factory,
"context", context,
NULL);
}
diff --git a/app/widgets/gimpsessioninfo-book.c b/app/widgets/gimpsessioninfo-book.c
index 42ca5ad..4291bc4 100644
--- a/app/widgets/gimpsessioninfo-book.c
+++ b/app/widgets/gimpsessioninfo-book.c
@@ -26,8 +26,6 @@
#include "widgets-types.h"
-#include "menus/menus.h"
-
#include "gimpdialogfactory.h"
#include "gimpdock.h"
#include "gimpdockbook.h"
@@ -242,14 +240,19 @@ GimpDockbook *
gimp_session_info_book_restore (GimpSessionInfoBook *info,
GimpDock *dock)
{
- GtkWidget *dockbook;
- GList *pages;
- gint n_dockables = 0;
+ GimpDialogFactory *dialog_factory;
+ GimpMenuFactory *menu_factory;
+ GtkWidget *dockbook;
+ GList *pages;
+ gint n_dockables = 0;
g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
- dockbook = gimp_dockbook_new (global_menu_factory);
+ dialog_factory = gimp_dock_get_dialog_factory (dock);
+ menu_factory = gimp_dialog_factory_get_menu_factory (dialog_factory);
+
+ dockbook = gimp_dockbook_new (menu_factory);
gimp_dock_add_book (dock, GIMP_DOCKBOOK (dockbook), -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]