linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #01207
[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 372: Fix favorite users on status change and other minor cleanup
------------------------------------------------------------
revno: 372
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-05-25 01:12:37 -0500
message:
Fix favorite users on status change and other minor cleanup
modified:
linux/favoriteusers.cc
linux/favoriteusers.hh
--
lp:linuxdcpp
https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk
Your team LinuxDC++ Team is subscribed to branch lp:linuxdcpp.
To unsubscribe from this branch go to https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk/+edit-subscription
=== modified file 'linux/favoriteusers.cc'
--- linux/favoriteusers.cc 2010-05-22 14:23:56 +0000
+++ linux/favoriteusers.cc 2010-05-25 06:12:37 +0000
@@ -38,11 +38,11 @@
// Initialize favorite users list treeview
favoriteUserView.setView(GTK_TREE_VIEW(getWidget("favoriteUserView")), TRUE, "favoriteusers");
- favoriteUserView.insertColumn(_("Auto grant slot"), G_TYPE_BOOLEAN, TreeView::BOOL, 100);
+ favoriteUserView.insertColumn(_("Auto Grant Slot"), G_TYPE_BOOLEAN, TreeView::BOOL, 120);
favoriteUserView.insertColumn(_("Nick"), G_TYPE_STRING, TreeView::ICON_STRING, 100, "Icon");
- favoriteUserView.insertColumn(_("Hub (last seen in, if offline)"), G_TYPE_STRING, TreeView::STRING, 200);
- favoriteUserView.insertColumn(_("Time last seen"), G_TYPE_STRING, TreeView::STRING, 120);
- favoriteUserView.insertColumn(_("Description"), G_TYPE_STRING, TreeView::STRING, 100);
+ favoriteUserView.insertColumn(_("Most Recent Hub"), G_TYPE_STRING, TreeView::STRING, 200);
+ favoriteUserView.insertColumn(_("Time Last Seen"), G_TYPE_STRING, TreeView::STRING, 120);
+ favoriteUserView.insertColumn(_("Description"), G_TYPE_STRING, TreeView::STRING, 150);
favoriteUserView.insertColumn("CID", G_TYPE_STRING, TreeView::STRING, 350);
favoriteUserView.insertHiddenColumn("URL", G_TYPE_STRING);
favoriteUserView.insertHiddenColumn("Icon", G_TYPE_STRING);
@@ -59,7 +59,7 @@
gtk_tree_view_set_fixed_height_mode(favoriteUserView.get(), TRUE);
GList *list = gtk_tree_view_column_get_cell_renderers(gtk_tree_view_get_column(favoriteUserView.get(),
- favoriteUserView.col(_("Auto grant slot"))));
+ favoriteUserView.col(_("Auto Grant Slot"))));
GObject *renderer = (GObject *)g_list_nth_data(list, 0);
g_signal_connect(renderer, "toggled", G_CALLBACK(onAutoGrantSlotToggled_gui), (gpointer)this);
g_list_free(list);
@@ -101,10 +101,10 @@
gtk_list_store_append(favoriteUserStore, &iter);
gtk_list_store_set(favoriteUserStore, &iter,
- favoriteUserView.col(_("Auto grant slot")), user.isSet(FavoriteUser::FLAG_GRANTSLOT) ? TRUE : FALSE,
+ favoriteUserView.col(_("Auto Grant Slot")), user.isSet(FavoriteUser::FLAG_GRANTSLOT) ? TRUE : FALSE,
favoriteUserView.col(_("Nick")), user.getNick().c_str(),
- favoriteUserView.col(_("Hub (last seen in, if offline)")), hub.c_str(),
- favoriteUserView.col(_("Time last seen")), seen.c_str(),
+ favoriteUserView.col(_("Most Recent Hub")), hub.c_str(),
+ favoriteUserView.col(_("Time Last Seen")), seen.c_str(),
favoriteUserView.col(_("Description")), user.getDescription().c_str(),
favoriteUserView.col("CID"), cid.c_str(),
favoriteUserView.col("URL"), user.getUrl().c_str(),
@@ -126,6 +126,10 @@
{
fu->onRemoveItemClicked_gui(NULL, data);
}
+ else if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter)
+ {
+ fu->onDescriptionItemClicked_gui(NULL, data);
+ }
else if (event->keyval == GDK_Menu || (event->keyval == GDK_F10 && event->state & GDK_SHIFT_MASK))
{
gtk_menu_popup(GTK_MENU(fu->getWidget("menu")), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time());
@@ -245,9 +249,9 @@
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(fu->favoriteUserStore), &iter, path))
{
- WulforManager::get()->getMainWindow()->addPrivateMessage_gui(
- fu->favoriteUserView.getString(&iter, "CID"),
- fu->favoriteUserView.getString(&iter, "URL"));
+ string cid = fu->favoriteUserView.getString(&iter, "CID");
+ string url = fu->favoriteUserView.getString(&iter, "URL");
+ WulforManager::get()->getMainWindow()->addPrivateMessage_gui(cid, url);
}
gtk_tree_path_free(path);
}
@@ -272,9 +276,9 @@
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(fu->favoriteUserStore), &iter, path))
{
- F2 *func = new F2(fu, &FavoriteUsers::grantSlot_client,
- fu->favoriteUserView.getString(&iter, "CID"),
- fu->favoriteUserView.getString(&iter, "URL"));
+ string cid = fu->favoriteUserView.getString(&iter, "CID");
+ string url = fu->favoriteUserView.getString(&iter, "URL");
+ F2 *func = new F2(fu, &FavoriteUsers::grantSlot_client, cid, url);
WulforManager::get()->dispatchClientFunc(func);
}
gtk_tree_path_free(path);
@@ -299,7 +303,8 @@
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(fu->favoriteUserStore), &iter, path))
{
- WulforManager::get()->getMainWindow()->showHub_gui(fu->favoriteUserView.getString(&iter, "URL"));
+ string url = fu->favoriteUserView.getString(&iter, "URL");
+ WulforManager::get()->getMainWindow()->showHub_gui(url);
}
gtk_tree_path_free(path);
}
@@ -324,7 +329,8 @@
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(fu->favoriteUserStore), &iter, path))
{
- F1 *func = new F1(fu, &FavoriteUsers::removeUserFromQueue_client, fu->favoriteUserView.getString(&iter, "CID"));
+ string cid = fu->favoriteUserView.getString(&iter, "CID");
+ F1 *func = new F1(fu, &FavoriteUsers::removeUserFromQueue_client, cid);
WulforManager::get()->dispatchClientFunc(func);
}
gtk_tree_path_free(path);
@@ -402,8 +408,9 @@
if (gtk_tree_model_get_iter(GTK_TREE_MODEL(fu->favoriteUserStore), &iter, path))
{
- params.insert(ParamMap::value_type(fu->favoriteUserView.getString(&iter, "CID"),
- fu->favoriteUserView.getString(&iter, _("Nick"))));
+ string cid = fu->favoriteUserView.getString(&iter, "CID");
+ string nick = fu->favoriteUserView.getString(&iter, _("Nick"));
+ params.insert(ParamMap::value_type(cid, nick));
}
gtk_tree_path_free(path);
}
@@ -411,11 +418,12 @@
if (BOOLSETTING(CONFIRM_USER_REMOVAL))
{
- GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(WulforManager::get()->getMainWindow()->getContainer()),
+ GtkWindow* parent = GTK_WINDOW(WulforManager::get()->getMainWindow()->getContainer());
+ GtkWidget* dialog = gtk_message_dialog_new(parent,
GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
+ GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
- _("Are you sure you want to delete favorite user(s)?"));
+ _("Are you sure you want to delete the selected favorite user(s)?"));
gtk_dialog_add_buttons(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_REMOVE,
GTK_RESPONSE_YES, NULL);
gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_YES, GTK_RESPONSE_CANCEL, -1);
@@ -447,9 +455,9 @@
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(fu->favoriteUserStore), &iter, path))
{
string cid = fu->favoriteUserView.getString(&iter, "CID");
- gboolean grant = fu->favoriteUserView.getValue<gboolean>(&iter, _("Auto grant slot"));
+ gboolean grant = fu->favoriteUserView.getValue<gboolean>(&iter, _("Auto Grant Slot"));
grant = !grant;
- gtk_list_store_set(fu->favoriteUserStore, &iter, fu->favoriteUserView.col(_("Auto grant slot")), grant, -1);
+ gtk_list_store_set(fu->favoriteUserStore, &iter, fu->favoriteUserView.col(_("Auto Grant Slot")), grant, -1);
typedef Func2<FavoriteUsers, string, bool> F2;
F2 *func = new F2(fu, &FavoriteUsers::setAutoGrantSlot_client, cid, grant);
@@ -485,9 +493,10 @@
UserPtr user = ClientManager::getInstance()->findUser(CID(cid));
if (user)
{
+ string message = _("Slot granted to ") + WulforUtil::getNicks(user);
UploadManager::getInstance()->reserveSlot(user, hubUrl);
typedef Func1<FavoriteUsers, string> F1;
- F1 *func = new F1(this, &FavoriteUsers::setStatus_gui, _("Slot granted to ") + WulforUtil::getNicks(user));
+ F1 *func = new F1(this, &FavoriteUsers::setStatus_gui, message);
WulforManager::get()->dispatchGuiFunc(func);
}
}
@@ -554,15 +563,15 @@
if (findUser_gui(cid, &iter))
{
- gtk_list_store_set(favoriteUserStore, &iter, favoriteUserView.col(_("Time last seen")), params["Time"].c_str(), -1);
+ gtk_list_store_set(favoriteUserStore, &iter, favoriteUserView.col(_("Time Last Seen")), params["Time"].c_str(), -1);
}
else
{
gtk_list_store_append(favoriteUserStore, &iter);
gtk_list_store_set(favoriteUserStore, &iter,
favoriteUserView.col(_("Nick")), params["Nick"].c_str(),
- favoriteUserView.col(_("Hub (last seen in, if offline)")), params["Hub"].c_str(),
- favoriteUserView.col(_("Time last seen")), params["Time"].c_str(),
+ favoriteUserView.col(_("Most Recent Hub")), params["Hub"].c_str(),
+ favoriteUserView.col(_("Time Last Seen")), params["Time"].c_str(),
favoriteUserView.col(_("Description")), params["Description"].c_str(),
favoriteUserView.col("CID"), cid.c_str(),
favoriteUserView.col("URL"), params["URL"].c_str(),
@@ -588,8 +597,9 @@
{
if (!text.empty())
{
+ string status = "[" + Util::getShortTimeString() + "] " + text;
gtk_statusbar_pop(GTK_STATUSBAR(getWidget("status")), 0);
- gtk_statusbar_push(GTK_STATUSBAR(getWidget("status")), 0, ("[" + Util::getShortTimeString() + "] " + text).c_str());
+ gtk_statusbar_push(GTK_STATUSBAR(getWidget("status")), 0, status.c_str());
}
}
@@ -610,18 +620,33 @@
void FavoriteUsers::on(FavoriteManagerListener::UserRemoved, const FavoriteUser &user) throw()
{
- Func1<FavoriteUsers, string> *func = new Func1<FavoriteUsers, string>(this, &FavoriteUsers::removeFavoriteUser_gui,
- user.getUser()->getCID().toBase32());
+ string cid = user.getUser()->getCID().toBase32();
+ typedef Func1<FavoriteUsers, string> F1;
+ F1 *func = new F1(this, &FavoriteUsers::removeFavoriteUser_gui, cid);
WulforManager::get()->dispatchGuiFunc(func);
}
-void FavoriteUsers::on(FavoriteManagerListener::StatusChanged, const FavoriteUser &user) throw()
+void FavoriteUsers::on(FavoriteManagerListener::StatusChanged, const UserPtr &user) throw()
{
ParamMap params;
- string seen = user.getUser()->isOnline() ? _("Online") : Util::formatTime("%Y-%m-%d %H:%M", user.getLastSeen());
+ string seen;
+ string cid = user->getCID().toBase32();
+
+ if (user->isOnline())
+ {
+ seen = _("Online");
+ }
+ else
+ {
+ time_t time = FavoriteManager::getInstance()->getLastSeen(user);
+ seen = Util::formatTime("%Y-%m-%d %H:%M", time);
+ }
+
params.insert(ParamMap::value_type("Time", seen));
- params.insert(ParamMap::value_type("CID", user.getUser()->getCID().toBase32()));
+ params.insert(ParamMap::value_type("CID", cid));
- Func1<FavoriteUsers, ParamMap> *func = new Func1<FavoriteUsers, ParamMap>(this, &FavoriteUsers::updateFavoriteUser_gui, params);
+ typedef Func1<FavoriteUsers, ParamMap> F1;
+ F1 *func = new F1(this, &FavoriteUsers::updateFavoriteUser_gui, params);
WulforManager::get()->dispatchGuiFunc(func);
}
+
=== modified file 'linux/favoriteusers.hh'
--- linux/favoriteusers.hh 2010-05-23 20:08:42 +0000
+++ linux/favoriteusers.hh 2010-05-25 06:12:37 +0000
@@ -73,8 +73,7 @@
// Favorite callbacks
virtual void on(dcpp::FavoriteManagerListener::UserAdded, const dcpp::FavoriteUser &user) throw();
virtual void on(dcpp::FavoriteManagerListener::UserRemoved, const dcpp::FavoriteUser &user) throw();
- // TODO: The following on is missing from the dcpp/ (or its signature is different ::StatusChanged, const UserPtr&)
- virtual void on(dcpp::FavoriteManagerListener::StatusChanged, const dcpp::FavoriteUser &user) throw();
+ virtual void on(dcpp::FavoriteManagerListener::StatusChanged, const dcpp::UserPtr& user) throw();
UserIters userIters;
GdkEventType previous;