~mitya57/ubuntu/precise/nautilus/desktop-window-fixes

« back to all changes in this revision

Viewing changes to src/nautilus-window-pane.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-16 18:53:51 UTC
  • mfrom: (1.17.16 upstream) (2.2.10 experimental)
  • Revision ID: james.westby@ubuntu.com-20110516185351-9mpn1rya1t645ixq
Tags: 1:3.0.1.1-0ubuntu1
* Resynchronize on Debian using the GNOME3 ppa work, thanks to those who
  contributed there
* Known issues:
  - the indicator-application patch needs to be updated or dropped
    (design recommended to use a normal dialog for copies so maybe drop it)
  - the indicator-appmenu export patch needs to be updated
  - desktop icons are not displayed by default in GNOME3, you can set
    org.gnome.desktop.background show-desktop-icons to true in dconf-editor
    or using the gsettings command to get those back 
* New upstream version
* Remaining diffs:
* debian/changelog, debian/rules: set epoch number (which was added by error)
* debian/control.in:
  - Build-Depend on liblaunchpad-integration-dev, libappindicator-dev
  - Don't recommends desktop-base, don't suggests tracker
* debian/mount-archive.desktop:
* debian/mount-archive.desktop.in:
  - New nautilus context menu item to allow mounting zip, iso, etc
* debian/nautilus.gschema.override:
  - Change the default desktop icon configuration
* debian/nautilus-data.install:
  - Install Apport hook
* debian/nautilus.install:
  - Install mount-archive menu
* nautilus-desktop.desktop
* debian/source_nautilus.py:
  - Apport hook to list versions of files in /usr/lib/nautilus and reassign
    the crashes when there are not due to nautilus code directly
* debian/patches/00_do_not_require_unpackage_libexif.patch:
  - dropped, not required in Ubuntu since libexif is recent enough
* debian/patches/01_lpi.patch:
  - Launchpad changes.
* debian/patches/02_additional_marge_for_unity.patch:
  - ensure we don't move desktop icons when locking or unlocking the unity
    launcher 
* debian/patches/03_translations_list_update.patch:
  - Translate the mount-archive menu entry
* debian/patches/04_suppress_umount_in_ltsp.patch:
  - Don't list unmount and eject actions on LTSP clients
* debian/patches/05_desktop_menu_export.patch:
  - export the desktop menus for appmenu (lp #624274), commented for now
* debian/patches/06_never_exec_nonexec_launchers.patch:
  - Implement non-exec policy for .desktop handler.
* debian/patches/07_use_application_indicator.patch:
  - Use the application-indicator, needs to be updated
* debian/patches/08_fix_nautilus_desktop_autostart.patch
  - git commit, remove obsolete autostart code so that Nautilus windows
    can still be opened when desktop icons are shown
* debian/patches/09_no-initial-fade.patch:
  - Patch to disable the initial fade-in of the background without disabling 
    crossfades when the background is changed.
* debian/watch:
  - Watch unstable series
* Dropped:
* debian/patches/02_dont_set_default.patch:
  - deprecated in the new version
* debian/patches/03_menu_entry.patch:
  - no menu simplication needed with unity or gnome-shell
* debian/patches/17_disable_locked_automounting.patch:
  - the change is in the new upstream version
* debian/patches/82_gnome-app-install.patch:
  - don't use gnome-app-install it's deprecated
* debian/patches/90_git_audio_preview_url.patch:
  - the change is in the new version
* debian/patches/91_correct_rgba_use.patch:
  - the gtk rgba ubuntu specific work never landed no need to keep that one
* debian/patches/97_keyboard_nav_in_sidebar.patch:
  - the change is in the new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
2
 
 
3
 
   nautilus-window-pane.c: Nautilus window pane
4
 
 
5
 
   Copyright (C) 2008 Free Software Foundation, Inc.
6
 
 
7
 
   This program is free software; you can redistribute it and/or
8
 
   modify it under the terms of the GNU General Public License as
9
 
   published by the Free Software Foundation; either version 2 of the
10
 
   License, or (at your option) any later version.
11
 
 
12
 
   This program is distributed in the hope that it will be useful,
13
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
   General Public License for more details.
16
 
 
17
 
   You should have received a copy of the GNU General Public
18
 
   License along with this program; if not, write to the
19
 
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
   Boston, MA 02111-1307, USA.
21
 
 
22
 
   Author: Holger Berndt <berndth@gmx.de>
23
 
*/
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
 
 
3
/*
 
4
 * nautilus-window-pane.c: Nautilus window pane
 
5
 *
 
6
 * Copyright (C) 2008 Free Software Foundation, Inc.
 
7
 * Copyright (C) 2011 Red Hat, Inc.
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public License as
 
11
 * published by the Free Software Foundation; either version 2 of the
 
12
 * License, or (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
 * General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public
 
20
 * License along with this program; if not, write to the
 
21
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
22
 * Boston, MA 02111-1307, USA.
 
23
 *
 
24
 * Authors: Holger Berndt <berndth@gmx.de>
 
25
 *          Cosimo Cecchi <cosimoc@redhat.com>
 
26
 *
 
27
 */
24
28
 
25
29
#include "nautilus-window-pane.h"
 
30
 
 
31
#include "nautilus-actions.h"
 
32
#include "nautilus-location-bar.h"
 
33
#include "nautilus-notebook.h"
 
34
#include "nautilus-pathbar.h"
 
35
#include "nautilus-toolbar.h"
 
36
#include "nautilus-window-manage-views.h"
26
37
#include "nautilus-window-private.h"
27
 
#include "nautilus-navigation-window-pane.h"
28
 
#include "nautilus-window-manage-views.h"
29
 
#include <eel/eel-gtk-macros.h>
30
 
 
31
 
static void nautilus_window_pane_init       (NautilusWindowPane *pane);
32
 
static void nautilus_window_pane_class_init (NautilusWindowPaneClass *class);
33
 
static void nautilus_window_pane_dispose    (GObject *object);
34
 
 
35
 
G_DEFINE_TYPE (NautilusWindowPane,
36
 
               nautilus_window_pane,
 
38
 
 
39
#include <libnautilus-private/nautilus-clipboard.h>
 
40
#include <libnautilus-private/nautilus-global-preferences.h>
 
41
#include <libnautilus-private/nautilus-entry.h>
 
42
 
 
43
G_DEFINE_TYPE (NautilusWindowPane, nautilus_window_pane,
37
44
               G_TYPE_OBJECT)
38
 
#define parent_class nautilus_window_pane_parent_class
39
 
 
 
45
 
 
46
static gboolean
 
47
widget_is_in_temporary_bars (GtkWidget *widget,
 
48
                             NautilusWindowPane *pane)
 
49
{
 
50
        gboolean res = FALSE;
 
51
 
 
52
        if ((gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_LOCATION_BAR) != NULL &&
 
53
             pane->temporary_navigation_bar) ||
 
54
            (gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_SEARCH_BAR) != NULL &&
 
55
             pane->temporary_search_bar))
 
56
                res = TRUE;
 
57
 
 
58
        return res;
 
59
}
 
