]> spindle.queued.net Git - midori/commitdiff
Implement details dialog/ pop-over on left icon
authorChristian Dywan <christian@twotoasts.de>
Sun, 15 Jul 2012 15:22:30 +0000 (17:22 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 15 Jul 2012 15:25:07 +0000 (17:25 +0200)
Fixes: https://bugs.launchpad.net/midori/+bug/898495
midori/gtkiconentry.c
midori/gtkiconentry.h
midori/midori-locationaction.c

index 44fddc03100d81505f2933d5fb9923b85c772b09..6e5b97bac187de02538cb7720242a6911f8055fb 100644 (file)
@@ -1877,6 +1877,17 @@ gtk_icon_entry_set_tooltip (const GtkIconEntry *entry,
   icon_info->tooltip_text = new_tooltip;
 }
 
+const gchar*
+gtk_icon_entry_get_icon_tooltip (const GtkIconEntry *entry,
+                                  GtkIconEntryPosition icon_pos)
+{
+  g_return_val_if_fail (entry != NULL, FALSE);
+  g_return_val_if_fail (GTK_IS_ICON_ENTRY (entry), FALSE);
+  g_return_val_if_fail (IS_VALID_ICON_ENTRY_POSITION (icon_pos), FALSE);
+
+  return entry->priv->icons[icon_pos].tooltip_text;
+}
+
 /**
  * gtk_icon_entry_set_icon_sensitive
  * @entry: A #GtkIconEntry.
index 18ec4e100cb5d5ad3237841f3e9461aa04be9f54..76019d577461c8115311342255fa3be8bb88efbe 100644 (file)
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
                                          GtkEntryIconPosition position,
                                          GdkPixbuf*           pixbuf);
     #define gtk_icon_entry_set_tooltip gtk_entry_set_icon_tooltip_text
+    #define gtk_icon_entry_get_tooltip gtk_entry_get_icon_tooltip_text
     #define gtk_icon_entry_set_icon_highlight gtk_entry_set_icon_activatable
     #define gtk_icon_entry_set_progress_fraction gtk_entry_set_progress_fraction
 #else
@@ -123,6 +124,8 @@ void       gtk_icon_entry_set_cursor              (const GtkIconEntry *icon_entr
                                                   GtkIconEntryPosition icon_pos,
                                                   GdkCursorType cursor_type);
 
+const gchar* gtk_icon_entry_get_tooltip            (const GtkIconEntry *icon_entry,
+                                                  GtkIconEntryPosition icon_pos);
 void       gtk_icon_entry_set_tooltip             (const GtkIconEntry *icon_entry,
                                                   GtkIconEntryPosition icon_pos,
                                                   const gchar *text);
index 6f35e27e8ebbb791152f1677bf90154d6ce07f37..a76b1d88c03a7173e4eedc5526b69f3d46c0e7ec 100644 (file)
@@ -842,9 +842,8 @@ midori_location_action_create_tool_item (GtkAction* action)
     hildon_gtk_entry_set_input_mode (GTK_ENTRY (entry), mode);
     #else
     entry = gtk_icon_entry_new ();
-    /* Work-around icon being activatable by default */
     gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
-         GTK_ICON_ENTRY_PRIMARY, FALSE);
+         GTK_ICON_ENTRY_PRIMARY, TRUE);
     gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry),
          GTK_ICON_ENTRY_SECONDARY, TRUE);
     #endif
@@ -1133,6 +1132,46 @@ midori_location_action_icon_released_cb (GtkWidget*           widget,
                                          gint                 button,
                                          GtkAction*           action)
 {
+    if (icon_pos == GTK_ICON_ENTRY_PRIMARY)
+    {
+        const gchar* title = _("Security details");
+        GtkWidget* content_area;
+        GtkWidget* hbox;
+        gint root_x, root_y;
+        #ifdef HAVE_GRANITE
+        GdkRectangle icon_rect;
+        /* FIXME: granite: should return GtkWidget* like GTK+ */
+        GtkWidget* dialog = (GtkWidget*)granite_widgets_pop_over_new ();
+        gchar* markup = g_strdup_printf ("<b>%s</b>", title);
+        GtkWidget* label = gtk_label_new (markup);
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+        g_free (markup);
+        gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+        gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 0);
+        gtk_entry_get_icon_area (GTK_ENTRY (widget), icon_pos, &icon_rect);
+        gdk_window_get_root_coords (gtk_widget_get_window (widget),
+            icon_rect.x + icon_rect.width / 2, icon_rect.y + icon_rect.height,
+            &root_x, &root_y);
+        granite_widgets_pop_over_move_to_coords (GRANITE_WIDGETS_POP_OVER (dialog),
+            root_x, root_y, TRUE);
+        #else
+        GtkWidget* dialog = gtk_dialog_new_with_buttons (title, gtk_widget_get_toplevel (widget),
+            GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, NULL, NULL);
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+        #endif
+        hbox = gtk_hbox_new (FALSE, 0);
+        #if GTK_CHECK_VERSION (2, 16, 0)
+        gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_gicon (
+            gtk_entry_get_icon_gicon (GTK_ENTRY (widget), icon_pos), GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);
+        #else
+        gtk_box_pack_start (GTK_BOX (hbox),
+            gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0);
+        #endif
+        gtk_box_pack_start (GTK_BOX (hbox),
+            gtk_label_new (gtk_icon_entry_get_tooltip (GTK_ICON_ENTRY (widget), icon_pos)), FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);
+        gtk_widget_show_all (dialog);
+    }
     if (icon_pos == GTK_ICON_ENTRY_SECONDARY)
     {
         gboolean result;