First stab at integration history with the location

For starters, the location contains items from the
history and not only from the current session.
This commit is contained in:
Dale Whittaker 2008-10-27 03:12:09 +01:00 committed by Christian Dywan
parent 0ca873cb08
commit 70516f1f5b
5 changed files with 122 additions and 9 deletions

View 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 static void
midori_browser_load_history (MidoriBrowser* browser) midori_browser_load_history (MidoriBrowser* browser)
{ {
GtkTreeView* treeview; GtkTreeView* treeview;
GtkTreeModel* treemodel; GtkTreeModel* treemodel;
GtkAction* action;
if (!browser->history) if (!browser->history)
return; return;
@ -4292,6 +4324,11 @@ midori_browser_load_history (MidoriBrowser* browser)
_tree_store_insert_history_item (GTK_TREE_STORE (treemodel), _tree_store_insert_history_item (GTK_TREE_STORE (treemodel),
NULL, KATZE_ITEM (browser->history)); 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 static void

View file

@ -457,12 +457,54 @@ midori_location_action_add_uri (MidoriLocationAction* location_action,
item.favicon = NULL; item.favicon = NULL;
item.uri = uri; item.uri = uri;
item.title = NULL; item.title = NULL;
midori_location_entry_add_item ( midori_location_entry_prepend_item (
MIDORI_LOCATION_ENTRY (entry), &item); MIDORI_LOCATION_ENTRY (entry), &item);
} }
while ((proxies = g_slist_next (proxies))); 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 void
midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action, midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
GdkPixbuf* icon, GdkPixbuf* icon,
@ -492,7 +534,7 @@ midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
item.favicon = icon; item.favicon = icon;
item.uri = uri; item.uri = uri;
item.title = NULL; item.title = NULL;
midori_location_entry_add_item ( midori_location_entry_prepend_item (
MIDORI_LOCATION_ENTRY (entry), &item); MIDORI_LOCATION_ENTRY (entry), &item);
if (!g_strcmp0 (location_action->uri, uri)) if (!g_strcmp0 (location_action->uri, uri))
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (child), 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.favicon = NULL;
item.uri = uri; item.uri = uri;
item.title = item.uri; item.title = title;
midori_location_entry_add_item ( midori_location_entry_prepend_item (
MIDORI_LOCATION_ENTRY (entry), &item); MIDORI_LOCATION_ENTRY (entry), &item);
} }
while ((proxies = g_slist_next (proxies))); while ((proxies = g_slist_next (proxies)));

View file

@ -49,6 +49,11 @@ midori_location_action_add_uri (MidoriLocationAction* location_action
const gchar* uri); const gchar* uri);
void 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, midori_location_action_set_icon_for_uri (MidoriLocationAction* location_action,
GdkPixbuf* icon, GdkPixbuf* icon,
const gchar* text); const gchar* text);

View file

@ -726,14 +726,14 @@ midori_location_entry_set_item_from_uri (MidoriLocationEntry* location_entry,
} }
/** /**
* midori_location_entry_add_item: * midori_location_entry_prepend_item:
* @location_entry: a #MidoriLocationEntry * @location_entry: a #MidoriLocationEntry
* @item: a MidoriLocationItem * @item: a MidoriLocationItem
* *
* Adds @item if it is not already in the list. * Prepends @item if it is not already in the list.
**/ **/
void void
midori_location_entry_add_item (MidoriLocationEntry* location_entry, midori_location_entry_prepend_item (MidoriLocationEntry* location_entry,
MidoriLocationEntryItem* item) MidoriLocationEntryItem* item)
{ {
GtkTreeModel* model; GtkTreeModel* model;
@ -750,3 +750,28 @@ midori_location_entry_add_item (MidoriLocationEntry* location_entry,
midori_location_entry_set_item (location_entry, &iter, item); 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);
}

View file

@ -60,7 +60,11 @@ midori_location_entry_set_item_from_uri (MidoriLocationEntry* location_entry,
const gchar* uri); const gchar* uri);
void 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); MidoriLocationEntryItem* item);
gdouble gdouble