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;
    }
}
예제 #2
0
gboolean
caja_navigation_window_sidebar_showing (CajaNavigationWindow *window)
{
    g_return_val_if_fail (CAJA_IS_NAVIGATION_WINDOW (window), FALSE);

    return (window->sidebar != NULL)
           && gtk_widget_get_visible (gtk_paned_get_child1 (GTK_PANED (window->details->content_paned)));
}
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);
}
static void
activate_back_or_forward_menu_item (GtkMenuItem *menu_item,
                                    CajaNavigationWindow *window,
                                    gboolean back)
{
    int index;

    g_assert (GTK_IS_MENU_ITEM (menu_item));
    g_assert (CAJA_IS_NAVIGATION_WINDOW (window));

    index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "user_data"));

    caja_navigation_window_back_or_forward (window, back, index, should_open_in_new_tab ());
}
예제 #5
0
void
caja_navigation_window_add_sidebar_panel (CajaNavigationWindow *window,
        CajaSidebar *sidebar_panel)
{
    const char *sidebar_id;
    char *label;
    char *tooltip;
    char *default_id;
    GdkPixbuf *icon;

    g_return_if_fail (CAJA_IS_NAVIGATION_WINDOW (window));
    g_return_if_fail (CAJA_IS_SIDEBAR (sidebar_panel));
    g_return_if_fail (CAJA_IS_SIDE_PANE (window->sidebar));
    g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL);

    label = caja_sidebar_get_tab_label (sidebar_panel);
    tooltip = caja_sidebar_get_tab_tooltip (sidebar_panel);
    caja_side_pane_add_panel (window->sidebar,
                              GTK_WIDGET (sidebar_panel),
                              label,
                              tooltip);
    g_free (tooltip);
    g_free (label);

    icon = caja_sidebar_get_tab_icon (sidebar_panel);
    caja_side_pane_set_panel_image (CAJA_NAVIGATION_WINDOW (window)->sidebar,
                                    GTK_WIDGET (sidebar_panel),
                                    icon);
    if (icon)
    {
        g_object_unref (icon);
    }

    g_signal_connect (sidebar_panel, "tab_icon_changed",
                      (GCallback)side_panel_image_changed_callback, window);

    window->sidebar_panels = g_list_prepend (window->sidebar_panels,
                             g_object_ref (sidebar_panel));

    /* Show if default */
    sidebar_id = caja_sidebar_get_sidebar_id (sidebar_panel);
    default_id = g_settings_get_string (caja_window_state, CAJA_WINDOW_STATE_SIDE_PANE_VIEW);
    if (sidebar_id && default_id && !strcmp (sidebar_id, default_id))
    {
        caja_side_pane_show_panel (window->sidebar,
                                   GTK_WIDGET (sidebar_panel));
    }
    g_free (default_id);
}
예제 #6
0
void
caja_navigation_window_remove_sidebar_panel (CajaNavigationWindow *window,
        CajaSidebar *sidebar_panel)
{
    g_return_if_fail (CAJA_IS_NAVIGATION_WINDOW (window));
    g_return_if_fail (CAJA_IS_SIDEBAR (sidebar_panel));

    if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL)
    {
        return;
    }

    g_signal_handlers_disconnect_by_func (sidebar_panel, side_panel_image_changed_callback, window);

    caja_side_pane_remove_panel (window->sidebar,
                                 GTK_WIDGET (sidebar_panel));
    window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel);
    g_object_unref (sidebar_panel);
}
예제 #7
0
파일: caja-notebook.c 프로젝트: Exalm/caja
/* FIXME remove when gtknotebook's func for this becomes public, bug #.... */
static CajaNotebook *
find_notebook_at_pointer (gint abs_x, gint abs_y)
{
#if GTK_CHECK_VERSION(3, 0, 0)
    GdkDeviceManager *manager;
    GdkDevice *pointer;
#endif
    GdkWindow *win_at_pointer, *toplevel_win;
    gpointer toplevel = NULL;
    gint x, y;

    /* FIXME multi-head */
#if GTK_CHECK_VERSION(3, 0, 0)
    manager = gdk_display_get_device_manager (gdk_display_get_default ());
    pointer = gdk_device_manager_get_client_pointer (manager);
    win_at_pointer = gdk_device_get_window_at_position (pointer, &x, &y);
#else
    win_at_pointer = gdk_window_at_pointer (&x, &y);
#endif

    if (win_at_pointer == NULL)
    {
        /* We are outside all windows containing a notebook */
        return NULL;
    }

    toplevel_win = gdk_window_get_toplevel (win_at_pointer);

    /* get the GtkWidget which owns the toplevel GdkWindow */
    gdk_window_get_user_data (toplevel_win, &toplevel);

    /* toplevel should be an CajaWindow */
    if (toplevel != NULL && CAJA_IS_NAVIGATION_WINDOW (toplevel))
    {
        return CAJA_NOTEBOOK (CAJA_NAVIGATION_WINDOW_PANE (CAJA_WINDOW (toplevel)->details->active_pane)->notebook);
    }

    return NULL;
}
예제 #8
0
/**
 * add_sidebar_panels:
 * @window:	A CajaNavigationWindow
 *
 * Adds all sidebars available
 *
 */
static void
add_sidebar_panels (CajaNavigationWindow *window)
{
    GtkWidget *current;
    GList *providers;
    GList *p;
    CajaSidebar *sidebar_panel;

    g_assert (CAJA_IS_NAVIGATION_WINDOW (window));

    if (window->sidebar == NULL)
    {
        return;
    }

    providers = caja_module_get_extensions_for_type (CAJA_TYPE_SIDEBAR_PROVIDER);

    for (p = providers; p != NULL; p = p->next)
    {
        CajaSidebarProvider *provider;

        provider = CAJA_SIDEBAR_PROVIDER (p->data);

        sidebar_panel = caja_sidebar_provider_create (provider,
                        CAJA_WINDOW_INFO (window));
        caja_navigation_window_add_sidebar_panel (window,
                sidebar_panel);

        g_object_unref (sidebar_panel);
    }

    caja_module_extension_list_free (providers);

    current = caja_side_pane_get_current_panel (window->sidebar);
    set_current_side_panel
    (window,
     CAJA_SIDEBAR (current));
}
예제 #9
0
static void sighup_handler (int sig)
{
    caja_debug_log (TRUE, CAJA_DEBUG_LOG_DOMAIN_USER,
                    "HUP signal received, reloading windows");

    GList *list_copy;
    GList *l;

    list_copy = g_list_copy (caja_application_get_window_list());

    for (l = list_copy; l != NULL; l = l->next)
    {   
        CajaWindow *window;

        window = CAJA_WINDOW (l->data);

        if (CAJA_IS_NAVIGATION_WINDOW (window))
        {   
            caja_window_reload (window);
        }
    }

}
static void
view_as_menu_switch_views_callback (GtkComboBox *combo_box, CajaNavigationWindow *window)
{
    int active;

    g_assert (GTK_IS_COMBO_BOX (combo_box));
    g_assert (CAJA_IS_NAVIGATION_WINDOW (window));

    active = gtk_combo_box_get_active (combo_box);

    if (active < 0)
    {
        return;
    }
    else if (active < GPOINTER_TO_INT (g_object_get_data (G_OBJECT (combo_box), "num viewers")))
    {
        activate_nth_short_list_item (CAJA_WINDOW (window), active);
    }
    else
    {
        activate_extra_viewer (CAJA_WINDOW (window));
    }
}
예제 #11
0
/**
 * create_bookmarks_window:
 *
 * Create a new bookmark-editing window.
 * @list: The CajaBookmarkList that this window will edit.
 *
 * Return value: A pointer to the new window.
 **/
