[pan2] http://lists.nongnu.org/archive/html/pan-users/2012-07/msg00033.html



commit 03d24a9d8b6eba0f5824dc07fe6c6b4d290908a3
Author: Heinrich MÃller <henmull src gnome org>
Date:   Thu Jul 12 21:34:26 2012 +0200

    http://lists.nongnu.org/archive/html/pan-users/2012-07/msg00033.html

 pan/data-impl/data-impl.cc    |    4 ++-
 pan/data-impl/rules-filter.cc |   11 +++++++-
 pan/data-impl/rules-filter.h  |    3 +-
 pan/gui/actions.cc            |   37 +++++++++++++++++++++++++--
 pan/gui/gtk-compat.h          |    2 +
 pan/gui/gui.cc                |   10 +++++++
 pan/gui/gui.h                 |    2 +
 pan/gui/header-pane.cc        |   54 ++++++++++++++++++++++++++++++++++++----
 pan/gui/header-pane.h         |    2 +
 pan/gui/pan-ui.h              |    3 ++
 pan/gui/pan.ui.h              |    2 +
 pan/gui/prefs-ui.cc           |   27 ++++++++++++++++++--
 pan/gui/task-pane.cc          |    4 +-
 pan/gui/task-pane.h           |    1 +
 pan/icons/Makefile.am         |    4 ++-
 15 files changed, 147 insertions(+), 19 deletions(-)
