gtkieembed r208 - in trunk: . src
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkieembed r208 - in trunk: . src
- Date: Tue, 3 Feb 2009 04:00:40 +0000 (UTC)
Author: hiikezoe
Date: Tue Feb 3 04:00:39 2009
New Revision: 208
URL: http://svn.gnome.org/viewvc/gtkieembed?rev=208&view=rev
Log:
* src/gtk-ie-embed.[ch]: Added gtk_ie_embed_set_whole_history().
* src/ie-bridge.[cpp|h]: Added _ie_bridge_set_while_history(). Remain
issue: remove current page.
Modified:
trunk/ChangeLog
trunk/src/gtk-ie-embed.c
trunk/src/gtk-ie-embed.h
trunk/src/ie-bridge.cpp
trunk/src/ie-bridge.h
Modified: trunk/src/gtk-ie-embed.c
==============================================================================
--- trunk/src/gtk-ie-embed.c (original)
+++ trunk/src/gtk-ie-embed.c Tue Feb 3 04:00:39 2009
@@ -783,6 +783,16 @@
return priv->bridge ? _ie_bridge_set_history (priv->bridge, GTK_IE_EMBED_HISTORY_FORWARD, history) : NULL;
}
+void
+gtk_ie_embed_set_whole_history (GtkIEEmbed *ie,
+ const GList *history,
+ guint current_position)
+{
+ GtkIEEmbedPriv *priv = GTK_IE_EMBED_GET_PRIVATE (ie);
+
+ return priv->bridge ? _ie_bridge_set_whole_history (priv->bridge, history, current_position) : NULL;
+}
+
guint
gtk_ie_embed_get_history_count (GtkIEEmbed *ie)
{
Modified: trunk/src/gtk-ie-embed.h
==============================================================================
--- trunk/src/gtk-ie-embed.h (original)
+++ trunk/src/gtk-ie-embed.h Tue Feb 3 04:00:39 2009
@@ -167,6 +167,10 @@
void gtk_ie_embed_set_forward_history
(GtkIEEmbed *ie,
const GList *history);
+void gtk_ie_embed_set_whole_history
+ (GtkIEEmbed *ie,
+ const GList *history,
+ guint current_position);
guint gtk_ie_embed_get_history_count
(GtkIEEmbed *ie);
guint gtk_ie_embed_get_current_position_in_history
Modified: trunk/src/ie-bridge.cpp
==============================================================================
--- trunk/src/ie-bridge.cpp (original)
+++ trunk/src/ie-bridge.cpp Tue Feb 3 04:00:39 2009
@@ -1248,7 +1248,6 @@
ITravelLogStg *travel_log = NULL;
IEnumTravelLogEntry *enum_entry = NULL;
ITravelLogEntry *entry = NULL;
- IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
TLENUMF direction_flags = (direction == GTK_IE_EMBED_HISTORY_FORWARD) ? TLEF_RELATIVE_FORE : TLEF_RELATIVE_BACK;
travel_log = _get_travel_log (ie);
@@ -1264,7 +1263,7 @@
while (enum_entry->Next (1, &entry, NULL) != S_FALSE) {
GtkIEEmbedHistoryItem *history_item;
- history_item = travel_log_entry_to_history_item(entry);
+ history_item = travel_log_entry_to_history_item (entry);
history = g_list_append (history, history_item);
entry->Release ();
@@ -1277,15 +1276,57 @@
return history;
}
+#ifdef HAVE_TLOGSTG_H
+static ITravelLogEntry *
+create_travel_log_entry_from_history_item (ITravelLogStg *travel_log, GtkIEEmbedHistoryItem *item)
+{
+ ITravelLogEntry *entry = NULL;
+ gunichar2 *utf16_uri, *utf16_title;
+
+ utf16_uri = g_utf8_to_utf16 (gtk_ie_embed_history_item_get_uri (item), -1,
+ NULL, NULL, NULL);
+ utf16_title = g_utf8_to_utf16 (gtk_ie_embed_history_item_get_title (item), -1,
+ NULL, NULL, NULL);
+ travel_log->CreateEntry ((LPOLESTR) utf16_uri, (LPOLESTR) utf16_title,
+ NULL, FALSE, &entry);
+ g_free (utf16_uri);
+ g_free (utf16_title);
+
+ return entry;
+}
+
+static void
+remove_entries_from_travel_log (ITravelLogStg *travel_log, IEnumTravelLogEntry *enum_entries)
+{
+ ITravelLogEntry *entry = NULL;
+ ITravelLogEntry *prev_entry = NULL;
+
+ if (!enum_entries)
+ return;
+
+ while (enum_entries->Next (1, &entry, NULL) != S_FALSE) {
+ if (prev_entry) {
+ travel_log->RemoveEntry (prev_entry);
+ prev_entry->Release ();
+ }
+ prev_entry = entry;
+ }
+
+ if (prev_entry) {
+ travel_log->RemoveEntry (prev_entry);
+ prev_entry->Release ();
+ }
+}
+#endif
+
void
_ie_bridge_set_history (IEBridge *ie, GtkIEEmbedHistoryDirection direction, const GList *history)
{
#ifdef HAVE_TLOGSTG_H
const GList *list;
ITravelLogStg *travel_log = NULL;
- IEnumTravelLogEntry *enum_entry = NULL;
ITravelLogEntry *entry = NULL;
- IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
+ IEnumTravelLogEntry *enum_entry = NULL;
TLENUMF direction_flags = (direction == GTK_IE_EMBED_HISTORY_FORWARD) ? TLEF_RELATIVE_FORE : TLEF_RELATIVE_BACK;
travel_log = _get_travel_log (ie);
@@ -1293,30 +1334,66 @@
return;
travel_log->EnumEntries (direction_flags, &enum_entry);
- if (enum_entry) {
- while (enum_entry->Next (1, &entry, NULL) != S_FALSE) {
- travel_log->RemoveEntry (entry);
- entry->Release ();
- entry = NULL;
- }
+ remove_entries_from_travel_log (travel_log, enum_entry);
+ enum_entry->Release ();
+
+ for (list = g_list_last ((GList*) history); list; list = g_list_previous (list)) {
+ GtkIEEmbedHistoryItem *item = GTK_IE_EMBED_HISTORY_ITEM (list->data);
+ entry = create_travel_log_entry_from_history_item (travel_log, item);
+ entry->Release ();
}
+
+ travel_log->Release ();
+#endif
+}
+
+void
+_ie_bridge_set_whole_history (IEBridge *ie,
+ const GList *history,
+ guint current_position)
+{
+#ifdef HAVE_TLOGSTG_H
+ const GList *list;
+ ITravelLogStg *travel_log = NULL;
+ ITravelLogEntry *entry = NULL;
+ ITravelLogEntry *current_entry = NULL;
+ ITravelLogEntry *old_current_entry = NULL;
+ IEnumTravelLogEntry *enum_entry = NULL;
+ guint count;
+
+ travel_log = _get_travel_log (ie);
+ if (!travel_log)
+ return;
+
+ travel_log->EnumEntries (TLEF_ABSOLUTE, &enum_entry);
+ remove_entries_from_travel_log (travel_log, enum_entry);
enum_entry->Release ();
- for (list = history; list; list = g_list_next (list)) {
+ /* current entry can not be removed so we remove it after create new entries */
+ travel_log->GetRelativeEntry (0, &old_current_entry);
+
+ count = g_list_length ((GList *)history);
+ for (list = g_list_last ((GList *)history); list; list = g_list_previous (list)) {
GtkIEEmbedHistoryItem *item = GTK_IE_EMBED_HISTORY_ITEM (list->data);
- gunichar2 *utf16_uri, *utf16_title;
+ entry = create_travel_log_entry_from_history_item (travel_log, item);
- utf16_uri = g_utf8_to_utf16 (gtk_ie_embed_history_item_get_uri (item), -1,
- NULL, NULL, NULL);
- utf16_title = g_utf8_to_utf16 (gtk_ie_embed_history_item_get_title (item), -1,
- NULL, NULL, NULL);
- travel_log->CreateEntry ((LPOLESTR) utf16_uri, (LPOLESTR) utf16_title,
- NULL, FALSE, &entry);
+ if (count == current_position)
+ current_entry = entry;
+ else
+ entry->Release ();
+ count--;
+ }
- g_free (utf16_uri);
- g_free (utf16_title);
+ if (current_entry) {
+ travel_log->TravelTo (current_entry);
+ current_entry->Release ();
}
+ if (old_current_entry) {
+ /* FIXME remove current entry after navigation to a new entry completed. */
+ /* travel_log->RemoveEntry (old_current_entry); */
+ old_current_entry->Release ();
+ }
travel_log->Release ();
#endif
}
Modified: trunk/src/ie-bridge.h
==============================================================================
--- trunk/src/ie-bridge.h (original)
+++ trunk/src/ie-bridge.h Tue Feb 3 04:00:39 2009
@@ -154,6 +154,10 @@
void _ie_bridge_set_history (IEBridge *ie,
GtkIEEmbedHistoryDirection direction,
const GList *history);
+void _ie_bridge_set_whole_history
+ (IEBridge *ie,
+ const GList *history,
+ guint current_position);
guint _ie_bridge_get_history_count
(IEBridge *ie);
guint _ie_bridge_get_current_position_in_history
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]