diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig.py | 273 |
1 files changed, 203 insertions, 70 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 721d145a6a..1bc155d008 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py | |||
@@ -172,6 +172,45 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
172 | hbox.show_all() | 172 | hbox.show_all() |
173 | return hbox, entry | 173 | return hbox, entry |
174 | 174 | ||
175 | def details_cb(self, button, parent, protocol): | ||
176 | dialog = ProxyDetailsDialog(title = protocol.upper() + " Proxy Details", | ||
177 | user = self.configuration.proxies[protocol][1], | ||
178 | passwd = self.configuration.proxies[protocol][2], | ||
179 | parent = parent, | ||
180 | flags = gtk.DIALOG_MODAL | ||
181 | | gtk.DIALOG_DESTROY_WITH_PARENT | ||
182 | | gtk.DIALOG_NO_SEPARATOR) | ||
183 | dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_OK) | ||
184 | response = dialog.run() | ||
185 | if response == gtk.RESPONSE_OK: | ||
186 | self.configuration.proxies[protocol][1] = dialog.user | ||
187 | self.configuration.proxies[protocol][2] = dialog.passwd | ||
188 | self.refresh_proxy_components() | ||
189 | dialog.destroy() | ||
190 | |||
191 | def gen_proxy_entry_widget(self, protocol, parent, need_button=True): | ||
192 | hbox = gtk.HBox(False, 12) | ||
193 | |||
194 | label = gtk.Label(protocol.upper() + " proxy") | ||
195 | hbox.pack_start(label, expand=True, fill=False, padding=24) | ||
196 | |||
197 | proxy_entry = gtk.Entry() | ||
198 | proxy_entry.set_size_request(300, -1) | ||
199 | hbox.pack_start(proxy_entry, expand=False, fill=False) | ||
200 | |||
201 | hbox.pack_start(gtk.Label(":"), expand=False, fill=False) | ||
202 | |||
203 | port_entry = gtk.Entry() | ||
204 | port_entry.set_size_request(60, -1) | ||
205 | hbox.pack_start(port_entry, expand=False, fill=False) | ||
206 | |||
207 | details_button = HobAltButton("Details") | ||
208 | details_button.connect("clicked", self.details_cb, parent, protocol) | ||
209 | hbox.pack_start(details_button, expand=False, fill=False) | ||
210 | |||
211 | hbox.show_all() | ||
212 | return hbox, proxy_entry, port_entry, details_button | ||
213 | |||
175 | def rootfs_combo_changed_cb(self, rootfs_combo, all_package_format, check_hbox): | 214 | def rootfs_combo_changed_cb(self, rootfs_combo, all_package_format, check_hbox): |
176 | combo_item = self.rootfs_combo.get_active_text() | 215 | combo_item = self.rootfs_combo.get_active_text() |
177 | for child in check_hbox.get_children(): | 216 | for child in check_hbox.get_children(): |
@@ -309,7 +348,7 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
309 | 348 | ||
310 | def __init__(self, title, configuration, all_image_types, | 349 | def __init__(self, title, configuration, all_image_types, |
311 | all_package_formats, all_distros, all_sdk_machines, | 350 | all_package_formats, all_distros, all_sdk_machines, |
312 | max_threads, enable_proxy, parent, flags, buttons=None): | 351 | max_threads, parent, flags, buttons=None): |
313 | super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) | 352 | super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) |
314 | 353 | ||
315 | # class members from other objects | 354 | # class members from other objects |
@@ -320,7 +359,6 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
320 | self.all_distros = all_distros | 359 | self.all_distros = all_distros |
321 | self.all_sdk_machines = all_sdk_machines | 360 | self.all_sdk_machines = all_sdk_machines |
322 | self.max_threads = max_threads | 361 | self.max_threads = max_threads |
323 | self.enable_proxy = enable_proxy | ||
324 | 362 | ||
325 | # class members for internal use | 363 | # class members for internal use |
326 | self.distro_combo = None | 364 | self.distro_combo = None |
@@ -356,15 +394,10 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
356 | data += ("SDK_MACHINE: " + self._get_sorted_value(self.configuration.curr_sdk_machine)) | 394 | data += ("SDK_MACHINE: " + self._get_sorted_value(self.configuration.curr_sdk_machine)) |
357 | data += ("TOOLCHAIN_BUILD: " + self._get_sorted_value(self.configuration.toolchain_build)) | 395 | data += ("TOOLCHAIN_BUILD: " + self._get_sorted_value(self.configuration.toolchain_build)) |
358 | data += ("IMAGE_FSTYPES: " + self._get_sorted_value(self.configuration.image_fstypes)) | 396 | data += ("IMAGE_FSTYPES: " + self._get_sorted_value(self.configuration.image_fstypes)) |
359 | if self.enable_proxy: | 397 | data += ("ENABLE_PROXY: " + self._get_sorted_value(self.configuration.enable_proxy)) |
360 | data += ("ALL_PROXY: " + self._get_sorted_value(self.configuration.all_proxy)) | 398 | if self.configuration.enable_proxy: |
361 | data += ("HTTP_PROXY: " + self._get_sorted_value(self.configuration.http_proxy)) | 399 | for protocol in self.configuration.proxies.keys(): |
362 | data += ("HTTPS_PROXY: " + self._get_sorted_value(self.configuration.https_proxy)) | 400 | data += (protocol + ": " + self._get_sorted_value(self.configuration.combine_proxy(protocol))) |
363 | data += ("FTP_PROXY: " + self._get_sorted_value(self.configuration.ftp_proxy)) | ||
364 | data += ("GIT_PROXY_HOST: " + self._get_sorted_value(self.configuration.git_proxy_host)) | ||
365 | data += ("GIT_PROXY_PORT: " + self._get_sorted_value(self.configuration.git_proxy_port)) | ||
366 | data += ("CVS_PROXY_HOST: " + self._get_sorted_value(self.configuration.cvs_proxy_host)) | ||
367 | data += ("CVS_PROXY_PORT: " + self._get_sorted_value(self.configuration.cvs_proxy_port)) | ||
368 | for key in self.configuration.extra_setting.keys(): | 401 | for key in self.configuration.extra_setting.keys(): |
369 | data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) | 402 | data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) |
370 | return hashlib.md5(data).hexdigest() | 403 | return hashlib.md5(data).hexdigest() |
@@ -529,60 +562,56 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
529 | 562 | ||
530 | sub_vbox = gtk.VBox(False, 6) | 563 | sub_vbox = gtk.VBox(False, 6) |
531 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) | 564 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) |
532 | self.proxy_checkbox = gtk.CheckButton("Enable proxy") | 565 | label = self.gen_label_widget("<span weight=\"bold\">Set the proxies that will be used during fetching source code</span>") |
566 | tooltip = "Set the proxies that will be used during fetching source code or set none for direct the Internet connection" | ||
567 | info = HobInfoButton(tooltip, self) | ||
568 | hbox = gtk.HBox(False, 12) | ||
569 | hbox.pack_start(label, expand=True, fill=True) | ||
570 | hbox.pack_start(info, expand=False, fill=False) | ||
571 | sub_vbox.pack_start(hbox, expand=False, fill=False) | ||
572 | |||
573 | self.direct_checkbox = gtk.RadioButton(None, "Direct internet connection") | ||
574 | self.direct_checkbox.set_tooltip_text("Check this box to connect the Internet directly without any proxy") | ||
575 | self.direct_checkbox.set_active(not self.configuration.enable_proxy) | ||
576 | sub_vbox.pack_start(self.direct_checkbox, expand=False, fill=False) | ||
577 | |||
578 | self.proxy_checkbox = gtk.RadioButton(self.direct_checkbox, "Manual proxy configuration") | ||
533 | self.proxy_checkbox.set_tooltip_text("Check this box to setup the proxy you specified") | 579 | self.proxy_checkbox.set_tooltip_text("Check this box to setup the proxy you specified") |
534 | self.proxy_checkbox.set_active(self.enable_proxy) | 580 | self.proxy_checkbox.set_active(self.configuration.enable_proxy) |
535 | self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) | ||
536 | sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) | 581 | sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) |
537 | 582 | ||
538 | label = self.gen_label_widget("<span weight=\"bold\">Set all proxy:</span>") | 583 | self.same_checkbox = gtk.CheckButton("Use the same proxy for all protocols") |
539 | tooltip = "Set the all proxy that will be used if the proxy for a URL isn't specified." | 584 | self.same_checkbox.set_tooltip_text("Use the same proxy as the first proxy i.e. http proxy for all protocols") |
540 | proxy_widget, self.all_proxy_text = self.gen_entry_widget(self.configuration.all_proxy, self, tooltip, False) | 585 | self.same_checkbox.set_active(self.configuration.same_proxy) |
541 | self.all_proxy_text.set_editable(self.enable_proxy) | 586 | hbox = gtk.HBox(False, 12) |
542 | self.all_proxy_text.set_sensitive(self.enable_proxy) | 587 | hbox.pack_start(self.same_checkbox, expand=False, fill=False, padding=24) |
543 | sub_vbox.pack_start(label, expand=False, fill=False) | 588 | sub_vbox.pack_start(hbox, expand=False, fill=False) |
544 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
545 | 589 | ||
546 | label = self.gen_label_widget("<span weight=\"bold\">Set http proxy:</span>") | 590 | proxy_widget, self.http_proxy, self.http_proxy_port, self.http_proxy_details = self.gen_proxy_entry_widget( |
547 | tooltip = "Set the http proxy that will be used in do_fetch() source code" | 591 | "http", self, True) |
548 | proxy_widget, self.http_proxy_text = self.gen_entry_widget(self.configuration.http_proxy, self, tooltip, False) | ||
549 | self.http_proxy_text.set_editable(self.enable_proxy) | ||
550 | self.http_proxy_text.set_sensitive(self.enable_proxy) | ||
551 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
552 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 592 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) |
553 | 593 | ||
554 | label = self.gen_label_widget("<span weight=\"bold\">Set https proxy:</span>") | 594 | proxy_widget, self.https_proxy, self.https_proxy_port, self.https_proxy_details = self.gen_proxy_entry_widget( |
555 | tooltip = "Set the https proxy that will be used in do_fetch() source code" | 595 | "https", self, True) |
556 | proxy_widget, self.https_proxy_text = self.gen_entry_widget(self.configuration.https_proxy, self, tooltip, False) | ||
557 | self.https_proxy_text.set_editable(self.enable_proxy) | ||
558 | self.https_proxy_text.set_sensitive(self.enable_proxy) | ||
559 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
560 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 596 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) |
561 | 597 | ||
562 | label = self.gen_label_widget("<span weight=\"bold\">Set ftp proxy:</span>") | 598 | proxy_widget, self.ftp_proxy, self.ftp_proxy_port, self.ftp_proxy_details = self.gen_proxy_entry_widget( |
563 | tooltip = "Set the ftp proxy that will be used in do_fetch() source code" | 599 | "ftp", self, True) |
564 | proxy_widget, self.ftp_proxy_text = self.gen_entry_widget(self.configuration.ftp_proxy, self, tooltip, False) | ||
565 | self.ftp_proxy_text.set_editable(self.enable_proxy) | ||
566 | self.ftp_proxy_text.set_sensitive(self.enable_proxy) | ||
567 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
568 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 600 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) |
569 | 601 | ||
570 | label = self.gen_label_widget("<span weight=\"bold\">Set git proxy:</span>") | 602 | proxy_widget, self.git_proxy, self.git_proxy_port, self.git_proxy_details = self.gen_proxy_entry_widget( |
571 | tooltip = "Set the git proxy that will be used in do_fetch() source code" | 603 | "git", self, True) |
572 | proxy_widget, self.git_proxy_text = self.gen_entry_widget(self.configuration.git_proxy_host + ':' + self.configuration.git_proxy_port, self, tooltip, False) | ||
573 | self.git_proxy_text.set_editable(self.enable_proxy) | ||
574 | self.git_proxy_text.set_sensitive(self.enable_proxy) | ||
575 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
576 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 604 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) |
577 | 605 | ||
578 | label = self.gen_label_widget("<span weight=\"bold\">Set cvs proxy:</span>") | 606 | proxy_widget, self.cvs_proxy, self.cvs_proxy_port, self.cvs_proxy_details = self.gen_proxy_entry_widget( |
579 | tooltip = "Set the cvs proxy that will be used in do_fetch() source code" | 607 | "cvs", self, True) |
580 | proxy_widget, self.cvs_proxy_text = self.gen_entry_widget(self.configuration.cvs_proxy_host + ':' + self.configuration.cvs_proxy_port, self, tooltip, False) | ||
581 | self.cvs_proxy_text.set_editable(self.enable_proxy) | ||
582 | self.cvs_proxy_text.set_sensitive(self.enable_proxy) | ||
583 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
584 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 608 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) |
585 | 609 | ||
610 | self.direct_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) | ||
611 | self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) | ||
612 | self.same_checkbox.connect("toggled", self.same_checkbox_toggled_cb) | ||
613 | |||
614 | self.refresh_proxy_components() | ||
586 | return advanced_vbox | 615 | return advanced_vbox |
587 | 616 | ||
588 | def create_others_page(self): | 617 | def create_others_page(self): |
@@ -599,20 +628,59 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
599 | 628 | ||
600 | return advanced_vbox | 629 | return advanced_vbox |
601 | 630 | ||
631 | def refresh_proxy_components(self): | ||
632 | self.same_checkbox.set_sensitive(self.configuration.enable_proxy) | ||
633 | |||
634 | self.http_proxy.set_text(self.configuration.combine_host_only("http")) | ||
635 | self.http_proxy.set_editable(self.configuration.enable_proxy) | ||
636 | self.http_proxy.set_sensitive(self.configuration.enable_proxy) | ||
637 | self.http_proxy_port.set_text(self.configuration.combine_port_only("http")) | ||
638 | self.http_proxy_port.set_editable(self.configuration.enable_proxy) | ||
639 | self.http_proxy_port.set_sensitive(self.configuration.enable_proxy) | ||
640 | self.http_proxy_details.set_sensitive(self.configuration.enable_proxy) | ||
641 | |||
642 | self.https_proxy.set_text(self.configuration.combine_host_only("https")) | ||
643 | self.https_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
644 | self.https_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
645 | self.https_proxy_port.set_text(self.configuration.combine_port_only("https")) | ||
646 | self.https_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
647 | self.https_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
648 | self.https_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
649 | |||
650 | self.ftp_proxy.set_text(self.configuration.combine_host_only("ftp")) | ||
651 | self.ftp_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
652 | self.ftp_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
653 | self.ftp_proxy_port.set_text(self.configuration.combine_port_only("ftp")) | ||
654 | self.ftp_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
655 | self.ftp_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
656 | self.ftp_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
657 | |||
658 | self.git_proxy.set_text(self.configuration.combine_host_only("git")) | ||
659 | self.git_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
660 | self.git_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
661 | self.git_proxy_port.set_text(self.configuration.combine_port_only("git")) | ||
662 | self.git_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
663 | self.git_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
664 | self.git_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
665 | |||
666 | self.cvs_proxy.set_text(self.configuration.combine_host_only("cvs")) | ||
667 | self.cvs_proxy.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
668 | self.cvs_proxy.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
669 | self.cvs_proxy_port.set_text(self.configuration.combine_port_only("cvs")) | ||
670 | self.cvs_proxy_port.set_editable(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
671 | self.cvs_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
672 | self.cvs_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | ||
673 | |||
602 | def proxy_checkbox_toggled_cb(self, button): | 674 | def proxy_checkbox_toggled_cb(self, button): |
603 | self.enable_proxy = self.proxy_checkbox.get_active() | 675 | self.configuration.enable_proxy = self.proxy_checkbox.get_active() |
604 | self.all_proxy_text.set_editable(self.enable_proxy) | 676 | if not self.configuration.enable_proxy: |
605 | self.all_proxy_text.set_sensitive(self.enable_proxy) | 677 | self.configuration.same_proxy = False |
606 | self.http_proxy_text.set_editable(self.enable_proxy) | 678 | self.same_checkbox.set_active(self.configuration.same_proxy) |
607 | self.http_proxy_text.set_sensitive(self.enable_proxy) | 679 | self.refresh_proxy_components() |
608 | self.https_proxy_text.set_editable(self.enable_proxy) | 680 | |
609 | self.https_proxy_text.set_sensitive(self.enable_proxy) | 681 | def same_checkbox_toggled_cb(self, button): |
610 | self.ftp_proxy_text.set_editable(self.enable_proxy) | 682 | self.configuration.same_proxy = self.same_checkbox.get_active() |
611 | self.ftp_proxy_text.set_sensitive(self.enable_proxy) | 683 | self.refresh_proxy_components() |
612 | self.git_proxy_text.set_editable(self.enable_proxy) | ||
613 | self.git_proxy_text.set_sensitive(self.enable_proxy) | ||
614 | self.cvs_proxy_text.set_editable(self.enable_proxy) | ||
615 | self.cvs_proxy_text.set_sensitive(self.enable_proxy) | ||
616 | 684 | ||
617 | def response_cb(self, dialog, response_id): | 685 | def response_cb(self, dialog, response_id): |
618 | package_format = [] | 686 | package_format = [] |
@@ -656,12 +724,17 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
656 | self.configuration.extra_setting[key] = value | 724 | self.configuration.extra_setting[key] = value |
657 | it = self.setting_store.iter_next(it) | 725 | it = self.setting_store.iter_next(it) |
658 | 726 | ||
659 | self.configuration.all_proxy = self.all_proxy_text.get_text() | 727 | self.configuration.split_proxy("http", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) |
660 | self.configuration.http_proxy = self.http_proxy_text.get_text() | 728 | if self.configuration.same_proxy: |
661 | self.configuration.https_proxy = self.https_proxy_text.get_text() | 729 | self.configuration.split_proxy("https", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) |
662 | self.configuration.ftp_proxy = self.ftp_proxy_text.get_text() | 730 | self.configuration.split_proxy("ftp", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) |
663 | self.configuration.git_proxy_host, self.configuration.git_proxy_port = self.git_proxy_text.get_text().split(':') | 731 | self.configuration.split_proxy("git", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) |
664 | self.configuration.cvs_proxy_host, self.configuration.cvs_proxy_port = self.cvs_proxy_text.get_text().split(':') | 732 | self.configuration.split_proxy("cvs", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) |
733 | else: | ||
734 | self.configuration.split_proxy("https", self.https_proxy.get_text() + ":" + self.https_proxy_port.get_text()) | ||
735 | self.configuration.split_proxy("ftp", self.ftp_proxy.get_text() + ":" + self.ftp_proxy_port.get_text()) | ||
736 | self.configuration.split_proxy("git", self.git_proxy.get_text() + ":" + self.git_proxy_port.get_text()) | ||
737 | self.configuration.split_proxy("cvs", self.cvs_proxy.get_text() + ":" + self.cvs_proxy_port.get_text()) | ||
665 | 738 | ||
666 | md5 = self.config_md5() | 739 | md5 = self.config_md5() |
667 | self.settings_changed = (self.md5 != md5) | 740 | self.settings_changed = (self.md5 != md5) |
@@ -1150,3 +1223,63 @@ class ImageSelectionDialog (CrumbsDialog): | |||
1150 | self.image_names.append(f) | 1223 | self.image_names.append(f) |
1151 | break | 1224 | break |
1152 | iter = self.image_store.iter_next(iter) | 1225 | iter = self.image_store.iter_next(iter) |
1226 | |||
1227 | class ProxyDetailsDialog (CrumbsDialog): | ||
1228 | |||
1229 | def __init__(self, title, user, passwd, parent, flags, buttons=None): | ||
1230 | super(ProxyDetailsDialog, self).__init__(title, parent, flags, buttons) | ||
1231 | self.connect("response", self.response_cb) | ||
1232 | |||
1233 | self.auth = not (user == None or passwd == None or user == "") | ||
1234 | self.user = user or "" | ||
1235 | self.passwd = passwd or "" | ||
1236 | |||
1237 | # create visual elements on the dialog | ||
1238 | self.create_visual_elements() | ||
1239 | |||
1240 | def create_visual_elements(self): | ||
1241 | self.auth_checkbox = gtk.CheckButton("Use authentication") | ||
1242 | self.auth_checkbox.set_tooltip_text("Check this box to set the username and the password") | ||
1243 | self.auth_checkbox.set_active(self.auth) | ||
1244 | self.auth_checkbox.connect("toggled", self.auth_checkbox_toggled_cb) | ||
1245 | self.vbox.pack_start(self.auth_checkbox, expand=False, fill=False) | ||
1246 | |||
1247 | hbox = gtk.HBox(False, 6) | ||
1248 | self.user_label = gtk.Label("Username:") | ||
1249 | self.user_text = gtk.Entry() | ||
1250 | self.user_text.set_text(self.user) | ||
1251 | hbox.pack_start(self.user_label, expand=False, fill=False) | ||
1252 | hbox.pack_end(self.user_text, expand=False, fill=False) | ||
1253 | self.vbox.pack_start(hbox, expand=False, fill=False) | ||
1254 | |||
1255 | hbox = gtk.HBox(False, 6) | ||
1256 | self.passwd_label = gtk.Label("Password:") | ||
1257 | self.passwd_text = gtk.Entry() | ||
1258 | self.passwd_text.set_text(self.passwd) | ||
1259 | hbox.pack_start(self.passwd_label, expand=False, fill=False) | ||
1260 | hbox.pack_end(self.passwd_text, expand=False, fill=False) | ||
1261 | self.vbox.pack_start(hbox, expand=False, fill=False) | ||
1262 | |||
1263 | self.refresh_auth_components() | ||
1264 | self.show_all() | ||
1265 | |||
1266 | def refresh_auth_components(self): | ||
1267 | self.user_label.set_sensitive(self.auth) | ||
1268 | self.user_text.set_editable(self.auth) | ||
1269 | self.user_text.set_sensitive(self.auth) | ||
1270 | self.passwd_label.set_sensitive(self.auth) | ||
1271 | self.passwd_text.set_editable(self.auth) | ||
1272 | self.passwd_text.set_sensitive(self.auth) | ||
1273 | |||
1274 | def auth_checkbox_toggled_cb(self, button): | ||
1275 | self.auth = self.auth_checkbox.get_active() | ||
1276 | self.refresh_auth_components() | ||
1277 | |||
1278 | def response_cb(self, dialog, response_id): | ||
1279 | if response_id == gtk.RESPONSE_OK: | ||
1280 | if self.auth: | ||
1281 | self.user = self.user_text.get_text() | ||
1282 | self.passwd = self.passwd_text.get_text() | ||
1283 | else: | ||
1284 | self.user = None | ||
1285 | self.passwd = None | ||