fix disco window (+ remove cmp() + some GTK3 changements)

This commit is contained in:
Yann Leboulanger 2013-01-05 15:32:53 +01:00
parent 9f64f04b37
commit b541736407
6 changed files with 154 additions and 96 deletions

View File

@ -1,7 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<requires lib="gtk+" version="2.16"/> <!-- interface-requires gtk+ 3.0 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkListStore" id="liststore1"> <object class="GtkListStore" id="liststore1">
<columns> <columns>
<!-- column-name item --> <!-- column-name item -->
@ -9,27 +8,31 @@
</columns> </columns>
</object> </object>
<object class="GtkWindow" id="service_discovery_window"> <object class="GtkWindow" id="service_discovery_window">
<property name="can_focus">False</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="role">Service Discovery</property> <property name="role">Service Discovery</property>
<property name="default_width">550</property> <property name="default_width">550</property>
<property name="default_height">420</property> <property name="default_height">420</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<signal name="destroy" handler="on_service_discovery_window_destroy"/> <signal name="destroy" handler="on_service_discovery_window_destroy" swapped="no"/>
<child> <child>
<object class="GtkVBox" id="vbox11"> <object class="GtkVBox" id="vbox11">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="can_focus">False</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<object class="GtkEventBox" id="banner_agent_eventbox"> <object class="GtkEventBox" id="banner_agent_eventbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<child> <child>
<object class="GtkHBox" id="banner_agent_hbox"> <object class="GtkHBox" id="banner_agent_hbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<object class="GtkLabel" id="banner_agent_label"> <object class="GtkLabel" id="banner_agent_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0.05000000074505806</property> <property name="xalign">0.05000000074505806</property>
<property name="ypad">6</property> <property name="ypad">6</property>
<property name="label">&lt;span weight="heavy" size="large"&gt;Agent name&lt;/span&gt; <property name="label">&lt;span weight="heavy" size="large"&gt;Agent name&lt;/span&gt;
@ -37,18 +40,22 @@ Agent JID - node</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkImage" id="banner_agent_icon"> <object class="GtkImage" id="banner_agent_icon">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xpad">6</property> <property name="xpad">6</property>
<property name="ypad">6</property> <property name="ypad">6</property>
<property name="stock">gtk-missing-image</property> <property name="stock">gtk-missing-image</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
@ -64,44 +71,38 @@ Agent JID - node</property>
<child> <child>
<object class="GtkTable" id="address_table"> <object class="GtkTable" id="address_table">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">3</property> <property name="n_rows">3</property>
<property name="n_columns">3</property> <property name="n_columns">3</property>
<property name="column_spacing">6</property> <property name="column_spacing">6</property>
<child> <child>
<object class="GtkComboBoxEntry" id="address_comboboxentry"> <placeholder/>
<property name="visible">True</property>
<property name="model">liststore1</property>
<property name="text_column">0</property>
<signal name="changed" handler="on_address_comboboxentry_changed"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="browse_button"> <object class="GtkButton" id="browse_button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="has_default">True</property> <property name="has_default">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<signal name="clicked" handler="on_go_button_clicked"/> <property name="use_action_appearance">False</property>
<signal name="clicked" handler="on_go_button_clicked" swapped="no"/>
<child> <child>
<object class="GtkAlignment" id="alignment93"> <object class="GtkAlignment" id="alignment93">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xscale">0</property> <property name="xscale">0</property>
<property name="yscale">0</property> <property name="yscale">0</property>
<child> <child>
<object class="GtkHBox" id="hbox2995"> <object class="GtkHBox" id="hbox2995">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkImage" id="image1148"> <object class="GtkImage" id="image1148">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-jump-to</property> <property name="stock">gtk-jump-to</property>
</object> </object>
<packing> <packing>
@ -113,6 +114,7 @@ Agent JID - node</property>
<child> <child>
<object class="GtkLabel" id="label362"> <object class="GtkLabel" id="label362">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">G_o</property> <property name="label" translatable="yes">G_o</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
</object> </object>
@ -132,24 +134,44 @@ Agent JID - node</property>
<property name="right_attach">3</property> <property name="right_attach">3</property>
<property name="bottom_attach">3</property> <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"/>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="label224"> <object class="GtkLabel" id="label224">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Address:</property> <property name="label" translatable="yes">_Address:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">address_comboboxentry</property>
</object> </object>
<packing> <packing>
<property name="bottom_attach">3</property> <property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"/>
</packing> </packing>
</child> </child>
<child> <child>
<placeholder/> <object class="GtkComboBoxText" id="address_comboboxtext">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<property name="entry_text_column">0</property>
<property name="id_column">1</property>
<signal name="changed" handler="on_address_comboboxtext_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="address_entry">
<property name="can_focus">False</property>
<property name="activates_default">True</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>
@ -157,6 +179,7 @@ Agent JID - node</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
@ -164,29 +187,34 @@ Agent JID - node</property>
<object class="GtkScrolledWindow" id="services_scrollwin"> <object class="GtkScrolledWindow" id="services_scrollwin">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property> <property name="shadow_type">etched-in</property>
<child> <child>
<object class="GtkTreeView" id="services_treeview"> <object class="GtkTreeView" id="services_treeview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="headers_visible">False</property> <property name="headers_visible">False</property>
<signal name="row_activated" handler="on_services_treeview_row_activated"/> <signal name="row-activated" handler="on_services_treeview_row_activated" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkHBox" id="hbox2994"> <object class="GtkHBox" id="hbox2994">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkProgressBar" id="services_progressbar"> <object class="GtkProgressBar" id="services_progressbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="pulse_step">0.10000000149</property> <property name="pulse_step">0.10000000149</property>
</object> </object>
@ -199,25 +227,31 @@ Agent JID - node</property>
<child> <child>
<object class="GtkLabel" id="label363"> <object class="GtkLabel" id="label363">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkHBox" id="action_buttonbox"> <object class="GtkHBox" id="action_buttonbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<object class="GtkButton" id="close_button"> <object class="GtkButton" id="close_button">
<property name="label">gtk-close</property> <property name="label">gtk-close</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="has_focus">True</property> <property name="has_focus">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<signal name="clicked" handler="on_close_button_clicked"/> <signal name="clicked" handler="on_close_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -229,12 +263,14 @@ Agent JID - node</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">2</property> <property name="padding">2</property>
<property name="position">3</property> <property name="position">3</property>
</packing> </packing>

