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

« back to all changes in this revision

Viewing changes to .pc/85_disable_shutdown_on_ltsp.patch/gnome-panel/panel-menu-items.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:
40
40
#include <glib/gi18n.h>
41
41
#include <gio/gio.h>
42
42
 
 
43
#ifdef HAVE_TELEPATHY_GLIB
 
44
#include <telepathy-glib/account-manager.h>
 
45
#endif
 
46
 
43
47
#include <libpanel-util/panel-error.h>
44
48
#include <libpanel-util/panel-glib.h>
45
49
#include <libpanel-util/panel-keyfile.h>
46
50
#include <libpanel-util/panel-launch.h>
 
51
#include <libpanel-util/panel-session-manager.h>
47
52
#include <libpanel-util/panel-show.h>
48
53
 
49
54
#include "menu.h"
50
55
#include "panel-action-button.h"
 
56
#include "panel-gconf.h"
51
57
#include "panel-globals.h"
52
58
#include "panel-icon-names.h"
53
59
#include "panel-lockdown.h"
54
60
#include "panel-recent.h"
55
61
#include "panel-stock-icons.h"
56
62
#include "panel-util.h"
57
 
#include "applet-signaler.h"
58
63
 
59
64
#define BOOKMARKS_FILENAME      ".gtk-bookmarks"
60
65
#define DESKTOP_IS_HOME_DIR_DIR "/apps/nautilus/preferences"
89
94
        gulong       mount_added_id;
90
95
        gulong       mount_changed_id;
91
96
        gulong       mount_removed_id;
92
 
 
93
 
        guint        use_image : 1;
94
97
};
95
98
 
96
99
struct _PanelDesktopMenuItemPrivate {
97
100
        GtkWidget   *menu;
98
101
        PanelWidget *panel;
99
102
 
100
 
        guint        use_image : 1;
101
 
        guint        append_lock_logout : 1;
 
103
#ifdef HAVE_TELEPATHY_GLIB
 
104
        GList            *presence_items;
 
105
        guint             presence_changed_id;
 
106
        TpAccountManager *account_manager;
 
107
#endif
102
108
};
103
109
 
 
110
#ifdef HAVE_TELEPATHY_GLIB
 
111
static void
 
112
panel_menu_item_activate_presence (GtkWidget        *menuitem,
 
113
                                   TpAccountManager *account_manager)
 
114
{
 
115
        PanelSessionManagerPresenceType  presence_type;
 
116
        TpConnectionPresenceType         tp_presence_type;
 
117
        const char                      *status;
 
118
        char                            *message;
 
119
 
 
120
        presence_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem),
 
121
                                                            "panel-menu-presence"));
 
122
 
 
123
        panel_session_manager_set_presence (panel_session_manager_get (),
 
124
                                            presence_type);
 
125
 
 
126
        tp_presence_type = tp_account_manager_get_most_available_presence (account_manager,
 
127
                                                                           NULL,
 
128
                                                                           &message);
 
129
 
 
130
        if (tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_UNSET ||
 
131
            tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE ||
 
132
            tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_UNKNOWN ||
 
133
            tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_ERROR)
 
134
                goto free_message;
 
135
 
 
136
        if (presence_type == PANEL_SESSION_MANAGER_PRESENCE_AVAILABLE) {
 
137
                tp_presence_type = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
 
138
                status = "available";
 
139
        } else if (presence_type == PANEL_SESSION_MANAGER_PRESENCE_BUSY) {
 
140
                tp_presence_type = TP_CONNECTION_PRESENCE_TYPE_BUSY;
 
141
                status = "busy";
 
142
        } else
 
143
                goto free_message;
 
144
 
 
145
        tp_account_manager_set_all_requested_presences (account_manager,
 
146
                                                        tp_presence_type,
 
147
                                                        status, message);
 
148
 
 
149
free_message:
 
150
        g_free (message);
 
151
}
 
152
 
 
153
static GtkWidget *
 
154
panel_menu_item_presence_new (TpAccountManager                *account_manager,
 
155
                              PanelSessionManagerPresenceType  presence_type,
 
156
                              const char                      *name,
 
157
                              const char                      *icon,
 
158
                              gboolean                         use_icon)
 
159
{
 
160
        GtkWidget *item;
 
161
 
 
162
        if (!account_manager)
 
163
                return NULL;
 
164
 
 
165
        item = gtk_check_menu_item_new ();
 
166
        setup_menuitem (item, GTK_ICON_SIZE_INVALID, NULL, name);
 
167
        gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
168
 
 
169
        /* TODO: we need to add an icon at the right of this CheckMenuItem */
 
170
#if 0
 
171
        if (use_icon) {
 
172
                GtkWidget *image;
 
173
                image = gtk_image_new_from_icon_name (icon,
 
174
                                                      panel_menu_icon_get_size ());
 
175
                gtk_container_add (GTK_CONTAINER (item), image);
 
176
        }
 
177
#endif
 
178
 
 
179
        g_object_set_data (G_OBJECT (item), "panel-menu-presence",
 
180
                           GINT_TO_POINTER (presence_type));
 
181
 
 
182
        g_signal_connect (item, "activate",
 
183
                          G_CALLBACK (panel_menu_item_activate_presence),
 
184
                          account_manager);
 
185
        g_signal_connect (G_OBJECT (item), "button_press_event",
 
186
                          G_CALLBACK (menu_dummy_button_press_event), NULL);
 
187
 
 
188
        return item;
 
189
}
 
190
#endif
 
191
 
104
192
static void
105
193
activate_uri_on_screen (const char *uri,
106
194
                        GdkScreen  *screen)
140
228
        activate_path (menuitem,
141
229
                       g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
142
230
}
143
 
 
144
 
static void
145
 
panel_menu_items_append_from_desktop (GtkWidget *menu,
146
 
                                      char      *path,
147
 
                                      char      *force_name,
148
 
                                      gboolean   use_icon)
 
231
 
 
232
static GtkWidget *
 
233
panel_menu_item_desktop_new (char      *path,
 
234
                             char      *force_name,
 
235
                             gboolean   use_icon)
149
236
{
150
237
        GKeyFile  *key_file;
151
238
        gboolean   loaded;
195
282
                g_key_file_free (key_file);
196
283
                if (path_freeme)
197
284
                        g_free (path_freeme);
198
 
                return;
 
285
                return NULL;
199
286
        }
200
287
 
201
288
        /* For Application desktop files, respect TryExec */
204
291
                g_key_file_free (key_file);
205
292
                if (path_freeme)
206
293
                        g_free (path_freeme);
207
 
                return;
 
294
                return NULL;
208
295
        }
209
296
        is_application = (strcmp (type, "Application") == 0);
210
297
        g_free (type);
225
312
                                g_key_file_free (key_file);
226
313
                                if (path_freeme)
227
314
                                        g_free (path_freeme);
228
 
                                return;
 
315
                                return NULL;
229
316
                        }
230
317
 
231
318
                        g_free (prog);
252
339
 
253
340
        panel_util_set_tooltip_text (item, comment);
254
341
 
255
 
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
256
342
        g_signal_connect_data (item, "activate",
257
343
                               G_CALLBACK (panel_menu_item_activate_desktop_file),
258
344
                               g_strdup (full_path),
262
348
 
263
349
        uri = g_filename_to_uri (full_path, NULL, NULL);
264
350
 
265
 
        setup_uri_drag (item, uri, icon, GDK_ACTION_COPY);
 
351
        setup_uri_drag (item, uri, icon);
266
352
        g_free (uri);
267
353
 
268
354
        g_key_file_free (key_file);
278
364
 
279
365
        if (path_freeme)
280
366
                g_free (path_freeme);
 
367
 
 
368
        return item;
281
369
}
282
370
 
283
 
static void
284
 
panel_menu_items_append_place_item (const char *icon_name,
285
 
                                    GIcon      *gicon,
286
 
                                    const char *title,
287
 
                                    const char *tooltip,
288
 
                                    GtkWidget  *menu,
289
 
                                    GCallback   callback,
290
 
                                    const char *uri)
 
371
static GtkWidget *
 
372
panel_menu_item_uri_new (const char *uri,
 
373
                         const char *icon_name,
 
374
                         GIcon      *gicon,
 
375
                         const char *title,
 
376
                         const char *tooltip,
 
377
                         GCallback   callback)
291
378
{
292
379
        GtkWidget *item;
293
380
        char      *user_data;
300
387
 
301
388
        panel_util_set_tooltip_text (item, tooltip);
302
389
 
303
 
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
304
 
 
305
390
        user_data = g_strdup (uri);
306
391
        g_signal_connect_data (item, "activate", callback, user_data,
307
392
                               (GClosureNotify) g_free, 0);
309
394
        g_signal_connect (G_OBJECT (item), "button_press_event",
310
395
                          G_CALLBACK (menu_dummy_button_press_event), NULL);
311
396
 
312
 
        if (g_str_has_prefix (uri, "file:")) /*Links only work for local files*/
313
 
                setup_uri_drag (item, uri, icon_name, GDK_ACTION_LINK);
 
397
        setup_uri_drag (item, uri, icon_name);
 
398
 
 
399
        return item;
314
400
}
315
401
 
316
402
static GtkWidget *
317
403
panel_menu_items_create_action_item_full (PanelActionButtonType  action_type,
318
404
                                          const char            *label,
319
 
                                          const char            *tooltip)
 
405
                                          const char            *tooltip,
 
406
                                          gboolean               create_even_if_disabled)
320
407
{
321
408
        GtkWidget *item;
322
409
 
323
 
        if (panel_action_get_is_disabled (action_type))
 
410
        if (!create_even_if_disabled && panel_action_get_is_disabled (action_type))
324
411
                return NULL;
325
412
 
326
413
        item = gtk_image_menu_item_new ();
348
435
panel_menu_items_create_action_item (PanelActionButtonType action_type)
349
436
{
350
437
        return panel_menu_items_create_action_item_full (action_type,
351
 
                                                         NULL, NULL);
 
438
                                                         NULL, NULL, FALSE);
 
439
}
 
440
 
 
441
#define GDM_FLEXISERVER_COMMAND "gdmflexiserver"
 
442
#define GDM_FLEXISERVER_ARGS    "--startnew"
 
443
 
 
444
static void
 
445
panel_menu_item_activate_switch_user (GtkWidget *menuitem,
 
446
                                      gpointer   user_data)
 
447
{
 
448
        GdkScreen *screen;
 
449
        GAppInfo  *app_info;
 
450
 
 
451
        if (panel_lockdown_get_disable_switch_user_s ())
 
452
                return;
 
453
 
 
454
        screen = gtk_widget_get_screen (GTK_WIDGET (menuitem));
 
455
        app_info = g_app_info_create_from_commandline (GDM_FLEXISERVER_COMMAND " " GDM_FLEXISERVER_ARGS,
 
456
                                                       GDM_FLEXISERVER_COMMAND,
 
457
                                                       G_APP_INFO_CREATE_NONE,
 
458
                                                       NULL);
 
459
 
 
460
        if (app_info) {
 
461
                GdkAppLaunchContext *launch_context;
 
462
                GdkDisplay          *display;
 
463
 
 
464
                display = gdk_screen_get_display (screen);
 
465
                launch_context = gdk_display_get_app_launch_context (display);
 
466
                gdk_app_launch_context_set_screen (launch_context, screen);
 
467
 
 
468
                g_app_info_launch (app_info, NULL,
 
469
                                   G_APP_LAUNCH_CONTEXT (launch_context),
 
470
                                   NULL);
 
471
 
 
472
                g_object_unref (launch_context);
 
473
                g_object_unref (app_info);
 
474
        }
 
475
}
 
476
 
 
477
static GtkWidget *
 
478
panel_menu_items_create_switch_user (gboolean use_icon)
 
479
{
 
480
        GtkWidget *item;
 
481
 
 
482
        if (use_icon) {
 
483
                item = panel_image_menu_item_new ();
 
484
        } else {
 
485
                item = gtk_image_menu_item_new ();
 
486
        }
 
487
 
 
488
        setup_menu_item_with_icon (item, panel_menu_icon_get_size (),
 
489
                                   NULL, NULL, NULL, _("Switch User"));
 
490
 
 
491
        g_signal_connect (item, "activate",
 
492
                          G_CALLBACK (panel_menu_item_activate_switch_user),
 
493
                          NULL);
 
494
        g_signal_connect (G_OBJECT (item), "button_press_event",
 
495
                          G_CALLBACK (menu_dummy_button_press_event), NULL);
 
496
 
 
497
        return item;
352
498
}
353
499
 
354
500
static void
487
633
                char *icon;
488
634
                GFile *file;
489
635
                GIcon *gicon;
 
636
                GtkWidget *menu_item;
490
637
 
491
638
                bookmark = l->data;
492
639
                
528
675
                gicon = g_themed_icon_new_with_default_fallbacks (icon);
529
676
 
530
677
                //FIXME: drag and drop will be broken for x-nautilus-search uris
531
 
                panel_menu_items_append_place_item (icon, gicon,
532
 
                                                    label,
533
 
                                                    tooltip,
534
 
                                                    add_menu,
535
 
                                                    G_CALLBACK (activate_uri),
536
 
                                                    bookmark->full_uri);
 
678
                menu_item = panel_menu_item_uri_new (bookmark->full_uri,
 
679
                                                     icon, gicon,
 
680
                                                     label,
 
681
                                                     tooltip,
 
682
                                                     G_CALLBACK (activate_uri));
 
683
                gtk_menu_shell_append (GTK_MENU_SHELL (add_menu), menu_item);
537
684
 
538
685
                g_free (icon);
539
686
                g_object_unref (gicon);
589
736
                                menuitem_to_screen (menuitem));
590
737
}
591
738
 
592
 
static void
593
 
panel_menu_item_append_drive (GtkWidget *menu,
594
 
                              GDrive    *drive)
 
739
static GtkWidget *
 
740
panel_menu_item_drive_new (GDrive *drive)
595
741
{
596
742
        GtkWidget *item;
597
743
        GIcon     *icon;
614
760
 
615
761
        g_free (title);
616
762
 
617
 
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
618
 
 
619
763
        g_signal_connect_data (item, "activate",
620
764
                               G_CALLBACK (panel_menu_item_rescan_drive),
621
765
                               g_object_ref (drive),
623
767
 
624
768
        g_signal_connect (G_OBJECT (item), "button_press_event",
625
769
                          G_CALLBACK (menu_dummy_button_press_event), NULL);
 
770
 
 
771
        return item;
626
772
}
627
773
 
628
774
typedef struct {
689
835
                        volume_mount_cb, mount_data);
690
836
}
691
837
 
692
 
static void
693
 
panel_menu_item_append_volume (GtkWidget *menu,
694
 
                               GVolume   *volume)
 
838
static GtkWidget *
 
839
panel_menu_item_volume_new (GVolume *volume)
695
840
{
696
841
        GtkWidget *item;
697
842
        GIcon     *icon;
714
859
 
715
860
        g_free (title);
716
861
 
717
 
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
718
 
 
719
862
        g_signal_connect_data (item, "activate",
720
863
                               G_CALLBACK (panel_menu_item_mount_volume),
721
864
                               g_object_ref (volume),
723
866
 
724
867
        g_signal_connect (G_OBJECT (item), "button_press_event",
725
868
                          G_CALLBACK (menu_dummy_button_press_event), NULL);
 
869
 
 
870
        return item;
726
871
}
727
872
 
728
 
static void
729
 
panel_menu_item_append_mount (GtkWidget *menu,
730
 
                              GMount    *mount)
 
873
static GtkWidget *
 
874
panel_menu_item_mount_new (GMount *mount)
731
875
{
732
 
        GFile  *root;
733
 
        GIcon  *icon;
734
 
        char   *display_name;
735
 
        char   *activation_uri;
 
876
        GtkWidget *item;
 
877
        GFile     *root;
 
878
        GIcon     *icon;
 
879
        char      *display_name;
 
880
        char      *activation_uri;
736
881
 
737
882
        icon = g_mount_get_icon (mount);
738
883
        display_name = g_mount_get_name (mount);
741
886
        activation_uri = g_file_get_uri (root);
742
887
        g_object_unref (root);
743
888
 
744
 
        panel_menu_items_append_place_item (NULL, icon,
745
 
                                            display_name,
746
 
                                            display_name, //FIXME tooltip
747
 
                                            menu,
748
 
                                            G_CALLBACK (activate_uri),
749
 
                                            activation_uri);
 
889
        item = panel_menu_item_uri_new (activation_uri, NULL, icon,
 
890
                                        display_name,
 
891
                                        display_name, //FIXME tooltip
 
892
                                        G_CALLBACK (activate_uri));
750
893
 
751
894
        g_object_unref (icon);
752
895
        g_free (display_name);
753
896
        g_free (activation_uri);
 
897
 
 
898
        return item;
754
899
}
755
900
 
756
901
typedef enum {
926
1071
        }
927
1072
 
928
1073
        for (sl = items; sl; sl = sl->next) {
 
1074
                GtkWidget *menu_item;
929
1075
                item = sl->data;
 
1076
 
930
1077
                switch (item->type) {
931
1078
                case PANEL_GIO_DRIVE:
932
 
                        panel_menu_item_append_drive (add_menu, item->u.drive);
 
1079
                        menu_item = panel_menu_item_drive_new (item->u.drive);
933
1080
                        g_object_unref (item->u.drive);
934
1081
                        break;
935
1082
                case PANEL_GIO_VOLUME:
936
 
                        panel_menu_item_append_volume (add_menu, item->u.volume);
 
1083
                        menu_item = panel_menu_item_volume_new (item->u.volume);
937
1084
                        g_object_unref (item->u.volume);
938
1085
                        break;
939
1086
                case PANEL_GIO_MOUNT:
940
 
                        panel_menu_item_append_mount (add_menu, item->u.mount);
 
1087
                        menu_item = panel_menu_item_mount_new (item->u.mount);
941
1088
                        g_object_unref (item->u.mount);
942
1089
                        break;
943
1090
                default:
944
1091
                        g_assert_not_reached ();
945
1092
                }
946
1093
                g_slice_free (PanelGioItem, item);
 
1094
 
 
1095
                gtk_menu_shell_append (GTK_MENU_SHELL (add_menu), menu_item);
947
1096
        }
948
1097
 
949
1098
        g_slist_free (items);
1013
1162
        }
1014
1163
 
1015
1164
        for (sl = add_mounts; sl; sl = sl->next) {
 
1165
                GtkWidget *item;
 
1166
 
1016
1167
                mount = sl->data;
1017
 
                panel_menu_item_append_mount (add_menu, mount);
 
1168
 
 
1169
                item = panel_menu_item_mount_new (mount);
 
1170
                gtk_menu_shell_append (GTK_MENU_SHELL (add_menu), item);
 
1171
 
1018
1172
                g_object_unref (mount);
1019
1173
        }
1020
1174
 
1030
1184
        GtkWidget *item;
1031
1185
        char      *gconf_name;
1032
1186
        char      *name;
1033
 
        char      *path;
1034
1187
        char      *uri;
1035
1188
        GFile     *file;
1036
1189
 
1041
1194
        name = panel_util_get_label_for_uri (uri);
1042
1195
        g_object_unref (file);
1043
1196
        
1044
 
        panel_menu_items_append_place_item (PANEL_ICON_HOME, NULL,
1045
 
                                            name,
1046
 
                                            _("Open your personal folder"),
1047
 
                                            places_menu,
1048
 
                                            G_CALLBACK (activate_home_uri),
1049
 
                                            uri);
 
1197
        item = panel_menu_item_uri_new (uri, PANEL_ICON_HOME, NULL,
 
1198
                                        name,
 
1199
                                        _("Open your personal folder"),
 
1200
                                        G_CALLBACK (activate_home_uri));
 
1201
        gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);
 
1202
 
1050
1203
        g_free (name);
1051
1204
        g_free (uri);
1052
1205
 
