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

« back to all changes in this revision

Viewing changes to applets/wncklet/window-menu.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:
25
25
 *      Jacob Berkman <jacob@helixcode.com>
26
26
 */
27
27
 
28
 
#define WNCK_I_KNOW_THIS_IS_UNSTABLE 1
29
 
 
30
28
#ifdef HAVE_CONFIG_H
31
29
#include <config.h>
32
30
#endif
37
35
#include <glib/gi18n.h>
38
36
#include <gdk/gdkkeysyms.h>
39
37
 
40
 
#include <libwnck/selector.h>
 
38
#include <libwnck/libwnck.h>
41
39
 
42
40
#include "wncklet.h"
43
41
#include "window-menu.h"
47
45
typedef struct {
48
46
        GtkWidget    *applet;
49
47
        GtkWidget    *selector;
50
 
        GtkWidget    *about_dialog;
51
48
        int           size;
52
49
        PanelAppletOrient orient;
53
50
} WindowMenu;
54
51
 
55
52
static void
56
 
window_menu_help (GtkAction  *action,
57
 
                  WindowMenu *window_menu)
58
 
{
59
 
        wncklet_display_help (window_menu->applet, "user-guide",
60
 
                              "panel-windowselector", WINDOW_MENU_ICON);
61
 
}
62
 
 
63
 
static void
64
 
window_menu_about (GtkAction  *action,
65
 
                   WindowMenu *window_menu)
66
 
{
67
 
        static const char *authors[] = {
68
 
                "Mark McLoughlin <mark@skynet.ie>",
69
 
                "George Lebl <jirka@5z.com>",
70
 
                "Jacob Berkman <jacob@helixcode.com>",
71
 
                NULL
72
 
        };
73
 
        const char *documenters [] = { 
74
 
                "Sun GNOME Documentation Team <gdocteam@sun.com>",
75
 
                NULL 
76
 
        };
77
 
        const char *translator_credits = _("translator-credits");
78
 
 
79
 
        wncklet_display_about (window_menu->applet, &window_menu->about_dialog,
80
 
                               _("Window Selector"),
81
 
                               "Copyright \xc2\xa9 2003 Sun Microsystems, Inc.\n"
82
 
                               "Copyright \xc2\xa9 2001 Free Software Foundation, Inc.\n"
83
 
                               "Copyright \xc2\xa9 2000 Helix Code, Inc.",
84
 
                               _("The Window Selector shows a list of all windows in a menu and lets you browse them."),
85
 
                               authors,
86
 
                               documenters,
87
 
                               translator_credits,
88
 
                               WINDOW_MENU_ICON,
89
 
                               "window-menu",
90
 
                               "WindowMenu");
91
 
}
92
 
 
93
 
static const GtkActionEntry window_menu_actions [] =
94
 
{
95
 
        { "WindowMenuHelp", GTK_STOCK_HELP, N_("_Help"),
96
 
          NULL, NULL,
97
 
          G_CALLBACK (window_menu_help) },
98
 
        { "WindowMenuAbout", GTK_STOCK_ABOUT, N_("_About"),
99
 
          NULL, NULL,
100
 
          G_CALLBACK (window_menu_about) }
101
 
};
102
 
 
103
 
static void
104
53
window_menu_destroy (GtkWidget  *widget,
105
54
                     WindowMenu *window_menu)
106
55
{
107
 
        if (window_menu->about_dialog) {
108
 
                gtk_widget_destroy (window_menu->about_dialog);
109
 
                window_menu->about_dialog = NULL;
110
 
        }
111
 
 
112
56
        g_free (window_menu);
113
57
}
114
58
 
115
59
static gboolean
116
 
window_menu_on_expose (GtkWidget *widget,
117
 
                       GdkEventExpose *event,
118
 
                       gpointer data)
 
60
window_menu_on_draw (GtkWidget *widget,
 
61
                     cairo_t   *cr,
 
62
                     gpointer   data)
119
63
{
120
 
        WindowMenu *window_menu = data;
121
 
 
122
 
        if (gtk_widget_has_focus (window_menu->applet))
123
 
                gtk_paint_focus (gtk_widget_get_style (widget),
124
 
                                 gtk_widget_get_window (widget), 
125
 
                                 gtk_widget_get_state (widget),
126
 
                                 NULL,
127
 
                                 widget,
128
 
                                 "menu-applet",
129
 
                                 0, 0, -1, -1);
 
64
        GtkStyleContext *context;
 
65
        GtkStateFlags    state;
 
66
        WindowMenu      *window_menu = data;
 
67
 
 
68
        if (!gtk_widget_has_focus (window_menu->applet))
 
69
                return FALSE;
 
70
 
 
71
        state = gtk_widget_get_state_flags (widget);
 
72
        context = gtk_widget_get_style_context (widget);
 
73
        gtk_style_context_save (context);
 
74
        gtk_style_context_set_state (context, state);
 
75
 
 
76
        cairo_save (cr);
 
77
        gtk_render_focus (context, cr,
 
78
                          0., 0.,
 
79
                          gtk_widget_get_allocated_width (widget),
 
80
                          gtk_widget_get_allocated_height (widget));
 
81
        cairo_restore (cr);
 
82
 
 
83
        gtk_style_context_restore (context);
 
84
 
130
85
        return FALSE;
131
86
}
132
87
 