---
diff --git a/pan/data-impl/data-impl.cc b/pan/data-impl/data-impl.cc
index e3410e9..b68e2b2 100644
--- a/pan/data-impl/data-impl.cc
+++ b/pan/data-impl/data-impl.cc
@@ -77,7 +77,9 @@ DataImpl :: DataImpl (const StringView& cache_ext, Prefs& prefs, bool unit_test,
   _prefs (prefs),
   _descriptions_loaded (false),
   newsrc_autosave_id (0),
-  newsrc_autosave_timeout (0)
+  newsrc_autosave_timeout (0),
+  _rules_filter (prefs.get_flag("autocache-mark-read", false), prefs.get_flag("auto-dl-mark-read", false),
+                 prefs.get_flag("auto-delete-mark-read", false))
 
 {
   rebuild_backend ();
diff --git a/pan/data-impl/rules-filter.cc b/pan/data-impl/rules-filter.cc
index 98e449b..e2b2211 100644
--- a/pan/data-impl/rules-filter.cc
+++ b/pan/data-impl/rules-filter.cc
@@ -39,11 +39,9 @@ RulesFilter :: finalize (Data& data)
   _mark_read.clear();
 
   const std::vector<const Article*> tmp2 ( _cached.begin(),  _cached.end());
-  data.mark_read ((const Article**)&tmp2.front(), tmp2.size());
   _cached.clear();
 
   const std::vector<const Article*> tmp3 (_downloaded.begin(), _downloaded.end());
-  data.mark_read ((const Article**)&tmp3.front(), tmp3.size());
   _downloaded.clear();
 }
 
@@ -88,17 +86,26 @@ RulesFilter :: test_article ( Data        & data,
 
     case RulesInfo::AUTOCACHE:
       if (pass)
+      {
         _cached.insert (&article);
+        if (_auto_cache_mark_read) _mark_read.insert(&article);
+      }
       break;
 
     case RulesInfo::AUTODOWNLOAD:
       if (pass)
+      {
         _downloaded.insert (&article);
+        if (_auto_dl_mark_read) _mark_read.insert(&article);
+      }
       break;
 
     case RulesInfo::DELETE_ARTICLE:
       if (pass)
+      {
          _delete.insert (&article);
+         if (_auto_delete_mark_read) _mark_read.insert(&article);
+      }
       break;
 
     default:
diff --git a/pan/data-impl/rules-filter.h b/pan/data-impl/rules-filter.h
index 0bf6ea8..dd37082 100644
--- a/pan/data-impl/rules-filter.h
+++ b/pan/data-impl/rules-filter.h
@@ -39,7 +39,7 @@ namespace pan
 
     public:
 
-      RulesFilter() {  }
+      RulesFilter(bool cache, bool dl, bool del) : _auto_cache_mark_read(cache), _auto_dl_mark_read(dl), _auto_delete_mark_read(del) {  }
 
       bool test_article (Data        & data,
                          RulesInfo   & rules,
@@ -49,6 +49,7 @@ namespace pan
       private:
         std::set<const Article*> _mark_read;
         std::set<const Article*> _delete;
+        bool _auto_cache_mark_read, _auto_dl_mark_read, _auto_delete_mark_read;
 
       public:
 
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index 1419708..c8e136f 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -74,7 +74,10 @@ namespace pan
     { icon_score, "ICON_SCORE" },
     { icon_search_pulldown, "ICON_SEARCH_PULLDOWN" },
     { icon_red_flag, "ICON_FLAGGED"},
-    { icon_get_flagged, "ICON_GET_FLAGGED" }
+    { icon_get_flagged, "ICON_GET_FLAGGED" },
+    { icon_expand_thread, "ICON_EXPAND_THREAD" },
+    { icon_collapse_thread, "ICON_COLLAPSE_THREAD" }
+
   };
 
   void
@@ -152,6 +155,8 @@ namespace pan
   void do_read_parent_article          (GtkAction*) { pan_ui->do_read_parent_article(); }
   void do_show_servers_dialog          (GtkAction*) { pan_ui->do_show_servers_dialog(); }
   void do_show_sec_dialog              (GtkAction*) { pan_ui->do_show_sec_dialog(); }
+  void do_collapse_thread              (GtkAction*) { pan_ui->do_collapse_thread(); }
+  void do_expand_thread                (GtkAction*) { pan_ui->do_expand_thread(); }
   void do_plonk                        (GtkAction*) { pan_ui->do_plonk(); }
   void do_ignore                       (GtkAction*) { pan_ui->do_ignore(); }
   void do_watch                        (GtkAction*) { pan_ui->do_watch(); }
@@ -252,6 +257,15 @@ namespace pan
     pan_ui->do_enable_toggle_rules(prefs->_rules_enabled);
   }
 
+  void do_toggle_expand_thread (GtkToggleAction * a)
+  {
+    const bool active (gtk_toggle_action_get_active (a));
+    if (active)
+      do_expand_thread(NULL);
+    else
+      do_collapse_thread(NULL);
+  }
+
   void do_match_only_watched_articles (GtkToggleAction * a)   { set_new_match_on_score_state (gtk_toggle_action_get_active(a) ? MATCH_WATCHED : prev_score_state); }
   void do_match_watched_articles (GtkToggleAction * a)        { set_score_state_bit_from_toggle (a, MATCH_WATCHED); }
   void do_match_high_scoring_articles (GtkToggleAction * a)   { set_score_state_bit_from_toggle (a, MATCH_HIGH_SCORING); }
@@ -670,7 +684,22 @@ namespace pan
       { "show-sec-dialog", GTK_STOCK_DIALOG_AUTHENTICATION,
         N_("Edit _SSL Certificates"), NULL,
         NULL,
-        G_CALLBACK(do_show_sec_dialog) } };
+        G_CALLBACK(do_show_sec_dialog) }
+/*
+       { "collapse-thread", "ICON_COLLAPSE_THREAD",
+         N_("Collapse selected Thread"), NULL,
+         NULL,
+         G_CALLBACK(do_collapse_thread)
+       },
+
+       { "expand-thread", "ICON_EXPAND_THREAD",
+         N_("Expand selected thread"), "E",
+         NULL,
+         G_CALLBACK(do_expand_thread)
+       }
+*/
+
+     };
 
   void prefs_toggle_callback_impl (GtkToggleAction * action)
   {
@@ -716,7 +745,9 @@ namespace pan
     { "match-low-scoring-articles", NULL, N_("Match Scores of -9998...-1 (_Low)"), NULL, NULL, G_CALLBACK(do_match_low_scoring_articles), true },
     { "match-ignored-articles", NULL, N_("Match Scores of -9999 (_Ignored)"), NULL, NULL, G_CALLBACK(do_match_ignored_articles), false },
 
-    { "enable-rules", NULL, N_("Enable/Disable All _Rules"), "R", NULL, G_CALLBACK(do_toggle_rules), true    }
+    { "enable-rules", NULL, N_("Enable/Disable All _Rules"), "R", NULL, G_CALLBACK(do_toggle_rules), true }
+
+    //{"toggle-expand-thread", NULL, N_("Toggle expansion of selected thread"), NULL, NULL, G_CALLBACK(do_toggle_expand_thread), true }
   };
 
   const guint n_toggle_entries (G_N_ELEMENTS(toggle_entries));
