}
}
+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;
_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
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,
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),
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)));
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);
}
/**
- * 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;
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);
+}
+
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