← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 388: Added icon to tab labels

 

------------------------------------------------------------
revno: 388
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-09-07 21:51:30 -0500
message:
  Added icon to tab labels
modified:
  linux/bookentry.cc
  linux/bookentry.hh
  linux/entry.hh
  linux/hub.cc
  linux/privatemessage.cc
  linux/search.cc


--
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/bookentry.cc'
--- linux/bookentry.cc	2008-12-30 05:43:44 +0000
+++ linux/bookentry.cc	2010-09-08 02:51:30 +0000
@@ -37,6 +37,10 @@
 	gtk_event_box_set_above_child(GTK_EVENT_BOX(eventBox), TRUE);
 	gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventBox), FALSE);
 
+	// Add an icon to the tab label
+	icon = gtk_image_new();
+	gtk_box_pack_start(GTK_BOX(labelBox), icon, FALSE, FALSE, 0);
+
 	// Make the eventbox fill to all left-over space.
 	gtk_box_pack_start(GTK_BOX(labelBox), GTK_WIDGET(eventBox), TRUE, TRUE, 0);
 
@@ -71,6 +75,7 @@
 	group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(tabMenuItem));
 
 	setLabel_gui(text);
+	setIcon_gui();
 
 	// Associates entry to the widget for later retrieval in MainWindow::switchPage_gui()
 	g_object_set_data(G_OBJECT(getContainer()), "entry", (gpointer)this);
@@ -114,6 +119,52 @@
 		WulforManager::get()->getMainWindow()->setTitle(getLabelText());
 }
 
+void BookEntry::setIcon_gui(const string &customIconName)
+{
+	string iconName = customIconName;
+
+	if (iconName.empty())
+	{
+		switch (getType())
+		{
+			case Entry::DOWNLOAD_QUEUE:
+				iconName = "linuxdcpp-queue";
+				break;
+			case Entry::FAVORITE_HUBS:
+				iconName = "linuxdcpp-favorite-hubs";
+				break;
+			case Entry::FAVORITE_USERS:
+				iconName = "linuxdcpp-favorite-users";
+				break;
+			case Entry::FINISHED_DOWNLOADS:
+				iconName = "linuxdcpp-finished-downloads";
+				break;
+			case Entry::FINISHED_UPLOADS:
+				iconName = "linuxdcpp-finished-uploads";
+				break;
+			case Entry::HUB:
+				iconName = "network-server";
+				break;
+			case Entry::PRIVATE_MESSAGE:
+				iconName = "user-available";
+				break;
+			case Entry::PUBLIC_HUBS:
+				iconName = "linuxdcpp-public-hubs";
+				break;
+			case Entry::SEARCH:
+				iconName = "linuxdcpp-search";
+				break;
+			case Entry::SHARE_BROWSER:
+				iconName = "folder";
+				break;
+			default:
+				;
+		}
+	}
+
+	gtk_image_set_from_icon_name(GTK_IMAGE(icon), iconName.c_str(), GTK_ICON_SIZE_MENU);
+}
+
 void BookEntry::setBold_gui()
 {
 	if (!bold && !isActive_gui())

=== modified file 'linux/bookentry.hh'
--- linux/bookentry.hh	2008-12-30 05:43:44 +0000
+++ linux/bookentry.hh	2010-09-08 02:51:30 +0000
@@ -27,7 +27,6 @@
 class BookEntry : public Entry
 {
 	public:
-		BookEntry() {}
 		BookEntry(const EntryType type, const std::string &text, const std::string &glade, const std::string &id = "");
 		virtual ~BookEntry() {}
 
@@ -37,6 +36,7 @@
 		GtkWidget *getTabMenuItem() { return tabMenuItem; }
 		void setLabel_gui(std::string text);
 		const std::string& getLabelText();
+		void setIcon_gui(const std::string &iconName = "");
 		void setBold_gui();
 		void setUrgent_gui();
 		void setActive_gui();
@@ -44,11 +44,13 @@
 		virtual void show() = 0;
 
 	private:
+		BookEntry() {}
 		void updateLabel_gui();
 
 		std::string labelText;
 		std::string truncatedLabelText;
 		GtkWidget *eventBox;
+		GtkWidget *icon;
 		GtkWidget *labelBox;
 		GtkWidget *tabMenuItem;
 		GtkWidget *closeButton;

=== modified file 'linux/entry.hh'
--- linux/entry.hh	2010-05-22 14:23:56 +0000
+++ linux/entry.hh	2010-09-08 02:51:30 +0000
@@ -36,6 +36,7 @@
 		{
 			DOWNLOAD_QUEUE,
 			FAVORITE_HUBS,
+			FAVORITE_USERS,
 			FINISHED_DOWNLOADS,
 			FINISHED_UPLOADS,
 			HASH_DIALOG,
@@ -47,7 +48,6 @@
 			SETTINGS_DIALOG,
 			SHARE_BROWSER,
 			TRANSFERS,
-			FAVORITE_USERS,
 			USER_COMMAND_MENU
 		} EntryType;
 

=== modified file 'linux/hub.cc'
--- linux/hub.cc	2010-09-05 00:10:54 +0000
+++ linux/hub.cc	2010-09-08 02:51:30 +0000
@@ -37,7 +37,7 @@
 using namespace dcpp;
 
 Hub::Hub(const string &address, const string &encoding):
-	BookEntry(Entry::HUB, _("Hub: ") + address, "hub.glade", address),
+	BookEntry(Entry::HUB, address, "hub.glade", address),
 	client(NULL),
 	historyIndex(0),
 	totalShared(0),
@@ -1608,12 +1608,12 @@
 void Hub::on(ClientListener::HubUpdated, Client *) throw()
 {
 	typedef Func1<Hub, string> F1;
-	string hubName = _("Hub: ");
+	string hubName;
 
 	if (client->getHubName().empty())
-		hubName += client->getAddress() + ":" + Util::toString(client->getPort());
+		hubName = client->getAddress() + ":" + Util::toString(client->getPort());
 	else
-		hubName += client->getHubName();
+		hubName = client->getHubName();
 
 	if (!client->getHubDescription().empty())
 		hubName += " - " + client->getHubDescription();

=== modified file 'linux/privatemessage.cc'
--- linux/privatemessage.cc	2009-08-15 04:40:26 +0000
+++ linux/privatemessage.cc	2010-09-08 02:51:30 +0000
@@ -31,7 +31,7 @@
 using namespace dcpp;
 
 PrivateMessage::PrivateMessage(const string &cid, const string &hubUrl):
-	BookEntry(Entry::PRIVATE_MESSAGE, _("PM: ") + WulforUtil::getNicks(cid), "privatemessage.glade", cid),
+	BookEntry(Entry::PRIVATE_MESSAGE, WulforUtil::getNicks(cid), "privatemessage.glade", cid),
 	cid(cid),
 	hubUrl(hubUrl),
 	historyIndex(0),
@@ -83,7 +83,7 @@
 	UserPtr user = ClientManager::getInstance()->findUser(CID(cid));
 	isBot = user ? user->isSet(User::BOT) : FALSE;
 
-	setLabel_gui(_("PM: ") + WulforUtil::getNicks(cid) + " [" + WulforUtil::getHubNames(cid) + "]");
+	setLabel_gui(WulforUtil::getNicks(cid) + " [" + WulforUtil::getHubNames(cid) + "]");
 }
 
 PrivateMessage::~PrivateMessage()

=== modified file 'linux/search.cc'
--- linux/search.cc	2010-09-05 06:31:22 +0000
+++ linux/search.cc	2010-09-08 02:51:30 +0000
@@ -37,7 +37,7 @@
 GtkTreeModel* Search::searchEntriesModel = NULL;
 
 Search::Search():
-	BookEntry(Entry::SEARCH, _("Search: "), "search.glade", generateID()),
+	BookEntry(Entry::SEARCH, _("Search"), "search.glade", generateID()),
 	previousGrouping(NOGROUPING)
 {
 	// Initialize the search entries combo box
@@ -461,7 +461,7 @@
 	setStatus_gui("statusbar1", _("Searching for ") + text + " ...");
 	setStatus_gui("statusbar2", _("0 items"));
 	setStatus_gui("statusbar3", _("0 filtered"));
-	setLabel_gui(_("Search: ") + text);
+	setLabel_gui(text);
 
 	if (SearchManager::getInstance()->okToSearch())
 	{