60
 
 
61
static void
 
62
unset_focus_widget (NautilusWindowPane *pane)
 
63
{
 
64
        if (pane->last_focus_widget != NULL) {
 
65
                g_object_remove_weak_pointer (G_OBJECT (pane->last_focus_widget),
 
66
                                              (gpointer *) &pane->last_focus_widget);
 
67
                pane->last_focus_widget = NULL;
 
68
        }
 
69
}
 
70
 
 
71
static void
 
72
remember_focus_widget (NautilusWindowPane *pane)
 
73
{
 
74
        GtkWidget *focus_widget;
 
75
 
 
76
        focus_widget = gtk_window_get_focus (GTK_WINDOW (pane->window));
 
77
        if (focus_widget != NULL &&
 
78
            !widget_is_in_temporary_bars (focus_widget, pane)) {
 
79
                unset_focus_widget (pane);
 
80
 
 
81
                pane->last_focus_widget = focus_widget;
 
82
                g_object_add_weak_pointer (G_OBJECT (focus_widget),
 
83
                                           (gpointer *) &(pane->last_focus_widget));
 
84
        }
 
85
}
 
86
 
 
87
static void
 
88
restore_focus_widget (NautilusWindowPane *pane)
 
89
{
 
90
        if (pane->last_focus_widget != NULL) {
 
91
                if (NAUTILUS_IS_VIEW (pane->last_focus_widget)) {
 
92
                        nautilus_view_grab_focus (NAUTILUS_VIEW (pane->last_focus_widget));
 
93
                } else {
 
94
                        gtk_widget_grab_focus (pane->last_focus_widget);
 
95
                }
 
96
 
 
97
                unset_focus_widget (pane);
 
98
        }
 
99
}
40
100
 
41
101
static inline NautilusWindowSlot *
42
102
get_first_inactive_slot (NautilusWindowPane *pane)
54
114
        return NULL;
55
115
}
56
116
 
 
117
static int
 
118
bookmark_list_get_uri_index (GList *list, GFile *location)
 
119
{
 
120
        NautilusBookmark *bookmark;
 
121
        GList *l;
 
122
        GFile *tmp;
 
123
        int i;
 
124
 
 
125
        g_return_val_if_fail (location != NULL, -1);
 
126
 
 
127
        for (i = 0, l = list; l != NULL; i++, l = l->next) {
 
128
                bookmark = NAUTILUS_BOOKMARK (l->data);
 
129
 
 
130
                tmp = nautilus_bookmark_get_location (bookmark);
 
131
                if (g_file_equal (location, tmp)) {
 
132
                        g_object_unref (tmp);
 
133
                        return i;
 
134
                }
 
135
                g_object_unref (tmp);
 
136
        }
 
137
 
 
138
        return -1;
 
139
}
 
140
 
 
141
static void
 
142
search_bar_activate_callback (NautilusSearchBar *bar,
 
143
                              NautilusWindowPane *pane)
 
144
{
 
145
        char *uri, *current_uri;
 
146
        NautilusDirectory *directory;
 
147
        NautilusSearchDirectory *search_directory;
 
148
        NautilusQuery *query;
 
149
        GFile *location;
 
150
 
 
151
        uri = nautilus_search_directory_generate_new_uri ();
 
152
        location = g_file_new_for_uri (uri);
 
153
        g_free (uri);
 
154
 
 
155
        directory = nautilus_directory_get (location);
 
156
 
 
157
        g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
 
158
 
 
159
        search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
 
160
 
 
161
        query = nautilus_search_bar_get_query (NAUTILUS_SEARCH_BAR (pane->search_bar));
 
162
        if (query != NULL) {
 
163
                NautilusWindowSlot *slot = pane->active_slot;
 
164
                if (!nautilus_search_directory_is_indexed (search_directory)) {
 
165
                        current_uri = nautilus_window_slot_get_location_uri (slot);
 
166
                        nautilus_query_set_location (query, current_uri);
 
167
                        g_free (current_uri);
 
168
                }
 
169
                nautilus_search_directory_set_query (search_directory, query);
 
170
                g_object_unref (query);
 
171
        }
 
172
 
 
173
        nautilus_window_slot_go_to (pane->active_slot, location, FALSE);
 
174
 
 
175
        nautilus_directory_unref (directory);
 
176
        g_object_unref (location);
 
177
}
 
178
 
 
179
static void
 
180
nautilus_window_pane_hide_temporary_bars (NautilusWindowPane *pane)
 
181
{
 
182
        NautilusWindowSlot *slot;
 
183
        NautilusDirectory *directory;
 
184
 
 
185
        slot = pane->active_slot;
 
186
 
 
187
        if (pane->temporary_navigation_bar) {
 
188
                directory = nautilus_directory_get (slot->location);
 
189
 
 
190
                pane->temporary_navigation_bar = FALSE;
 
191
 
 
192
                /* if we're in a search directory, hide the main bar, and show the search
 
193
                 * bar again; otherwise, just hide the whole toolbar.
 
194
                 */
 
195
                if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 
196
                        nautilus_toolbar_set_show_main_bar (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
 
197
                        nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar), TRUE);
 
198
                } else {
 
199
                        gtk_widget_hide (pane->tool_bar);
 
200
                }
 
201
 
 
202
                nautilus_directory_unref (directory);
 
203
        }
 
204
}
 
205
 
 
206
static void
 
207
search_bar_cancel_callback (GtkWidget *widget,
 
208
                            NautilusWindowPane *pane)
 
209
{
 
210
        GtkAction *search;
 
211
 
 
212
        search = gtk_action_group_get_action (pane->action_group,
 
213
                                              NAUTILUS_ACTION_SEARCH);
 
214
 
 
215
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (search), FALSE);
 
216
}
 
217
 
 
218
static void
 
219
navigation_bar_cancel_callback (GtkWidget *widget,
 
220
                                NautilusWindowPane *pane)
 
221
{
 
222
        nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
 
223
 
 
224
        nautilus_window_pane_hide_temporary_bars (pane);
 
225
        restore_focus_widget (pane);
 
226
}
 
227
 
 
228
static void
 
