[pan2: 223/268] * fixed bug in flags not saving to headers * fixed glib version requirement string
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 223/268] * fixed bug in flags not saving to headers * fixed glib version requirement string
- Date: Mon, 2 Jan 2012 15:56:45 +0000 (UTC)
commit 9a34affbe287f9c597f7d191deb8854914748ce0
Author: Heinrich MÃller <henmull src gnome org>
Date: Sun Dec 4 15:22:21 2011 +0100
* fixed bug in flags not saving to headers
* fixed glib version requirement string
configure.in | 2 +-
pan/data-impl/data-impl.cc | 2 +
pan/data-impl/data-impl.h | 21 ++++++----------
pan/data-impl/headers.cc | 16 ++++++++++--
pan/data/data.cc | 7 +++++
pan/data/data.h | 7 +++++
pan/gui/gui.cc | 14 ++++++++---
pan/gui/gui.h | 4 ++-
pan/gui/header-pane.cc | 55 +++++++++++++++++++++----------------------
pan/gui/header-pane.h | 2 +-
10 files changed, 79 insertions(+), 51 deletions(-)
---
diff --git a/configure.in b/configure.in
index ed6ce47..6ab3e39 100644
--- a/configure.in
+++ b/configure.in
@@ -45,7 +45,7 @@ dnl
dnl GtkSpell is optional: GTKSPELL_REQUIRED refers to the minimum version
dnl needed if you want to build Pan with spellchecking in the Post window.
-GLIB_REQUIRED=2.28.6
+GLIB_REQUIRED=2.14.0
GMIME_REQUIRED=2.4.0
GTK_REQUIRED=2.16.0
GTK3_REQUIRED=3.0.0
diff --git a/pan/data-impl/data-impl.cc b/pan/data-impl/data-impl.cc
index 15c179a..d285e9e 100644
--- a/pan/data-impl/data-impl.cc
+++ b/pan/data-impl/data-impl.cc
@@ -106,6 +106,7 @@ DataImpl :: rebuild_backend ()
DataImpl :: ~DataImpl ()
{
save_state ();
+
}
void
@@ -118,3 +119,4 @@ DataImpl :: save_state ()
save_newsrc_files (*_data_io);
}
}
+
diff --git a/pan/data-impl/data-impl.h b/pan/data-impl/data-impl.h
index 97c9ce3..166040e 100644
--- a/pan/data-impl/data-impl.h
+++ b/pan/data-impl/data-impl.h
@@ -90,6 +90,7 @@ namespace pan
virtual CertStore& get_certstore () { return _certstore; }
virtual const CertStore& get_certstore () const { return _certstore; }
+
private:
EncodeCache _encode_cache;
ArticleCache _cache;
@@ -309,19 +310,6 @@ namespace pan
private: // implementation
-// struct Headers
-// {
-// struct Listener
-// {
-// virtual ~Listener() {}
-// /* functions that other listeners listen on */
-// virtual void on_articles_plus (const Quark&, const quarks_t&) = 0;
-// };
-// };
-
-// typedef std::set<Listener*> listeners_t;
-// listeners_t _header_listeners;
-
/** 'article' MUST have been allocated by GroupHeaders::alloc_new_article()!! */
void load_article (const Quark& g, Article * article, const StringView& references);
@@ -384,6 +372,11 @@ namespace pan
}
};
+ /***
+ **
+ ***/
+ virtual void fire_article_flag_changed (const Article* a, const Quark& group);
+
struct GroupHeaders
{
int _ref;
@@ -409,6 +402,7 @@ namespace pan
const Article* find_article (const Quark& mid) const;
void remove_articles (const quarks_t& mids);
void build_references_header (const Article* article, std::string& setme) const;
+
};
static void find_nodes (const quarks_t & mids,
@@ -497,6 +491,7 @@ namespace pan
private:
void cache_articles (std::set<const Article*> s);
void download_articles (std::set<const Article*> s);
+
};
diff --git a/pan/data-impl/headers.cc b/pan/data-impl/headers.cc
index e6feb55..47b5485 100644
--- a/pan/data-impl/headers.cc
+++ b/pan/data-impl/headers.cc
@@ -47,10 +47,12 @@ DataImpl :: GroupHeaders :: GroupHeaders ():
_ref (0),
_dirty (false)
{
+
}
DataImpl :: GroupHeaders :: ~GroupHeaders ()
{
+
}
DataImpl :: ArticleNode*
@@ -177,7 +179,7 @@ DataImpl :: ref_group (const Quark& group)
load_headers (*_data_io, group);
}
++h->_ref;
- //std::cerr << LINE_ID << " group " << group << " refcount up to " << h->_ref << std::endl;
+// std::cerr << LINE_ID << " group " << group << " refcount up to " << h->_ref << std::endl;
}
void
@@ -187,10 +189,10 @@ DataImpl :: unref_group (const Quark& group)
pan_return_if_fail (h != 0);
--h->_ref;
- //std::cerr << LINE_ID << " group " << group << " refcount down to " << h->_ref << std::endl;
+// std::cerr << LINE_ID << " group " << group << " refcount down to " << h->_ref << std::endl;
if (h->_ref == 0)
{
- if (h->_dirty)
+ if (h->_dirty )
save_headers (*_data_io, group);
h->_dirty = false;
free_group_headers_memory (group);
@@ -198,6 +200,14 @@ DataImpl :: unref_group (const Quark& group)
}
void
+DataImpl :: fire_article_flag_changed (const Article* a, const Quark& group)
+{
+ GroupHeaders * h (get_group_headers (group));
+ h->_dirty = true;
+ Data::fire_article_flag_changed(a,group);
+}
+
+void
DataImpl :: find_nodes (const quarks_t & mids,
nodes_t & nodes,
nodes_v & setme)
diff --git a/pan/data/data.cc b/pan/data/data.cc
index d29b6f4..0182032 100644
--- a/pan/data/data.cc
+++ b/pan/data/data.cc
@@ -69,3 +69,10 @@ Data :: fire_group_subscribe (const Quark& group, bool sub)
for (listeners_t::iterator it(_listeners.begin()), end(_listeners.end()); it!=end; )
(*it++)->on_group_subscribe (group, sub);
}
+
+void
+Data :: fire_article_flag_changed (const Article* a, const Quark& group)
+{
+ for (listeners_t::iterator it(_listeners.begin()), end(_listeners.end()); it!=end; )
+ (*it++)->on_article_flag_changed (a, group);
+}
diff --git a/pan/data/data.h b/pan/data/data.h
index 2182b64..9649f96 100644
--- a/pan/data/data.h
+++ b/pan/data/data.h
@@ -262,6 +262,9 @@ namespace pan
virtual void on_group_counts (const Quark& group UNUSED,
unsigned long unread UNUSED,
unsigned long total UNUSED) {}
+
+ /* listener for article flag, don't call too often */
+ virtual void on_article_flag_changed (const Article* a UNUSED, const Quark& group UNUSED) {}
};
void add_listener (Listener * l);
@@ -285,6 +288,10 @@ namespace pan
typedef std::set<Listener*> listeners_t;
listeners_t _listeners;
+ public:
+
+ virtual void fire_article_flag_changed (const Article* a, const Quark& group);
+
/*****************************************************************
***
*** GROUPS
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index f5eb56f..c8e6d44 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -340,6 +340,7 @@ GUI :: GUI (Data& data, Queue& queue, Prefs& prefs, GroupPrefs& group_prefs):
_prefs.add_listener (this);
_certstore.add_listener(this);
Log::get().add_listener (this);
+ _data.add_listener (this);
gtk_accel_map_load (get_accel_filename().c_str());
@@ -364,6 +365,10 @@ namespace
GUI :: ~GUI ()
{
_certstore.remove_listener(this);
+ _data.remove_listener(this);
+ _prefs.remove_listener (this);
+ _queue.remove_listener (this);
+ Log::get().remove_listener (this);
const std::string accel_filename (get_accel_filename());
gtk_accel_map_save (accel_filename.c_str());
@@ -378,9 +383,7 @@ GUI :: ~GUI ()
&& (gdk_window_get_state( gtk_widget_get_window(_root)) & GDK_WINDOW_STATE_MAXIMIZED);
_prefs.set_flag ("main-window-is-maximized", maximized);
- _prefs.remove_listener (this);
- _queue.remove_listener (this);
- Log::get().remove_listener (this);
+
g_source_remove (upkeep_tag);
std::set<GtkWidget*> unref;
@@ -1138,9 +1141,12 @@ void GUI :: do_ignore ()
void
GUI :: do_flag ()
{
+ /// TODO flag selection
Article* a = _header_pane->get_first_selected_article();
+ g_return_if_fail(a);
a->toggle_flag();
- _header_pane->on_article_flag_toggled(a);
+ const Quark& g(_header_pane->get_group());
+ _data.fire_article_flag_changed(a, g);
}
void
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 031f008..4566504 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -25,6 +25,7 @@
#include <pan/data/article-cache.h>
#include <pan/data/encode-cache.h>
#include <pan/tasks/queue.h>
+#include <pan/data/article.h>
#include <pan/data/cert-store.h>
#include <pan/gui/action-manager.h>
#include <pan/gui/pan-ui.h>
@@ -53,7 +54,8 @@ namespace pan
private Progress::Listener,
private Queue::Listener,
private Prefs::Listener,
- private CertStore::Listener
+ private CertStore::Listener,
+ private Data::Listener
{
public:
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index 9fdc9d1..bfe36c3 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -1637,7 +1637,7 @@ HeaderPane :: ~HeaderPane ()
_cache.remove_listener (this);
_queue.remove_listener (this);
_prefs.remove_listener (this);
- _data.remove_listener (this);
+ _data.remove_listener (this);
// save the column widths
GList * columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(_tree_view));
@@ -2260,7 +2260,7 @@ HeaderPane :: rebuild_article_action (const Quark& message_id)
}
void
-HeaderPane :: on_article_flag_toggled (Article* a)
+HeaderPane :: on_article_flag_changed (const Article* a, const Quark& group)
{
g_return_if_fail(a);
rebuild_article_action (a->message_id);
@@ -2344,10 +2344,10 @@ struct HeaderPane::SimilarWalk: public PanTreeStore::WalkFunctor
// strip out frequent substrings that tend to skew string_likeness too high
static const char * const frequent_substrings [] = { "mp3", "gif", "jpg", "jpeg", "yEnc" };
for (size_t i=0; i!=G_N_ELEMENTS(frequent_substrings); ++i) {
- std::string::size_type pos;
- const char * needle (frequent_substrings[i]);
- while (((pos = sa.find (needle))) != std::string::npos) sa.erase (pos, strlen(needle));
- while (((pos = sb.find (needle))) != std::string::npos) sb.erase (pos, strlen(needle));
+ std::string::size_type pos;
+ const char * needle (frequent_substrings[i]);
+ while (((pos = sa.find (needle))) != std::string::npos) sa.erase (pos, strlen(needle));
+ while (((pos = sb.find (needle))) != std::string::npos) sb.erase (pos, strlen(needle));
}
// strip out non-alpha characters
@@ -2362,11 +2362,11 @@ struct HeaderPane::SimilarWalk: public PanTreeStore::WalkFunctor
const bool is_long_string (min_len >= 30);
double min_closeness;
if (is_short_string)
- min_closeness = 0.6;
+ min_closeness = 0.6;
else if (is_long_string)
- min_closeness = 0.5;
+ min_closeness = 0.5;
else
- min_closeness = 0.55;
+ min_closeness = 0.55;
return string_likeness (sa, sb) >= min_closeness;
}
@@ -2378,30 +2378,29 @@ struct HeaderPane::SimilarWalk: public PanTreeStore::WalkFunctor
if (!a.strchr(' ')) // only one word, so count common characters
{
- int common_chars = 0;
+ int common_chars = 0;
- foreach_const (StringView, a, it) {
- const char * pos = b.strchr (*it);
- if (pos) {
- ++common_chars;
- b.eat_chars (pos - b.str);
- }
- }
+ foreach_const (StringView, a, it) {
+ const char * pos = b.strchr (*it);
+ if (pos) {
+ ++common_chars;
+ b.eat_chars (pos - b.str);
+ }
+ }
- retval = (double)common_chars / a.len;
+ retval = (double)common_chars / a.len;
}
- else // more than one word, so count common words
+ else // more than one word, so count common words
{
- StringView tok;
- int str1_words(0), common_words(0);
- while (a.pop_token (tok)) {
- ++str1_words;
- const char *pch = b.strstr (tok);
- if (pch) ++common_words;
- }
- retval = (double)common_words / str1_words;
+ StringView tok;
+ int str1_words(0), common_words(0);
+ while (a.pop_token (tok)) {
+ ++str1_words;
+ const char *pch = b.strstr (tok);
+ if (pch) ++common_words;
+ }
+ retval = (double)common_words / str1_words;
}
-
return retval;
}
};
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index 44524da..32b6abc 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -146,7 +146,7 @@ namespace pan
virtual void on_prefs_color_changed (const StringView&, const GdkColor&) {}
public:
- void on_article_flag_toggled(Article*) ;
+ virtual void on_article_flag_changed (const Article* a, const Quark& group);
private:
virtual void on_queue_task_active_changed (Queue&, Task&, bool active UNUSED) { }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]