void
caja_navigation_window_pane_set_bar_mode (CajaNavigationWindowPane *pane,
        CajaBarMode mode)
{
    gboolean use_entry;
    GtkWidget *focus_widget;
    CajaNavigationWindow *window;

    switch (mode)
    {

    case CAJA_BAR_PATH:
        gtk_widget_show (pane->path_bar);
        gtk_widget_hide (pane->navigation_bar);
        gtk_widget_hide (pane->search_bar);
        break;

    case CAJA_BAR_NAVIGATION:
        gtk_widget_show (pane->navigation_bar);
        gtk_widget_hide (pane->path_bar);
        gtk_widget_hide (pane->search_bar);
        break;

    case CAJA_BAR_SEARCH:
        gtk_widget_show (pane->search_bar);
        gtk_widget_hide (pane->path_bar);
        gtk_widget_hide (pane->navigation_bar);
        break;
    }
    
    if (mode == CAJA_BAR_NAVIGATION || mode == CAJA_BAR_PATH) {
        use_entry = (mode == CAJA_BAR_NAVIGATION);

        g_signal_handlers_block_by_func (pane->location_button,
                         G_CALLBACK (location_button_toggled_cb),
                         pane);
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pane->location_button),
                          use_entry);
        g_signal_handlers_unblock_by_func (pane->location_button,
                           G_CALLBACK (location_button_toggled_cb),
                           pane);
    }

    window = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window);
    focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
    if (focus_widget != NULL && !caja_navigation_window_is_in_temporary_navigation_bar (focus_widget, window) &&
            !caja_navigation_window_is_in_temporary_search_bar (focus_widget, window))
    {
        if (mode == CAJA_BAR_NAVIGATION || mode == CAJA_BAR_PATH)
        {
            caja_navigation_window_set_search_button (window, FALSE);
        }
        else
        {
            caja_navigation_window_set_search_button (window, TRUE);
        }
    }
}
static void
notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem,
    			gpointer user_data)
{
    CajaWindowPane *pane;

    pane = CAJA_WINDOW_PANE (user_data);
    caja_window_new_tab (pane->window);
}
static void
navigation_bar_cancel_callback (GtkWidget *widget,
                                CajaNavigationWindowPane *pane)
{
    if (caja_navigation_window_pane_hide_temporary_bars (pane))
    {
        caja_navigation_window_restore_focus_widget (CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window));
    }
}
void
caja_navigation_window_pane_show_location_bar (CajaNavigationWindowPane *pane, gboolean save_preference)
{
    gtk_widget_show(pane->location_bar);
    caja_navigation_window_update_show_hide_menu_items(CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window));
    if (save_preference)
    {
        g_settings_set_boolean (caja_window_state, CAJA_WINDOW_STATE_START_WITH_LOCATION_BAR, TRUE);
    }
}
static void
notebook_popup_menu_close_cb (GtkMenuItem *menuitem,
                              gpointer user_data)
{
    CajaWindowPane *pane;
    CajaWindowSlot *slot;

    pane = CAJA_WINDOW_PANE (user_data);
    slot = pane->active_slot;
    caja_window_slot_close (slot);
}
static void
search_bar_activate_callback (CajaSearchBar *bar,
                              CajaNavigationWindowPane *pane)
{
    char *uri, *current_uri;
    CajaDirectory *directory;
    CajaSearchDirectory *search_directory;
    CajaQuery *query;
    GFile *location;

    uri = caja_search_directory_generate_new_uri ();
    location = g_file_new_for_uri (uri);
    g_free (uri);

    directory = caja_directory_get (location);

    g_assert (CAJA_IS_SEARCH_DIRECTORY (directory));

    search_directory = CAJA_SEARCH_DIRECTORY (directory);

    query = caja_search_bar_get_query (CAJA_SEARCH_BAR (pane->search_bar));
    if (query != NULL)
    {
        CajaWindowSlot *slot = CAJA_WINDOW_PANE (pane)->active_slot;
        if (!caja_search_directory_is_indexed (search_directory))
        {
            current_uri = caja_window_slot_get_location_uri (slot);
            caja_query_set_location (query, current_uri);
            g_free (current_uri);
        }
        caja_search_directory_set_query (search_directory, query);
        g_object_unref (query);
    }

    caja_window_slot_go_to (CAJA_WINDOW_PANE (pane)->active_slot, location, FALSE);

    caja_directory_unref (directory);
    g_object_unref (location);
}
static gboolean
path_bar_button_pressed_callback (GtkWidget *widget,
                                  GdkEventButton *event,
                                  CajaNavigationWindowPane *pane)
{
    CajaWindowSlot *slot;
    CajaView *view;
    GFile *location;
    char *uri;

    caja_window_set_active_pane (CAJA_WINDOW_PANE (pane)->window, CAJA_WINDOW_PANE (pane));

    g_object_set_data (G_OBJECT (widget), "handle-button-release",
                       GINT_TO_POINTER (TRUE));

    if (event->button == 3)
    {
        slot = caja_window_get_active_slot (CAJA_WINDOW_PANE (pane)->window);
        view = slot->content_view;
        if (view != NULL)
        {
            location = caja_path_bar_get_path_for_button (
                           CAJA_PATH_BAR (pane->path_bar), widget);
            if (location != NULL)
            {
                uri = g_file_get_uri (location);
                caja_view_pop_up_location_context_menu (
                    view, event, uri);
                g_object_unref (G_OBJECT (location));
                g_free (uri);
                return TRUE;
            }
        }
    }

    return FALSE;
}
예제 #8
0
static void
caja_window_slot_active (CajaWindowSlot *slot)
{
    CajaWindow *window;
    CajaWindowPane *pane;

    g_assert (CAJA_IS_WINDOW_SLOT (slot));

    pane = CAJA_WINDOW_PANE (slot->pane);
    window = CAJA_WINDOW (slot->pane->window);
    g_assert (g_list_find (pane->slots, slot) != NULL);
    g_assert (slot == window->details->active_pane->active_slot);

    EEL_CALL_METHOD (CAJA_WINDOW_SLOT_CLASS, slot,
                     active, (slot));
}
static gboolean
path_bar_button_released_callback (GtkWidget *widget,
                                   GdkEventButton *event,
                                   CajaNavigationWindowPane *pane)
{
    CajaWindowSlot *slot;
    CajaWindowOpenFlags flags;
    GFile *location;
    int mask;
    gboolean handle_button_release;

    mask = event->state & gtk_accelerator_get_default_mod_mask ();
    flags = 0;

    handle_button_release = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
                            "handle-button-release"));

    if (event->type == GDK_BUTTON_RELEASE && handle_button_release)
    {
        location = caja_path_bar_get_path_for_button (CAJA_PATH_BAR (pane->path_bar), widget);

        if (event->button == 2 && mask == 0)
        {
            flags = CAJA_WINDOW_OPEN_FLAG_NEW_TAB;
        }
        else if (event->button == 1 && mask == GDK_CONTROL_MASK)
        {
            flags = CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW;
        }

        if (flags != 0)
        {
            slot = caja_window_get_active_slot (CAJA_WINDOW_PANE (pane)->window);
            caja_window_slot_info_open_location (slot, location,
                                                 CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
                                                 flags, NULL);
            g_object_unref (location);
            return TRUE;
        }

        g_object_unref (location);
    }

    return FALSE;
}
예제 #10
0
static gboolean
notebook_switch_page_cb (GtkNotebook *notebook,
                         GtkWidget *page,
                         unsigned int page_num,
                         CajaNavigationWindowPane *pane)
{
    CajaWindowSlot *slot;
    GtkWidget *widget;

    widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (pane->notebook), page_num);
    g_assert (widget != NULL);

    /* find slot corresponding to the target page */
    slot = caja_window_pane_get_slot_for_content_box (CAJA_WINDOW_PANE (pane), widget);
    g_assert (slot != NULL);

    caja_window_set_active_slot (slot->pane->window, slot);
    
    caja_window_slot_update_icon (slot);

    return FALSE;
}
예제 #11
0
static void
caja_navigation_window_init (CajaNavigationWindow *window)
{
    GtkUIManager *ui_manager;
    GtkWidget *toolbar;
    CajaWindow *win;
    CajaNavigationWindowPane *pane;
    GtkWidget *hpaned;
    GtkWidget *vbox;

    win = CAJA_WINDOW (window);

    window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, CAJA_TYPE_NAVIGATION_WINDOW, CajaNavigationWindowDetails);

    pane = caja_navigation_window_pane_new (win);
    win->details->panes = g_list_prepend (win->details->panes, pane);

    window->details->header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
    gtk_size_group_set_ignore_hidden (window->details->header_size_group, FALSE);

