]> spindle.queued.net Git - midori/commitdiff
First stab at integration history with the location
authorDale Whittaker <dayul@users.sf.net>
Mon, 27 Oct 2008 02:12:09 +0000 (03:12 +0100)
committerChristian Dywan <christian@twotoasts.de>
Mon, 27 Oct 2008 02:12:09 +0000 (03:12 +0100)
For starters, the location contains items from the
history and not only from the current session.

midori/midori-browser.c
midori/midori-locationaction.c
midori/midori-locationaction.h
midori/midori-locationentry.c
midori/midori-locationentry.h

index 0df54628058ca6f52c39f05ad97bbeb461eacf46..e7b43ee99aa70441df4ff26eb26538419dd2ff48 100644 (file)
@@ -4278,11 +4278,43 @@ midori_browser_new_history_item (MidoriBrowser* browser,
     }
 }
 
+static void
+_location_action_insert_history_item (MidoriLocationAction* action,
+                                      MidoriBrowser*        browser,
+                                      KatzeItem*            item)
+{
+    KatzeItem* child;
+    guint i, n;
+    const gchar* uri;
+    GdkPixbuf* pixbuf = NULL;
+
+    g_return_if_fail (MIDORI_IS_LOCATION_ACTION (action));
+    g_return_if_fail (KATZE_IS_ITEM (item));
+
+    if (KATZE_IS_ARRAY (item))
+    {
+        n = katze_array_get_length (KATZE_ARRAY (item));
+        for (i = n; i > 0; i--)
+        {
+            child = katze_array_get_nth_item (KATZE_ARRAY (item), i - 1);
+            _location_action_insert_history_item (action, browser, child);
+        }
+    }
+    else
+    {
+        uri = katze_item_get_uri (item);
+        pixbuf = katze_net_load_icon (browser->net, katze_item_get_uri (item),
+                                      NULL, GTK_WIDGET (browser), NULL);
+        midori_location_action_add_item (action, uri, pixbuf, katze_item_get_name (item));
+    }
+}
+
 static void
 midori_browser_load_history (MidoriBrowser* browser)
 {
     GtkTreeView* treeview;
     GtkTreeModel* treemodel;
+    GtkAction* action;
 
     if (!browser->history)
         return;
@@ -4292,6 +4324,11 @@ midori_browser_load_history (MidoriBrowser* browser)
 
     _tree_store_insert_history_item (GTK_TREE_STORE (treemodel),
                                      NULL, KATZE_ITEM (browser->history));
+
+    action = _action_by_name (browser, "Location");
+    _location_action_insert_history_item (MIDORI_LOCATION_ACTION (action),
+                                          browser,
+                                          KATZE_ITEM (browser->history));
 }
 
 static void
index e8b0f4069d692effd5a6fbfbd95c1ff4e5e24ccf..1e03ea999fe1c2f13bc944790b81e6cdfa423509 100644 (file)
@@ -457,12 +457,54 @@ midori_location_action_add_uri (MidoriLocationAction* location_action,
         item.favicon = NULL;
         item.uri = uri;
         item.title = NULL;
-        midori_location_entry_add_item (
+        midori_location_entry_prepend_item (
             MIDORI_LOCATION_ENTRY (entry), &item);
     }
     while ((proxies = g_slist_next (proxies)));
 }
 
+void
+midori_location_action_add_item (MidoriLocationAction* location_action,
+                                 const gchar*          uri,
+                                 GdkPixbuf*            icon,
+                                 const gchar*          title)
+{
+    GSList* proxies;
+    GtkWidget* alignment;
+    GtkWidget* entry;
+    GtkWidget* child;
+    MidoriLocationEntryItem item;
+
+    g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
+    g_return_if_fail (uri != NULL);
+    g_return_if_fail (title != NULL);
+    g_return_if_fail (!icon || GDK_IS_PIXBUF (icon));
+
+    katze_assign (location_action->uri, g_strdup (uri));
+
+    proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
+    if (!proxies)
+        return;
+
+    do
+    if (GTK_IS_TOOL_ITEM (proxies->data))
+    {
+        alignment = gtk_bin_get_child (GTK_BIN (proxies->data));
+        entry = gtk_bin_get_child (GTK_BIN (alignment));
+        child = gtk_bin_get_child (GTK_BIN (entry));
+
+        item.favicon = icon;
+        item.uri = uri;
+        item.title = title;
+        midori_location_entry_append_item (
+            MIDORI_LOCATION_ENTRY (entry), &item);
+        if (!g_strcmp0 (location_action->uri, uri))
+            gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (child),
+                GTK_ICON_ENTRY_PRIMARY, icon);
+    }
+    while ((proxies = g_slist_next (proxies)));
+}
+
 void
 midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
                                          GdkPixbuf*            icon,