1057
1210
                uri = g_file_get_uri (file);
1058
1211
                g_object_unref (file);
1059
1212
                
1060
 
                panel_menu_items_append_place_item (
1061
 
                                PANEL_ICON_DESKTOP, NULL,
 
1213
                item = panel_menu_item_uri_new (
 
1214
                                /* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
 
1215
                                uri, PANEL_ICON_DESKTOP, NULL,
1062
1216
                                /* Translators: Desktop is used here as in
1063
1217
                                 * "Desktop Folder" (this is not the Desktop
1064
1218
                                 * environment). */
1065
1219
                                C_("Desktop Folder", "Desktop"),
1066
1220
                                _("Open the contents of your desktop in a folder"),
1067
 
                                places_menu,
1068
 
                                G_CALLBACK (activate_desktop_uri),
1069
 
                                /* FIXME: if the dir changes, we'd need to update the drag data since the uri is not the same */
1070
 
                                uri);
 
1221
                                G_CALLBACK (activate_desktop_uri));
 
1222
                gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);
 
1223
 
1071
1224
                g_free (uri);
1072
1225
        }
1073
1226
 
1077
1230
        gconf_name = gconf_client_get_string (panel_gconf_get_client (),
1078
1231
                                              COMPUTER_NAME_KEY,
1079
1232
                                              NULL);
1080
 
        panel_menu_items_append_from_desktop (places_menu,
1081
 
                                              "nautilus-computer.desktop",
1082
 
                                              gconf_name,
1083
 
                                              TRUE);
1084
 
        if (gconf_name)
1085
 
                g_free (gconf_name);
 
1233
 
 
1234
        if (gconf_name == NULL) {
 
1235
                gconf_name = g_strdup (_("Computer"));
 
1236
        }
 
1237
 
 
1238
        item = panel_menu_item_uri_new ("computer://",
 
1239
                                        PANEL_ICON_COMPUTER, NULL,
 
1240
                                        gconf_name,
 
1241
                                        _("Browse all local and remote disks and folders accessible from this computer"),
 
1242
                                        G_CALLBACK (activate_uri));
 
1243
        gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);
 
1244
        g_free (gconf_name);
1086
1245
 
1087
1246
        panel_place_menu_item_append_local_gio (place_item, places_menu);
1088
1247
        add_menu_separator (places_menu);
1089
1248
 
1090
 
        panel_menu_items_append_from_desktop (places_menu,
1091
 
                                              "network-scheme.desktop",
1092
 
                                              NULL,
1093
 
                                              TRUE);
 
1249
        item = panel_menu_item_uri_new ("network://",
 
1250
                                        PANEL_ICON_NETWORK, NULL,
 
1251
                                        _("Network"),
 
1252
                                        _("Browse bookmarked and local network locations"),
 
1253
                                        G_CALLBACK (activate_uri));
 
1254
        gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);
 
1255
 
1094
1256
        panel_place_menu_item_append_remote_gio (place_item, places_menu);
1095
1257
 
1096
1258
        if (panel_is_program_in_path ("nautilus-connect-server")) {
1102
1264
 
1103
1265
        add_menu_separator (places_menu);
1104
1266
 
1105
 
        panel_menu_items_append_from_desktop (places_menu,
1106
 
                                              "gnome-search-tool.desktop",
1107
 
                                              NULL,
1108
 
                                              FALSE);
 
1267
        item = panel_menu_item_desktop_new ("gnome-search-tool.desktop",
 
1268
                                            NULL,
 
1269
                                            FALSE);
 
1270
        if (item)
 
1271
                gtk_menu_shell_append (GTK_MENU_SHELL (places_menu), item);
1109
1272
 
1110
1273
        panel_recent_append_documents_menu (places_menu,
1111
1274
                                            place_item->priv->recent_manager);
1174
1337
        panel_place_menu_item_recreate_menu (place_menu);
1175
1338
}
1176
1339
 
1177
 
static void
1178
 
panel_desktop_menu_item_append_menu (GtkWidget *menu,
1179
 
                                     gpointer   data)
1180
 
{
1181
 
        PanelDesktopMenuItem *parent;
1182
 
        gboolean              add_separator;
1183
 
        GList                *children;
1184
 
        GList                *last;
1185
 
 
1186
 
        parent = PANEL_DESKTOP_MENU_ITEM (data);
1187
 
 
1188
 
        add_separator = FALSE;
1189
 
        children = gtk_container_get_children (GTK_CONTAINER (menu));
1190
 
        last = g_list_last (children);
1191
 
 
1192
 
        if (last != NULL)
1193
 
                add_separator = !GTK_IS_SEPARATOR (GTK_WIDGET (last->data));
1194
 
 
1195
 
        g_list_free (children);
1196
 
 
1197
 
        if (add_separator)
1198
 
                add_menu_separator (menu);
1199
 
 
1200
 
        panel_menu_items_append_from_desktop (menu, "yelp.desktop", _("Help and Support"), FALSE);
1201
 
 
1202
 
        panel_menu_items_append_from_desktop (menu, "gnome-about.desktop", NULL, FALSE);
1203
 
 
1204
 
        if (g_file_test ("/usr/share/omf/about-ubuntu/about-ubuntu-C.omf",
1205
 
                         G_FILE_TEST_IS_REGULAR))
1206
 
          panel_menu_items_append_from_desktop (menu, "ubuntu-about.desktop", NULL, FALSE);
1207
 
 
1208
 
        if (g_file_test ("/usr/share/omf/about-edubuntu/about-edubuntu-C.omf",
1209
 
                         G_FILE_TEST_IS_REGULAR))
1210
 
          panel_menu_items_append_from_desktop (menu, "edubuntu-about.desktop", NULL, FALSE);
1211
 
 
1212
 
        if (parent->priv->append_lock_logout)
1213
 
                panel_menu_items_append_lock_logout (menu);
1214
 
}
1215
 
 
1216
1340
static GtkWidget *
1217
 
panel_desktop_menu_item_create_menu (PanelDesktopMenuItem *desktop_item)
 
1341
panel_desktop_menu_item_create_menu (PanelDesktopMenuItem *desktop_item,
 
1342
                                     gboolean append_lock_logout)
