[pan2/testing: 183/279] [+] added tooltips in taskpane showing info about up-/downloads
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 183/279] [+] added tooltips in taskpane showing info about up-/downloads
- Date: Sat, 3 Dec 2011 22:37:33 +0000 (UTC)
commit 1547150854b49a9f701c9909cf7f3e12f7bc1d46
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Mon Jul 25 20:33:41 2011 +0200
[+] added tooltips in taskpane showing info about up-/downloads
pan/gui/post-ui.cc | 4 +-
pan/gui/task-pane.cc | 93 ++++++++++++++++++++++++++++++++++++++++++++-
pan/gui/task-pane.h | 8 ++++
pan/tasks/queue.cc | 12 ------
pan/tasks/queue.h | 2 +-
pan/tasks/task-article.cc | 17 ++++++++-
pan/tasks/task-article.h | 2 +
pan/tasks/task-upload.cc | 20 +++++++++-
pan/tasks/task-upload.h | 18 +++++---
9 files changed, 149 insertions(+), 27 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 8c78cab..d9a2da7 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1125,7 +1125,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
if (master_reply)
{
- std::cerr<<"adding master reply to queue\n";
+// std::cerr<<"adding master reply to queue\n";
// master article, other attachments are threaded as replies to this
const Profile profile (get_current_profile ());
@@ -1153,7 +1153,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
if (!inline_or_bulk) // bulk upload
{
- std::cerr<<"adding "<<tasks.size()<<" tasks."<<std::endl;
+// std::cerr<<"adding "<<tasks.size()<<" tasks."<<std::endl;
foreach (PostUI::tasks_t, tasks, it)
{
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index d72f2a1..9d87960 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -23,6 +23,7 @@ extern "C" {
#include <glib/gi18n.h>
#include <gtk/gtk.h>
}
+#include <pan/general/e-util.h>
#include <pan/general/debug.h>
#include <pan/general/macros.h>
#include <pan/general/utf8-utils.h>
@@ -91,6 +92,87 @@ namespace
}
}
+namespace
+{
+ std::string escaped (const std::string& s)
+ {
+ char * pch = g_markup_escape_text (s.c_str(), s.size());
+ const std::string ret (pch);
+ g_free (pch);
+ return ret;
+ }
+}
+
+gboolean
+TaskPane:: on_tooltip_query(GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_tip,
+ GtkTooltip *tooltip,
+ gpointer data)
+{
+ TaskPane* tp(static_cast<TaskPane*>(data));
+
+ gtk_tooltip_set_icon_from_stock (tooltip, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+
+ GtkTreeIter iter;
+ GtkTreeView *tree_view = GTK_TREE_VIEW (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;
+
+ gtk_tree_model_get (model, &iter, COL_TASK_POINTER, &task, -1);
+// if (!task) return false;
+
+ 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;
+
+ if (task_found)
+ {
+ gtk_tooltip_set_markup (tooltip, buffer);
+ gtk_tree_view_set_tooltip_row (tree_view, tooltip, path);
+ }
+ gtk_tree_path_free (path);
+
+ return true;
+}
+
void TaskPane :: online_toggled_cb (GtkToggleButton* b, Queue *queue)
{
queue->set_online (gtk_toggle_button_get_active (b));
@@ -227,7 +309,7 @@ TaskPane :: update_status (const task_states_t& tasks)
g_snprintf (buf, sizeof(buf), _("Pan: Tasks (%d Queued, %d Running, %d Stopped)"), queued_count, running_count, stopped_count);
else if (running_count || queued_count)
g_snprintf (buf, sizeof(buf), _("Pan: Tasks (%d Queued, %d Running)"), queued_count, running_count);
- else
+ else
g_snprintf (buf, sizeof(buf), _("Pan: Tasks"));
gtk_window_set_title (GTK_WINDOW(_root), buf);
@@ -251,7 +333,8 @@ TaskPane :: update_status (const task_states_t& tasks)
if (selected_count) {
guint64 selected_bytes (0ul);
foreach_const (tasks_t, tasks_selected, it)
- selected_bytes += (*it)->get_bytes_remaining ();
+ if (*it)
+ selected_bytes += (*it)->get_bytes_remaining ();
g_snprintf (buf, sizeof(buf), _("%lu selected, %s"), selected_count, render_bytes(selected_bytes));
line += '\n';
line += buf;
@@ -311,6 +394,8 @@ namespace
COL_TASK_STATE, &state,
-1);
+ if (!task) return;
+
// build the state string
const char * state_str (0);
switch (state) {
@@ -481,6 +566,10 @@ TaskPane :: TaskPane (Queue& queue, Prefs& prefs): _queue(queue)
GtkTreeSelection * selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+ gtk_widget_set_has_tooltip (_view, true);
+ g_signal_connect(_view,"query-tooltip",G_CALLBACK(on_tooltip_query), this);
+// gtk_widget_set_tooltip_window (_view, _tooltip_window);
+
w = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(w), GTK_SHADOW_IN);
diff --git a/pan/gui/task-pane.h b/pan/gui/task-pane.h
index 99be244..3b4192f 100644
--- a/pan/gui/task-pane.h
+++ b/pan/gui/task-pane.h
@@ -51,6 +51,14 @@ namespace pan
virtual void on_queue_error (Queue&, const StringView&) { }
private:
+ static gboolean on_tooltip_query(GtkWidget *widget,
+ gint x,
+ gint y,
+ gboolean keyboard_tip,
+ GtkTooltip *tooltip,
+ gpointer data);
+
+ private:
Queue& _queue;
GtkWidget * _root;
GtkWidget * _view;
diff --git a/pan/tasks/queue.cc b/pan/tasks/queue.cc
index fc09484..8d5aeae 100644
--- a/pan/tasks/queue.cc
+++ b/pan/tasks/queue.cc
@@ -646,10 +646,6 @@ Queue :: get_all_task_states (task_states_t& setme)
need_decode.clear();
need_decode.reserve(setme.tasks.capacity());
- std::vector<Task *> & need_encode = setme._need_encode.get_container();
- need_encode.clear();
- need_encode.reserve(setme.tasks.capacity());
-
foreach(TaskSet, _tasks, it) {
setme.tasks.push_back(*it);
if ((*it)->get_state()._work == Task::NEED_DECODER)
@@ -657,13 +653,6 @@ Queue :: get_all_task_states (task_states_t& setme)
}
setme._need_decode.sort();
- foreach(TaskSet, _tasks, it) {
- setme.tasks.push_back(*it);
- if ((*it)->get_state()._work == Task::NEED_ENCODER)
- need_encode.push_back(*it);
- }
- setme._need_encode.sort();
-
setme._queued.get_container() = setme.tasks;
setme._queued.sort ();
@@ -682,7 +671,6 @@ Queue :: get_all_task_states (task_states_t& setme)
running.insert (running.end(), tmp.begin(), tmp.end());
setme._decoding = _decoder_task;
- setme._encoding = _encoder_task;
}
void
diff --git a/pan/tasks/queue.h b/pan/tasks/queue.h
index 293cf5f..b97d2c9 100644
--- a/pan/tasks/queue.h
+++ b/pan/tasks/queue.h
@@ -107,7 +107,7 @@ namespace pan
public:
enum TaskState { QUEUED, RUNNING, DECODING, ENCODING, STOPPED, REMOVING,
- QUEUED_FOR_DECODE, QUEUED_FOR_ENCODE, PAUSED};
+ QUEUED_FOR_DECODE, QUEUED_FOR_ENCODE};
/**
* An ordered collection of tasks and their corresponding TaskState s.
diff --git a/pan/tasks/task-article.cc b/pan/tasks/task-article.cc
index e529d52..9d1a0e0 100644
--- a/pan/tasks/task-article.cc
+++ b/pan/tasks/task-article.cc
@@ -56,6 +56,20 @@ namespace
snprintf (buf, sizeof(buf), _("Reading %s"), stripped.c_str());
return std::string (buf);
}
+
+ std::string get_groups_str(const Article& a)
+ {
+ std::string r;
+ quarks_t groups;
+ int cnt(1);
+ foreach_const (Xref, a.xref, xit)
+ {
+ r += xit->group.to_string();
+ if (cnt != a.xref.size() && a.xref.size() != 1) r+=", ";
+ ++cnt;
+ }
+ return r;
+ }
}
TaskArticle :: TaskArticle (const ServerRank & server_rank,
@@ -75,7 +89,8 @@ TaskArticle :: TaskArticle (const ServerRank & server_rank,
_time_posted (article.time_posted),
_save_mode (save_mode),
_decoder(0),
- _decoder_has_run (false)
+ _decoder_has_run (false),
+ _groups(get_groups_str(article))
{
cache.reserve (article.get_part_mids());
diff --git a/pan/tasks/task-article.h b/pan/tasks/task-article.h
index 73befae..64cefa1 100644
--- a/pan/tasks/task-article.h
+++ b/pan/tasks/task-article.h
@@ -62,6 +62,7 @@ namespace pan
time_t get_time_posted () const { return _time_posted; }
const Quark& get_save_path () const { return _save_path; }
const Article& get_article () const { return _article; }
+ const std::string& get_groups () const { return _groups; }
public: // Task subclass
unsigned long get_bytes_remaining () const;
@@ -99,6 +100,7 @@ namespace pan
friend class Decoder;
Decoder * _decoder;
bool _decoder_has_run;
+ std::string _groups;
private:
struct Needed {
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 58b1a89..3b56655 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -61,6 +61,20 @@ namespace
g_free(freeme);
return buf;
}
+
+ std::string get_groups_str(const Article& a)
+ {
+ std::string r;
+ quarks_t groups;
+ int cnt(1);
+ foreach_const (Xref, a.xref, xit)
+ {
+ r += xit->group.to_string();
+ if (cnt != a.xref.size() && a.xref.size() != 1) r+=", ";
+ ++cnt;
+ }
+ return r;
+ }
}
/***
@@ -92,7 +106,9 @@ TaskUpload :: TaskUpload (const std::string & filename,
_msg (msg),
_total_parts(format.total),
_save_file(format.save_file),
- _first(true)
+ _first(true),
+ _paused(true),
+ _groups(get_groups_str(article))
{
const char * tmp (g_mime_object_get_header ((GMimeObject *)_msg, "References"));
@@ -367,7 +383,7 @@ TaskUpload :: on_nntp_done (NNTP * nntp,
unsigned long
TaskUpload :: get_bytes_remaining () const
{
- if (_needed.empty()) return _bytes*1.15;
+ if (_paused) return _bytes*1.15;
unsigned long bytes (0);
foreach_const (needed_t, _needed, it)
bytes += (unsigned long)it->second.bytes;
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index 22bafe9..73362c9 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -66,6 +66,8 @@ namespace pan
};
const Article& get_article () { return _article; }
+ const std::string& get_groups () const { return _groups; }
+ const std::string& get_filename () const { return _filename; }
typedef std::vector<Quark> mid_sequence_t;
@@ -150,6 +152,7 @@ namespace pan
friend class PostUI;
friend class Queue;
friend class NZB;
+ friend class TaskPane;
Encoder * _encoder;
bool _encoder_has_run;
@@ -171,6 +174,13 @@ namespace pan
needed_t _needed;
std::string _references; // original references, not to be touched!
std::string _first_mid;
+ bool _paused;
+ std::set<int> _wanted;
+ GMimeMessage * _msg;
+ void prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::string& d);
+ void add_reference_to_list(std::string s);
+ bool _first;
+ std::string _groups;
void update_work (NNTP * checkin_pending = 0);
@@ -178,14 +188,8 @@ namespace pan
void set_encoder_done (bool setme) { _encoder_has_run = setme; }
needed_t& needed() { return _needed; }
void build_needed_tasks();
- void wakeup() { _state.set_working(); update_work(); }
+ void wakeup() { _state.set_working(); _paused=false; update_work(); }
- private:
- std::set<int> _wanted;
- GMimeMessage * _msg;
- void prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::string& d);
- void add_reference_to_list(std::string s);
- bool _first;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]