2
* Copyright (C) 2004 Jens Oknelid, paskharen@gmail.com
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2
* Copyright © 2004-2006 Jens Oknelid, paskharen@gmail.com
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
#include "bookentry.hh"
20
#include <client/stdinc.h>
21
#include <client/DCPlusPlus.h>
22
#include <client/Util.h>
20
#include "wulformanager.hh"
24
22
using namespace std;
26
BookEntry::BookEntry(string title)
24
BookEntry::BookEntry(string title, string glade):
28
// Allow search tab to have many tabs with the same title.
29
if (title == "Search")
30
this->id = title + Util::toString((long)this);
35
28
box = gtk_hbox_new(FALSE, 5);
43
36
gtk_container_add(GTK_CONTAINER(eventBox), GTK_WIDGET(label));
45
38
button = GTK_BUTTON(gtk_button_new());
46
gtk_container_add(GTK_CONTAINER(button),
47
gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));
39
gtk_container_add(GTK_CONTAINER(button), gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));
48
40
gtk_widget_set_size_request(GTK_WIDGET(button), 16, 16);
49
41
gtk_button_set_relief(button, GTK_RELIEF_NONE);
50
42
gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(button), FALSE, TRUE, 0);
57
49
setLabel_gui(title);
52
GtkWidget* BookEntry::getContainer()
54
return getWidget("mainBox");
60
57
GtkWidget *BookEntry::getTitle()
65
std::string BookEntry::getID()
70
62
void BookEntry::applyCallback(GCallback closeCallback)
72
g_signal_connect(G_OBJECT(button), "clicked", closeCallback, (gpointer)this);
64
g_signal_connect(button, "clicked", closeCallback, (gpointer)this);
75
void BookEntry::setLabel_gui(std::string text)
67
void BookEntry::setLabel_gui(string text)
77
69
gtk_tooltips_set_tip(tips, eventBox, text.c_str(), text.c_str());
78
70
if (text.size() > 20)
79
text = text.substr(0, 20) + "...";
71
text = text.substr(0, 17) + "...";
80
72
gtk_label_set_text(label, text.c_str());
84
76
void BookEntry::setBold_gui()
78
if (!bold && WulforManager::get()->getMainWindow()->currentPage_gui() != getContainer())
88
80
char *markup = g_markup_printf_escaped("<b>%s</b>", title.c_str());
89
81
gtk_label_set_markup(label, markup);