1218
1343
{
1219
1344
        GtkWidget *desktop_menu;
1220
 
 
1221
 
        desktop_menu = create_applications_menu ("settings.menu", NULL, FALSE);
1222
 
 
1223
 
        g_object_set_data (G_OBJECT (desktop_menu),
1224
 
                           "panel-menu-append-callback",
1225
 
                           panel_desktop_menu_item_append_menu);
1226
 
        g_object_set_data (G_OBJECT (desktop_menu),
1227
 
                           "panel-menu-append-callback-data",
1228
 
                           desktop_item);
 
1345
        GtkWidget *item;
 
1346
#ifdef HAVE_TELEPATHY_GLIB
 
1347
        gboolean   added;
 
1348
#endif
 
1349
 
 
1350
        desktop_menu = panel_create_menu ();
 
1351
 
 
1352
#ifdef HAVE_TELEPATHY_GLIB
 
1353
        desktop_item->priv->account_manager = tp_account_manager_dup ();
 
1354
 
 
1355
        item = panel_menu_item_presence_new (desktop_item->priv->account_manager,
 
1356
                                             PANEL_SESSION_MANAGER_PRESENCE_AVAILABLE,
 
1357
                                             _("Available"),
 
1358
                                             PANEL_ICON_USER_AVAILABLE, TRUE);
 
1359
        if (item) {
 
1360
                desktop_item->priv->presence_items = g_list_prepend (desktop_item->priv->presence_items, item);
 
1361
                gtk_menu_shell_append (GTK_MENU_SHELL (desktop_menu), item);
 
1362
                added = TRUE;
 
1363
        }
 
1364
 
 
1365
        item = panel_menu_item_presence_new (desktop_item->priv->account_manager,
 
1366
                                             PANEL_SESSION_MANAGER_PRESENCE_BUSY,
 
1367
                                             _("Busy"),
 
1368
                                             PANEL_ICON_USER_BUSY, TRUE);
 
1369
        if (item) {
 
1370
                desktop_item->priv->presence_items = g_list_prepend (desktop_item->priv->presence_items, item);
 
1371
                gtk_menu_shell_append (GTK_MENU_SHELL (desktop_menu), item);
 
1372
                added = TRUE;
 
1373
        }
 
1374
 
 
1375
        if (added)
 
1376
                add_menu_separator (desktop_menu);
 
1377
#endif
 
1378
 
 
1379
        item = panel_menu_item_desktop_new ("gnome-user-accounts-panel.desktop",
 
1380
                                            _("My Account"), FALSE);
 
1381
        if (item)
 
1382
                gtk_menu_shell_append (GTK_MENU_SHELL (desktop_menu), item);
 
1383
 
 
1384
        /* Do not force the string like in gnome-shell, but just use the one
 
1385
         * from the .desktop file */
 
1386
        item = panel_menu_item_desktop_new ("gnome-control-center.desktop",
 
1387
                                            NULL, FALSE);
 
1388
        if (item)
 
1389
                gtk_menu_shell_append (GTK_MENU_SHELL (desktop_menu), item);
 
1390
 
 
1391
        if (append_lock_logout)
 
1392
                panel_menu_items_append_lock_logout (desktop_menu);
1229
1393
 
1230
1394
        return desktop_menu;
1231
1395
}
1232
1396
 
1233
1397
static void
1234
 
panel_desktop_menu_item_recreate_menu (PanelDesktopMenuItem *desktop_item)
1235
 
{
1236
 
        if (desktop_item->priv->menu) {
1237
 
                gtk_widget_destroy (desktop_item->priv->menu);
1238
 
                desktop_item->priv->menu = panel_desktop_menu_item_create_menu (desktop_item);
1239
 
                gtk_menu_item_set_submenu (GTK_MENU_ITEM (desktop_item),
1240
 
                                           desktop_item->priv->menu);
1241
 
                panel_applet_menu_set_recurse (GTK_MENU (desktop_item->priv->menu),
1242
 
                                               "menu_panel",
1243
 
                                               desktop_item->priv->panel);
1244
 
        }
1245
 
}
1246
 
 
1247
 
static void
1248
1398
panel_place_menu_item_finalize (GObject *object)
1249
1399
{
1250
1400
        PanelPlaceMenuItem *menuitem = (PanelPlaceMenuItem *) object;
1319
1469
{
1320
1470
        PanelDesktopMenuItem *menuitem = (PanelDesktopMenuItem *) object;
1321
1471
 
1322
 
        if (menuitem->priv->append_lock_logout)
1323
 
                panel_lockdown_notify_remove (G_CALLBACK (panel_desktop_menu_item_recreate_menu),
1324
 
                                              menuitem);
 
1472
#ifdef HAVE_TELEPATHY_GLIB
 
1473
        g_list_free (menuitem->priv->presence_items);
 
1474
        menuitem->priv->presence_items = NULL;
 
1475
 
 
1476
        if (menuitem->priv->presence_changed_id != 0)
 
1477
                g_signal_handler_disconnect (panel_session_manager_get (),
 
1478
                                             menuitem->priv->presence_changed_id);
 
1479
        menuitem->priv->presence_changed_id = 0;
 
1480
 
 
1481
        if (menuitem->priv->account_manager != NULL)
 
1482
                g_object_unref (menuitem->priv->account_manager);
 
1483
        menuitem->priv->account_manager = NULL;
 
1484
#endif
 
1485
 
1325
1486
        G_OBJECT_CLASS (panel_desktop_menu_item_parent_class)->finalize (object);
1326
1487
}
1327
1488
 
1424
1585
panel_desktop_menu_item_init (PanelDesktopMenuItem *menuitem)
1425
1586
{
1426
1587
        menuitem->priv = PANEL_DESKTOP_MENU_ITEM_GET_PRIVATE (menuitem);
 
1588
 
 
1589
#ifdef HAVE_TELEPATHY_GLIB
 
1590
        menuitem->priv->presence_items = NULL;
 
1591
        menuitem->priv->presence_changed_id = 0;
 
1592
        menuitem->priv->account_manager = NULL;
 
1593
#endif
1427
1594
}
1428
1595
 
1429
1596
static void
1430
1597
panel_place_menu_item_class_init (PanelPlaceMenuItemClass *klass)
1431
1598
{
1432
 
        GObjectClass *gobject_class = (GObjectClass   *) klass;
 
1599
        GObjectClass *gobject_class = (GObjectClass *) klass;
1433
1600
 
1434
 
        gobject_class->finalize  = panel_place_menu_item_finalize;
 
1601
        gobject_class->finalize = panel_place_menu_item_finalize;
1435
1602
 
1436
1603
        g_type_class_add_private (klass, sizeof (PanelPlaceMenuItemPrivate));
1437
1604
}
1439
1606
static void
1440
1607
panel_desktop_menu_item_class_init (PanelDesktopMenuItemClass *klass)
1441
1608
{
1442
 
        GObjectClass *gobject_class = (GObjectClass   *) klass;
 
1609
        GObjectClass *gobject_class = (GObjectClass *) klass;
1443
1610
 
1444
 
        gobject_class->finalize  = panel_desktop_menu_item_finalize;
 
1611
        gobject_class->finalize = panel_desktop_menu_item_finalize;
1445
1612
 
1446
1613
        g_type_class_add_private (klass, sizeof (PanelDesktopMenuItemPrivate));
1447
1614
}
1465
1632
                        image,
1466
1633
                        _("Places"));
