static void
real_sync_location_widgets (CajaWindowPane *pane)
{
    CajaNavigationWindowSlot *navigation_slot;
    CajaNavigationWindowPane *navigation_pane;
    CajaWindowSlot *slot;

    slot = pane->active_slot;
    navigation_pane = CAJA_NAVIGATION_WINDOW_PANE (pane);

    /* Change the location bar and path bar to match the current location. */
    if (slot->location != NULL)
    {
        char *uri;

        /* this may be NULL if we just created the slot */
        uri = caja_window_slot_get_location_uri (slot);
        caja_location_bar_set_location (CAJA_LOCATION_BAR (navigation_pane->navigation_bar), uri);
        g_free (uri);
        caja_path_bar_set_path (CAJA_PATH_BAR (navigation_pane->path_bar), slot->location);
    }

    /* Update window global UI if this is the active pane */
    if (pane == pane->window->details->active_pane)
    {
        caja_window_update_up_button (pane->window);

        /* Check if the back and forward buttons need enabling or disabling. */
        navigation_slot = CAJA_NAVIGATION_WINDOW_SLOT (pane->window->details->active_pane->active_slot);
        caja_navigation_window_allow_back (CAJA_NAVIGATION_WINDOW (pane->window),
                                           navigation_slot->back_list != NULL);
        caja_navigation_window_allow_forward (CAJA_NAVIGATION_WINDOW (pane->window),
                                              navigation_slot->forward_list != NULL);
    }
}
static void
fill_menu (CajaNavigationWindow *window,
           GtkWidget *menu,
           gboolean back)
{
    CajaNavigationWindowSlot *slot;
    GtkWidget *menu_item;
    int index;
    GList *list;

    g_assert (CAJA_IS_NAVIGATION_WINDOW (window));

    slot = CAJA_NAVIGATION_WINDOW_SLOT (CAJA_WINDOW (window)->details->active_pane->active_slot);

    list = back ? slot->back_list : slot->forward_list;
    index = 0;
    while (list != NULL)
    {
        menu_item = caja_bookmark_menu_item_new (CAJA_BOOKMARK (list->data));
        g_object_set_data (G_OBJECT (menu_item), "user_data", GINT_TO_POINTER (index));
        gtk_widget_show (GTK_WIDGET (menu_item));
        g_signal_connect_object (menu_item, "activate",
                                 back
                                 ? G_CALLBACK (activate_back_menu_item_callback)
                                 : G_CALLBACK (activate_forward_menu_item_callback),
                                 window, 0);

        gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
        list = g_list_next (list);
        ++index;
    }
}
static void
path_bar_location_changed_callback (GtkWidget *widget,
                                    GFile *location,
                                    CajaNavigationWindowPane *pane)
{
    CajaNavigationWindowSlot *slot;
    CajaWindowPane *win_pane;
    int i;

    g_assert (CAJA_IS_NAVIGATION_WINDOW_PANE (pane));

    win_pane = CAJA_WINDOW_PANE(pane);

    slot = CAJA_NAVIGATION_WINDOW_SLOT (win_pane->active_slot);

    /* check whether we already visited the target location */
    i = bookmark_list_get_uri_index (slot->back_list, location);
    if (i >= 0)
    {
        caja_navigation_window_back_or_forward (CAJA_NAVIGATION_WINDOW (win_pane->window), TRUE, i, FALSE);
    }
    else
    {
        caja_window_slot_go_to (win_pane->active_slot, location, FALSE);
    }
}
Esempio n. 4
0
/**
 * caja_navigation_window_get_base_page_index:
 * @window:	Window to get index from
 *
 * Returns the index of the base page in the history list.
 * Base page is not the currently displayed page, but the page
 * that acts as the base from which the back and forward commands
 * navigate from.
 */
gint
caja_navigation_window_get_base_page_index (CajaNavigationWindow *window)
{
    CajaNavigationWindowSlot *slot;
    gint forward_count;

    slot = CAJA_NAVIGATION_WINDOW_SLOT (CAJA_WINDOW (window)->details->active_pane->active_slot);

    forward_count = g_list_length (slot->forward_list);

    /* If forward is empty, the base it at the top of the list */
    if (forward_count == 0)
    {
        return 0;
    }

    /* The forward count indicate the relative postion of the base page
     * in the history list
     */
    return forward_count;
}