Instead of adding multiple same history items, update the original item
This commit is contained in:
parent
3e18b780ac
commit
6b2d8df6af
3 changed files with 47 additions and 6 deletions
|
@ -682,6 +682,30 @@ midori_history_clear_cb (KatzeArray* history,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
midori_history_notify_item_cb (KatzeItem* item,
|
||||
GParamSpec* pspec,
|
||||
sqlite3* db)
|
||||
{
|
||||
gchar* sqlcmd;
|
||||
gboolean success = TRUE;
|
||||
GError* error = NULL;
|
||||
|
||||
sqlcmd = sqlite3_mprintf ("UPDATE history SET title='%q' WHERE "
|
||||
"uri='%q' AND date=%" G_GUINT64_FORMAT,
|
||||
katze_item_get_name (item),
|
||||
katze_item_get_uri (item),
|
||||
katze_item_get_added (item));
|
||||
success = db_exec (db, sqlcmd, &error);
|
||||
sqlite3_free (sqlcmd);
|
||||
if (!success)
|
||||
{
|
||||
g_printerr (_("Failed to add history item: %s\n"), error->message);
|
||||
g_error_free (error);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
midori_history_add_item_cb (KatzeArray* array,
|
||||
KatzeItem* item,
|
||||
|
@ -716,7 +740,8 @@ midori_history_add_item_cb (KatzeArray* array,
|
|||
}
|
||||
}
|
||||
sqlcmd = sqlite3_mprintf ("INSERT INTO history VALUES"
|
||||
"('%q', '%q', %" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT ")",
|
||||
"('%q', '%q', %" G_GUINT64_FORMAT ","
|
||||
" %" G_GUINT64_FORMAT ")",
|
||||
katze_item_get_uri (item),
|
||||
katze_item_get_name (item),
|
||||
katze_item_get_added (item),
|
||||
|
@ -729,6 +754,10 @@ midori_history_add_item_cb (KatzeArray* array,
|
|||
g_error_free (error);
|
||||
return ;
|
||||
}
|
||||
|
||||
/* The title is set after the item is added */
|
||||
g_signal_connect_after (item, "notify::name",
|
||||
G_CALLBACK (midori_history_notify_item_cb), db);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -437,7 +437,6 @@ midori_view_notify_title_cb (GtkWidget* view,
|
|||
const gchar* title;
|
||||
GtkAction* action;
|
||||
gchar* window_title;
|
||||
KatzeItem* item;
|
||||
|
||||
uri = midori_view_get_display_uri (MIDORI_VIEW (view));
|
||||
title = midori_view_get_display_title (MIDORI_VIEW (view));
|
||||
|
@ -447,13 +446,23 @@ midori_view_notify_title_cb (GtkWidget* view,
|
|||
MIDORI_LOCATION_ACTION (action), title, uri);
|
||||
if (midori_view_get_load_status (MIDORI_VIEW (view)) == MIDORI_LOAD_COMMITTED)
|
||||
{
|
||||
KatzeItem* item;
|
||||
KatzeItem* proxy;
|
||||
|
||||
if (!browser->history)
|
||||
return;
|
||||
|
||||
item = katze_item_new ();
|
||||
katze_item_set_uri (item, uri);
|
||||
katze_item_set_name (item, title);
|
||||
midori_browser_new_history_item (browser, item);
|
||||
item = g_object_get_data (G_OBJECT (view), "history-item-added");
|
||||
proxy = midori_view_get_proxy_item (MIDORI_VIEW (view));
|
||||
if (item && katze_item_get_added (item) == katze_item_get_added (proxy))
|
||||
katze_item_set_name (item, katze_item_get_name (proxy));
|
||||
else
|
||||
{
|
||||
katze_object_assign (item, katze_item_copy (proxy));
|
||||
midori_browser_new_history_item (browser, g_object_ref (item));
|
||||
g_object_set_data_full (G_OBJECT (view), "history-item-added",
|
||||
item, (GDestroyNotify)g_object_unref);
|
||||
}
|
||||
}
|
||||
|
||||
if (view == midori_browser_get_current_tab (browser))
|
||||
|
|
|
@ -546,7 +546,10 @@ webkit_web_view_load_committed_cb (WebKitWebView* web_view,
|
|||
g_return_if_fail (uri != NULL);
|
||||
katze_assign (view->uri, g_strdup (uri));
|
||||
if (view->item)
|
||||
{
|
||||
katze_item_set_uri (view->item, uri);
|
||||
katze_item_set_added (view->item, time (NULL));
|
||||
}
|
||||
g_object_notify (G_OBJECT (view), "uri");
|
||||
g_object_set (view, "title", NULL, NULL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue