~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to gnome-panel/panel-menu-bar.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Sebastien Bacher, Jeremy Bicha
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.13.10 upstream) (2.2.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110530110449-hinl17kxkcefjw6x
Tags: 1:3.0.2-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in:
  - the new libgweather version is in oneiric, use it
  - drop the python and python-gconf depends, 
    they were added for gnome-panel-add which is still using gconf and buggy
* debian/gnome-panel-data.install:
  - don't install the apport hook, it's only getting gconf datas which 
    doesn't work since gnome-panel uses gsettings
* debian/patches/90_build_fixes.patch:
  - restore build fix from git not applied in the new serie
* debian/patches/01_panel_submenus.patch:
  - don't take that Debian diff, the .menus use the upstream naming in Ubuntu
* debian/patches/06_no_resize_grip.patch:
  - dropped, the issue is fixed in the new version
* debian/patches/50_fix-potfiles.patch:
  - dropped, the issue is fixed in the new version
* debian/watch:
  - track unstable series as well

Drop those delta, since gnome-panel is not the default Ubuntu session now we
can go back to an experience closer to the upstream one: 
* debian/control.in:
  - drop the indicators recommends, unity-2d is the ubuntu fallback session
    so we can get back to use an upstream config for gnome-panel and reduce
    the delta we carry
* debian/patches/04_default_panel_config.patch:
  - don't modify the upstream layout
* debian/patches/05_no_session_delay.patch:
  - no need to tweak the upstream session to optimize it
* debian/patches/16_compiz_workspace_switcher.patch:
  - go back to the upstream switcher behaviour    
* debian/patches/25_dynamic_fusa_detection.patch:
  - not needed since we use the upstream layout, could be ported if someone
    is wanting to do the work though
* debian/patches/30_disable-initial-animation.patch, debian/rules:
  - drop the --disable-initial-animation, that was some login optimization
    but since it's not the default desktop you should go back to the 
    upstream behaviour

[ Jeremy Bicha ]   
* New upstream version
* Merge from Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Recommends gnome-settings-daemon which has the timezone polkit service
* debian/rules:
  - Update translations template.
* debian/gnome-panel-data.install:
  - Install apport hook
  - Install the "About Ubuntu" menu item.
* debian/patches/01_layout.patch:
  - Disabled, Help & About Ubuntu don't fit as well in Gnome Panel 3
* debian/patches/01_panel_submenus.patch.
  - Dropped
* debian/patches/03_dnd_places_link.patch:
  - Disabled, when using Drag'n'Drop from Places menu, install a link launcher
    (.desktop file) instead of copying the entire directory.
* debian/patches/17_about-ubuntu-translation.patch:
  - List ubuntu-about.desktop for translation.
* debian/patches/40_unset_menuproxy.patch:
  - Make sure gnome-panel and the applets don't pick up menu proxies.
* debian/patches/50_fix-potfiles.patch
  - Fix i18n
* debian/patches/85_disable_shutdown_on_ltsp.patch:
  - Suppress the shutdown option in the panel if LTSP_CLIENT is set.
* debian/patches/71_change_bookmark_submenu_limit_value.patch
  - Dropped, picked up by Debian
* debian/patches/18_lockdown_lock_editor.patch:
* debian/patches/90_git_wnck_show_realize.patch:
* debian/patches/90_fix_linking_DSO_link.patch:
* debian/patches/91_gir_annotations.patch
* debian/patches/92_git_calendar_day.patch
* debian/patches/92_git_fix_applets_in_multiscreen.patch:
  - Dropped, applied upstream
* debian/watch:
  - watch unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <libpanel-util/panel-launch.h>
36
36
#include <libpanel-util/panel-show.h>
37
37
 
38
 
#include "panel-util.h"
39
 
#include "panel-background.h"
40
 
#include "panel-action-button.h"
41
38
#include "applet.h"
42
39
#include "menu.h"
43
 
#include "panel-menu-items.h"
44
 
#include "panel-globals.h"
45
 
#include "panel-profile.h"
 
40
#include "panel-layout.h"
46
41
#include "panel-lockdown.h"
47
 
#include "panel-stock-icons.h"
48
 
#include "panel-typebuiltins.h"
49
42
#include "panel-icon-names.h"
50
 
#include "applet-signaler.h"
 
43
#include "panel-menu-bar-object.h"
 
44
#include "panel-menu-items.h"
 
45
#include "panel-util.h"
51
46
 
52
 
G_DEFINE_TYPE (PanelMenuBar, panel_menu_bar, GTK_TYPE_MENU_BAR)
 
47
G_DEFINE_TYPE (PanelMenuBar, panel_menu_bar, PANEL_TYPE_MENU_BAR_OBJECT)
53
48
 
54
49
#define PANEL_MENU_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_MENU_BAR, PanelMenuBarPrivate))
55
50
 
57
52
        AppletInfo  *info;
58
53
        PanelWidget *panel;
59
54
 
 
55
        GtkWidget   *image;
60
56
        GtkWidget   *applications_menu;
61
57
        GtkWidget   *applications_item;
62
58
        GtkWidget   *places_item;
63
 
        GtkWidget   *desktop_item;
64
 
 
65
 
        PanelOrientation orientation;
66
 
};
67
 
 
68
 
