~ubuntu-branches/ubuntu/saucy/nautilus/saucy-proposed

« back to all changes in this revision

Viewing changes to src/nautilus-toolbar.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Sebastien Bacher, Iain Lane, Jeremy Bicha, Robert Ancell, Rico Tzschichholz, Tim Lunn, Marco Trevisan (Treviño)
  • Date: 2013-06-21 17:10:06 UTC
  • mfrom: (1.17.42)
  • Revision ID: package-import@ubuntu.com-20130621171006-0vajxyu6ebhp1p9p
Tags: 1:3.8.2-0ubuntu1
[ Sebastien Bacher ]
* Bring the 3.8 update work from the gnome3 ppa to the distribution vcs
* debian/patches/16_unity_new_documents.patch: 
  - updated to work on 3.8 (by adding a revert of the commit that broke it)
* debian/patches/ubuntu_revert_no_wallpaper.patch:
  - revert upstream changes to use a rgba desktop view, until the other
    components are ready for that change, see lp #1159430 for details
* debian/patches/ubuntu_sync_background_to_accountsservice.patch:
  - restore that dropped patch since we keep display the wallpaper there

[ Iain Lane ]
* debian/patches/disconnect-extra-location-widgets.patch:
  - updated for the new nautilus codebase

[ Jeremy Bicha ]
* New upstream release (LP: #1130746)
  - Share the show-hidden-files setting with the GTK file chooser
    (LP: #1039014)
  - Limit folder size and content count to a single filesystem (LP: #585472)
* debian/nautilus.install:
  - Shell search provider doesn't need a separate library any more
* Drop git patches
* Refreshed patches

[ Robert Ancell ]
* debian/control:
  - Bump build-depends on libglib2.0-dev

[ Rico Tzschichholz ]
* New upstream release
* debian/control:
  - Bump build-depends on libgtk-3-dev (>= 3.7.7)
* debian/patches:
  - 09_no-initial-fade.patch:
  - 10_sync_background_to_accountsservice.patch:
    + Dropped, Nautilus doesn't draw the background itself any more
* Refreshed patches

[ Tim Lunn ]
* Add build-dep on gsettings-desktop-schemas

[ Marco Trevisan (Treviño) ]
* debian/patches:
  - 19_unity_open_location_xid.patch: updated to apply properly

Show diffs side-by-side

added added

removed removed

Lines of Context:
175
175
        GList *list;
176
176
 
177
177
        slot = nautilus_window_get_active_slot (window);
 
178
        list = back ? nautilus_window_slot_get_back_history (slot) :
 
179
                nautilus_window_slot_get_forward_history (slot);
178
180
 
179
 
        list = back ? slot->back_list : slot->forward_list;
180
181
        index = 0;
181
182
        while (list != NULL) {
182
183
                menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list->data));
194
195
        }
195
196
}
196
197
 
 
198
/* adapted from gtk/gtkmenubutton.c */
 
199
static void
 
200
menu_position_func (GtkMenu       *menu,
 
201
                    gint          *x,
 
202
                    gint          *y,
 
203
                    gboolean      *push_in,
 
204
                    GtkWidget     *widget)
 
205
{
 
206
        GtkWidget *toplevel;
 
207
        GtkRequisition menu_req;
 
208
        GdkRectangle monitor;
 
209
        gint monitor_num;
 
210
        GdkScreen *screen;
 
211
        GdkWindow *window;
 
212
        GtkAllocation allocation;
 
213
 
 
214
        /* Set the dropdown menu hint on the toplevel, so the WM can omit the top side
 
215
         * of the shadows.
 
216
         */
 
217
        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
 
218
        gtk_window_set_type_hint (GTK_WINDOW (toplevel), GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU);
 
219
 
 
220
        window = gtk_widget_get_window (widget);
 
221
        screen = gtk_widget_get_screen (GTK_WIDGET (menu));
 
222
        monitor_num = gdk_screen_get_monitor_at_window (screen, window);
 
223
        if (monitor_num < 0) {
 
224
                monitor_num = 0;
 
225
        }
 
226
 
 
227
        gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
 
228
        gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL);
 
229
        gtk_widget_get_allocation (widget, &allocation);
 
230
        gdk_window_get_origin (window, x, y);
 
231
 
 
232
        *x += allocation.x;
 
233
        *y += allocation.y;
 
234
 
 
235
        if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
 
236
                *x -= MAX (menu_req.width - allocation.width, 0);
 
237
        } else {
 
238
                *x += MAX (allocation.width - menu_req.width, 0);
 
239
        }
 
