[pan2/testing: 184/279] [~] removed pop-up dialog for upload with empty queue



commit 9f6e291515b196040aecc783e60e90455b95ac2a
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Mon Jul 25 21:59:21 2011 +0200

    [~] removed pop-up dialog for upload with empty queue

 pan/gui/post-ui.cc       |   58 ++++-----------------------------------------
 pan/gui/post-ui.h        |    3 +-
 pan/tasks/task-post.cc   |    7 +++++
 pan/tasks/task-upload.cc |    2 -
 4 files changed, 14 insertions(+), 56 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index d9a2da7..e939ecf 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -675,7 +675,7 @@ PostUI :: close_window (bool flag)
   if (get_body() == _unchanged_body)
     destroy_flag = true;
 
-  else if (!flag) {
+  if (!destroy_flag) {
     GtkWidget * d = gtk_message_dialog_new (
       GTK_WINDOW(_root),
       GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -694,6 +694,7 @@ PostUI :: close_window (bool flag)
 
   int w,h;
   gtk_window_get_size( GTK_WINDOW(_root), &w, &h);
+  std::cerr<<"post ui sizes: "<<w<<" "<<h<<std::endl;
   _prefs.set_int("post-ui-width", w);
   _prefs.set_int("post-ui-height", h);
 
@@ -796,19 +797,6 @@ namespace
   }
 }
 
-namespace
-{
-  gboolean pulse_me (gpointer progressbar)
-  {
-    gtk_progress_bar_pulse (GTK_PROGRESS_BAR (progressbar));
-    return true;
-  }
-  void remove_progress_tag (gpointer tag)
-  {
-    g_source_remove (GPOINTER_TO_UINT(tag));
-  }
-}
-
 void
 PostUI :: add_files ()
 {
@@ -957,7 +945,7 @@ PostUI :: on_progress_finished (Progress&, int status) // posting finished
       done_sending_message (message, false);
     else
       maybe_mail_message (message);
-    gtk_widget_destroy (_post_dialog);
+    close_window(true);
   } else
   {
     --_running_uploads;
@@ -975,21 +963,9 @@ PostUI :: on_progress_finished (Progress&, int status) // posting finished
         }
       mut.unlock();
     }
-
+    if (_running_uploads==0) close_window(true);
   }
-  if (_running_uploads==0) close_window(true);
-}
 
-void
-PostUI :: on_progress_error (Progress&, const StringView& message)
-{
-  GtkWidget * d = gtk_message_dialog_new (GTK_WINDOW(_root),
-                                          GTK_DIALOG_DESTROY_WITH_PARENT,
-                                          GTK_MESSAGE_ERROR,
-                                          GTK_BUTTONS_CLOSE, "%s", message.to_string().c_str());
-  g_signal_connect_swapped (d, "response",
-                            G_CALLBACK(gtk_widget_destroy), d);
-  gtk_widget_show (d);
 }
 
 bool
@@ -1054,37 +1030,15 @@ PostUI :: maybe_post_message (GMimeMessage * message)
     _queue.set_online (true);
   }
 
-  /**
-  ***  Pop up a ``Posting'' Dialog...
-  **/
+  gtk_widget_hide (_root);
+
   if(_file_queue_empty)
   {
-    GtkWidget * d = gtk_dialog_new_with_buttons (_("Posting Article"),
-                                                 GTK_WINDOW(_root),
-                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                 //GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                                 NULL);
-    char buf[512];
-    g_snprintf (buf, sizeof(buf), "<b>%s</b>", _("Posting..."));
-    GtkWidget * w = GTK_WIDGET (g_object_new (GTK_TYPE_LABEL, "use-markup", TRUE, "label", buf, NULL));
-    GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(d));
-    gtk_box_pack_start (GTK_BOX(content), w, false, false, PAD_SMALL);
-    w = gtk_progress_bar_new ();
-    gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR(w), 0.05);
-    const guint tag = g_timeout_add (100, pulse_me, w);
-    gtk_box_pack_start (GTK_BOX(content), w, false, false, PAD_SMALL);
-    g_object_set_data_full (G_OBJECT(d), "progressbar-timeout-tag", GUINT_TO_POINTER(tag), remove_progress_tag);
-    _post_dialog = d;
-    g_signal_connect (_post_dialog, "destroy", G_CALLBACK(gtk_widget_destroyed), &_post_dialog);
-    gtk_widget_show_all (d);
-
     _post_task = new TaskPost (server, message);
     _post_task->add_listener (this);
     _queue.add_task (_post_task, Queue::TOP);
   } else {
 
-    gtk_widget_hide (_root); // hide the main window, we still need the class' data
-
     // prepend header for xml file (if one was chosen)
     if (!_save_file.empty())
     {
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index f76c0cb..887e9b7 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -116,7 +116,7 @@ namespace pan
 
     private:
       virtual void on_progress_finished (Progress&, int status=OK);
-      virtual void on_progress_error (Progress&, const StringView&);
+      virtual void on_progress_error (Progress&, const StringView&) {}
 
       virtual void on_progress_step (Progress&, int p) {}
       virtual void on_progress_status (Progress&, const StringView& s) {}
@@ -151,7 +151,6 @@ namespace pan
       GtkUIManager * _uim;
       GtkActionGroup * _agroup, * _pgroup, * _epgroup;
       std::string _current_signature;
-      GtkWidget * _post_dialog;
       TaskPost * _post_task;
       typedef std::map<std::string, std::string> str2str_t;
       str2str_t _hidden_headers;
diff --git a/pan/tasks/task-post.cc b/pan/tasks/task-post.cc
index 18e7747..5af7d92 100644
--- a/pan/tasks/task-post.cc
+++ b/pan/tasks/task-post.cc
@@ -23,6 +23,7 @@ extern "C" {
 }
 #include "task-post.h"
 #include <pan/general/debug.h>
+#include <pan/general/log.h>
 
 using namespace pan;
 
@@ -69,8 +70,14 @@ TaskPost :: on_nntp_done (NNTP              * nntp,
   _state.set_health (health);
 
   if (health == ERR_NETWORK)
+  {
+    Log :: add_err_va (_("Posting of \"%s\" failed: %s"),
+                          g_mime_message_get_subject(_message), response.str);
     _state.set_need_nntp (_server);
+  }
   else {
+    Log :: add_info_va (_("Posting of \"%s\" succesful: %s"),
+                          g_mime_message_get_subject(_message), response.str);
     _state.set_completed ();
     set_error (response);
     set_finished (health);
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 3b56655..d21803f 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -278,8 +278,6 @@ TaskUpload :: on_nntp_done (NNTP * nntp,
   bool found(false);
   bool post_ok(false);
 
-  if (!nntp ) std::cerr<<"nntp error!\n";
-
   needed_t::iterator it;
   for (it=_needed.begin(); it!=_needed.end(); ++it)
     if (it->second.nntp == nntp) {



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