Commit af6450bc authored by sb's avatar sb

add context menu for zeroconf account

parent d45aaa85
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkMenu" id="zeroconf_context_menu">
<child>
<widget class="GtkImageMenuItem" id="status_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Status</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1251">
<property name="visible">True</property>
<property name="stock">gtk-network</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="join_group_chat_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Group Chat</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1252">
<property name="visible">True</property>
<property name="stock">gtk-connect</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="new_message_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">Send Single _Message...</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1253">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="zeroconf_properties_menuitem">
<property name="visible">True</property>
<property name="label" translatable="yes">_Zeroconf Properties...</property>
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1254">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</glade-interface>
......@@ -101,13 +101,15 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
gajim.config.set_per('accounts', 'zeroconf', 'no_log_for', False)
gajim.config.set_per('accounts', 'zeroconf', 'password', 'zeroconf')
gajim.config.set_per('accounts', 'zeroconf', 'sync_with_global_status', True)
username = unicode(getpass.getuser())
gajim.config.set_per('accounts', 'zeroconf', 'name', username)
#XXX make sure host is US-ASCII
host = unicode(socket.gethostname())
gajim.config.set_per('accounts', 'zeroconf', 'hostname', host)
port = 5298
gajim.config.set_per('accounts', 'zeroconf', 'custom_port', 5298)
gajim.config.set_per('accounts', 'zeroconf', 'custom_port', port)
gajim.config.set_per('accounts', 'zeroconf', 'is_zeroconf', True)
else:
username = gajim.config.get_per('accounts', 'zeroconf', 'name')
host = gajim.config.get_per('accounts', 'zeroconf', 'hostname')
......
......@@ -1842,6 +1842,7 @@ class AccountsWindow:
model = self.accounts_treeview.get_model()
model.clear()
for account in gajim.connections:
# if account != 'zeroconf':
iter = model.append()
model.set(iter, 0, account, 1, gajim.get_hostname_from_account(account))
......
......@@ -1746,6 +1746,14 @@ class RosterWindow:
gajim.interface.instances[account]['account_modification'] = \
config.AccountModificationWindow(account)
def on_zeroconf_properties(self, widget, account):
if gajim.interface.instances.has_key('zeroconf_properties'):
gajim.interface.instances['zeroconf_properties'].\
window.present()
else:
gajim.interface.instances['zeroconf_properties'] = \
config.ZeroconfPropertiesWindow()
def on_open_gmail_inbox(self, widget, account):
if gajim.config.get_per('accounts', account, 'savepass'):
url = ('http://www.google.com/accounts/ServiceLoginAuth?service=mail&Email=%s&Passwd=%s&continue=https://mail.google.com/mail') %\
......@@ -1771,6 +1779,7 @@ class RosterWindow:
path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
state_images = self.load_iconset(path)
if not gajim.config.get_per('accounts', account, 'is_zeroconf'):
xml = gtkgui_helpers.get_glade('account_context_menu.glade')
account_context_menu = xml.get_widget('account_context_menu')
......@@ -1835,6 +1844,56 @@ class RosterWindow:
for widget in [add_contact_menuitem, service_discovery_menuitem,
join_group_chat_menuitem, new_message_menuitem]:
widget.set_sensitive(False)
else:
xml = gtkgui_helpers.get_glade('zeroconf_context_menu.glade')
account_context_menu = xml.get_widget('zeroconf_context_menu')
status_menuitem = xml.get_widget('status_menuitem')
join_group_chat_menuitem =xml.get_widget('join_group_chat_menuitem')
new_message_menuitem = xml.get_widget('new_message_menuitem')
zeroconf_properties_menuitem = xml.get_widget('zeroconf_properties_menuitem')
sub_menu = gtk.Menu()
status_menuitem.set_submenu(sub_menu)
for show in ('online', 'away', 'dnd', 'invisible'):
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
item = gtk.ImageMenuItem(uf_show)
icon = state_images[show]
item.set_image(icon)
sub_menu.append(item)
item.connect('activate', self.change_status, account, show)
item = gtk.SeparatorMenuItem()
sub_menu.append(item)
item = gtk.ImageMenuItem(_('_Change Status Message'))
path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png')
img = gtk.Image()
img.set_from_file(path)
item.set_image(img)
sub_menu.append(item)
item.connect('activate', self.on_change_status_message_activate, account)
if gajim.connections[account].connected < 2:
item.set_sensitive(False)
uf_show = helpers.get_uf_show('offline', use_mnemonic = True)
item = gtk.ImageMenuItem(uf_show)
icon = state_images['offline']
item.set_image(icon)
sub_menu.append(item)
item.connect('activate', self.change_status, account, 'offline')
zeroconf_properties_menuitem.connect('activate', self.on_zeroconf_properties, account)
gc_sub_menu = gtk.Menu() # gc is always a submenu
join_group_chat_menuitem.set_submenu(gc_sub_menu)
self.add_bookmarks_list(gc_sub_menu, account)
new_message_menuitem.connect('activate',
self.on_new_message_menuitem_activate, account)
# make some items insensitive if account is offline
if gajim.connections[account].connected < 2:
for widget in [join_group_chat_menuitem, new_message_menuitem]:
widget.set_sensitive(False)
return account_context_menu
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment