Exemple #1
0
static void
tab_panel_browser_add_tab_cb (MidoriBrowser*   browser,
                              GtkWidget*       view,
                              MidoriExtension* extension)
{
    GtkWidget* notebook = katze_object_get_object (browser, "notebook");
    gint page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), view);
    MidoriWebSettings* settings = midori_browser_get_settings (browser);
    gboolean minimized = katze_object_get_boolean (view, "minimized");
    GdkPixbuf* icon = midori_view_get_icon (MIDORI_VIEW (view));
    const gchar* title = midori_view_get_display_title (MIDORI_VIEW (view));
    GtkTreeModel* model = tab_panel_get_model_for_browser (browser);

    if (minimized)
    {
        GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
        GtkWidget* image = gtk_image_new_from_pixbuf (
            midori_view_get_icon (MIDORI_VIEW (view)));
        GtkToolItem* toolitem = gtk_tool_button_new (image, NULL);
        gtk_tool_item_set_tooltip_text (toolitem, title);
        gtk_widget_show (image);
        g_object_set_data (G_OBJECT (view), "tab-panel-ext-toolitem", toolitem);
        gtk_widget_show (GTK_WIDGET (toolitem));
        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
        tab_panel_toggle_toolbook (toolbar);
        g_signal_connect (toolitem, "clicked",
            G_CALLBACK (tab_panel_toolitem_clicked_cb), view);
        g_signal_connect (gtk_bin_get_child (GTK_BIN (toolitem)), "button-press-event",
            G_CALLBACK (tab_panel_toolitem_button_press_event_cb), view);
    }
    else
    {
        GtkTreeIter iter;
        gboolean buttons = katze_object_get_boolean (settings, "close-buttons-on-tabs");
        gint ellipsize = midori_view_get_label_ellipsize (MIDORI_VIEW (view));

        gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
            &iter, NULL, page, 0, view, 1, GTK_STOCK_CLOSE, 2, buttons,
            3, icon, 4, title, 5, ellipsize, 6, NULL, -1);
    }

    if (!g_signal_handler_find (view, G_SIGNAL_MATCH_FUNC,
        g_signal_lookup ("notify", MIDORI_TYPE_VIEW), 0, NULL,
        tab_panel_view_notify_minimized_cb, extension))
    {
        g_signal_connect (settings, "notify::close-buttons-on-tabs",
            G_CALLBACK (tab_panel_settings_notify_cb), model);
        g_signal_connect (view, "notify::minimized",
            G_CALLBACK (tab_panel_view_notify_minimized_cb), extension);
        g_signal_connect (view, "notify::icon",
            G_CALLBACK (tab_panel_view_notify_icon_cb), extension);
        g_signal_connect (view, "notify::title",
            G_CALLBACK (tab_panel_view_notify_title_cb), extension);
    }

    g_object_unref (notebook);
}
Exemple #2
0
static void
tab_panel_remove_view (MidoriBrowser* browser,
                       GtkWidget*     view,
                       gboolean       minimized)
{
    if (minimized)
    {
        GtkToolItem* toolitem = tab_panel_get_toolitem_for_view (view);
        GtkWidget* toolbar = tab_panel_get_toolbar_for_browser (browser);
        gtk_widget_destroy (GTK_WIDGET (toolitem));
        tab_panel_toggle_toolbook (toolbar);
    }
    else
    {
        GtkTreeModel* model = tab_panel_get_model_for_browser (browser);
        GtkTreeIter iter;
        if (tab_panel_get_iter_for_view (model, &iter, view))
            gtk_tree_store_remove (GTK_TREE_STORE (model), &iter);
    }
}