]> spindle.queued.net Git - midori/commitdiff
Show thumbnail tab tooltips with Gtk 2.12 if speed dial is enabled
authorChristian Dywan <christian@twotoasts.de>
Mon, 1 Jun 2009 07:35:16 +0000 (09:35 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 1 Jun 2009 07:35:16 +0000 (09:35 +0200)
midori/midori-view.c

index 6af6a93eae1641dc1f53c18054e9d9d3f91cc3af..f1625e0e238b6d806fa133527c1281e3707d8932 100644 (file)
@@ -46,6 +46,11 @@ midori_search_action_get_icon (KatzeNet*  net,
 static void
 midori_view_construct_web_view (MidoriView* view);
 
+GdkPixbuf*
+midori_view_get_snapshot (MidoriView* view,
+                          guint       width,
+                          guint       height);
+
 struct _MidoriView
 {
     GtkScrolledWindow parent_instance;
@@ -75,6 +80,7 @@ struct _MidoriView
 
     GtkWidget* menu_item;
     GtkWidget* tab_label;
+    GtkWidget* tooltip_image;
     GtkWidget* tab_icon;
     GtkWidget* tab_title;
     GtkWidget* tab_close;
@@ -548,7 +554,9 @@ midori_view_update_title (MidoriView* view)
                 soup_uri_free (uri);
         }
         gtk_label_set_text (GTK_LABEL (view->tab_title), title);
+        #if !GTK_CHECK_VERSION (2, 12, 0)
         gtk_widget_set_tooltip_text (view->tab_title, title);
+        #endif
     }
     if (view->menu_item)
         gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (
@@ -2535,6 +2543,23 @@ midori_view_tab_label_parent_set (GtkWidget*  tab_label,
     }
 }
 
+#if GTK_CHECK_VERSION (2, 12, 0)
+static gboolean
+midori_view_tab_label_query_tooltip_cb (GtkWidget*  tab_label,
+                                        gint        x,
+                                        gint        y,
+                                        gboolean    keyboard,
+                                        GtkTooltip* tooltip,
+                                        MidoriView* view)
+{
+    if (view->speed_dial_in_new_tabs)
+        gtk_tooltip_set_icon (tooltip, midori_view_get_snapshot (view, 160, 107));
+    else
+        gtk_tooltip_set_text (tooltip, view->uri);
+    return TRUE;
+}
+#endif
+
 /**
  * midori_view_get_proxy_tab_label:
  * @view: a #MidoriView
@@ -2611,6 +2636,11 @@ midori_view_get_proxy_tab_label (MidoriView* view)
             G_CALLBACK (midori_view_tab_close_clicked), view);
 
         view->tab_label = event_box;
+        #if GTK_CHECK_VERSION (2, 12, 0)
+        gtk_widget_set_has_tooltip (view->tab_label, TRUE);
+        g_signal_connect (view->tab_label, "query-tooltip",
+            G_CALLBACK (midori_view_tab_label_query_tooltip_cb), view);
+        #endif
         g_signal_connect (view->tab_icon, "destroy",
                           G_CALLBACK (gtk_widget_destroyed),
                           &view->tab_icon);