[pan2] * make taskpane info popups deactivatable from task pane, set and gotten in/from prefs * try to fix



commit db8adcfd8b66034ed644edb01f51abddbc430d4d
Author: Heinrich MÃller <henmull src gnome org>
Date:   Sun Feb 17 10:28:13 2013 +0100

    * make taskpane info popups deactivatable from task pane, set and gotten in/from prefs
    * try to fix sent folder

 pan/data/article-cache.cc |    3 ++-
 pan/data/article-cache.h  |    2 +-
 pan/gui/post-ui.cc        |   34 +++++++++++++++++-----------------
 pan/gui/post-ui.h         |    3 +--
 pan/gui/prefs-ui.cc       |    2 +-
 pan/gui/task-pane.cc      |   14 +++++++++++++-
 pan/gui/task-pane.h       |    2 ++
 7 files changed, 37 insertions(+), 23 deletions(-)
---
diff --git a/pan/data/article-cache.cc b/pan/data/article-cache.cc
index f8f89c8..d6cb747 100644
--- a/pan/data/article-cache.cc
+++ b/pan/data/article-cache.cc
@@ -214,7 +214,7 @@ ArticleCache :: get_filename (char * buf, int buflen, const Quark& mid) const
 };
 
 ArticleCache :: CacheResponse
-ArticleCache :: add (const Quark& message_id, const StringView& article)
+ArticleCache :: add (const Quark& message_id, const StringView& article, const bool virtual_file)
 {
   debug ("adding " << message_id << ", which is " << article.len << " bytes long");
 
@@ -257,6 +257,7 @@ ArticleCache :: add (const Quark& message_id, const StringView& article)
       fire_added (message_id);
 
       _current_bytes += info._size;
+      if (virtual_file) ++_locks[message_id];
       resize ();
       res.type = CACHE_OK;
     }
diff --git a/pan/data/article-cache.h b/pan/data/article-cache.h
index 3f868b3..0219090 100644
--- a/pan/data/article-cache.h
+++ b/pan/data/article-cache.h
@@ -80,7 +80,7 @@ namespace pan
       typedef std::vector<Quark> mid_sequence_t;
 
       bool contains (const Quark& message_id) const;
-      CacheResponse add (const Quark& message_id, const StringView& article);
+      CacheResponse add (const Quark& message_id, const StringView& article, const bool virtual_file = 
false);
       void reserve (const mid_sequence_t& mids);
       void release (const mid_sequence_t& mids);
       void resize ();
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 73381b4..ebf0b9c 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -304,6 +304,18 @@ PostUI :: set_spellcheck_enabled (bool enabled)
   }
 }
 
+int
+PostUI :: count_lines()
+{
+  GtkTextBuffer * buf (_body_buf);
+  GtkTextView * view (GTK_TEXT_VIEW(_body_view));
+  GtkTextIter body_start, body_end, line_end;
+  gtk_text_buffer_get_bounds (buf, &body_start, &body_end);
+  int count(0);
+  while ((gtk_text_view_forward_display_line (view, &line_end))) ++count;
+  return count;
+}
+
 /***
 ****  WRAP CODE
 ***/