View File

@ -181,7 +181,11 @@ class Command(object):
return "<Command %s>" % ', '.join(self.names) return "<Command %s>" % ', '.join(self.names)
def __cmp__(self, other): def __cmp__(self, other):
return cmp(self.first_name, other.first_name) if self.first_name > other.first_name:
return 1
if self.first_name < other.first_name:
return -1
return 0
@property @property
def first_name(self): def first_name(self):

View File

@ -311,7 +311,7 @@ class ChooseGPGKeyDialog:
self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
self.window.show_all() self.window.show_all()
def sort_keys(self, model, iter1, iter2): def sort_keys(self, model, iter1, iter2, data=None):
value1 = model[iter1][1] value1 = model[iter1][1]
value2 = model[iter2][1] value2 = model[iter2][1]
if value1 == _('None'): if value1 == _('None'):
@ -3807,7 +3807,7 @@ class ArchivingPreferencesWindow:
self.current_item = None self.current_item = None
def sort_items(model, iter1, iter2): def sort_items(model, iter1, iter2, data=None):
item1 = model.get_value(iter1, 0) item1 = model.get_value(iter1, 0)
item2 = model.get_value(iter2, 0) item2 = model.get_value(iter2, 0)
if item1 == 'Default': if item1 == 'Default':

View File