@@ -492,7 +534,7 @@ midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
         item.favicon = icon;
         item.uri = uri;
         item.title = NULL;
-        midori_location_entry_add_item (
+        midori_location_entry_prepend_item (
             MIDORI_LOCATION_ENTRY (entry), &item);
         if (!g_strcmp0 (location_action->uri, uri))
             gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (child),
@@ -527,8 +569,8 @@ midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
 
         item.favicon = NULL;
         item.uri = uri;
-        item.title = item.uri;
-        midori_location_entry_add_item (
+        item.title = title;
+        midori_location_entry_prepend_item (
             MIDORI_LOCATION_ENTRY (entry), &item);
     }
     while ((proxies = g_slist_next (proxies)));
index 837527d72a8ffa32c785009df039d5688de5d605..ba6da7bb482804d381ceb4868cd8e9253203a755 100644 (file)
@@ -49,6 +49,11 @@ midori_location_action_add_uri            (MidoriLocationAction* location_action
                                            const gchar*          uri);
 
 void
+midori_location_action_add_item           (MidoriLocationAction* location_action,
+                                           const gchar*          uri,
+                                           GdkPixbuf*            icon,
+                                           const gchar*          title);
+void
 midori_location_action_set_icon_for_uri   (MidoriLocationAction* location_action,
                                            GdkPixbuf*            icon,
                                            const gchar*          text);
index 2f6846310ce385ede9bf9f97a37e02ee98058fec..d90e3f88a22a6eff56b7e8cc79abc49d29db8566 100644 (file)
@@ -726,15 +726,15 @@ midori_location_entry_set_item_from_uri (MidoriLocationEntry* location_entry,
 }
 
 /**
- * midori_location_entry_add_item:
+ * midori_location_entry_prepend_item:
  * @location_entry: a #MidoriLocationEntry
  * @item: a MidoriLocationItem
  *
- * Adds @item if it is not already in the list.
+ * Prepends @item if it is not already in the list.
  **/
 void
-midori_location_entry_add_item (MidoriLocationEntry*     location_entry,
-                                MidoriLocationEntryItem* item)
+midori_location_entry_prepend_item (MidoriLocationEntry*     location_entry,
+                                    MidoriLocationEntryItem* item)
 {
     GtkTreeModel* model;
     GtkTreeIter iter;
@@ -750,3 +750,28 @@ midori_location_entry_add_item (MidoriLocationEntry*     location_entry,
     midori_location_entry_set_item (location_entry, &iter, item);
 }
 
+/**
+ * midori_location_entry_append_item:
+ * @location_entry: a #MidoriLocationEntry
+ * @item: a MidoriLocationItem
+ *
+ * Appends @item if it is not already in the list.
+ **/
+void
+midori_location_entry_append_item (MidoriLocationEntry*     location_entry,
+                                   MidoriLocationEntryItem* item)
+{
+    GtkTreeModel* model;
+    GtkTreeIter iter;
+
+    g_return_if_fail (MIDORI_IS_LOCATION_ENTRY (location_entry));
+    g_return_if_fail (item->uri != NULL);
+
+    model = gtk_combo_box_get_model (GTK_COMBO_BOX (location_entry));
+
+    if (!midori_location_entry_item_iter (location_entry, item->uri, &iter))
+        gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+
+    midori_location_entry_set_item (location_entry, &iter, item);
+}
+
index 53f8a6fc3d122ebb0624f2cb5ac7c6f41dcdd48e..cc47b9da5d98389e6913c4eded0e6349e8a61784 100644 (file)
@@ -60,7 +60,11 @@ midori_location_entry_set_item_from_uri (MidoriLocationEntry* location_entry,
                                          const gchar*         uri);
 
 void
-midori_location_entry_add_item          (MidoriLocationEntry* location_entry,
+midori_location_entry_prepend_item      (MidoriLocationEntry* location_entry,
+                                         MidoriLocationEntryItem* item);
+
+void
+midori_location_entry_append_item       (MidoriLocationEntry* location_entry,
                                          MidoriLocationEntryItem* item);
 
 gdouble