enum {
69
 
        PROP_0,
70
 
        PROP_ORIENTATION,
71
 
};
72
 
 
73
 
static void panel_menu_bar_update_text_gravity (PanelMenuBar *menubar);
 
59
};
 
60
 
 
61
/* themeable size - "panel-foobar" -- This is only used for the icon of the
 
62
 * Applications item in the menu bar */
 
63
#define PANEL_DEFAULT_MENU_BAR_ICON_SIZE       24
 
64
 
 
65
static GtkIconSize panel_menu_bar_icon_size = 0;
 
66
 
 
67
static GtkIconSize
 
68
panel_menu_bar_icon_get_size (void)
 
69
{
 
70
        return panel_menu_bar_icon_size;
 
71
}
74
72
 
75
73
static gboolean
76
74
panel_menu_bar_reinit_tooltip (GtkWidget    *widget,
80
78
                      "has-tooltip", TRUE, NULL);
81
79
        g_object_set (menubar->priv->places_item,
82
80
                      "has-tooltip", TRUE, NULL);
83
 
        g_object_set (menubar->priv->desktop_item,
84
 
                      "has-tooltip", TRUE, NULL);
85
81
 
86
82
        return FALSE;
87
83
}
100
96
        return FALSE;
101
97
}
102
98
 
103
 
#define FUSA_APPLET_IID "OAFIID:GNOME_FastUserSwitchApplet"
104
 
#define INDICATOR_APPLET_COMPLETE_IID "OAFIID:GNOME_IndicatorAppletComplete"
105
 
 
106
 
static void
107
 
panel_menu_bar_set_tooltip_remove (PanelAppletSignaler * pas, AppletInfo * info, GtkWidget * widget)
108
 
{
109
 
        const char * iid = panel_applet_get_iid(info);
110
 
        if (iid == NULL)
111
 
                return;
112
 
 
113
 
        if (g_strcmp0(iid, FUSA_APPLET_IID) == 0 ||
114
 
                g_strcmp0(iid, INDICATOR_APPLET_COMPLETE_IID) == 0)
115
 
                panel_util_set_tooltip_text (widget,
116
 
                                                 _("Change desktop appearance and behavior, get help, or log out"));
117
 
 
118
 
        return;
119
 
}
120
 
 
121
 
static void
122
 
panel_menu_bar_set_tooltip_add (PanelAppletSignaler * pas, AppletInfo * info, GtkWidget * widget)
123
 
{
124
 
        const char * iid = panel_applet_get_iid(info);
125
 
        if (iid == NULL)
126
 
                return;
127
 
 
128
 
        if (g_strcmp0(iid, FUSA_APPLET_IID) == 0 ||
129
 
                g_strcmp0(iid, INDICATOR_APPLET_COMPLETE_IID) == 0)
130
 
                panel_util_set_tooltip_text (widget,
131
 
                                                 _("Change system appearance and behavior, or get help"));
132
 
 
133
 
        return;
134
 
}
135
 
 
136
 
static void
137
 
disconnect_signalers (PanelAppletSignaler *signaler,
138
 
                      GtkWidget           *widget)
139
 
{
140
 
  g_signal_handlers_disconnect_by_func (signaler,
141
 
                                        panel_menu_bar_set_tooltip_add,
142
 
                                        widget);
143
 
  g_signal_handlers_disconnect_by_func (signaler,
144
 
                                        panel_menu_bar_set_tooltip_remove,
145
 
                                        widget);
146
 
}
147
 
 
148
99
static void
149
100
panel_menu_bar_setup_tooltip (PanelMenuBar *menubar)
150
101
{
151
 
        PanelAppletSignaler *signaler = panel_applet_signaler_get_default ();
152
 
 
153
102
        panel_util_set_tooltip_text (menubar->priv->applications_item,
154
103
                                     _("Browse and run installed applications"));
155
104
        panel_util_set_tooltip_text (menubar->priv->places_item,
156
105
                                     _("Access documents, folders and network places"));
157
 
        panel_util_set_tooltip_text (menubar->priv->desktop_item,
158
 
                                     _("Change desktop appearance and behavior, get help, or log out"));
159
 
 
160
 
        g_object_weak_ref (G_OBJECT (menubar->priv->desktop_item),
161
 
                           (GWeakNotify) disconnect_signalers,
162
 
                           signaler);
163
 
 
164
 
        g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_ADDED,
165
 
                         G_CALLBACK(panel_menu_bar_set_tooltip_add), menubar->priv->desktop_item);
166
 
        g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_REMOVED,
167
 
                         G_CALLBACK(panel_menu_bar_set_tooltip_remove), menubar->priv->desktop_item);
168
 
 
169
106
 
170
107
        //FIXME: this doesn't handle the right-click case. Sigh.
171
108
        /* Hide tooltip if a menu is activated */
177
114
                          "activate",
178
115
                          G_CALLBACK (panel_menu_bar_hide_tooltip_and_focus),
179
116
                          menubar);
180
 
        g_signal_connect (menubar->priv->desktop_item,
181
 
                          "activate",
182
 
                          G_CALLBACK (panel_menu_bar_hide_tooltip_and_focus),
183
 
                          menubar);
184
117
 
185
118
        /* Reset tooltip when the menu bar is not used */
186
119
        g_signal_connect (GTK_MENU_SHELL (menubar),
192
125
static void
193
126
panel_menu_bar_init (PanelMenuBar *menubar)
194
127
{
195
 
        GtkWidget *image;
196
 
 
197
128
        menubar->priv = PANEL_MENU_BAR_GET_PRIVATE (menubar);
198
129
 
199
130
        menubar->priv->info = NULL;
203
134
        menubar->priv->applications_item = panel_image_menu_item_new ();
204
135
        gtk_menu_item_set_label (GTK_MENU_ITEM (menubar->priv->applications_item),
205
136
                                 _("Applications"));
206
 
        image = gtk_image_new_from_icon_name (PANEL_ICON_MAIN_MENU,
207
 
                                              panel_menu_bar_icon_get_size ());
208
 
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item),
209
 
                                       image);
 
137
        menubar->priv->image = gtk_image_new_from_icon_name (PANEL_ICON_MAIN_MENU,
 
138
                                                             panel_menu_bar_icon_get_size ());
210
139
 
211
140
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar->priv->applications_item),
212
141
                                   menubar->priv->applications_menu);
213
142
        gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
214
143
                               menubar->priv->applications_item);
 
144
        gtk_widget_show (menubar->priv->applications_item);
215
145
 
216
146
        menubar->priv->places_item = panel_place_menu_item_new (FALSE);
217
147
        gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
218
148
                               menubar->priv->places_item);
219
 
 
220
 
        menubar->priv->desktop_item = panel_desktop_menu_item_new (FALSE, TRUE);
221
 
        gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
222
 
                               menubar->priv->desktop_item);
 
149
        gtk_widget_show (menubar->priv->places_item);
223
150
 
224
151
        panel_menu_bar_setup_tooltip (menubar);
225
 
 
226
 
        panel_menu_bar_update_text_gravity (menubar);
227
 
        g_signal_connect (menubar, "screen-changed",
228
 
                          G_CALLBACK (panel_menu_bar_update_text_gravity),
229
 
                          NULL);
230
 
}
231
 
 
232
 
static void
233
 
panel_menu_bar_get_property (GObject    *object,
234
 
                             guint       prop_id,
235
 
                             GValue     *value,
236
 
                             GParamSpec *pspec)
237
 
{
238
 
        PanelMenuBar *menubar;
239
 
 
240
 
        g_return_if_fail (PANEL_IS_MENU_BAR (object));
241
 
 
242
 
        menubar = PANEL_MENU_BAR (object);
243
 
 
244
 
        switch (prop_id) {
245
 
        case PROP_ORIENTATION:
246
 
                g_value_set_enum (value, menubar->priv->orientation);
247
 
                break;
248
 
        default:
249
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
250
 
                break;
251
 
        }
252
 
}
253
 
 
254
 
static void
255
 
panel_menu_bar_set_property (GObject      *object,
256
 
                             guint         prop_id,
257
 
                             const GValue *value,
258
 
                             GParamSpec   *pspec)
259
 
{
260
 
        PanelMenuBar *menubar;
261
 
 
262
 
        g_return_if_fail (PANEL_IS_MENU_BAR (object));
263
 
 
264
 
        menubar = PANEL_MENU_BAR (object);
265
 
 
266
 
        switch (prop_id) {
267
 
        case PROP_ORIENTATION:
268
 
                panel_menu_bar_set_orientation (menubar, g_value_get_enum (value));
269
 
                break;
270
 
        default:
271
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
272
 
                break;
273
 
        }
274
152
}
275
153
 
276
154
static void
292
170
        if (menubar->priv->places_item)
293
171
                panel_place_menu_item_set_panel (menubar->priv->places_item,
294
172
                                                 menubar->priv->panel);
295
 
        if (menubar->priv->desktop_item)
296
 
                panel_desktop_menu_item_set_panel (menubar->priv->desktop_item,
297
 
                                                   menubar->priv->panel);
298
173
}
299
174
 
300
175
static void
301
 
panel_menu_bar_size_allocate (GtkWidget     *widget,
302
 
                              GtkAllocation *allocation)
 
176
panel_menu_bar_style_updated (GtkWidget *widget)
303
177
{
304
 
        GtkAllocation    old_allocation;
305
 
        GtkAllocation    widget_allocation;
306
 
        PanelBackground *background;
307
 
 
308
 
        gtk_widget_get_allocation (widget, &widget_allocation);
309
 
 
310
 
        old_allocation.x      = widget_allocation.x;
311
 
        old_allocation.y      = widget_allocation.y;
312
 
        old_allocation.width  = widget_allocation.width;
313
 
        old_allocation.height = widget_allocation.height;
314
 
 
315
 
        GTK_WIDGET_CLASS (panel_menu_bar_parent_class)->size_allocate (widget, allocation);
316
 
 
317
 
        if (old_allocation.x      == allocation->x &&
318
 
            old_allocation.y      == allocation->y &&
319
 
            old_allocation.width  == allocation->width &&
320
 
            old_allocation.height == allocation->height)
321
 
                return;
322
 
 
323
 
        background = &PANEL_MENU_BAR (widget)->priv->panel->background;
324
 
 
325
 
        if (background->type == PANEL_BACK_NONE ||
326
 
           (background->type == PANEL_BACK_COLOR && !background->has_alpha))
327
 
                return;
328
 
 
329
 
        panel_menu_bar_change_background (PANEL_MENU_BAR (widget));
 
178
        PanelMenuBar *menubar = PANEL_MENU_BAR (widget);
 
179
        gboolean      visible;
 
180
 
 
181
        GTK_WIDGET_CLASS (panel_menu_bar_parent_class)->style_updated (widget);
 
182
 
 
183
        gtk_widget_style_get (widget, "icon-visible", &visible, NULL);
 
184
 
 
185
        if (visible)
 
186
                gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item),
 
187
                                               menubar->priv->image);
 
188
        else
 
189
                gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item),
 
190
                                               NULL);
330
191
}
331
192
 