#if GTK_CHECK_VERSION(3, 0, 0)
    window->details->content_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
#else
    window->details->content_paned = gtk_hpaned_new ();
#endif
    gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table),
                      window->details->content_paned,
                      /* X direction */                   /* Y direction */
                      0, 1,                               3, 4,
                      GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_EXPAND | GTK_FILL | GTK_SHRINK,
                      0,                                  0);
    gtk_widget_show (window->details->content_paned);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_paned_pack2 (GTK_PANED (window->details->content_paned), vbox,
    		     TRUE, FALSE);
    gtk_widget_show (vbox);

#if GTK_CHECK_VERSION(3, 0, 0)    
    hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
#else
    hpaned = gtk_hpaned_new ();
#endif
    gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
    gtk_widget_show (hpaned);
    window->details->split_view_hpane = hpaned;

    gtk_box_pack_start (GTK_BOX (vbox), win->details->statusbar, FALSE, FALSE, 0);
    gtk_widget_show (win->details->statusbar);

    caja_navigation_window_pane_setup (pane);

    gtk_paned_pack1 (GTK_PANED(hpaned), pane->widget, TRUE, FALSE);
    gtk_widget_show (pane->widget);

    /* this has to be done after the location bar has been set up,
     * but before menu stuff is being called */
    caja_window_set_active_pane (win, CAJA_WINDOW_PANE (pane));

    caja_navigation_window_initialize_actions (window);

    caja_navigation_window_initialize_menus (window);

    ui_manager = caja_window_get_ui_manager (CAJA_WINDOW (window));
    toolbar = gtk_ui_manager_get_widget (ui_manager, "/Toolbar");
