static void
open_selected_item (CajaHistorySidebar *sidebar,
                    GtkTreePath *path,
                    CajaWindowOpenFlags flags)
{
    CajaWindowSlotInfo *slot;
    GtkTreeModel *model;
    GtkTreeIter iter;
    CajaBookmark *bookmark;
    GFile *location;

    model = gtk_tree_view_get_model (sidebar->tree_view);

    if (!gtk_tree_model_get_iter (model, &iter, path))
    {
        return;
    }

    gtk_tree_model_get
    (model, &iter, HISTORY_SIDEBAR_COLUMN_BOOKMARK, &bookmark, -1);

    /* Navigate to the clicked location. */
    location = caja_bookmark_get_location (CAJA_BOOKMARK (bookmark));
    slot = caja_window_info_get_active_slot (sidebar->window);
    caja_window_slot_info_open_location
    (slot,
     location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE,
     flags, NULL);
    g_object_unref (location);
}
static int
bookmark_list_get_uri_index (GList *list, GFile *location)
{
    CajaBookmark *bookmark;
    GList *l;
    GFile *tmp;
    int i;

    g_return_val_if_fail (location != NULL, -1);

    for (i = 0, l = list; l != NULL; i++, l = l->next)
    {
        bookmark = CAJA_BOOKMARK (l->data);

        tmp = caja_bookmark_get_location (bookmark);
        if (g_file_equal (location, tmp))
        {
            g_object_unref (tmp);
            return i;
        }
        g_object_unref (tmp);
    }

    return -1;
}
static void
show_bogus_bookmark_window (CajaWindow *window,
                            CajaBookmark *bookmark)
{
    GtkDialog *dialog;
    GFile *location;
    char *uri_for_display;
    char *prompt;
    char *detail;

    location = caja_bookmark_get_location (bookmark);
    uri_for_display = g_file_get_parse_name (location);

    prompt = _("Do you want to remove any bookmarks with the "
               "non-existing location from your list?");
    detail = g_strdup_printf (_("The location \"%s\" does not exist."), uri_for_display);

    dialog = eel_show_yes_no_dialog (prompt, detail,
                                     _("Bookmark for Nonexistent Location"),
                                     GTK_STOCK_CANCEL,
                                     GTK_WINDOW (window));

    g_signal_connect (dialog, "response",
                      G_CALLBACK (remove_bookmarks_for_uri_if_yes), window);
    g_object_set_data_full (G_OBJECT (dialog), "uri", g_file_get_uri (location), g_free);

    gtk_dialog_set_default_response (dialog, GTK_RESPONSE_NO);

    g_object_unref (location);
    g_free (uri_for_display);
    g_free (detail);
}
static void
open_selected_bookmark (gpointer user_data, GdkScreen *screen)
{
    CajaBookmark *selected;
    CajaWindow *window;
    GFile *location;

    selected = get_selected_bookmark ();

    if (!selected)
    {
        return;
    }

    location = caja_bookmark_get_location (selected);
    if (location == NULL)
    {
        return;
    }

    if (CAJA_IS_NAVIGATION_WINDOW (user_data))
    {
        window = user_data;
    }
    else if (CAJA_IS_SPATIAL_WINDOW (user_data))
    {
        window = caja_application_get_spatial_window (application,
                                                      NULL,
                                                      NULL,
                                                      location,
                                                      screen,
                                                      NULL,
                                                      FALSE);
    } else { /* window that opened bookmarks window has been closed */
        if (parent_is_browser_window || g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) {
            window = caja_application_create_navigation_window (application,
                     NULL,
                     screen);
        }
        else
        {
            window = caja_application_get_spatial_window (application,
                                                          NULL,
                                                          NULL,
                                                          location,
                                                          screen,
                                                          NULL,
                                                          FALSE);
        }
    }

    caja_window_go_to (window, location);

    g_object_unref (location);
}
Exemple #5
0
static void
on_selection_changed (GtkTreeSelection *treeselection,
                      gpointer user_data)
{
    CajaBookmark *selected;
    char *name = NULL, *entry_text = NULL;
    GFile *location;

    g_assert (GTK_IS_ENTRY (name_field));
    g_assert (GTK_IS_ENTRY (uri_field));

    selected = get_selected_bookmark ();

    if (selected)
    {
        name = caja_bookmark_get_name (selected);
        location = caja_bookmark_get_location (selected);
        entry_text = g_file_get_parse_name (location);

        g_object_unref (location);
    }

    /* Set the sensitivity of widgets that require a selection */
    gtk_widget_set_sensitive (remove_button, selected != NULL);
    gtk_widget_set_sensitive (jump_button, selected != NULL);
    gtk_widget_set_sensitive (name_field, selected != NULL);
    gtk_widget_set_sensitive (uri_field, selected != NULL);

    g_signal_handler_block (name_field, name_field_changed_signal_id);
    caja_entry_set_text (CAJA_ENTRY (name_field),
                         name ? name : "");
    g_signal_handler_unblock (name_field, name_field_changed_signal_id);

    g_signal_handler_block (uri_field, uri_field_changed_signal_id);
    caja_entry_set_text (CAJA_ENTRY (uri_field),
                         entry_text ? entry_text : "");
    g_signal_handler_unblock (uri_field, uri_field_changed_signal_id);

    text_changed = FALSE;
    name_text_changed = FALSE;

    g_free (name);
    g_free (entry_text);
}
Exemple #6
0
static void
activate_bookmark_in_menu_item (GtkAction *action, gpointer user_data)
{
    CajaWindowSlot *slot;
    BookmarkHolder *holder;
    GFile *location;

    holder = (BookmarkHolder *)user_data;

    if (caja_bookmark_uri_known_not_to_exist (holder->bookmark))
    {
        holder->failed_callback (holder->window, holder->bookmark);
    }
    else
    {
        location = caja_bookmark_get_location (holder->bookmark);
        slot = caja_window_get_active_slot (holder->window);
        caja_window_slot_go_to (slot,
                                location,
                                should_open_in_new_tab ());
        g_object_unref (location);
    }
}