app: Add gimp_display_get_action_name() utility function

This commit is contained in:
Martin Nordholts 2011-03-15 08:18:48 +01:00
parent 5cea6b067f
commit 3b243bdcfe
5 changed files with 83 additions and 6 deletions

View File

@ -41,6 +41,7 @@
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-utils.h"
#include "dialogs/dialogs.h"
@ -229,8 +230,7 @@ windows_actions_display_remove (GimpContainer *container,
GimpActionGroup *group)
{
GtkAction *action;
gchar *action_name = g_strdup_printf ("windows-display-%04d",
gimp_display_get_ID (display));
gchar *action_name = gimp_display_get_action_name (display);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
@ -250,8 +250,7 @@ windows_actions_image_notify (GimpDisplay *display,
if (image)
{
GtkAction *action;
gchar *action_name = g_strdup_printf ("windows-display-%04d",
gimp_display_get_ID (display));
gchar *action_name = gimp_display_get_action_name (display);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
action_name);

View File

@ -71,6 +71,8 @@ libappdisplay_a_sources = \
gimpdisplay-foreach.h \
gimpdisplay-handlers.c \
gimpdisplay-handlers.h \
gimpdisplay-utils.c \
gimpdisplay-utils.h \
gimpdisplayshell.c \
gimpdisplayshell.h \
gimpdisplayshell-appearance.c \

View File

@ -0,0 +1,48 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdisplay-utils.c
* Copyright (C) 2011 Martin Nordholts <martinn@src.gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Utility functions for the display module (not only the GimpDisplay
* class).
*/
#include "config.h"
#include <gtk/gtk.h>
#include "display-types.h"
#include "gimpdisplay-utils.h"
#include "gimpdisplay.h"
/**
* gimp_display_get_action_name:
* @display:
*
* Returns: The action name for the given display. The action name
* depends on the display ID. The result must be freed with g_free().
**/
gchar *
gimp_display_get_action_name (GimpDisplay *display)
{
return g_strdup_printf ("windows-display-%04d",
gimp_display_get_ID (display));
}

View File

@ -0,0 +1,28 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdisplay-utils.h
* Copyright (C) 2011 Martin Nordholts <martinn@src.gnome.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_DISPLAY_UTILS_H__
#define __GIMP_DISPLAY_UTILS_H__
gchar * gimp_display_get_action_name (GimpDisplay *display);
#endif /* __GIMP_ACTIONS_UTILS_H__ */

View File

@ -40,6 +40,7 @@
#include "widgets/gimpuimanager.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-utils.h"
#include "dialogs/dialogs.h"
@ -205,8 +206,7 @@ windows_menu_image_notify (GimpDisplay *display,
ui_path = g_object_get_data (G_OBJECT (manager),
"image-menu-ui-path");
action_name = g_strdup_printf ("windows-display-%04d",
gimp_display_get_ID (display));
action_name = gimp_display_get_action_name (display);
action_path = g_strdup_printf ("%s/Windows/Images", ui_path);
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));