332
193
static void
333
194
panel_menu_bar_class_init (PanelMenuBarClass *klass)
334
195
{
335
 
        GObjectClass   *gobject_class = (GObjectClass   *) klass;
336
196
        GtkWidgetClass *widget_class  = (GtkWidgetClass *) klass;
337
197
 
338
 
        gobject_class->get_property = panel_menu_bar_get_property;
339
 
        gobject_class->set_property = panel_menu_bar_set_property;
340
 
 
341
198
        widget_class->parent_set = panel_menu_bar_parent_set;
342
 
        widget_class->size_allocate = panel_menu_bar_size_allocate;
 
199
        widget_class->style_updated = panel_menu_bar_style_updated;
343
200
 
344
201
        g_type_class_add_private (klass, sizeof (PanelMenuBarPrivate));
345
202
 
346
 
        g_object_class_install_property (
347
 
                gobject_class,
348
 
                PROP_ORIENTATION,
349
 
                g_param_spec_enum ("orientation",
350
 
                                   "Orientation",
351
 
                                   "The PanelMenuBar orientation",
352
 
                                   PANEL_TYPE_ORIENTATION,
353
 
                                   PANEL_ORIENTATION_TOP,
354
 
                                   G_PARAM_READWRITE));
355
 
 
356
 
        gtk_rc_parse_string (
357
 
                "style \"panel-menubar-style\"\n"
358
 
                "{\n"
359
 
                "  GtkMenuBar::shadow-type = none\n"
360
 
                "  GtkMenuBar::internal-padding = 0\n"
361
 
                "}\n"
362
 
                "class \"PanelMenuBar\" style \"panel-menubar-style\"");
363
 
}
364
 
 
365
 
static gboolean
366
 
panel_menu_bar_on_expose (GtkWidget      *widget,
367
 
                          GdkEventExpose *event,
368
 
                          gpointer        data)
369
 
{
370
 
        PanelMenuBar *menubar = data;
371
 
 
372
 
        if (gtk_widget_has_focus (GTK_WIDGET (menubar)))
373
 
                gtk_paint_focus (gtk_widget_get_style (widget),
374
 
                                 gtk_widget_get_window (widget),
375
 
                                 gtk_widget_get_state (GTK_WIDGET (menubar)),
376
 
                                 NULL,
377
 
                                 widget,
378
 
                                 "menubar-applet",
379
 
                                 0, 0, -1, -1);
380
 
        return FALSE;
381
 
}
382
 
 
383
 
static void
 
203
        gtk_widget_class_install_style_property (
 
204
                widget_class,
 
205
                g_param_spec_boolean ("icon-visible",
 
206
                                      "Icon visible",
 
207
                                      "Whether the menubar icon is visible",
 
208
                                      FALSE,
 
209
                                      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
210
 
 
211
        if (panel_menu_bar_icon_size == 0)
 
212
                panel_menu_bar_icon_size = gtk_icon_size_register ("panel-foobar",
 
213
                                                                   PANEL_DEFAULT_MENU_BAR_ICON_SIZE,
 
214
                                                                   PANEL_DEFAULT_MENU_BAR_ICON_SIZE);
 
215
}
 
216
 
 
217
void
384
218
panel_menu_bar_load (PanelWidget *panel,
385
 
                     gboolean     locked,
386
 
                     int          position,
387
 
                     gboolean     exactpos,
388
 
                     const char  *id)
 
219
                     const char  *id,
 
220
                     GSettings   *settings)
389
221
{
390
222
        PanelMenuBar *menubar;
391
223
 
394
226
        menubar = g_object_new (PANEL_TYPE_MENU_BAR, NULL);
395
227
 
396
228
        menubar->priv->info = panel_applet_register (
397
 
                                        GTK_WIDGET (menubar), NULL, NULL,
398
 
                                        panel, locked, position, exactpos,
399
 
                                        PANEL_OBJECT_MENU_BAR, id);
 
229
                                        GTK_WIDGET (menubar), panel,
 
230
                                        PANEL_OBJECT_MENU_BAR, id,
 
231
                                        settings,
 
232
                                        NULL, NULL);
400
233
        if (!menubar->priv->info) {
401
234
                gtk_widget_destroy (GTK_WIDGET (menubar));
402
235
                return;
403
236
        }
404
237
 
 
238
        if (panel_is_program_in_path ("alacarte") ||
 
239
            panel_is_program_in_path ("gmenu-simple-editor")) {
 
240
                panel_applet_add_callback (menubar->priv->info,
 
241
                                           "edit",
 
242
                                           NULL,
 
243
                                           _("_Edit Menus"),
 
244
                                           panel_lockdown_get_not_panels_locked_down_s);
 
245
        }
 
246
 
405
247
        panel_applet_add_callback (menubar->priv->info,
406
248
                                   "help",
407
249
                                   GTK_STOCK_HELP,
408
250
                                   _("_Help"),
409
251
                                   NULL);
410
252
 
