~ubuntu-branches/debian/experimental/xfce4-panel/experimental

« back to all changes in this revision

Viewing changes to libxfce4panel/xfce-hvbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Yves-Alexis Perez, Lionel Le Folgoc, Yves-Alexis Perez
  • Date: 2011-02-06 18:10:07 UTC
  • mfrom: (1.3.13 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110206181007-vpw5z3xnm3hdvybx
Tags: 4.8.1-1
[ Lionel Le Folgoc ]
* New upstream bugfix release.
* debian/control:
  - refreshed (b-)deps for this new major release
  - add myself to Uploaders
  - bump Standards-Version to 3.9.1.
* debian/NEWS: dropped, unneeded.
* debian/xfce4-panel.shlibs: refreshed, bump to (>= 4.7.2).
* debian/xfce4-panel.lintian-overrides: refreshed, new lib name.
* debian/xfce4-panel.preinst: added, handles removal of old conffiles.
* debian/xfce4-panel.postinst: explicitly set -e.
* debian/*.install: refreshed.
* debian/rules:
  - call dpkg-buildflags
  - dropped rc files mangling as they don't exist anymore
  - updated removal of *.{l,}a files.
  - drop overrides for dh_auto_{configure,clean}, obsolete.
* debian/xfce4-panel.{preinst,postinst,prerm}: use dpkg-maintscript-helper
  to remove pre-xfconf config files.
* Bugs fixed by 4.7.x/4.8.x series:
  - rgba support                                                  lp: #586012
  - disappearing menus                                             lp: #53897
  - xrandr support                               lp: #176174, Closes: #432914
  - Fails to reap children, creating zombies                      lp: #420187
  - DND of desktop-files on the panel to create new launchers Closes: #480380
* Bumped shlibs to >= 4.7.7, abi break for external plugins.

[ Yves-Alexis Perez ]
* New upstream development release
* debian/xfce4-panel.install:
  - install wrapper and migrate tools in xfce4-panel package
  - update plugins paths
* debian/rules:
  - update path when removing .a/.la files for plugins.
  - add hardening flags to {C,LD}FLAGS
* debian/control:
  - add build-dep on hardening-includes
  - update build-dep on garcon to 0.1.4.
* debian/copyright updated for new release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: xfce-hvbox.c 27412 2008-08-01 20:19:47Z nick $
 
1
/*
 
2
 * This file is partly based on OBox
 
3
 * Copyright (C) 2002      Red Hat Inc. based on GtkHBox
2
4
 *
3
 
 *  OBox Copyright (c) 2002      Red Hat Inc. based on GtkHBox
4
 
 *  Copyright      (c) 2006      Jani Monoses <jani@ubuntu.com>
5
 
 *  Copyright      (c) 2006-2007 Jasper Huijsmans <jasper@xfce.org>
 
5
 * Copyright (C) 2006-2007 Jasper Huijsmans <jasper@xfce.org>
 
6
 * Copyright (C) 2006      Jani Monoses <jani@ubuntu.com>
 
7
 * Copyright (C) 2007-2010 Nick Schermer <nick@xfce.org>
6
8
 *
7
9
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Library General Public
 
10
 * modify it under the terms of the GNU Lesser General Public
9
11
 * License as published by the Free Software Foundation; either
10
 
 * version 2 of the License, or (at your option) any later version.
 
12
 * version 2.1 of the License, or (at your option) any later version.
11
13
 *
12
14
 * This library is distributed in the hope that it will be useful,
13
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * Library General Public License for more details.
 
17
 * Lesser General Public License for more details.
16
18
 *
17
 
 * You should have received a copy of the GNU Library General Public
18
 
 * License along with this library; if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
 
19
 * You should have received a copy of the GNU Lesser General Public
 
20
 * License along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
22
 */
22
23
 
23
24
#ifdef HAVE_CONFIG_H
24
25
#include <config.h>
25
26
#endif
26
27
 
27
 
#include <gdk/gdk.h>
28
 
#include <gtk/gtkhbox.h>
29
 
#include <gtk/gtkvbox.h>
 
28
#include <gtk/gtk.h>
30
29
 
31
30
#include <libxfce4panel/xfce-panel-macros.h>
32
31
#include <libxfce4panel/xfce-hvbox.h>
34
33
 
35
34
 
36
35
 
37
 
/* prototypes */
38
 
static void  xfce_hvbox_class_init     (XfceHVBoxClass *klass);
39
 
static void  xfce_hvbox_size_request   (GtkWidget      *widget,
40
 
                                        GtkRequisition *requisition);
41
 
static void  xfce_hvbox_size_allocate  (GtkWidget      *widget,
42
 
                                        GtkAllocation  *allocation);
43
 
 
44
 
 
45
 
 
46
 
GtkType
47
 
xfce_hvbox_get_type (void)
 
36
/**
 
37
 * SECTION: xfce-hvbox
 
38
 * @title: XfceHVBox
 
39
 * @short_description: Container widget with configurable orienation
 
40
 * @include: libxfce4panel/libxfce4panel.h
 
41
 *
 
42
 * #XfceHVBox is a #GtkBox widget that allows the user to change
 
43
 * its orientation. It is in fact a combination of #GtkHBox and #GtkVBox.
 
44
 *
 
45
 * If your code depends on Gtk+ 2.16 or later, if it better to use
 
46
 * the normal #GtkBox widgets in combination with
 
47
 * gtk_orientable_set_orientation().
 
48
 *
 
49
 * See also: #GtkOrientable and #GtkBox.
 
50
 **/
 
51
 
 
52
 
 
53
 
 
54
#if !GTK_CHECK_VERSION (2, 16, 0)
 
55
enum
48
56
{
49
 
  static GtkType type = G_TYPE_INVALID;
50
 
 
51
 
  if (G_UNLIKELY (type == G_TYPE_INVALID))
52
 
    {
53
 
        type = _panel_g_type_register_simple (GTK_TYPE_BOX,
54
 
                                              "XfceHVBox",
55
 
                                              sizeof (XfceHVBoxClass),
56
 
                                              xfce_hvbox_class_init,
57
 
                                              sizeof (XfceHVBox),
58
 
                                              NULL);
59
 
    }
60
 
 
61
 
    return type;
62
 
}
 
57
  PROP_0,
 
58
  PROP_ORIENTATION
 
59
};
 