1467
1634
 
1468
 
        menuitem->priv->use_image = use_image;
1469
 
 
1470
1635
        menuitem->priv->menu = panel_place_menu_item_create_menu (menuitem);
1471
1636
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
1472
1637
                                   menuitem->priv->menu);
1474
1639
        return GTK_WIDGET (menuitem);
1475
1640
}
1476
1641
 
 
1642
#ifdef HAVE_TELEPATHY_GLIB
 
1643
static void
 
1644
panel_desktop_menu_item_on_presence_changed (PanelSessionManager             *manager,
 
1645
                                             PanelSessionManagerPresenceType  presence_type,
 
1646
                                             PanelDesktopMenuItem            *desktop_item)
 
1647
{
 
1648
        const char *icon;
 
1649
        GtkWidget  *image;
 
1650
        GList      *l;
 
1651
 
 
1652
        switch (presence_type) {
 
1653
        case PANEL_SESSION_MANAGER_PRESENCE_AVAILABLE:
 
1654
                icon = PANEL_ICON_USER_AVAILABLE;
 
1655
                break;
 
1656
        case PANEL_SESSION_MANAGER_PRESENCE_INVISIBLE:
 
1657
                icon = PANEL_ICON_USER_INVISIBLE;
 
1658
                break;
 
1659
        case PANEL_SESSION_MANAGER_PRESENCE_BUSY:
 
1660
                icon = PANEL_ICON_USER_BUSY;
 
1661
                break;
 
1662
        case PANEL_SESSION_MANAGER_PRESENCE_IDLE:
 
1663
        default:
 
1664
                icon = PANEL_ICON_USER_IDLE;
 
1665
                break;
 
1666
        }
 
1667
 
 
1668
        image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (desktop_item));
 
1669
        /* we only have an image if we are specifically using an icon for this
 
1670
         * menu */
 
1671
        if (image) {
 
1672
                gtk_image_set_from_icon_name (GTK_IMAGE (image),
 
1673
                                              icon, panel_menu_icon_get_size ());
 
1674
        }
 
1675
 
 
1676
        for (l = desktop_item->priv->presence_items; l != NULL; l = l->next) {
 
1677
                PanelSessionManagerPresenceType for_presence;
 
1678
                GObject *object = l->data;
 
1679
 
 
1680
                for_presence = GPOINTER_TO_INT (g_object_get_data (object,
 
1681
                                                                   "panel-menu-presence"));
 
1682
                g_signal_handlers_block_by_func (object,
 
1683
                                                 panel_menu_item_activate_presence,
 
1684
                                                 desktop_item->priv->account_manager);
 
1685
                gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (object),
 
1686
                                                for_presence == presence_type);
 
1687
                g_signal_handlers_unblock_by_func (object,
 
1688
                                                   panel_menu_item_activate_presence,
 
1689
                                                   desktop_item->priv->account_manager);
 
1690
        }
 
1691
}
 
1692
#endif
 
1693
 
1477
1694
GtkWidget *
1478
1695
panel_desktop_menu_item_new (gboolean use_image,
1479
1696
                             gboolean append_lock_logout)
1480
1697
{
1481
1698
        PanelDesktopMenuItem *menuitem;
1482
 
        GtkWidget            *image;
 
1699
        char                 *name;
 
1700
#ifdef HAVE_TELEPATHY_GLIB
 
1701
        PanelSessionManager  *manager;
 
1702
#endif
1483
1703
 
1484
1704
        menuitem = g_object_new (PANEL_TYPE_DESKTOP_MENU_ITEM, NULL);
1485
1705
 
1486
 
        if (use_image)
1487
 
                image = gtk_image_new_from_icon_name ("computer",
1488
 
                                                      panel_menu_icon_get_size ());
1489
 
        else
1490
 
                image = NULL;
1491
 
 
1492
 
        setup_menuitem (GTK_WIDGET (menuitem),
1493
 
                        image ? panel_menu_icon_get_size () : GTK_ICON_SIZE_INVALID,
1494
 
                        image,
1495
 
                        _("System"));
1496
 
 
1497
 
        menuitem->priv->use_image = use_image;
1498
 
 
1499
 
        menuitem->priv->append_lock_logout = append_lock_logout;
1500
 
        if (append_lock_logout)
1501
 
                panel_lockdown_notify_add (G_CALLBACK (panel_desktop_menu_item_recreate_menu),
1502
 
                                           menuitem);
1503
 
 
1504
 
        menuitem->priv->menu = panel_desktop_menu_item_create_menu (menuitem);
 
1706
        name = panel_util_get_user_name ();
 
1707
 
 
1708
        if (use_image) {
 
1709
#ifdef HAVE_TELEPATHY_GLIB
 
1710
                setup_menu_item_with_icon (GTK_WIDGET (menuitem),
 
1711
                                           panel_menu_icon_get_size (),
 
1712
                                           PANEL_ICON_USER_AVAILABLE,
 
1713
                                           NULL, NULL,
 
1714
                                           name);
 
1715
                gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem),
 
1716
                                                           TRUE);
 
1717
#else
 
1718
                setup_menu_item_with_icon (GTK_WIDGET (menuitem),
 
1719
                                           panel_menu_icon_get_size (),
 
1720
                                           PANEL_ICON_COMPUTER,
 
1721
                                           NULL, NULL,
 
1722
                                           name);
 
1723
#endif
 
1724
        } else
 
1725
                setup_menuitem (GTK_WIDGET (menuitem),
 
1726
                                GTK_ICON_SIZE_INVALID, NULL,
 
1727
                                name);
 
1728
 
 
1729
        g_free (name);
 
1730
 
 
1731
        menuitem->priv->menu = panel_desktop_menu_item_create_menu (menuitem,
 
1732
                                                                    append_lock_logout);
1505
1733
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),
1506
1734
                                   menuitem->priv->menu);
1507
1735
 
 
1736
#ifdef HAVE_TELEPATHY_GLIB
 
1737
        manager = panel_session_manager_get ();
 
1738
 
 
1739
        menuitem->priv->presence_changed_id =
 
1740
                g_signal_connect (manager,
 
1741
                                  "presence-changed",
 
1742
                                  G_CALLBACK (panel_desktop_menu_item_on_presence_changed),
 
1743
                                  menuitem);
 
1744
 
 
1745
        panel_desktop_menu_item_on_presence_changed (manager,
 
1746
                                                     panel_session_manager_get_presence (manager),
 
1747
                                                     menuitem);
 
1748
#endif
 
1749
 
1508
1750
        return GTK_WIDGET (menuitem);
1509
1751
}
1510
1752
 
1534
1776
                                       "menu_panel", panel);
1535
1777
}
1536
1778
 
1537
 