diff --git a/pan/gui/gtk-compat.h b/pan/gui/gtk-compat.h
index 985cfcb..72bf8ba 100644
--- a/pan/gui/gtk-compat.h
+++ b/pan/gui/gtk-compat.h
@@ -101,6 +101,8 @@ namespace
   #define GDK_KEY_Delete GDK_Delete
   #define GDK_KEY_Return GDK_Return
   #define GDK_KEY_Down GDK_Down
+  #define GDK_KEY_Left GDK_Left
+  #define GDK_KEY_Right GDK_Right
   #define GDK_KEY_Up GDK_Up
   #define GDK_KEY_KP_Up GDK_KP_Up
   #define GDK_KEY_KP_Down GDK_KP_Down
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 2e01ae8..2b1658b 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1138,6 +1138,16 @@ void GUI :: do_show_sec_dialog ()
 #endif
 }
 
+void GUI :: do_collapse_thread ()
+{
+  _header_pane->collapse_selected();
+}
+
+void GUI :: do_expand_thread ()
+{
+  _header_pane->expand_selected();
+}
+
 
 void GUI :: do_show_score_dialog ()
 {
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 09de6c3..80b871b 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -138,6 +138,8 @@ namespace pan
       virtual void do_read_parent_article ();
       virtual void do_show_servers_dialog ();
       virtual void do_show_sec_dialog ();
+      virtual void do_collapse_thread ();
+      virtual void do_expand_thread ();
       virtual void do_show_selected_article_info ();
       virtual void do_plonk ();
       virtual void do_watch ();
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index aecf1e3..6aba02c 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -373,11 +373,6 @@ HeaderPane :: create_row (const EvolutionDateMaker & e,
   return row;
 }
 
-namespace
-{
-  typedef std::vector<const Article*> article_v;
-}
-
 void
 HeaderPane ::  add_children_to_model (PanTreeStore               * store,
                                       PanTreeStore::Row          * parent_row,
@@ -690,6 +685,26 @@ namespace
 }
 
 void
+HeaderPane :: collapse_selected()
+{
+  {
+  // get a list of paths
+  GtkTreeModel * model (0);
+  GtkTreeView * view (GTK_TREE_VIEW (_tree_view));
+  GtkTreeSelection * selection (gtk_tree_view_get_selection (view));
+  GList * list (gtk_tree_selection_get_selected_rows (selection, &model));
+  if (list)
+  {
+    GtkTreePath * path (static_cast<GtkTreePath*>(list->data));
+    gtk_tree_view_collapse_row (view, path);
+//    gtk_tree_view_expand_to_path (view, path);
+  }
+  g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
+  g_list_free (list);
+}
+}
+
+void
 HeaderPane :: select_message_id (const Quark& mid, bool do_scroll)
 {
 
@@ -1083,8 +1098,25 @@ namespace
     return false;
 
   }
+  static gboolean left_pressed (gpointer data)
+  {
+    HeaderPane * self (static_cast<HeaderPane*>(data));
+    // TODO move this into headerpane
+    self->_gui.do_collapse_thread ();
+    return false;
+
+  }
+  static gboolean right_pressed (gpointer data)
+  {
+    HeaderPane * self (static_cast<HeaderPane*>(data));
+    // TODO move this into headerpane
+    self->_gui.do_expand_thread ();
+    return false;
+
+  }
 }
 