60
 
 
61
static void      xfce_hvbox_get_property (GObject        *object,
 
62
                                          guint           prop_id,
 
63
                                          GValue         *value,
 
64
                                          GParamSpec     *pspec);
 
65
static void      xfce_hvbox_set_property (GObject        *object,
 
66
                                          guint           prop_id,
 
67
                                          const GValue   *value,
 
68
                                          GParamSpec     *pspec);
 
69
static gpointer xfce_hvbox_get_class     (XfceHVBox      *hvbox);
 
70
static void     xfce_hvbox_size_request  (GtkWidget      *widget,
 
71
                                          GtkRequisition *requisition);
 
72
static void     xfce_hvbox_size_allocate (GtkWidget      *widget,
 
73
                                          GtkAllocation  *allocation);
 
74
#endif
 
75
 
 
76
 
 
77
 
 
78
G_DEFINE_TYPE (XfceHVBox, xfce_hvbox, GTK_TYPE_BOX)
63
79
 
64
80
 
65
81
 
66
82
static void
67
83
xfce_hvbox_class_init (XfceHVBoxClass *klass)
68
84
{
69
 
    GtkWidgetClass *widget_class;
70
 
 
71
 
    widget_class = (GtkWidgetClass *) klass;
72
 
 
73
 
    widget_class->size_request  = xfce_hvbox_size_request;
74
 
    widget_class->size_allocate = xfce_hvbox_size_allocate;
 
85
#if !GTK_CHECK_VERSION (2, 16, 0)
 
86
  GObjectClass   *gobject_class;
 
87
  GtkWidgetClass *gtkwidget_class;
 
88
 
 
89
  gobject_class = G_OBJECT_CLASS (klass);
 
90
  gobject_class->get_property = xfce_hvbox_get_property;
 
91
  gobject_class->set_property = xfce_hvbox_set_property;
 
92
 
 
93
  gtkwidget_class = GTK_WIDGET_CLASS (klass);
 
94
  gtkwidget_class->size_request  = xfce_hvbox_size_request;
 
95
  gtkwidget_class->size_allocate = xfce_hvbox_size_allocate;
 
96
 
 
97
  /**
 
98
   * XfceHVBox:orientation:
 
99
   *
 
100
   * The orientation of the #XfceHVBox. When compiled with Gtk+ 2.16,
 
101
   * this is the orientation property of the #GtkOrientable.
 
102
   **/
 
103
  g_object_class_install_property (gobject_class,
 
104
                                   PROP_ORIENTATION,
 
105
                                   g_param_spec_enum ("orientation",
 
106
                                                      "Orientation",
 
107
                                                      "Orientation of the box",
 
108
                                                      GTK_TYPE_ORIENTATION,
 
109
                                                      GTK_ORIENTATION_HORIZONTAL,
 
110
                                                      G_PARAM_READWRITE
 
111
                                                      | G_PARAM_STATIC_STRINGS));
 
112
#endif
 
113
}
 
