Commit 7d25d6e6 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/actions/windows-commands.[ch] app/actions/windows-actions.c add

2008-05-11  Michael Natterer  <mitch@gimp.org>

	* app/actions/windows-commands.[ch]
	* app/actions/windows-actions.c
	* app/menus/windows-menu.c: add dynamic actions and menu items for
	all open docks. Present the dock when the menu item is selected.


svn path=/trunk/; revision=25633
parent d9338124
2008-05-11 Michael Natterer <mitch@gimp.org>
* app/actions/windows-commands.[ch]
* app/actions/windows-actions.c
* app/menus/windows-menu.c: add dynamic actions and menu items for
all open docks. Present the dock when the menu item is selected.
2008-05-10 Martin Nordholts <martinn@svn.gnome.org>
* app/tools/gimprectangletool.c
......@@ -42,7 +49,7 @@
* app/widgets/gimpactiongroup.h: fix parameter name.
2008-05-10 DindinX <dindinx@mitch.org>
2008-05-10 DindinX <dindinx@gimp.org>
* plug-ins/flame/cmap.c
* plug-ins/flame/libifs.c
......
......@@ -32,25 +32,39 @@
#include "file/file-utils.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "dialogs/dialogs.h"
#include "windows-actions.h"
#include "windows-commands.h"
#include "gimp-intl.h"
static void windows_actions_display_add (GimpContainer *container,
GimpDisplay *display,
GimpActionGroup *group);
static void windows_actions_display_remove (GimpContainer *container,
GimpDisplay *display,
GimpActionGroup *group);
static void windows_actions_image_notify (GimpDisplay *display,
const GParamSpec *unused,
GimpActionGroup *group);
static void windows_actions_display_add (GimpContainer *container,
GimpDisplay *display,
GimpActionGroup *group);
static void windows_actions_display_remove (GimpContainer *container,
GimpDisplay *display,
GimpActionGroup *group);
static void windows_actions_image_notify (GimpDisplay *display,
const GParamSpec *unused,
GimpActionGroup *group);
static void windows_actions_dock_added (GimpDialogFactory *factory,
GimpDock *dock,
GimpActionGroup *group);
static void windows_actions_dock_removed (GimpDialogFactory *factory,
GimpDock *dock,
GimpActionGroup *group);
static void windows_actions_dock_notify (GimpDock *dock,
const GParamSpec *pspec,
GimpActionGroup *group);
static const GimpActionEntry windows_actions[] =
......@@ -94,6 +108,23 @@ windows_actions_setup (GimpActionGroup *group)
windows_actions_display_add (group->gimp->displays, display, group);
}
g_signal_connect_object (global_dock_factory, "dock-added",
G_CALLBACK (windows_actions_dock_added),
group, 0);
g_signal_connect_object (global_dock_factory, "dock-removed",
G_CALLBACK (windows_actions_dock_removed),
group, 0);
for (list = global_dock_factory->open_dialogs;
list;
list = g_list_next (list))
{
GimpDock *dock = list->data;
if (GIMP_IS_DOCK (dock))
windows_actions_dock_added (global_dock_factory, dock, group);
}
}
void
......@@ -207,3 +238,69 @@ windows_actions_image_notify (GimpDisplay *display,
windows_actions_display_remove (group->gimp->displays, display, group);
}
}
static void
windows_actions_dock_added (GimpDialogFactory *factory,
GimpDock *dock,
GimpActionGroup *group)
{
GtkAction *action;
GimpActionEntry entry;
gchar *action_name = g_strdup_printf ("windows-dock-%04d", dock->ID);
entry.name = action_name;
entry.stock_id = NULL;
entry.label = "";
entry.accelerator = NULL;
entry.tooltip = NULL;
entry.callback = G_CALLBACK (windows_show_dock_cmd_callback);
entry.help_id = NULL;
gimp_action_group_add_actions (group, &entry, 1);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
action_name);
g_object_set_data (G_OBJECT (action), "dock", dock);
g_free (action_name);
g_signal_connect_object (dock, "notify::title",
G_CALLBACK (windows_actions_dock_notify),
group, 0);
if (gtk_window_get_title (GTK_WINDOW (dock)))
windows_actions_dock_notify (dock, NULL, group);
}
static void
windows_actions_dock_removed (GimpDialogFactory *factory,
GimpDock *dock,
GimpActionGroup *group)
{
GtkAction *action;
gchar *action_name = g_strdup_printf ("windows-dock-%04d", dock->ID);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
if (action)
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
g_free (action_name);
}
static void
windows_actions_dock_notify (GimpDock *dock,
const GParamSpec *pspec,
GimpActionGroup *group)
{
GtkAction *action;
gchar *action_name = g_strdup_printf ("windows-dock-%04d", dock->ID);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
if (action)
g_object_set (action,
"label", gtk_window_get_title (GTK_WINDOW (dock)),
NULL);
}
......@@ -51,6 +51,15 @@ windows_show_display_cmd_callback (GtkAction *action,
gtk_window_present (GTK_WINDOW (display->shell));
}
void
windows_show_dock_cmd_callback (GtkAction *action,
gpointer data)
{
GtkWindow *dock = g_object_get_data (G_OBJECT (action), "dock");
gtk_window_present (dock);
}
void
windows_show_toolbox (void)
{
......
......@@ -24,6 +24,8 @@ void windows_show_toolbox_cmd_callback (GtkAction *action,
gpointer data);
void windows_show_display_cmd_callback (GtkAction *action,
gpointer data);
void windows_show_dock_cmd_callback (GtkAction *action,
gpointer data);
void windows_show_toolbox (void);
......
......@@ -31,22 +31,33 @@
#include "core/gimpviewable.h"
#include "widgets/gimpaction.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpuimanager.h"
#include "display/gimpdisplay.h"
#include "dialogs/dialogs.h"
#include "windows-menu.h"
static void windows_menu_display_add (GimpContainer *container,
GimpDisplay *display,
GimpUIManager *manager);
static void windows_menu_display_remove (GimpContainer *container,
GimpDisplay *display,
GimpUIManager *manager);
static void windows_menu_image_notify (GimpDisplay *display,
const GParamSpec *unused,
GimpUIManager *manager);
static void windows_menu_display_add (GimpContainer *container,
GimpDisplay *display,
GimpUIManager *manager);
static void windows_menu_display_remove (GimpContainer *container,
GimpDisplay *display,
GimpUIManager *manager);
static void windows_menu_image_notify (GimpDisplay *display,
const GParamSpec *unused,
GimpUIManager *manager);
static void windows_menu_dock_added (GimpDialogFactory *factory,
GimpDock *dock,
GimpUIManager *manager);
static void windows_menu_dock_removed (GimpDialogFactory *factory,
GimpDock *dock,
GimpUIManager *manager);
void
......@@ -58,6 +69,9 @@ windows_menu_setup (GimpUIManager *manager,
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (ui_path != NULL);
g_object_set_data (G_OBJECT (manager), "image-menu-ui-path",
(gpointer) ui_path);
g_signal_connect_object (manager->gimp->displays, "add",
G_CALLBACK (windows_menu_display_add),
manager, 0);
......@@ -65,9 +79,6 @@ windows_menu_setup (GimpUIManager *manager,
G_CALLBACK (windows_menu_display_remove),
manager, 0);
g_object_set_data (G_OBJECT (manager), "image-menu-ui-path",
(gpointer) ui_path);
for (list = GIMP_LIST (manager->gimp->displays)->list;
list;
list = g_list_next (list))
......@@ -76,6 +87,23 @@ windows_menu_setup (GimpUIManager *manager,
windows_menu_display_add (manager->gimp->displays, display, manager);
}
g_signal_connect_object (global_dock_factory, "dock-added",
G_CALLBACK (windows_menu_dock_added),
manager, 0);
g_signal_connect_object (global_dock_factory, "dock-removed",
G_CALLBACK (windows_menu_dock_removed),
manager, 0);
for (list = global_dock_factory->open_dialogs;
list;
list = g_list_next (list))
{
GimpDock *dock = list->data;
if (GIMP_IS_DOCK (dock))
windows_menu_dock_added (global_dock_factory, dock, manager);
}
}
......@@ -161,3 +189,54 @@ windows_menu_image_notify (GimpDisplay *display,
windows_menu_display_remove (manager->gimp->displays, display, manager);
}
}
static void
windows_menu_dock_added (GimpDialogFactory *factory,
GimpDock *dock,
GimpUIManager *manager)
{
const gchar *ui_path;
gchar *action_name;
gchar *action_path;
gchar *merge_key;
guint merge_id;
ui_path = g_object_get_data (G_OBJECT (manager), "image-menu-ui-path");
action_name = g_strdup_printf ("windows-dock-%04d", dock->ID);
action_path = g_strdup_printf ("%s/Windows/Docks/Docks", ui_path);
merge_key = g_strdup_printf ("windows-dock-%04d-merge-id", dock->ID);
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
g_object_set_data (G_OBJECT (manager), merge_key,
GUINT_TO_POINTER (merge_id));
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
action_path, action_name, action_name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
g_free (merge_key);
g_free (action_path);
g_free (action_name);
}
static void
windows_menu_dock_removed (GimpDialogFactory *factory,
GimpDock *dock,
GimpUIManager *manager)
{
gchar *merge_key = g_strdup_printf ("windows-dock-%04d-merge-id", dock->ID);
guint merge_id;
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
merge_key));
if (merge_id)
gtk_ui_manager_remove_ui (GTK_UI_MANAGER (manager), merge_id);
g_object_set_data (G_OBJECT (manager), merge_key, NULL);
g_free (merge_key);
}
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