[pan2/testing] improved flag option + icon
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing] improved flag option + icon
- Date: Fri, 9 Dec 2011 14:26:40 +0000 (UTC)
commit ec882875e8440ea3850a61295d419a6a7281d7e8
Author: Heinrich MÃller <henmull src gnome org>
Date: Sun Dec 4 23:01:41 2011 +0100
improved flag option + icon
pan/data-impl/data-impl.h | 2 +-
pan/data-impl/headers.cc | 2 +-
pan/data/data.cc | 2 +-
pan/data/data.h | 6 ++++--
pan/gui/actions.cc | 19 +++++++++++++------
pan/gui/gui.cc | 27 ++++++++++++++++++++++-----
pan/gui/gui.h | 4 +++-
pan/gui/header-pane.cc | 19 ++++++++++---------
pan/gui/header-pane.h | 9 ++++++---
pan/gui/pan-ui.h | 3 ++-
pan/gui/pan.ui.h | 2 ++
11 files changed, 65 insertions(+), 30 deletions(-)
---
diff --git a/pan/data-impl/data-impl.h b/pan/data-impl/data-impl.h
index 166040e..1cd97b1 100644
--- a/pan/data-impl/data-impl.h
+++ b/pan/data-impl/data-impl.h
@@ -375,7 +375,7 @@ namespace pan
/***
**
***/
- virtual void fire_article_flag_changed (const Article* a, const Quark& group);
+ virtual void fire_article_flag_changed (articles_t& a, const Quark& group);
struct GroupHeaders
{
diff --git a/pan/data-impl/headers.cc b/pan/data-impl/headers.cc
index 47b5485..adf1420 100644
--- a/pan/data-impl/headers.cc
+++ b/pan/data-impl/headers.cc
@@ -200,7 +200,7 @@ DataImpl :: unref_group (const Quark& group)
}
void
-DataImpl :: fire_article_flag_changed (const Article* a, const Quark& group)
+DataImpl :: fire_article_flag_changed (articles_t& a, const Quark& group)
{
GroupHeaders * h (get_group_headers (group));
h->_dirty = true;
diff --git a/pan/data/data.cc b/pan/data/data.cc
index 0182032..6290d5b 100644
--- a/pan/data/data.cc
+++ b/pan/data/data.cc
@@ -71,7 +71,7 @@ Data :: fire_group_subscribe (const Quark& group, bool sub)
}
void
-Data :: fire_article_flag_changed (const Article* a, const Quark& group)
+Data :: fire_article_flag_changed (articles_t& 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 9649f96..89bf317 100644
--- a/pan/data/data.h
+++ b/pan/data/data.h
@@ -246,6 +246,8 @@ namespace pan
public:
+ typedef std::vector<const Article*> articles_t;
+
/**
* Interface class for objects that listen to a Data's events.
* @ingroup data
@@ -264,7 +266,7 @@ namespace pan
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) {}
+ virtual void on_article_flag_changed (articles_t& a UNUSED, const Quark& group UNUSED) {}
};
void add_listener (Listener * l);
@@ -290,7 +292,7 @@ namespace pan
public:
- virtual void fire_article_flag_changed (const Article* a, const Quark& group);
+ virtual void fire_article_flag_changed (articles_t& a, const Quark& group);
/*****************************************************************
***
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index a56ecdd..ca78b8e 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -63,7 +63,8 @@ namespace
{ icon_read_unread_article, "ICON_READ_UNREAD_ARTICLE" },
{ icon_read_unread_thread, "ICON_READ_UNREAD_THREAD" },
{ icon_score, "ICON_SCORE" },
- { icon_search_pulldown, "ICON_SEARCH_PULLDOWN" }
+ { icon_search_pulldown, "ICON_SEARCH_PULLDOWN" },
+ { icon_red_flag, "ICON_FLAGGED"}
};
void
@@ -144,7 +145,8 @@ namespace
void do_plonk (GtkAction*) { pan_ui->do_plonk(); }
void do_ignore (GtkAction*) { pan_ui->do_ignore(); }
void do_watch (GtkAction*) { pan_ui->do_watch(); }
- void do_flag (GtkAction*) { pan_ui->do_flag(); }
+ void do_flag_on (GtkAction*) { pan_ui->do_flag_on(); }
+ void do_flag_off (GtkAction*) { pan_ui->do_flag_off(); }
void do_next_flag (GtkAction*) { pan_ui->do_next_flag(); }
void do_last_flag (GtkAction*) { pan_ui->do_last_flag(); }
void do_show_score_dialog (GtkAction*) { pan_ui->do_show_score_dialog(); }
@@ -541,10 +543,15 @@ namespace
NULL,
G_CALLBACK(do_ignore) },
- { "flag-thread", NULL,
- N_("_Flag Thread"), "X",
- N_("_Flag Thread"),
- G_CALLBACK(do_flag) },
+ { "flag-thread", "ICON_FLAGGED",
+ N_("_Toggle Flag on for Thread"), "X",
+ N_("_Toggle Flag on for Thread"),
+ G_CALLBACK(do_flag_on) },
+
+ { "unflag-thread", NULL,
+ N_("_Toggle Flag off for Thread"), "<shift>X",
+ N_("_Toggle Flag off for Thread"),
+ G_CALLBACK(do_flag_off) },
{ "next-flagged", NULL,
N_("_Goto next flagged Thread"), "plus",
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index c8e6d44..fb3dbbb 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1139,14 +1139,31 @@ void GUI :: do_ignore ()
}
void
-GUI :: do_flag ()
+GUI :: do_flag_on ()
+{
+ do_flag(true);
+}
+
+void
+GUI :: do_flag_off ()
+{
+ do_flag(false);
+}
+
+
+void
+GUI :: do_flag (bool on)
{
/// TODO flag selection
- Article* a = _header_pane->get_first_selected_article();
- g_return_if_fail(a);
- a->toggle_flag();
+ std::vector<const Article*> v(_header_pane->get_full_selection_v());
+ g_return_if_fail(!v.empty());
+ foreach (std::vector<const Article*>,v,it)
+ {
+ Article* a((Article*)*it);
+ a->set_flag(on);
+ }
const Quark& g(_header_pane->get_group());
- _data.fire_article_flag_changed(a, g);
+ _data.fire_article_flag_changed(v, g);
}
void
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 4566504..a8b0bb4 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -135,7 +135,8 @@ namespace pan
virtual void do_plonk ();
virtual void do_watch ();
virtual void do_ignore ();
- virtual void do_flag ();
+ virtual void do_flag_on ();
+ virtual void do_flag_off ();
virtual void do_next_flag ();
virtual void do_last_flag ();
virtual void do_show_score_dialog ();
@@ -186,6 +187,7 @@ namespace pan
void step_bookmarks(int step);
void do_read_or_save_articles ();
+ void do_flag(bool);
public:
static std::string prompt_user_for_save_path (GtkWindow * parent, const Prefs& prefs);
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index 6db8ce3..c4b0728 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -505,8 +505,8 @@ HeaderPane :: rebuild ()
{
quarks_t selectme;
if (1) {
- const articles_t old_selection (get_full_selection ());
- foreach_const (articles_t, old_selection, it)
+ const articles_set old_selection (get_full_selection ());
+ foreach_const (articles_set, old_selection, it)
selectme.insert ((*it)->message_id);
}
@@ -790,7 +790,7 @@ HeaderPane :: get_first_selected_article ()
}
const guint
-HeaderPane :: get_full_selection_rows_num()
+HeaderPane :: get_full_selection_rows_num() const
{
return (gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(_tree_view))));
}
@@ -831,7 +831,7 @@ HeaderPane :: get_full_selection () const
void
HeaderPane :: walk_and_collect (GtkTreeModel * model,
GtkTreeIter * cur,
- articles_t & setme) const
+ articles_set & setme) const
{
for (;;) {
setme.insert (get_article (model, cur));
@@ -858,7 +858,7 @@ HeaderPane :: get_nested_foreach (GtkTreeModel * model,
gpointer data) const
{
NestedData& ndata (*static_cast<NestedData*>(data));
- articles_t& articles (ndata.articles);
+ articles_set& articles (ndata.articles);
articles.insert (get_article (model, iter));
const bool expanded (gtk_tree_view_row_expanded (GTK_TREE_VIEW(_tree_view), path));
GtkTreeIter child;
@@ -876,7 +876,7 @@ HeaderPane :: get_nested_foreach_static (GtkTreeModel* model,
ndata.pane->get_nested_foreach (model, path, iter, &ndata);
}
-articles_t
+articles_set
HeaderPane :: get_nested_selection (bool do_mark_all) const
{
NestedData data;
@@ -2265,10 +2265,11 @@ HeaderPane :: rebuild_article_action (const Quark& message_id)
}
void
-HeaderPane :: on_article_flag_changed (const Article* a, const Quark& group)
+HeaderPane :: on_article_flag_changed (articles_t& a, const Quark& group)
{
- g_return_if_fail(a);
- rebuild_article_action (a->message_id);
+ g_return_if_fail(!a.empty());
+ foreach_const (articles_t, a, it)
+ rebuild_article_action ((*it)->message_id);
}
void
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index 32b6abc..7908cfe 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -65,6 +65,9 @@ namespace pan
virtual void operator() (GtkTreeModel* model, GtkTreeIter* iter, const Article& a) = 0;
};
+ typedef std::vector<const Article*> articles_t;
+ typedef std::set<const Article*> articles_set;
+
/**
* Header Pane in the main window of Pan's GUI.
* @ingroup GUI
@@ -119,7 +122,7 @@ namespace pan
Article* get_first_selected_article ();
std::set<const Article*> get_full_selection () const;
std::vector<const Article*> get_full_selection_v () const;
- const guint get_full_selection_rows_num();
+ const guint get_full_selection_rows_num () const;
std::set<const Article*> get_nested_selection (bool do_mark_all) const;
bool set_group (const Quark& group);
const Quark& get_group () { return _group; }
@@ -146,7 +149,7 @@ namespace pan
virtual void on_prefs_color_changed (const StringView&, const GdkColor&) {}
public:
- virtual void on_article_flag_changed (const Article* a, const Quark& group);
+ virtual void on_article_flag_changed (articles_t& a, const Quark& group);
private:
virtual void on_queue_task_active_changed (Queue&, Task&, bool active UNUSED) { }
@@ -341,7 +344,7 @@ namespace pan
class CountUnread;
class RowInserter;
class SimilarWalk;
- void walk_and_collect (GtkTreeModel*, GtkTreeIter*, std::set<const Article*>&) const;
+ void walk_and_collect (GtkTreeModel*, GtkTreeIter*, articles_set&) const;
private:
typedef void RenderFunc (GtkTreeViewColumn*, GtkCellRenderer*, GtkTreeModel*, GtkTreeIter*, gpointer);
static RenderFunc render_action;
diff --git a/pan/gui/pan-ui.h b/pan/gui/pan-ui.h
index 81a894d..a2ed903 100644
--- a/pan/gui/pan-ui.h
+++ b/pan/gui/pan-ui.h
@@ -66,7 +66,8 @@ namespace pan
virtual void do_plonk () = 0;
virtual void do_watch () = 0;
virtual void do_ignore () = 0;
- virtual void do_flag () = 0;
+ virtual void do_flag_on () = 0;
+ virtual void do_flag_off () = 0;
virtual void do_next_flag () = 0;
virtual void do_last_flag () = 0;
virtual void do_cancel_article () = 0;
diff --git a/pan/gui/pan.ui.h b/pan/gui/pan.ui.h
index 1a5fdc0..c6b8c3b 100644
--- a/pan/gui/pan.ui.h
+++ b/pan/gui/pan.ui.h
@@ -131,6 +131,7 @@ const char * fallback_ui_file =
" <menuitem action='ignore-thread' />\n"
" <separator />\n"
" <menuitem action='flag-thread' />\n"
+" <menuitem action='unflag-thread' />\n"
" <menuitem action='next-flagged' />\n"
" <menuitem action='last-flagged' />\n"
" <separator />\n"
@@ -203,6 +204,7 @@ const char * fallback_ui_file =
" <menuitem action='ignore-thread' />\n"
" <separator />\n"
" <menuitem action='flag-thread' />\n"
+" <menuitem action='unflag-thread' />\n"
" <menuitem action='next-flagged' />\n"
" <menuitem action='last-flagged' />\n"
" <separator />\n"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]