~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/menus/window-menu.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "menus-types.h"
 
24
 
 
25
#include "config/gimpguiconfig.h"
 
26
 
 
27
#include "core/gimp.h"
 
28
 
 
29
#include "widgets/gimpuimanager.h"
 
30
 
 
31
#include "window-menu.h"
 
32
 
 
33
 
 
34
/*  private functions  */
 
35
 
 
36
static void   window_menu_display_opened (GdkDisplayManager *disp_manager,
 
37
                                          GdkDisplay        *display,
 
38
                                          GimpUIManager     *manager);
 
39
static void   window_menu_display_closed (GdkDisplay        *display,
 
40
                                          gboolean           is_error,
 
41
                                          GimpUIManager     *manager);
 
42
 
 
43
 
 
44
/*  public functions  */
 
45
 
 
46
void
 
47
window_menu_setup (GimpUIManager *manager,
 
48
                   const gchar   *group_name,
 
49
                   const gchar   *ui_path)
 
50
{
 
51
  GdkDisplayManager *disp_manager = gdk_display_manager_get ();
 
52
  GSList            *displays;
 
53
  GSList            *list;
 
54
 
 
55
  g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
 
56
  g_return_if_fail (ui_path != NULL);
 
57
 
 
58
  g_object_set_data_full (G_OBJECT (manager), "move-to-screen-group-name",
 
59
                          g_strdup (group_name),
 
60
                          (GDestroyNotify) g_free);
 
61
  g_object_set_data_full (G_OBJECT (manager), "move-to-screen-ui-path",
 
62
                          g_strdup (ui_path),
 
63
                          (GDestroyNotify) g_free);
 
64
 
 
65
  displays = gdk_display_manager_list_displays (disp_manager);
 
66
 
 
67
  /*  present displays in the order in which they were opened  */
 
68
  displays = g_slist_reverse (displays);
 
69
 
 
70
  for (list = displays; list; list = g_slist_next (list))
 
71
    {
 
72
      window_menu_display_opened (disp_manager, list->data, manager);
 
73
    }
 
74
 
 
75
  g_slist_free (displays);
 
76
 
 
77
  g_signal_connect_object (disp_manager, "display-opened",
 
78
                           G_CALLBACK (window_menu_display_opened),
 
79
                           G_OBJECT (manager), 0);
 
80
}
 
81
 
 
82
 
 
83
/*  private functions  */
 
84
 
 
85
static void
 
86
window_menu_display_opened (GdkDisplayManager *disp_manager,
 
87
                            GdkDisplay        *display,
 
88
                            GimpUIManager     *manager)
 
89
{
 
90
  GtkUIManager *ui_manager = GTK_UI_MANAGER (manager);
 
91
  const gchar  *group_name;
 
92
  const gchar  *ui_path;
 
93
  const gchar  *display_name;
 
94
  gchar        *action_path;
 
95
  gchar        *merge_key;
 
96
  guint         merge_id;
 
97
  gint          n_screens;
 
98
  gint          i;
 
99
 
 
100
  group_name = g_object_get_data (G_OBJECT (manager),
 
101
                                  "move-to-screen-group-name");
 
102
  ui_path    = g_object_get_data (G_OBJECT (manager),
 
103
                                  "move-to-screen-ui-path");
 
104
 
 
105
  action_path = g_strdup_printf ("%s/Move to Screen", ui_path);
 
106
 
 
107
  display_name = gdk_display_get_name (display);
 
108
  if (! display_name)
 
109
    display_name = "eek";
 
110
 
 
111
  merge_key = g_strdup_printf ("%s-display-merge-id", display_name);
 
112
 
 
113
  merge_id = gtk_ui_manager_new_merge_id (ui_manager);
 
114
  g_object_set_data (G_OBJECT (manager), merge_key,
 
115
                     GUINT_TO_POINTER (merge_id));
 
116
 
 
117
  g_free (merge_key);
 
118
 
 
119
  n_screens = gdk_display_get_n_screens (display);
 
120
 
 
121
  for (i = 0; i < n_screens; i++)
 
122
    {
 
123
      GdkScreen *screen;
 
124
      gchar     *screen_name;
 
125
      gchar     *action_name;
 
126
 
 
127
      screen = gdk_display_get_screen (display, i);
 
128
 
 
129
      screen_name = gdk_screen_make_display_name (screen);
 
130
      action_name = g_strdup_printf ("%s-move-to-screen-%s",
 
131
                                     group_name, screen_name);
 
132
      g_free (screen_name);
 
133
 
 
134
      gtk_ui_manager_add_ui (ui_manager, merge_id,
 
135
                             action_path, action_name, action_name,
 
136
                             GTK_UI_MANAGER_MENUITEM,
 
137
                             FALSE);
 
138
 
 
139
      g_free (action_name);
 
140
    }
 
141
 
 
142
  g_free (action_path);
 
143
 
 
144
  g_signal_connect_object (display, "closed",
 
145
                           G_CALLBACK (window_menu_display_closed),
 
146
                           G_OBJECT (manager), 0);
 
147
}
 
148
 
 
149
static void
 
150
window_menu_display_closed (GdkDisplay    *display,
 
151
                            gboolean       is_error,
 
152
                            GimpUIManager *manager)
 
153
{
 
154
  const gchar *display_name;
 
155
  gchar       *merge_key;
 
156
  guint        merge_id;
 
157
 
 
158
  display_name = gdk_display_get_name (display);
 
159
  if (! display_name)
 
160
    display_name = "eek";
 
161
 
 
162
  merge_key = g_strdup_printf ("%s-display-merge-id", display_name);
 
163
  merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
 
164
                                                  merge_key));
 
165
  g_free (merge_key);
 
166
 
 
167
  if (merge_id)
 
168
    gtk_ui_manager_remove_ui (GTK_UI_MANAGER (manager), merge_id);
 
169
}