Commit 3b2104bd authored by Sophie Herold's avatar Sophie Herold
Browse files

Last missing functionality

parent 9644fab0
Pipeline #2143 passed with stages
in 2 minutes and 13 seconds
......@@ -2,41 +2,6 @@
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow">
<property name="can_focus">False</property>
<child>
<object class="GtkStack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
<object class="GtkListStore" id="groups_model">
<columns>
<!-- column-name in_group -->
......@@ -93,6 +58,9 @@
<property name="can_focus">False</property>
<property name="pixel_size">36</property>
<property name="icon_name">avatar-default</property>
<style>
<class name="image-shadow"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......@@ -371,6 +339,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Change display name</property>
<signal name="clicked" handler="on_edit_shown_name_button_clicked" swapped="no"/>
<child>
<object class="GtkImage">
......@@ -472,6 +441,7 @@
</child>
<child>
<object class="GtkListBox">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
......@@ -480,6 +450,8 @@
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......@@ -489,7 +461,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Reveal my online status</property>
<property name="label" translatable="yes">Contact can see my online status</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -498,28 +470,12 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkSwitch" id="from_subscription_switch">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkSwitch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
<property name="valign">center</property>
<signal name="notify::active" handler="on_from_subscription_switch_active_notify" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
......@@ -536,6 +492,8 @@
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activatable">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
......@@ -546,7 +504,7 @@
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_right">24</property>
<property name="label" translatable="yes">See contacts online status</property>
<property name="label" translatable="yes">I can see contacts online status</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -561,7 +519,7 @@
<property name="halign">end</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="to_subscription_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Not granted</property>
......@@ -576,12 +534,34 @@
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Request…</property>
<object class="GtkStack" id="to_subscription_stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="transition_type">crossfade</property>
<child>
<object class="GtkButton" id="to_subscription_button">
<property name="label" translatable="yes">Request</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="valign">center</property>
<signal name="clicked" handler="on_to_subscription_button_clicked" swapped="no"/>
</object>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="icon_name">object-select-symbolic.symbolic</property>
</object>
<packing>
<property name="name">checkmark</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -611,9 +591,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkGrid" id="var_grid">
<property name="visible">True</property>
......@@ -621,19 +598,7 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkBox">
<property name="width_request">6</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
<placeholder/>
</child>
</object>
<packing>
......@@ -642,9 +607,6 @@
<property name="position">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
......@@ -658,9 +620,10 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkBox" id="groups_page_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="margin_left">18</property>
<property name="margin_right">18</property>
<property name="margin_top">24</property>
......@@ -886,7 +849,6 @@
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
......@@ -913,6 +875,27 @@
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -210,7 +210,7 @@ treeview.space { padding: 6px; }
button.flat.link { padding: 0; border: 0; }
/* Images */
.image-shadow { box-shadow: 1px 1px 2px; }
.image-shadow { box-shadow: @borders 1px 1px 2px; }
/*MessageWindow Notebook*/
.notebook-tab-label {min-width: 80px}
......
......@@ -99,6 +99,8 @@ class ContactInfo:
self.vcard = {'default': {}}
self.clients = {}
self.ui.from_subscription_switch.gajim_ignore_next = None
# Get real jid
if gc_contact:
# Don't use real jid if room is (semi-)anonymous
......@@ -113,13 +115,12 @@ class ContactInfo:
self.real_jid = gc_contact.get_full_jid()
self.real_jid_for_vcard = self.real_jid
self.real_resource = gc_contact.name
self.ui.groups_page_box.hide()
else:
self.real_jid = contact.get_full_jid()
self.real_resource = contact.resource
self.vcard_arrived = False
self.os_info_arrived = False
self.entity_time_arrived = False
self.time = 0
self.fill_jabber_page()
......@@ -158,6 +159,44 @@ class ContactInfo:
def destroy(self):
self.ui.window.destroy()
def on_from_subscription_switch_active_notify(self, widget, *args):
if widget.gajim_ignore_next is not None:
if widget.get_active() == widget.gajim_ignore_next:
widget.gajim_ignore_next = None
return
if widget.get_active():
app.connections[self.account].get_module('Presence').subscribed(
self.contact.jid)
else:
dialog = Gtk.MessageDialog(None,
0,
Gtk.MessageType.QUESTION,
Gtk.ButtonsType.NONE,
_('No longer show online status to contact? '));
dialog.set_transient_for(self.ui.window)
dialog.format_secondary_text(
_('The contact will be informed that you stopped sharing your status with them.'))
dialog.add_button(_('Cancel'), 1)
dialog.add_button(_('Stop showing online status'), 2)
result = dialog.run()
dialog.destroy()
if result == 2:
app.connections[self.account].get_module('Presence').unsubscribed(
self.contact.jid)
else:
widget.gajim_ignore_next = True
widget.set_active(True)
def on_to_subscription_button_clicked(self, *args):
app.connections[self.account].get_module('Presence').subscribe(
self.contact.jid)
self.ui.to_subscription_stack.set_visible_child_name('checkmark')
def on_groups_treeview_selection_changed(self, *args):
(_, iter_) = self.ui.groups_treeview.get_selection().get_selected()
self.ui.group_edit_button.set_sensitive(bool(iter_))
......@@ -452,6 +491,12 @@ class ContactInfo:
for key, client in self.clients.items():
self.client_grid.add_header(_('Resource "{}"').format(key))
self.client_grid.add_value(_('Priority'), str(client['priority']))
if client.get('status'):
self.client_grid.add_value(_('Status'),
helpers.get_uf_show(client['status']))
if client.get('message'):
self.client_grid.add_value(_('Status Message'),
client['message'])
if client.get('client'):
self.client_grid.add_value(_('Software'), client['client'])
if client.get('os'):
......@@ -478,36 +523,22 @@ class ContactInfo:
self.rebuild_client_grid()
def fill_status_label(self):
contact_list = app.contacts.get_contacts(self.account, self.contact.jid)
connected_contact_list = []
for c in contact_list:
if c.show not in ('offline', 'error'):
connected_contact_list.append(c)
if not connected_contact_list:
# no connected contact, get the offline one
connected_contact_list = contact_list
# stats holds show and status message
stats = ''
if connected_contact_list:
# Start with self.contact, as with resources
stats = helpers.get_uf_show(self.contact.show)
if self.contact.status:
stats += ': ' + self.contact.status
for c in connected_contact_list:
if c.resource != self.contact.resource:
stats += '\n'
stats += helpers.get_uf_show(c.show)
if c.status:
stats += ': ' + c.status
else: # Maybe gc_vcard ?
stats = helpers.get_uf_show(self.contact.show)
if self.contact.status:
stats += ': ' + self.contact.status
status_label = self.ui.status_label
status_label.set_text(stats)
status_label.set_tooltip_text(stats)
def show(status, message, **kwargs):
if message:
return '{}: {}'.format(helpers.get_uf_show(status), message)
else:
return helpers.get_uf_show(status)
def fill_jabber_page(self):
stats = list(map(lambda x: show(**x), self.clients.values()))
if len(set(stats)) == 1:
stats_str = stats[0]
else:
stats_str = '\n'.join(stats)
self.ui.status_label.set_text(stats_str)
def fill_information_page(self):
self.ui.shown_name_label.set_text(self.contact.get_shown_name())
self.ui.shown_name_entry.set_text(self.contact.get_shown_name())
self.ui.header_shown_name_label.set_text(self.contact.get_shown_name())
......@@ -521,22 +552,22 @@ class ContactInfo:
self._add_to_vcard('group_chat', 'AFFILIATION',
helpers.get_uf_affiliation(self.gc_contact.affiliation))
else:
uf_sub = helpers.get_uf_sub(self.contact.sub)
if self.contact.sub == 'from':
tt_text = _("This contact is interested in your presence information, but you are not interested in their presence.")
elif self.contact.sub == 'to':
tt_text = _("You are interested in the contact's presence information, but it is not mutual.")
elif self.contact.sub == 'both':
tt_text = _("The contact and you want to exchange presence information.")
else: # None
tt_text = _("You and the contact have a mutual disinterest in each-others presence information.")
uf_ask = helpers.get_uf_ask(self.contact.ask)
if self.contact.ask == 'subscribe':
tt_text += ' ' + _("You are waiting contact's answer about your subscription request")
elif self.contact.sub != 'both':
tt_text += ' ' + _("There is no pending subscription request.")
if self.contact.sub in ('from', 'both'):
self.ui.from_subscription_switch.gajim_ignore_next = True
self.ui.from_subscription_switch.set_active(True)
if self.contact.sub in ('to', 'both'):
self.ui.to_subscription_label.set_text(_('Yes'))
self.ui.to_subscription_stack.hide()
elif self.contact.ask == 'subscribe':
self.ui.to_subscription_label.set_text(_('Requested'))
self.ui.to_subscription_button.set_label(_('Request Again'))
else:
self.ui.to_subscription_label.set_text(_('No'))
self.fill_status_label()
def fill_jabber_page(self):
if not self.contact.status:
self.contact.status = ''
......@@ -570,19 +601,27 @@ class ContactInfo:
GLib.idle_add(con.get_module('EntityTime').request_entity_time,
self.contact.jid, self.contact.resource)
self.clients[self.real_resource] = {'priority': self.contact.priority}
self.clients[self.real_resource] = {
'priority': self.contact.priority,
'status': self.contact.show,
'message': self.contact.status
}
contact_list = app.contacts.get_contacts(self.account, self.contact.jid)
if contact_list:
for c in contact_list:
if c.resource != self.contact.resource:
self.clients[c.resource] = {'priority': c.priority}
self.clients[c.resource] = {
'priority': c.priority,
'status': c.show,
'message': c.status
}
if c.show not in ('offline', 'error'):
GLib.idle_add(con.get_module('SoftwareVersion').request_os_info,
c.jid, c.resource)
GLib.idle_add(con.get_module('EntityTime').request_entity_time,
c.jid, c.resource)
self.fill_status_label()
self.fill_information_page()
if self.gc_contact:
con.get_module('VCardTemp').request_vcard(
......@@ -593,19 +632,6 @@ class ContactInfo:
con.get_module('VCardTemp').request_vcard(
self._nec_vcard_received, self.contact.jid)
class ListBoxSimple:
def __init__(self, listbox):
self.listbox = listbox
def add_row(self, key, text):
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
row.add(hbox)
label = Gtk.Label(text)
hbox.pack_start(label, False, False, 0)
row.gajim_id = key
self.listbox.add(row)
class InfoGrid:
......
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