411
 
        if (!panel_lockdown_get_locked_down () && 
412
 
            (panel_is_program_in_path ("alacarte") ||
413
 
            panel_is_program_in_path ("gmenu-simple-editor"))) {
414
 
                panel_applet_add_callback (menubar->priv->info,
415
 
                                           "edit",
416
 
                                           NULL,
417
 
                                           _("_Edit Menus"),
418
 
                                           NULL);
419
 
        }
420
 
 
421
 
        g_signal_connect_after (menubar, "focus-in-event",
422
 
                                G_CALLBACK (gtk_widget_queue_draw), menubar);
423
 
        g_signal_connect_after (menubar, "focus-out-event",
424
 
                                G_CALLBACK (gtk_widget_queue_draw), menubar);
425
 
        g_signal_connect_after (menubar, "expose-event",
426
 
                                G_CALLBACK (panel_menu_bar_on_expose), menubar);
427
 
        gtk_widget_set_can_focus (GTK_WIDGET (menubar), TRUE);
428
 
 
429
 
        panel_widget_set_applet_expandable (panel, GTK_WIDGET (menubar), FALSE, TRUE);
430
 
}
431
 
 
432
 
void
433
 
panel_menu_bar_load_from_gconf (PanelWidget *panel,
434
 
                                gboolean     locked,
435
 
                                int          position,
436
 
                                gboolean     exactpos,
437
 
                                const char  *id)
438
 
{
439
 
        panel_menu_bar_load (panel, locked, position, exactpos, id);
440
 
}
441
 
 
442
 
void
443
 
panel_menu_bar_create (PanelToplevel *toplevel,
444
 
                       int            position)
445
 
{
446
 
        char *id;
447
 
 
448
 
        id = panel_profile_prepare_object (PANEL_OBJECT_MENU_BAR, toplevel, position, FALSE);
449
 
        panel_profile_add_to_list (PANEL_GCONF_OBJECTS, id);
450
 
        g_free (id);
 
253
        panel_menu_bar_object_object_load_finish (PANEL_MENU_BAR_OBJECT (menubar),
 
254
                                                  panel);
 
255
}
 
256
 
 
257
void
 
258
panel_menu_bar_create (PanelToplevel       *toplevel,
 
259
                       PanelObjectPackType  pack_type,
 
260
                       int                  pack_index)
 
261
{
 
262
        panel_layout_object_create (PANEL_OBJECT_MENU_BAR, NULL,
 
263
                                    panel_toplevel_get_id (toplevel),
 
264
                                    pack_type, pack_index);
451
265
}
452
266
 
453
267
void
484
298
panel_menu_bar_popup_menu (PanelMenuBar *menubar,
485
299
                           guint32       activate_time)
486
300
{
487
 
        GtkMenu *menu;
488
 
        GtkMenuShell *menu_shell;
489
 
        
490
301
        g_return_if_fail (PANEL_IS_MENU_BAR (menubar));
491
302
 
492
 
        menu = GTK_MENU (menubar->priv->applications_menu);
493
 
 
494
 
        /* 
495
 
         * We need to call _gtk_menu_shell_activate() here as is done in 
496
 
         * window_key_press_handler in gtkmenubar.c which pops up menu
497
 
         * when F10 is pressed.
498
 
         *
499
 
         * As that function is private its code is replicated here.
500
 
         */
501
 
        menu_shell = GTK_MENU_SHELL (menubar);
502
 
        if (!menu_shell->active) {
503
 
                gtk_grab_add (GTK_WIDGET (menu_shell));
504
 
                menu_shell->have_grab = TRUE;
505
 
                menu_shell->active = TRUE;
506
 
        }
507
 
        gtk_menu_shell_select_item (menu_shell,
508
 
                                    gtk_menu_get_attach_widget (menu));
509
 
}
510
 
 
511
 
void
512
 
panel_menu_bar_change_background (PanelMenuBar *menubar)
513
 
{
514
 
        panel_background_change_background_on_widget (&menubar->priv->panel->background,
515
 
                                                      GTK_WIDGET (menubar));
516
 
}
517
 
 
518
 
static void
519
 
set_item_text_gravity (GtkWidget *item)
520
 
{
521
 
        GtkWidget    *label;
522
 
        PangoLayout  *layout;
523
 
        PangoContext *context;
524
 
 
525
 
        label = gtk_bin_get_child (GTK_BIN (item));
526
 
        layout = gtk_label_get_layout (GTK_LABEL (label));
527
 
        context = pango_layout_get_context (layout);
528
 
        pango_context_set_base_gravity (context, PANGO_GRAVITY_AUTO);
529
 
}
530
 
 
531
 
