Commit e87ed66b authored by Martin Nordholts's avatar Martin Nordholts

app: Don't cast GimpDock to GimpDockWindow

In preparation for making GimpDock inherit from a non-window, stop
casting GimpDocks to GimpDockWindows. Instead look up the toplevel
widget for a dock and get the dock window that way.
parent 17f0b1aa
......@@ -34,6 +34,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpdockwindow.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
......@@ -161,10 +162,10 @@ windows_actions_update (GimpActionGroup *group,
gchar *
windows_actions_dock_to_action_name (GimpDock *dock)
{
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
GimpDockWindow *dock_window = gimp_dock_window_from_dock (dock);
return g_strdup_printf ("windows-dock-%04d",
gimp_dock_window_get_id (GIMP_DOCK_WINDOW (dock)));
gimp_dock_window_get_id (dock_window));
}
......
......@@ -295,8 +295,10 @@ windows_menu_dock_removed (GimpDialogFactory *factory,
static gchar *
windows_menu_dock_to_merge_id (GimpDock *dock)
{
GimpDockWindow *dock_window = gimp_dock_window_from_dock (dock);
return g_strdup_printf ("windows-dock-%04d-merge-id",
gimp_dock_window_get_id (GIMP_DOCK_WINDOW (dock)));
gimp_dock_window_get_id (dock_window));
}
static void
......
......@@ -36,6 +36,7 @@
#include "gimpdockable.h"
#include "gimpdockbook.h"
#include "gimpdocked.h"
#include "gimpdockwindow.h"
#include "gimphelp-ids.h"
#include "gimpmenufactory.h"
#include "gimpstringaction.h"
......@@ -463,9 +464,10 @@ GtkWidget *
gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
GimpDockable *dockable)
{
GtkWidget *tab_widget;
GtkIconSize tab_size = DEFAULT_TAB_ICON_SIZE;
GtkAction *action = NULL;
GtkWidget *tab_widget;
GimpDockWindow *dock_window;
GtkIconSize tab_size = DEFAULT_TAB_ICON_SIZE;
GtkAction *action = NULL;
gtk_widget_style_get (GTK_WIDGET (dockbook),
"tab-icon-size", &tab_size,
......@@ -490,8 +492,8 @@ gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
}
/* EEK */
if (GIMP_IS_DOCK_WINDOW (dockbook->p->dock) &&
gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dockbook->p->dock)))
dock_window = gimp_dock_window_from_dock (dockbook->p->dock);
if (dock_window && gimp_dock_window_get_ui_manager (dock_window))
{
const gchar *dialog_id;
......@@ -503,7 +505,7 @@ gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
GimpActionGroup *group;
group = gimp_ui_manager_get_action_group
(gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dockbook->p->dock)), "dialogs");
(gimp_dock_window_get_ui_manager (dock_window), "dialogs");
if (group)
{
......
......@@ -527,3 +527,27 @@ gimp_dock_window_get_ui_manager (GimpDockWindow *dock_window)
return dock_window->p->ui_manager;
}
/**
* gimp_dock_window_from_dock:
* @dock:
*
* For convenience.
*
* Returns: If the toplevel widget for the dock is a GimpDockWindow,
* return that. Otherwise return %NULL.
**/
GimpDockWindow *
gimp_dock_window_from_dock (GimpDock *dock)
{
GtkWidget *toplevel = NULL;
g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (dock));
if (GIMP_IS_DOCK_WINDOW (toplevel))
return GIMP_DOCK_WINDOW (toplevel);
else
return NULL;
}
......@@ -56,6 +56,7 @@ struct _GimpDockWindowClass
GType gimp_dock_window_get_type (void) G_GNUC_CONST;
gint gimp_dock_window_get_id (GimpDockWindow *dock_window);
GimpUIManager * gimp_dock_window_get_ui_manager (GimpDockWindow *dock_window);
GimpDockWindow * gimp_dock_window_from_dock (GimpDock *dock);
#endif /* __GIMP_DOCK_WINDOW_H__ */
......@@ -39,6 +39,7 @@
#include "gimpdevices.h"
#include "gimpdialogfactory.h"
#include "gimpdockseparator.h"
#include "gimpdockwindow.h"
#include "gimphelp-ids.h"
#include "gimptoolbox.h"
#include "gimptoolbox-color-area.h"
......@@ -690,10 +691,11 @@ toolbox_create_tools (GimpToolbox *toolbox,
list;
list = g_list_next (list))
{
GimpToolInfo *tool_info = list->data;
GtkWidget *button;
GtkWidget *image;
const gchar *stock_id;
GimpToolInfo *tool_info = list->data;
GtkWidget *button;
GtkWidget *image;
GimpDockWindow *dock_window;
const gchar *stock_id;
button = gtk_radio_button_new (group);
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
......@@ -728,7 +730,8 @@ toolbox_create_tools (GimpToolbox *toolbox,
G_CALLBACK (toolbox_tool_button_press),
toolbox);
if (gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (toolbox)))
dock_window = gimp_dock_window_from_dock (GIMP_DOCK (toolbox));
if (gimp_dock_window_get_ui_manager (dock_window))
{
GimpUIManager *ui_manager;
GtkAction *action;
......@@ -743,8 +746,8 @@ toolbox_create_tools (GimpToolbox *toolbox,
name = g_strdup_printf ("tools-%s", tmp);
g_free (tmp);
ui_manager = gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (toolbox));
action = gimp_ui_manager_find_action (ui_manager, "tools", name);
ui_manager = gimp_dock_window_get_ui_manager (dock_window);
action = gimp_ui_manager_find_action (ui_manager, "tools", name);
g_free (name);
if (action)
......
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