229
nautilus_window_pane_ensure_search_bar (NautilusWindowPane *pane)
 
230
{
 
231
        remember_focus_widget (pane);
 
232
 
 
233
        nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar), TRUE);
 
234
 
 
235
        if (!g_settings_get_boolean (nautilus_window_state,
 
236
                                     NAUTILUS_WINDOW_STATE_START_WITH_TOOLBAR)) {
 
237
                nautilus_toolbar_set_show_main_bar (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
 
238
                gtk_widget_show (pane->tool_bar);
 
239
                nautilus_search_bar_clear (NAUTILUS_SEARCH_BAR (pane->search_bar));
 
240
 
 
241
                pane->temporary_search_bar = TRUE;
 
242
        }
 
243
 
 
244
        nautilus_search_bar_grab_focus (NAUTILUS_SEARCH_BAR (pane->search_bar));
 
245
}
 
246
 
 
247
static void
 
248
nautilus_window_pane_hide_search_bar (NautilusWindowPane *pane)
 
249
{
 
250
        nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
 
251
        restore_focus_widget (pane);
 
252
 
 
253
        if (pane->temporary_search_bar) {
 
254
                pane->temporary_search_bar = FALSE;
 
255
 
 
256
                gtk_widget_hide (pane->tool_bar);
 
257
        }
 
258
}
 
259
 
 
260
static void
 
261
navigation_bar_location_changed_callback (GtkWidget *widget,
 
262
                                          const char *uri,
 
263
                                          NautilusWindowPane *pane)
 
264
{
 
265
        GFile *location;
 
266
 
 
267
        nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
 
268
        nautilus_window_pane_hide_search_bar (pane);
 
269
        nautilus_window_pane_hide_temporary_bars (pane);
 
270
 
 
271
        restore_focus_widget (pane);
 
272
 
 
273
        location = g_file_new_for_uri (uri);
 
274
        nautilus_window_slot_go_to (pane->active_slot, location, FALSE);
 
275
        g_object_unref (location);
 
276
}
 
277
 
 
278
static void
 
279
path_bar_location_changed_callback (GtkWidget *widget,
 
280
                                    GFile *location,
 
281
                                    NautilusWindowPane *pane)
 
282
{
 
283
        NautilusWindowSlot *slot;
 
284
        int i;
 
285
 
 
286
        slot = pane->active_slot;
 
287
 
 
288
        /* check whether we already visited the target location */
 
289
        i = bookmark_list_get_uri_index (slot->back_list, location);
 
290
        if (i >= 0) {
 
291
                nautilus_window_back_or_forward (pane->window, TRUE, i, FALSE);
 
292
        } else {
 
293
                nautilus_window_slot_go_to (pane->active_slot, location, FALSE);
 
294
        }
 
295
}
 
296
 
 
297
static gboolean
 
298
path_bar_button_pressed_callback (GtkWidget *widget,
 
299
                                  GdkEventButton *event,
 
300
                                  NautilusWindowPane *pane)
 
301
{
 
302
        NautilusWindowSlot *slot;
 
303
        NautilusView *view;
 
304
        GFile *location;
 
305
        char *uri;
 
306
 
 
307
        g_object_set_data (G_OBJECT (widget), "handle-button-release",
 
308
                           GINT_TO_POINTER (TRUE));
 
309
 
 
310
        if (event->button == 3) {
 
311
                slot = nautilus_window_get_active_slot (pane->window);
 
312
                view = slot->content_view;
 
313
                if (view != NULL) {
 
314
                        location = nautilus_path_bar_get_path_for_button (
 
315
                                NAUTILUS_PATH_BAR (pane->path_bar), widget);
 
316
                        if (location != NULL) {
 
317
                                uri = g_file_get_uri (location);
 
318
                                nautilus_view_pop_up_location_context_menu (
 
319
                                        view, event, uri);
 
320
                                g_object_unref (G_OBJECT (location));
 
321
                                g_free (uri);
 
322
                                return TRUE;
 
323
                        }
 
324
                }
 
325
        }
 
326
 
 
327
        return FALSE;
 
328
}
 
329
 
 
330
static gboolean
 
331
path_bar_button_released_callback (GtkWidget *widget,
 
332
                                   GdkEventButton *event,
 
333
                                   NautilusWindowPane *pane)
 
334
{
 
335
        NautilusWindowSlot *slot;
 
336
        NautilusWindowOpenFlags flags;
 
337
        GFile *location;
 
338
        int mask;
 
339
        gboolean handle_button_release;
 
340
 
 
341
        mask = event->state & gtk_accelerator_get_default_mod_mask ();
 
342
        flags = 0;
 
343
 
 
344
        handle_button_release = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
 
345
                                                  "handle-button-release"));
 
346
 
 
347
        if (event->type == GDK_BUTTON_RELEASE && handle_button_release) {
 
348
                location = nautilus_path_bar_get_path_for_button (NAUTILUS_PATH_BAR (pane->path_bar), widget);
 
349
 
 
350
                if (event->button == 2 && mask == 0) {
 
351
                        flags = NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
 
352
                } else if (event->button == 1 && mask == GDK_CONTROL_MASK) {
 
353
                        flags = NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW;
 
354
                }
 
355
 
 
356
                if (flags != 0) {
 
357
                        slot = nautilus_window_get_active_slot (pane->window);
 
358
                        nautilus_window_slot_open_location (slot, location,
 
359
                                                            flags, NULL);
 
360
                        g_object_unref (location);
 
361
                        return TRUE;
 
362
                }
 
363
 
 
364
                g_object_unref (location);
 
365
        }
 
366
 
 
367
        return FALSE;
 
368
}
 
369
 
 
370
static void
 
371
path_bar_button_drag_begin_callback (GtkWidget *widget,
 
372
                                     GdkEventButton *event,
 
373
                                     gpointer user_data)
 
374
{
 
375
        g_object_set_data (G_OBJECT (widget), "handle-button-release",
 
376
                           GINT_TO_POINTER (FALSE));
 
377
}
 
378
 
 
379
static void
 
380
notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem,
 
381
                                gpointer user_data)
 
382
{
 
383
        NautilusWindowPane *pane;
 
384
 
 
385
        pane = user_data;
 
386
        nautilus_window_new_tab (pane->window);
 
387
}
 
388
 
 
389
static void
 
390
path_bar_path_set_callback (GtkWidget *widget,
 
391
                            GFile *location,
 
392
                            NautilusWindowPane *pane)
 