114
 
 
115
 
 
116
 
 
117
static void
 
118
xfce_hvbox_init (XfceHVBox *hvbox)
 
119
{
 
120
  /* initialize variables */
 
121
  hvbox->orientation = GTK_ORIENTATION_HORIZONTAL;
 
122
}
 
123
 
 
124
 
 
125
 
 
126
#if !GTK_CHECK_VERSION (2, 16, 0)
 
127
static void
 
128
xfce_hvbox_get_property (GObject    *object,
 
129
                         guint       prop_id,
 
130
                         GValue     *value,
 
131
                         GParamSpec *pspec)
 
132
{
 
133
  XfceHVBox *hvbox = XFCE_HVBOX (object);
 
134
 
 
135
  switch (prop_id)
 
136
    {
 
137
    case PROP_ORIENTATION:
 
138
      g_value_set_enum (value, hvbox->orientation);
 
139
      break;
 
140
 
 
141
    default:
 
142
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
143
      break;
 
144
    }
 
145
}
 
146
 
 
147
 
 
148
 
 
149
static void
 
150
xfce_hvbox_set_property (GObject      *object,
 
151
                         guint         prop_id,
 
152
                         const GValue *value,
 
153
                         GParamSpec   *pspec)
 
154
{
 
155
  XfceHVBox *hvbox = XFCE_HVBOX (object);
 
156
 
 
157
  switch (prop_id)
 
158
    {
 
159
    case PROP_ORIENTATION:
 
160
      xfce_hvbox_set_orientation (hvbox, g_value_get_enum (value));
 
161
      break;
 
162
 
 
163
    default:
 
164
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
165
      break;
 
166
    }
75
167
}
76
168
 
77
169
 
79
171
static gpointer
80
172
xfce_hvbox_get_class (XfceHVBox *hvbox)
81
173
{
82
 
    GType    type;
83
 
    gpointer klass;
84
 
 
85
 
    if (hvbox->orientation == GTK_ORIENTATION_HORIZONTAL)
86
 
        type = GTK_TYPE_HBOX;
87
 
    else
88
 
        type = GTK_TYPE_VBOX;
89
 
 
90
 
    /* peek the class, this only works if the class already exists */
91
 
    klass = g_type_class_peek (type);
92
 
  
93
 
    /* return the type or create the class */
94
 
    return klass ? klass : g_type_class_ref (type);
 
174
  GType    type;
 
175
  gpointer klass;
 
176
 
 
177
  if (hvbox->orientation == GTK_ORIENTATION_HORIZONTAL)
 
178
    type = GTK_TYPE_HBOX;
 
179
  else
 
180
    type = GTK_TYPE_VBOX;
 
181
 
 
182
  /* peek the class, this only works if the class already exists */
 
183
  klass = g_type_class_peek (type);
 
184
 
 
185
  /* return the type or create the class */
 
186
  return klass ? klass : g_type_class_ref (type);
95
187
}
96
188
 
97
189
 
100
192
xfce_hvbox_size_request (GtkWidget      *widget,
101
193
                         GtkRequisition *requisition)
102
194
{
103
 
    gpointer klass;
104
 
 
105
 
    /* get the widget class */
106
 
    klass = xfce_hvbox_get_class (XFCE_HVBOX (widget));
107
 
  
108
 
    /* request the size */
109
 
    (*GTK_WIDGET_CLASS (klass)->size_request) (widget, requisition);
 
195
  gpointer klass;
 
196
 
 
197
  /* get the widget class */
 
198
  klass = xfce_hvbox_get_class (XFCE_HVBOX (widget));
 
199
 
 
200
  /* request the size */
 
201
  (*GTK_WIDGET_CLASS (klass)->size_request) (widget, requisition);
110
202
}
111
203
 
112
204
 
115
207
xfce_hvbox_size_allocate (GtkWidget     *widget,
116
208
                          GtkAllocation *allocation)
