1 | /* rgpreferenceswindow.cc |
---|
2 | * |
---|
3 | * Copyright (c) 2000, 2001 Conectiva S/A |
---|
4 | * 2003 Michael Vogt |
---|
5 | * |
---|
6 | * Author: Alfredo K. Kojima <kojima@conectiva.com.br> |
---|
7 | * Michael Vogt <mvo@debian.org> |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License as |
---|
11 | * published by the Free Software Foundation; either version 2 of the |
---|
12 | * License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
22 | * USA |
---|
23 | */ |
---|
24 | |
---|
25 | #include "config.h" |
---|
26 | |
---|
27 | #include <apt-pkg/error.h> |
---|
28 | #include <apt-pkg/configuration.h> |
---|
29 | #include <gtk/gtk.h> |
---|
30 | #include <cassert> |
---|
31 | |
---|
32 | #include "rconfiguration.h" |
---|
33 | #include "rgpreferenceswindow.h" |
---|
34 | #include "rguserdialog.h" |
---|
35 | #include "gsynaptic.h" |
---|
36 | |
---|
37 | #include "i18n.h" |
---|
38 | |
---|
39 | enum { FONT_DEFAULT, FONT_TERMINAL }; |
---|
40 | |
---|
41 | const char * RGPreferencesWindow::column_names[] = |
---|
42 | {"status", "supported", "name", "section", "component", "instVer", |
---|
43 | "availVer", "instSize", "downloadSize", "descr", NULL }; |
---|
44 | |
---|
45 | const char *RGPreferencesWindow::column_visible_names[] = |
---|
46 | {_("Status"), _("Supported"), _("Package Name"), _("Section"), |
---|
47 | _("Component"), _("Installed Version"), _("Available Version"), |
---|
48 | _("Installed Size"), _("Download Size"),_("Description"), NULL }; |
---|
49 | |
---|
50 | const gboolean RGPreferencesWindow::column_visible_defaults[] = |
---|
51 | { TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE }; |
---|
52 | |
---|
53 | #if !GTK_CHECK_VERSION(2,6,0) |
---|
54 | gchar * |
---|
55 | gtk_combo_box_get_active_text (GtkComboBox *combo_box) |
---|
56 | { |
---|
57 | GtkTreeIter iter; |
---|
58 | gchar *text = NULL; |
---|
59 | |
---|
60 | GtkTreeModel* model = gtk_combo_box_get_model(combo_box); |
---|
61 | |
---|
62 | if (gtk_combo_box_get_active_iter (combo_box, &iter)) |
---|
63 | gtk_tree_model_get (model, &iter, 0, &text, -1); |
---|
64 | |
---|
65 | return text; |
---|
66 | } |
---|
67 | #endif |
---|
68 | |
---|
69 | void RGPreferencesWindow::cbArchiveSelection(GtkWidget *self, void *data) |
---|
70 | { |
---|
71 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
72 | //cout << "void RGPreferencesWindow::onArchiveSelection()" << endl; |
---|
73 | //cout << "data is: " << (char*)data << endl; |
---|
74 | |
---|
75 | if(me->_blockAction) |
---|
76 | return; |
---|
77 | |
---|
78 | gchar *s=gtk_combo_box_get_active_text(GTK_COMBO_BOX(self)); |
---|
79 | if(s!=NULL) { |
---|
80 | me->_defaultDistro = s; |
---|
81 | //cout << "new default distro: " << me->_defaultDistro << endl; |
---|
82 | me->distroChanged = true; |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | void RGPreferencesWindow::cbRadioDistributionChanged(GtkWidget *self, |
---|
87 | void *data) |
---|
88 | { |
---|
89 | //cout << "void RGPreferencesWindow::cbRadioDistributionChanged()" << endl; |
---|
90 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
91 | |
---|
92 | // we are only interessted in the active one |
---|
93 | if(me->_blockAction || !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self))) |
---|
94 | return; |
---|
95 | |
---|
96 | gchar *defaultDistro = (gchar*)g_object_get_data(G_OBJECT(self),"defaultDistro"); |
---|
97 | if(strcmp(defaultDistro, "distro") == 0) { |
---|
98 | gtk_widget_set_sensitive(GTK_WIDGET(me->_comboDefaultDistro),TRUE); |
---|
99 | gchar *s = gtk_combo_box_get_active_text(GTK_COMBO_BOX(me->_comboDefaultDistro)); |
---|
100 | if(s!=NULL) |
---|
101 | me->_defaultDistro = s; |
---|
102 | } else { |
---|
103 | gtk_widget_set_sensitive(GTK_WIDGET(me->_comboDefaultDistro),FALSE); |
---|
104 | me->_defaultDistro = defaultDistro; |
---|
105 | } |
---|
106 | //cout << "new default distro: " << me->_defaultDistro << endl; |
---|
107 | me->distroChanged = true; |
---|
108 | } |
---|
109 | |
---|
110 | void RGPreferencesWindow::applyProxySettings() |
---|
111 | { |
---|
112 | string http, ftp, noProxy; |
---|
113 | gchar *s; |
---|
114 | int httpPort, ftpPort; |
---|
115 | |
---|
116 | // save apts settings here |
---|
117 | static bool firstRun = true; |
---|
118 | static string aptHttpProxy, aptFtpProxy; |
---|
119 | |
---|
120 | if(firstRun) { |
---|
121 | aptHttpProxy = _config->Find("Acquire::http::Proxy"); |
---|
122 | aptFtpProxy = _config->Find("Acquire::ftp::Proxy"); |
---|
123 | |
---|
124 | firstRun = false; |
---|
125 | } |
---|
126 | |
---|
127 | bool useProxy = _config->FindB("Synaptic::useProxy", false); |
---|
128 | // now set the stuff for apt |
---|
129 | if (useProxy) { |
---|
130 | http = _config->Find("Synaptic::httpProxy", ""); |
---|
131 | httpPort = _config->FindI("Synaptic::httpProxyPort", 3128); |
---|
132 | ftp = _config->Find("Synaptic::ftpProxy", ""); |
---|
133 | ftpPort = _config->FindI("Synaptic::ftpProxyPort", 3128); |
---|
134 | noProxy = _config->Find("Synaptic::noProxy", ""); |
---|
135 | |
---|
136 | if(!http.empty()) { |
---|
137 | s = g_strdup_printf("http://%s:%i", http.c_str(), httpPort); |
---|
138 | _config->Set("Acquire::http::Proxy", s); |
---|
139 | g_free(s); |
---|
140 | } |
---|
141 | if(!ftp.empty()) { |
---|
142 | s = g_strdup_printf("http://%s:%i", ftp.c_str(), ftpPort); |
---|
143 | _config->Set("Acquire::ftp::Proxy", s); |
---|
144 | g_free(s); |
---|
145 | } |
---|
146 | // set the no-proxies |
---|
147 | gchar **noProxyArray = g_strsplit(noProxy.c_str(), ",", 0); |
---|
148 | for (int j = 0; noProxyArray[j] != NULL; j++) { |
---|
149 | g_strstrip(noProxyArray[j]); |
---|
150 | s = g_strdup_printf("Acquire::http::Proxy::%s", noProxyArray[j]); |
---|
151 | _config->Set(s, "DIRECT"); |
---|
152 | g_free(s); |
---|
153 | s = g_strdup_printf("Acquire::ftp::Proxy::%s", noProxyArray[j]); |
---|
154 | _config->Set(s, "DIRECT"); |
---|
155 | g_free(s); |
---|
156 | } |
---|
157 | g_strfreev(noProxyArray); |
---|
158 | } else { |
---|
159 | //FIXME: we can't just clean here as apt may have it's own proxy |
---|
160 | // settings! |
---|
161 | _config->Set("Acquire::http::Proxy",aptHttpProxy); |
---|
162 | _config->Set("Acquire::ftp::Proxy", aptFtpProxy); |
---|
163 | } |
---|
164 | } |
---|
165 | |
---|
166 | void RGPreferencesWindow::saveGeneral() |
---|
167 | { |
---|
168 | bool newval; |
---|
169 | int i; |
---|
170 | |
---|
171 | // show package properties in main window |
---|
172 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionShowAllPkgInfoInMain)); |
---|
173 | _config->Set("Synaptic::ShowAllPkgInfoInMain", newval ? "true" : "false"); |
---|
174 | // apply the changes |
---|
175 | GtkWidget *notebook = glade_xml_get_widget(_mainWin->getGladeXML(), |
---|
176 | "notebook_pkginfo"); |
---|
177 | gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), newval); |
---|
178 | GtkWidget *box = glade_xml_get_widget(_mainWin->getGladeXML(), |
---|
179 | "vbox_pkgdescr"); |
---|
180 | if(newval) { |
---|
181 | gtk_container_set_border_width(GTK_CONTAINER(box), 6); |
---|
182 | } else { |
---|
183 | gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0); |
---|
184 | gtk_container_set_border_width(GTK_CONTAINER(box), 0); |
---|
185 | } |
---|
186 | |
---|
187 | // Ask to confirm changes also affecting other packages |
---|
188 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionAskRelated)); |
---|
189 | _config->Set("Synaptic::AskRelated", newval ? "true" : "false"); |
---|
190 | |
---|
191 | // Consider recommended packages as dependencies |
---|
192 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionCheckRecom)); |
---|
193 | _config->Set("Synaptic::UseRecommends", newval ? "true" : "false"); |
---|
194 | |
---|
195 | // Clicking on the status icon marks the most likely action |
---|
196 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionOneClick)); |
---|
197 | _config->Set("Synaptic::OneClickOnStatusActions", newval ? "true" : "false"); |
---|
198 | |
---|
199 | // Removal of packages: |
---|
200 | int delAction= gtk_option_menu_get_history(GTK_OPTION_MENU(_optionmenuDel)); |
---|
201 | // ugly :( but we need this +2 because RGPkgAction starts with |
---|
202 | // "keep","install" |
---|
203 | delAction += 2; |
---|
204 | _config->Set("Synaptic::delAction", delAction); |
---|
205 | |
---|
206 | // System upgrade: |
---|
207 | // upgrade type, (ask=-1,normal=0,dist-upgrade=1) |
---|
208 | i = gtk_option_menu_get_history(GTK_OPTION_MENU(glade_xml_get_widget(_gladeXML, "optionmenu_upgrade_method"))); |
---|
209 | _config->Set("Synaptic::upgradeType", i - 1); |
---|
210 | |
---|
211 | // package list update date check |
---|
212 | i = gtk_option_menu_get_history(GTK_OPTION_MENU(glade_xml_get_widget(_gladeXML, "optionmenu_update_ask"))); |
---|
213 | _config->Set("Synaptic::update::type", i); |
---|
214 | |
---|
215 | |
---|
216 | // Number of undo operations: |
---|
217 | int maxUndo = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(_maxUndoE)); |
---|
218 | _config->Set("Synaptic::undoStackSize", maxUndo); |
---|
219 | |
---|
220 | // Apply changes in a terminal window |
---|
221 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionUseTerminal)); |
---|
222 | _config->Set("Synaptic::UseTerminal", newval ? "true" : "false"); |
---|
223 | |
---|
224 | // Ask to quit after the changes have been applied successfully |
---|
225 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionAskQuit)); |
---|
226 | _config->Set("Synaptic::AskQuitOnProceed", newval ? "true" : "false"); |
---|
227 | |
---|
228 | } |
---|
229 | |
---|
230 | void RGPreferencesWindow::saveColumnsAndFonts() |
---|
231 | { |
---|
232 | bool newval; |
---|
233 | |
---|
234 | // Use custom application font |
---|
235 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(_gladeXML, "checkbutton_user_font"))); |
---|
236 | _config->Set("Synaptic::useUserFont", newval); |
---|
237 | |
---|
238 | GValue value = { 0, }; |
---|
239 | g_value_init(&value, G_TYPE_STRING); |
---|
240 | if (newval) { |
---|
241 | g_value_set_string(&value, _config->Find("Synaptic::FontName").c_str()); |
---|
242 | g_object_set_property(G_OBJECT(gtk_settings_get_default()), |
---|
243 | "gtk-font-name", &value); |
---|
244 | } else { |
---|
245 | g_value_set_string(&value, |
---|
246 | _config->Find("Volatile::orginalFontName", |
---|
247 | "Sans 10").c_str()); |
---|
248 | g_object_set_property(G_OBJECT(gtk_settings_get_default()), |
---|
249 | "gtk-font-name", &value); |
---|
250 | } |
---|
251 | g_value_unset(&value); |
---|
252 | |
---|
253 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(_gladeXML, "checkbutton_user_terminal_font"))); |
---|
254 | _config->Set("Synaptic::useUserTerminalFont", newval); |
---|
255 | |
---|
256 | |
---|
257 | // treeviewstuff |
---|
258 | // get from GtkListStore |
---|
259 | GtkListStore *store = _listColumns; |
---|
260 | GtkTreeIter iter; |
---|
261 | int i=0; |
---|
262 | char *column_name, *config_name; |
---|
263 | gboolean visible; |
---|
264 | gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); |
---|
265 | do { |
---|
266 | gtk_tree_model_get (GTK_TREE_MODEL(store), &iter, |
---|
267 | TREE_CHECKBOX_COLUMN, &visible, |
---|
268 | TREE_NAME_COLUMN, &column_name, |
---|
269 | -1); |
---|
270 | |
---|
271 | // pos |
---|
272 | config_name = g_strdup_printf("Synaptic::%sColumnPos",column_name); |
---|
273 | _config->Set(config_name, i); |
---|
274 | //cout << column_name << " : " << i << endl; |
---|
275 | g_free(config_name); |
---|
276 | |
---|
277 | // visible |
---|
278 | config_name = g_strdup_printf("Synaptic::%sColumnVisible",column_name); |
---|
279 | _config->Set(config_name, visible); |
---|
280 | g_free(config_name); |
---|
281 | |
---|
282 | i++; |
---|
283 | } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); |
---|
284 | |
---|
285 | // rebuild the treeview |
---|
286 | _mainWin->rebuildTreeView(); |
---|
287 | } |
---|
288 | |
---|
289 | void RGPreferencesWindow::saveColors() |
---|
290 | { |
---|
291 | bool newval; |
---|
292 | |
---|
293 | // save the colors |
---|
294 | RGPackageStatus::pkgStatus.saveColors(); |
---|
295 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionUseStatusColors)); |
---|
296 | _config->Set("Synaptic::UseStatusColors", newval ? "true" : "false"); |
---|
297 | } |
---|
298 | |
---|
299 | void RGPreferencesWindow::saveFiles() |
---|
300 | { |
---|
301 | bool newval; |
---|
302 | |
---|
303 | // cache |
---|
304 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_cacheClean)); |
---|
305 | _config->Set("Synaptic::CleanCache", newval ? "true" : "false"); |
---|
306 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_cacheAutoClean)); |
---|
307 | _config->Set("Synaptic::AutoCleanCache", newval ? "true" : "false"); |
---|
308 | |
---|
309 | // history |
---|
310 | newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_delHistory)); |
---|
311 | if(!newval) { |
---|
312 | _config->Set("Synaptic::delHistory", -1); |
---|
313 | return; |
---|
314 | } |
---|
315 | int delHistory= gtk_spin_button_get_value(GTK_SPIN_BUTTON(_spinDelHistory)); |
---|
316 | _config->Set("Synaptic::delHistory", delHistory); |
---|
317 | _lister->cleanCommitLog(); |
---|
318 | } |
---|
319 | |
---|
320 | void RGPreferencesWindow::saveNetwork() |
---|
321 | { |
---|
322 | // proxy stuff |
---|
323 | bool useProxy; |
---|
324 | const gchar *http, *ftp, *noProxy; |
---|
325 | int httpPort, ftpPort; |
---|
326 | |
---|
327 | useProxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_useProxy)); |
---|
328 | _config->Set("Synaptic::useProxy", useProxy); |
---|
329 | // http |
---|
330 | http = gtk_entry_get_text( |
---|
331 | GTK_ENTRY(glade_xml_get_widget(_gladeXML, "entry_http_proxy"))); |
---|
332 | _config->Set("Synaptic::httpProxy", http); |
---|
333 | httpPort = (int) gtk_spin_button_get_value( |
---|
334 | GTK_SPIN_BUTTON(glade_xml_get_widget(_gladeXML, |
---|
335 | "spinbutton_http_port"))); |
---|
336 | _config->Set("Synaptic::httpProxyPort", httpPort); |
---|
337 | // ftp |
---|
338 | ftp = gtk_entry_get_text( |
---|
339 | GTK_ENTRY(glade_xml_get_widget(_gladeXML, "entry_ftp_proxy"))); |
---|
340 | _config->Set("Synaptic::ftpProxy", ftp); |
---|
341 | ftpPort = (int) gtk_spin_button_get_value( |
---|
342 | GTK_SPIN_BUTTON(glade_xml_get_widget(_gladeXML, |
---|
343 | "spinbutton_ftp_port"))); |
---|
344 | _config->Set("Synaptic::ftpProxyPort", ftpPort); |
---|
345 | noProxy = gtk_entry_get_text( |
---|
346 | GTK_ENTRY(glade_xml_get_widget(_gladeXML, "entry_no_proxy"))); |
---|
347 | _config->Set("Synaptic::noProxy", noProxy); |
---|
348 | |
---|
349 | applyProxySettings(); |
---|
350 | |
---|
351 | } |
---|
352 | |
---|
353 | void RGPreferencesWindow::saveDistribution() |
---|
354 | { |
---|
355 | if (_defaultDistro.empty()) { |
---|
356 | _config->Clear("APT::Default-Release"); |
---|
357 | _config->Clear("Synaptic::DefaultDistro"); |
---|
358 | } else { |
---|
359 | _config->Set("APT::Default-Release", _defaultDistro); |
---|
360 | _config->Set("Synaptic::DefaultDistro", _defaultDistro); |
---|
361 | } |
---|
362 | } |
---|
363 | |
---|
364 | |
---|
365 | void RGPreferencesWindow::saveAction(GtkWidget *self, void *data) |
---|
366 | { |
---|
367 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
368 | |
---|
369 | me->saveGeneral(); |
---|
370 | me->saveColumnsAndFonts(); |
---|
371 | me->saveColors(); |
---|
372 | me->saveFiles(); |
---|
373 | me->saveNetwork(); |
---|
374 | me->saveDistribution(); |
---|
375 | |
---|
376 | if (!RWriteConfigFile(*_config)) { |
---|
377 | _error->Error(_("An error occurred while saving configurations.")); |
---|
378 | RGUserDialog userDialog(me); |
---|
379 | userDialog.showErrors(); |
---|
380 | } |
---|
381 | } |
---|
382 | |
---|
383 | |
---|
384 | void RGPreferencesWindow::closeAction(GtkWidget *self, void *data) |
---|
385 | { |
---|
386 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
387 | me->close(); |
---|
388 | } |
---|
389 | |
---|
390 | void RGPreferencesWindow::doneAction(GtkWidget *self, void *data) |
---|
391 | { |
---|
392 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
393 | me->saveAction(self, data); |
---|
394 | if (me->distroChanged) { |
---|
395 | me->hide(); |
---|
396 | me->_lister->unregisterObserver(me->_mainWin); |
---|
397 | me->_mainWin->setTreeLocked(TRUE); |
---|
398 | me->_lister->openCache(); |
---|
399 | me->_mainWin->setTreeLocked(FALSE); |
---|
400 | me->_lister->registerObserver(me->_mainWin); |
---|
401 | me->_mainWin->refreshTable(); |
---|
402 | } |
---|
403 | me->closeAction(self, data); |
---|
404 | } |
---|
405 | |
---|
406 | void RGPreferencesWindow::changeFontAction(GtkWidget *self, void *data) |
---|
407 | { |
---|
408 | const char *fontName, *propName; |
---|
409 | |
---|
410 | switch (GPOINTER_TO_INT(data)) { |
---|
411 | case FONT_DEFAULT: |
---|
412 | propName = "Synaptic::FontName"; |
---|
413 | fontName = "sans 10"; |
---|
414 | break; |
---|
415 | case FONT_TERMINAL: |
---|
416 | propName = "Synaptic::TerminalFontName"; |
---|
417 | fontName = "monospace 10"; |
---|
418 | break; |
---|
419 | default: |
---|
420 | cerr << "changeFontAction called with unknown argument" << endl; |
---|
421 | return; |
---|
422 | } |
---|
423 | |
---|
424 | GtkWidget *fontsel = gtk_font_selection_dialog_new(_("Choose font")); |
---|
425 | |
---|
426 | gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontsel), |
---|
427 | _config->Find(propName, |
---|
428 | fontName).c_str()); |
---|
429 | |
---|
430 | gint result = gtk_dialog_run(GTK_DIALOG(fontsel)); |
---|
431 | if (result != GTK_RESPONSE_OK) { |
---|
432 | gtk_widget_destroy(fontsel); |
---|
433 | return; |
---|
434 | } |
---|
435 | |
---|
436 | fontName = |
---|
437 | gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG |
---|
438 | (fontsel)); |
---|
439 | |
---|
440 | //cout << "fontname: " << fontName << endl; |
---|
441 | |
---|
442 | _config->Set(propName, fontName); |
---|
443 | |
---|
444 | gtk_widget_destroy(fontsel); |
---|
445 | } |
---|
446 | |
---|
447 | void RGPreferencesWindow::clearCacheAction(GtkWidget *self, void *data) |
---|
448 | { |
---|
449 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
450 | |
---|
451 | me->_lister->cleanPackageCache(true); |
---|
452 | } |
---|
453 | |
---|
454 | void RGPreferencesWindow::readGeneral() |
---|
455 | { |
---|
456 | // Allow regular expressions in searches and filters |
---|
457 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionShowAllPkgInfoInMain), |
---|
458 | _config->FindB("Synaptic::ShowAllPkgInfoInMain", false)); |
---|
459 | |
---|
460 | // Ask to confirm changes also affecting other packages |
---|
461 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionAskRelated), |
---|
462 | _config->FindB("Synaptic::AskRelated", true)); |
---|
463 | |
---|
464 | // Consider recommended packages as dependencies |
---|
465 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionCheckRecom), |
---|
466 | _config->FindB("Synaptic::UseRecommends", |
---|
467 | false)); |
---|
468 | |
---|
469 | // Clicking on the status icon marks the most likely action |
---|
470 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionOneClick), |
---|
471 | _config->FindB("Synaptic::OneClickOnStatusActions", |
---|
472 | false)); |
---|
473 | |
---|
474 | // Removal of packages: |
---|
475 | int delAction = _config->FindI("Synaptic::delAction", PKG_DELETE); |
---|
476 | // now set the optionmenu |
---|
477 | // ugly :( but we need this -2 because RGPkgAction starts with |
---|
478 | // "keep","install" |
---|
479 | gtk_option_menu_set_history(GTK_OPTION_MENU(_optionmenuDel), delAction - 2); |
---|
480 | |
---|
481 | |
---|
482 | // System upgrade: |
---|
483 | // upgradeType (ask=-1,normal=0,dist-upgrade=1) |
---|
484 | int i = _config->FindI("Synaptic::upgradeType", 0); |
---|
485 | gtk_option_menu_set_history(GTK_OPTION_MENU(glade_xml_get_widget(_gladeXML, "optionmenu_upgrade_method")), i + 1); |
---|
486 | |
---|
487 | i = _config->FindI("Synaptic::update::type", 0); |
---|
488 | gtk_option_menu_set_history(GTK_OPTION_MENU(glade_xml_get_widget(_gladeXML, "optionmenu_update_ask")), i); |
---|
489 | |
---|
490 | |
---|
491 | // Number of undo operations: |
---|
492 | |
---|
493 | #ifdef HAVE_RPM |
---|
494 | int UndoStackSize = 3; |
---|
495 | #else |
---|
496 | int UndoStackSize = 20; |
---|
497 | #endif |
---|
498 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(_maxUndoE), |
---|
499 | _config->FindI("Synaptic::undoStackSize", |
---|
500 | UndoStackSize)); |
---|
501 | |
---|
502 | |
---|
503 | // Apply changes in a terminal window |
---|
504 | bool UseTerminal = false; |
---|
505 | #ifndef HAVE_TERMINAL |
---|
506 | gtk_widget_set_sensitive(GTK_WIDGET(_optionUseTerminal), false); |
---|
507 | _config->Set("Synaptic::UseTerminal", false); |
---|
508 | #else |
---|
509 | #ifndef HAVE_RPM |
---|
510 | #ifndef WITH_DPKG_STATUSFD |
---|
511 | UseTerminal = true; |
---|
512 | #endif |
---|
513 | #endif |
---|
514 | #endif |
---|
515 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionUseTerminal), |
---|
516 | _config->FindB("Synaptic::UseTerminal", |
---|
517 | UseTerminal)); |
---|
518 | |
---|
519 | // Ask to quit after the changes have been applied successfully |
---|
520 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionAskQuit), |
---|
521 | _config->FindB("Synaptic::AskQuitOnProceed", |
---|
522 | false)); |
---|
523 | } |
---|
524 | |
---|
525 | void RGPreferencesWindow::readColumnsAndFonts() |
---|
526 | { |
---|
527 | // font stuff |
---|
528 | bool b = _config->FindB("Synaptic::useUserFont", false); |
---|
529 | gtk_toggle_button_set_active( |
---|
530 | GTK_TOGGLE_BUTTON(glade_xml_get_widget(_gladeXML, |
---|
531 | "checkbutton_user_font")), b); |
---|
532 | b = _config->FindB("Synaptic::useUserTerminalFont", false); |
---|
533 | gtk_toggle_button_set_active( |
---|
534 | GTK_TOGGLE_BUTTON(glade_xml_get_widget(_gladeXML, |
---|
535 | "checkbutton_user_terminal_font")), b); |
---|
536 | |
---|
537 | readTreeViewValues(); |
---|
538 | |
---|
539 | } |
---|
540 | |
---|
541 | void RGPreferencesWindow::readColors() |
---|
542 | { |
---|
543 | GdkColor *color; |
---|
544 | gchar *color_button; |
---|
545 | GtkWidget *button = NULL; |
---|
546 | |
---|
547 | // Color packages by their status |
---|
548 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionUseStatusColors), |
---|
549 | _config->FindB("Synaptic::UseStatusColors", |
---|
550 | true)); |
---|
551 | |
---|
552 | // color buttons |
---|
553 | for (int i = 0; i < RGPackageStatus::N_STATUS_COUNT; i++) { |
---|
554 | color_button = |
---|
555 | g_strdup_printf("button_%s_color", |
---|
556 | RGPackageStatus::pkgStatus. |
---|
557 | getShortStatusString(RGPackageStatus::PkgStatus(i))); |
---|
558 | button = glade_xml_get_widget(_gladeXML, color_button); |
---|
559 | assert(button); |
---|
560 | if (RGPackageStatus::pkgStatus.getColor(i) != NULL) { |
---|
561 | color = RGPackageStatus::pkgStatus.getColor(i); |
---|
562 | gtk_widget_modify_bg(button, GTK_STATE_PRELIGHT, color); |
---|
563 | gtk_widget_modify_bg(button, GTK_STATE_NORMAL, color); |
---|
564 | } |
---|
565 | g_free(color_button); |
---|
566 | } |
---|
567 | |
---|
568 | } |
---|
569 | |
---|
570 | void RGPreferencesWindow::readFiles() |
---|
571 | { |
---|
572 | // <b>Temporary Files</b> |
---|
573 | bool postClean = _config->FindB("Synaptic::CleanCache", false); |
---|
574 | bool postAutoClean = _config->FindB("Synaptic::AutoCleanCache", true); |
---|
575 | |
---|
576 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_cacheClean), postClean); |
---|
577 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_cacheAutoClean), |
---|
578 | postAutoClean); |
---|
579 | |
---|
580 | if (postClean) |
---|
581 | gtk_button_clicked(GTK_BUTTON(_cacheClean)); |
---|
582 | else if (postAutoClean) |
---|
583 | gtk_button_clicked(GTK_BUTTON(_cacheAutoClean)); |
---|
584 | else |
---|
585 | gtk_button_clicked(GTK_BUTTON(_cacheLeave)); |
---|
586 | |
---|
587 | // history |
---|
588 | int delHistory = _config->FindI("Synaptic::delHistory", -1); |
---|
589 | if(delHistory < 0) |
---|
590 | gtk_button_clicked(GTK_BUTTON(_keepHistory)); |
---|
591 | else { |
---|
592 | gtk_button_clicked(GTK_BUTTON(_delHistory)); |
---|
593 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(_spinDelHistory), |
---|
594 | delHistory); |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | void RGPreferencesWindow::readNetwork() |
---|
599 | { |
---|
600 | // proxy stuff |
---|
601 | bool useProxy = _config->FindB("Synaptic::useProxy", false); |
---|
602 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(glade_xml_get_widget(_gladeXML, "radio_use_proxy")), useProxy); |
---|
603 | gtk_widget_set_sensitive(glade_xml_get_widget(_gladeXML, "table_proxy"), |
---|
604 | useProxy); |
---|
605 | string str = _config->Find("Synaptic::httpProxy", ""); |
---|
606 | gtk_entry_set_text(GTK_ENTRY(glade_xml_get_widget(_gladeXML, "entry_http_proxy")), str.c_str()); |
---|
607 | int i = _config->FindI("Synaptic::httpProxyPort", 3128); |
---|
608 | gtk_spin_button_set_value(GTK_SPIN_BUTTON |
---|
609 | (glade_xml_get_widget |
---|
610 | (_gladeXML, "spinbutton_http_port")), i); |
---|
611 | |
---|
612 | str = _config->Find("Synaptic::ftpProxy", ""); |
---|
613 | gtk_entry_set_text( |
---|
614 | GTK_ENTRY(glade_xml_get_widget(_gladeXML, "entry_ftp_proxy")), str.c_str()); |
---|
615 | i = _config->FindI("Synaptic::ftpProxyPort", 3128); |
---|
616 | gtk_spin_button_set_value( |
---|
617 | GTK_SPIN_BUTTON(glade_xml_get_widget(_gladeXML, "spinbutton_ftp_port")), i); |
---|
618 | str = _config->Find("Synaptic::noProxy", ""); |
---|
619 | gtk_entry_set_text(GTK_ENTRY(glade_xml_get_widget(_gladeXML, |
---|
620 | "entry_no_proxy")), |
---|
621 | str.c_str()); |
---|
622 | |
---|
623 | } |
---|
624 | |
---|
625 | void RGPreferencesWindow::readDistribution() |
---|
626 | { |
---|
627 | // distro selection, block actions here because the optionmenu changes |
---|
628 | // and a signal is emited |
---|
629 | _blockAction = true; |
---|
630 | |
---|
631 | int distroMatch = 0; |
---|
632 | string defaultDistro = _config->Find("Synaptic::DefaultDistro", ""); |
---|
633 | vector<string> archives = _lister->getPolicyArchives(); |
---|
634 | |
---|
635 | // setup the toggle buttons |
---|
636 | GtkWidget *button, *ignore,*now,*distro; |
---|
637 | ignore = glade_xml_get_widget(_gladeXML, "radiobutton_ignore"); |
---|
638 | g_object_set_data(G_OBJECT(ignore),"defaultDistro",(void*)""); |
---|
639 | now = glade_xml_get_widget(_gladeXML, "radiobutton_now"); |
---|
640 | g_object_set_data(G_OBJECT(now),"defaultDistro",(void*)"now"); |
---|
641 | distro = glade_xml_get_widget(_gladeXML, "radiobutton_distro"); |
---|
642 | g_object_set_data(G_OBJECT(distro),"defaultDistro",(void*)"distro"); |
---|
643 | glade_xml_signal_connect_data(_gladeXML, |
---|
644 | "on_radiobutton_distribution_group_changed", |
---|
645 | G_CALLBACK(cbRadioDistributionChanged), |
---|
646 | this); |
---|
647 | |
---|
648 | // clear the combo box |
---|
649 | GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(_comboDefaultDistro)); |
---|
650 | int num = gtk_tree_model_iter_n_children(model, NULL); |
---|
651 | for(;num >= 0;num--) |
---|
652 | gtk_combo_box_remove_text(GTK_COMBO_BOX(_comboDefaultDistro), num); |
---|
653 | |
---|
654 | if(defaultDistro == "") { |
---|
655 | button = ignore; |
---|
656 | gtk_widget_set_sensitive(GTK_WIDGET(_comboDefaultDistro),FALSE); |
---|
657 | } else if(defaultDistro == "now") { |
---|
658 | button = now; |
---|
659 | gtk_widget_set_sensitive(GTK_WIDGET(_comboDefaultDistro),FALSE); |
---|
660 | } else { |
---|
661 | button = distro; |
---|
662 | gtk_widget_set_sensitive(GTK_WIDGET(_comboDefaultDistro),TRUE); |
---|
663 | } |
---|
664 | assert(button); |
---|
665 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); |
---|
666 | |
---|
667 | |
---|
668 | // set up combo-box |
---|
669 | g_signal_connect(G_OBJECT(_comboDefaultDistro), "changed", |
---|
670 | G_CALLBACK(cbArchiveSelection), this); |
---|
671 | |
---|
672 | for (unsigned int i = 0; i < archives.size(); i++) { |
---|
673 | //cout << "archive: " << archives[i] << endl; |
---|
674 | // ignore "now", it's a toggle button item now |
---|
675 | if(archives[i] == "now") |
---|
676 | continue; |
---|
677 | gtk_combo_box_append_text(GTK_COMBO_BOX(_comboDefaultDistro), |
---|
678 | archives[i].c_str()); |
---|
679 | if (defaultDistro == archives[i]) { |
---|
680 | //cout << "match for: " << archives[i] << " (" << i << ")" << endl; |
---|
681 | // we ignored the "now" archive, so we have to subtract by one |
---|
682 | distroMatch=i-1; |
---|
683 | } |
---|
684 | } |
---|
685 | gtk_combo_box_set_active(GTK_COMBO_BOX(_comboDefaultDistro), distroMatch); |
---|
686 | |
---|
687 | _blockAction = false; |
---|
688 | } |
---|
689 | |
---|
690 | void RGPreferencesWindow::show() |
---|
691 | { |
---|
692 | readGeneral(); |
---|
693 | readColumnsAndFonts(); |
---|
694 | readColors(); |
---|
695 | readFiles(); |
---|
696 | readNetwork(); |
---|
697 | readDistribution(); |
---|
698 | |
---|
699 | RGWindow::show(); |
---|
700 | } |
---|
701 | |
---|
702 | |
---|
703 | void RGPreferencesWindow::readTreeViewValues() |
---|
704 | { |
---|
705 | |
---|
706 | // number of entries in columns is (sizeof(columns)/sizeof(char*))-1 |
---|
707 | int number_of_columns = sizeof(column_names)/sizeof(char*)-1; |
---|
708 | |
---|
709 | // the position in this vector is the position of the column |
---|
710 | vector<column_struct> columns(number_of_columns); |
---|
711 | |
---|
712 | // make sure that we fail gracefully |
---|
713 | bool corrupt=false; |
---|
714 | |
---|
715 | // put into right place |
---|
716 | gchar *name; |
---|
717 | int pos; |
---|
718 | column_struct c; |
---|
719 | for(int i=0;column_names[i] != NULL; i++) { |
---|
720 | // pos |
---|
721 | name = g_strdup_printf("Synaptic::%sColumnPos",column_names[i]); |
---|
722 | pos = _config->FindI(name, i); |
---|
723 | g_free(name); |
---|
724 | |
---|
725 | // visible |
---|
726 | name = g_strdup_printf("Synaptic::%sColumnVisible",column_names[i]); |
---|
727 | c.visible = _config->FindB(name, column_visible_defaults[i]); |
---|
728 | c.name = column_names[i]; |
---|
729 | c.visible_name = column_visible_names[i]; |
---|
730 | g_free(name); |
---|
731 | |
---|
732 | if(pos > number_of_columns || pos < 0 || columns[pos].name != NULL) { |
---|
733 | //cerr << "invalid column config found, reseting"<<endl; |
---|
734 | corrupt=true; |
---|
735 | continue; |
---|
736 | } |
---|
737 | columns[pos] = c; |
---|
738 | } |
---|
739 | |
---|
740 | // if corrupt for some reason, repair |
---|
741 | if(corrupt) { |
---|
742 | cerr << "seting column order to default" << endl; |
---|
743 | for(int i=0;column_names[i] != NULL; i++) { |
---|
744 | name = g_strdup_printf("Synaptic::%sColumnPos",column_names[i]); |
---|
745 | _config->Set(name, i); |
---|
746 | c.visible = column_visible_defaults[i]; |
---|
747 | c.name = column_names[i]; |
---|
748 | c.visible_name = column_visible_names[i]; |
---|
749 | columns[i] = c; |
---|
750 | } |
---|
751 | } |
---|
752 | |
---|
753 | |
---|
754 | // put into GtkListStore |
---|
755 | GtkListStore *store = _listColumns = gtk_list_store_new(3, |
---|
756 | G_TYPE_BOOLEAN, |
---|
757 | G_TYPE_STRING, |
---|
758 | G_TYPE_STRING); |
---|
759 | GtkTreeIter iter; |
---|
760 | for(unsigned int i=0;i<columns.size();i++) { |
---|
761 | gtk_list_store_append (store, &iter); |
---|
762 | gtk_list_store_set (store, &iter, |
---|
763 | TREE_CHECKBOX_COLUMN, columns[i].visible, |
---|
764 | TREE_NAME_COLUMN, columns[i].name, |
---|
765 | TREE_VISIBLE_NAME_COLUMN, _(columns[i].visible_name), |
---|
766 | -1); |
---|
767 | |
---|
768 | } |
---|
769 | |
---|
770 | // now set the model |
---|
771 | gtk_tree_view_set_model(GTK_TREE_VIEW(_treeView), |
---|
772 | GTK_TREE_MODEL(_listColumns)); |
---|
773 | |
---|
774 | } |
---|
775 | |
---|
776 | void RGPreferencesWindow::cbMoveColumnUp(GtkWidget *self, void *data) |
---|
777 | { |
---|
778 | //cout << "void RGPReferencesWindow::cbMoveColumnUp()" << endl; |
---|
779 | RGPreferencesWindow *me = (RGPreferencesWindow*)data; |
---|
780 | |
---|
781 | GtkTreeIter iter, next; |
---|
782 | GtkTreePath *first = gtk_tree_path_new_first(); |
---|
783 | |
---|
784 | GtkTreeSelection* selection; |
---|
785 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(me->_treeView)); |
---|
786 | if(!gtk_tree_selection_get_selected (selection, NULL, |
---|
787 | &iter)) { |
---|
788 | return; |
---|
789 | } |
---|
790 | next = iter; |
---|
791 | GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(me->_listColumns), &iter); |
---|
792 | gtk_tree_path_prev(path); |
---|
793 | gtk_tree_model_get_iter(GTK_TREE_MODEL(me->_listColumns), &next, path); |
---|
794 | |
---|
795 | if(gtk_tree_path_compare(path, first) == 0) |
---|
796 | gtk_list_store_move_after(me->_listColumns, &iter, NULL); |
---|
797 | else |
---|
798 | gtk_list_store_move_before(me->_listColumns, &iter, &next); |
---|
799 | |
---|
800 | } |
---|
801 | |
---|
802 | void RGPreferencesWindow::cbMoveColumnDown(GtkWidget *self, void *data) |
---|
803 | { |
---|
804 | //cout << "void RGPReferencesW2indow::cbMoveColumnDown()" << endl; |
---|
805 | RGPreferencesWindow *me = (RGPreferencesWindow*)data; |
---|
806 | |
---|
807 | GtkTreeIter iter, next; |
---|
808 | |
---|
809 | GtkTreeSelection* selection; |
---|
810 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(me->_treeView)); |
---|
811 | if(!gtk_tree_selection_get_selected (selection, NULL, |
---|
812 | &iter)) { |
---|
813 | return; |
---|
814 | } |
---|
815 | next = iter; |
---|
816 | if(!gtk_tree_model_iter_next(GTK_TREE_MODEL(me->_listColumns), &next)) |
---|
817 | return; |
---|
818 | gtk_list_store_move_after(me->_listColumns, &iter, &next); |
---|
819 | } |
---|
820 | |
---|
821 | void RGPreferencesWindow::cbToggleColumn(GtkWidget *self, char*path_string, |
---|
822 | void *data) |
---|
823 | { |
---|
824 | //cout << "void RGPReferencesWindow::cbToggle()" << endl; |
---|
825 | RGPreferencesWindow *me = (RGPreferencesWindow*)data; |
---|
826 | GtkTreeIter iter; |
---|
827 | gboolean res; |
---|
828 | |
---|
829 | GtkTreeModel *model = (GtkTreeModel*)me->_listColumns; |
---|
830 | GtkTreePath* path = gtk_tree_path_new_from_string(path_string); |
---|
831 | gtk_tree_model_get_iter(model, &iter, path); |
---|
832 | gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
---|
833 | TREE_CHECKBOX_COLUMN, &res, -1); |
---|
834 | gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
---|
835 | TREE_CHECKBOX_COLUMN, !res, |
---|
836 | -1); |
---|
837 | |
---|
838 | } |
---|
839 | |
---|
840 | |
---|
841 | void RGPreferencesWindow::colorClicked(GtkWidget *self, void *data) |
---|
842 | { |
---|
843 | GtkWidget *color_dialog; |
---|
844 | GtkWidget *color_selection; |
---|
845 | RGPreferencesWindow *me; |
---|
846 | me = (RGPreferencesWindow *) g_object_get_data(G_OBJECT(self), "me"); |
---|
847 | |
---|
848 | color_dialog = gtk_color_selection_dialog_new(_("Color selection")); |
---|
849 | color_selection = GTK_COLOR_SELECTION_DIALOG(color_dialog)->colorsel; |
---|
850 | |
---|
851 | GdkColor *color = NULL; |
---|
852 | color = RGPackageStatus::pkgStatus.getColor(GPOINTER_TO_INT(data)); |
---|
853 | if (color != NULL) |
---|
854 | gtk_color_selection_set_current_color(GTK_COLOR_SELECTION |
---|
855 | (color_selection), color); |
---|
856 | |
---|
857 | if (gtk_dialog_run(GTK_DIALOG(color_dialog)) == GTK_RESPONSE_OK) { |
---|
858 | GdkColor current_color; |
---|
859 | gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(color_selection), ¤t_color); |
---|
860 | RGPackageStatus::pkgStatus.setColor(GPOINTER_TO_INT(data), |
---|
861 | gdk_color_copy(¤t_color)); |
---|
862 | me->readColors(); |
---|
863 | } |
---|
864 | gtk_widget_destroy(color_dialog); |
---|
865 | } |
---|
866 | |
---|
867 | void RGPreferencesWindow::useProxyToggled(GtkWidget *self, void *data) |
---|
868 | { |
---|
869 | //cout << "void RGPreferencesWindow::useProxyToggled() " << endl; |
---|
870 | bool useProxy; |
---|
871 | |
---|
872 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
873 | useProxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(me->_useProxy)); |
---|
874 | gtk_widget_set_sensitive(glade_xml_get_widget(me->_gladeXML, "table_proxy"), |
---|
875 | useProxy); |
---|
876 | } |
---|
877 | |
---|
878 | void RGPreferencesWindow::checkbuttonUserFontToggled(GtkWidget *self, |
---|
879 | void *data) |
---|
880 | { |
---|
881 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
882 | |
---|
883 | GtkWidget *button = |
---|
884 | glade_xml_get_widget(me->_gladeXML, "button_default_font"); |
---|
885 | GtkWidget *check = |
---|
886 | glade_xml_get_widget(me->_gladeXML, "checkbutton_user_font"); |
---|
887 | gtk_widget_set_sensitive(button, |
---|
888 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON |
---|
889 | (check))); |
---|
890 | } |
---|
891 | |
---|
892 | void RGPreferencesWindow::checkbuttonUserTerminalFontToggled(GtkWidget *self, |
---|
893 | void *data) |
---|
894 | { |
---|
895 | RGPreferencesWindow *me = (RGPreferencesWindow *) data; |
---|
896 | |
---|
897 | GtkWidget *button = |
---|
898 | glade_xml_get_widget(me->_gladeXML, "button_terminal_font"); |
---|
899 | GtkWidget *check = |
---|
900 | glade_xml_get_widget(me->_gladeXML, "checkbutton_user_terminal_font"); |
---|
901 | gtk_widget_set_sensitive(button, |
---|
902 | gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON |
---|
903 | (check))); |
---|
904 | } |
---|
905 | |
---|
906 | |
---|
907 | |
---|
908 | RGPreferencesWindow::RGPreferencesWindow(RGWindow *win, |
---|
909 | RPackageLister *lister) |
---|
910 | : RGGladeWindow(win, "preferences"), distroChanged(false) |
---|
911 | { |
---|
912 | GtkWidget *button; |
---|
913 | |
---|
914 | _optionShowAllPkgInfoInMain = glade_xml_get_widget(_gladeXML, "check_show_all_pkg_info"); |
---|
915 | _optionUseStatusColors = |
---|
916 | glade_xml_get_widget(_gladeXML, "check_use_colors"); |
---|
917 | |
---|
918 | _optionAskRelated = glade_xml_get_widget(_gladeXML, "check_ask_related"); |
---|
919 | _optionUseTerminal = glade_xml_get_widget(_gladeXML, "check_terminal"); |
---|
920 | _optionCheckRecom = glade_xml_get_widget(_gladeXML, "check_recommends"); |
---|
921 | _optionAskQuit = glade_xml_get_widget(_gladeXML, "check_ask_quit"); |
---|
922 | _optionOneClick = glade_xml_get_widget(_gladeXML, "check_oneclick"); |
---|
923 | |
---|
924 | // cache |
---|
925 | _cacheLeave = glade_xml_get_widget(_gladeXML, "radio_cache_leave"); |
---|
926 | _cacheClean = glade_xml_get_widget(_gladeXML, "radio_cache_del_after"); |
---|
927 | // history |
---|
928 | _delHistory = glade_xml_get_widget(_gladeXML, "radio_delete_history"); |
---|
929 | _keepHistory = glade_xml_get_widget(_gladeXML, "radio_keep_history"); |
---|
930 | _spinDelHistory = glade_xml_get_widget(_gladeXML, "spin_del_history"); |
---|
931 | _cacheAutoClean = |
---|
932 | glade_xml_get_widget(_gladeXML, "radio_cache_del_obsolete"); |
---|
933 | _useProxy = glade_xml_get_widget(_gladeXML, "radio_use_proxy"); |
---|
934 | _mainWin = (RGMainWindow *) win; |
---|
935 | |
---|
936 | _maxUndoE = glade_xml_get_widget(_gladeXML, "spinbutton_max_undos"); |
---|
937 | assert(_maxUndoE); |
---|
938 | |
---|
939 | _optionmenuDel = |
---|
940 | glade_xml_get_widget(_gladeXML, "optionmenu_delbutton_action"); |
---|
941 | assert(_optionmenuDel); |
---|
942 | |
---|
943 | _comboDefaultDistro = |
---|
944 | glade_xml_get_widget(_gladeXML, "combobox_default_distro"); |
---|
945 | assert(_comboDefaultDistro); |
---|
946 | GtkTooltips *tips = gtk_tooltips_new(); |
---|
947 | gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), |
---|
948 | glade_xml_get_widget(_gladeXML,"radiobutton_distro"), |
---|
949 | _("Prefer package versions from the selected " |
---|
950 | "distribution when upgrading packages. If you " |
---|
951 | "manually force a version from a different " |
---|
952 | "distribution, the package version will follow " |
---|
953 | "that distribution until it enters the default " |
---|
954 | "distribution."),""); |
---|
955 | gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), |
---|
956 | glade_xml_get_widget(_gladeXML,"radiobutton_now"), |
---|
957 | _("Never upgrade to a new version automatically. " |
---|
958 | "Be _very_ careful with this option as you will " |
---|
959 | "not get security updates automatically! " |
---|
960 | "If you manually force a version " |
---|
961 | "the package version will follow " |
---|
962 | "the choosen distribution."),""); |
---|
963 | gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), |
---|
964 | glade_xml_get_widget(_gladeXML,"radiobutton_ignore"), |
---|
965 | _("Let synaptic pick the best version for you. " |
---|
966 | "If unsure use this option. "),""); |
---|
967 | |
---|
968 | |
---|
969 | // hide the "remove with configuration" from rpm users |
---|
970 | #ifdef HAVE_RPM |
---|
971 | GtkWidget *w = glade_xml_get_widget(_gladeXML, "menuitem_purge"); |
---|
972 | gtk_widget_hide(w); |
---|
973 | int delAction = _config->FindI("Synaptic::delAction", PKG_DELETE); |
---|
974 | // purge not available |
---|
975 | if (delAction == PKG_PURGE) |
---|
976 | delAction = PKG_DELETE; |
---|
977 | gtk_widget_hide(glade_xml_get_widget(_gladeXML, |
---|
978 | "optionmenu_delbutton_action")); |
---|
979 | gtk_widget_hide(glade_xml_get_widget(_gladeXML, "label_removal")); |
---|
980 | #endif |
---|
981 | |
---|
982 | // set data for the checkbutton |
---|
983 | g_object_set_data(G_OBJECT |
---|
984 | (glade_xml_get_widget |
---|
985 | (_gladeXML, "checkbutton_user_font")), "me", this); |
---|
986 | g_object_set_data(G_OBJECT |
---|
987 | (glade_xml_get_widget |
---|
988 | (_gladeXML, "checkbutton_user_terminal_font")), "me", |
---|
989 | this); |
---|
990 | |
---|
991 | // save the lister |
---|
992 | _lister = lister; |
---|
993 | |
---|
994 | // treeview stuff |
---|
995 | _treeView = glade_xml_get_widget(_gladeXML, "treeview_columns"); |
---|
996 | GtkCellRenderer *renderer; |
---|
997 | GtkTreeViewColumn *column; |
---|
998 | renderer = gtk_cell_renderer_toggle_new (); |
---|
999 | g_object_set(renderer, "activatable", TRUE, NULL); |
---|
1000 | g_signal_connect(renderer, "toggled", |
---|
1001 | (GCallback) cbToggleColumn, this); |
---|
1002 | column = gtk_tree_view_column_new_with_attributes(_("Visible"), |
---|
1003 | renderer, |
---|
1004 | "active", TREE_CHECKBOX_COLUMN, |
---|
1005 | NULL); |
---|
1006 | gtk_tree_view_append_column (GTK_TREE_VIEW(_treeView), column); |
---|
1007 | renderer = gtk_cell_renderer_text_new (); |
---|
1008 | column = gtk_tree_view_column_new_with_attributes (_("Name"), |
---|
1009 | renderer, |
---|
1010 | "text", TREE_VISIBLE_NAME_COLUMN, |
---|
1011 | NULL); |
---|
1012 | gtk_tree_view_append_column (GTK_TREE_VIEW(_treeView), column); |
---|
1013 | |
---|
1014 | |
---|
1015 | // lots of signals :) |
---|
1016 | glade_xml_signal_connect_data(_gladeXML, "on_button_column_up_clicked", |
---|
1017 | G_CALLBACK(cbMoveColumnUp), this); |
---|
1018 | glade_xml_signal_connect_data(_gladeXML, "on_button_column_down_clicked", |
---|
1019 | G_CALLBACK(cbMoveColumnDown), this); |
---|
1020 | |
---|
1021 | glade_xml_signal_connect_data(_gladeXML, |
---|
1022 | "on_close_clicked", |
---|
1023 | G_CALLBACK(closeAction), this); |
---|
1024 | glade_xml_signal_connect_data(_gladeXML, |
---|
1025 | "on_apply_clicked", |
---|
1026 | G_CALLBACK(saveAction), this); |
---|
1027 | glade_xml_signal_connect_data(_gladeXML, |
---|
1028 | "on_ok_clicked", |
---|
1029 | G_CALLBACK(doneAction), this); |
---|
1030 | |
---|
1031 | glade_xml_signal_connect_data(_gladeXML, |
---|
1032 | "on_button_clean_cache_clicked", |
---|
1033 | G_CALLBACK(clearCacheAction), this); |
---|
1034 | |
---|
1035 | glade_xml_signal_connect_data(_gladeXML, |
---|
1036 | "on_radio_use_proxy_toggled", |
---|
1037 | G_CALLBACK(useProxyToggled), this); |
---|
1038 | |
---|
1039 | glade_xml_signal_connect_data(_gladeXML, |
---|
1040 | "on_button_default_font_clicked", |
---|
1041 | G_CALLBACK(changeFontAction), |
---|
1042 | GINT_TO_POINTER(FONT_DEFAULT)); |
---|
1043 | |
---|
1044 | glade_xml_signal_connect_data(_gladeXML, |
---|
1045 | "on_checkbutton_user_terminal_font_toggled", |
---|
1046 | G_CALLBACK |
---|
1047 | (checkbuttonUserTerminalFontToggled), this); |
---|
1048 | glade_xml_signal_connect_data(_gladeXML, "on_checkbutton_user_font_toggled", |
---|
1049 | G_CALLBACK(checkbuttonUserFontToggled), this); |
---|
1050 | |
---|
1051 | glade_xml_signal_connect_data(_gladeXML, |
---|
1052 | "on_button_terminal_font_clicked", |
---|
1053 | G_CALLBACK(changeFontAction), |
---|
1054 | GINT_TO_POINTER(FONT_TERMINAL)); |
---|
1055 | |
---|
1056 | |
---|
1057 | checkbuttonUserTerminalFontToggled(NULL, this); |
---|
1058 | checkbuttonUserFontToggled(NULL, this); |
---|
1059 | |
---|
1060 | // color stuff |
---|
1061 | char *color_button = NULL; |
---|
1062 | for (int i = 0; i < RGPackageStatus::N_STATUS_COUNT; i++) { |
---|
1063 | color_button = |
---|
1064 | g_strdup_printf("button_%s_color", |
---|
1065 | RGPackageStatus::pkgStatus. |
---|
1066 | getShortStatusString(RGPackageStatus::PkgStatus(i))); |
---|
1067 | button = glade_xml_get_widget(_gladeXML, color_button); |
---|
1068 | assert(button); |
---|
1069 | g_object_set_data(G_OBJECT(button), "me", this); |
---|
1070 | g_signal_connect(G_OBJECT(button), "clicked", |
---|
1071 | G_CALLBACK(colorClicked), GINT_TO_POINTER(i)); |
---|
1072 | g_free(color_button); |
---|
1073 | } |
---|
1074 | |
---|
1075 | skipTaskbar(true); |
---|
1076 | setTitle(_("Preferences")); |
---|
1077 | } |
---|
1078 | |
---|
1079 | // vim:ts=3:sw=3:et |
---|