393
{
 
394
        GList *children, *l;
 
395
        GtkWidget *child;
 
396
 
 
397
        children = gtk_container_get_children (GTK_CONTAINER (widget));
 
398
 
 
399
        for (l = children; l != NULL; l = l->next) {
 
400
                child = GTK_WIDGET (l->data);
 
401
 
 
402
                if (!GTK_IS_TOGGLE_BUTTON (child)) {
 
403
                        continue;
 
404
                }
 
405
 
 
406
                if (!g_signal_handler_find (child,
 
407
                                            G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
 
408
                                            0, 0, NULL,
 
409
                                            path_bar_button_pressed_callback,
 
410
                                            pane)) {
 
411
                        g_signal_connect (child, "button-press-event",
 
412
                                          G_CALLBACK (path_bar_button_pressed_callback),
 
413
                                          pane);
 
414
                        g_signal_connect (child, "button-release-event",
 
415
                                          G_CALLBACK (path_bar_button_released_callback),
 
416
                                          pane);
 
417
                        g_signal_connect (child, "drag-begin",
 
418
                                          G_CALLBACK (path_bar_button_drag_begin_callback),
 
419
                                          pane);
 
420
                }
 
421
        }
 
422
 
 
423
        g_list_free (children);
 
424
}
 
425
 
 
426
static void
 
427
notebook_popup_menu_move_left_cb (GtkMenuItem *menuitem,
 
428
                                  gpointer user_data)
 
429
{
 
430
        NautilusWindowPane *pane;
 
431
 
 
432
        pane = NAUTILUS_WINDOW_PANE (user_data);
 
433
        nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), -1);
 
434
}
 
435
 
 
436
static void
 
437
notebook_popup_menu_move_right_cb (GtkMenuItem *menuitem,
 
438
                                   gpointer user_data)
 
439
{
 
440
        NautilusWindowPane *pane;
 
441
 
 
442
        pane = NAUTILUS_WINDOW_PANE (user_data);
 
443
        nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), 1);
 
444
}
 
445
 
 
446
static void
 
447
notebook_popup_menu_close_cb (GtkMenuItem *menuitem,
 
448
                              gpointer user_data)
 
449
{
 
450
        NautilusWindowPane *pane;
 
451
        NautilusWindowSlot *slot;
 
452
 
 
453
        pane = NAUTILUS_WINDOW_PANE (user_data);
 
454
        slot = pane->active_slot;
 
455
        nautilus_window_pane_slot_close (pane, slot);
 
456
}
 
457
 
 
458
static void
 
459
notebook_popup_menu_show (NautilusWindowPane *pane,
 
460
                          GdkEventButton *event)
 
461
{
 
462
        GtkWidget *popup;
 
463
        GtkWidget *item;
 
464
        GtkWidget *image;
 
465
        int button, event_time;
 
466
        gboolean can_move_left, can_move_right;
 
467
        NautilusNotebook *notebook;
 
468
 
 
469
        notebook = NAUTILUS_NOTEBOOK (pane->notebook);
 
470
 
 
471
        can_move_left = nautilus_notebook_can_reorder_current_child_relative (notebook, -1);
 
472
        can_move_right = nautilus_notebook_can_reorder_current_child_relative (notebook, 1);
 
473
 
 
474
        popup = gtk_menu_new();
 
475
 
 
476
        item = gtk_menu_item_new_with_mnemonic (_("_New Tab"));
 
477
        g_signal_connect (item, "activate",
 
478
                          G_CALLBACK (notebook_popup_menu_new_tab_cb),
 
479
                          pane);
 
480
        gtk_menu_shell_append (GTK_MENU_SHELL (popup),
 
481
                               item);
 
482
 
 
483
        gtk_menu_shell_append (GTK_MENU_SHELL (popup),
 
484
                               gtk_separator_menu_item_new ());
 
485
 
 
486
        item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left"));
 
487
        g_signal_connect (item, "activate",
 
488
                          G_CALLBACK (notebook_popup_menu_move_left_cb),
 
489
                          pane);
 
490
        gtk_menu_shell_append (GTK_MENU_SHELL (popup),
 
491
                               item);
 
492
        gtk_widget_set_sensitive (item, can_move_left);
 
493
 
 
494
        item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Right"));
 
495
        g_signal_connect (item, "activate",
 
496
                          G_CALLBACK (notebook_popup_menu_move_right_cb),
 
497
                          pane);
 
498
        gtk_menu_shell_append (GTK_MENU_SHELL (popup),
 
499
                               item);
 
500
        gtk_widget_set_sensitive (item, can_move_right);
 
501
 
 
502
        gtk_menu_shell_append (GTK_MENU_SHELL (popup),
 
503
                               gtk_separator_menu_item_new ());
 
504
 
 
505
        item = gtk_image_menu_item_new_with_mnemonic (_("_Close Tab"));
 
506
        image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
 
507
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
 
508
        g_signal_connect (item, "activate",
 
509
                          G_CALLBACK (notebook_popup_menu_close_cb), pane);
 
510
        gtk_menu_shell_append (GTK_MENU_SHELL (popup),
 
511
                               item);
 
512
 
 
513
        gtk_widget_show_all (popup);
 
514
 
 
515
        if (event) {
 
516
                button = event->button;
 
517
                event_time = event->time;
 
518
        } else {
 
519
                button = 0;
 
520
                event_time = gtk_get_current_event_time ();
 
521
        }
 
522
 
 
523
        /* TODO is this correct? */
 
524
        gtk_menu_attach_to_widget (GTK_MENU (popup),
 
525
                                   pane->notebook,
 
526
                                   NULL);
 
527
 
 
528
        gtk_menu_popup (GTK_MENU (popup), NULL, NULL, NULL, NULL,
 
529
                        button, event_time);
 
530
}
 
531
 
 
532
/* emitted when the user clicks the "close" button of tabs */
 
533
static void
 
534
notebook_tab_close_requested (NautilusNotebook *notebook,
 
535
                              NautilusWindowSlot *slot,
 
536
                              NautilusWindowPane *pane)
 
537
{
 
538
        nautilus_window_pane_slot_close (pane, slot);
 
539
}
 
540
 
 
541
static gboolean
 
542
notebook_button_press_cb (GtkWidget *widget,
 
543
                          GdkEventButton *event,
 
544
                          gpointer user_data)
 
545
{
 
546
        NautilusWindowPane *pane;
 
547
 
 
548
        pane = user_data;
 
549
        if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
 
550
                notebook_popup_menu_show (pane, event);
 
551
                return TRUE;
 
552
        }
 
553
 
 
554
        return FALSE;
 
555
}
 
556
 
 
557
static gboolean
 
558
notebook_popup_menu_cb (GtkWidget *widget,
 
559
                        gpointer user_data)
 