117
209
{
118
 
    gpointer klass;
119
 
 
120
 
    /* get the widget class */
121
 
    klass = xfce_hvbox_get_class (XFCE_HVBOX (widget));
122
 
 
123
 
    /* allocate the size */
124
 
    (*GTK_WIDGET_CLASS (klass)->size_allocate) (widget, allocation);
 
210
  gpointer klass;
 
211
 
 
212
  /* get the widget class */
 
213
  klass = xfce_hvbox_get_class (XFCE_HVBOX (widget));
 
214
 
 
215
  /* allocate the size */
 
216
  (*GTK_WIDGET_CLASS (klass)->size_allocate) (widget, allocation);
125
217
}
 
218
#endif
126
219
 
127
220
 
128
221
 
134
227
 *
135
228
 * Creates a new #XfceHVBox container widget.
136
229
 *
137
 
 * Return value: the newly allocated #XfceHVBox container widget.
 
230
 * Returns: the newly allocated #XfceHVBox container widget.
138
231
 **/
139
232
GtkWidget *
140
233
xfce_hvbox_new (GtkOrientation orientation,
141
234
                gboolean       homogeneous,
142
235
                gint           spacing)
143
236
{
144
 
    GtkWidget *box;
145
 
 
146
 
    box = g_object_new (XFCE_TYPE_HVBOX,
147
 
                        "homogeneous", homogeneous,
148
 
                        "spacing", spacing,
149
 
                        NULL);
150
 
 
151
 
    XFCE_HVBOX (box)->orientation = orientation;
152
 
 
153
 
    return box;
 
237
  XfceHVBox *box;
 
238
 
 
239
  /* create new object */
 
240
  box = g_object_new (XFCE_TYPE_HVBOX,
 
241
#if GTK_CHECK_VERSION (2, 16, 0)
 
242
                      "orientation", orientation,
 
243
#endif
 
244
                      "homogeneous", homogeneous,
 
245
                      "spacing", spacing, NULL);
 
246
 
 
247
  /* store the orientation */
 
248
  box->orientation = orientation;
 
249
 
 
250
  return GTK_WIDGET (box);
154
251
}
155
252
 
156
253
 
166
263
xfce_hvbox_set_orientation (XfceHVBox      *hvbox,
167
264
                            GtkOrientation  orientation)
168
265
{
169
 
    _panel_return_if_fail (XFCE_IS_HVBOX (hvbox));
170
 
 
171
 
    if (G_UNLIKELY (hvbox->orientation == orientation))
172
 
        return;
173
 
 
174
 
    hvbox->orientation = orientation;
175
 
 
176
 
    gtk_widget_queue_resize (GTK_WIDGET (hvbox));
 
266
  g_return_if_fail (XFCE_IS_HVBOX (hvbox));
 
267
 
 
268
  if (G_LIKELY (hvbox->orientation != orientation))
 
269
    {
 
270
      /* store new orientation */
 
271
      hvbox->orientation = orientation;
 
272
 
 
273
#if GTK_CHECK_VERSION (2, 16, 0)
 
274
      gtk_orientable_set_orientation (GTK_ORIENTABLE (hvbox), orientation);
 
275
#else
 
276
      gtk_widget_queue_resize (GTK_WIDGET (hvbox));
 
277
#endif
 
278
    }
 
279
}
 
280
 
 
281
 
 
282
 
 
283
/**
 
284
 * xfce_hvbox_get_orientation:
 
285
 * @hvbox       : #XfceHVBox
 
286
 *
 
287
 * Get the current orientation of the @hvbox.
 
288
 *
 
289
 * Returns: the current orientation of the #XfceHVBox.
 
290
 **/
 
291
GtkOrientation
 
292
xfce_hvbox_get_orientation (XfceHVBox *hvbox)
 
293
{
 
294
  g_return_val_if_fail (XFCE_IS_HVBOX (hvbox), GTK_ORIENTATION_HORIZONTAL);
 
295
 
 
296
#if GTK_CHECK_VERSION (2, 16, 0)
 
297
  return gtk_orientable_get_orientation (GTK_ORIENTABLE (hvbox));
 
298
#else
 
299
  return hvbox->orientation;
 
300
#endif
177
301
}
178
302
 
179
303
 
180
304
 
181
305
#define __XFCE_HVBOX_C__
182
306
#include <libxfce4panel/libxfce4panel-aliasdef.c>
183