#define FUSA_APPLET_IID "OAFIID:GNOME_FastUserSwitchApplet"
1538
 
#define INDICATOR_APPLET_COMPLETE_IID "OAFIID:GNOME_IndicatorAppletComplete"
1539
 
 
1540
 
static void
1541
 
panel_menu_items_hide_on_fusa (PanelAppletSignaler * pas, AppletInfo * info, GtkWidget * widget)
1542
 
{
1543
 
        /* check if we are running stracciatella session */
1544
 
        if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {
1545
 
                g_debug("Running stracciatella GNOME session, not touching menu items");
1546
 
                return TRUE;
1547
 
        }
1548
 
 
1549
 
        const char * iid = panel_applet_get_iid(info);
1550
 
        if (iid == NULL)
1551
 
                return;
1552
 
 
1553
 
        if (g_strcmp0(iid, FUSA_APPLET_IID) == 0 ||
1554
 
                g_strcmp0(iid, INDICATOR_APPLET_COMPLETE_IID) == 0)
1555
 
                gtk_widget_hide(widget);
1556
 
 
1557
 
        return;
1558
 
}
1559
 
 
1560
 
static void
1561
 
panel_menu_items_show_on_fusa (PanelAppletSignaler * pas, AppletInfo * info, GtkWidget * widget)
1562
 
{
1563
 
        /* check if we are running stracciatella session */
1564
 
        if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {
1565
 
                g_debug("Running stracciatella GNOME session, not touching menu items");
1566
 
                return TRUE;
1567
 
        }
1568
 
 
1569
 
        const char * iid = panel_applet_get_iid(info);
1570
 
        if (iid == NULL)
1571
 
                return;
1572
 
 
1573
 
        if (g_strcmp0(iid, FUSA_APPLET_IID) == 0 ||
1574
 
                g_strcmp0(iid, INDICATOR_APPLET_COMPLETE_IID) == 0)
1575
 
                gtk_widget_show(widget);
1576
 
 
1577
 
        return;
1578
 
}
1579
 
 
1580
 
static void
1581
 
disconnect_signalers (PanelAppletSignaler *signaler,
1582
 
                      GtkWidget           *widget)
1583
 
{
1584
 
        g_signal_handlers_disconnect_by_func (signaler,
1585
 
                                              panel_menu_items_hide_on_fusa,
1586
 
                                              widget);
1587
 
        g_signal_handlers_disconnect_by_func (signaler,
1588
 
                                              panel_menu_items_show_on_fusa,
1589
 
                                              widget);
 
1779
static void
 
1780
panel_menu_items_lock_logout_separator_notified (PanelLockdown *lockdown,
 
1781
                                                 gpointer       user_data)
 
1782
{
 
1783
        GtkWidget *separator = user_data;
 
1784
 
 
1785
        if (!panel_lockdown_get_disable_lock_screen (lockdown) ||
 
1786
            !panel_lockdown_get_disable_switch_user (lockdown) ||
 
1787
            !panel_lockdown_get_disable_log_out (lockdown))
 
1788
                gtk_widget_show (separator);
 
1789
        else
 
1790
                gtk_widget_hide (separator);
1590
1791
}
1591
1792
 
1592
1793
void
1593
1794
panel_menu_items_append_lock_logout (GtkWidget *menu)
1594
1795
{
1595
 
        gboolean    separator_inserted;
1596
1796
        GList      *children;
1597
1797
        GList      *last;
1598
1798
        GtkWidget  *item;
1599
 
        const char *translate;
1600
 
        char       *label;
1601
 
        char       *tooltip;
1602
 
        GtkWidget  *separator = NULL;
1603
 
        AppletInfo *fusa = NULL;
1604
 
        PanelAppletSignaler *signaler = panel_applet_signaler_get_default ();
1605
 
 
1606
 
        fusa = panel_applet_get_by_iid(FUSA_APPLET_IID);
1607
 
        if (fusa == NULL)
1608
 
                fusa = panel_applet_get_by_iid(INDICATOR_APPLET_COMPLETE_IID);
1609
 
 
1610
 
        separator_inserted = FALSE;
 
1799
 
1611
1800
        children = gtk_container_get_children (GTK_CONTAINER (menu));
1612
1801
        last = g_list_last (children);
1613
 
        if (last != NULL) {
1614
 
                separator_inserted = GTK_IS_SEPARATOR (GTK_WIDGET (last->data));
1615
 
        }
1616
 
        if (separator_inserted) {
1617
 
                g_object_weak_ref (G_OBJECT (last->data),
1618
 
                                   (GWeakNotify) disconnect_signalers,
1619
 
                                   signaler);
1620
 
 
1621
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_ADDED,
1622
 
                                 G_CALLBACK(panel_menu_items_hide_on_fusa), last->data);
1623
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_REMOVED,
1624
 
                                 G_CALLBACK(panel_menu_items_show_on_fusa), last->data);
1625
 
                if (fusa != NULL) {
1626
 
                        gtk_widget_hide(GTK_WIDGET(last->data));
1627
 
                }
1628
 
        }
 
1802
        if (last != NULL &&
 
1803
            GTK_IS_SEPARATOR (last->data))
 
1804
                item = GTK_WIDGET (last->data);
 
1805
        else
 
1806
                item = add_menu_separator (menu);
1629
1807
        g_list_free (children);
1630
1808
 
1631
 
        if (panel_lock_screen_action_available ("lock")) {
1632
 
                item = panel_menu_items_create_action_item (PANEL_ACTION_LOCK);
 
1809
        panel_lockdown_on_notify (panel_lockdown_get (),
 
1810
                                  NULL,
 
1811
                                  G_OBJECT (item),
 
1812
                                  panel_menu_items_lock_logout_separator_notified,
 
1813
                                  item);
 
1814
        panel_menu_items_lock_logout_separator_notified (panel_lockdown_get (),
 
1815
                                                         item);
 
1816
 
 
1817
        item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOCK,
 
1818
                                                         NULL, NULL, TRUE);
 
