27
27
#include "rgwindow.h"
28
28
#include "rgmainwindow.h"
29
29
#include "rgpkgdetails.h"
30
#include "rggladewindow.h"
30
#include "rggtkbuilderwindow.h"
31
31
#include "rpackage.h"
32
32
#include "rgpackagestatus.h"
33
#include "rgchangelogdialog.h"
33
34
#include "sections_trans.h"
37
36
RGPkgDetailsWindow::RGPkgDetailsWindow(RGWindow *parent)
38
: RGGladeWindow(parent, "details")
37
: RGGtkBuilderWindow(parent, "details")
40
glade_xml_signal_connect_data(_gladeXML,
41
"on_button_close_clicked",
42
G_CALLBACK(cbCloseClicked),
39
g_signal_connect(gtk_builder_get_object(_builder, "button_close"),
41
G_CALLBACK(cbCloseClicked), this);
43
GtkWidget *comboDepends = GTK_WIDGET(gtk_builder_get_object
44
(_builder, "combobox_depends"));
45
g_signal_connect(G_OBJECT(comboDepends),
47
G_CALLBACK(cbDependsMenuChanged), this);
48
GtkListStore *relTypes = gtk_list_store_new(1, G_TYPE_STRING);
51
// HACK: the labels for the combo box items are defined as
52
// the relOptions array in gtk/rgmainwindow.h.
53
// We already include it, so we get those for free.
54
for (int i = 0; relOptions[i] != NULL; i++) {
55
gtk_list_store_append(relTypes, &relIter);
56
gtk_list_store_set(relTypes, &relIter, 0, _(relOptions[i]), -1);
58
gtk_combo_box_set_model(GTK_COMBO_BOX(comboDepends),
59
GTK_TREE_MODEL(relTypes));
60
GtkCellRenderer *relRenderText = gtk_cell_renderer_text_new();
61
gtk_cell_layout_clear(GTK_CELL_LAYOUT(comboDepends));
62
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(comboDepends),
63
relRenderText, FALSE);
64
gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(comboDepends),
65
relRenderText, "text", 0);
66
gtk_combo_box_set_active(GTK_COMBO_BOX(comboDepends), 0);
46
70
void RGPkgDetailsWindow::cbCloseClicked(GtkWidget *self, void *data)
109
133
GtkWidget *win = gtk_dialog_new();
110
134
gtk_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
111
135
gtk_widget_show(img);
112
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win)->vbox), img);
136
GtkWidget *content_area = gtk_dialog_get_content_area (GTK_DIALOG (win));
137
gtk_container_add(GTK_CONTAINER(content_area), img);
113
138
gtk_dialog_run(GTK_DIALOG(win));
114
139
gtk_widget_destroy(win);
136
161
gtk_widget_show_all(event);
139
void RGPkgDetailsWindow::fillInValues(RGGladeWindow *me,
164
void RGPkgDetailsWindow::cbShowChangelog(GtkWidget *button, void *data)
166
RPackage *pkg = (RPackage*)data;
167
RGWindow *parent = (RGWindow*)g_object_get_data(G_OBJECT(button), "me");
168
ShowChangelogDialog(parent, pkg);
171
void RGPkgDetailsWindow::fillInValues(RGGtkBuilderWindow *me,
176
208
static GtkTooltips *tips = gtk_tooltips_new ();
178
textview = glade_xml_get_widget(me->getGladeXML(), "text_descr");
210
textview = GTK_WIDGET(gtk_builder_get_object
211
(me->getGtkBuilder(), "text_descr"));
179
212
assert(textview);
180
213
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
181
214
// clear old buffer
231
264
gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textview), button, anchor);
232
265
gtk_widget_show(button);
267
// add button to get changelog
268
gtk_text_buffer_insert(buf, &it, " ", 1);
269
anchor = gtk_text_buffer_create_child_anchor(buf, &it);
270
button = gtk_button_new_with_label(_("Get Changelog"));
271
g_object_set_data(G_OBJECT(button), "me", me);
272
g_signal_connect(G_OBJECT(button),"clicked",
273
G_CALLBACK(cbShowChangelog),
275
gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textview), button, anchor);
276
gtk_widget_show(button);
234
278
// show the rest of the description
235
279
gtk_text_buffer_insert(buf, &it, "\n", 1);
236
280
s = utf8(pkg->description());
259
gtk_widget_show(glade_xml_get_widget(me->getGladeXML(),
260
"scrolledwindow_filelist"));
303
gtk_widget_show(GTK_WIDGET(gtk_builder_get_object
304
(me->getGtkBuilder(),
305
"scrolledwindow_filelist")));
261
306
me->setTextView("textview_files", pkg->installedFiles());
279
324
me->setTreeList("treeview_versions", list);
281
glade_xml_signal_connect_data(me->getGladeXML(),
282
"on_optionmenu_depends_changed",
283
G_CALLBACK(cbDependsMenuChanged), me);
327
g_signal_connect(gtk_builder_get_object
328
(me->getGtkBuilder(), "combobox_depends"),
330
G_CALLBACK(cbDependsMenuChanged), me);
286
334
void RGPkgDetailsWindow::cbDependsMenuChanged(GtkWidget *self, void *data)
288
336
RGPkgDetailsWindow *me = (RGPkgDetailsWindow*)data;
290
int nr = gtk_option_menu_get_history(GTK_OPTION_MENU(self));
291
GtkWidget *notebook = glade_xml_get_widget(me->_gladeXML,
338
int nr = gtk_combo_box_get_active(GTK_COMBO_BOX(self));
339
GtkWidget *notebook = GTK_WIDGET(gtk_builder_get_object
340
(me->_builder, "notebook_dep_tab"));
293
341
assert(notebook);
294
342
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), nr);