560
{
 
561
        NautilusWindowPane *pane;
 
562
 
 
563
        pane = user_data;
 
564
        notebook_popup_menu_show (pane, NULL);
 
565
        return TRUE;
 
566
}
 
567
 
 
568
static gboolean
 
569
notebook_switch_page_cb (GtkNotebook *notebook,
 
570
                         GtkWidget *page,
 
571
                         unsigned int page_num,
 
572
                         NautilusWindowPane *pane)
 
573
{
 
574
        NautilusWindowSlot *slot;
 
575
        GtkWidget *widget;
 
576
 
 
577
        widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (pane->notebook), page_num);
 
578
        g_assert (widget != NULL);
 
579
 
 
580
        /* find slot corresponding to the target page */
 
581
        slot = nautilus_window_pane_get_slot_for_content_box (pane, widget);
 
582
        g_assert (slot != NULL);
 
583
 
 
584
        nautilus_window_set_active_slot (slot->pane->window, slot);
 
585
 
 
586
        return FALSE;
 
587
}
 
588
 
 
589
static void
 
590
real_set_active (NautilusWindowPane *pane,
 
591
                 gboolean is_active)
 
592
{
 
593
        if (is_active) {
 
594
                nautilus_navigation_state_set_master (pane->window->details->nav_state,
 
595
                                                      pane->action_group);
 
596
        }
 
597
 
 
598
        /* toolbar */
 
599
        gtk_widget_set_sensitive (pane->tool_bar, is_active);
 
600
}
 
601
 
 
602
static void
 
603
action_show_hide_search_callback (GtkAction *action,
 
604
                                  gpointer user_data)
 
605
{
 
606
        NautilusWindowPane *pane = user_data;
 
607
        NautilusWindow *window = pane->window;
 
608
 
 
609
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
 
610
                nautilus_window_pane_ensure_search_bar (pane);
 
611
        } else {
 
612
                NautilusWindowSlot *slot;
 
613
                GFile *location = NULL;
 
614
 
 
615
                slot = pane->active_slot;
 
616
                nautilus_window_pane_hide_search_bar (pane);
 
617
 
 
618
                /* Use the location bar as the return location */
 
619
                if (slot->query_editor != NULL) {
 
620
                        NautilusQuery *query;
 
621
                        char *uri;
 
622
 
 
623
                        query = nautilus_query_editor_get_query (slot->query_editor);
 
624
                        if (query != NULL) {
 
625
                                uri = nautilus_query_get_location (query);
 
626
                                if (uri != NULL) {
 
627
                                        location = g_file_new_for_uri (uri);
 
628
                                        g_free (uri);
 
629
                                }
 
630
                                g_object_unref (query);
 
631
                        }
 
632
 
 
633
                        /* Last try: use the home directory as the return location */
 
634
                        if (location == NULL) {
 
635
                                location = g_file_new_for_path (g_get_home_dir ());
 
636
                        }
 
637
 
 
638
                        nautilus_window_go_to (window, location);
 
639
                        g_object_unref (location);
 
640
                }
 
641
        }
 
642
}
 
643
 
 
644
static void
 
645
setup_search_action (NautilusWindowPane *pane)
 
646
{
 
647
        GtkActionGroup *group = pane->action_group;
 
648
        GtkAction *action;
 
649
 
 
650
        action = gtk_action_group_get_action (group, NAUTILUS_ACTION_SEARCH);
 
651
        g_signal_connect (action, "activate",
 
652
                          G_CALLBACK (action_show_hide_search_callback), pane);
 
653
}
 
654
 
 
655
static void
 
656
nautilus_window_pane_setup (NautilusWindowPane *pane)
 
657
{
 
658
        GtkSizeGroup *header_size_group;
 
659
        NautilusWindow *window;
 
660
        GtkActionGroup *action_group;
 
661
 
 
662
        pane->widget = gtk_vbox_new (FALSE, 0);
 
663
        window = pane->window;
 
664
 
 
665
        header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
 
666
        gtk_size_group_set_ignore_hidden (header_size_group, FALSE);
 
667
 
 
668
        /* build the toolbar */
 
669
        action_group = nautilus_window_create_toolbar_action_group (window);
 
670
        pane->tool_bar = nautilus_toolbar_new (action_group);
 
671
        pane->action_group = action_group;
 
672
 
 
673
        setup_search_action (pane);
 
674
 
 
675
        gtk_box_pack_start (GTK_BOX (pane->widget),
 
676
                            pane->tool_bar,
 
677
                            FALSE, FALSE, 0);
 
678
 
 
679
        g_settings_bind_with_mapping (nautilus_window_state,
 
680
                                      NAUTILUS_WINDOW_STATE_START_WITH_TOOLBAR,
 
681
                                      pane->tool_bar,
 
682
                                      "visible",
 
683
                                      G_SETTINGS_BIND_GET,
 
684
                                      nautilus_window_disable_chrome_mapping, NULL,
 
685
                                      window, NULL);
 
686
 
 
687
        /* connect to the pathbar signals */
 
688
        pane->path_bar = nautilus_toolbar_get_path_bar (NAUTILUS_TOOLBAR (pane->tool_bar));
 
689
        gtk_size_group_add_widget (header_size_group, pane->path_bar);
 
690
 
 
691
        g_signal_connect_object (pane->path_bar, "path-clicked",
 
692
                                 G_CALLBACK (path_bar_location_changed_callback), pane, 0);
 
693
        g_signal_connect_object (pane->path_bar, "path-set",
 
694
                                 G_CALLBACK (path_bar_path_set_callback), pane, 0);
 
695
 
 
696
        /* connect to the location bar signals */
 
697
        pane->location_bar = nautilus_toolbar_get_location_bar (NAUTILUS_TOOLBAR (pane->tool_bar));
 
698
        gtk_size_group_add_widget (header_size_group, pane->location_bar);
 
699
 
 
700
        nautilus_clipboard_set_up_editable
 
701
                (GTK_EDITABLE (nautilus_location_bar_get_entry (NAUTILUS_LOCATION_BAR (pane->location_bar))),
 
702
                 nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)),
 
703
                 TRUE);
 
704
 
 
705
        g_signal_connect_object (pane->location_bar, "location-changed",
 
706
                                 G_CALLBACK (navigation_bar_location_changed_callback), pane, 0);
 
707
        g_signal_connect_object (pane->location_bar, "cancel",
 
708
                                 G_CALLBACK (navigation_bar_cancel_callback), pane, 0);
 
709
 
 
710
        /* connect to the search bar signals */
 
711
        pane->search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar));
 
