[pan2] https://bugzilla.gnome.org/show_bug.cgi?id=680298, added context menu option, too



commit 5f8a8ef1cb71bc1aebb4a9b0e73b1e49da4c8d30
Author: Heinrich MÃller <henmull src gnome org>
Date:   Sun Jul 22 10:48:13 2012 +0200

    https://bugzilla.gnome.org/show_bug.cgi?id=680298, added context menu option, too

 pan/gui/task-pane.cc     |  107 +++++++++++++++++++++++++++++++---------------
 pan/gui/task-pane.h      |    2 +
 pan/gui/taskpane.ui.h    |    2 +
 pan/tasks/task-upload.cc |    3 -
 4 files changed, 76 insertions(+), 38 deletions(-)
---
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index dd63115..c6fa495 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -103,6 +103,65 @@ namespace
   }
 }
 
+namespace
+{
+  bool fill_task_info (Task* task, char* buffer, size_t size)
+  {
+
+    EvolutionDateMaker date_maker;
+    char * date(0);
+
+    TaskUpload * tu (dynamic_cast<TaskUpload*>(task));
+    if (tu)
+    {
+      const Article& a(tu->get_article());
+      date = date_maker.get_date_string (tu->get_article().time_posted);
+      g_snprintf(buffer,size,
+                 _("\n<u>Upload</u>\n\n<i>Subject:</i> <b>\"%s\"</b>\n<i>From:</i> <b>%s</b>\n"
+                   "<i>Groups:</i> <b>%s</b>\n<i>Sourcefile:</i> <b>%s</b>\n"),
+                 a.subject.to_string().c_str(), escaped(a.author.to_string()).c_str(),
+                 tu->get_groups().c_str(), tu->get_filename().c_str());
+    }
+
+    TaskArticle * ta (dynamic_cast<TaskArticle*>(task));
+    if (ta)
+    {
+      const Article& a(ta->get_article());
+      date = date_maker.get_date_string (ta->get_article().time_posted);
+      g_snprintf(buffer, size,
+                 _("\n<u>Download</u>\n\n<i>Subject:</i> <b>\"%s\"</b>\n<i>From:</i> <b>%s</b>\n<i>Date:</i> <b>%s</b>\n"
+                   "<i>Groups:</i> <b>%s</b>\n<i>Save Path:</i><b>%s</b>\n"),
+                 a.subject.to_string().c_str(), escaped(a.author.to_string()).c_str(), date ? date : _("unknown"),
+                 ta->get_groups().c_str(), ta->get_save_path().to_string().c_str());
+    }
+
+    g_free (date);
+
+    return tu || ta;
+  }
+
+}
+
+void
+TaskPane :: show_task_info(const tasks_t& tasks)
+{
+  Task* task (tasks.front());
+  if (!task) return;
+
+  char buffer[4096];
+  const bool task_found (fill_task_info (task, buffer, sizeof(buffer)));
+
+  GtkWidget * w = gtk_message_dialog_new_with_markup (
+      GTK_WINDOW (gtk_widget_get_toplevel (_root)),
+      GTK_DIALOG_DESTROY_WITH_PARENT,
+      GTK_MESSAGE_INFO,
+      GTK_BUTTONS_CLOSE,
+        buffer, NULL);
+  g_signal_connect_swapped (w, "response", G_CALLBACK (gtk_widget_destroy), w);
+  gtk_widget_show_all (w);
+
+}
+
 gboolean
 TaskPane:: on_tooltip_query(GtkWidget  *widget,
                             gint        x,
@@ -122,45 +181,15 @@ TaskPane:: on_tooltip_query(GtkWidget  *widget,
   GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
   GtkTreePath *path(0);
 
-  char buffer[4096];
-  Task * task(0);
-  bool task_found(false);
-
   if (!gtk_tree_view_get_tooltip_context (tree_view, &x, &y, keyboard_tip, &model, &path, &iter))
     return false;
 
+  Task * task(0);
   gtk_tree_model_get (model, &iter, COL_TASK_POINTER, &task, -1);
 
+  char buffer[4096];
   g_snprintf(buffer,sizeof(buffer),"...");
-
-  EvolutionDateMaker date_maker;
-  char * date(0);
-
-  TaskUpload * tu (dynamic_cast<TaskUpload*>(task));
-  if (tu)
-  {
-    const Article& a(tu->get_article());
-    date = date_maker.get_date_string (tu->get_article().time_posted);
-    g_snprintf(buffer,sizeof(buffer),
-               _("\n<u>Upload</u>\n\n<i>Subject:</i> <b>\"%s\"</b>\n<i>From:</i> <b>%s</b>\n"
-                 "<i>Groups:</i> <b>%s</b>\n<i>Sourcefile:</i> <b>%s</b>\n"),
-               a.subject.to_string().c_str(), escaped(a.author.to_string()).c_str(),
-               tu->get_groups().c_str(), tu->get_filename().c_str());
-  }
-
-  TaskArticle * ta (dynamic_cast<TaskArticle*>(task));
-  if (ta)
-  {
-    const Article& a(ta->get_article());
-    date = date_maker.get_date_string (ta->get_article().time_posted);
-    g_snprintf(buffer,sizeof(buffer),
-               _("\n<u>Download</u>\n\n<i>Subject:</i> <b>\"%s\"</b>\n<i>From:</i> <b>%s</b>\n<i>Date:</i> <b>%s</b>\n"
-                 "<i>Groups:</i> <b>%s</b>\n<i>Save Path:</i><b>%s</b>\n"),
-               a.subject.to_string().c_str(), escaped(a.author.to_string()).c_str(), date ? date : _("unknown"),
-               ta->get_groups().c_str(), ta->get_save_path().to_string().c_str());
-  }
-
-  task_found = tu || ta;
+  const bool task_found (fill_task_info (task, buffer, sizeof(buffer)));
 
   if (task_found)
   {
@@ -169,8 +198,6 @@ TaskPane:: on_tooltip_query(GtkWidget  *widget,
   }
   gtk_tree_path_free (path);
 
-  g_free (date);
-
   return true;
 }
 
@@ -238,6 +265,10 @@ void TaskPane :: bottom_clicked_cb (GtkButton*, TaskPane* pane)
 {
   pane->_queue.move_bottom (pane->get_selected_tasks());
 }
+void TaskPane :: show_info_clicked_cb (GtkButton*, TaskPane* pane)
+{
+  pane->show_task_info (pane->get_selected_tasks());
+}
 void TaskPane :: stop_clicked_cb (GtkButton*, TaskPane* pane)
 {
   pane->_queue.stop_tasks (pane->get_selected_tasks());
@@ -626,6 +657,7 @@ namespace
   void do_move_down      (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->down_clicked_cb(0, static_cast<TaskPane*>(p)); }
   void do_move_top       (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->top_clicked_cb(0, static_cast<TaskPane*>(p)); }
   void do_move_bottom    (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->bottom_clicked_cb(0, static_cast<TaskPane*>(p)); }
+  void do_show_info      (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->show_info_clicked_cb(0, static_cast<TaskPane*>(p)); }
   void do_stop           (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->stop_clicked_cb(0, static_cast<TaskPane*>(p)); }
   void do_delete         (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->delete_clicked_cb(0, static_cast<TaskPane*>(p)); }
   void do_restart        (GtkAction*, gpointer p)  { static_cast<TaskPane*>(p)->restart_clicked_cb(0, static_cast<TaskPane*>(p)); }
@@ -654,6 +686,11 @@ namespace
       N_("Move To Bottom"),
       G_CALLBACK(do_move_bottom) },
 
+    { "show-info", NULL,
+      N_("Show Task Information"), "",
+      N_("Show Task Information"),
+      G_CALLBACK(do_show_info) },
+
     { "stop", NULL,
       N_("Stop Task"), "",
       N_("Stop Task"),
diff --git a/pan/gui/task-pane.h b/pan/gui/task-pane.h
index b638636..bd49195 100644
--- a/pan/gui/task-pane.h
+++ b/pan/gui/task-pane.h
@@ -59,6 +59,7 @@ namespace pan
                                        gboolean    keyboard_tip,
                                        GtkTooltip *tooltip,
                                        gpointer    data);
+      void show_task_info (const tasks_t& tasks);
 
     private:
       Queue& _queue;
@@ -110,6 +111,7 @@ namespace pan
       static void down_clicked_cb    (GtkButton*, TaskPane*);
       static void top_clicked_cb     (GtkButton*, TaskPane*);
       static void bottom_clicked_cb  (GtkButton*, TaskPane*);
+      static void show_info_clicked_cb (GtkButton*, TaskPane* pane);
       static void stop_clicked_cb    (GtkButton*, TaskPane*);
       static void delete_clicked_cb  (GtkButton*, TaskPane*);
       static void restart_clicked_cb (GtkButton*, TaskPane*);
diff --git a/pan/gui/taskpane.ui.h b/pan/gui/taskpane.ui.h
index 22d6f5d..239a8d1 100644
--- a/pan/gui/taskpane.ui.h
+++ b/pan/gui/taskpane.ui.h
@@ -8,6 +8,8 @@ const char * fallback_taskpane_ui =
 "    <menuitem action='move-top' />\n"
 "    <menuitem action='move-bottom' />\n"
 "    <separator />\n"
+"    <menuitem action='show-info' />\n"
+"    <separator />\n"
 "    <menuitem action='stop' />\n"
 "    <menuitem action='delete' />\n"
 "    <menuitem action='restart' />\n"
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 0a59025..27636d6 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -176,9 +176,6 @@ TaskUpload :: update_work (NNTP* checkin_pending)
   }
   else if (_encoder_has_run && !_needed.empty())
   {
-    // DBG
-//     _state.set_completed();
-//     set_finished(_queue_pos);
     _state.set_need_nntp(_server);
   }
   else if (_needed.empty())



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