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

« back to all changes in this revision

Viewing changes to gnome-panel/panel-util.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-xdg.h>
36
36
 
37
37
#include "applet.h"
38
 
#include "nothing.h"
39
38
#include "xstuff.h"
40
 
#include "panel-config-global.h"
 
39
#include "panel-bindings.h"
41
40
#include "panel-gconf.h"
42
41
#include "panel-globals.h"
43
42
#include "launcher.h"
44
43
#include "panel-icon-names.h"
45
 
#include "panel-lockdown.h"
 
44
#include "panel-schemas.h"
46
45
 
47
46
char *
48
47
panel_util_make_exec_uri_for_desktop (const char *exec)
110
109
                if (win != NULL) {
111
110
                        GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
112
111
                        gdk_window_set_cursor (win, cursor);
113
 
                        gdk_cursor_unref (cursor);
 
112
                        g_object_unref (cursor);
114
113
                        gdk_flush ();
115
114
                }
116
115
        }
335
334
}
336
335
 
337
336
static char *
338
 
panel_lock_screen_action_get_command (const char *action)
339
 
{
340
 
        char    *command          = NULL;
341
 
        gboolean use_gscreensaver = FALSE;
342
 
 
343
 
        if (panel_is_program_in_path ("gnome-screensaver-command")
344
 
            && panel_is_program_in_path ("gnome-screensaver-preferences"))
345
 
                use_gscreensaver = TRUE;
346
 
        else if (!panel_is_program_in_path ("xscreensaver-command"))
347
 
                return NULL;
348
 
 
349
 
        if (strcmp (action, "prefs") == 0) {
350
 
                if (use_gscreensaver) {
351
 
                        command = g_strdup ("gnome-screensaver-preferences");
352
 
                } else if (panel_is_program_in_path ("xscreensaver-demo")) {
353
 
                        command = g_strdup ("xscreensaver-demo");
354
 
                } else {
355
 
                        command = NULL;
356
 
                }
357
 
        } else if (strcmp (action, "activate") == 0
358
 
                   || strcmp (action, "lock") == 0) {
359
 
                /* Neither gnome-screensaver or xscreensaver allow root
360
 
                 * to lock the screen */
361
 
                if (geteuid () == 0) {
362
 
                        command = NULL;
363
 
                } else {
364
 
                        if (use_gscreensaver) {
365
 
                                command = g_strdup_printf ("gnome-screensaver-command --%s", action);
366
 
                        } else {
367
 
                                command = g_strdup_printf ("xscreensaver-command -%s", action);
368
 
                        }
369
 
                }
370
 
        }
371
 
 
372
 
        return command;
373
 
}
374
 
 
375
 
gboolean
376
 
panel_lock_screen_action_available (const char *action)
377
 
{
378
 
        char    *command;
379
 
        gboolean enabled = FALSE;
380
 
 
381
 
        g_return_val_if_fail (action != NULL, FALSE);
382
 
 
383
 
        if (strcmp (action, "prefs") != 0 &&
384
 
            panel_lockdown_get_disable_lock_screen ())
385
 
                return FALSE;
386
 
 
387
 
        command = panel_lock_screen_action_get_command (action);
388
 
        if (command)
389
 
                enabled = TRUE;
390
 
 
391
 
        g_free (command);
392
 
 
393
 
        return enabled;
394
 
}
395
 
 
396
 
void
397
 
panel_lock_screen_action (GdkScreen  *screen,
398
 
                          const char *action)
399
 
{
400
 
        GError  *error            = NULL;
401
 
        char    *command          = NULL;
402
 
 
403
 
        g_return_if_fail (GDK_IS_SCREEN (screen));
404
 
        g_return_if_fail (action != NULL);
405
 
 
406
 
        if (strcmp (action, "prefs") != 0 &&
407
 
            panel_lockdown_get_disable_lock_screen ())
408
 
                return;
409
 
 
410
 
        command = panel_lock_screen_action_get_command (action);
411
 
 
412
 
        if (!command)
413
 
                return;
414
 
 
415
 
        if (!gdk_spawn_command_line_on_screen (screen, command, &error)) {
416
 
                char *primary;
417
 
 
418
 
                primary = g_strdup_printf (_("Could not execute '%s'"),
419
 
                                           command);
420
 
                panel_error_dialog (NULL, screen,
421
 
                                    "cannot_exec_screensaver", TRUE,
422
 
                                    primary, error->message);
423
 
                g_free (primary);
424
 
                g_error_free (error);
425
 
        }
426
 
 
427
 
        g_free (command);
428
 
}
429
 
 
430
 
void
431
 
panel_lock_screen (GdkScreen *screen)
432
 
{
433
 
        panel_lock_screen_action (screen, "lock");
434
 
}
435
 
 
436
 
 
437
 
#define PANEL_LAUNCHER_PERSONAL_PATH "panel2.d/default/launchers"
438
 
 
439
 
static char *
440
337
panel_launcher_get_personal_path (void)
441
338
{
442
 
        const char *override;
443
 
 
444
 
        override = g_getenv ("GNOME22_USER_DIR");
445
 
 
446
 
        if (override)
447
 
               return g_build_filename (override,
448
 
                                        PANEL_LAUNCHER_PERSONAL_PATH, NULL);
449
 
        else
450
 
                return g_build_filename (g_get_home_dir (), ".gnome2",
451
 
                                         PANEL_LAUNCHER_PERSONAL_PATH, NULL);
 
339
        return g_build_filename (g_get_user_config_dir (),
 
340
                                 "gnome-panel", "launchers", NULL);
452
341
}
453
342
 
