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