+// TODO just pass TRUE and let actions.cc handle that!
 gboolean
 HeaderPane :: on_keyboard_button_pressed ( GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
@@ -1095,6 +1127,16 @@ HeaderPane :: on_keyboard_button_pressed ( GtkWidget *widget, GdkEventKey *event
       g_idle_add(return_pressed_download_all, data);
       return TRUE;
     }
+    if (event->keyval == GDK_KEY_Left)
+    {
+      g_idle_add(left_pressed, data);
+      return TRUE;
+    }
+    if (event->keyval == GDK_KEY_Right)
+    {
+      g_idle_add(right_pressed, data);
+      return TRUE;
+    }
   }
 
   return FALSE;
@@ -1910,7 +1952,7 @@ HeaderPane :: HeaderPane (ActionManager       & action_manager,
   g_signal_connect (w, "button-release-event", G_CALLBACK(on_button_pressed), this);
   g_signal_connect (w, "button-press-event", G_CALLBACK(on_button_pressed), this);
 
-  /* intercept ENTER for selection of multiple articles */
+  /* intercept ENTER and left/right for article selection */
   g_signal_connect (w, "key-press-event", G_CALLBACK(on_keyboard_button_pressed), this);
 
   g_signal_connect (w, "row-collapsed", G_CALLBACK(row_collapsed_cb), NULL);
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index 25ef6a1..024e523 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -67,6 +67,7 @@ namespace pan
 
   typedef std::vector<const Article*> articles_t;
   typedef std::set<const Article*> articles_set;
+  typedef std::vector<const Article*> article_v;
 
   /**
    * Header Pane in the main window of Pan's GUI.
@@ -95,6 +96,7 @@ namespace pan
       void select_subthreads ();
       void select_similar ();
       void expand_selected ();
+      void collapse_selected();
 
     public:
       void read_next_article ();
diff --git a/pan/gui/pan-ui.h b/pan/gui/pan-ui.h
index 98c4d13..fe33114 100644
--- a/pan/gui/pan-ui.h
+++ b/pan/gui/pan-ui.h
@@ -100,6 +100,9 @@ namespace pan
     virtual void do_show_new_score_dialog () = 0;
     virtual void do_show_selected_article_info () = 0;
 
+    virtual void do_collapse_thread () = 0;
+    virtual void do_expand_thread () = 0;
+
     virtual void do_read_selected_group () = 0;
     virtual void do_mark_selected_groups_read () = 0;
     virtual void do_clear_selected_groups () = 0;
diff --git a/pan/gui/pan.ui.h b/pan/gui/pan.ui.h
index 64a0fbd..a24fd70 100644
--- a/pan/gui/pan.ui.h
+++ b/pan/gui/pan.ui.h
@@ -40,6 +40,8 @@ const char * fallback_ui_file =
 "        <menuitem action='shorten-group-names' />\n"
 "      </menu>\n"
 "      <menu action='view-header-pane-menu'>\n"
+"        <menuitem action='toggle-expand-thread' />\n"
+"        <separator />\n"
 "        <menuitem action='thread-headers' />\n"
 "        <separator />\n"
 "        <menuitem action='enable-rules' />\n"
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index 0604996..b9c1af8 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -1092,16 +1092,37 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
   row = 0;
   t = HIG :: workarea_create ();
 
-    gtk_widget_set_tooltip_text (t, _("This menu lets you configure Pan to take certain actions on your behalf automatically, based on an article's score."));
+    gtk_widget_set_tooltip_text (t, _("This menu lets you configure Pan to take certain actions on your behalf automatically, "
+                                      "based on an article's score."));
+
+    int i(0);
+    GtkWidget** action_combo = new GtkWidget*[2];
+    char* tmp = _("Mark affected articles read");
+    action_combo[i++] = new_check_button (tmp, "auto-delete-mark-read", false, prefs);
+    action_combo[i++] = new_check_button (tmp, "autocache-mark-read", false, prefs);
+    action_combo[i++] = new_check_button (tmp, "auto-dl-mark-read", false, prefs);
+    i=0;
 
     w = score_handler_new (prefs, "rules-delete-value", "never", b);
+    h = gtk_hbox_new (false, PAD);
+    gtk_box_pack_start (GTK_BOX(h), w, false, false, 0);
+    gtk_box_pack_start (GTK_BOX(h), action_combo[i++], false, false, 0);
     HIG :: workarea_add_row (t, &row, _("_Delete articles scoring at: "), w);
+
     w = score_handler_new (prefs, "rules-mark-read-value", "never", b);
     HIG :: workarea_add_row (t, &row, _("Mark articles as _read scoring at: "), w);
+
     w = score_handler_new (prefs, "rules-autocache-value", "never", b);
-    HIG :: workarea_add_row (t, &row, _("_Cache articles scoring at: "), w);
+    h = gtk_hbox_new (false, PAD);
+    gtk_box_pack_start (GTK_BOX(h), w, false, false, 0);
+    gtk_box_pack_start (GTK_BOX(h), action_combo[i++], false, false, 0);
+    HIG :: workarea_add_row (t, &row, _("_Cache articles scoring at: "), h);
+
     w = score_handler_new (prefs, "rules-auto-dl-value", "never", b);
-    HIG :: workarea_add_row (t, &row, _("Download _attachments of articles scoring at: "), w);
+    h = gtk_hbox_new (false, PAD);
+    gtk_box_pack_start (GTK_BOX(h), w, false, false, 0);
+    gtk_box_pack_start (GTK_BOX(h), action_combo[i++], false, false, 0);
+    HIG :: workarea_add_row (t, &row, _("Download _attachments of articles scoring at: "), h);
 
   HIG :: workarea_finish (t, &row);
   gtk_notebook_append_page (GTK_NOTEBOOK(notebook), t, new_label_with_icon(_("_Actions"), _("Actions"), icon_prefs_actions, prefs));
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index 883b23b..71f257b 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -941,7 +941,7 @@ TaskPane :: create_filter_entry ()
                                  GTK_ENTRY_ICON_SECONDARY,
                                  GTK_STOCK_CLEAR );
 
-  bool regex = false;//_prefs.get_flag ("use-regex", false);
+  bool regex = _prefs.get_flag ("use-regex", false);
   GtkWidget * menu = gtk_menu_new ();
   if (regex == true )
     search_mode = 1;
@@ -966,7 +966,7 @@ TaskPane :: create_filter_entry ()
   return entry;
 }
 
-TaskPane :: TaskPane (Queue& queue, Prefs& prefs): _queue(queue)
+TaskPane :: TaskPane (Queue& queue, Prefs& prefs): _queue(queue), _prefs(prefs)
 {
   _root = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
diff --git a/pan/gui/task-pane.h b/pan/gui/task-pane.h
index 0ac1efc..943aa5c 100644
--- a/pan/gui/task-pane.h
+++ b/pan/gui/task-pane.h
@@ -62,6 +62,7 @@ namespace pan
 
     private:
       Queue& _queue;
+      Prefs& _prefs;
       GtkWidget * _root;
       GtkWidget * _view;
       GtkWidget * _online_image;
diff --git a/pan/icons/Makefile.am b/pan/icons/Makefile.am
index 4677c27..5e4e19d 100644
--- a/pan/icons/Makefile.am
+++ b/pan/icons/Makefile.am
@@ -65,7 +65,9 @@ stock_images = \
   icon_prefs_colors.png \
   icon_prefs_headers.png \
   icon_prefs_layout.png \
-  icon_prefs_actions.png
+  icon_prefs_actions.png \
+  icon_expand_thread.png \
+  icon_collapse_thread.png
 
 EXTRA_DIST = \
 	pan-template.xcf \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]