From: Christian Dywan Date: Sun, 26 Jul 2009 21:50:17 +0000 (+0200) Subject: Ellipsize titles and show tooltips in the tab panel X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0d0b3bba7895fbd5119dce0d0476c72f76084e6;p=midori Ellipsize titles and show tooltips in the tab panel --- diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c index a45dc70b..adc88b53 100644 --- a/extensions/tab-panel.c +++ b/extensions/tab-panel.c @@ -75,7 +75,10 @@ midori_extension_treeview_render_text_cb (GtkTreeViewColumn* column, gtk_tree_model_get (model, iter, 0, &view, -1); - g_object_set (renderer, "text", midori_view_get_display_title (view), NULL); + g_object_set (renderer, "text", midori_view_get_display_title (view), + "ellipsize", midori_view_get_label_ellipsize (view), NULL); + gtk_tree_store_set (GTK_TREE_STORE (model), iter, + 1, midori_view_get_display_title (view), -1); g_object_unref (view); } @@ -248,6 +251,9 @@ tab_panel_app_add_browser_cb (MidoriApp* app, treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); gtk_tree_view_set_show_expanders (GTK_TREE_VIEW (treeview), FALSE); + #if GTK_CHECK_VERSION (2, 12, 0) + gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), 1); + #endif column = gtk_tree_view_column_new (); renderer_pixbuf = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE); @@ -255,7 +261,7 @@ tab_panel_app_add_browser_cb (MidoriApp* app, (GtkTreeCellDataFunc)midori_extension_treeview_render_icon_cb, treeview, NULL); renderer_text = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, renderer_text, FALSE); + gtk_tree_view_column_pack_start (column, renderer_text, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer_text, (GtkTreeCellDataFunc)midori_extension_treeview_render_text_cb, treeview, NULL); @@ -314,7 +320,7 @@ tab_panel_activate_cb (MidoriExtension* extension, MidoriBrowser* browser; guint i; - model = gtk_tree_store_new (1, MIDORI_TYPE_VIEW); + model = gtk_tree_store_new (2, MIDORI_TYPE_VIEW, G_TYPE_STRING); g_object_set_data (G_OBJECT (extension), "treemodel", model); browsers = katze_object_get_object (app, "browsers"); diff --git a/midori/midori-view.c b/midori/midori-view.c index e9fc7ad3..6fc24260 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -2745,6 +2745,27 @@ midori_view_tab_label_query_tooltip_cb (GtkWidget* tab_label, } #endif +/** + * midori_view_get_label_ellipsize: + * @view: a #MidoriView + * + * Determines how labels representing the view should be + * ellipsized, which is helpful for alternative labels. + * + * Return value: how to ellipsize the label + * + * Since: 0.1.9 + **/ +PangoEllipsizeMode +midori_view_get_label_ellipsize (MidoriView* view) +{ + g_return_val_if_fail (MIDORI_IS_VIEW (view), PANGO_ELLIPSIZE_END); + + if (view->tab_label) + return gtk_label_get_ellipsize (GTK_LABEL (view->tab_title)); + return PANGO_ELLIPSIZE_END; +} + /** * midori_view_get_proxy_tab_label: * @view: a #MidoriView diff --git a/midori/midori-view.h b/midori/midori-view.h index 017499a6..0dbfc52b 100644 --- a/midori/midori-view.h +++ b/midori/midori-view.h @@ -116,6 +116,9 @@ midori_view_get_proxy_menu_item (MidoriView* view); GtkWidget* midori_view_get_tab_menu (MidoriView* view); +PangoEllipsizeMode +midori_view_get_label_ellipsize (MidoriView* view); + GtkWidget* midori_view_get_proxy_tab_label (MidoriView* view);