133
88
static inline void
134
89
force_no_focus_padding (GtkWidget *widget)
135
90
{
136
 
        gboolean first_time = TRUE;
 
91
        GtkCssProvider *provider;
137
92
 
138
 
        if (first_time) {
139
 
                gtk_rc_parse_string ("\n"
140
 
                                     "   style \"window-menu-applet-button-style\"\n"
141
 
                                     "   {\n"
142
 
                                     "      GtkWidget::focus-line-width=0\n"
143
 
                                     "      GtkWidget::focus-padding=0\n"
144
 
                                     "   }\n"
145
 
                                     "\n"
146
 
                                     "    widget \"*.window-menu-applet-button\" style \"window-menu-applet-button-style\"\n"
147
 
                                     "\n");
148
 
                first_time = FALSE;
149
 
        }
 
93
        provider = gtk_css_provider_new ();
 
94
        gtk_css_provider_load_from_data (provider,
 
95
                                         "#window-menu-applet-button {\n"
 
96
                                         " border-width: 0px;\n"
 
97
                                         " -GtkWidget-focus-line-width: 0px;\n"
 
98
                                         " -GtkWidget-focus-padding: 0px;\n"
 
99
                                         "}",
 
100
                                         -1, NULL);
 
101
        gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
 
102
                                        GTK_STYLE_PROVIDER (provider),
 
103
                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
104
        g_object_unref (provider);
150
105
 
151
106
        gtk_widget_set_name (widget, "window-menu-applet-button");
152
107
}
193
148
        WnckSelector *selector;
194
149
 
195
150
        switch (event->keyval) {
196
 
        case GDK_KP_Enter:
197
 
        case GDK_ISO_Enter:
198
 
        case GDK_3270_Enter:
199
 
        case GDK_Return:
200
 
        case GDK_space:
201
 
        case GDK_KP_Space:
 
151
        case GDK_KEY_KP_Enter:
 
152
        case GDK_KEY_ISO_Enter:
 
153
        case GDK_KEY_3270_Enter:
 
154
        case GDK_KEY_Return:
 
155
        case GDK_KEY_space:
 
156
        case GDK_KEY_KP_Space:
202
157
                selector = WNCK_SELECTOR(window_menu->selector);
203
158
                /* 
204
159
                 * We need to call _gtk_menu_shell_activate() here as is done in 
208
163
                 * As that function is private its code is replicated here.
209
164
                 */
210
165
                menu_shell = GTK_MENU_SHELL (selector);
211
 
                if (!menu_shell->active) {
 
166
                /* FIXMEgpoo: We need either accessors or a workaround
 
167
                   to grab the focus */
 
168
#if 0
 
169
                if (!menu_shell->GSEAL(active)) {
212
170
                        gtk_grab_add (GTK_WIDGET (menu_shell));
213
 
                        menu_shell->have_grab = TRUE;
214
 
                        menu_shell->active = TRUE;
 
171
                        menu_shell->GSEAL(have_grab) = TRUE;
 
172
                        menu_shell->GSEAL(active) = TRUE;
215
173
                }
 
174
#endif
216
175
                gtk_menu_shell_select_first (menu_shell, FALSE);
217
176
                return TRUE;
218
177
        default:
237
196
window_menu_applet_fill (PanelApplet *applet)
238
197
{
239
198
        WindowMenu *window_menu;
240
 
        GtkActionGroup *action_group;
241
 
        gchar *ui_path;
242
199
 
243
200
        window_menu = g_new0 (WindowMenu, 1);
244
201
 
253
210
        g_signal_connect (window_menu->applet, "destroy",
254
211
                          G_CALLBACK (window_menu_destroy), window_menu);
255
212
 
256
 
        action_group = gtk_action_group_new ("WindowMenu Applet Actions");
257
 
        gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
258
 
        gtk_action_group_add_actions (action_group,
259
 
                                      window_menu_actions,
260
 
                                      G_N_ELEMENTS (window_menu_actions),
261
 
                                      window_menu);
262
 
        ui_path = g_build_filename (WNCK_MENU_UI_DIR, "window-menu-menu.xml", NULL);
263
 
        panel_applet_setup_menu_from_file (applet, ui_path, action_group);
264
 
        g_free (ui_path);
265
 
        g_object_unref (action_group);
266
 
 
267
213
        window_menu->selector = wnck_selector_new ();
268
214
        gtk_container_add (GTK_CONTAINER (window_menu->applet), 
269
215
                           window_menu->selector);
280
226
                                G_CALLBACK (gtk_widget_queue_draw), window_menu);
281
227
        g_signal_connect_after (G_OBJECT (window_menu->applet), "focus-out-event",
282
228
                                G_CALLBACK (gtk_widget_queue_draw), window_menu);
283
 
        g_signal_connect_after (G_OBJECT (window_menu->selector), "expose-event",
284
 
                                G_CALLBACK (window_menu_on_expose), window_menu);
 
229
        g_signal_connect_after (G_OBJECT (window_menu->selector), "draw",
 
230
                                G_CALLBACK (window_menu_on_draw), window_menu);
285
231
 
286
232
        g_signal_connect (G_OBJECT (window_menu->selector), "button_press_event",
287
233
                          G_CALLBACK (filter_button_press), window_menu);