GtkWindow *
create_bookmarks_window (CajaBookmarkList *list, CajaWindow *window_source)
{
    GtkWidget         *window;
    GtkTreeViewColumn *col;
    GtkCellRenderer   *rend;
    GtkBuilder        *builder;

    bookmarks = list;

    builder = gtk_builder_new ();
    if (!gtk_builder_add_from_file (builder,
                                    UIDIR  "/caja-bookmarks-window.ui",
                                    NULL))
    {
        return NULL;
    }

    window = (GtkWidget *)gtk_builder_get_object (builder, "bookmarks_dialog");
    bookmark_list_widget = (GtkTreeView *)gtk_builder_get_object (builder, "bookmark_tree_view");
    remove_button = (GtkWidget *)gtk_builder_get_object (builder, "bookmark_delete_button");
    jump_button = (GtkWidget *)gtk_builder_get_object (builder, "bookmark_jump_button");

    application = window_source->application;

    if (CAJA_IS_NAVIGATION_WINDOW (window_source))
    {
        parent_is_browser_window = TRUE;
    }
    else
    {
        parent_is_browser_window = FALSE;
    }

    set_up_close_accelerator (window);

    gtk_window_set_wmclass (GTK_WINDOW (window), "bookmarks", "Caja");
    caja_bookmarks_window_restore_geometry (window);

    g_object_weak_ref (G_OBJECT (window_source), edit_bookmarks_dialog_reset_signals,
                       window_source);

    bookmark_list_widget = GTK_TREE_VIEW (gtk_builder_get_object (builder, "bookmark_tree_view"));

    rend = gtk_cell_renderer_pixbuf_new ();
    col = gtk_tree_view_column_new_with_attributes ("Icon",
            rend,
            "pixbuf",
            BOOKMARK_LIST_COLUMN_ICON,
            NULL);
    gtk_tree_view_append_column (bookmark_list_widget,
                                 GTK_TREE_VIEW_COLUMN (col));
    gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (col),
                                          CAJA_ICON_SIZE_SMALLER);

    rend = gtk_cell_renderer_text_new ();
    g_object_set (rend,
                  "ellipsize", PANGO_ELLIPSIZE_END,
                  "ellipsize-set", TRUE,
                  NULL);

    col = gtk_tree_view_column_new_with_attributes ("Icon",
            rend,
            "text",
            BOOKMARK_LIST_COLUMN_NAME,
            "style",
            BOOKMARK_LIST_COLUMN_STYLE,
            NULL);
    gtk_tree_view_append_column (bookmark_list_widget,
                                 GTK_TREE_VIEW_COLUMN (col));

    bookmark_list_store = create_bookmark_store ();
    setup_empty_list ();
    gtk_tree_view_set_model (bookmark_list_widget,
                             GTK_TREE_MODEL (bookmark_empty_list_store));

    bookmark_selection =
        GTK_TREE_SELECTION (gtk_tree_view_get_selection (bookmark_list_widget));

    name_field = caja_entry_new ();

    gtk_widget_show (name_field);
    gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_name_placeholder")),
                        name_field, TRUE, TRUE, 0);

    gtk_label_set_mnemonic_widget (
        GTK_LABEL (gtk_builder_get_object (builder, "bookmark_name_label")),
        name_field);

    uri_field = caja_entry_new ();
    gtk_widget_show (uri_field);
    gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "bookmark_location_placeholder")),
                        uri_field, TRUE, TRUE, 0);

    gtk_label_set_mnemonic_widget (
        GTK_LABEL (gtk_builder_get_object (builder, "bookmark_location_label")),
        uri_field);

    bookmark_list_changed_signal_id =
        g_signal_connect (bookmarks, "contents_changed",
                          G_CALLBACK (on_bookmark_list_changed), NULL);
    row_changed_signal_id =
        g_signal_connect (bookmark_list_store, "row_changed",
                          G_CALLBACK (on_row_changed), NULL);
    row_deleted_signal_id =
        g_signal_connect (bookmark_list_store, "row_deleted",
                          G_CALLBACK (on_row_deleted), NULL);
    row_activated_signal_id =
        g_signal_connect (bookmark_list_widget, "row_activated",
                          G_CALLBACK (on_row_activated), window_source);
    button_pressed_signal_id =
        g_signal_connect (bookmark_list_widget, "button_press_event",
                          G_CALLBACK (on_button_pressed), NULL);
    key_pressed_signal_id =
        g_signal_connect (bookmark_list_widget, "key_press_event",
                          G_CALLBACK (on_key_pressed), NULL);
    selection_changed_id =
        g_signal_connect (bookmark_selection, "changed",
                          G_CALLBACK (on_selection_changed), NULL);

    g_signal_connect (window, "delete_event",
                      G_CALLBACK (on_window_delete_event), NULL);
    g_signal_connect (window, "hide",
                      G_CALLBACK (on_window_hide_event), NULL);
    g_signal_connect (window, "destroy",
                      G_CALLBACK (on_window_destroy_event), NULL);
    g_signal_connect (window, "response",
                      G_CALLBACK (caja_bookmarks_window_response_callback), NULL);

    name_field_changed_signal_id =
        g_signal_connect (name_field, "changed",
                          G_CALLBACK (on_name_field_changed), NULL);

    g_signal_connect (name_field, "focus_out_event",
                      G_CALLBACK (on_text_field_focus_out_event), NULL);
    g_signal_connect (name_field, "activate",
                      G_CALLBACK (name_or_uri_field_activate), NULL);

    uri_field_changed_signal_id =
        g_signal_connect (uri_field, "changed",
                          G_CALLBACK (on_uri_field_changed), NULL);

    g_signal_connect (uri_field, "focus_out_event",
                      G_CALLBACK (on_text_field_focus_out_event), NULL);
    g_signal_connect (uri_field, "activate",
                      G_CALLBACK (name_or_uri_field_activate), NULL);
    g_signal_connect (remove_button, "clicked",
                      G_CALLBACK (on_remove_button_clicked), NULL);
    jump_button_signal_id =
        g_signal_connect (jump_button, "clicked",
                          G_CALLBACK (on_jump_button_clicked), window_source);

    gtk_tree_selection_set_mode (bookmark_selection, GTK_SELECTION_BROWSE);

    /* Fill in list widget with bookmarks, must be after signals are wired up. */
    repopulate();

    g_object_unref (builder);

    return GTK_WINDOW (window);
}