712
        gtk_size_group_add_widget (header_size_group, pane->search_bar);
 
713
 
 
714
        g_signal_connect_object (pane->search_bar, "activate",
 
715
                                 G_CALLBACK (search_bar_activate_callback), pane, 0);
 
716
        g_signal_connect_object (pane->search_bar, "cancel",
 
717
                                 G_CALLBACK (search_bar_cancel_callback), pane, 0);
 
718
 
 
719
        /* initialize the notebook */
 
720
        pane->notebook = g_object_new (NAUTILUS_TYPE_NOTEBOOK, NULL);
 
721
        gtk_box_pack_start (GTK_BOX (pane->widget), pane->notebook,
 
722
                            TRUE, TRUE, 0);
 
723
        g_signal_connect (pane->notebook,
 
724
                          "tab-close-request",
 
725
                          G_CALLBACK (notebook_tab_close_requested),
 
726
                          pane);
 
727
        g_signal_connect_after (pane->notebook,
 
728
                                "button_press_event",
 
729
                                G_CALLBACK (notebook_button_press_cb),
 
730
                                pane);
 
731
        g_signal_connect (pane->notebook, "popup-menu",
 
732
                          G_CALLBACK (notebook_popup_menu_cb),
 
733
                          pane);
 
734
        g_signal_connect (pane->notebook,
 
735
                          "switch-page",
 
736
                          G_CALLBACK (notebook_switch_page_cb),
 
737
                          pane);
 
738
 
 
739
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (pane->notebook), FALSE);
 
740
        gtk_notebook_set_show_border (GTK_NOTEBOOK (pane->notebook), FALSE);
 
741
        gtk_widget_show (pane->notebook);
 
742
        gtk_container_set_border_width (GTK_CONTAINER (pane->notebook), 0);
 
743
 
 
744
        /* start as non-active */
 
745
        real_set_active (pane, FALSE);
 
746
 
 
747
        /* Ensure that the view has some minimal size and that other parts
 
748
         * of the UI (like location bar and tabs) don't request more and
 
749
         * thus affect the default position of the split view paned.
 
750
         */
 
751
        gtk_widget_set_size_request (pane->widget, 60, 60);
 
752
 
 
753
        /* we can unref the size group now */
 
754
        g_object_unref (header_size_group);
 
755
}
 
756
 
 
757
static void
 
758
nautilus_window_pane_dispose (GObject *object)
 
759
{
 
760
        NautilusWindowPane *pane = NAUTILUS_WINDOW_PANE (object);
 
761
 
 
762
        unset_focus_widget (pane);
 
763
 
 
764
        pane->window = NULL;
 
765
        gtk_widget_destroy (pane->widget);
 
766
        g_clear_object (&pane->action_group);
 
767
 
 
768
        g_assert (pane->slots == NULL);
 
769
 
 
770
        G_OBJECT_CLASS (nautilus_window_pane_parent_class)->dispose (object);
 
771
}
 
772
 
 
773
static void
 
774
nautilus_window_pane_class_init (NautilusWindowPaneClass *klass)
 
775
{
 
776
        GObjectClass *oclass = G_OBJECT_CLASS (klass);
 
777
 
 
778
        oclass->dispose = nautilus_window_pane_dispose;
 
779
}
 
780
 
 
781
static void
 
782
nautilus_window_pane_init (NautilusWindowPane *pane)
 
783
{
 
784
        pane->slots = NULL;
 
785
        pane->active_slot = NULL;
 
786
        pane->is_active = FALSE;
 
787
}
 
788
 
 
789
NautilusWindowPane *
 
790
nautilus_window_pane_new (NautilusWindow *window)
 
791
{
 
792
        NautilusWindowPane *pane;
 
793
 
 
794
        pane = g_object_new (NAUTILUS_TYPE_WINDOW_PANE, NULL);
 
795
        pane->window = window;
 
796
 
 
797
        nautilus_window_pane_setup (pane);
 
798
        
 
799
        return pane;
 
800
}
 
801
 
 
802
NautilusWindowSlot *
 
803
nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane,
 
804
                                               GtkWidget *content_box)
 
805
{
 
806
        NautilusWindowSlot *slot;
 
807
        GList *l;
 
808
 
 
809
        for (l = pane->slots; l != NULL; l = l->next) {
 
810
                slot = NAUTILUS_WINDOW_SLOT (l->data);
 
811
 
 
812
                if (slot->content_box == content_box) {
 
813
                        return slot;
 
814
                }
 
815
        }
 
816
        return NULL;
 
817
}
 
818
 
 
819
void
 
820
nautilus_window_pane_set_active (NautilusWindowPane *pane,
 
821
                                 gboolean is_active)
 
822
{
 
823
        NautilusView *view;
 
824
 
 
825
        if (is_active == pane->is_active) {
 
826
                return;
 
827
        }
 
828
 
 
829
        pane->is_active = is_active;
 
830
 
 
831
        /* notify the current view about its activity state */
 
832
        if (pane->active_slot != NULL) {
 
833
                view = nautilus_window_slot_get_current_view (pane->active_slot);
 
834
                nautilus_view_set_is_active (view, is_active);
 
835
        }
 
836
 
 
837
        real_set_active (pane, is_active);
 
838
}
 
839
 
57
840
void
58
841
nautilus_window_pane_show (NautilusWindowPane *pane)
59
842
{
60
843
        pane->visible = TRUE;
61
 
        EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
62
 
                         show, (pane));
63
 
}
64
 
 
65
 
void
66
 
nautilus_window_pane_zoom_in (NautilusWindowPane *pane)
67
 
{
68
 
        NautilusWindowSlot *slot;
69
 
 
70
 
        g_assert (pane != NULL);
71
 
 
72
 
        nautilus_window_set_active_pane (pane->window, pane);
73
 
 
74
 
        slot = pane->active_slot;
75
 
        if (slot->content_view != NULL) {
76
 
                nautilus_view_bump_zoom_level (slot->content_view, 1);
77
 
        }
78
 
}
79
 
 
80
 
void
81
 
nautilus_window_pane_zoom_to_level (NautilusWindowPane *pane,
82
 
                               NautilusZoomLevel level)
83
 
{
84
 
        NautilusWindowSlot *slot;
85
 
 
86
 
        g_assert (pane != NULL);
87
 
 
88
 
        nautilus_window_set_active_pane (pane->window, pane);
89
 
 
90
 
        slot = pane->active_slot;
91
 
        if (slot->content_view != NULL) {
92
 
                nautilus_view_zoom_to_level (slot->content_view, level);
93
 
        }
94
 
}
95
 
 
96
 
void
97
 
