gimp r25633 - in trunk: . app/actions app/menus
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25633 - in trunk: . app/actions app/menus
- Date: Sun, 11 May 2008 09:15:01 +0100 (BST)
Author: mitch
Date: Sun May 11 08:15:00 2008
New Revision: 25633
URL: http://svn.gnome.org/viewvc/gimp?rev=25633&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/app/actions/windows-actions.c
trunk/app/actions/windows-commands.c
trunk/app/actions/windows-commands.h
trunk/app/menus/windows-menu.c
Modified: trunk/app/actions/windows-actions.c
==============================================================================
--- trunk/app/actions/windows-actions.c (original)
+++ trunk/app/actions/windows-actions.c Sun May 11 08:15:00 2008
@@ -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_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_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);
+}
Modified: trunk/app/actions/windows-commands.c
==============================================================================
--- trunk/app/actions/windows-commands.c (original)
+++ trunk/app/actions/windows-commands.c Sun May 11 08:15:00 2008
@@ -52,6 +52,15 @@
}
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)
{
if (! global_toolbox_factory->open_dialogs)
Modified: trunk/app/actions/windows-commands.h
==============================================================================
--- trunk/app/actions/windows-commands.h (original)
+++ trunk/app/actions/windows-commands.h Sun May 11 08:15:00 2008
@@ -24,6 +24,8 @@
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);
Modified: trunk/app/menus/windows-menu.c
==============================================================================
--- trunk/app/menus/windows-menu.c (original)
+++ trunk/app/menus/windows-menu.c Sun May 11 08:15:00 2008
@@ -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 @@
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 @@
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_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_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);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]