[geoclue-properties] Use GObject-Introspection instead of PyGTK
- From: Laurent Bigonville <lbigon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geoclue-properties] Use GObject-Introspection instead of PyGTK
- Date: Fri, 16 Sep 2011 08:27:00 +0000 (UTC)
commit 4ec2587af791be125d8266a040bb8f4266a33899
Author: Laurent Bigonville <bigon bigon be>
Date: Wed Sep 14 18:49:23 2011 +0200
Use GObject-Introspection instead of PyGTK
geoclueproperties/address-dialog.ui | 1 -
geoclueproperties/address_dialog.py | 19 ++-----
geoclueproperties/geoclue-properties.ui | 1 -
geoclueproperties/geoclue_properties.py | 83 +++++++++++++---------------
geoclueproperties/localnet-preferences.ui | 1 -
geoclueproperties/localnet_preferences.py | 40 ++++++--------
geoclueproperties/manual-preferences.ui | 1 -
geoclueproperties/manual_preferences.py | 25 +++------
8 files changed, 71 insertions(+), 100 deletions(-)
---
diff --git a/geoclueproperties/address-dialog.ui b/geoclueproperties/address-dialog.ui
index 660dc9e..62fa2bc 100644
--- a/geoclueproperties/address-dialog.ui
+++ b/geoclueproperties/address-dialog.ui
@@ -9,7 +9,6 @@
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="type_hint">normal</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
diff --git a/geoclueproperties/address_dialog.py b/geoclueproperties/address_dialog.py
index 2c6e6ba..4651101 100644
--- a/geoclueproperties/address_dialog.py
+++ b/geoclueproperties/address_dialog.py
@@ -1,14 +1,7 @@
# -*- coding: utf-8 -*-
try:
- import pygtk
- pygtk.require("2.0")
-except:
- pass
-
-try:
- import gtk
- import gobject
+ from gi.repository import Gtk
except:
print "Can't import Gtk"
sys.exit(1)
@@ -23,7 +16,7 @@ class AddressDialog:
path = os.path.dirname(os.path.abspath(__file__))
self.uifile = os.path.join(path, "address-dialog.ui")
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(self.uifile)
builder.connect_signals({
@@ -71,7 +64,7 @@ class AddressDialog:
def on_dialog_close (self, button):
self.dialog.hide()
- self.dialog.response (gtk.RESPONSE_CANCEL)
+ self.dialog.response (Gtk.ResponseType.CANCEL)
def on_save_button_clicked (self, button):
@@ -81,8 +74,8 @@ class AddressDialog:
if address['locality'] == "" and address['country'] == "":
- dialog = gtk.MessageDialog (self.dialog, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
- gtk.BUTTONS_CLOSE, "You must fill locality and country.")
+ dialog = Gtk.MessageDialog (self.dialog, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.CLOSE, "You must fill locality and country.")
dialog.set_title("Incomplete data")
dialog.run()
dialog.hide()
@@ -96,7 +89,7 @@ class AddressDialog:
self.address = address
self.dialog.hide()
- self.dialog.response (gtk.RESPONSE_OK)
+ self.dialog.response (Gtk.ResponseType.OK)
def run (self):
return self.dialog.run ()
diff --git a/geoclueproperties/geoclue-properties.ui b/geoclueproperties/geoclue-properties.ui
index 2cb41c5..d85087c 100644
--- a/geoclueproperties/geoclue-properties.ui
+++ b/geoclueproperties/geoclue-properties.ui
@@ -9,7 +9,6 @@
<property name="default_width">500</property>
<property name="default_height">400</property>
<property name="type_hint">normal</property>
- <property name="has_separator">False</property>
<signal name="close" handler="on_properties_dialog_close"/>
<signal name="delete_event" handler="on_properties_dialog_close"/>
<child internal-child="vbox">
diff --git a/geoclueproperties/geoclue_properties.py b/geoclueproperties/geoclue_properties.py
index ad16d79..c15396b 100644
--- a/geoclueproperties/geoclue_properties.py
+++ b/geoclueproperties/geoclue_properties.py
@@ -18,16 +18,11 @@
import os
import sys
-try:
- import pygtk
- pygtk.require("2.0")
-except:
- pass
try:
- import gtk
- import gobject
- import pango
+ from gi.repository import Gtk
+ from gi.repository import GObject
+ from gi.repository import Pango
except:
print "Can't import Gtk"
sys.exit(1)
@@ -51,12 +46,12 @@ class GeocluePropertiesDialog:
path = os.path.dirname(os.path.abspath(__file__))
self.uifile = os.path.join(path, "geoclue-properties.ui")
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(self.uifile)
builder.connect_signals({
- "on_properties_dialog_close" : gtk.main_quit,
- "on_close_button_clicked": gtk.main_quit,
+ "on_properties_dialog_close" : Gtk.main_quit,
+ "on_close_button_clicked": Gtk.main_quit,
"on_preferences_button_clicked": self.on_preferences_button_clicked,
"on_about_button_clicked": self.on_about_button_clicked,
})
@@ -75,49 +70,49 @@ class GeocluePropertiesDialog:
self.dialog.show ()
def create_provider_tab (self):
- cellrenderer = gtk.CellRendererText ()
- cellrenderer.set_property('ellipsize', pango.ELLIPSIZE_END)
- column = gtk.TreeViewColumn("Name", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ cellrenderer.set_property('ellipsize', Pango.EllipsizeMode.END)
+ column = Gtk.TreeViewColumn("Name", cellrenderer)
column.add_attribute(cellrenderer, 'markup', 1)
column.set_expand (True)
self.provider_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Address", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Address", cellrenderer)
column.add_attribute(cellrenderer, 'text', 2)
column.add_attribute(cellrenderer, 'visible', 3)
cellrenderer.set_property('xalign', 0.5)
self.provider_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Position", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Position", cellrenderer)
column.add_attribute(cellrenderer, 'text', 2)
column.add_attribute(cellrenderer, 'visible', 4)
cellrenderer.set_property('xalign', 0.5)
self.provider_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Geocoding", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Geocoding", cellrenderer)
column.add_attribute(cellrenderer, 'text', 2)
column.add_attribute(cellrenderer, 'visible', 5)
cellrenderer.set_property('xalign', 0.5)
self.provider_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Rev. Geocoding", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Rev. Geocoding", cellrenderer)
column.add_attribute(cellrenderer, 'text', 2)
column.add_attribute(cellrenderer, 'visible', 6)
cellrenderer.set_property('xalign', 0.5)
self.provider_treeview.append_column (column)
- self.provider_store = gtk.ListStore (gobject.TYPE_PYOBJECT,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN)
- self.provider_store.set_sort_column_id (1, gtk.SORT_ASCENDING)
+ self.provider_store = Gtk.ListStore (GObject.TYPE_PYOBJECT,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_BOOLEAN)
+ self.provider_store.set_sort_column_id (1, Gtk.SortType.ASCENDING)
path = "/usr/share/geoclue-providers/"
dir = os.listdir(path)
@@ -164,7 +159,7 @@ class GeocluePropertiesDialog:
license = license_file.read()
license_file.close()
- dialog = gtk.AboutDialog()
+ dialog = Gtk.AboutDialog()
dialog.set_name("Geoclue Properties")
dialog.set_version("0.1")
dialog.set_copyright("Â 2009, Pierre-Luc Beaudoin")
@@ -177,24 +172,24 @@ class GeocluePropertiesDialog:
def create_general_tab (self):
# Setup current address display
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Field", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Field", cellrenderer)
column.add_attribute(cellrenderer, 'text', 0)
self.address_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Value", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Value", cellrenderer)
column.add_attribute(cellrenderer, 'text', 1)
self.address_treeview.append_column (column)
# Setup current position display
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Field", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Field", cellrenderer)
column.add_attribute(cellrenderer, 'text', 0)
self.position_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Value", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Value", cellrenderer)
column.add_attribute(cellrenderer, 'text', 1)
self.position_treeview.append_column (column)
@@ -235,8 +230,8 @@ class GeocluePropertiesDialog:
self.position_provider_label.set_text(name)
def address_changed (self, timestamp, address, accuracy):
- self.address_store = gtk.ListStore (str, str)
- self.address_store.set_sort_column_id (0, gtk.SORT_ASCENDING)
+ self.address_store = Gtk.ListStore (str, str)
+ self.address_store.set_sort_column_id (0, Gtk.SortType.ASCENDING)
for key, value in address.items():
self.address_store.append([key, value])
@@ -245,8 +240,8 @@ class GeocluePropertiesDialog:
mydate = date.fromtimestamp(timestamp)
def position_changed (self, fields, timestamp, latitude, longitude, altitude, accuracy):
- self.position_store = gtk.ListStore (str, str)
- self.position_store.set_sort_column_id (0, gtk.SORT_ASCENDING)
+ self.position_store = Gtk.ListStore (str, str)
+ self.position_store.set_sort_column_id (0, Gtk.SortType.ASCENDING)
self.position_treeview.set_model (self.position_store)
@@ -259,7 +254,7 @@ class GeocluePropertiesDialog:
def main():
dialog = GeocluePropertiesDialog()
- gtk.main()
+ Gtk.main()
if __name__ == "__main__":
main()
diff --git a/geoclueproperties/localnet-preferences.ui b/geoclueproperties/localnet-preferences.ui
index ad1ad2e..112b3f2 100644
--- a/geoclueproperties/localnet-preferences.ui
+++ b/geoclueproperties/localnet-preferences.ui
@@ -8,7 +8,6 @@
<property name="window_position">center</property>
<property name="default_height">400</property>
<property name="type_hint">normal</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
diff --git a/geoclueproperties/localnet_preferences.py b/geoclueproperties/localnet_preferences.py
index b87435e..386a07a 100644
--- a/geoclueproperties/localnet_preferences.py
+++ b/geoclueproperties/localnet_preferences.py
@@ -19,16 +19,10 @@
import os
import sys
-try:
- import pygtk
- pygtk.require("2.0")
-except:
- pass
try:
- import gtk
- import gobject
- import pango
+ from gi.repository import Gtk
+ from gi.repository import Pango
except:
print "Can't import Gtk"
sys.exit(1)
@@ -50,7 +44,7 @@ class LocalnetPreferencesDialog:
path = os.path.dirname(os.path.abspath(__file__))
self.uifile = os.path.join(path, "localnet-preferences.ui")
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(self.uifile)
builder.connect_signals({
@@ -75,13 +69,13 @@ class LocalnetPreferencesDialog:
def create_general_tab (self):
# Setup current address display
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Field", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Field", cellrenderer)
column.add_attribute(cellrenderer, 'text', 0)
self.address_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Value", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Value", cellrenderer)
column.add_attribute(cellrenderer, 'text', 1)
self.address_treeview.append_column (column)
@@ -102,8 +96,8 @@ class LocalnetPreferencesDialog:
self.update_current_address (address)
def update_current_address (self, address):
- self.address_store = gtk.ListStore (str, str)
- self.address_store.set_sort_column_id (0, gtk.SORT_ASCENDING)
+ self.address_store = Gtk.ListStore (str, str)
+ self.address_store.set_sort_column_id (0, Gtk.SortType.ASCENDING)
for key, value in address.items():
self.address_store.append([key, value])
@@ -121,20 +115,20 @@ class LocalnetPreferencesDialog:
def create_addresses_tab (self):
# Setup current address display
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Mac Address", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Mac Address", cellrenderer)
column.add_attribute(cellrenderer, 'text', 0)
self.addresses_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- cellrenderer.set_property('ellipsize', pango.ELLIPSIZE_END)
- column = gtk.TreeViewColumn("Address", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ cellrenderer.set_property('ellipsize', Pango.EllipsizeMode.END)
+ column = Gtk.TreeViewColumn("Address", cellrenderer)
column.add_attribute(cellrenderer, 'text', 1)
column.set_expand (True)
self.addresses_treeview.append_column (column)
- self.addresses_store = gtk.ListStore (str, str)
- self.addresses_store.set_sort_column_id (0, gtk.SORT_ASCENDING)
+ self.addresses_store = Gtk.ListStore (str, str)
+ self.addresses_store.set_sort_column_id (0, Gtk.SortType.ASCENDING)
self.addresses_treeview.set_model (self.addresses_store)
self.load_addresses ()
@@ -161,7 +155,7 @@ class LocalnetPreferencesDialog:
dialog = AddressDialog("New Address", "Enter an address.", self.address)
response = dialog.run ()
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.ResponseType.OK:
try:
localnet = self.provider.get_proxy()
localnet.SetAddress (dialog.address)
diff --git a/geoclueproperties/manual-preferences.ui b/geoclueproperties/manual-preferences.ui
index bc53b0f..108af11 100644
--- a/geoclueproperties/manual-preferences.ui
+++ b/geoclueproperties/manual-preferences.ui
@@ -8,7 +8,6 @@
<property name="window_position">center</property>
<property name="default_height">400</property>
<property name="type_hint">normal</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
diff --git a/geoclueproperties/manual_preferences.py b/geoclueproperties/manual_preferences.py
index 2738c97..0bf7f9c 100644
--- a/geoclueproperties/manual_preferences.py
+++ b/geoclueproperties/manual_preferences.py
@@ -19,16 +19,9 @@
import os
import sys
-try:
- import pygtk
- pygtk.require("2.0")
-except:
- pass
try:
- import gtk
- import gobject
- import pango
+ from gi.repository import Gtk
except:
print "Can't import Gtk"
sys.exit(1)
@@ -50,7 +43,7 @@ class ManualPreferencesDialog:
path = os.path.dirname(os.path.abspath(__file__))
self.uifile = os.path.join(path, "manual-preferences.ui")
- builder = gtk.Builder()
+ builder = Gtk.Builder()
builder.add_from_file(self.uifile)
builder.connect_signals({
@@ -68,13 +61,13 @@ class ManualPreferencesDialog:
def create_general_tab (self):
# Setup current address display
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Field", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Field", cellrenderer)
column.add_attribute(cellrenderer, 'text', 0)
self.address_treeview.append_column (column)
- cellrenderer = gtk.CellRendererText ()
- column = gtk.TreeViewColumn("Value", cellrenderer)
+ cellrenderer = Gtk.CellRendererText ()
+ column = Gtk.TreeViewColumn("Value", cellrenderer)
column.add_attribute(cellrenderer, 'text', 1)
self.address_treeview.append_column (column)
@@ -96,8 +89,8 @@ class ManualPreferencesDialog:
self.update_current_address(address)
def update_current_address (self, address):
- self.address_store = gtk.ListStore (str, str)
- self.address_store.set_sort_column_id (0, gtk.SORT_ASCENDING)
+ self.address_store = Gtk.ListStore (str, str)
+ self.address_store.set_sort_column_id (0, Gtk.SortType.ASCENDING)
for key, value in address.items():
self.address_store.append([key, value])
@@ -112,7 +105,7 @@ class ManualPreferencesDialog:
dialog = AddressDialog("New Address", "Enter the address associated with the current network.", self.address)
response = dialog.run ()
- if response == gtk.RESPONSE_OK:
+ if response == Gtk.ResponseType.OK:
try:
manual = self.provider.get_proxy()
manual.SetAddress (0, dialog.address)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]