Daniel Brötzmann pushed to branch master at gajim / gajim
Commits: eeacc0c8 by wurstsalat at 2022-03-04T20:11:43+01:00 ContactInfo: Add ContactSettings
- - - - - 88709300 by wurstsalat at 2022-03-04T20:59:07+01:00 ContactInfo: Add Remove History button
- - - - -
4 changed files:
- gajim/data/gui/contact_info.ui - gajim/gtk/builder.pyi - gajim/gtk/contact_info.py - + gajim/gtk/contact_settings.py
Changes:
===================================== gajim/data/gui/contact_info.ui ===================================== @@ -417,78 +417,35 @@ </packing> </child> <child> - <object class="GtkBox" id="settings_box"> + <object class="GtkScrolledWindow" id="settings_scrolled"> <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">18</property> + <property name="can-focus">True</property> + <property name="hscrollbar-policy">never</property> <child> - <object class="GtkListBox" id="subscription_listbox"> - <property name="width-request">400</property> + <object class="GtkViewport"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="halign">center</property> - <property name="selection-mode">none</property> - <child> - <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> - <property name="can-focus">False</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">end</property> - <property name="label" translatable="yes">Share my online status</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkSwitch" id="from_subscription_switch"> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="halign">end</property> - <property name="valign">center</property> - <signal name="state-set" handler="_on_from_subscription_switch_toggled" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack-type">end</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - </child> <child> - <object class="GtkListBoxRow"> + <object class="GtkBox" id="settings_box"> <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="activatable">False</property> - <property name="selectable">False</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">24</property> <child> <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> <child> <object class="GtkLabel"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="halign">end</property> - <property name="margin-end">24</property> - <property name="label" translatable="yes">I can see contact's online status</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Status</property> + <style> + <class name="bold"/> + </style> </object> <packing> <property name="expand">False</property> @@ -497,54 +454,28 @@ </packing> </child> <child> - <object class="GtkBox"> + <object class="GtkListBox" id="subscription_listbox"> + <property name="width-request">400</property> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="halign">end</property> - <property name="spacing">12</property> + <property name="no-show-all">True</property> + <property name="selection-mode">none</property> <child> - <object class="GtkStack" id="to_subscription_stack"> + <object class="GtkListBoxRow"> <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="no-show-all">True</property> - <property name="halign">end</property> - <property name="valign">center</property> - <property name="transition-type">crossfade</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> <property name="can-focus">False</property> - <property name="halign">end</property> - <property name="spacing">12</property> <child> - <object class="GtkStack" id="request_stack"> + <object class="GtkLabel"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="transition-type">crossfade</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="tooltip-text" translatable="yes">You cannot see this contact's online status</property> - <property name="halign">center</property> - <property name="icon-name">window-close-symbolic</property> - </object> - <packing> - <property name="name">cross</property> - </packing> - </child> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="tooltip-text" translatable="yes">You requested to see this contact's online status</property> - <property name="icon-name">document-open-recent-symbolic</property> - </object> - <packing> - <property name="name">requested</property> - <property name="position">1</property> - </packing> - </child> + <property name="halign">end</property> + <property name="label" translatable="yes">Share my online status</property> </object> <packing> <property name="expand">False</property> @@ -553,73 +484,232 @@ </packing> </child> <child> - <object class="GtkButton" id="to_subscription_button"> - <property name="label" translatable="yes">_Request</property> + <object class="GtkSwitch" id="from_subscription_switch"> <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="tooltip-text" translatable="yes">Request to see this contact's online status</property> + <property name="halign">end</property> <property name="valign">center</property> - <property name="use-underline">True</property> - <signal name="clicked" handler="_on_to_subscription_button_clicked" swapped="no"/> + <signal name="state-set" handler="_on_from_subscription_switch_toggled" swapped="no"/> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> + <property name="pack-type">end</property> <property name="position">1</property> </packing> </child> </object> - <packing> - <property name="name">request</property> - </packing> </child> + </object> + </child> + <child> + <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="GtkImage"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can-focus">False</property> - <property name="tooltip-text" translatable="yes">You can see the contact's online status</property> - <property name="halign">end</property> - <property name="icon-name">object-select-symbolic</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">end</property> + <property name="margin-end">24</property> + <property name="label" translatable="yes">I can see contact's online status</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">end</property> + <property name="spacing">12</property> + <child> + <object class="GtkStack" id="to_subscription_stack"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="transition-type">crossfade</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">end</property> + <property name="spacing">12</property> + <child> + <object class="GtkStack" id="request_stack"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="transition-type">crossfade</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="tooltip-text" translatable="yes">You cannot see this contact's online status</property> + <property name="halign">center</property> + <property name="icon-name">window-close-symbolic</property> + </object> + <packing> + <property name="name">cross</property> + </packing> + </child> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="tooltip-text" translatable="yes">You requested to see this contact's online status</property> + <property name="icon-name">document-open-recent-symbolic</property> + </object> + <packing> + <property name="name">requested</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <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="tooltip-text" translatable="yes">Request to see this contact's online status</property> + <property name="valign">center</property> + <property name="use-underline">True</property> + <signal name="clicked" handler="_on_to_subscription_button_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="name">request</property> + </packing> + </child> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="tooltip-text" translatable="yes">You can see the contact's online status</property> + <property name="halign">end</property> + <property name="icon-name">object-select-symbolic</property> + </object> + <packing> + <property name="name">checkmark</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack-type">end</property> + <property name="position">1</property> + </packing> + </child> </object> - <packing> - <property name="name">checkmark</property> - <property name="position">1</property> - </packing> </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> + <style> + <class name="settings"/> + </style> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="pack-type">end</property> <property name="position">1</property> </packing> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> </child> + <child> + <object class="GtkBox" id="contact_settings_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Privacy</property> + <style> + <class name="bold"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="remove_history_button"> + <property name="label" translatable="yes">Remove History…</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="halign">start</property> + <style> + <class name="destructive-action"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <style> + <class name="padding-18"/> + </style> </object> </child> - <style> - <class name="settings"/> - </style> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> - <style> - <class name="padding-18"/> - </style> </object> <packing> <property name="name">settings</property>
===================================== gajim/gtk/builder.pyi ===================================== @@ -282,12 +282,15 @@ class ContactInfoBuilder(Builder): group_chat_grid: Gtk.Grid role_label: Gtk.Label affiliation_label: Gtk.Label + settings_scrolled: Gtk.ScrolledWindow settings_box: Gtk.Box subscription_listbox: Gtk.ListBox from_subscription_switch: Gtk.Switch to_subscription_stack: Gtk.Stack request_stack: Gtk.Stack to_subscription_button: Gtk.Button + contact_settings_box: Gtk.Box + remove_history_button: Gtk.Button groups_page_box: Gtk.Box groups_treeview: Gtk.TreeView tree_selection: Gtk.TreeSelection
===================================== gajim/gtk/contact_info.py ===================================== @@ -21,10 +21,11 @@ import logging from enum import IntEnum
-from gi.repository import Gtk + from gi.repository import Gdk from gi.repository import GdkPixbuf from gi.repository import GObject +from gi.repository import Gtk
from nbxmpp.task import Task from nbxmpp.errors import StanzaError @@ -45,12 +46,14 @@ from gajim.common.modules.contacts import ResourceContact from gajim.common.modules.contacts import GroupchatParticipant
+from .contact_settings import ContactSettings from .dialogs import ConfirmationDialog from .dialogs import DialogButton from .sidebar_switcher import SideBarSwitcher from .builder import get_builder from .util import connect_destroy from .vcard_grid import VCardGrid +from .structs import RemoveHistoryActionParams
log = logging.getLogger('gajim.gui.contact_info')
@@ -210,6 +213,14 @@ def _fill_settings_page(self, contact: BareContact) -> None: self._ui.request_stack.set_visible_child_name('cross')
self._switcher.set_row_visible('settings', True) + contact_settings = ContactSettings(self.account, contact.jid) + self._ui.contact_settings_box.add(contact_settings) + + params = RemoveHistoryActionParams( + account=self.account, jid=self.contact.jid) + self._ui.remove_history_button.set_action_name('app.remove-history') + self._ui.remove_history_button.set_action_target_value( + params.to_variant())
def _fill_groups_page(self, contact: BareContact) -> None: if not contact.is_in_roster:
===================================== gajim/gtk/contact_settings.py ===================================== @@ -0,0 +1,58 @@ +# This file is part of Gajim. +# +# Gajim is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 3 only. +# +# Gajim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Gajim. If not, see http://www.gnu.org/licenses/. + +from gi.repository import Gtk + +from nbxmpp.protocol import JID + +from gajim.common.i18n import _ + +from .const import Setting +from .const import SettingKind +from .const import SettingType +from .settings import SettingsBox + + +class ContactSettings(SettingsBox): + def __init__(self, account: str, jid: JID) -> None: + SettingsBox.__init__(self, account, str(jid)) + + self.get_style_context().add_class('settings-border') + self.set_selection_mode(Gtk.SelectionMode.NONE) + self.set_valign(Gtk.Align.START) + self.set_halign(Gtk.Align.CENTER) + + chat_state = { + 'disabled': _('Disabled'), + 'composing_only': _('Composing Only'), + 'all': _('All Chat States') + } + + settings: list[Setting] = [ + Setting(SettingKind.POPOVER, + _('Send Chat State'), + SettingType.CONTACT, + 'send_chatstate', + props={'entries': chat_state}), + + Setting(SettingKind.SWITCH, + _('Send Chat Markers'), + SettingType.CONTACT, + 'send_marker', + desc=_('Let others know if you read up to this point')), + ] + + for setting in settings: + self.add_setting(setting) + self.update_states()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/257991159c4b25a15afc975d3a4c6287...