nautilus_window_pane_zoom_out (NautilusWindowPane *pane)
98
 
{
99
 
        NautilusWindowSlot *slot;
100
 
 
101
 
        g_assert (pane != NULL);
102
 
 
103
 
        nautilus_window_set_active_pane (pane->window, pane);
104
 
 
105
 
        slot = pane->active_slot;
106
 
        if (slot->content_view != NULL) {
107
 
                nautilus_view_bump_zoom_level (slot->content_view, -1);
108
 
        }
109
 
}
110
 
 
111
 
void
112
 
nautilus_window_pane_zoom_to_default (NautilusWindowPane *pane)
113
 
{
114
 
        NautilusWindowSlot *slot;
115
 
 
116
 
        g_assert (pane != NULL);
117
 
 
118
 
        nautilus_window_set_active_pane (pane->window, pane);
119
 
 
120
 
        slot = pane->active_slot;
121
 
        if (slot->content_view != NULL) {
122
 
                nautilus_view_restore_default_zoom_level (slot->content_view);
123
 
        }
124
 
}
125
 
 
126
 
void
127
 
nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSlot *slot)
 
844
        gtk_widget_show (pane->widget);
 
845
}
 
846
 
 
847
void
 
848
nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
 
849
{
 
850
        NautilusWindowSlot *slot, *active_slot;
 
851
 
 
852
        slot = pane->active_slot;
 
853
 
 
854
        nautilus_window_pane_hide_temporary_bars (pane);
 
855
 
 
856
        /* Change the location bar and path bar to match the current location. */
 
857
        if (slot->location != NULL) {
 
858
                char *uri;
 
859
 
 
860
                /* this may be NULL if we just created the slot */
 
861
                uri = nautilus_window_slot_get_location_uri (slot);
 
862
                nautilus_location_bar_set_location (NAUTILUS_LOCATION_BAR (pane->location_bar), uri);
 
863
                g_free (uri);
 
864
                nautilus_path_bar_set_path (NAUTILUS_PATH_BAR (pane->path_bar), slot->location);
 
865
        }
 
866
 
 
867
        /* Update window global UI if this is the active pane */
 
868
        if (pane == pane->window->details->active_pane) {
 
869
                nautilus_window_update_up_button (pane->window);
 
870
 
 
871
                /* Check if the back and forward buttons need enabling or disabling. */
 
872
                active_slot = pane->window->details->active_pane->active_slot;
 
873
                nautilus_window_allow_back (pane->window,
 
874
                                            active_slot->back_list != NULL);
 
875
                nautilus_window_allow_forward (pane->window,
 
876
                                               active_slot->forward_list != NULL);
 
877
        }
 
878
}
 
879
 
 
880
static void
 
881
toggle_toolbar_search_button (NautilusWindowPane *pane)
 
882
{
 
883
        GtkActionGroup *group;
 
884
        GtkAction *action;
 
885
 
 
886
        group = pane->action_group;
 
887
        action = gtk_action_group_get_action (group, NAUTILUS_ACTION_SEARCH);
 
888
 
 
889
        g_signal_handlers_block_by_func (action,
 
890
                                         action_show_hide_search_callback, pane);
 
891
        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
 
892
        g_signal_handlers_unblock_by_func (action,
 
893
                                           action_show_hide_search_callback, pane);     
 
894
}
 
895
 
 
896
void
 
897
nautilus_window_pane_sync_search_widgets (NautilusWindowPane *pane)
 
898
{
 
899
        NautilusWindowSlot *slot;
 
900
        NautilusDirectory *directory;
 
901
        NautilusSearchDirectory *search_directory;
 
902
 
 
903
        slot = pane->active_slot;
 
904
        search_directory = NULL;
 
905
 
 
906
        directory = nautilus_directory_get (slot->location);
 
907
        if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 
908
                search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
 
909
        }
 
910
 
 
911
        if (search_directory != NULL) {
 
912
                if (!nautilus_search_directory_is_saved_search (search_directory)) {
 
913
                        nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar), TRUE);
 
914
                        pane->temporary_search_bar = FALSE;
 
915
                } else {
 
916
                        toggle_toolbar_search_button (pane);
 
917
                }
 
918
        } else {
 
919
                search_bar_cancel_callback (pane->search_bar, pane);
 
920
        }
 
921
 
 
922
        nautilus_directory_unref (directory);
 
923
}
 
924
 
 
925
void
 
926
nautilus_window_pane_slot_close (NautilusWindowPane *pane,
 
927
                                 NautilusWindowSlot *slot)
128
928
{
129
929
        NautilusWindowSlot *next_slot;
130
930
 
131
931
        if (pane->window) {
132
932
                NautilusWindow *window;
 
933
 
133
934
                window = pane->window;
 
935
 
134
936
                if (pane->active_slot == slot) {
135
 
                        g_assert (pane->active_slots != NULL);
136
 
                        g_assert (pane->active_slots->data == slot);
137
 
 
138
 
                        next_slot = NULL;
139
 
                        if (pane->active_slots->next != NULL) {
140
 
                                next_slot = NAUTILUS_WINDOW_SLOT (pane->active_slots->next->data);
141
 
                        }
142
 
 
143
 
                        if (next_slot == NULL) {
144
 
                                next_slot = get_first_inactive_slot (NAUTILUS_WINDOW_PANE (pane));
145
 
                        }
146
 
 
 
937
                        next_slot = get_first_inactive_slot (NAUTILUS_WINDOW_PANE (pane));
147
938
                        nautilus_window_set_active_slot (window, next_slot);
148
939
                }
 
940
 
149
941
                nautilus_window_close_slot (slot);
150
942
 
151
943
                /* If that was the last slot in the active pane, close the pane or even the whole window. */
156
948
                        /* If next_pane is non-NULL, we have more than one pane available. In this
157
949
                         * case, close the current pane and switch to the next one. If there is
158
950
                         * no next pane, close the window. */
159
 
                        if(next_pane) {
160
 
                                nautilus_window_close_pane (pane);
161
 
                                nautilus_window_pane_switch_to (next_pane);
162
 
                                if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
163
 
                                        nautilus_navigation_window_update_show_hide_menu_items (NAUTILUS_NAVIGATION_WINDOW (window));
164
 
                                }
 
951
                        if (next_pane) {
 
952
                                nautilus_window_set_active_pane (window, next_pane);
 
953
                                nautilus_window_split_view_off (window);
165
954
                        } else {
166
955
                                nautilus_window_close (window);
167
956
                        }
169
958
        }
170
959
}
171
960
 
172
 
static void
173
 
real_sync_location_widgets (NautilusWindowPane *pane)
174
 
