paperbox r132 - in trunk: . src
- From: markoa svn gnome org
- To: svn-commits-list gnome org
- Subject: paperbox r132 - in trunk: . src
- Date: Fri, 25 Apr 2008 17:38:46 +0100 (BST)
Author: markoa
Date: Fri Apr 25 16:38:45 2008
New Revision: 132
URL: http://svn.gnome.org/viewvc/paperbox?rev=132&view=rev
Log:
Cleanup in tag signalling
Modified:
trunk/ChangeLog
trunk/src/browser.cc
trunk/src/browser.hh
trunk/src/document-tag-cloud-model.cc
trunk/src/document-tag-cloud-model.hh
trunk/src/document-tile.cc
trunk/src/document-tile.hh
trunk/src/tracker-phone.cc
trunk/src/tracker-phone.hh
Modified: trunk/src/browser.cc
==============================================================================
--- trunk/src/browser.cc (original)
+++ trunk/src/browser.cc Fri Apr 25 16:38:45 2008
@@ -79,14 +79,14 @@
void
Browser::connect_to_tracker_signals()
{
- tracker_client_->signal_documents_request_completed().connect(
+ tracker_client_->signal_documents().connect(
sigc::mem_fun(*this, &Browser::on_documents));
tracker_client_->signal_tags_added().connect(
- sigc::mem_fun(*this, &Browser::on_add_tags_request_completed));
+ sigc::mem_fun(*this, &Browser::on_tags_added));
tracker_client_->signal_tags_removed().connect(
- sigc::mem_fun(*this, &Browser::on_remove_tags_request_completed));
+ sigc::mem_fun(*this, &Browser::on_tags_removed));
}
void
@@ -157,22 +157,19 @@
}
void
- Browser::on_add_tags_request_completed(bool success,
- const ustring& uri,
- const vector<ustring>& tags)
+ Browser::on_tags_added(const ustring& uri,
+ const vector<ustring>& tags)
{
doc_map::iterator doc_iter = docs_.find(uri.raw());
shared_ptr<Document> doc = doc_iter->second;
- if (success) {
- vector<ustring>::const_iterator it(tags.begin());
- vector<ustring>::const_iterator end(tags.end());
+ vector<ustring>::const_iterator it(tags.begin());
+ vector<ustring>::const_iterator end(tags.end());
- for ( ; it != end; ++it) doc->add_tag(*it);
- }
+ for ( ; it != end; ++it) doc->add_tag(*it);
vector<ustring> tags_removed_none;
- signal_tags_changed_.emit(uri, success, tags, tags_removed_none);
+ signal_tags_changed_.emit(uri, tags, tags_removed_none);
}
// Does the validation work and forwards the add request to TrackerPhone
@@ -202,22 +199,19 @@
}
void
- Browser::on_remove_tags_request_completed(bool success,
- const ustring& uri,
- const vector<ustring>& tags)
+ Browser::on_tags_removed(const ustring& uri,
+ const vector<ustring>& tags)
{
doc_map::iterator doc_iter = docs_.find(uri.raw());
shared_ptr<Document> doc = doc_iter->second;
- if (success) {
- vector<ustring>::const_iterator it(tags.begin());
- vector<ustring>::const_iterator end(tags.end());
+ vector<ustring>::const_iterator it(tags.begin());
+ vector<ustring>::const_iterator end(tags.end());
- for ( ; it != end; ++it) doc->remove_tag(*it);
- }
+ for ( ; it != end; ++it) doc->remove_tag(*it);
vector<ustring> tags_added_none;
- signal_tags_changed_.emit(uri, success, tags_added_none, tags);
+ signal_tags_changed_.emit(uri, tags_added_none, tags);
}
// Does the validation work and forwards the remove request to TrackerPhone
Modified: trunk/src/browser.hh
==============================================================================
--- trunk/src/browser.hh (original)
+++ trunk/src/browser.hh Fri Apr 25 16:38:45 2008
@@ -47,13 +47,11 @@
/*
* eg void on_tags_changed(
* const std::string& uri,
- * bool success,
* const std::vector<Glib::ustring>& tags_added,
* const std::vector<Glib::ustring>& tags_removed);
*/
typedef sigc::signal<void,
const std::string&,
- bool,
const std::vector<Glib::ustring>& ,
const std::vector<Glib::ustring>& >
SignalTagsChanged;
@@ -101,15 +99,11 @@
bool on_idle_initial_document_retrieval();
- void on_add_tags_request_completed(
- bool status,
- const Glib::ustring& uri,
- const std::vector<Glib::ustring>& tags);
-
- void on_remove_tags_request_completed(
- bool status,
- const Glib::ustring& uri,
- const std::vector<Glib::ustring>& tags);
+ void on_tags_added(const Glib::ustring& uri,
+ const std::vector<Glib::ustring>& tags);
+
+ void on_tags_removed(const Glib::ustring& uri,
+ const std::vector<Glib::ustring>& tags);
boost::shared_ptr<TrackerPhone> tracker_client_;
std::queue<Glib::ustring> uri_queue_;
Modified: trunk/src/document-tag-cloud-model.cc
==============================================================================
--- trunk/src/document-tag-cloud-model.cc (original)
+++ trunk/src/document-tag-cloud-model.cc Fri Apr 25 16:38:45 2008
@@ -48,12 +48,9 @@
void
DocumentTagCloudModel::on_tags_changed(
const std::string& /* uri */,
- bool success,
const vector<Glib::ustring>& tags_added,
const vector<Glib::ustring>& tags_removed)
{
- if (! success) return; // just ignore, a tile would notify the user
-
vector<Glib::ustring>::const_iterator it_add(tags_added.begin());
vector<Glib::ustring>::const_iterator end_add(tags_added.end());
Modified: trunk/src/document-tag-cloud-model.hh
==============================================================================
--- trunk/src/document-tag-cloud-model.hh (original)
+++ trunk/src/document-tag-cloud-model.hh Fri Apr 25 16:38:45 2008
@@ -44,7 +44,6 @@
protected:
void on_tags_changed(const std::string& uri,
- bool success,
const std::vector<Glib::ustring>& tags_added,
const std::vector<Glib::ustring>& tags_removed);
};
Modified: trunk/src/document-tile.cc
==============================================================================
--- trunk/src/document-tile.cc (original)
+++ trunk/src/document-tile.cc Fri Apr 25 16:38:45 2008
@@ -24,7 +24,6 @@
#include <gtk/gtklinkbutton.h>
#include <gtk/gtkwidget.h>
#include <glibmm-utils/ustring.h>
-#include <gtkmm-utils/dialog.h>
#include <gtkmm/stock.h>
#include "browser.hh"
#include "dialog-tag-entry.hh"
@@ -295,22 +294,14 @@
void
DocumentTile::on_tags_changed(const std::string& uri,
- bool success,
const vector<ustring>& tags_added,
const vector<ustring>& tags_removed)
{
if (uri_ != uri) return;
- if (success) {
- unpack_tag_links();
- refresh_tag_links(tags_added, tags_removed);
- pack_tag_links();
- } else {
- // TODO: wrap in _()
- ustring op;
- op = tags_added.size() > 0 ? "add tags to" : "remove tags from ";
- Gtk::Util::display_dialog_error("Failed to " + op + uri);
- }
+ unpack_tag_links();
+ refresh_tag_links(tags_added, tags_removed);
+ pack_tag_links();
}
void
Modified: trunk/src/document-tile.hh
==============================================================================
--- trunk/src/document-tile.hh (original)
+++ trunk/src/document-tile.hh Fri Apr 25 16:38:45 2008
@@ -82,7 +82,6 @@
// Browser's signal handler
void on_tags_changed(const std::string& uri,
- bool success,
const std::vector<Glib::ustring>& tags_added,
const std::vector<Glib::ustring>& tags_removed);
Modified: trunk/src/tracker-phone.cc
==============================================================================
--- trunk/src/tracker-phone.cc (original)
+++ trunk/src/tracker-phone.cc Fri Apr 25 16:38:45 2008
@@ -102,18 +102,10 @@
namespace paperbox {
- enum AsyncRequestType
- {
- ASYNC_REQUEST_TYPE_ADD,
- ASYNC_REQUEST_TYPE_REMOVE
- };
-
struct AsyncTagPack
{
- AsyncRequestType req_type;
TrackerPhone* phone;
Glib::ustring uri;
- char** tags;
};
} // namespace paperbox
@@ -148,7 +140,7 @@
uris.push(found_uri);
}
- phone->signal_documents_request_completed().emit(uris);
+ phone->signal_documents().emit(uris);
g_strfreev(results);
}
@@ -156,36 +148,16 @@
void
on_tracker_void_reply(GError* error, paperbox::AsyncTagPack* pack)
{
-/*
- bool success = true;
+ if (! error) return;
- if (error) {
- if (pack->req_type == paperbox::ASYNC_REQUEST_TYPE_ADD)
- LOG_ERROR("Tracker add tags request failed: "
- << error->message);
- else if (pack->req_type == paperbox::ASYNC_REQUEST_TYPE_REMOVE)
- LOG_ERROR("Tracker remove tags request failed: "
- << error->message);
+ // this is the material for potential signalling which would
+ // propagate to some error dialog
- g_clear_error(&error);
- success = false;
- }
-
- std::vector<Glib::ustring> cpp_tags;
- ustring_array_to_vector(pack->tags, cpp_tags);
+ LOG_ERROR("Tracker tag(s) request failed for URI "
+ << pack->uri
+ << ": " << error->message);
- if (pack->req_type == paperbox::ASYNC_REQUEST_TYPE_ADD) {
- pack->phone->signal_tags_added().emit(success,
- pack->uri,
- cpp_tags);
-
- } else if (pack->req_type == paperbox::ASYNC_REQUEST_TYPE_REMOVE) {
- pack->phone->signal_tags_removed().emit(success,
- pack->uri,
- cpp_tags);
- }
-*/
- g_strfreev(pack->tags);
+ g_clear_error(&error);
delete pack;
}
@@ -201,7 +173,7 @@
std::vector<Glib::ustring> tags;
tags.push_back(Glib::ustring(ckeyword));
- phone->signal_tags_added().emit(true, uri, tags);
+ phone->signal_tags_added().emit(uri, tags);
}
// Handler for D-Bus signal Tracker.Keywords/KeywordRemoved
@@ -216,7 +188,7 @@
std::vector<Glib::ustring> tags;
tags.push_back(Glib::ustring(ckeyword));
- phone->signal_tags_removed().emit(true, uri, tags);
+ phone->signal_tags_removed().emit(uri, tags);
}
} // anonymous namespace
@@ -246,24 +218,6 @@
tracker_disconnect(tracker_connection_);
}
- TrackerPhone::SignalDocuments&
- TrackerPhone::signal_documents_request_completed()
- {
- return signal_documents_;
- }
-
- TrackerPhone::SignalTags&
- TrackerPhone::signal_tags_added()
- {
- return signal_tags_added_;
- }
-
- TrackerPhone::SignalTags&
- TrackerPhone::signal_tags_removed()
- {
- return signal_tags_removed_;
- }
-
bool
TrackerPhone::ping_tracker()
{
@@ -457,10 +411,8 @@
char** ctags = ustring_vector_to_array(tags);
AsyncTagPack* data = new AsyncTagPack;
- data->req_type = ASYNC_REQUEST_TYPE_ADD;
data->phone = this;
data->uri = uri;
- data->tags = ctags;
tracker_keywords_add_async (tracker_connection_,
SERVICE_DOCUMENTS,
@@ -477,10 +429,8 @@
char** ctags = ustring_vector_to_array(tags);
AsyncTagPack* data = new AsyncTagPack;
- data->req_type = ASYNC_REQUEST_TYPE_REMOVE;
data->phone = this;
data->uri = uri;
- data->tags = ctags;
tracker_keywords_remove_async (tracker_connection_,
SERVICE_DOCUMENTS,
Modified: trunk/src/tracker-phone.hh
==============================================================================
--- trunk/src/tracker-phone.hh (original)
+++ trunk/src/tracker-phone.hh Fri Apr 25 16:38:45 2008
@@ -42,13 +42,10 @@
{
public:
typedef sigc::signal<void,
- const std::queue<Glib::ustring>& >
+ const std::queue<Glib::ustring>& > // uri queue
SignalDocuments;
- // Tags can be added or removed after the application request
- // or externally. success may be false only in the former case.
typedef sigc::signal<void,
- bool, // success
const Glib::ustring&, // uri
const std::vector<Glib::ustring>& > // tags
SignalTags;
@@ -69,11 +66,11 @@
void remove_tags(const Glib::ustring& uri,
const std::vector<Glib::ustring> tags);
- SignalDocuments& signal_documents_request_completed();
+ SignalDocuments& signal_documents() { return signal_documents_; }
- SignalTags& signal_tags_added();
+ SignalTags& signal_tags_added() { return signal_tags_added_; }
- SignalTags& signal_tags_removed();
+ SignalTags& signal_tags_removed() { return signal_tags_removed_; }
protected:
void connect_to_dbus_signals();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]