240
 
 
241
        if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height) {
 
242
                *y += allocation.height;
 
243
        } else if ((*y - menu_req.height) >= monitor.y) {
 
244
                *y -= menu_req.height;
 
245
        } else if (monitor.y + monitor.height - (*y + allocation.height) > *y) {
 
246
                *y += allocation.height;
 
247
        } else {
 
248
                *y -= menu_req.height;
 
249
        }
 
250
 
 
251
        *push_in = FALSE;
 
252
}
 
253
 
197
254
static void
198
255
show_menu (NautilusToolbar *self,
199
 
           NautilusNavigationDirection direction,
 
256
           GtkWidget *widget,
200
257
           guint button,
201
258
           guint32 event_time)
202
259
{
203
260
        NautilusWindow *window;
204
261
        GtkWidget *menu;
 
262
        NautilusNavigationDirection direction;
205
263
 
206
264
        window = self->priv->window;
207
265
        menu = gtk_menu_new ();
208
266
 
 
267
        direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
 
268
                                                         "nav-direction"));
 
269
 
209
270
        switch (direction) {
210
271
        case NAUTILUS_NAVIGATION_DIRECTION_FORWARD:
211
272
                fill_menu (window, menu, FALSE);
218
279
                break;
219
280
        }
220
281
 
221
 
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
 
282
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
 
283
                        (GtkMenuPositionFunc) menu_position_func, widget,
222
284
                        button, event_time);
223
285
}
224
286
 
226
288
 
227
289
typedef struct {
228
290
        NautilusToolbar *self;
229
 
        NautilusNavigationDirection direction;
 
291
        GtkWidget *widget;
230
292
} ScheduleMenuData;
231
293
 
232
294
static void
240
302
{
241
303
        ScheduleMenuData *data = user_data;
242
304
 
243
 
        show_menu (data->self, data->direction,
 
305
        show_menu (data->self, data->widget,
244
306
                   1, gtk_get_current_event_time ());
245
307
 
246
308
        return FALSE;
257
319
 
258
320
static void
259
321
schedule_menu_popup_timeout (NautilusToolbar *self,
260
 
                             NautilusNavigationDirection direction)
 
322
                             GtkWidget *widget)
261
323
{
262
324
        ScheduleMenuData *data;
263
325
 
266
328
 
267
329
        data = g_slice_new0 (ScheduleMenuData);
268
330
        data->self = self;
269
 
        data->direction = direction;
 
331
        data->widget = widget;
270
332
 
271
333
        self->priv->popup_timeout_id =
272
334
                g_timeout_add_full (G_PRIORITY_DEFAULT, MENU_POPUP_TIMEOUT,
280
342
                      gpointer user_data)
281
343
{
282
344
        NautilusToolbar *self = user_data;
283
 
        NautilusNavigationDirection direction;
284
 
 
285
 
        direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button),
286
 
                                                         "nav-direction"));
287
345
 
288
346
        if (event->button == 3) {
289
347
                /* right click */
290
 
                show_menu (self, direction, event->button, event->time);
 
348
                show_menu (self, GTK_WIDGET (button), event->button, event->time);
291
349
                return TRUE;
292
350
        }
293
351
 
294
352
        if (event->button == 1) {
295
 
                schedule_menu_popup_timeout (self, direction);
 
353
                schedule_menu_popup_timeout (self, GTK_WIDGET (button));
296
354
        }
297
355
 
298
356
        return FALSE;
323
381
                          G_CALLBACK (tool_button_release_cb), self);
324
382
}
325
383
 
 
384
static gboolean
 
385
gear_menu_key_press (GtkWidget *widget,
 
386
                     GdkEventKey *event,
 
387
                     gpointer user_data)
 
388
{
 
389
        GdkModifierType mask = gtk_accelerator_get_default_mod_mask ();
 
390
 
 
391
        if ((event->state & mask) == 0 && (event->keyval == GDK_KEY_F10)) {
 
392
            gtk_menu_shell_deactivate (GTK_MENU_SHELL (widget));
 
393
            return TRUE;
 
394
        }
 
395
 
 
396
        return FALSE;
 
397
}
 
398
 
326
399
static void
327
400
nautilus_toolbar_constructed (GObject *obj)
328
401
{
434
507
        gtk_widget_set_halign (menu, GTK_ALIGN_END);
435
508
        gtk_menu_button_set_popup (GTK_MENU_BUTTON (tool_button), menu);
436
509
        gtk_actionable_set_action_name (GTK_ACTIONABLE (tool_button), "win.gear-menu");
 
510
        g_signal_connect (menu, "key-press-event", G_CALLBACK (gear_menu_key_press), self);
437
511
 
438
512
        gtk_container_add (GTK_CONTAINER (tool_item), tool_button);
439
513
        gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (tool_item));