454
343
gboolean
1151
1040
                             GtkTooltip *tooltip,
1152
1041
                             const char *text)
1153
1042
{
1154
 
        if (!panel_global_config_get_tooltips_enabled ())
 
1043
        GSettings *gsettings;
 
1044
        gboolean   enable_tooltips;
 
1045
 
 
1046
        gsettings = g_settings_new (PANEL_GENERAL_SCHEMA);
 
1047
        enable_tooltips = g_settings_get_boolean (gsettings,
 
1048
                                                  PANEL_GENERAL_ENABLE_TOOLTIPS_KEY);
 
1049
        g_object_unref (gsettings);
 
1050
 
 
1051
        if (!enable_tooltips)
1155
1052
                return FALSE;
1156
1053
 
1157
1054
        gtk_tooltip_set_text (tooltip, text);
1205
1102
 
1206
1103
        return file;
1207
1104
}
 
1105
 
 
1106
/*
 
1107
 * Keep code in panel-applet-bindings.c in sync!
 
1108
 */
 
1109
static void
 
1110
panel_util_key_event_is_binding (GdkEventKey *event,
 
1111
                                 GType        type,
 
1112
                                 const char  *signal_name,
 
1113
                                 gboolean    *is_popup,
 
1114
                                 gboolean    *is_popup_modifier)
 
1115
{
 
1116
        GtkBindingSet   *binding_set;
 
1117
        GtkBindingEntry *binding_entry;
 
1118
        gboolean         popup = FALSE;
 
1119
        gboolean         popup_modifier = FALSE;
 
1120
        guint            modifiers;
 
1121
        char            *signal_dash;
 
1122
        char            *signal_underscore;
 
1123
 
 
1124
        modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
 
1125
 
 
1126
        signal_dash = g_strdup (signal_name);
 
1127
        g_strdelimit (signal_dash, "_", '-');
 
1128
        signal_underscore = g_strdup (signal_name);
 
1129
        g_strdelimit (signal_underscore, "-", '_');
 
1130
 
 
1131
        binding_set = gtk_binding_set_by_class (g_type_class_peek (type));
 
1132
 
 
1133
        for (binding_entry = binding_set->entries;
 
1134
             binding_entry != NULL;
 
1135
             binding_entry = binding_entry->set_next) {
 
1136
                GtkBindingSignal *binding_signal;
 
1137
 
 
1138
                for (binding_signal = binding_entry->signals;
 
1139
                     binding_signal != NULL;
 
1140
                     binding_signal = binding_signal->next) {
 
1141
                        if (g_strcmp0 (binding_signal->signal_name, signal_dash) == 0 ||
 
1142
                            g_strcmp0 (binding_signal->signal_name, signal_underscore) == 0) {
 
1143
                                if (binding_entry->keyval != event->keyval)
 
1144
                                        break;
 
1145
 
 
1146
                                popup = modifiers == binding_entry->modifiers;
 
1147
                                popup_modifier = modifiers == (panel_bindings_get_mouse_button_modifier_keymask ()|binding_entry->modifiers);
 
1148
                                break;
 
1149
                        }
 
1150
                }
 
1151
 
 
1152
                if (popup || popup_modifier)
 
1153
                        break;
 
1154
        }
 
1155
 
 
1156
        if (is_popup)
 
1157
                *is_popup = popup;
 
1158
        if (is_popup_modifier)
 
1159
                *is_popup_modifier = popup_modifier;
 
1160
 
 
1161
        g_free (signal_dash);
 
1162
        g_free (signal_underscore);
 
1163
}
 
1164
 
 
1165
void
 
1166
panel_util_key_event_is_popup (GdkEventKey *event,
 
1167
                               gboolean    *is_popup,
 
1168
                               gboolean    *is_popup_modifier)
 
1169
{
 
1170
        panel_util_key_event_is_binding (event, GTK_TYPE_WIDGET, "popup-menu",
 
1171
                                         is_popup, is_popup_modifier);
 
1172
}
 
1173
 
 
1174
void
 
1175
panel_util_key_event_is_popup_panel (GdkEventKey *event,
 
1176
                                     gboolean    *is_popup,
 
1177
                                     gboolean    *is_popup_modifier)
 
1178
{
 
1179
        panel_util_key_event_is_binding (event, PANEL_TYPE_TOPLEVEL, "popup-panel-menu",
 
1180
                                         is_popup, is_popup_modifier);
 
1181
}
 
1182
 
 
1183
char *
 
1184
panel_util_get_user_name (void)
 
1185
{
 
1186
        char *name;
 
1187
 
 
1188
        name = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL);
 
1189
 
 
1190
        if (PANEL_GLIB_STR_EMPTY (name) || g_strcmp0 (name, "Unknown") == 0) {
 
1191
                g_free (name);
 
1192
                name = g_locale_to_utf8 (g_get_user_name (), -1 , NULL, NULL, NULL);
 
1193
        }
 
1194
 
 
1195
        if (!name)
 
1196
                name = g_strdup (g_get_user_name ());
 
1197
 
 
1198
        return name;
 
1199
}