=== modified file 'gtk/configscript.py' --- gtk/configscript.py 2011-10-19 10:46:03 +0000 +++ gtk/configscript.py 2011-10-19 15:38:45 +0000 @@ -28,8 +28,11 @@ import sys import os -import gtk import ConfigParser +try: + from gi.repository import Gtk as gtk +except ImportError: + import gtk from wicd import wpath from wicd.translations import _ === modified file 'gtk/gui.py' --- gtk/gui.py 2011-10-19 10:31:31 +0000 +++ gtk/gui.py 2011-10-19 16:17:13 +0000 @@ -26,12 +26,32 @@ import os import sys import time -import gobject -import pango -import gtk from itertools import chain from dbus import DBusException +try: + from gi.repository import GObject as gobject + from gi.repository import Pango as pango + from gi.repository import Gtk as gtk + from gi.repository import Gdk as gdk + pygi = True + + DIALOG_MODAL = gtk.DialogFlags.MODAL + MESSAGE_ERROR = gtk.MessageType.ERROR + BUTTONS_OK = gtk.ButtonsType.OK + RESPONSE_ACCEPT = gtk.ResponseType.ACCEPT +except ImportError: + import gobject + import pango + import gtk + from gtk import gdk as gdk + pygi = False + + DIALOG_MODAL = gtk.DIALOG_MODAL + MESSAGE_ERROR = gtk.MESSAGE_ERROR + BUTTONS_OK = gtk.BUTTONS_OK + RESPONSE_ACCEPT = gtk.RESPONSE_ACCEPT + from wicd import misc from wicd import wpath from wicd import dbusmanager @@ -95,10 +115,9 @@ wired_net_entry = WiredNetworkEntry() dialog = gtk.Dialog(title = _('Wired connection detected'), - flags = gtk.DIALOG_MODAL, + flags = DIALOG_MODAL, buttons = (gtk.STOCK_CONNECT, 1, gtk.STOCK_CANCEL, 2)) - dialog.set_has_separator(False) dialog.set_size_request(400, 150) instruct_label = gtk.Label(_('Select or create a wired profile to connect with') + ':\n') stoppopcheckbox = gtk.CheckButton(_('Stop Showing Autoconnect pop-up temporarily')) @@ -112,10 +131,10 @@ wired_net_entry.vbox_top.remove(wired_net_entry.hbox_temp) wired_net_entry.vbox_top.remove(wired_net_entry.profile_help) - dialog.vbox.pack_start(instruct_label, fill=False, expand=False) - dialog.vbox.pack_start(wired_net_entry.profile_help, False, False) - dialog.vbox.pack_start(wired_net_entry.hbox_temp, False, False) - dialog.vbox.pack_start(stoppopcheckbox, False, False) + dialog.vbox.pack_start(instruct_label, False, False, 0) + dialog.vbox.pack_start(wired_net_entry.profile_help, False, False, 0) + dialog.vbox.pack_start(wired_net_entry.hbox_temp, False, False, 0) + dialog.vbox.pack_start(stoppopcheckbox, False, False, 0) dialog.show_all() wired_profiles = wired_net_entry.combo_profile_names @@ -151,9 +170,9 @@ errmsg = "Error connecting to wicd service via D-Bus." + \ "Please ensure the wicd service is running." d = gtk.MessageDialog(parent=None, - flags=gtk.DIALOG_MODAL, - type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_OK, + flags=DIALOG_MODAL, + type=MESSAGE_ERROR, + buttons=BUTTONS_OK, message_format=errmsg) d.run() sys.exit(1) @@ -165,10 +184,16 @@ self.wTree.set_translation_domain('wicd') self.wTree.add_from_file(gladefile) self.window = self.wTree.get_object("window1") - width = int(gtk.gdk.screen_width() / 2) + if pygi: + width = int(gdk.Screen.width() / 2) + else: + width = int(gdk.screen_width() / 2) if width > 530: width = 530 - self.window.resize(width, int(gtk.gdk.screen_height() / 1.7)) + if pygi: + self.window.resize(width, int(gdk.Screen.height() / 1.7)) + else: + self.window.resize(width, int(gdk.screen_height() / 1.7)) dic = { "refresh_clicked" : self.refresh_clicked, "quit_clicked" : self.exit, @@ -193,17 +218,21 @@ self.rfkill_button = self.wTree.get_object("rfkill_button") self.all_network_list = self.wTree.get_object("network_list_vbox") self.all_network_list.show_all() - self.wired_network_box = gtk.VBox(False, 0) + self.wired_network_box = gtk.VBox() + self.wired_network_box.set_homogeneous(False) + self.wired_network_box.set_spacing(0) self.wired_network_box.show_all() - self.network_list = gtk.VBox(False, 0) - self.all_network_list.pack_start(self.wired_network_box, False, False) - self.all_network_list.pack_start(self.network_list, True, True) + self.network_list = gtk.VBox() + self.network_list.set_homogeneous(False) + self.network_list.set_spacing(0) + self.all_network_list.pack_start(self.wired_network_box, False, False, 0) + self.all_network_list.pack_start(self.network_list, True, True, 0) self.network_list.show_all() self.status_area = self.wTree.get_object("connecting_hbox") self.status_bar = self.wTree.get_object("statusbar") menu = self.wTree.get_object("menu1") - self.status_area.hide_all() + self.status_area.hide() if os.path.exists(os.path.join(wpath.images, "wicd.png")): self.window.set_icon_from_file(os.path.join(wpath.images, "wicd.png")) @@ -221,7 +250,7 @@ self._wired_showing = False self.network_list.set_sensitive(False) label = gtk.Label("%s..." % _('Scanning')) - self.network_list.pack_start(label) + self.network_list.pack_start(label, True, True, 0) label.show() self.wait_for_events(0.2) self.window.connect('delete_event', self.exit) @@ -256,9 +285,8 @@ """ Shows a dialog that creates a new adhoc network. """ print "Starting the Ad-Hoc Network Creation Process..." dialog = gtk.Dialog(title = _('Create an Ad-Hoc Network'), - flags = gtk.DIALOG_MODAL, + flags = DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL, 2, gtk.STOCK_OK, 1)) - dialog.set_has_separator(False) dialog.set_size_request(400, -1) self.chkbox_use_encryption = gtk.CheckButton(_('Use Encryption (WEP only)')) self.chkbox_use_encryption.set_active(False) @@ -277,16 +305,20 @@ essid_entry.entry.set_text('My_Adhoc_Network') ip_entry.entry.set_text('169.254.12.10') # Just a random IP - vbox_ah = gtk.VBox(False, 0) - self.wired_network_box = gtk.VBox(False, 0) - vbox_ah.pack_start(self.chkbox_use_encryption, False, False) - vbox_ah.pack_start(self.key_entry, False, False) + vbox_ah = gtk.VBox() + vbox_ah.set_homogeneous(False) + vbox_ah.set_spacing(0) + self.wired_network_box = gtk.VBox() + self.wired_network_box.set_homogeneous(False) + self.wired_network_box.set_spacing(0) + vbox_ah.pack_start(self.chkbox_use_encryption, False, False, 0) + vbox_ah.pack_start(self.key_entry, False, False, 0) vbox_ah.show() - dialog.vbox.pack_start(essid_entry) - dialog.vbox.pack_start(ip_entry) - dialog.vbox.pack_start(channel_entry) - dialog.vbox.pack_start(chkbox_use_ics) - dialog.vbox.pack_start(vbox_ah) + dialog.vbox.pack_start(essid_entry, True, True, 0) + dialog.vbox.pack_start(ip_entry, True, True, 0) + dialog.vbox.pack_start(channel_entry, True, True, 0) + dialog.vbox.pack_start(chkbox_use_ics, True, True, 0) + dialog.vbox.pack_start(vbox_ah, True, True, 0) dialog.vbox.set_spacing(5) dialog.show_all() response = dialog.run() @@ -334,9 +366,14 @@ def key_event (self, widget, event=None): """ Handle key-release-events. """ - if event.state & gtk.gdk.CONTROL_MASK and \ - gtk.gdk.keyval_name(event.keyval) in ["w", "q"]: - self.exit() + if pygi: + if event.get_state() & gdk.EventMask.CONTROL_MASK and \ + Gdk.keyval_name(event.keyval) in ["w", "q"]: + self.exit() + else: + if event.state & gdk.CONTROL_MASK and \ + gdk.keyval_name(event.keyval) in ["w", "q"]: + self.exit() def settings_dialog(self, widget, event=None): """ Displays a general settings dialog. """ @@ -351,13 +388,12 @@ def connect_hidden(self, widget): """ Prompts the user for a hidden network, then scans for it. """ dialog = gtk.Dialog(title=('Hidden Network'), - flags=gtk.DIALOG_MODAL, + flags=DIALOG_MODAL, buttons=(gtk.STOCK_CONNECT, 1, gtk.STOCK_CANCEL, 2)) - dialog.set_has_separator(False) lbl = gtk.Label(_('Hidden Network ESSID')) textbox = gtk.Entry() - dialog.vbox.pack_start(lbl) - dialog.vbox.pack_start(textbox) + dialog.vbox.pack_start(lbl, True, True, 0) + dialog.vbox.pack_start(textbox, True, True, 0) dialog.show_all() button = dialog.run() if button == 1: @@ -526,12 +562,12 @@ self._remove_items_from_vbox(self.wired_network_box) self._remove_items_from_vbox(self.network_list) label = gtk.Label("%s..." % _('Scanning')) - self.network_list.pack_start(label) + self.network_list.pack_start(label, True, True, 0) self.network_list.show_all() if wired.CheckPluggedIn() or daemon.GetAlwaysShowWiredInterface(): printLine = True # In this case we print a separator. wirednet = WiredNetworkEntry() - self.wired_network_box.pack_start(wirednet, False, False) + self.wired_network_box.pack_start(wirednet, False, False, 0) wirednet.connect_button.connect("clicked", self.connect, "wired", 0, wirednet) wirednet.disconnect_button.connect("clicked", self.disconnect, @@ -579,13 +615,12 @@ if skip_never_connect and misc.to_bool(get_wireless_prop(x,'never')): continue if printLine: sep = gtk.HSeparator() - self.network_list.pack_start(sep, padding=10, fill=False, - expand=False) + self.network_list.pack_start(sep, False, False, 10) sep.show() else: printLine = True tempnet = WirelessNetworkEntry(x) - self.network_list.pack_start(tempnet, False, False) + self.network_list.pack_start(tempnet, False, False, 0) tempnet.connect_button.connect("clicked", self.connect, "wireless", x, tempnet) @@ -601,7 +636,7 @@ label = gtk.Label(_('Wireless Kill Switch Enabled') + ".") else: label = gtk.Label(_('No wireless networks found.')) - self.network_list.pack_start(label) + self.network_list.pack_start(label, True, True, 0) label.show() self.update_connect_buttons(force_check=True) self.network_list.set_sensitive(True) @@ -675,7 +710,7 @@ """ result = dialog.run() - if result == gtk.RESPONSE_ACCEPT: + if result == RESPONSE_ACCEPT: if self.save_settings(nettype, networkid, networkentry): return True else: === modified file 'gtk/guiutil.py' --- gtk/guiutil.py 2011-09-15 10:50:21 +0000 +++ gtk/guiutil.py 2011-10-19 16:18:01 +0000 @@ -16,21 +16,43 @@ # along with this program. If not, see . # -import gtk import os.path import wicd.wpath as wpath +try: + from gi.repository import Gtk as gtk + pygi = True + + DIALOG_MODAL = gtk.DialogFlags.MODAL + MESSAGE_ERROR = gtk.MessageType.ERROR + MESSAGE_QUESTION = gtk.MessageType.QUESTION + BUTTONS_OK = gtk.ButtonsType.OK + BUTTONS_OK_CANCEL = gtk.ButtonsType.OK_CANCEL + RESPONSE_OK = gtk.ResponseType.OK +except ImportError: + import gtk + pygi = False + + DIALOG_MODAL = gtk.DIALOG_MODAL + MESSAGE_ERROR = gtk.MESSAGE_ERROR + MESSAGE_QUESTION = gtk.MESSAGE_QUESTION + BUTTONS_OK = gtk.BUTTONS_OK + BUTTONS_OK_CANCEL = gtk.BUTTONS_OK_CANCEL + RESPONSE_OK = gtk.RESPONSE_OK + HAS_NOTIFY = True try: - import pynotify + if pygi: + from gi.repository import Notify as pynotify + else: + import pynotify if not pynotify.init("Wicd"): print 'Could not initalize pynotify' HAS_NOTIFY = False except ImportError: - print "Importing pynotify failed, notifications disabled." HAS_NOTIFY = False - + print "Has notifications support", HAS_NOTIFY if wpath.no_use_notifications: @@ -50,8 +72,8 @@ notification = pynotify.Notification("ERROR", message, "error") notification.show() return - dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, - gtk.BUTTONS_OK) + dialog = gtk.MessageDialog(parent, DIALOG_MODAL, MESSAGE_ERROR, + BUTTONS_OK) dialog.set_markup(message) if not block: dialog.present() @@ -64,8 +86,8 @@ """ Shows an warning dialog. """ def delete_event(dialog, id): dialog.destroy() - dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, - gtk.BUTTONS_OK) + dialog = gtk.MessageDialog(parent, DIALOG_MODAL, MESSAGE_WARNING, + BUTTONS_OK) dialog.set_markup(message) if not block: dialog.present() @@ -83,9 +105,9 @@ dialog = gtk.MessageDialog( None, - gtk.DIALOG_MODAL, - gtk.MESSAGE_QUESTION, - gtk.BUTTONS_OK_CANCEL, + DIALOG_MODAL, + MESSAGE_QUESTION, + BUTTONS_OK_CANCEL, None) # set the text @@ -95,18 +117,18 @@ entry = gtk.Entry() # allow the user to press enter instead of clicking OK - entry.connect("activate", dialog_response, dialog, gtk.RESPONSE_OK) + entry.connect("activate", dialog_response, dialog, RESPONSE_OK) # create an hbox and pack the label and entry in hbox = gtk.HBox() - hbox.pack_start(gtk.Label(textbox_label), False, 4, 4) - hbox.pack_start(entry) + hbox.pack_start(gtk.Label(textbox_label), False, True, 4) + hbox.pack_start(entry, True, True, 0) # pack the boxes and show the dialog dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() - if dialog.run() == gtk.RESPONSE_OK: + if dialog.run() == RESPONSE_OK: text = entry.get_text() dialog.destroy() return text @@ -133,8 +155,8 @@ self.label = LeftAlignedLabel() self.label.set_text(text) self.label.set_size_request(170, -1) - self.pack_start(self.label, fill=True, expand=True) - self.pack_start(self.entry, fill=False, expand=False) + self.pack_start(self.label, True, True, 0) + self.pack_start(self.entry, False, False, 0) self.label.show() self.entry.show() self.entry.connect('focus-out-event', self.hide_characters) @@ -192,9 +214,9 @@ self.check.set_size_request(5, -1) self.check.set_active(False) self.check.set_focus_on_click(False) - self.pack_start(self.label, fill=True, expand=True) - self.pack_start(self.check, fill=True, expand=True) - self.pack_start(self.entry, fill=False, expand=False) + self.pack_start(self.label, True, True, 0) + self.pack_start(self.check, True, True, 0) + self.pack_start(self.entry, False, False, 0) self.label.show() self.check.show() self.entry.show() === modified file 'gtk/netentry.py' --- gtk/netentry.py 2011-10-18 21:33:23 +0000 +++ gtk/netentry.py 2011-10-19 16:24:37 +0000 @@ -23,9 +23,35 @@ # along with this program. If not, see . # -import gtk import os +try: + from gi.repository import Gtk as gtk + from gi.repository import Gdk as gdk + pygi = True + + DIALOG_MODAL = gtk.DialogFlags.MODAL + RESPONSE_REJECT = gtk.ResponseType.REJECT + RESPONSE_ACCEPT = gtk.ResponseType.ACCEPT + RESPONSE_CLOSE = gtk.ResponseType.CLOSE + POLICY_NEVER = gtk.PolicyType.NEVER + POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC + SHADOW_NONE = gtk.ShadowType.NONE + JUSTIFY_LEFT = gtk.Justification.LEFT +except ImportError: + import gtk + from gtk import gdk as gdk + pygi = False + + DIALOG_MODAL = gtk.DIALOG_MODAL + RESPONSE_REJECT = gtk.RESPONSE_REJECT + RESPONSE_ACCEPT = gtk.RESPONSE_ACCEPT + RESPONSE_CLOSE = gtk.RESPONSE_CLOSE + POLICY_NEVER = gtk.POLICY_NEVER + POLICY_AUTOMATIC = gtk.POLICY_AUTOMATIC + SHADOW_NONE = gtk.SHADOW_NONE + JUSTIFY_LEFT = gtk.JUSTIFY_LEFT + import wicd.misc as misc import wicd.wpath as wpath import wicd.dbusmanager as dbusmanager @@ -60,10 +86,10 @@ title = _('Properties') gtk.Dialog.__init__(self, title=title, - flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL, - gtk.RESPONSE_REJECT, + flags=DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL, + RESPONSE_REJECT, gtk.STOCK_OK, - gtk.RESPONSE_ACCEPT)) + RESPONSE_ACCEPT)) self.set_default_size() @@ -79,17 +105,17 @@ self.txt_dns_1 = LabelEntry(_('DNS server') + ' 1') self.txt_dns_2 = LabelEntry(_('DNS server') + ' 2') self.txt_dns_3 = LabelEntry(_('DNS server') + ' 3') - dhcp_hostname_hbox = gtk.HBox(False, 0) + dhcp_hostname_hbox = gtk.HBox() self.chkbox_use_dhcp_hostname = gtk.CheckButton() self.txt_dhcp_hostname = LabelEntry("DHCP Hostname") - dhcp_hostname_hbox.pack_start(self.chkbox_use_dhcp_hostname, fill=False, expand=False) - dhcp_hostname_hbox.pack_start(self.txt_dhcp_hostname) + dhcp_hostname_hbox.pack_start(self.chkbox_use_dhcp_hostname, False, False, 0) + dhcp_hostname_hbox.pack_start(self.txt_dhcp_hostname, True, True, 0) self.chkbox_static_ip = gtk.CheckButton(_('Use Static IPs')) self.chkbox_static_dns = gtk.CheckButton(_('Use Static DNS')) self.chkbox_global_dns = gtk.CheckButton(_('Use global DNS servers')) - self.hbox_dns = gtk.HBox(False, 0) - self.hbox_dns.pack_start(self.chkbox_static_dns) - self.hbox_dns.pack_start(self.chkbox_global_dns) + self.hbox_dns = gtk.HBox() + self.hbox_dns.pack_start(self.chkbox_static_dns, True, True, 0) + self.hbox_dns.pack_start(self.chkbox_global_dns, True, True, 0) # Set up the script settings button self.script_button = gtk.Button() @@ -100,32 +126,35 @@ self.script_button.set_image(script_image) self.script_button.set_label(_('Scripts')) - self.button_hbox = gtk.HBox(False, 2) - self.button_hbox.pack_start(self.script_button, fill=False, expand=False) + self.button_hbox = gtk.HBox() + self.button_hbox.set_spacing(2) + self.button_hbox.pack_start(self.script_button, False, False, 0) self.button_hbox.show() self.swindow = gtk.ScrolledWindow() - self.swindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + self.swindow.set_policy(POLICY_NEVER, POLICY_AUTOMATIC) self.viewport = gtk.Viewport() - self.viewport.set_shadow_type(gtk.SHADOW_NONE) + self.viewport.set_shadow_type(SHADOW_NONE) self.cvbox = gtk.VBox() self.viewport.add(self.cvbox) self.swindow.add(self.viewport) - self.vbox.pack_start(self.swindow) + if pygi: + self.vbox = self.get_children()[0] + self.vbox.pack_start(self.swindow, True, True, 0) assert(isinstance(self.cvbox, gtk.VBox)) - self.cvbox.pack_start(self.chkbox_static_ip, fill=False, expand=False) - self.cvbox.pack_start(self.txt_ip, fill=False, expand=False) - self.cvbox.pack_start(self.txt_netmask, fill=False, expand=False) - self.cvbox.pack_start(self.txt_gateway, fill=False, expand=False) - self.cvbox.pack_start(self.hbox_dns, fill=False, expand=False) - self.cvbox.pack_start(self.txt_domain, fill=False, expand=False) - self.cvbox.pack_start(self.txt_search_dom, fill=False, expand=False) - self.cvbox.pack_start(self.txt_dns_1, fill=False, expand=False) - self.cvbox.pack_start(self.txt_dns_2, fill=False, expand=False) - self.cvbox.pack_start(self.txt_dns_3, fill=False, expand=False) - self.cvbox.pack_start(dhcp_hostname_hbox, fill=False, expand=False) - self.cvbox.pack_end(self.button_hbox, fill=False, expand=False, padding=5) + self.cvbox.pack_start(self.chkbox_static_ip, False, False, 0) + self.cvbox.pack_start(self.txt_ip, False, False, 0) + self.cvbox.pack_start(self.txt_netmask, False, False, 0) + self.cvbox.pack_start(self.txt_gateway, False, False, 0) + self.cvbox.pack_start(self.hbox_dns, False, False, 0) + self.cvbox.pack_start(self.txt_domain, False, False, 0) + self.cvbox.pack_start(self.txt_search_dom, False, False, 0) + self.cvbox.pack_start(self.txt_dns_1, False, False, 0) + self.cvbox.pack_start(self.txt_dns_2, False, False, 0) + self.cvbox.pack_start(self.txt_dns_3, False, False, 0) + self.cvbox.pack_start(dhcp_hostname_hbox, False, False, 0) + self.cvbox.pack_end(self.button_hbox, False, False, 5) # Connect the events to the actions self.chkbox_static_ip.connect("toggled", self.toggle_ip_checkbox) @@ -141,7 +170,10 @@ def set_default_size(self): width, height = self.get_size() - s_height = gtk.gdk.screen_height() + if pygi: + s_height = gdk.Screen.height() + else: + s_height = gdk.screen_height() if s_height < 768: height = s_height * .75 else: @@ -351,18 +383,21 @@ AdvancedSettingsDialog.__init__(self, wireless.GetWirelessProperty(networkID, 'essid')) # Set up encryption stuff self.networkID = networkID - self.combo_encryption = gtk.combo_box_new_text() + if pygi: + self.combo_encryption = gtk.ComboBoxText() + else: + self.combo_encryption = gtk.combo_box_new_text() self.chkbox_encryption = gtk.CheckButton(_('Use Encryption')) self.chkbox_global_settings = gtk.CheckButton(_('Use these settings for all networks sharing this essid')) # Make the vbox to hold the encryption stuff. - self.vbox_encrypt_info = gtk.VBox(False, 0) + self.vbox_encrypt_info = gtk.VBox() self.toggle_encryption() self.chkbox_encryption.set_active(False) self.combo_encryption.set_sensitive(False) self.encrypt_types = misc.LoadEncryptionMethods() information_button = gtk.Button(stock=gtk.STOCK_INFO) - self.button_hbox.pack_start(information_button, False, False) + self.button_hbox.pack_start(information_button, False, False, 0) information_button.connect('clicked', lambda *a, **k: WirelessInformationDialog(networkID, self)) information_button.show() @@ -381,10 +416,10 @@ self.combo_encryption.set_active(0) self.change_encrypt_method() - self.cvbox.pack_start(self.chkbox_global_settings, False, False) - self.cvbox.pack_start(self.chkbox_encryption, False, False) - self.cvbox.pack_start(self.combo_encryption, False, False) - self.cvbox.pack_start(self.vbox_encrypt_info, False, False) + self.cvbox.pack_start(self.chkbox_global_settings, False, False, 0) + self.cvbox.pack_start(self.chkbox_encryption, False, False, 0) + self.cvbox.pack_start(self.combo_encryption, False, False, 0) + self.cvbox.pack_start(self.vbox_encrypt_info, False, False, 0) # Connect signals. self.chkbox_encryption.connect("toggled", self.toggle_encryption) @@ -542,7 +577,7 @@ else: box = LabelEntry(field_text) - self.vbox_encrypt_info.pack_start(box) + self.vbox_encrypt_info.pack_start(box, True, True, 0) # Add the data to a dict, so that the information # can be easily accessed by giving the name of the wanted # data. @@ -562,31 +597,36 @@ """ setup_dbus() - gtk.HBox.__init__(self, False, 2) + gtk.HBox.__init__(self) + self.set_homogeneous(False) + self.set_spacing(2) self.image = gtk.Image() - self.pack_start(self.image, False, False) + self.pack_start(self.image, False, False, 0) # Create an HBox to hold the buttons - self.buttons_hbox = gtk.HBox(False, 6) + self.buttons_hbox = gtk.HBox() + self.buttons_hbox.set_spacing(6) # Set up the Connect button self.connect_button = gtk.Button(stock=gtk.STOCK_CONNECT) - self.connect_hbox = gtk.HBox(False, 2) - self.connect_hbox.pack_start(self.connect_button, False, False) + self.connect_hbox = gtk.HBox() + self.connect_hbox.set_spacing(2) + self.connect_hbox.pack_start(self.connect_button, False, False, 0) self.connect_hbox.show() # Set up the Disconnect button self.disconnect_button = gtk.Button(stock=gtk.STOCK_DISCONNECT) - self.connect_hbox.pack_start(self.disconnect_button, False, False) + self.connect_hbox.pack_start(self.disconnect_button, False, False, 0) # Create a label to hold the name of the entry self.name_label = gtk.Label() self.name_label.set_alignment(0, 0.5) # Set up the VBox that goes in the gtk.Expander - self.expander_vbox = gtk.VBox(False, 1) + self.expander_vbox = gtk.VBox() + self.expander_vbox.set_spacing(1) self.expander_vbox.show() - self.pack_end(self.expander_vbox) + self.pack_end(self.expander_vbox, True, True, 0) # Set up the advanced settings button self.advanced_button = gtk.Button() @@ -597,13 +637,13 @@ self.advanced_button.set_label(_('Properties')) self.advanced_button.set_image(self.advanced_image) - self.buttons_hbox.pack_start(self.connect_hbox, False, False) - self.buttons_hbox.pack_start(self.advanced_button, False, False) + self.buttons_hbox.pack_start(self.connect_hbox, False, False, 0) + self.buttons_hbox.pack_start(self.advanced_button, False, False, 0) - self.vbox_top = gtk.VBox(False, 0) - self.expander_vbox.pack_start(self.name_label) - self.expander_vbox.pack_start(self.vbox_top) - self.expander_vbox.pack_start(self.buttons_hbox) + self.vbox_top = gtk.VBox() + self.expander_vbox.pack_start(self.name_label, True, True, 0) + self.expander_vbox.pack_start(self.vbox_top, True, True, 0) + self.expander_vbox.pack_start(self.buttons_hbox, True, True, 0) def destroy_called(self, *args): """ Clean up everything. """ @@ -633,22 +673,25 @@ self.button_delete = gtk.Button(stock=gtk.STOCK_DELETE) self.profile_help = gtk.Label(_('To connect to a wired network, you must create a network profile. To create a network profile, type a name that describes this network, and press Add.')) self.chkbox_default_profile = gtk.CheckButton(_('Use as default profile (overwrites any previous default)')) - self.combo_profile_names = gtk.combo_box_new_text() + if pygi: + self.combo_profile_names = gtk.ComboBoxText() + else: + self.combo_profile_names = gtk.combo_box_new_text() # Format the profile help label. - self.profile_help.set_justify(gtk.JUSTIFY_LEFT) + self.profile_help.set_justify(JUSTIFY_LEFT) self.profile_help.set_line_wrap(True) # Pack the various VBox objects. - self.hbox_temp = gtk.HBox(False, 0) - self.hbox_def = gtk.HBox(False, 0) - self.vbox_top.pack_start(self.profile_help, True, True) - self.vbox_top.pack_start(self.hbox_def) - self.vbox_top.pack_start(self.hbox_temp) - self.hbox_temp.pack_start(self.combo_profile_names, True, True) - self.hbox_temp.pack_start(self.button_add, False, False) - self.hbox_temp.pack_start(self.button_delete, False, False) - self.hbox_def.pack_start(self.chkbox_default_profile, False, False) + self.hbox_temp = gtk.HBox() + self.hbox_def = gtk.HBox() + self.vbox_top.pack_start(self.profile_help, True, True, 0) + self.vbox_top.pack_start(self.hbox_def, True, True, 0) + self.vbox_top.pack_start(self.hbox_temp, True, True, 0) + self.hbox_temp.pack_start(self.combo_profile_names, True, True, 0) + self.hbox_temp.pack_start(self.button_add, False, False, 0) + self.hbox_temp.pack_start(self.button_delete, False, False, 0) + self.hbox_def.pack_start(self.chkbox_default_profile, False, False, 0) # Connect events self.button_add.connect("clicked", self.add_profile) @@ -756,7 +799,10 @@ self.advanced_dialog.prof_name = self.combo_profile_names.get_active_text() if not wired.GetWiredProfileList(): self.profile_help.show() - entry = self.combo_profile_names.child + if pygi: + entry = self.combo_profile_names.get_child() + else: + entry = self.combo_profile_names.child entry.set_text("") if self.is_full_gui: self.button_delete.set_sensitive(False) @@ -834,8 +880,8 @@ ) # Add the wireless network specific parts to the NetworkEntry # VBox objects. - self.vbox_top.pack_start(self.chkbox_autoconnect, False, False) - self.vbox_top.pack_start(self.chkbox_neverconnect, False, False) + self.vbox_top.pack_start(self.chkbox_autoconnect, False, False, 0) + self.vbox_top.pack_start(self.chkbox_neverconnect, False, False, 0) if to_bool(self.format_entry(networkID, "automatic")): self.chkbox_autoconnect.set_active(True) @@ -984,7 +1030,8 @@ self.lbl_channel.set_alignment(0, 0.5) self.lbl_mode = gtk.Label() self.lbl_mode.set_alignment(0, 0.5) - self.hbox_status = gtk.HBox(False, 5) + self.hbox_status = gtk.HBox() + self.hbox_status.set_spacing(5) # Set the values of the network info labels. self.set_signal_strength(wireless.GetWirelessProperty(networkID, @@ -1000,11 +1047,12 @@ 'encryption_method')) self.set_title('Network Information') + if pygi: + self.vbox = self.get_children()[0] vbox = self.vbox - self.set_has_separator(False) table = gtk.Table(5, 2) table.set_col_spacings(12) - vbox.pack_start(table) + vbox.pack_start(table, True, True, 0) # Pack the network status HBox. table.attach(LeftAlignedLabel('Signal strength:'), 0, 1, 0, 1) @@ -1024,7 +1072,7 @@ vbox.show_all() - self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) + self.add_button(gtk.STOCK_CLOSE, RESPONSE_CLOSE) self.show() self.run() self.destroy() === modified file 'gtk/prefs.py' --- gtk/prefs.py 2011-10-18 21:33:23 +0000 +++ gtk/prefs.py 2011-10-19 15:53:12 +0000 @@ -24,9 +24,23 @@ # along with this program. If not, see . # -import gtk -import gobject -#import pango +try: + from gi.repository import Gtk as gtk + from gi.repository import GObject as gobject + from gi.repository import Gdk as gdk + #from gi.repository import Pango as pango + pygi = True + + #WEIGHT_BOLD = pango.Weight.BOLD +except ImportError: + import gtk + import gobject + import gdk + #import pango + pygi = False + + #WEIGHT_BOLD = pango.WEIGHT_BOLD + import os from wicd import misc @@ -154,7 +168,10 @@ # if pynotify isn't installed disable the option try: - import pynotify + if pygi: + from gi.repository import Notify as pynotify + else: + import pynotify except ImportError: self.notificationscheckbox.set_active(False) self.notificationscheckbox.set_sensitive(False) @@ -278,7 +295,7 @@ combobox.clear() combobox.set_model(liststore) cell = gtk.CellRendererText() - combobox.pack_start(cell, True) + combobox.pack_start(cell, True, True, 0) combobox.add_attribute(cell, 'text', 0) return combobox @@ -303,7 +320,7 @@ # entryWiredAutoMethod.set_label('Wired Autoconnect Setting:') # entryWiredAutoMethod.set_alignment(0, 0) # atrlist = pango.AttrList() - # atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50)) + # atrlist.insert(pango.AttrWeight(WEIGHT_BOLD, 0, 50)) # entryWiredAutoMethod.set_attributes(atrlist) # self.set_label("pref_dns1_label", "%s 1" % _('DNS server')) @@ -318,10 +335,16 @@ self.dialog.set_title(_('Preferences')) if os.path.exists(os.path.join(wpath.images, "wicd.png")): self.dialog.set_icon_from_file(os.path.join(wpath.images, "wicd.png")) - width = int(gtk.gdk.screen_width() / 2.4) + if pygi: + width = int(gdk.Screen.width() / 2.4) + else: + width = int(gdk.screen_width() / 2.4) if width > 450: width = 450 - self.dialog.resize(width, int(gtk.gdk.screen_height() / 2)) + if pygi: + self.dialog.resize(width, int(gdk.Screen.height() / 2)) + else: + self.dialog.resize(width, int(gdk.screen_height() / 2)) self.wiredcheckbox = setup_label("pref_always_check", _('''Always show wired interface''')) self.preferwiredcheckbox = setup_label("pref_prefer_wired_check", === modified file 'gtk/wicd-client.py' --- gtk/wicd-client.py 2011-10-18 21:33:23 +0000 +++ gtk/wicd-client.py 2011-10-19 18:26:32 +0000 @@ -37,21 +37,45 @@ # import sys -import gtk -import gobject import getopt import os -import pango import time import atexit from dbus import DBusException -import pygtk -pygtk.require('2.0') +try: + from gi.repository import Gtk as gtk + from gi.repository import GObject as gobject + from gi.repository import Pango as pango + from gi.repository import GdkPixbuf + import gi + gi.require_version('Gtk', '3.0') + pygi = True + + WEIGHT_BOLD = pango.Weight.BOLD + JUSTIFY_LEFT = gtk.Justification.LEFT + RESPONSE_CLOSE = gtk.ResponseType.CLOSE + STATE_PRELIGHT = gtk.StateType.PRELIGHT +except ImportError: + import gtk + import gobject + import pango + import pygtk + pygtk.require('2.0') + pygi = False + + WEIGHT_BOLD = pango.WEIGHT_BOLD + JUSTIFY_LEFT = gtk.JUSTIFY_LEFT + RESPONSE_CLOSE = gtk.RESPONSE_CLOSE + STATE_PRELIGHT = gtk.STATE_PRELIGHT HAS_NOTIFY = True try: - import pynotify + if pygi: + from gi.repository import Notify as pynotify + else: + import pynotify + if not pynotify.init("Wicd"): HAS_NOTIFY = False except ImportError: @@ -110,9 +134,13 @@ self.label = gtk.Label(lbl) if is_active: atrlist = pango.AttrList() - atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50)) + if pygi: + # FIXME: how to do this with gi? + pass + else: + atrlist.insert(pango.AttrWeight(WEIGHT_BOLD, 0, 50)) self.label.set_attributes(atrlist) - self.label.set_justify(gtk.JUSTIFY_LEFT) + self.label.set_justify(JUSTIFY_LEFT) self.label.set_alignment(0, 0) self.add(self.label) self.label.show() @@ -207,21 +235,25 @@ """ Updates the trayicon tooltip based on current connection status """ + if pygi: + set_tooltip = self.tr.set_tooltip_text + else: + set_tooltip = self.tr.set_tooltip if (self.network_type == "none"): - self.tr.set_tooltip(_('Not connected')) + set_tooltip(_('Not connected')) elif (self.network_type == "wireless"): - self.tr.set_tooltip(_('Connected to $A at $B (IP: $C)') + set_tooltip(_('Connected to $A at $B (IP: $C)') .replace('$A', self.network_name) .replace('$B', self.network_str) .replace('$C', self.network_addr)) elif (self.network_type == "wired"): - self.tr.set_tooltip(_('Connected to wired network (IP: $A)') + set_tooltip(_('Connected to wired network (IP: $A)') .replace('$A', self.network_addr)) elif (self.network_type == "killswitch"): - self.tr.set_tooltip(_('Not connected') + "(" + + set_tooltip(_('Not connected') + "(" + _('Wireless Kill Switch Enabled') + ")") elif (self.network_type == "no_daemon"): - self.tr.set_tooltip(_('Wicd daemon unreachable')) + set_tooltip(_('Wicd daemon unreachable')) return True @@ -554,7 +586,7 @@ def on_conn_info(self, data=None): """ Opens the Connection Information Dialog """ - window = gtk.Dialog("Wicd Connection Info", None, 0, (gtk.STOCK_OK, gtk.RESPONSE_CLOSE)) + window = gtk.Dialog("Wicd Connection Info", None, 0, (gtk.STOCK_OK, RESPONSE_CLOSE)) # Create labels self.label = gtk.Label() @@ -675,8 +707,12 @@ if type_ == "__wired__": image.set_from_icon_name("network-wired", 2) else: - pb = gtk.gdk.pixbuf_new_from_file_at_size(self._get_img(n_id), - 20, 20) + if pygi: + pb = GdkPixbuf.Pixbuf.new_from_file_at_size(self._get_img(n_id), + 20, 20) + else: + pb = gtk.gdk.pixbuf_new_from_file_at_size(self._get_img(n_id), + 20, 20) image.set_from_pixbuf(pb) del pb item.set_image(image) @@ -746,7 +782,7 @@ """ Trigger a scan if the network menu is being hovered over. """ while gtk.events_pending(): gtk.main_iteration() - if item.state != gtk.STATE_PRELIGHT: + if item.state != STATE_PRELIGHT: return True wireless.Scan(False) return False @@ -805,7 +841,8 @@ submenu = net_menuitem.get_submenu() self._clear_menu(submenu) - loading_item = gtk.MenuItem(_('Scanning') + "...") + loading_item = gtk.MenuItem() + loading_item.set_label(_('Scanning') + "...") loading_item.set_sensitive(False) loading_item.show() submenu.append(loading_item) @@ -902,12 +939,15 @@ self.connect('activate', self.on_activate) self.connect('popup-menu', self.on_popup_menu) self.set_from_file(wpath.images + "no-signal.png") - self.set_tooltip("Initializing wicd...") + if pygi: + self.set_tooltip_text("Initializing wicd...") + else: + self.set_tooltip("Initializing wicd...") def on_popup_menu(self, status, button, timestamp): """ Opens the right click menu for the tray icon. """ self.init_network_menu() - self.menu.popup(None, None, None, button, timestamp) + self.menu.popup(None, None, None, None, button, timestamp) def set_from_file(self, path=None): """ Sets a new tray icon picture. """