1819
        if (item != NULL) {
 
1820
                gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
1821
                g_object_bind_property (panel_lockdown_get (),
 
1822
                                        "disable-lock-screen",
 
1823
                                        item,
 
1824
                                        "visible",
 
1825
                                        G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
 
1826
        }
 
1827
 
 
1828
        item = panel_menu_items_create_switch_user (FALSE);
 
1829
 
 
1830
        if (item != NULL) {
 
1831
                gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
1832
                g_object_bind_property (panel_lockdown_get (),
 
1833
                                        "disable-switch-user",
 
1834
                                        item,
 
1835
                                        "visible",
 
1836
                                        G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
 
1837
        }
 
1838
 
 
1839
        item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT,
 
1840
                                                         NULL, NULL, TRUE);
 
1841
 
 
1842
        if (item != NULL) {
 
1843
                gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
1844
                g_object_bind_property (panel_lockdown_get (),
 
1845
                                        "disable-log-out",
 
1846
                                        item,
 
1847
                                        "visible",
 
1848
                                        G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
 
1849
        }
 
1850
 
 
1851
        /* FIXME: should be dynamic */
 
1852
        if (panel_session_manager_is_shutdown_available (panel_session_manager_get ())) {
 
1853
                item = panel_menu_items_create_action_item_full (PANEL_ACTION_SHUTDOWN,
 
1854
                                                                 NULL, NULL, TRUE);
1633
1855
                if (item != NULL) {
1634
 
                        if (!separator_inserted) {
1635
 
                                separator = add_menu_separator (menu);
1636
 
                                separator_inserted = TRUE;
1637
 
                        }
 
1856
                        GtkWidget *sep;
 
1857
 
 
1858
                        sep = add_menu_separator (menu);
1638
1859
 
1639
1860
                        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
1640
1861
 
1641
 
                        g_object_weak_ref (G_OBJECT (item),
1642
 
                                           (GWeakNotify) disconnect_signalers,
1643
 
                                           signaler);
1644
 
 
1645
 
                        g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_ADDED,
1646
 
                                         G_CALLBACK(panel_menu_items_hide_on_fusa), item);
1647
 
                        g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_REMOVED,
1648
 
                                         G_CALLBACK(panel_menu_items_show_on_fusa), item);
1649
 
                        if (fusa != NULL) {
1650
 
                                gtk_widget_hide(GTK_WIDGET(item));
1651
 
                        }
1652
 
                }
1653
 
        }
1654
 
 
1655
 
        if (panel_lockdown_get_disable_log_out ())
1656
 
                return;
1657
 
        /* Below this, we only have log out/shutdown items */
1658
 
 
1659
 
        /* Translators: translate "1" (msgctxt: "panel:showusername") to anything
1660
 
         * but "1" if "Log Out %s" doesn't make any sense in your
1661
 
         * language (where %s is a username).
1662
 
         */
1663
 
        translate = C_("panel:showusername", "1");
1664
 
        if (strcmp (translate, "1") == 0) {
1665
 
                const char *user_name;
1666
 
 
1667
 
                user_name = g_get_real_name ();
1668
 
                if (!user_name || !user_name [0])
1669
 
                        user_name = g_get_user_name ();
1670
 
 
1671
 
                /* keep those strings in sync with the ones in
1672
 
                 * panel-action-button.c */
1673
 
                /* Translators: this string is used ONLY if you translated
1674
 
                 * "1" (msgctxt: "panel:showusername") to "1" */
1675
 
                label = g_strdup_printf (_("Log Out %s..."),
1676
 
                                         g_get_user_name ());
1677
 
                /* Translators: this string is used ONLY if you translated
1678
 
                 * "1" (msgctxt: "panel:showusername") to "1" */
1679
 
                tooltip = g_strdup_printf (_("Log out %s of this session to "
1680
 
                                             "log in as a different user"),
1681
 
                                           user_name);
1682
 
        } else {
1683
 
                label   = NULL;
1684
 
                tooltip = NULL;
1685
 
        }
1686
 
 
1687
 
        item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT,
1688
 
                                                         label, tooltip);
1689
 
        g_free (label);
1690
 
        g_free (tooltip);
1691
 
 
1692
 
        if (item != NULL) {
1693
 
                if (!separator_inserted) {
1694
 
                        separator = add_menu_separator (menu);
1695
 
                        separator_inserted = TRUE;
1696
 
                }
1697
 
 
1698
 
                gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
1699
 
 
1700
 
                g_object_weak_ref (G_OBJECT (item),
1701
 
                                   (GWeakNotify) disconnect_signalers,
1702
 
                                   signaler);
1703
 
 
1704
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_ADDED,
1705
 
                                 G_CALLBACK(panel_menu_items_hide_on_fusa), item);
1706
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_REMOVED,
1707
 
                                 G_CALLBACK(panel_menu_items_show_on_fusa), item);
1708
 
                if (fusa != NULL) {
1709
 
                        gtk_widget_hide(GTK_WIDGET(item));
1710
 
                }
1711
 
        }
1712
 
 
1713
 
        item = panel_menu_items_create_action_item (PANEL_ACTION_SHUTDOWN);
1714
 
        if (item != NULL) {
1715
 
                if (!separator_inserted)
1716
 
                        separator = add_menu_separator (menu);
1717
 
 
1718
 
                gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
1719
 
 
1720
 
                g_object_weak_ref (G_OBJECT (item),
1721
 
                                   (GWeakNotify) disconnect_signalers,
1722
 
                                   signaler);
1723
 
 
1724
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_ADDED,
1725
 
                                 G_CALLBACK(panel_menu_items_hide_on_fusa), item);
1726
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_REMOVED,
1727
 
                                 G_CALLBACK(panel_menu_items_show_on_fusa), item);
1728
 
                if (fusa != NULL) {
1729
 
                        gtk_widget_hide(GTK_WIDGET(item));
1730
 
                }
1731
 
        }
1732
 
 
1733
 
        /* Okay, this is confusing, but required to make the patch
1734
 
         * smaller.  Basically if the seperator was created externally it
1735
 
         * gets the signal handlers added when it is detected, but the
1736
 
         * local variable remains NULL.  This allows the return in the
1737
 
         * middle to still work.  But, if the seperator gets built in the
1738
 
         * remainder of this function then the signal handlers get added
1739
 
         * on here as the local variable becomes a pointer to that created
1740
 
         * seperator.  Whew.  */
1741
 
        if (separator != NULL) {
1742
 
                g_object_weak_ref (G_OBJECT (separator),
1743
 
                                   (GWeakNotify) disconnect_signalers,
1744
 
                                   signaler);
1745
 
 
1746
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_ADDED,
1747
 
                                 G_CALLBACK(panel_menu_items_hide_on_fusa), separator);
1748
 
                g_signal_connect(signaler, PANEL_APPLET_SIGNALER_SIGNAL_APPLET_REMOVED,
1749
 
                                 G_CALLBACK(panel_menu_items_show_on_fusa), separator);
1750
 
                if (fusa != NULL) {
1751
 
                        gtk_widget_hide(GTK_WIDGET(separator));
 
1862
                        g_object_bind_property (panel_lockdown_get (),
 
1863
                                                "disable-log-out",
 
1864
                                                sep,
 
1865
                                                "visible",
 
1866
                                                G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
 
1867
                        g_object_bind_property (panel_lockdown_get (),
 
1868
                                                "disable-log-out",
 
1869
                                                item,
 
1870
                                                "visible",
 
1871
                                                G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN);
1752
1872
                }
1753
1873
        }
1754
1874
}