static void
532
 
panel_menu_bar_update_text_gravity (PanelMenuBar *menubar)
533
 
{
534
 
        set_item_text_gravity (menubar->priv->applications_item);
535
 
        set_item_text_gravity (menubar->priv->places_item);
536
 
        set_item_text_gravity (menubar->priv->desktop_item);
537
 
}
538
 
 
539
 
static void
540
 
set_item_text_angle_and_alignment (GtkWidget *item,
541
 
                                   double     text_angle,
542
 
                                   float      xalign,
543
 
                                   float      yalign)
544
 
{
545
 
        GtkWidget *label;
546
 
 
547
 
        label = gtk_bin_get_child (GTK_BIN (item));
548
 
 
549
 
        gtk_label_set_angle (GTK_LABEL (label), text_angle);
550
 
 
551
 
        gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
552
 
}
553
 
 
554
 
static void
555
 
panel_menu_bar_update_orientation (PanelMenuBar *menubar)
556
 
{
557
 
        GtkPackDirection pack_direction;
558
 
        double           text_angle;
559
 
        float            text_xalign;
560
 
        float            text_yalign;
561
 
 
562
 
        pack_direction = GTK_PACK_DIRECTION_LTR;
563
 
        text_angle = 0.0;
564
 
        text_xalign = 0.0;
565
 
        text_yalign = 0.5;
566
 
 
567
 
        switch (menubar->priv->orientation) {
568
 
        case PANEL_ORIENTATION_TOP:
569
 
        case PANEL_ORIENTATION_BOTTOM:
570
 
                break;
571
 
        case PANEL_ORIENTATION_LEFT:
572
 
                pack_direction = GTK_PACK_DIRECTION_BTT;
573
 
                text_angle = 90.0;
574
 
                text_xalign = 0.5;
575
 
                text_yalign = 0.0;
576
 
                break;
577
 
        case PANEL_ORIENTATION_RIGHT:
578
 
                pack_direction = GTK_PACK_DIRECTION_TTB;
579
 
                text_angle = 270.0;
580
 
                text_xalign = 0.5;
581
 
                text_yalign = 0.0;
582
 
                break;
583
 
        default:
584
 
                g_assert_not_reached ();
585
 
                break;
586
 
        }
587
 
 
588
 
        gtk_menu_bar_set_pack_direction (GTK_MENU_BAR (menubar), pack_direction);
589
 
        gtk_menu_bar_set_child_pack_direction (GTK_MENU_BAR (menubar), pack_direction);
590
 
 
591
 
        set_item_text_angle_and_alignment (menubar->priv->applications_item,
592
 
                                           text_angle,
593
 
                                           text_xalign,
594
 
                                           text_yalign);
595
 
        set_item_text_angle_and_alignment (menubar->priv->places_item,
596
 
                                           text_angle,
597
 
                                           text_xalign,
598
 
                                           text_yalign);
599
 
        set_item_text_angle_and_alignment (menubar->priv->desktop_item,
600
 
                                           text_angle,
601
 
                                           text_xalign,
602
 
                                           text_yalign);
603
 
}
604
 
 
605
 
void
606
 
panel_menu_bar_set_orientation (PanelMenuBar     *menubar,
607
 
                                PanelOrientation  orientation)
608
 
{
609
 
        g_return_if_fail (PANEL_IS_MENU_BAR (menubar));
610
 
 
611
 
        if (menubar->priv->orientation == orientation)
612
 
                return;
613
 
 
614
 
        menubar->priv->orientation = orientation;
615
 
 
616
 
        panel_menu_bar_update_orientation (menubar);
617
 
 
618
 
        g_object_notify (G_OBJECT (menubar), "orientation");
619
 
}
620
 
 
621
 
PanelOrientation
622
 
panel_menu_bar_get_orientation (PanelMenuBar *menubar)
623
 
{
624
 
        g_return_val_if_fail (PANEL_IS_MENU_BAR (menubar), 0);
625
 
 
626
 
        return menubar->priv->orientation;
 
303
        gtk_menu_shell_select_item (GTK_MENU_SHELL (menubar),
 
304
                                    menubar->priv->applications_item);
627
305
}