Commit 4f9c6165 authored by Yann Leboulanger's avatar Yann Leboulanger

edit dialog windows code is now available

parent 68d0f517
......@@ -208,6 +208,84 @@ class vcard_information_window:
self.xml.signal_autoconnect(self)
class Edit_groups_dialog:
"""Class for the edit group dialog window"""
def __init__(self, user, account, plugin):
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'edit_groups_dialog', APP)
self.dialog = self.xml.get_widget('edit_groups_dialog')
self.plugin = plugin
self.account = account
self.user = user
self.list = self.xml.get_widget('groups_treeview')
self.xml.get_widget('nickname_label').set_text(_('<b>Edit groups for %s</b>') % user.name)
self.xml.get_widget('jid_label').set_text(user.jid)
self.xml.signal_autoconnect(self)
self.init_list()
def run(self):
self.dialog.run()
self.dialog.destroy()
#TODO: send to the core
def update_user(self):
luser = self.plugin.roster.contacts[self.account][self.user.jid]
for u in luser:
self.plugin.roster.remove_user(u, self.account)
self.plugin.roster.add_user_to_roster(self.user.jid, self.account)
def on_add_button_clicked(self, widget):
group = self.xml.get_widget('group_entry').get_text()
if not group:
return
# check if it already exists
model = self.list.get_model()
iter = model.get_iter_root()
while iter:
if model.get_value(iter, 0) == group:
return
iter = model.iter_next(iter)
model.append((group, True))
self.user.groups.append(group)
self.update_user()
def group_toggled_cb(self, cell, path):
model = self.list.get_model()
if model[path][1] and len(self.user.groups) == 1: # we try to remove
# the latest group
Error_dialog(_('There must be at least one group for each contact'))
#TODO: re-set the checkbutton
return
model[path][1] = not model[path][1]
if model[path][1]:
self.user.groups.append(model[path][0])
else:
self.user.groups.remove(model[path][0])
self.update_user()
def init_list(self):
store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN)
self.list.set_model(store)
for g in self.plugin.roster.groups[self.account].keys():
iter = store.append()
store.set(iter, 0, g)
if g in self.user.groups:
store.set(iter, 1, True)
else:
store.set(iter, 1, False)
column = gtk.TreeViewColumn(_('Group'))
self.list.append_column(column)
renderer = gtk.CellRendererText()
column.pack_start(renderer)
column.set_attributes(renderer, text=0)
column = gtk.TreeViewColumn(_('In the group'))
self.list.append_column(column)
renderer = gtk.CellRendererToggle()
column.pack_start(renderer)
renderer.set_property('activatable', True)
renderer.connect('toggled', self.group_toggled_cb)
column.set_attributes(renderer, active=1)
class Passphrase_dialog:
"""Class for Passphrase dialog"""
def run(self):
......
......@@ -8376,42 +8376,15 @@ Custom</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="applybutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-apply</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-10</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton1">
<widget class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<property name="response_id">-7</property>
</widget>
</child>
</widget>
......@@ -8439,7 +8412,7 @@ Custom</property>
<child>
<widget class="GtkLabel" id="nickname_label">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Edit groups for Nickname&lt;/b&gt;</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
......@@ -8460,7 +8433,7 @@ Custom</property>
<child>
<widget class="GtkLabel" id="jid_label">
<property name="visible">True</property>
<property name="label" translatable="yes">jid_label</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
......@@ -8492,7 +8465,7 @@ Custom</property>
<property name="spacing">5</property>
<child>
<widget class="GtkEntry" id="entry2">
<widget class="GtkEntry" id="group_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
......@@ -8511,13 +8484,14 @@ Custom</property>
</child>
<child>
<widget class="GtkButton" id="button32">
<widget class="GtkButton" id="add_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-add</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_add_button_clicked" last_modification_time="Thu, 17 Mar 2005 11:40:17 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
......
......@@ -403,6 +403,10 @@ class roster_window:
model.set_value(iter, 5, True)
self.tree.set_cursor(path, self.tree.get_column(0), True)
def on_edit_groups(self, widget, user, account):
dlg = Edit_groups_dialog(user, account, self.plugin)
dlg.run()
def on_history(self, widget, user):
"""When history button is pressed : call log window"""
if not self.plugin.windows['logs'].has_key(user.jid):
......@@ -418,41 +422,44 @@ class roster_window:
user = self.contacts[account][jid][0]
menu = gtk.Menu()
item = gtk.MenuItem(_("Start chat"))
item = gtk.MenuItem(_('Start chat'))
menu.append(item)
item.connect('activate', self.on_roster_treeview_row_activated, path)
item = gtk.MenuItem(_('Rename'))
menu.append(item)
item.connect("activate", self.on_roster_treeview_row_activated, path)
item = gtk.MenuItem(_("Rename"))
item.connect('activate', self.on_rename, iter, path)
item = gtk.MenuItem(_('Edit groups'))
menu.append(item)
item.connect("activate", self.on_rename, iter, path)
item.connect('activate', self.on_edit_groups, user, account)
item = gtk.MenuItem()
menu.append(item)
item = gtk.MenuItem(_("Subscription"))
item = gtk.MenuItem(_('Subscription'))
menu.append(item)
sub_menu = gtk.Menu()
item.set_submenu(sub_menu)
item = gtk.MenuItem(_("Resend authorization to"))
item = gtk.MenuItem(_('Resend authorization to'))
sub_menu.append(item)
item.connect("activate", self.authorize, jid, account)
item = gtk.MenuItem(_("Rerequest authorization from"))
item.connect('activate', self.authorize, jid, account)
item = gtk.MenuItem(_('Rerequest authorization from'))
sub_menu.append(item)
item.connect("activate", self.req_sub, jid, \
item.connect('activate', self.req_sub, jid, \
_('I would like to add you to my contact list, please.'), account)
item = gtk.MenuItem()
menu.append(item)
item = gtk.MenuItem(_("Remove"))
item = gtk.MenuItem(_('Remove'))
menu.append(item)
item.connect("activate", self.on_req_usub, user, account)
item.connect('activate', self.on_req_usub, user, account)
item = gtk.MenuItem()
menu.append(item)
item = gtk.MenuItem(_("Information"))
item = gtk.MenuItem(_('Information'))
menu.append(item)
item.connect("activate", self.on_info, user, account)
item = gtk.MenuItem(_("History"))
item.connect('activate', self.on_info, user, account)
item = gtk.MenuItem(_('History'))
menu.append(item)
item.connect("activate", self.on_history, user)
item.connect('activate', self.on_history, user)
menu.popup(None, None, None, event.button, event.time)
menu.show_all()
......@@ -478,25 +485,25 @@ class roster_window:
path = model.get_path(iter)
account = model.get_value(iter, 4)
menu = gtk.Menu()
item = gtk.MenuItem(_("Log on"))
item = gtk.MenuItem(_('Log on'))
if self.contacts[account][jid][0].show != 'offline':
item.set_sensitive(False)
menu.append(item)
item.connect("activate", self.on_agent_logging, jid, 'available', account)
item.connect('activate', self.on_agent_logging, jid, 'available', account)
item = gtk.MenuItem(_("Log off"))
item = gtk.MenuItem(_('Log off'))
if self.contacts[account][jid][0].show == 'offline':
item.set_sensitive(False)
menu.append(item)
item.connect("activate", self.on_agent_logging, jid, 'unavailable', \
item.connect('activate', self.on_agent_logging, jid, 'unavailable', \
account)
item = gtk.MenuItem()
menu.append(item)
item = gtk.MenuItem(_("Remove"))
item = gtk.MenuItem(_('Remove'))
menu.append(item)
item.connect("activate", self.on_remove_agent, jid, account)
item.connect('activate', self.on_remove_agent, jid, account)
menu.popup(None, None, None, event.button, event.time)
menu.show_all()
......
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