diff options
Diffstat (limited to 'plugins/omemo')
-rw-r--r-- | plugins/omemo/CMakeLists.txt | 3 | ||||
-rw-r--r-- | plugins/omemo/data/contact_details_dialog.ui | 161 | ||||
-rw-r--r-- | plugins/omemo/data/manage_key_dialog.ui | 223 | ||||
-rw-r--r-- | plugins/omemo/src/logic/trust_manager.vala | 2 | ||||
-rw-r--r-- | plugins/omemo/src/ui/account_settings_entry.vala | 54 | ||||
-rw-r--r-- | plugins/omemo/src/ui/account_settings_widget.vala | 54 | ||||
-rw-r--r-- | plugins/omemo/src/ui/bad_messages_populator.vala | 6 | ||||
-rw-r--r-- | plugins/omemo/src/ui/contact_details_dialog.vala | 57 | ||||
-rw-r--r-- | plugins/omemo/src/ui/contact_details_provider.vala | 6 | ||||
-rw-r--r-- | plugins/omemo/src/ui/device_notification_populator.vala | 8 | ||||
-rw-r--r-- | plugins/omemo/src/ui/encryption_list_entry.vala | 8 | ||||
-rw-r--r-- | plugins/omemo/src/ui/manage_key_dialog.vala | 28 |
12 files changed, 270 insertions, 340 deletions
diff --git a/plugins/omemo/CMakeLists.txt b/plugins/omemo/CMakeLists.txt index 195001cb..dc9a93b0 100644 --- a/plugins/omemo/CMakeLists.txt +++ b/plugins/omemo/CMakeLists.txt @@ -9,7 +9,7 @@ find_packages(OMEMO_PACKAGES REQUIRED GLib GModule GObject - GTK3 + GTK4 ) set(RESOURCE_LIST @@ -53,7 +53,6 @@ SOURCES src/protocol/stream_module.vala src/ui/account_settings_entry.vala - src/ui/account_settings_widget.vala src/ui/bad_messages_populator.vala src/ui/call_encryption_entry.vala src/ui/contact_details_provider.vala diff --git a/plugins/omemo/data/contact_details_dialog.ui b/plugins/omemo/data/contact_details_dialog.ui index 62aded6b..fdb9f1cf 100644 --- a/plugins/omemo/data/contact_details_dialog.ui +++ b/plugins/omemo/data/contact_details_dialog.ui @@ -1,28 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> + <requires lib="gtk" version="4.0"/> <template class="DinoPluginsOmemoContactDetailsDialog"> <property name="modal">True</property> <property name="resizable">False</property> - <child internal-child="vbox"> + <child internal-child="content_area"> <object class="GtkBox"> - <property name="visible">True</property> - <property name="margin">12</property> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> <property name="spacing">12</property> <child> <object class="GtkFrame"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkListBox"> - <property name="visible">True</property> <property name="selection-mode">none</property> <child> <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="activatable">False</property> - <child> + <property name="activatable">0</property> + <property name="child"> <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> <property name="margin-start">20</property> <property name="margin-end">20</property> <property name="margin-top">14</property> @@ -30,27 +28,25 @@ <property name="spacing">40</property> <child> <object class="GtkBox"> - <property name="visible">True</property> <property name="orientation">vertical</property> - <property name="hexpand">True</property> + <property name="hexpand">1</property> <child> <object class="GtkLabel" id="automatically_accept_new_label"> - <property name="visible">True</property> <property name="halign">start</property> <attributes> - <attribute name="scale" value="1.1"/> + <attribute name="scale" value="1.1"></attribute> </attributes> </object> </child> <child> <object class="GtkLabel" id="automatically_accept_new_descr"> - <property name="visible">True</property> <property name="max_width_chars">1</property> - <property name="expand">True</property> + <property name="hexpand">1</property> + <property name="vexpand">1</property> <property name="xalign">0</property> - <property name="wrap">True</property> + <property name="wrap">1</property> <attributes> - <attribute name="scale" value="0.8"/> + <attribute name="scale" value="0.8"></attribute> </attributes> <style> <class name="dim-label"/> @@ -61,92 +57,73 @@ </child> <child> <object class="GtkSwitch" id="auto_accept_switch"> - <property name="visible">True</property> <property name="halign">end</property> <property name="valign">center</property> </object> </child> </object> - </child> + </property> </object> </child> </object> - </child> + </property> </object> </child> <child> <object class="GtkBox" id="own_fingerprint_container"> - <property name="visible">False</property> + <property name="visible">0</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child> <object class="GtkLabel" id="own_key_label"> - <property name="visible">True</property> <property name="halign">start</property> <attributes> - <attribute name="weight" value="PANGO_WEIGHT_BOLD"/> + <attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute> </attributes> </object> </child> <child> <object class="GtkFrame"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkListBox"> - <property name="visible">True</property> <property name="selection-mode">none</property> <child> <object class="GtkListBoxRow"> - <property name="visible">True</property> - <property name="activatable">False</property> - <property name="hexpand">True</property> - <child> + <property name="activatable">0</property> + <property name="hexpand">1</property> + <property name="child"> <object class="GtkBox"> - <property name="visible">True</property> <property name="margin-start">20</property> <property name="margin-end">20</property> <property name="margin-top">14</property> <property name="spacing">40</property> <property name="margin-bottom">14</property> - <property name="orientation">horizontal</property> - <property name="hexpand">True</property> + <property name="hexpand">1</property> <child> <object class="GtkLabel" id="own_fingerprint_label"> - <property name="visible">True</property> <property name="halign">start</property> <property name="justify">right</property> - <property name="hexpand">True</property> + <property name="hexpand">1</property> </object> </child> <child> <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="hexpand">True</property> + <property name="hexpand">1</property> <property name="spacing">5</property> <child> - <object class="GtkButton" id="show_qrcode_button"> - <property name="visible">True</property> + <object class="GtkMenuButton" id="show_qrcode_button"> + <property name="icon-name">dino-qr-code-symbolic</property> <property name="halign">start</property> - <property name="hexpand">True</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">dino-qr-code-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> + <property name="hexpand">1</property> </object> </child> <child> <object class="GtkButton" id="copy_button"> - <property name="visible">True</property> <property name="halign">end</property> - <property name="hexpand">True</property> + <property name="hexpand">1</property> <child> <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-size">1</property> + <property name="icon-size">normal</property> <property name="icon-name">edit-copy-symbolic</property> </object> </child> @@ -155,114 +132,99 @@ </object> </child> </object> - </child> + </property> </object> </child> </object> - </child> + </property> </object> </child> </object> </child> <child> <object class="GtkBox" id="new_keys_container"> - <property name="visible">False</property> + <property name="visible">0</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child> <object class="GtkLabel" id="new_keys_label"> - <property name="visible">True</property> <property name="halign">start</property> <attributes> - <attribute name="weight" value="PANGO_WEIGHT_BOLD"/> + <attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute> </attributes> </object> </child> <child> <object class="GtkFrame"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkScrolledWindow"> <property name="hscrollbar_policy">never</property> - <property name="vscrollbar_policy">automatic</property> - <property name="visible">True</property> - <property name="propagate_natural_height">True</property> - <child> + <property name="propagate_natural_height">1</property> + <property name="child"> <object class="GtkListBox" id="new_keys_listbox"> - <property name="visible">True</property> <property name="selection-mode">none</property> </object> - </child> + </property> </object> - </child> + </property> </object> </child> </object> </child> <child> <object class="GtkBox" id="keys_container"> - <property name="visible">False</property> + <property name="visible">0</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child> <object class="GtkLabel" id="associated_keys_label"> - <property name="visible">True</property> <property name="halign">start</property> <attributes> - <attribute name="weight" value="PANGO_WEIGHT_BOLD"/> + <attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute> </attributes> </object> </child> <child> <object class="GtkFrame"> - <property name="visible">True</property> - <child> + <property name="child"> <object class="GtkScrolledWindow"> <property name="hscrollbar_policy">never</property> - <property name="vscrollbar_policy">automatic</property> - <property name="visible">True</property> - <property name="propagate_natural_height">True</property> - <child> + <property name="propagate_natural_height">1</property> + <property name="child"> <object class="GtkListBox" id="keys_listbox"> - <property name="visible">True</property> <property name="selection-mode">none</property> </object> - </child> + </property> </object> - </child> + </property> </object> </child> </object> </child> <child> <object class="GtkExpander" id="inactive_keys_expander"> - <property name="visible">False</property> + <property name="visible">0</property> <child type="label"> <object class="GtkLabel" id="inactive_expander_label"> - <property name="visible">True</property> <attributes> - <attribute name="weight" value="PANGO_WEIGHT_BOLD"/> + <attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute> </attributes> </object> </child> <child> <object class="GtkFrame"> - <property name="visible">True</property> <property name="margin-top">2</property> - <child> + <property name="child"> <object class="GtkScrolledWindow"> <property name="hscrollbar_policy">never</property> - <property name="vscrollbar_policy">automatic</property> - <property name="visible">True</property> - <property name="propagate_natural_height">True</property> - <child> + <property name="propagate_natural_height">1</property> + <property name="child"> <object class="GtkListBox" id="inactive_keys_listbox"> - <property name="visible">True</property> <property name="selection-mode">none</property> </object> - </child> + </property> </object> - </child> + </property> </object> </child> </object> @@ -271,19 +233,18 @@ </child> </template> <object class="GtkPopover" id="qrcode_popover"> - <property name="visible">False</property> - <property name="relative-to">show_qrcode_button</property> <property name="position">left</property> - <property name="modal">True</property> - <child> + <property name="child"> <object class="GtkBox"> <property name="visible">True</property> + <property name="margin-start">10</property> + <property name="margin-end">10</property> + <property name="margin-top">10</property> + <property name="margin-bottom">10</property> <child> - <object class="GtkImage" id="qrcode_image"> - <property name="visible">True</property> - </object> + <object class="GtkImage" id="qrcode_image"/> </child> </object> - </child> + </property> </object> </interface> diff --git a/plugins/omemo/data/manage_key_dialog.ui b/plugins/omemo/data/manage_key_dialog.ui index dcec4c90..37f158da 100644 --- a/plugins/omemo/data/manage_key_dialog.ui +++ b/plugins/omemo/data/manage_key_dialog.ui @@ -1,164 +1,149 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> + <requires lib="gtk" version="4.0"/> <template class="DinoPluginsOmemoManageKeyDialog"> <property name="modal">True</property> <property name="resizable">False</property> <child type="titlebar"> <object class="GtkHeaderBar" id="headerbar"> - <property name="visible">True</property> - <property name="show_close_button">False</property> + <property name="show_title_buttons">0</property> <child> - <object class="GtkButton" id="cancel_button"> - <property name="sensitive">True</property> - <property name="visible">True</property> - </object> - <packing> - <property name="pack_type">start</property> - </packing> + <object class="GtkButton" id="cancel_button"/> </child> - <child> + <child type="end"> <object class="GtkButton" id="ok_button"> - <property name="has_default">True</property> - <property name="can_default">True</property> - <property name="sensitive">False</property> - <property name="visible">True</property> + <property name="sensitive">0</property> <style> <class name="suggested-action"/> </style> </object> - <packing> - <property name="pack_type">end</property> - </packing> </child> </object> </child> - <child internal-child="vbox"> + <child internal-child="content_area"> <object class="GtkBox"> - <property name="visible">True</property> <child> <object class="GtkStack" id="manage_stack"> - <property name="visible">True</property> <property name="transition-type">slide-left-right</property> <child> - <object class="GtkBox" id="main_screen"> - <property name="visible">True</property> - <property name="margin">12</property> - <property name="spacing">12</property> - <property name="orientation">vertical</property> - <property name="valign">center</property> - <child> - <object class="GtkLabel" id="main_desc_label"> - <property name="visible">True</property> - <property name="wrap">True</property> - <property name="xalign">0</property> - <property name="max-width-chars">1</property> - </object> - </child> - <child> - <object class="GtkFrame"> - <property name="visible">True</property> + <object class="GtkStackPage"> + <property name="name">main</property> + <property name="child"> + <object class="GtkBox" id="main_screen"> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="spacing">12</property> + <property name="orientation">vertical</property> + <property name="valign">center</property> + <child> + <object class="GtkLabel" id="main_desc_label"> + <property name="wrap">1</property> + <property name="xalign">0</property> + <property name="max-width-chars">1</property> + </object> + </child> <child> - <object class="GtkListBox" id="main_action_list"> - <property name="visible">True</property> - <property name="selection-mode">none</property> + <object class="GtkFrame"> + <property name="child"> + <object class="GtkListBox" id="main_action_list"> + <property name="selection-mode">none</property> + </object> + </property> </object> </child> </object> - </child> + </property> </object> - <packing> - <property name="name">main</property> - </packing> </child> <child> - <object class="GtkBox" id="verify_screen"> - <property name="visible">True</property> - <property name="margin">12</property> - <property name="spacing">12</property> - <property name="orientation">vertical</property> - <property name="valign">center</property> - <child> - <object class="GtkLabel" id="compare_fingerprint_label"> - <property name="visible">True</property> - <property name="wrap">True</property> - <property name="xalign">0.5</property> - <property name="max-width-chars">45</property> - </object> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="margin-left">12</property> - <property name="margin-right">12</property> + <object class="GtkStackPage"> + <property name="name">verify</property> + <property name="child"> + <object class="GtkBox" id="verify_screen"> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> <property name="spacing">12</property> - <property name="hexpand">False</property> - <property name="halign">center</property> - <child> - <object class="GtkLabel" id="verify_label"> - <property name="visible">True</property> - <property name="margin-top">12</property> - <property name="margin-bottom">12</property> - <property name="justify">right</property> - </object> - </child> + <property name="orientation">vertical</property> + <property name="valign">center</property> <child> - <object class="GtkButton" id="verify_no_button"> - <property name="visible">True</property> - <property name="hexpand">True</property> + <object class="GtkLabel" id="compare_fingerprint_label"> + <property name="wrap">1</property> + <property name="max-width-chars">45</property> </object> </child> <child> - <object class="GtkButton" id="verify_yes_button"> - <property name="visible">True</property> - <property name="hexpand">True</property> + <object class="GtkBox"> + <property name="orientation">vertical</property> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="spacing">12</property> + <property name="hexpand">0</property> + <property name="halign">center</property> + <child> + <object class="GtkLabel" id="verify_label"> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="justify">right</property> + </object> + </child> + <child> + <object class="GtkButton" id="verify_no_button"> + <property name="hexpand">1</property> + </object> + </child> + <child> + <object class="GtkButton" id="verify_yes_button"> + <property name="hexpand">1</property> + </object> + </child> </object> </child> </object> - </child> + </property> </object> - <packing> - <property name="name">verify</property> - </packing> </child> <child> - <object class="GtkBox" id="confirm_screen"> - <property name="visible">True</property> - <property name="margin">12</property> - <property name="spacing">12</property> - <property name="orientation">vertical</property> - <property name="valign">center</property> - <child> - <object class="GtkImage" id="confirm_image"> - <property name="visible">True</property> - </object> - </child> - <child> - <object class="GtkLabel" id="confirm_title_label"> - <property name="visible">True</property> - <attributes> - <attribute name="scale" value="1.1"/> - </attributes> - </object> - </child> - <child> - <object class="GtkLabel" id="confirm_desc_label"> - <property name="visible">True</property> - <property name="justify">center</property> - <property name="wrap">True</property> - <property name="max-width-chars">40</property> - <attributes> - <attribute name="scale" value="0.8"/> - </attributes> - <style> - <class name="dim-label"/> - </style> + <object class="GtkStackPage"> + <property name="name">confirm</property> + <property name="child"> + <object class="GtkBox" id="confirm_screen"> + <property name="margin-start">12</property> + <property name="margin-end">12</property> + <property name="margin-top">12</property> + <property name="margin-bottom">12</property> + <property name="spacing">12</property> + <property name="orientation">vertical</property> + <property name="valign">center</property> + <child> + <object class="GtkImage" id="confirm_image"/> + </child> + <child> + <object class="GtkLabel" id="confirm_title_label"> + <attributes> + <attribute name="scale" value="1.1"></attribute> + </attributes> + </object> + </child> + <child> + <object class="GtkLabel" id="confirm_desc_label"> + <property name="justify">center</property> + <property name="wrap">1</property> + <property name="max-width-chars">40</property> + <attributes> + <attribute name="scale" value="0.8"></attribute> + </attributes> + <style> + <class name="dim-label"/> + </style> + </object> + </child> </object> - </child> + </property> </object> - <packing> - <property name="name">confirm</property> - </packing> </child> </object> </child> diff --git a/plugins/omemo/src/logic/trust_manager.vala b/plugins/omemo/src/logic/trust_manager.vala index 20076a43..cae88eef 100644 --- a/plugins/omemo/src/logic/trust_manager.vala +++ b/plugins/omemo/src/logic/trust_manager.vala @@ -109,7 +109,7 @@ public class TrustManager { // TODO: Handling of files - ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item(conversation, 1, message.id); + ContentItem? content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_item_by_foreign(conversation, 1, message.id); if (content_item != null && device_id != 0) { Jid jid = content_item.jid; diff --git a/plugins/omemo/src/ui/account_settings_entry.vala b/plugins/omemo/src/ui/account_settings_entry.vala index 3866febe..8736260b 100644 --- a/plugins/omemo/src/ui/account_settings_entry.vala +++ b/plugins/omemo/src/ui/account_settings_entry.vala @@ -1,26 +1,58 @@ +using Dino.Entities; +using Gtk; + namespace Dino.Plugins.Omemo { public class AccountSettingsEntry : Plugins.AccountSettingsEntry { private Plugin plugin; + private Account account; + + private Box box = new Box(Orientation.HORIZONTAL, 0); + private Label fingerprint = new Label("...") { xalign=0 }; + private Button btn = new Button.from_icon_name("view-list-symbolic") { has_frame=false, valign=Align.CENTER, visible=false }; + + public override string id { get { return "omemo_identity_key"; }} + + public override string name { get { return "OMEMO"; }} public AccountSettingsEntry(Plugin plugin) { this.plugin = plugin; - } - public override string id { get { - return "omemo_identity_key"; - }} + Border border = new Button().get_style_context().get_padding(); + fingerprint.margin_top = border.top + 1; + fingerprint.margin_start = border.left + 1; + fingerprint.visible = true; + box.append(fingerprint); - public override string name { get { - return "OMEMO"; - }} + btn.clicked.connect(() => { + activated(); + ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, account, account.bare_jid); + dialog.set_transient_for((Window) box.get_root()); + dialog.present(); + }); + // TODO expand=false? + box.append(btn); + } + + public override Object? get_widget(WidgetType type) { + if (type != WidgetType.GTK4) return null; + return box; + } - public override Plugins.AccountSettingsWidget? get_widget(WidgetType type) { - if (type == WidgetType.GTK) { - return new AccountSettingWidget(plugin); + public override void set_account(Account account) { + this.account = account; + btn.visible = false; + Qlite.Row? row = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id).inner; + if (row == null) { + fingerprint.set_markup("%s\n<span font='8'>%s</span>".printf(_("Own fingerprint"), _("Will be generated on first connection"))); + } else { + string res = fingerprint_markup(fingerprint_from_base64(((!)row)[plugin.db.identity.identity_key_public_base64])); + fingerprint.set_markup("%s\n<span font_family='monospace' font='8'>%s</span>".printf(_("Own fingerprint"), res)); + btn.visible = true; } - return null; } + + public override void deactivate() { } } }
\ No newline at end of file diff --git a/plugins/omemo/src/ui/account_settings_widget.vala b/plugins/omemo/src/ui/account_settings_widget.vala deleted file mode 100644 index cc562221..00000000 --- a/plugins/omemo/src/ui/account_settings_widget.vala +++ /dev/null @@ -1,54 +0,0 @@ -using Gtk; -using Dino.Entities; - -namespace Dino.Plugins.Omemo { - -public class AccountSettingWidget : Plugins.AccountSettingsWidget, Box { - private Plugin plugin; - private Label fingerprint; - private Account account; - private Button btn; - - public AccountSettingWidget(Plugin plugin) { - this.plugin = plugin; - - fingerprint = new Label("..."); - fingerprint.xalign = 0; - Border border = new Button().get_style_context().get_padding(StateFlags.NORMAL); - fingerprint.margin_top = border.top + 1; - fingerprint.margin_start = border.left + 1; - fingerprint.visible = true; - pack_start(fingerprint); - - btn = new Button(); - btn.image = new Image.from_icon_name("view-list-symbolic", IconSize.BUTTON); - btn.relief = ReliefStyle.NONE; - btn.visible = false; - btn.valign = Align.CENTER; - btn.clicked.connect(() => { - activated(); - ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, account, account.bare_jid); - dialog.set_transient_for((Window) get_toplevel()); - dialog.present(); - }); - pack_start(btn, false); - } - - public void set_account(Account account) { - this.account = account; - btn.visible = false; - Qlite.Row? row = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id).inner; - if (row == null) { - fingerprint.set_markup("%s\n<span font='8'>%s</span>".printf(_("Own fingerprint"), _("Will be generated on first connection"))); - } else { - string res = fingerprint_markup(fingerprint_from_base64(((!)row)[plugin.db.identity.identity_key_public_base64])); - fingerprint.set_markup("%s\n<span font_family='monospace' font='8'>%s</span>".printf(_("Own fingerprint"), res)); - btn.visible = true; - } - } - - public void deactivate() { - } -} - -} diff --git a/plugins/omemo/src/ui/bad_messages_populator.vala b/plugins/omemo/src/ui/bad_messages_populator.vala index bd2474f2..ca0bd35d 100644 --- a/plugins/omemo/src/ui/bad_messages_populator.vala +++ b/plugins/omemo/src/ui/bad_messages_populator.vala @@ -123,7 +123,7 @@ public class BadMessageItem : Plugins.MetaConversationItem { this.badness_type = badness_type; } - public override Object? get_widget(Plugins.WidgetType widget_type) { + public override Object? get_widget(Plugins.ConversationItemWidgetInterface outer, Plugins.WidgetType widget_type) { return new BadMessagesWidget(plugin, conversation, problem_jid, badness_type); } @@ -161,12 +161,12 @@ public class BadMessagesWidget : Box { } Label label = new Label(warning_text) { margin_start=70, margin_end=70, justify=Justification.CENTER, use_markup=true, selectable=true, wrap=true, wrap_mode=Pango.WrapMode.WORD_CHAR, hexpand=true, visible=true }; label.get_style_context().add_class("dim-label"); - this.add(label); + this.append(label); label.activate_link.connect(() => { if (badness_type == BadnessType.UNTRUSTED) { ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, conversation.account, jid); - dialog.set_transient_for((Window) get_toplevel()); + dialog.set_transient_for((Window) get_root()); dialog.present(); } diff --git a/plugins/omemo/src/ui/contact_details_dialog.vala b/plugins/omemo/src/ui/contact_details_dialog.vala index b4d6d8f0..80943824 100644 --- a/plugins/omemo/src/ui/contact_details_dialog.vala +++ b/plugins/omemo/src/ui/contact_details_dialog.vala @@ -37,10 +37,12 @@ public class ContactDetailsDialog : Gtk.Dialog { [GtkChild] private unowned ListBox inactive_keys_listbox; [GtkChild] private unowned Switch auto_accept_switch; [GtkChild] private unowned Button copy_button; - [GtkChild] private unowned Button show_qrcode_button; + [GtkChild] private unowned MenuButton show_qrcode_button; [GtkChild] private unowned Image qrcode_image; [GtkChild] private unowned Popover qrcode_popover; + private ArrayList<Widget> new_keys_listbox_children = new ArrayList<Widget>(); + construct { // If we set the strings in the .ui file, they don't get translated title = _("OMEMO Key Management"); @@ -59,7 +61,7 @@ public class ContactDetailsDialog : Gtk.Dialog { this.jid = jid; if (Environment.get_variable("GTK_CSD") != "0") { - ((HeaderBar) get_header_bar()).set_subtitle(jid.bare_jid.to_string()); +// ((HeaderBar) get_header_bar()).set_subtitle(jid.bare_jid.to_string()); } keys_listbox.row_activated.connect(on_key_entry_clicked); @@ -89,7 +91,7 @@ public class ContactDetailsDialog : Gtk.Dialog { string fingerprint = fingerprint_from_base64(own_b64); own_fingerprint_label.set_markup(fingerprint_markup(fingerprint)); - copy_button.clicked.connect(() => {Clipboard.get_default(get_display()).set_text(fingerprint, fingerprint.length);}); + copy_button.clicked.connect(() => { copy_button.get_clipboard().set_text(fingerprint); }); int sid = plugin.db.identity.row_with(plugin.db.identity.account_id, account.id)[plugin.db.identity.device_id]; var iri_query = @"omemo-sid-$(sid)=$(fingerprint)"; @@ -104,12 +106,12 @@ public class ContactDetailsDialog : Gtk.Dialog { const int MODULE_SIZE_PX = 4; // arbitrary var qr_pixbuf = new QRcode(iri, 2) .to_pixbuf(MODULE_SIZE_PX * qrcode_image.scale_factor); - qrcode_image.set_from_surface( - Gdk.cairo_surface_create_from_pixbuf(qr_pixbuf,0,get_window())); - qrcode_image.margin = QUIET_ZONE_MODULES*MODULE_SIZE_PX; + qrcode_image.set_from_pixbuf(qr_pixbuf); + qrcode_image.margin_top = qrcode_image.margin_end = + qrcode_image.margin_bottom = qrcode_image.margin_start = QUIET_ZONE_MODULES*MODULE_SIZE_PX; qrcode_popover.get_style_context().add_class("qrcode-container"); - show_qrcode_button.clicked.connect(qrcode_popover.popup); + show_qrcode_button.popover = qrcode_popover; } new_keys_listbox.set_header_func(header_function); @@ -196,10 +198,10 @@ public class ContactDetailsDialog : Gtk.Dialog { if (device[plugin.db.identity_meta.now_active]) { keys_container.visible = true; - keys_listbox.add(fingerprint_row); + keys_listbox.append(fingerprint_row); } else { inactive_keys_expander.visible=true; - inactive_keys_listbox.add(fingerprint_row); + inactive_keys_listbox.append(fingerprint_row); } displayed_ids.add(device[plugin.db.identity_meta.device_id]); } @@ -210,7 +212,7 @@ public class ContactDetailsDialog : Gtk.Dialog { Row updated_device = plugin.db.identity_meta.get_device(fingerprint_row.row[plugin.db.identity_meta.identity_id], fingerprint_row.row[plugin.db.identity_meta.address_name], fingerprint_row.row[plugin.db.identity_meta.device_id]); ManageKeyDialog manage_dialog = new ManageKeyDialog(updated_device, plugin.db); - manage_dialog.set_transient_for((Gtk.Window) get_toplevel()); + manage_dialog.set_transient_for((Gtk.Window) get_root()); manage_dialog.present(); manage_dialog.response.connect((response) => { fingerprint_row.update_trust_state(response, fingerprint_row.row[plugin.db.identity_meta.now_active]); @@ -257,12 +259,12 @@ public class ContactDetailsDialog : Gtk.Dialog { Box box = new Box(Gtk.Orientation.HORIZONTAL, 40) { visible = true, margin_start = 20, margin_end = 20, margin_top = 14, margin_bottom = 14, hexpand = true }; Button accept_button = new Button() { visible = true, valign = Align.CENTER, hexpand = true }; - accept_button.add(new Image.from_icon_name("emblem-ok-symbolic", IconSize.BUTTON) { visible=true }); // using .image = sets .image-button. Together with .suggested/destructive action that breaks the button Adwaita + accept_button.set_icon_name("emblem-ok-symbolic"); // using .image = sets .image-button. Together with .suggested/destructive action that breaks the button Adwaita accept_button.get_style_context().add_class("suggested-action"); accept_button.tooltip_text = _("Accept key"); Button reject_button = new Button() { visible = true, valign = Align.CENTER, hexpand = true }; - reject_button.add(new Image.from_icon_name("action-unavailable-symbolic", IconSize.BUTTON) { visible=true }); + reject_button.set_icon_name("action-unavailable-symbolic"); reject_button.get_style_context().add_class("destructive-action"); reject_button.tooltip_text = _("Reject key"); @@ -270,35 +272,38 @@ public class ContactDetailsDialog : Gtk.Dialog { plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.TRUSTED); add_fingerprint(device, TrustLevel.TRUSTED); new_keys_listbox.remove(lbr); - if (new_keys_listbox.get_children().length() < 1) new_keys_container.visible = false; + new_keys_listbox_children.remove(lbr); + if (new_keys_listbox_children.size < 1) new_keys_container.visible = false; }); reject_button.clicked.connect(() => { plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.UNTRUSTED); add_fingerprint(device, TrustLevel.UNTRUSTED); new_keys_listbox.remove(lbr); - if (new_keys_listbox.get_children().length() < 1) new_keys_container.visible = false; + new_keys_listbox_children.remove(lbr); + if (new_keys_listbox_children.size < 1) new_keys_container.visible = false; }); string res = fingerprint_markup(fingerprint_from_base64(device[plugin.db.identity_meta.identity_key_public_base64])); Label fingerprint_label = new Label(res) { use_markup=true, justify=Justification.RIGHT, visible=true, halign = Align.START, valign = Align.CENTER, hexpand = false }; - box.add(fingerprint_label); + box.append(fingerprint_label); Box control_box = new Box(Gtk.Orientation.HORIZONTAL, 0) { visible = true, hexpand = true }; - control_box.add(accept_button); - control_box.add(reject_button); + control_box.append(accept_button); + control_box.append(reject_button); control_box.get_style_context().add_class("linked"); // .linked: Visually link the accept / reject buttons - box.add(control_box); + box.append(control_box); - lbr.add(box); - new_keys_listbox.add(lbr); + lbr.set_child(box); + new_keys_listbox.append(lbr); + new_keys_listbox_children.add(lbr); displayed_ids.add(device[plugin.db.identity_meta.device_id]); } } public class FingerprintRow : ListBoxRow { - private Image trust_image = new Image() { visible = true, halign = Align.END, icon_size = IconSize.BUTTON }; + private Image trust_image = new Image() { visible = true, halign = Align.END }; private Label fingerprint_label = new Label("") { use_markup=true, justify=Justification.RIGHT, visible=true, halign = Align.START, valign = Align.CENTER, hexpand = false }; private Label trust_label = new Label(null) { visible = true, hexpand = true, xalign = 0 }; @@ -308,13 +313,13 @@ public class FingerprintRow : ListBoxRow { Box box = new Box(Gtk.Orientation.HORIZONTAL, 40) { visible = true, margin_start = 20, margin_end = 20, margin_top = 14, margin_bottom = 14, hexpand = true }; Box status_box = new Box(Gtk.Orientation.HORIZONTAL, 5) { visible = true, hexpand = true }; - box.add(fingerprint_label); - box.add(status_box); + box.append(fingerprint_label); + box.append(status_box); - status_box.add(trust_label); - status_box.add(trust_image); + status_box.append(trust_label); + status_box.append(trust_image); - this.add(box); + this.set_child(box); } public FingerprintRow(Row row, string key_base64, int trust, bool now_active) { diff --git a/plugins/omemo/src/ui/contact_details_provider.vala b/plugins/omemo/src/ui/contact_details_provider.vala index 7250d135..822294cc 100644 --- a/plugins/omemo/src/ui/contact_details_provider.vala +++ b/plugins/omemo/src/ui/contact_details_provider.vala @@ -15,7 +15,7 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object { } public void populate(Conversation conversation, Plugins.ContactDetails contact_details, WidgetType type) { - if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK) { + if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK4) { int identity_id = plugin.db.identity.get_id(conversation.account.id); if (identity_id < 0) return; @@ -28,11 +28,11 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object { } if (i > 0) { - Button btn = new Button.from_icon_name("view-list-symbolic") { visible = true, valign = Align.CENTER, relief = ReliefStyle.NONE }; + Button btn = new Button.from_icon_name("view-list-symbolic") { visible = true, valign = Align.CENTER, has_frame = false }; btn.clicked.connect(() => { btn.activate(); ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, conversation.account, conversation.counterpart); - dialog.set_transient_for((Window) btn.get_toplevel()); + dialog.set_transient_for((Window) btn.get_root()); dialog.response.connect((response_type) => { plugin.device_notification_populator.should_hide(); }); diff --git a/plugins/omemo/src/ui/device_notification_populator.vala b/plugins/omemo/src/ui/device_notification_populator.vala index 2f276f2b..9f40353d 100644 --- a/plugins/omemo/src/ui/device_notification_populator.vala +++ b/plugins/omemo/src/ui/device_notification_populator.vala @@ -70,18 +70,18 @@ private class ConversationNotification : MetaConversationNotification { this.account = account; Box box = new Box(Orientation.HORIZONTAL, 5) { visible=true }; - Button manage_button = new Button() { label=_("Manage"), visible=true }; + Button manage_button = new Button.with_label(_("Manage")) { visible=true }; manage_button.clicked.connect(() => { manage_button.activate(); ContactDetailsDialog dialog = new ContactDetailsDialog(plugin, account, jid); - dialog.set_transient_for((Window) manage_button.get_toplevel()); + dialog.set_transient_for((Window) manage_button.get_root()); dialog.response.connect((response_type) => { should_hide(); }); dialog.present(); }); - box.add(new Label(_("This contact has new devices")) { margin_end=10, visible=true }); - box.add(manage_button); + box.append(new Label(_("This contact has new devices")) { margin_end=10, visible=true }); + box.append(manage_button); widget = box; } diff --git a/plugins/omemo/src/ui/encryption_list_entry.vala b/plugins/omemo/src/ui/encryption_list_entry.vala index a0e6bb0f..b262ef81 100644 --- a/plugins/omemo/src/ui/encryption_list_entry.vala +++ b/plugins/omemo/src/ui/encryption_list_entry.vala @@ -22,9 +22,11 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object { return "OMEMO"; }} - public static IconSize ICON_SIZE_HEADER = Gtk.icon_size_register("im.dino.Dino.HEADER_ICON2", 17, 12); - public Object? get_encryption_icon(Entities.Conversation conversation, ContentItem content_item) { + return null; + } + + public string? get_encryption_icon_name(Entities.Conversation conversation, ContentItem content_item) { if (content_item.encryption != encryption) return null; RowOption row = db.content_item_meta.select( { db.identity_meta.trust_level } ).with(db.content_item_meta.content_item_id, "=", content_item.id) @@ -33,7 +35,7 @@ public class EncryptionListEntry : Plugins.EncryptionListEntry, Object { if (row.is_present() && (TrustLevel) row[db.identity_meta.trust_level] == TrustLevel.VERIFIED) { - return new Image.from_icon_name("dino-security-high-symbolic", ICON_SIZE_HEADER) { opacity=0.4, visible = true }; + return "dino-security-high-symbolic"; } return null; } diff --git a/plugins/omemo/src/ui/manage_key_dialog.vala b/plugins/omemo/src/ui/manage_key_dialog.vala index 9bdaaaee..a4b61f70 100644 --- a/plugins/omemo/src/ui/manage_key_dialog.vala +++ b/plugins/omemo/src/ui/manage_key_dialog.vala @@ -32,7 +32,7 @@ public class ManageKeyDialog : Gtk.Dialog { construct { // If we set the strings in the .ui file, they don't get translated - headerbar.title = _("Manage Key"); + this.title = _("Manage Key"); compare_fingerprint_label.label = _("Compare the fingerprint, character by character, with the one shown on your contact's device."); verify_no_button.label = _("Fingerprints differ"); verify_yes_button.label = _("Fingerprints match"); @@ -56,7 +56,7 @@ public class ManageKeyDialog : Gtk.Dialog { }); verify_yes_button.clicked.connect(() => { - confirm_image.set_from_icon_name("security-high-symbolic", IconSize.DIALOG); + confirm_image.set_from_icon_name("security-high-symbolic"); confirm_title_label.label = _("Verify key"); confirm_desc_label.set_markup(_("Future messages sent by %s from the device that uses this key will be highlighted accordingly in the chat window.").printf(@"<b>$(device[db.identity_meta.address_name])</b>")); manage_stack.set_visible_child_name("confirm"); @@ -67,7 +67,7 @@ public class ManageKeyDialog : Gtk.Dialog { verify_no_button.clicked.connect(() => { return_to_main = false; - confirm_image.set_from_icon_name("dialog-warning-symbolic", IconSize.DIALOG); + confirm_image.set_from_icon_name("dialog-warning-symbolic"); confirm_title_label.label = _("Fingerprints do not match"); confirm_desc_label.set_markup(_("Please verify that you are comparing the correct fingerprint. If fingerprints do not match, %s's account may be compromised and you should consider rejecting this key.").printf(@"<b>$(device[db.identity_meta.address_name])</b>")); manage_stack.set_visible_child_name("confirm"); @@ -107,8 +107,8 @@ public class ManageKeyDialog : Gtk.Dialog { lbl_desc.attributes = desc_attrs; lbl_desc.get_style_context().add_class("dim-label"); - box.add(lbl_title); - box.add(lbl_desc); + box.append(lbl_title); + box.append(lbl_desc); return box; } @@ -121,25 +121,25 @@ public class ManageKeyDialog : Gtk.Dialog { }); ListBoxRow verify_row = new ListBoxRow() { visible = true }; - verify_row.add(make_action_box(_("Verify key fingerprint"), _("Compare this key's fingerprint with the fingerprint displayed on the contact's device."))); + verify_row.set_child(make_action_box(_("Verify key fingerprint"), _("Compare this key's fingerprint with the fingerprint displayed on the contact's device."))); ListBoxRow reject_row = new ListBoxRow() { visible = true }; - reject_row.add(make_action_box(_("Reject key"), _("Block encrypted communication with the contact's device that uses this key."))); + reject_row.set_child(make_action_box(_("Reject key"), _("Block encrypted communication with the contact's device that uses this key."))); ListBoxRow accept_row = new ListBoxRow() {visible = true }; - accept_row.add(make_action_box(_("Accept key"), _("Allow encrypted communication with the contact's device that uses this key."))); + accept_row.set_child(make_action_box(_("Accept key"), _("Allow encrypted communication with the contact's device that uses this key."))); switch((TrustLevel) device[db.identity_meta.trust_level]) { case TrustLevel.TRUSTED: main_desc_label.set_markup(_("This key is currently %s.").printf("<span color='#1A63D9'>"+_("accepted")+"</span>")+" "+_("This means it can be used by %s to receive and send encrypted messages.").printf(@"<b>$(device[db.identity_meta.address_name])</b>")); - main_action_list.add(verify_row); - main_action_list.add(reject_row); + main_action_list.append(verify_row); + main_action_list.append(reject_row); break; case TrustLevel.VERIFIED: main_desc_label.set_markup(_("This key is currently %s.").printf("<span color='#1A63D9'>"+_("verified")+"</span>")+" "+_("This means it can be used by %s to receive and send encrypted messages.").printf(@"<b>$(device[db.identity_meta.address_name])</b>") + " " + _("Additionally it has been verified to match the key on the contact's device.")); - main_action_list.add(reject_row); + main_action_list.append(reject_row); break; case TrustLevel.UNTRUSTED: main_desc_label.set_markup(_("This key is currently %s.").printf("<span color='#D91900'>"+_("rejected")+"</span>")+" "+_("This means it cannot be used by %s to decipher your messages, and you won't see messages encrypted with it.").printf(@"<b>$(device[db.identity_meta.address_name])</b>")); - main_action_list.add(accept_row); + main_action_list.append(accept_row); break; } @@ -148,7 +148,7 @@ public class ManageKeyDialog : Gtk.Dialog { if(row == verify_row) { manage_stack.set_visible_child_name("verify"); } else if (row == reject_row) { - confirm_image.set_from_icon_name("action-unavailable-symbolic", IconSize.DIALOG); + confirm_image.set_from_icon_name("action-unavailable-symbolic"); confirm_title_label.label = _("Reject key"); confirm_desc_label.set_markup(_("You won't see encrypted messages from the device of %s that uses this key. Conversely, that device won't be able to decipher your messages anymore.").printf(@"<b>$(device[db.identity_meta.address_name])</b>")); manage_stack.set_visible_child_name("confirm"); @@ -156,7 +156,7 @@ public class ManageKeyDialog : Gtk.Dialog { return_to_main = true; current_response = TrustLevel.UNTRUSTED; } else if (row == accept_row) { - confirm_image.set_from_icon_name("emblem-ok-symbolic", IconSize.DIALOG); + confirm_image.set_from_icon_name("emblem-ok-symbolic"); confirm_title_label.label = _("Accept key"); confirm_desc_label.set_markup(_("You will be able to exchange encrypted messages with the device of %s that uses this key.").printf(@"<b>$(device[db.identity_meta.address_name])</b>")); manage_stack.set_visible_child_name("confirm"); |