@ -149,7 +149,7 @@ class CacheDictionary:
return self.value return self.value
def cleanup(self): def cleanup(self):
for key in self.cache.keys(): for key in list(self.cache.keys()):
item = self.cache[key] item = self.cache[key]
if item.source: if item.source:
GObject.source_remove(item.source) GObject.source_remove(item.source)
@ -171,7 +171,7 @@ class CacheDictionary:
if item.source: if item.source:
GObject.source_remove(item.source) GObject.source_remove(item.source)
if self.lifetime: if self.lifetime:
source = GObject.timeout_add_seconds(self.lifetime/1000, self._expire_timeout, key) source = GObject.timeout_add_seconds(int(self.lifetime/1000), self._expire_timeout, key)
item.source = source item.source = source
def __getitem__(self, key): def __getitem__(self, key):
@ -221,7 +221,7 @@ class Closure(object):
self.remove = remove self.remove = remove
self.removeargs = removeargs self.removeargs = removeargs
if isinstance(cb, types.MethodType): if isinstance(cb, types.MethodType):
self.meth_self = weakref.ref(cb.im_self, self._remove) self.meth_self = weakref.ref(cb.__self__, self._remove)
self.meth_name = cb.__name__ self.meth_name = cb.__name__
elif callable(cb): elif callable(cb):
self.meth_self = None self.meth_self = None
@ -544,13 +544,13 @@ _('Without a connection, you can not browse available services'))
self.action_buttonbox = self.xml.get_object('action_buttonbox') self.action_buttonbox = self.xml.get_object('action_buttonbox')
# Address combobox # Address combobox
self.address_comboboxentry = None self.address_comboboxtext = None
address_table = self.xml.get_object('address_table') address_table = self.xml.get_object('address_table')
if address_entry: if address_entry:
self.address_comboboxentry = self.xml.get_object( self.address_comboboxtext = self.xml.get_object(
'address_comboboxentry') 'address_comboboxtext')
self.address_comboboxentry_entry = self.address_comboboxentry.get_child() self.address_comboboxtext_entry = self.xml.get_object(
self.address_comboboxentry_entry.set_activates_default(True) 'address_entry')
self.latest_addresses = gajim.config.get( self.latest_addresses = gajim.config.get(
'latest_disco_addresses').split() 'latest_disco_addresses').split()
@ -560,8 +560,8 @@ _('Without a connection, you can not browse available services'))
if len(self.latest_addresses) > 10: if len(self.latest_addresses) > 10:
self.latest_addresses = self.latest_addresses[0:10] self.latest_addresses = self.latest_addresses[0:10]
for j in self.latest_addresses: for j in self.latest_addresses:
self.address_comboboxentry.append_text(j) self.address_comboboxtext.append_text(j)
self.address_comboboxentry.get_child().set_text(jid) self.address_comboboxtext.get_child().set_text(jid)
else: else:
# Don't show it at all if we didn't ask for it # Don't show it at all if we didn't ask for it
address_table.set_no_show_all(True) address_table.set_no_show_all(True)
@ -754,7 +754,7 @@ _('Without a connection, you can not browse available services'))
if self.dying or jid != self.jid or node != self.node: if self.dying or jid != self.jid or node != self.node:
return return
if not identities: if not identities:
if not self.address_comboboxentry: if not self.address_comboboxtext:
# We can't travel anywhere else. # We can't travel anywhere else.
self.destroy() self.destroy()
dialogs.ErrorDialog(_('The service could not be found'), dialogs.ErrorDialog(_('The service could not be found'),
@ -796,10 +796,10 @@ _('This type of service does not contain any items to browse.'))
def on_close_button_clicked(self, widget): def on_close_button_clicked(self, widget):
self.destroy() self.destroy()
def on_address_comboboxentry_changed(self, widget): def on_address_comboboxtext_changed(self, widget):
if self.address_comboboxentry.get_active() != -1: if self.address_comboboxtext.get_active() != -1:
# user selected one of the entries so do auto-visit # user selected one of the entries so do auto-visit
jid = self.address_comboboxentry.get_child().get_text() jid = self.address_comboboxtext_entry.get_text()
try: try:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except helpers.InvalidFormat as s: except helpers.InvalidFormat as s:
@ -809,7 +809,7 @@ _('This type of service does not contain any items to browse.'))
self.travel(jid, '') self.travel(jid, '')
def on_go_button_clicked(self, widget): def on_go_button_clicked(self, widget):
jid = self.address_comboboxentry.get_child().get_text() jid = self.address_comboboxtext_entry.get_text()
try: try:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except helpers.InvalidFormat as s: except helpers.InvalidFormat as s:
@ -823,9 +823,9 @@ _('This type of service does not contain any items to browse.'))
self.latest_addresses.insert(0, jid) self.latest_addresses.insert(0, jid)
if len(self.latest_addresses) > 10: if len(self.latest_addresses) > 10:
self.latest_addresses = self.latest_addresses[0:10] self.latest_addresses = self.latest_addresses[0:10]
self.address_comboboxentry.get_model().clear() self.address_comboboxtext.get_model().clear()
for j in self.latest_addresses: for j in self.latest_addresses:
self.address_comboboxentry.append_text(j) self.address_comboboxtext.append_text(j)
gajim.config.set('latest_disco_addresses', gajim.config.set('latest_disco_addresses',
' '.join(self.latest_addresses)) ' '.join(self.latest_addresses))
self.travel(jid, '') self.travel(jid, '')
@ -884,15 +884,15 @@ class AgentBrowser:
# Name column # Name column
col = Gtk.TreeViewColumn(_('Name')) col = Gtk.TreeViewColumn(_('Name'))
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, text = 2) col.add_attribute(renderer, 'text', 2)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True) col.set_resizable(True)
# Address column # Address column
col = Gtk.TreeViewColumn(_('JID')) col = Gtk.TreeViewColumn(_('JID'))
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, text = 3) col.add_attribute(renderer, 'text', 3)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True) col.set_resizable(True)
self.window.services_treeview.set_headers_visible(True) self.window.services_treeview.set_headers_visible(True)
@ -914,7 +914,7 @@ class AgentBrowser:
label.set_use_underline(True) label.set_use_underline(True)
hbox = Gtk.HBox() hbox = Gtk.HBox()
hbox.pack_start(image, False, True, 6) hbox.pack_start(image, False, True, 6)
hbox.pack_end(label, True, True) hbox.pack_end(label, True, True, 6)
self.browse_button.add(hbox) self.browse_button.add(hbox)
self.browse_button.connect('clicked', self.on_browse_button_clicked) self.browse_button.connect('clicked', self.on_browse_button_clicked)
self.window.action_buttonbox.add(self.browse_button) self.window.action_buttonbox.add(self.browse_button)
@ -1095,7 +1095,7 @@ class AgentBrowser:
self.window.progressbar.hide() self.window.progressbar.hide()
# The server returned an error # The server returned an error
if items == 0: if items == 0:
if not self.window.address_comboboxentry: if not self.window.address_comboboxtext:
# We can't travel anywhere else. # We can't travel anywhere else.
self.window.destroy() self.window.destroy()
dialogs.ErrorDialog(_('The service is not browsable'), dialogs.ErrorDialog(_('The service is not browsable'),
@ -1180,7 +1180,7 @@ class ToplevelAgentBrowser(AgentBrowser):
self._view_signals = [] self._view_signals = []
self._scroll_signal = None self._scroll_signal = None
def _pixbuf_renderer_data_func(self, col, cell, model, iter_): def _pixbuf_renderer_data_func(self, col, cell, model, iter_, data=None):
""" """
Callback for setting the pixbuf renderer's properties Callback for setting the pixbuf renderer's properties
""" """
@ -1192,7 +1192,7 @@ class ToplevelAgentBrowser(AgentBrowser):
else: else:
cell.set_property('visible', False) cell.set_property('visible', False)
def _text_renderer_data_func(self, col, cell, model, iter_): def _text_renderer_data_func(self, col, cell, model, iter_, data=None):
""" """
Callback for setting the text renderer's properties Callback for setting the text renderer's properties
""" """
@ -1215,28 +1215,30 @@ class ToplevelAgentBrowser(AgentBrowser):
cell.set_property('cell_background_set', True) cell.set_property('cell_background_set', True)
cell.set_property('foreground_set', False) cell.set_property('foreground_set', False)
def _treemodel_sort_func(self, model, iter1, iter2): def _treemodel_sort_func(self, model, iter1, iter2, data=None):
""" """
Sort function for our treemode Sort function for our treemode
""" """
# Compare state # Compare state
statecmp = cmp(model.get_value(iter1, 4), model.get_value(iter2, 4)) state1 = model.get_value(iter1, 4)
if statecmp == 0: state2 = model.get_value(iter2, 4)
# These can be None, apparently if state1 > state2:
descr1 = model.get_value(iter1, 3) return 1
if descr1: if state1 < state2:
descr1 = descr1 return -1
descr2 = model.get_value(iter2, 3) descr1 = model.get_value(iter1, 3)
if descr2: descr2 = model.get_value(iter2, 3)
descr2 = descr2 # Compare strings
# Compare strings if descr1 > descr2:
return cmp(descr1, descr2) return 1
return statecmp if descr1 < descr2:
return -1
return 0
def _show_tooltip(self, state): def _show_tooltip(self, state):
view = self.window.services_treeview view = self.window.services_treeview
pointer = view.get_pointer() pointer = view.get_pointer()
props = view.get_path_at_pos(pointer[1], pointer[2]) props = view.get_path_at_pos(pointer[0], pointer[1])
# check if the current pointer is at the same path # check if the current pointer is at the same path
# as it was before setting the timeout # as it was before setting the timeout
if props and self.tooltip.id == props[0]: if props and self.tooltip.id == props[0]:
@ -1296,11 +1298,11 @@ class ToplevelAgentBrowser(AgentBrowser):
# Icon Renderer # Icon Renderer
renderer = Gtk.CellRendererPixbuf() renderer = Gtk.CellRendererPixbuf()
renderer.set_property('xpad', 6) renderer.set_property('xpad', 6)
col.pack_start(renderer, False, True, 0) col.pack_start(renderer, False)
col.set_cell_data_func(renderer, self._pixbuf_renderer_data_func) col.set_cell_data_func(renderer, self._pixbuf_renderer_data_func)
# Text Renderer # Text Renderer
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_cell_data_func(renderer, self._text_renderer_data_func) col.set_cell_data_func(renderer, self._text_renderer_data_func)
renderer.set_property('foreground', 'dark gray') renderer.set_property('foreground', 'dark gray')
# Save this so we can go along with theme changes # Save this so we can go along with theme changes
@ -1343,7 +1345,7 @@ class ToplevelAgentBrowser(AgentBrowser):
label.set_use_underline(True) label.set_use_underline(True)
hbox = Gtk.HBox() hbox = Gtk.HBox()
hbox.pack_start(image, False, True, 6) hbox.pack_start(image, False, True, 6)
hbox.pack_end(label, True, True) hbox.pack_end(label, True, True, 6)
self.execute_button.add(hbox) self.execute_button.add(hbox)
self.execute_button.connect('clicked', self.on_execute_button_clicked) self.execute_button.connect('clicked', self.on_execute_button_clicked)
self.window.action_buttonbox.add(self.execute_button) self.window.action_buttonbox.add(self.execute_button)
@ -1361,7 +1363,7 @@ class ToplevelAgentBrowser(AgentBrowser):
label.set_use_underline(True) label.set_use_underline(True)
hbox = Gtk.HBox() hbox = Gtk.HBox()
hbox.pack_start(image, False, True, 6) hbox.pack_start(image, False, True, 6)
hbox.pack_end(label, True, True) hbox.pack_end(label, True, True, 6)
self.join_button.add(hbox) self.join_button.add(hbox)
self.join_button.connect('clicked', self.on_join_button_clicked) self.join_button.connect('clicked', self.on_join_button_clicked)
self.window.action_buttonbox.add(self.join_button) self.window.action_buttonbox.add(self.join_button)
@ -1373,7 +1375,7 @@ class ToplevelAgentBrowser(AgentBrowser):
label.set_use_underline(True) label.set_use_underline(True)
hbox = Gtk.HBox() hbox = Gtk.HBox()
hbox.pack_start(image, False, True, 6) hbox.pack_start(image, False, True, 6)
hbox.pack_end(label, True, True) hbox.pack_end(label, True, True, 6)
self.search_button.add(hbox) self.search_button.add(hbox)
self.search_button.connect('clicked', self.on_search_button_clicked) self.search_button.connect('clicked', self.on_search_button_clicked)
self.window.action_buttonbox.add(self.search_button) self.window.action_buttonbox.add(self.search_button)
@ -1744,32 +1746,32 @@ class MucBrowser(AgentBrowser):
col.set_sizing(Gtk.TreeViewColumnSizing.FIXED) col.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
col.set_fixed_width(100) col.set_fixed_width(100)
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, text = 2) col.add_attribute(renderer, 'text', 2)
col.set_sort_column_id(2) col.set_sort_column_id(2)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True) col.set_resizable(True)
# Users column # Users column
col = Gtk.TreeViewColumn(_('Users')) col = Gtk.TreeViewColumn(_('Users'))
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, text = 4) col.add_attribute(renderer, 'text', 4)
col.set_sort_column_id(3) col.set_sort_column_id(3)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True) col.set_resizable(True)
# Description column # Description column
col = Gtk.TreeViewColumn(_('Description')) col = Gtk.TreeViewColumn(_('Description'))
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, text = 5) col.add_attribute(renderer, 'text', 5)
col.set_sort_column_id(4) col.set_sort_column_id(4)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True) col.set_resizable(True)
# Id column # Id column
col = Gtk.TreeViewColumn(_('Id')) col = Gtk.TreeViewColumn(_('Id'))
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, text = 0) col.add_attribute(renderer, 'text', 0)
col.set_sort_column_id(0) col.set_sort_column_id(0)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
col.set_resizable(True) col.set_resizable(True)
@ -1906,7 +1908,7 @@ class MucBrowser(AgentBrowser):
iter_ = end = None iter_ = end = None
# Top row # Top row
try: try:
sx, sy = view.tree_to_widget_coords(rect.x, rect.y) sx, sy = view.convert_tree_to_bin_window_coords(rect.x, rect.y)
spath = view.get_path_at_pos(sx, sy)[0] spath = view.get_path_at_pos(sx, sy)[0]
iter_ = self.model.get_iter(spath) iter_ = self.model.get_iter(spath)
except TypeError: except TypeError:
@ -1915,8 +1917,8 @@ class MucBrowser(AgentBrowser):
# Bottom row # Bottom row
# Iter compare is broke, use the path instead # Iter compare is broke, use the path instead
try: try:
ex, ey = view.tree_to_widget_coords(rect.x + rect.height, ex, ey = view.convert_tree_to_bin_window_coords(rect.x + \
rect.y + rect.height) rect.height, rect.y + rect.height)
end = view.get_path_at_pos(ex, ey)[0] end = view.get_path_at_pos(ex, ey)[0]
# end is the last visible, we want to query that aswell # end is the last visible, we want to query that aswell
end = (end[0] + 1,) end = (end[0] + 1,)
@ -1979,7 +1981,7 @@ class MucBrowser(AgentBrowser):
if users: if users:
self.model[iter_][3] = int(users.getValue()) self.model[iter_][3] = int(users.getValue())
self.model[iter_][4] = users.getValue() self.model[iter_][4] = users.getValue()
if descr: if descr and descr.getValue():
self.model[iter_][5] = descr.getValue() self.model[iter_][5] = descr.getValue()
# Only set these when we find a form with additional info # Only set these when we find a form with additional info
# Some servers don't support forms and put extra info in # Some servers don't support forms and put extra info in
@ -2043,8 +2045,8 @@ class DiscussionGroupsBrowser(AgentBrowser):
# <small/> font # <small/> font
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col = Gtk.TreeViewColumn(_('Name')) col = Gtk.TreeViewColumn(_('Name'))
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, markup=2) col.add_attribute(renderer, 'markup', 2)
col.set_resizable(True) col.set_resizable(True)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
self.window.services_treeview.set_headers_visible(True) self.window.services_treeview.set_headers_visible(True)
@ -2052,16 +2054,17 @@ class DiscussionGroupsBrowser(AgentBrowser):
# Subscription state # Subscription state
renderer = Gtk.CellRendererToggle() renderer = Gtk.CellRendererToggle()
col = Gtk.TreeViewColumn(_('Subscribed')) col = Gtk.TreeViewColumn(_('Subscribed'))
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, inconsistent=3, active=4) col.add_attribute(renderer, 'inconsistent', 3)
col.add_attribute(renderer, 'active', 4)
col.set_resizable(False) col.set_resizable(False)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)
# Node Column # Node Column
renderer = Gtk.CellRendererText() renderer = Gtk.CellRendererText()
col = Gtk.TreeViewColumn(_('Node')) col = Gtk.TreeViewColumn(_('Node'))
col.pack_start(renderer, True, True, 0) col.pack_start(renderer, True)
col.set_attributes(renderer, markup=1) col.add_attribute(renderer, 'markup', 1)
col.set_resizable(True) col.set_resizable(True)
self.window.services_treeview.insert_column(col, -1) self.window.services_treeview.insert_column(col, -1)

View File

@ -517,7 +517,7 @@ class GroupchatControl(ChatControlBase):
renderer.set_property(self.renderers_propertys[renderer][0], renderer.set_property(self.renderers_propertys[renderer][0],
self.renderers_propertys[renderer][1]) self.renderers_propertys[renderer][1])
def tree_compare_iters(self, model, iter1, iter2): def tree_compare_iters(self, model, iter1, iter2, data=None):
""" """
Compare two iters to sort them Compare two iters to sort them
""" """

View File

@ -254,7 +254,12 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
""" """
if value.endswith('%'): if value.endswith('%'):
val = float(value[:-1]) val = float(value[:-1])
sign = cmp(val, 0) if val > 0:
sign = 1
elif val < 0:
sign = -1
else:
sign = 0
# limits: 1% to 500% # limits: 1% to 500%
val = sign*max(1, min(abs(val), 500)) val = sign*max(1, min(abs(val), 500))
frac = val/100 frac = val/100
@ -279,7 +284,12 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
def get_val(): def get_val():
val = float(value[:-2]) val = float(value[:-2])
sign = cmp(val, 0) if val > 0:
sign = 1
elif val < 0:
sign = -1
else:
sign = 0
# validate length # validate length
return sign*max(minl, min(abs(val*display_resolution), maxl)) return sign*max(minl, min(abs(val*display_resolution), maxl))
if value.endswith('pt'): # points if value.endswith('pt'): # points
@ -304,7 +314,12 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
try: try:
# TODO: isn't "no units" interpreted as pixels? # TODO: isn't "no units" interpreted as pixels?
val = int(value) val = int(value)
sign = cmp(val, 0) if val > 0:
sign = 1
elif val < 0:
sign = -1
else:
sign = 0
# validate length # validate length
val = sign*max(minl, min(abs(val), maxl)) val = sign*max(minl, min(abs(val), maxl))
callback(val, *args) callback(val, *args)