{
175
 
        NautilusWindowSlot *slot;
176
 
 
177
 
        /* TODO: Would be nice with a real subclass for spatial panes */
178
 
        g_assert (NAUTILUS_IS_SPATIAL_WINDOW (pane->window));
179
 
 
180
 
        slot = pane->active_slot;
181
 
 
182
 
        /* Change the location button to match the current location. */
183
 
        nautilus_spatial_window_set_location_button (NAUTILUS_SPATIAL_WINDOW (pane->window),
184
 
                                                     slot->location);
185
 
}
186
 
 
187
 
 
188
 
void
189
 
nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
190
 
{
191
 
        EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
192
 
                         sync_location_widgets, (pane));
193
 
}
194
 
 
195
 
void
196
 
nautilus_window_pane_sync_search_widgets (NautilusWindowPane *pane)
197
 
{
198
 
        g_assert (NAUTILUS_IS_WINDOW_PANE (pane));
199
 
 
200
 
        EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
201
 
                         sync_search_widgets, (pane));
202
 
}
203
 
 
204
961
void
205
962
nautilus_window_pane_grab_focus (NautilusWindowPane *pane)
206
963
{
210
967
}
211
968
 
212
969
void
213
 
nautilus_window_pane_switch_to (NautilusWindowPane *pane)
214
 
{
215
 
        nautilus_window_pane_grab_focus (pane);
216
 
}
217
 
 
218
 
static void
219
 
nautilus_window_pane_init (NautilusWindowPane *pane)
220
 
{
221
 
        pane->slots = NULL;
222
 
        pane->active_slots = NULL;
223
 
        pane->active_slot = NULL;
224
 
        pane->is_active = FALSE;
225
 
}
226
 
 
227
 
void
228
 
nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_active)
229
 
{
230
 
        if (is_active == pane->is_active) {
231
 
                return;
232
 
        }
233
 
 
234
 
        pane->is_active = is_active;
235
 
 
236
 
        /* notify the current slot about its activity state (so that it can e.g. modify the bg color) */
237
 
        nautilus_window_slot_is_in_active_pane (pane->active_slot, is_active);
238
 
 
239
 
        EEL_CALL_METHOD (NAUTILUS_WINDOW_PANE_CLASS, pane,
240
 
                         set_active, (pane, is_active));
241
 
}
242
 
 
243
 
static void
244
 
nautilus_window_pane_class_init (NautilusWindowPaneClass *class)
245
 
{
246
 
        G_OBJECT_CLASS (class)->dispose = nautilus_window_pane_dispose;
247
 
        NAUTILUS_WINDOW_PANE_CLASS (class)->sync_location_widgets = real_sync_location_widgets;
248
 
}
249
 
 
250
 
static void
251
 
nautilus_window_pane_dispose (GObject *object)
252
 
{
253
 
        NautilusWindowPane *pane = NAUTILUS_WINDOW_PANE (object);
254
 
 
255
 
        g_assert (pane->slots == NULL);
256
 
 
257
 
        pane->window = NULL;
258
 
        G_OBJECT_CLASS (parent_class)->dispose (object);
259
 
}
260
 
 
261
 
NautilusWindowPane *
262
 
nautilus_window_pane_new (NautilusWindow *window)
263
 
{
264
 
        NautilusWindowPane *pane;
265
 
 
266
 
        pane = g_object_new (NAUTILUS_TYPE_WINDOW_PANE, NULL);
267
 
        pane->window = window;
268
 
        return pane;
269
 
}
270
 
 
271
 
NautilusWindowSlot *
272
 
nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane,
273
 
                                               GtkWidget *content_box)
274
 
{
275
 
        NautilusWindowSlot *slot;
276
 
        GList *l;
277
 
 
278
 
        for (l = pane->slots; l != NULL; l = l->next) {
279
 
                slot = NAUTILUS_WINDOW_SLOT (l->data);
280
 
 
281
 
                if (slot->content_box == content_box) {
282
 
                        return slot;
283
 
                }
284
 
        }
285
 
        return NULL;
 
970
nautilus_window_pane_ensure_location_bar (NautilusWindowPane *pane)
 
971
{
 
972
        remember_focus_widget (pane);
 
973
 
 
974
        nautilus_toolbar_set_show_main_bar (NAUTILUS_TOOLBAR (pane->tool_bar), TRUE);
 
975
        nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (pane->tool_bar), TRUE);
 
976
 
 
977
        if (!g_settings_get_boolean (nautilus_window_state,
 
978
                                     NAUTILUS_WINDOW_STATE_START_WITH_TOOLBAR)) {
 
979
                gtk_widget_show (pane->tool_bar);
 
980
                pane->temporary_navigation_bar = TRUE;
 
981
        }
 
982
 
 
983
        nautilus_location_bar_activate
 
984
                (NAUTILUS_LOCATION_BAR (pane->location_bar));
 
985
}
 
986
 
 
987
void
 
988
nautilus_window_pane_add_slot_in_tab (NautilusWindowPane *pane,
 
989
                                      NautilusWindowSlot *slot,
 
990
                                      NautilusWindowOpenSlotFlags flags)
 
991
{
 
992
        NautilusNotebook *notebook;
 
993
 
 
994
        notebook = NAUTILUS_NOTEBOOK (pane->notebook);
 
995
        g_signal_handlers_block_by_func (notebook,
 
996
                                         G_CALLBACK (notebook_switch_page_cb),
 
997
                                         pane);
 
998
        nautilus_notebook_add_tab (notebook,
 
999
                                   slot,
 
1000
                                   (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ?
 
1001
                                   -1 :
 
1002
                                   gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) + 1,
 
1003
                                   FALSE);
 
1004
        g_signal_handlers_unblock_by_func (notebook,
 
1005
                                           G_CALLBACK (notebook_switch_page_cb),
 
1006
                                           pane);
 
1007
}
 
1008
 
 
1009
void
 
1010
nautilus_window_pane_remove_page (NautilusWindowPane *pane,
 
1011
                                  int page_num)
 
1012
{
 
1013
        GtkNotebook *notebook;
 
1014
        notebook = GTK_NOTEBOOK (pane->notebook);
 
1015
 
 
1016
        g_signal_handlers_block_by_func (notebook,
 
1017
                                         G_CALLBACK (notebook_switch_page_cb),
 
1018
                                         pane);
 
1019
        gtk_notebook_remove_page (notebook, page_num);
 
1020
        g_signal_handlers_unblock_by_func (notebook,
 
1021
                                           G_CALLBACK (notebook_switch_page_cb),
 
1022
                                           pane);
286
1023
}