#if GTK_CHECK_VERSION(3, 0, 0)
    gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
#endif
    window->details->toolbar = toolbar;
    gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table),
                      toolbar,
                      /* X direction */                   /* Y direction */
                      0, 1,                               1, 2,
                      GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0,
                      0,                                  0);
    gtk_widget_show (toolbar);

    caja_navigation_window_initialize_toolbars (window);

    /* Set initial sensitivity of some buttons & menu items
     * now that they're all created.
     */
    caja_navigation_window_allow_back (window, FALSE);
    caja_navigation_window_allow_forward (window, FALSE);

    g_signal_connect_swapped (caja_preferences,
                              "changed::" CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY,
                              G_CALLBACK(always_use_location_entry_changed),
                              window);

    g_signal_connect_swapped (caja_preferences,
                              "changed::" CAJA_PREFERENCES_ALWAYS_USE_BROWSER,
                              G_CALLBACK(always_use_browser_changed),
                              window);
}
예제 #12
0
void
caja_navigation_window_pane_setup (CajaNavigationWindowPane *pane)
{
    GtkWidget *hbox;
    CajaEntry *entry;
    GtkSizeGroup *header_size_group;

    pane->widget = gtk_vbox_new (FALSE, 0);

    hbox = gtk_hbox_new (FALSE, 12);
    pane->location_bar = hbox;
    gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
    gtk_box_pack_start (GTK_BOX (pane->widget), hbox,
                        FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    /* the header size group ensures that the location bar has the same height as the sidebar header */
    header_size_group = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window)->details->header_size_group;
    gtk_size_group_add_widget (header_size_group, pane->location_bar);

    pane->location_button = location_button_create (pane);
    gtk_box_pack_start (GTK_BOX (hbox), pane->location_button, FALSE, FALSE, 0);
    gtk_widget_show (pane->location_button);

    pane->path_bar = g_object_new (CAJA_TYPE_PATH_BAR, NULL);
    gtk_widget_show (pane->path_bar);

    g_signal_connect_object (pane->path_bar, "path_clicked",
                             G_CALLBACK (path_bar_location_changed_callback), pane, 0);
    g_signal_connect_object (pane->path_bar, "path_set",
                             G_CALLBACK (path_bar_path_set_callback), pane, 0);

    gtk_box_pack_start (GTK_BOX (hbox),
                        pane->path_bar,
                        TRUE, TRUE, 0);

    pane->navigation_bar = caja_location_bar_new (pane);
    g_signal_connect_object (pane->navigation_bar, "location_changed",
                             G_CALLBACK (navigation_bar_location_changed_callback), pane, 0);
    g_signal_connect_object (pane->navigation_bar, "cancel",
                             G_CALLBACK (navigation_bar_cancel_callback), pane, 0);
    entry = caja_location_bar_get_entry (CAJA_LOCATION_BAR (pane->navigation_bar));
    g_signal_connect (entry, "focus-in-event",
                      G_CALLBACK (navigation_bar_focus_in_callback), pane);

    gtk_box_pack_start (GTK_BOX (hbox),
                        pane->navigation_bar,
                        TRUE, TRUE, 0);

    pane->search_bar = caja_search_bar_new ();
    g_signal_connect_object (pane->search_bar, "activate",
                             G_CALLBACK (search_bar_activate_callback), pane, 0);
    g_signal_connect_object (pane->search_bar, "cancel",
                             G_CALLBACK (search_bar_cancel_callback), pane, 0);
    g_signal_connect_object (pane->search_bar, "focus-in",
                             G_CALLBACK (search_bar_focus_in_callback), pane, 0);
    gtk_box_pack_start (GTK_BOX (hbox),
                        pane->search_bar,
                        TRUE, TRUE, 0);

    pane->notebook = g_object_new (CAJA_TYPE_NOTEBOOK, NULL);
    gtk_box_pack_start (GTK_BOX (pane->widget), pane->notebook,
                        TRUE, TRUE, 0);
    g_signal_connect (pane->notebook,
                      "tab-close-request",
                      G_CALLBACK (notebook_tab_close_requested),
                      pane);
    g_signal_connect_after (pane->notebook,
                            "button_press_event",
                            G_CALLBACK (notebook_button_press_cb),
                            pane);
    g_signal_connect (pane->notebook, "popup-menu",
                      G_CALLBACK (notebook_popup_menu_cb),
                      pane);
    g_signal_connect (pane->notebook,
                      "switch-page",
                      G_CALLBACK (notebook_switch_page_cb),
                      pane);

    gtk_notebook_set_show_tabs (GTK_NOTEBOOK (pane->notebook), FALSE);
    gtk_notebook_set_show_border (GTK_NOTEBOOK (pane->notebook), FALSE);
    gtk_widget_show (pane->notebook);
    gtk_container_set_border_width (GTK_CONTAINER (pane->notebook), 0);

    /* Ensure that the view has some minimal size and that other parts
     * of the UI (like location bar and tabs) don't request more and
     * thus affect the default position of the split view paned.
     */
    gtk_widget_set_size_request (pane->widget, 60, 60);
}
예제 #13
0
gboolean
caja_navigation_window_pane_hide_temporary_bars (CajaNavigationWindowPane *pane)
{
    CajaWindowSlot *slot;
    CajaDirectory *directory;
    gboolean success;

    g_assert (CAJA_IS_NAVIGATION_WINDOW_PANE (pane));

    slot = CAJA_WINDOW_PANE(pane)->active_slot;
    success = FALSE;

    if (pane->temporary_location_bar)
    {
        if (caja_navigation_window_pane_location_bar_showing (pane))
        {
            caja_navigation_window_pane_hide_location_bar (pane, FALSE);
        }
        pane->temporary_location_bar = FALSE;
        success = TRUE;
    }
    if (pane->temporary_navigation_bar)
    {
        directory = caja_directory_get (slot->location);

        if (CAJA_IS_SEARCH_DIRECTORY (directory))
        {
            caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_SEARCH);
        }
        else
        {
            if (!g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY))
            {
                caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH);
            }
        }
        pane->temporary_navigation_bar = FALSE;
        success = TRUE;

        caja_directory_unref (directory);
    }
    if (pane->temporary_search_bar)
    {
        CajaNavigationWindow *window;

        if (!g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY))
        {
            caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH);
        }
        else
        {
            caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_NAVIGATION);
        }
        window = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window);
        caja_navigation_window_set_search_button (window, FALSE);
        pane->temporary_search_bar = FALSE;
        success = TRUE;
    }

    return success;
}