~canonical-dx-team/ubuntu/maverick/gtk+2.0/menuproxy

« back to all changes in this revision

Viewing changes to gtk/gtkinvisible.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-05-04 12:24:25 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20070504122425-0m8midgzrp40y8w2
Tags: 2.10.12-1ubuntu1
* Sync with Debian
* New upstream version:
  Fixed bugs:
  - 379414 file chooser warnings when changing path in the entry
  - 418585 GtkFileChooserDefault sizing code is not DPI independent
  - 419568 Crash in search if start with special letter
  - 435062 build dies with icon cache validation
  - 379399 Segfault to call gtk_print_operation_run twice.
  - 387889 cups backend has problems when there are too many printers
  - 418531 invalid read to gtkicontheme.c gtk_icon_theme_lookup_icon...
  - 423916 crash in color scheme code
  - 424042 Segmentation fault while quickly pressing Alt+arrows
  - 415260 Protect against negative indices when setting values in G...
  - 419171 XGetVisualInfo() may not set nxvisuals
  - 128852 Gdk cursors don't look good on win32
  - 344657 Ctrl-H doesn't toggle "Show Hidden Files" setting
  - 345345 PrintOperation::paginate is not emitted for class handler
  - 347567 GtkPrintOperation::end-print is not emitted if it's cance...
  - 369112 gtk_ui_manager_add_ui should accept unnamed separator
  - 392015 Selected menu item invisible on Windows Vista
  - 399253 MS-Windows Theme Bottom Tab placement rendering glitches
  - 399425 gtk_input_dialog_fill_axes() adds child to gtkscrolledwin...
  - 403251 [patch] little memory leak in GtkPrintJob
  - 403267 [patch] memory leak in GtkPageSetupUnixDialog
  - 403470 MS-Windows Theme tab placement other than on top leaks a ...
  - 404506 Windows system fonts that have multi-byte font names cann...
  - 405089 Incorrect window placement for GtkEventBox private window
  - 405515 Minor leak in gtkfilesystemmodel.c
  - 405539 gdk_pixbuf_save() for PNG saver can return FALSE without ...
  - 415681 gdk_window_clear_area includes an extra line and column o...
  - 418219 GtkRecentChooser should apply filter before sorting and c...
  - 418403 Scroll to printer after selecting it from settings
  - 421985 _gtk_print_operation_platform_backend_launch_preview
  - 421990 gtk_print_job_get_surface
  - 421993 gtk_print_operation_init
  - 423064 Conditional jump or move depends on uninitialised value(s...
  - 423722 Fix printing header in gtk-demo
  - 424168 gtk_print_operation_run on async preview
  - 425655 Don't install gtk+-unix-print-2.0.pc on non-UNIX platforms
  - 425786 GDK segfaults if XineramaQueryScreens fails
  - 428665 Lpr Backend gets stuck in infinite loop during gtk_enumer...
  - 429902 GtkPrintOperation leaks cairo contextes
  - 431997 First delay of GdkPixbufAnimationIter is wrong
  - 433242 Inconsistent scroll arrow position calculations
  - 433972 Placing gtk.Expander inside a gtk.TextView() changes gtk....
  - 434261 _gtk_toolbar_elide_underscores incorrectly handles some s...
  - 383354 ctrl-L should make 'Location' entry disappear
  - 418673 gtk_recent_manager_add_item
  - 429732 gtk_accel_group_finalize accesses invalid memory
  - 435028 WM_CLIENT_LEADER is wrong on the leader_window
  - 431067 Background of the header window is not updated
  - 338843 add recent files support inside the ui manager
  - 148535 add drop shadow to menus, tooltips, etc. under Windows XP
* debian/control.in:
  - Conflicts on ubuntulooks (<= 0.9.11-1)
* debian/patches/15_default-fallback-icon-theme.patch:
  - patch from Debian, fallback on gnome icon theme

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GTK - The GIMP Toolkit
 
2
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library 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 GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
/*
 
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
 
22
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 
23
 * files for a list of changes.  These files are distributed with
 
24
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 
25
 */
 
26
 
 
27
#include <config.h>
 
28
#include <gdk/gdk.h>
 
29
#include "gtkinvisible.h"
 
30
#include "gtkprivate.h"
 
31
#include "gtkintl.h"
 
32
#include "gtkalias.h"
 
33
 
 
34
enum {
 
35
  PROP_0,
 
36
  PROP_SCREEN,
 
37
  LAST_ARG
 
38
};
 
39
 
 
40
static void gtk_invisible_destroy       (GtkObject         *object);
 
41
static void gtk_invisible_realize       (GtkWidget         *widget);
 
42
static void gtk_invisible_style_set     (GtkWidget         *widget,
 
43
                                         GtkStyle          *previous_style);
 
44
static void gtk_invisible_show          (GtkWidget         *widget);
 
45
static void gtk_invisible_size_allocate (GtkWidget         *widget,
 
46
                                         GtkAllocation     *allocation);
 
47
static void gtk_invisible_set_property  (GObject           *object,
 
48
                                         guint              prop_id,
 
49
                                         const GValue      *value,
 
50
                                         GParamSpec        *pspec);
 
51
static void gtk_invisible_get_property  (GObject           *object,
 
52
                                         guint              prop_id,
 
53
                                         GValue            *value,
 
54
                                         GParamSpec        *pspec);
 
55
 
 
56
static GObject *gtk_invisible_constructor (GType                  type,
 
57
                                           guint                  n_construct_properties,
 
58
                                           GObjectConstructParam *construct_params);
 
59
 
 
60
G_DEFINE_TYPE (GtkInvisible, gtk_invisible, GTK_TYPE_WIDGET)
 
61
 
 
62
static void
 
63
gtk_invisible_class_init (GtkInvisibleClass *class)
 
64
{
 
65
  GObjectClass   *gobject_class;
 
66
  GtkObjectClass *object_class;
 
67
  GtkWidgetClass *widget_class;
 
68
 
 
69
  widget_class = (GtkWidgetClass*) class;
 
70
  object_class = (GtkObjectClass*) class;
 
71
  gobject_class = (GObjectClass*) class;
 
72
 
 
73
  widget_class->realize = gtk_invisible_realize;
 
74
  widget_class->style_set = gtk_invisible_style_set;
 
75
  widget_class->show = gtk_invisible_show;
 
76
  widget_class->size_allocate = gtk_invisible_size_allocate;
 
77
 
 
78
  object_class->destroy = gtk_invisible_destroy;
 
79
  gobject_class->set_property = gtk_invisible_set_property;
 
80
  gobject_class->get_property = gtk_invisible_get_property;
 
81
  gobject_class->constructor = gtk_invisible_constructor;
 
82
 
 
83
  g_object_class_install_property (gobject_class,
 
84
                                   PROP_SCREEN,
 
85
                                   g_param_spec_object ("screen",
 
86
                                                        P_("Screen"),
 
87
                                                        P_("The screen where this window will be displayed"),
 
88
                                                        GDK_TYPE_SCREEN,
 
89
                                                        GTK_PARAM_READWRITE));
 
90
}
 
91
 
 
92
static void
 
93
gtk_invisible_init (GtkInvisible *invisible)
 
94
{
 
95
  GdkColormap *colormap;
 
96
  
 
97
  GTK_WIDGET_UNSET_FLAGS (invisible, GTK_NO_WINDOW);
 
98
  GTK_WIDGET_SET_FLAGS (invisible, GTK_TOPLEVEL);
 
99
 
 
100
  g_object_ref_sink (invisible);
 
101
 
 
102
  invisible->has_user_ref_count = TRUE;
 
103
  invisible->screen = gdk_screen_get_default ();
 
104
  
 
105
  colormap = _gtk_widget_peek_colormap ();
 
106
  if (colormap)
 
107
    gtk_widget_set_colormap (GTK_WIDGET (invisible), colormap);
 
108
}
 
109
 
 
110
static void
 
111
gtk_invisible_destroy (GtkObject *object)
 
112
{
 
113
  GtkInvisible *invisible = GTK_INVISIBLE (object);
 
114
  
 
115
  if (invisible->has_user_ref_count)
 
116
    {
 
117
      invisible->has_user_ref_count = FALSE;
 
118
      g_object_unref (invisible);
 
119
    }
 
120
 
 
121
  GTK_OBJECT_CLASS (gtk_invisible_parent_class)->destroy (object);  
 
122
}
 
123
 
 
124
/**
 
125
 * gtk_invisible_new_for_screen:
 
126
 * @screen: a #GdkScreen which identifies on which
 
127
 *          the new #GtkInvisible will be created.
 
128
 *
 
129
 * Creates a new #GtkInvisible object for a specified screen
 
130
 *
 
131
 * Return value: a newly created #GtkInvisible object
 
132
 *
 
133
 * Since: 2.2
 
134
 **/
 
135
GtkWidget* 
 
136
gtk_invisible_new_for_screen (GdkScreen *screen)
 
137
{
 
138
  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
 
139
  
 
140
  return g_object_new (GTK_TYPE_INVISIBLE, "screen", screen, NULL);
 
141
}
 
142
 
 
143
/**
 
144
 * gtk_invisible_new:
 
145
 * 
 
146
 * Creates a new #GtkInvisible.
 
147
 * 
 
148
 * Return value: a new #GtkInvisible.
 
149
 **/
 
150
GtkWidget*
 
151
gtk_invisible_new (void)
 
152
{
 
153
  return g_object_new (GTK_TYPE_INVISIBLE, NULL);
 
154
}
 
155
 
 
156
/**
 
157
 * gtk_invisible_set_screen:
 
158
 * @invisible: a #GtkInvisible.
 
159
 * @screen: a #GdkScreen.
 
160
 *
 
161
 * Sets the #GdkScreen where the #GtkInvisible object will be displayed.
 
162
 *
 
163
 * Since: 2.2
 
164
 **/ 
 
165
void
 
166
gtk_invisible_set_screen (GtkInvisible *invisible,
 
167
                          GdkScreen    *screen)
 
168
{
 
169
  GtkWidget *widget;
 
170
  GdkScreen *previous_screen;
 
171
  gboolean was_realized;
 
172
  
 
173
  g_return_if_fail (GTK_IS_INVISIBLE (invisible));
 
174
  g_return_if_fail (GDK_IS_SCREEN (screen));
 
175
 
 
176
  if (screen == invisible->screen)
 
177
    return;
 
178
 
 
179
  widget = GTK_WIDGET (invisible);
 
180
 
 
181
  previous_screen = invisible->screen;
 
182
  was_realized = GTK_WIDGET_REALIZED (invisible);
 
183
 
 
184
  if (was_realized)
 
185
    gtk_widget_unrealize (widget);
 
186
  
 
187
  invisible->screen = screen;
 
188
  if (screen != previous_screen)
 
189
    _gtk_widget_propagate_screen_changed (widget, previous_screen);
 
190
  g_object_notify (G_OBJECT (invisible), "screen");
 
191
  
 
192
  if (was_realized)
 
193
    gtk_widget_realize (widget);
 
194
}
 
195
 
 
196
/**
 
197
 * gtk_invisible_get_screen:
 
198
 * @invisible: a #GtkInvisible.
 
199
 *
 
200
 * Returns the #GdkScreen object associated with @invisible
 
201
 *
 
202
 * Return value: the associated #GdkScreen.
 
203
 *
 
204
 * Since: 2.2
 
205
 **/
 
206
GdkScreen *
 
207
gtk_invisible_get_screen (GtkInvisible *invisible)
 
208
{
 
209
  g_return_val_if_fail (GTK_IS_INVISIBLE (invisible), NULL);
 
210
  
 
211
  return invisible->screen;
 
212
}
 
213
 
 
214
static void
 
215
gtk_invisible_realize (GtkWidget *widget)
 
216
{
 
217
  GdkWindow *parent;
 
218
  GdkWindowAttr attributes;
 
219
  gint attributes_mask;
 
220
 
 
221
  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
 
222
 
 
223
  parent = gtk_widget_get_parent_window (widget);
 
224
  if (parent == NULL)
 
225
    parent = gtk_widget_get_root_window (widget);
 
226
 
 
227
  attributes.x = -100;
 
228
  attributes.y = -100;
 
229
  attributes.width = 10;
 
230
  attributes.height = 10;
 
231
  attributes.window_type = GDK_WINDOW_TEMP;
 
232
  attributes.wclass = GDK_INPUT_ONLY;
 
233
  attributes.override_redirect = TRUE;
 
234
  attributes.event_mask = gtk_widget_get_events (widget);
 
235
 
 
236
  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
 
237
 
 
238
  widget->window = gdk_window_new (parent, &attributes, attributes_mask);
 
239
                                              
 
240
  gdk_window_set_user_data (widget->window, widget);
 
241
  
 
242
  widget->style = gtk_style_attach (widget->style, widget->window);
 
243
}
 
244
 
 
245
static void
 
246
gtk_invisible_style_set (GtkWidget *widget,
 
247
                         GtkStyle  *previous_style)
 
248
{
 
249
  /* Don't chain up to parent implementation */
 
250
}
 
251
 
 
252
static void
 
253
gtk_invisible_show (GtkWidget *widget)
 
254
{
 
255
  GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
 
256
  gtk_widget_map (widget);
 
257
}
 
258
 
 
259
static void
 
260
gtk_invisible_size_allocate (GtkWidget     *widget,
 
261
                            GtkAllocation *allocation)
 
262
{
 
263
  widget->allocation = *allocation;
 
264
 
265
 
 
266
 
 
267
static void 
 
268
gtk_invisible_set_property  (GObject      *object,
 
269
                             guint         prop_id,
 
270
                             const GValue *value,
 
271
                             GParamSpec   *pspec)
 
272
{
 
273
  GtkInvisible *invisible = GTK_INVISIBLE (object);
 
274
  
 
275
  switch (prop_id)
 
276
    {
 
277
    case PROP_SCREEN:
 
278
      gtk_invisible_set_screen (invisible, g_value_get_object (value));
 
279
      break;
 
280
    default:
 
281
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
282
      break;
 
283
    }
 
284
}
 
285
 
 
286
static void 
 
287
gtk_invisible_get_property  (GObject      *object,
 
288
                             guint         prop_id,
 
289
                             GValue       *value,
 
290
                             GParamSpec   *pspec)
 
291
{
 
292
  GtkInvisible *invisible = GTK_INVISIBLE (object);
 
293
 
 
294
  switch (prop_id)
 
295
    {
 
296
    case PROP_SCREEN:
 
297
      g_value_set_object (value, invisible->screen);
 
298
      break;
 
299
    default:
 
300
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
301
      break;
 
302
    }
 
303
}
 
304
 
 
305
/* We use a constructor here so that we can realize the invisible on
 
306
 * the correct screen after the "screen" property has been set
 
307
 */
 
308
static GObject*
 
309
gtk_invisible_constructor (GType                  type,
 
310
                           guint                  n_construct_properties,
 
311
                           GObjectConstructParam *construct_params)
 
312
{
 
313
  GObject *object;
 
314
 
 
315
  object = (* G_OBJECT_CLASS (gtk_invisible_parent_class)->constructor) (type,
 
316
                                                                         n_construct_properties,
 
317
                                                                         construct_params);
 
318
 
 
319
  gtk_widget_realize (GTK_WIDGET (object));
 
320
 
 
321
  return object;
 
322
}
 
323
 
 
324
#define __GTK_INVISIBLE_C__
 
325
#include "gtkaliasdef.c"