[pan2] https://bugzilla.gnome.org/show_bug.cgi?id=366668



commit 3a0153348fb37bf1a047f1b05005690b4a6504b1
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Sat Dec 3 19:57:10 2011 +0100

    https://bugzilla.gnome.org/show_bug.cgi?id=366668

 pan/gui/actions.cc     |    4 ----
 pan/gui/gui.cc         |   11 ++++++++++-
 pan/gui/gui.h          |    1 +
 pan/gui/header-pane.cc |   46 +++++++++++++++++++++++++++++++++++++++++++---
 pan/gui/header-pane.h  |    6 +++++-
 5 files changed, 59 insertions(+), 9 deletions(-)
---
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index 486465d..f39c6c4 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -82,10 +82,6 @@ namespace
       GtkIconSet * icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
       gtk_icon_factory_add (factory, my_builtin_icons[i].name, icon_set);
       g_object_unref (pixbuf);
-
-      //std::cerr << "registered icon " << my_builtin_icons[i].name << std::endl;
-
-      g_object_unref (pixbuf);
       gtk_icon_set_unref (icon_set);
     }
 
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 4a2ae4a..4baa2ab 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -191,7 +191,7 @@ GUI :: GUI (Data& data, Queue& queue, ArticleCache& cache, Prefs& prefs, GroupPr
 
   //_group_pane = new GroupPane (*this, data, _prefs);
   _group_pane = new GroupPane (*this, data, _prefs);
-  _header_pane = new HeaderPane (*this, data, _queue, _cache, _prefs, *this);
+  _header_pane = new HeaderPane (*this, data, _queue, _cache, _prefs, *this, *this);
   _body_pane = new BodyPane (data, _cache, _prefs);
 
   std::string path = "/ui/main-window-toolbar";
@@ -575,6 +575,15 @@ void GUI :: do_save_articles ()
   }
 }
 
+void GUI :: do_read_or_save_articles ()
+{
+  const guint rows(_header_pane->get_full_selection_rows_num());
+  if (rows != 1)
+    do_save_articles();
+  else
+    do_read_selected_article();
+}
+
 
 void GUI :: do_save_articles_to_nzb ()
 {
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 2c07a15..3ba6246 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -158,6 +158,7 @@ namespace pan
       virtual void do_unsubscribe_selected_groups ();
 
       void step_bookmarks(int step);
+      void do_read_or_save_articles ();
 
     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 0ca0274..eb67650 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -21,6 +21,7 @@ extern "C" {
   #include <config.h>
   #include <glib/gi18n.h>
   #include <gtk/gtk.h>
+  #include <gdk/gdkkeysyms.h>
 }
 #include <cctype>
 #include <cmath>
@@ -776,6 +777,13 @@ HeaderPane :: get_first_selected_article ()
    return a;
 }
 
+const guint
+HeaderPane :: get_full_selection_rows_num()
+{
+  return (gtk_tree_selection_count_selected_rows(gtk_tree_view_get_selection(GTK_TREE_VIEW(_tree_view))));
+}
+
+
 void
 HeaderPane :: get_full_selection_v_foreach (GtkTreeModel * model,
                                             GtkTreePath  * ,
@@ -936,6 +944,32 @@ namespace
   }
 }
 
+namespace
+{
+  static gboolean return_pressed_download_all (gpointer data)
+  {
+    HeaderPane * self (static_cast<HeaderPane*>(data));
+    self->_gui.do_read_or_save_articles();
+    return false;
+
+  }
+}
+
+gboolean
+HeaderPane :: on_keyboard_button_pressed ( GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+  if (event->type == GDK_KEY_PRESS)
+  {
+    if (event->keyval == GDK_KEY_Return)
+    {
+      g_idle_add(return_pressed_download_all, data);
+      return TRUE;
+    }
+  }
+
+  return FALSE;
+}
+
 gboolean
 HeaderPane :: on_button_pressed (GtkWidget * treeview, GdkEventButton *event, gpointer userdata)
 {
@@ -968,7 +1002,7 @@ HeaderPane :: on_button_pressed (GtkWidget * treeview, GdkEventButton *event, gp
            && (event->send_event == false)
            && (event->window == gtk_tree_view_get_bin_window (tv))
            && !(event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK))
-           && (self->get_full_selection_v().size() == 1u))
+           && (self->get_full_selection_rows_num() == 1u))
   {
     GtkTreePath * path;
     GtkTreeViewColumn * col;
@@ -1626,7 +1660,8 @@ HeaderPane :: HeaderPane (ActionManager       & action_manager,
                           Queue               & queue,
                           ArticleCache        & cache,
                           Prefs               & prefs,
-                          WaitUI              & wait):
+                          WaitUI              & wait,
+                          GUI                 & gui):
   _action_manager (action_manager),
   _data (data),
   _queue (queue),
@@ -1637,7 +1672,8 @@ HeaderPane :: HeaderPane (ActionManager       & action_manager,
   _tree_view (0),
   _tree_store (0),
   _selection_changed_idle_tag (0),
-  _cache (cache)
+  _cache (cache),
+  _gui (gui)
 {
   // init the icons
   for (guint i=0; i<ICON_QTY; ++i)
@@ -1666,6 +1702,10 @@ 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 */
+  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);
   g_signal_connect (w, "row-expanded", G_CALLBACK(row_expanded_cb), NULL);
   g_signal_connect (w, "popup-menu", G_CALLBACK(on_popup_menu), this);
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index a105ef2..1a1ad87 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -32,6 +32,7 @@
 #include <pan/gui/pan-tree.h>
 #include <pan/gui/prefs.h>
 #include <pan/gui/wait.h>
+#include <pan/gui/gui.h>
 
 namespace pan
 {
@@ -74,7 +75,7 @@ namespace pan
     private ArticleCache::Listener
   {
     public:
-      HeaderPane (ActionManager&, Data& data, Queue&, ArticleCache&, Prefs&, WaitUI&);
+      HeaderPane (ActionManager&, Data& data, Queue&, ArticleCache&, Prefs&, WaitUI&, GUI&);
       ~HeaderPane ();
 
     public:
@@ -116,6 +117,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();
       std::set<const Article*> get_nested_selection () const;
       bool set_group (const Quark& group);
       const Quark& get_group () { return _group; }
@@ -317,7 +319,9 @@ namespace pan
       static void do_popup_menu (GtkWidget*, GdkEventButton*, gpointer);
       static void on_row_activated (GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, gpointer);
       static gboolean on_button_pressed (GtkWidget*, GdkEventButton*, gpointer);
+      static gboolean on_keyboard_button_pressed ( GtkWidget *widget, GdkEventKey *event, gpointer data);
       ArticleCache& _cache;
+      GUI& _gui;
 
     private:
       void get_nested_foreach (GtkTreeModel*, GtkTreePath*, GtkTreeIter*, gpointer) const;



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