aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-01 18:37:11 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-01-01 18:37:11 +0800
commita4f9aed333d06c864f4ed719fa41eda82eff4713 (patch)
tree7daf75b10d5a45b9f7b6fc7e6f74dfce87b5a573
parent90870f6628f09e7e46693c95c9237b602960f1ab (diff)
downloadgsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.tar
gsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.tar.gz
gsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.tar.bz2
gsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.tar.lz
gsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.tar.xz
gsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.tar.zst
gsoc2013-epiphany-a4f9aed333d06c864f4ed719fa41eda82eff4713.zip
*** empty log message ***
-rw-r--r--ChangeLog17
-rw-r--r--TODO2
-rw-r--r--data/glade/epiphany.glade2
-rw-r--r--embed/ephy-history.c104
-rw-r--r--embed/ephy-history.h3
-rw-r--r--lib/toolbar/ephy-tb-button.c33
-rw-r--r--src/bookmarks/ephy-bookmarks.c1
-rwxr-xr-xsrc/history-dialog.c4
8 files changed, 159 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index a63c8feb8..a3b87c904 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2003-01-01 Marco Pesenti Gritti <marco@it.gnome.org>
+
+ * TODO:
+ * data/glade/epiphany.glade:
+ * embed/ephy-history.c: (page_is_obsolete),
+ (remove_obsolete_pages), (periodic_save_cb), (ephy_history_init),
+ (ephy_history_finalize), (ephy_history_clear),
+ (ephy_history_get_last_page), (ephy_history_remove):
+ * embed/ephy-history.h:
+ * lib/toolbar/ephy-tb-button.c: (button_state_changed_cb),
+ (ephy_tb_button_set_show_arrow), (ephy_tb_button_set_enable_menu):
+ * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_add):
+ * src/history-dialog.c: (get_date_filter):
+
+ Save history every 5 minutes, drop items older than 30 days,
+ fix Clear. Better prelight for navigation buttons.
+
2002-12-31 Marco Pesenti Gritti <marco@it.gnome.org>
* configure.in:
diff --git a/TODO b/TODO
index e5019d541..e114b2a5f 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
To do:
- implement phoenix like popup blocking / make popups less annoying
-- drop items from history when they are not visited since some time
Done:
@@ -17,3 +16,4 @@ Done:
* autocompletion refine borked for bookmarks
* history scoring for autocompletion
* urls like www.gnome.org and gnome.org should use same folder in history
+* drop items from history when they are not visited since some time
diff --git a/data/glade/epiphany.glade b/data/glade/epiphany.glade
index 520d9217e..c9d30cb91 100644
--- a/data/glade/epiphany.glade
+++ b/data/glade/epiphany.glade
@@ -248,7 +248,7 @@
<child>
<widget class="GtkMenuItem" id="convertwidget7">
<property name="visible">True</property>
- <property name="label" translatable="yes">Month</property>
+ <property name="label" translatable="yes">Two weeks</property>
<property name="use_underline">True</property>
</widget>
</child>
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 0511cfe67..7c6f08e9d 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -30,6 +30,11 @@
#define EPHY_HISTORY_XML_VERSION "0.1"
+/* how often to save the history, in milliseconds */
+#define HISTORY_SAVE_INTERVAL (60 * 5 * 1000)
+
+#define HISTORY_PAGE_OBSOLETE_DAYS 30
+
struct EphyHistoryPrivate
{
char *xml_file;
@@ -40,6 +45,7 @@ struct EphyHistoryPrivate
GStaticRWLock *hosts_hash_lock;
GHashTable *pages_hash;
GStaticRWLock *pages_hash_lock;
+ int autosave_timeout;
};
enum
@@ -214,6 +220,49 @@ ephy_history_load (EphyHistory *eb)
xmlFreeDoc (doc);
}
+static gboolean
+page_is_obsolete (EphyNode *node, GDate *now)
+{
+ int last_visit;
+ GDate date;
+
+ last_visit = ephy_node_get_property_int
+ (node, EPHY_NODE_PAGE_PROP_LAST_VISIT);
+
+ g_date_clear (&date, 1);
+ g_date_set_time (&date, last_visit);
+
+ return (g_date_days_between (&date, now) >=
+ HISTORY_PAGE_OBSOLETE_DAYS);
+}
+
+static void
+remove_obsolete_pages (EphyHistory *eb)
+{
+ GPtrArray *children;
+ int i;
+ GTime now;
+ GDate current_date;
+
+ now = time (NULL);
+ g_date_clear (&current_date, 1);
+ g_date_set_time (&current_date, time (NULL));
+
+ children = ephy_node_get_children (eb->priv->pages);
+ ephy_node_thaw (eb->priv->pages);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+
+ if (page_is_obsolete (kid, &current_date))
+ {
+ ephy_history_remove (eb, kid);
+ }
+ }
+}
+
static void
ephy_history_save (EphyHistory *eb)
{
@@ -311,6 +360,15 @@ pages_removed_cb (EphyNode *node,
g_static_rw_lock_writer_unlock (eb->priv->pages_hash_lock);
}
+static gboolean
+periodic_save_cb (EphyHistory *eh)
+{
+ remove_obsolete_pages (eh);
+ ephy_history_save (eh);
+
+ return TRUE;
+}
+
static void
ephy_history_init (EphyHistory *eb)
{
@@ -360,6 +418,12 @@ ephy_history_init (EphyHistory *eb)
ephy_history_load (eb);
ephy_history_emit_data_changed (eb);
+
+ /* setup the periodic history saving callback */
+ eb->priv->autosave_timeout =
+ g_timeout_add (HISTORY_SAVE_INTERVAL,
+ (GSourceFunc)periodic_save_cb,
+ eb);
}
static void
@@ -383,6 +447,8 @@ ephy_history_finalize (GObject *object)
g_hash_table_destroy (eb->priv->hosts_hash);
g_static_rw_lock_free (eb->priv->hosts_hash_lock);
+ g_source_remove (eb->priv->autosave_timeout);
+
g_free (eb->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -653,7 +719,19 @@ ephy_history_set_page_title (EphyHistory *gh,
void
ephy_history_clear (EphyHistory *gh)
{
- ephy_node_unref (gh->priv->hosts);
+ GPtrArray *children;
+ int i;
+
+ children = ephy_node_get_children (gh->priv->hosts);
+ ephy_node_thaw (gh->priv->hosts);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+ ephy_node_unref (kid);
+ }
+
ephy_history_save (gh);
}
@@ -677,3 +755,27 @@ ephy_history_get_last_page (EphyHistory *gh)
return ephy_node_get_property_string
(gh->priv->last_page, EPHY_NODE_PAGE_PROP_LOCATION);
}
+
+void
+ephy_history_remove (EphyHistory *gh, EphyNode *node)
+{
+ EphyNode *host;
+ int host_id;
+
+ host_id = ephy_node_get_property_int (node, EPHY_NODE_PAGE_PROP_HOST_ID);
+ if (host_id < 0)
+ {
+ ephy_node_unref (node);
+ return;
+ }
+
+ host = ephy_node_get_from_id (host_id);
+ if (ephy_node_get_n_children (host) == 1)
+ {
+ ephy_node_unref (host);
+ }
+ else
+ {
+ ephy_node_unref (node);
+ }
+}
diff --git a/embed/ephy-history.h b/embed/ephy-history.h
index 641ab6d7c..4bb9c14b1 100644
--- a/embed/ephy-history.h
+++ b/embed/ephy-history.h
@@ -85,6 +85,9 @@ void ephy_history_set_page_title (EphyHistory *gh,
const char *ephy_history_get_last_page (EphyHistory *gh);
+void ephy_history_remove (EphyHistory *gh,
+ EphyNode *node);
+
void ephy_history_clear (EphyHistory *gh);
G_END_DECLS
diff --git a/lib/toolbar/ephy-tb-button.c b/lib/toolbar/ephy-tb-button.c
index 4b251a094..4485102f0 100644
--- a/lib/toolbar/ephy-tb-button.c
+++ b/lib/toolbar/ephy-tb-button.c
@@ -374,6 +374,30 @@ ephy_tb_button_set_image (EphyTbButton *b, GtkWidget *image)
ephy_tb_button_build (b);
}
+static void
+button_state_changed_cb (GtkWidget *widget, GtkStateType previous_state, EphyTbButton *b)
+{
+ EphyTbButtonPrivate *p = b->priv;
+ GtkWidget *button;
+ GtkStateType state = GTK_WIDGET_STATE (widget);
+ GtkStateType other;
+
+ if (state == GTK_STATE_ACTIVE ||
+ state == GTK_STATE_SELECTED ||
+ state == GTK_STATE_INSENSITIVE)
+ {
+ return;
+ }
+
+ button = (widget == p->arrow_widget) ? p->button : p->arrow_widget;
+ other = GTK_WIDGET_STATE (button);
+
+ if (state != other)
+ {
+ gtk_widget_set_state (button, state);
+ }
+}
+
void
ephy_tb_button_set_show_arrow (EphyTbButton *b, gboolean value)
{
@@ -402,10 +426,15 @@ ephy_tb_button_set_show_arrow (EphyTbButton *b, gboolean value)
g_signal_connect (p->arrow_widget, "key_press_event",
G_CALLBACK (ephy_tb_button_arrow_key_press_event_cb),
b);
-
g_signal_connect (p->arrow_widget, "button_press_event",
G_CALLBACK (ephy_tb_button_arrow_button_press_event_cb),
b);
+ g_signal_connect (p->arrow_widget, "state_changed",
+ G_CALLBACK (button_state_changed_cb),
+ b);
+ g_signal_connect (p->button, "state_changed",
+ G_CALLBACK (button_state_changed_cb),
+ b);
gtk_widget_show_all (p->arrow_widget);
gtk_box_pack_end_defaults (GTK_BOX (b), p->arrow_widget);
@@ -420,7 +449,7 @@ ephy_tb_button_set_enable_menu (EphyTbButton *b, gboolean value)
if (value && !p->menu)
{
p->menu = GTK_MENU (gtk_menu_new ());
- g_signal_connect (p->menu, "deactivate",
+ g_signal_connect (p->menu, "deactivate",
G_CALLBACK (ephy_tb_button_menu_deactivated_cb), b);
}
else if (!value && p->menu)
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 2353ea7da..2432846e3 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -644,6 +644,7 @@ ephy_bookmarks_add (EphyBookmarks *eb,
ephy_node_add_child (eb->priv->bookmarks, bm);
ephy_bookmarks_emit_data_changed (eb);
+ ephy_bookmarks_save (eb);
return bm;
}
diff --git a/src/history-dialog.c b/src/history-dialog.c
index 4f5b5cc2b..ac9aa5449 100755
--- a/src/history-dialog.c
+++ b/src/history-dialog.c
@@ -311,9 +311,9 @@ get_date_filter (int filter_type,
case 4:
g_date_subtract_days (&current_date, 7);
break;
- /* Month */
+ /* Two weeks */
case 5:
- g_date_subtract_months (&current_date, 1);
+ g_date_subtract_days (&current_date, 14);
break;
default:
break;