@@ -1003,16 +1015,14 @@ PostUI :: save_message_in_local_folder(const Mode& mode, const std::string& fold
          // pseudo mid to get data from cache
          std::string message_id = pan_g_mime_message_set_message_id(msg, mid.c_str());
          std::stringstream xref;
-         xref << folder << ":42";
-
-          time_t posted = time(0);
-         const Article* article = _data.xover_add (p.posting_server, folder, subject, author, posted, 
message_id, refs, sizeof(*msg), 42, xref.str(), true);
-         // set adjusted time from article
+         time_t posted = time(0); // use posted as article number, this is unique anyway
+         xref << folder << ":"<<posted;
+         const Article* article = _data.xover_add (p.posting_server, folder, subject, author, posted, 
message_id, refs, sizeof(*msg), 3, xref.str(), true);
          if (article)
          {
                  g_mime_message_set_date(msg, posted, 0);
                  ArticleCache& cache(_data.get_cache());
-                 ArticleCache :: CacheResponse response = cache.add(mid, 
g_mime_object_to_string(GMIME_OBJECT(msg)));
+                 ArticleCache :: CacheResponse response = cache.add(mid, 
g_mime_object_to_string(GMIME_OBJECT(msg)), true);
                  g_object_unref(msg);
 
                  if (response.type != ArticleCache::CACHE_OK)
@@ -1054,14 +1064,6 @@ PostUI :: maybe_post_message (GMimeMessage * message)
   if (s && s->max_connections == 0)
     error_msg =  _("The selected posting server is currently disabled. Please choose an appropriate 
alternative.");
 
-//  if (server.empty() || !_data.get_servers().count(server)) {
-//    GtkWidget * d = gtk_message_dialog_new (
-//      GTK_WINDOW(_root),
-//      GTK_DIALOG_DESTROY_WITH_PARENT,
-//      GTK_MESSAGE_ERROR,
-//      GTK_BUTTONS_CLOSE,
-//      _("No posting server is set for this posting profile.\nPlease edit the profile via Edit|Manage 
Posting Profiles."));
-
   if (!error_msg.empty())
   {
     GtkWidget * d = gtk_message_dialog_new (
@@ -1596,9 +1598,7 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
 
   // Message-ID for single text-only posts
   if (mode==DRAFTING || ((mode==POSTING || mode==UPLOADING) && _prefs.get_flag (MESSAGE_ID_PREFS_KEY, 
false))) {
-    const std::string message_id = !profile.fqdn.empty()
-      ? GNKSA::generate_message_id (profile.fqdn)
-      : GNKSA::generate_message_id_from_email_address (profile.address);
+    const std::string message_id = generate_message_id(profile);
     pan_g_mime_message_set_message_id (msg, message_id.c_str());
   }
 
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 48a3848..cbffd4e 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -201,6 +201,7 @@ namespace pan
     private:
       std::string utf8ize (const StringView&) const;
       std::string get_body () const;
+      int count_lines();
       gulong body_view_realized_handler;
       static void body_view_realized_cb (GtkWidget*, gpointer);
       GtkWidget* create_body_widget (GtkTextBuffer*&, GtkWidget*&, const pan::Prefs&);
@@ -247,8 +248,6 @@ namespace pan
       std::ofstream _out;
       static void message_id_toggled_cb (GtkToggleButton * tb, gpointer prefs_gpointer);
 
-      void generate_unique_id (StringView& mid, int cnt, std::string& s);
-
       int get_total_parts(const char* file);
 
     private:
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index 934b899..1c63350 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -1005,7 +1005,7 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
   t = HIG :: workarea_create ();
     HIG::workarea_add_section_spacer (t, row, 1);
     HIG :: workarea_add_section_title (t, &row, _("Task Pane"));
-    w = new_check_button (_("Show Task Pane notifications"), "show-taskpane-popups", true, prefs);
+    w = new_check_button (_("Show Task Pane info popups"), "show-taskpane-popups", true, prefs);
     HIG :: workarea_add_wide_control (t, &row, w);
     w = new_check_button (_("Show Download Meter"), "dl-meter-show", true, prefs);
     HIG :: workarea_add_wide_control (t, &row, w);
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index 8619f2b..b2550d3 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -174,7 +174,7 @@ TaskPane:: on_tooltip_query(GtkWidget  *widget,
 {
   TaskPane* tp(static_cast<TaskPane*>(data));
 
-  if (!tp->get_prefs().get_flag("show-taskpane-popups", true)) return false;
+  if (!tp->_prefs.get_flag("show-taskpane-popups", true)) return false;
 
   gtk_tooltip_set_icon_from_stock (tooltip, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
 
@@ -251,6 +251,10 @@ void TaskPane :: online_toggled_cb (GtkToggleButton* b, Queue *queue)
 {
   queue->set_online (gtk_toggle_button_get_active (b));
 }
+void TaskPane :: popup_toggled_cb (GtkToggleButton* b, TaskPane* pane)
+{
+  pane->_prefs.set_flag("show-taskpane-popups", gtk_toggle_button_get_active(b));
+}
 void TaskPane :: up_clicked_cb (GtkButton*, TaskPane* pane)
 {
   pane->_queue.move_up (pane->get_selected_tasks());
@@ -1045,6 +1049,14 @@ TaskPane :: TaskPane (Queue& queue, Prefs& prefs): _queue(queue), _prefs(prefs)
     gtk_box_pack_start (GTK_BOX(buttons), gtk_separator_new(GTK_ORIENTATION_VERTICAL), 0, 0, 0);
     w = add_button (buttons, GTK_STOCK_CLOSE, 0, 0);
     g_signal_connect_swapped (w, "clicked", G_CALLBACK(gtk_widget_destroy), _root);
+    w = _popup_toggle = gtk_check_button_new ();
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), _prefs.get_flag("show-taskpane-popups", true));
+    l = gtk_label_new_with_mnemonic (_("Show info popups"));
+    v = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, PAD);
+    gtk_box_pack_start (GTK_BOX(v), l, 0, 0, 0);
+    gtk_container_add (GTK_CONTAINER(w), v);
+    g_signal_connect (w, "clicked", G_CALLBACK(popup_toggled_cb), this);
+    gtk_box_pack_start (GTK_BOX(buttons), w, false, false, 0);
     pan_box_pack_start_defaults (GTK_BOX(buttons), gtk_event_box_new()); // eat horizontal space
 
   gtk_box_pack_start (GTK_BOX(vbox), buttons, false, false, 0);
diff --git a/pan/gui/task-pane.h b/pan/gui/task-pane.h
index bd49195..ac35720 100644
--- a/pan/gui/task-pane.h
+++ b/pan/gui/task-pane.h
@@ -68,6 +68,7 @@ namespace pan
       GtkWidget * _view;
       GtkWidget * _online_image;
       GtkWidget * _online_toggle;
+      GtkWidget * _popup_toggle;
       GtkWidget * _status_label;
       GtkListStore * _store;
       gulong _online_toggle_handler;
@@ -99,6 +100,7 @@ namespace pan
       task_list get_selected_tasks () const;
       static void get_selected_tasks_foreach (GtkTreeModel*, GtkTreePath*, GtkTreeIter*, gpointer);
       static void online_toggled_cb  (GtkToggleButton*, Queue*);
+      static void popup_toggled_cb (GtkToggleButton* b,  TaskPane* pane);
 
     private:
       GtkWidget* create_filter_entry ();


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