~ubuntu-core-dev/synaptic/ubuntu

« back to all changes in this revision

Viewing changes to gtk/rgpkgdetails.cc

  • Committer: Michael Vogt
  • Date: 2010-12-13 10:14:40 UTC
  • mfrom: (1529.25.34 trunk)
  • Revision ID: michael.vogt@ubuntu.com-20101213101440-qxb1hccirxb6g4p4
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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"
34
35
 
35
 
 
36
 
 
37
36
RGPkgDetailsWindow::RGPkgDetailsWindow(RGWindow *parent)
38
 
   : RGGladeWindow(parent, "details")
 
37
   : RGGtkBuilderWindow(parent, "details")
39
38
{
40
 
   glade_xml_signal_connect_data(_gladeXML,
41
 
                                 "on_button_close_clicked",
42
 
                                 G_CALLBACK(cbCloseClicked),
43
 
                                 this); 
 
39
   g_signal_connect(gtk_builder_get_object(_builder, "button_close"),
 
40
                    "clicked",
 
41
                    G_CALLBACK(cbCloseClicked), this); 
 
42
   
 
43
   GtkWidget *comboDepends = GTK_WIDGET(gtk_builder_get_object
 
44
                                        (_builder, "combobox_depends"));
 
45
   g_signal_connect(G_OBJECT(comboDepends),
 
46
                    "changed",
 
47
                    G_CALLBACK(cbDependsMenuChanged), this);
 
48
   GtkListStore *relTypes = gtk_list_store_new(1, G_TYPE_STRING);
 
49
   GtkTreeIter relIter;
 
50
 
 
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);
 
57
   }
 
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);
 
67
 
44
68
}
45
69
 
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);
115
140
}
136
161
   gtk_widget_show_all(event);
137
162
}
138
163
 
139
 
void RGPkgDetailsWindow::fillInValues(RGGladeWindow *me, 
 
164
void RGPkgDetailsWindow::cbShowChangelog(GtkWidget *button, void *data)
 
165
{
 
166
   RPackage *pkg = (RPackage*)data;
 
167
   RGWindow *parent = (RGWindow*)g_object_get_data(G_OBJECT(button), "me");
 
168
   ShowChangelogDialog(parent, pkg);
 
169
}
 
170
 
 
171
void RGPkgDetailsWindow::fillInValues(RGGtkBuilderWindow *me, 
140
172
                                      RPackage *pkg,
141
173
                                      bool setTitle)
142
174
{
175
207
   const gchar *s;
176
208
   static GtkTooltips *tips = gtk_tooltips_new ();
177
209
 
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);
233
266
 
 
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),
 
274
                    pkg);
 
275
   gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(textview), button, anchor);
 
276
   gtk_widget_show(button);
 
277
 
234
278
   // show the rest of the description
235
279
   gtk_text_buffer_insert(buf, &it, "\n", 1);
236
280
   s = utf8(pkg->description());
256
300
 
257
301
   // file list
258
302
#ifndef HAVE_RPM
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());
262
307
#endif
263
308
 
278
323
   }
279
324
   me->setTreeList("treeview_versions", list);
280
325
 
281
 
   glade_xml_signal_connect_data(me->getGladeXML(), 
282
 
                                 "on_optionmenu_depends_changed",
283
 
                                 G_CALLBACK(cbDependsMenuChanged), me);
 
326
   /*
 
327
   g_signal_connect(gtk_builder_get_object
 
328
                    (me->getGtkBuilder(), "combobox_depends"),
 
329
                    "changed",
 
330
                    G_CALLBACK(cbDependsMenuChanged), me);
 
331
   */
284
332
}
285
333
 
286
334
void RGPkgDetailsWindow::cbDependsMenuChanged(GtkWidget *self, void *data)
287
335
{
288
336
   RGPkgDetailsWindow *me = (RGPkgDetailsWindow*)data;
289
337
 
290
 
   int nr =  gtk_option_menu_get_history(GTK_OPTION_MENU(self));
291
 
   GtkWidget *notebook = glade_xml_get_widget(me->_gladeXML, 
292
 
                                              "notebook_dep_tab");
 
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);
295
343
}