diff options
19 files changed, 115 insertions, 69 deletions
diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake index 820b6d82..436a03ce 100644 --- a/cmake/UseVala.cmake +++ b/cmake/UseVala.cmake @@ -118,7 +118,12 @@ function(vala_precompile output) cmake_parse_arguments(ARGS "FAST_VAPI" "DIRECTORY;GENERATE_HEADER;GENERATE_VAPI;EXPORTS_DIR" "SOURCES;PACKAGES;OPTIONS;DEFINITIONS;CUSTOM_VAPIS;CUSTOM_DEPS;GRESOURCES" ${ARGN}) - if("Ninja" STREQUAL ${CMAKE_GENERATOR} AND NOT DISABLE_FAST_VAPI) + # Header and internal header is needed to generate internal vapi + if (ARGS_GENERATE_VAPI AND NOT ARGS_GENERATE_HEADER) + set(ARGS_GENERATE_HEADER ${ARGS_GENERATE_VAPI}) + endif(ARGS_GENERATE_VAPI AND NOT ARGS_GENERATE_HEADER) + + if("Ninja" STREQUAL ${CMAKE_GENERATOR} AND NOT DISABLE_FAST_VAPI AND NOT ARGS_GENERATE_HEADER) set(ARGS_FAST_VAPI true) endif() @@ -173,11 +178,6 @@ function(vala_precompile output) list(APPEND out_extra_files "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}_internal.vapi") set(vapi_arguments "--vapi=${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}.vapi" "--internal-vapi=${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}_internal.vapi") - # Header and internal header is needed to generate internal vapi - if (NOT ARGS_GENERATE_HEADER) - set(ARGS_GENERATE_HEADER ${ARGS_GENERATE_VAPI}) - endif(NOT ARGS_GENERATE_HEADER) - if(ARGS_PACKAGES) string(REPLACE ";" "\\n" pkgs "${ARGS_PACKAGES};${ARGS_CUSTOM_DEPS}") add_custom_command(OUTPUT "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}.deps" COMMAND echo -e "\"${pkgs}\"" > "${ARGS_EXPORTS_DIR}/${ARGS_GENERATE_VAPI}.deps" COMMENT "Generating ${ARGS_GENERATE_VAPI}.deps") diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt index c60075a3..aa2ab253 100644 --- a/libdino/CMakeLists.txt +++ b/libdino/CMakeLists.txt @@ -1,9 +1,9 @@ find_packages(LIBDINO_PACKAGES REQUIRED + GDKPixbuf2 Gee GLib GModule GObject - GTK3 ) vala_precompile(LIBDINO_VALA_C diff --git a/libdino/src/application.vala b/libdino/src/application.vala index c8834288..72dbfeae 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -1,13 +1,11 @@ -using Gtk; - using Dino.Entities; -public class Dino.Application : Gtk.Application { +public interface Dino.Application : GLib.Application { - public Database db; - public StreamInteractor stream_interaction; - public Plugins.Registry plugin_registry = new Plugins.Registry(); - public SearchPathGenerator? search_path_generator { get; set; } + public abstract Database db { get; set; } + public abstract StreamInteractor stream_interaction { get; set; } + public abstract Plugins.Registry plugin_registry { get; set; } + public abstract SearchPathGenerator? search_path_generator { get; set; } static string print_xmpp; @@ -16,7 +14,7 @@ public class Dino.Application : Gtk.Application { { null } }; - public Application() throws Error { + public void init() throws Error { if (DirUtils.create_with_parents(get_storage_dir(), 0700) == -1) { throw new Error(-1, 0, "Could not create storage dir \"%s\": %s", get_storage_dir(), FileUtils.error_from_errno(errno).to_string()); } diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala index dbed6a00..729f7b26 100644 --- a/libdino/src/plugin/interfaces.vala +++ b/libdino/src/plugin/interfaces.vala @@ -1,5 +1,3 @@ -using Gtk; - using Dino.Entities; namespace Dino.Plugins { @@ -12,6 +10,10 @@ public enum Priority { HIGHEST } +public enum WidgetType { + GTK +} + public interface RootInterface : Object { public abstract void registered(Dino.Application app); @@ -31,10 +33,10 @@ public abstract class AccountSettingsEntry : Object { public abstract string name { get; } public virtual int16 label_top_padding { get { return -1; } } - public abstract AccountSettingsWidget get_widget(); + public abstract AccountSettingsWidget? get_widget(WidgetType type); } -public interface AccountSettingsWidget : Gtk.Widget { +public interface AccountSettingsWidget : Object { public abstract void set_account(Account account); public abstract signal void activated(); @@ -42,24 +44,30 @@ public interface AccountSettingsWidget : Gtk.Widget { public abstract void deactivate(); } -public abstract class ContactDetailsProvider : Object { +public interface ContactDetailsProvider : Object { public abstract string id { get; } - public abstract void populate(Conversation conversation, ContactDetails contact_details); + public abstract void populate(Conversation conversation, ContactDetails contact_details, WidgetType type); } public class ContactDetails : Object { public signal void save(); - public signal void add(string category, string label, string? desc, Widget widget); + public signal void add(string category, string label, string? desc, Object widget); +} + +public interface TextCommand : Object { + public abstract string cmd { get; } + + public abstract string? handle_command(string? text, Entities.Conversation? conversation); } -public abstract class ConversationTitlebarEntry : Object { +public interface ConversationTitlebarEntry : Object { public abstract string id { get; } public abstract double order { get; } - public abstract ConversationTitlebarWidget get_widget(); + public abstract ConversationTitlebarWidget get_widget(WidgetType type); } -public interface ConversationTitlebarWidget : Gtk.Widget { +public interface ConversationTitlebarWidget : Object { public abstract void set_conversation(Conversation conversation); } diff --git a/libdino/src/service/avatar_manager.vala b/libdino/src/service/avatar_manager.vala index 42a08168..61e1faef 100644 --- a/libdino/src/service/avatar_manager.vala +++ b/libdino/src/service/avatar_manager.vala @@ -31,7 +31,7 @@ public class AvatarManager : StreamInteractionModule, Object { } public static string get_storage_dir() { - return Path.build_filename(Application.get_storage_dir(), "avatars"); + return Path.build_filename(Dino.get_storage_dir(), "avatars"); } private AvatarManager(StreamInteractor stream_interactor, Database db) { diff --git a/libdino/src/util.vala b/libdino/src/util.vala index 03d6ee26..85047dd8 100644 --- a/libdino/src/util.vala +++ b/libdino/src/util.vala @@ -20,6 +20,10 @@ public class SearchPathGenerator { } } +public static string get_storage_dir() { + return Path.build_filename(Environment.get_user_data_dir(), "dino"); +} + [CCode (cname = "dino_gettext", cheader_filename = "dino_i18n.h")] public static extern unowned string _(string s); diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 72bd4d0d..75b82352 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -3,11 +3,17 @@ using Gtk; using Dino.Entities; using Dino.Ui; -public class Dino.Ui.Application : Dino.Application { +public class Dino.Ui.Application : Gtk.Application, Dino.Application { private Notifications notifications; private UnifiedWindow window; + public Database db { get; set; } + public StreamInteractor stream_interaction { get; set; } + public Plugins.Registry plugin_registry { get; set; default = new Plugins.Registry(); } + public SearchPathGenerator? search_path_generator { get; set; } + public Application() throws Error { + init(); Notify.init("dino"); Environment.set_application_name("Dino"); Gtk.Window.set_default_icon_name("dino"); diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala index a5b8ea38..4e61a3f5 100644 --- a/main/src/ui/contact_details/dialog.vala +++ b/main/src/ui/contact_details/dialog.vala @@ -45,7 +45,7 @@ public class Dialog : Gtk.Dialog { app.plugin_registry.register_contact_details_entry(new MucConfigFormProvider(stream_interactor)); foreach (Plugins.ContactDetailsProvider provider in app.plugin_registry.contact_details_entries) { - provider.populate(conversation, contact_details); + provider.populate(conversation, contact_details, Plugins.WidgetType.GTK); } destroy.connect(() => { @@ -72,7 +72,9 @@ public class Dialog : Gtk.Dialog { Util.image_set_from_scaled_pixbuf(avatar, (new AvatarGenerator(50, 50, avatar.scale_factor)).draw_conversation(stream_interactor, conversation)); } - private void add_entry(string category, string label, string? description, Widget w) { + private void add_entry(string category, string label, string? description, Object wo) { + if (!(wo is Widget)) return; + Widget w = (Widget) wo; add_category(category); ListBoxRow list_row = new ListBoxRow() { activatable=false, visible=true }; diff --git a/main/src/ui/contact_details/muc_config_form_provider.vala b/main/src/ui/contact_details/muc_config_form_provider.vala index 438f41c4..47bbbe28 100644 --- a/main/src/ui/contact_details/muc_config_form_provider.vala +++ b/main/src/ui/contact_details/muc_config_form_provider.vala @@ -6,15 +6,16 @@ using Xmpp.Xep; namespace Dino.Ui.ContactDetails { -public class MucConfigFormProvider : Plugins.ContactDetailsProvider { - public override string id { get { return "muc_config_form"; } } +public class MucConfigFormProvider : Plugins.ContactDetailsProvider, Object { + public string id { get { return "muc_config_form"; } } private StreamInteractor stream_interactor; public MucConfigFormProvider(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; } - public override void populate(Conversation conversation, Plugins.ContactDetails contact_details) { + public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) { + if (type != Plugins.WidgetType.GTK) return; if (conversation.type_ == Conversation.Type.GROUPCHAT) { Xmpp.Core.XmppStream? stream = stream_interactor.get_stream(conversation.account); if (stream == null) return; diff --git a/main/src/ui/contact_details/settings_provider.vala b/main/src/ui/contact_details/settings_provider.vala index 70eab72c..64d4598c 100644 --- a/main/src/ui/contact_details/settings_provider.vala +++ b/main/src/ui/contact_details/settings_provider.vala @@ -4,8 +4,8 @@ using Dino.Entities; namespace Dino.Ui.ContactDetails { -public class SettingsProvider : Plugins.ContactDetailsProvider { - public override string id { get { return "chat_settings"; } } +public class SettingsProvider : Plugins.ContactDetailsProvider, Object { + public string id { get { return "chat_settings"; } } private StreamInteractor stream_interactor; @@ -13,7 +13,8 @@ public class SettingsProvider : Plugins.ContactDetailsProvider { this.stream_interactor = stream_interactor; } - public override void populate(Conversation conversation, Plugins.ContactDetails contact_details) { + public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) { + if (type != Plugins.WidgetType.GTK) return; if (conversation.type_ == Conversation.Type.CHAT) { ComboBoxText[] comboboxes = new ComboBoxText[2]; for (int i = 0; i < 3; i++) { diff --git a/main/src/ui/conversation_titlebar/encryption_entry.vala b/main/src/ui/conversation_titlebar/encryption_entry.vala index 18c09773..12b73409 100644 --- a/main/src/ui/conversation_titlebar/encryption_entry.vala +++ b/main/src/ui/conversation_titlebar/encryption_entry.vala @@ -5,12 +5,15 @@ using Dino.Entities; namespace Dino.Ui { -class EncryptionEntry : Plugins.ConversationTitlebarEntry { - public override string id { get { return "encryption"; } } +class EncryptionEntry : Plugins.ConversationTitlebarEntry, Object { + public string id { get { return "encryption"; } } - public override double order { get { return 2; } } - public override Plugins.ConversationTitlebarWidget get_widget() { - return new EncryptionWidget() { visible=true }; + public double order { get { return 2; } } + public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) { + if (type == Plugins.WidgetType.GTK) { + return new EncryptionWidget() { visible=true }; + } + return null; } } diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala index 6cead69d..6cdd11c2 100644 --- a/main/src/ui/conversation_titlebar/menu_entry.vala +++ b/main/src/ui/conversation_titlebar/menu_entry.vala @@ -4,8 +4,8 @@ using Dino.Entities; namespace Dino.Ui { -class MenuEntry : Plugins.ConversationTitlebarEntry { - public override string id { get { return "menu"; } } +class MenuEntry : Plugins.ConversationTitlebarEntry, Object { + public string id { get { return "menu"; } } StreamInteractor stream_interactor; @@ -13,9 +13,12 @@ class MenuEntry : Plugins.ConversationTitlebarEntry { this.stream_interactor = stream_interactor; } - public override double order { get { return 0; } } - public override Plugins.ConversationTitlebarWidget get_widget() { - return new MenuWidget(stream_interactor) { visible=true }; + public double order { get { return 0; } } + public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) { + if (type == Plugins.WidgetType.GTK) { + return new MenuWidget(stream_interactor) { visible=true }; + } + return null; } } diff --git a/main/src/ui/conversation_titlebar/occupants_entry.vala b/main/src/ui/conversation_titlebar/occupants_entry.vala index c305bed7..904a832a 100644 --- a/main/src/ui/conversation_titlebar/occupants_entry.vala +++ b/main/src/ui/conversation_titlebar/occupants_entry.vala @@ -4,8 +4,8 @@ using Dino.Entities; namespace Dino.Ui { -class OccupantsEntry : Plugins.ConversationTitlebarEntry { - public override string id { get { return "occupants"; } } +class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object { + public string id { get { return "occupants"; } } StreamInteractor stream_interactor; Window window; @@ -15,9 +15,12 @@ class OccupantsEntry : Plugins.ConversationTitlebarEntry { this.window = window; } - public override double order { get { return 3; } } - public override Plugins.ConversationTitlebarWidget get_widget() { - return new OccupantsWidget(stream_interactor, window) { visible=true }; + public double order { get { return 3; } } + public Plugins.ConversationTitlebarWidget get_widget(Plugins.WidgetType type) { + if (type == Plugins.WidgetType.GTK) { + return new OccupantsWidget(stream_interactor, window) { visible=true }; + } + return null; } } diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index 7debddd6..34191995 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -25,9 +25,11 @@ public class ConversationTitlebar : Gtk.HeaderBar { app.plugin_registry.register_contact_titlebar_entry(new OccupantsEntry(stream_interactor, window)); foreach(var e in app.plugin_registry.conversation_titlebar_entries) { - Plugins.ConversationTitlebarWidget widget = e.get_widget(); - widgets.add(widget); - pack_end(widget); + Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK); + if (widget != null) { + widgets.add(widget); + pack_end((Gtk.Widget)widget); + } } stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => { diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala index 548cb713..dae2fa73 100644 --- a/main/src/ui/manage_accounts/dialog.vala +++ b/main/src/ui/manage_accounts/dialog.vala @@ -56,16 +56,22 @@ public class Dialog : Gtk.Dialog { int16 default_top_padding = new Gtk.Button().get_style_context().get_padding(Gtk.StateFlags.NORMAL).top + 1; Application app = GLib.Application.get_default() as Application; foreach (var e in app.plugin_registry.account_settings_entries) { - Plugins.AccountSettingsWidget widget = e.get_widget(); + Plugins.AccountSettingsWidget widget = e.get_widget(Plugins.WidgetType.GTK); plugin_widgets.add(widget); - widget.visible = true; Label label = new Label(e.name) { xalign=1, yalign=0, visible=true }; label.get_style_context().add_class("dim-label"); label.set_padding(0, e.label_top_padding == -1 ? default_top_padding : e.label_top_padding); settings_list.attach(label, 0, row_index); - settings_list.attach(widget, 1, row_index, 2); + if (widget is Widget) { + Widget gtkw = (Widget) widget; + plugin_widgets.add(widget); + gtkw.visible = true; + settings_list.attach(gtkw, 1, row_index, 2); + } else { + // TODO + } row_index++; } } diff --git a/plugins/http-files/src/contact_titlebar_entry.vala b/plugins/http-files/src/contact_titlebar_entry.vala index 74966c0e..064adca9 100644 --- a/plugins/http-files/src/contact_titlebar_entry.vala +++ b/plugins/http-files/src/contact_titlebar_entry.vala @@ -4,8 +4,8 @@ using Dino.Entities; namespace Dino.Plugins.HttpFiles { -public class ConversationsTitlebarEntry : Plugins.ConversationTitlebarEntry { - public override string id { get { return "send_files"; } } +public class ConversationsTitlebarEntry : Plugins.ConversationTitlebarEntry, Object { + public string id { get { return "send_files"; } } StreamInteractor stream_interactor; @@ -13,9 +13,12 @@ public class ConversationsTitlebarEntry : Plugins.ConversationTitlebarEntry { this.stream_interactor = stream_interactor; } - public override double order { get { return 4; } } - public override Plugins.ConversationTitlebarWidget get_widget() { - return new ConversationTitlebarWidget(stream_interactor) { visible=true }; + public double order { get { return 4; } } + public Plugins.ConversationTitlebarWidget get_widget(WidgetType type) { + if (type == WidgetType.GTK) { + return new ConversationTitlebarWidget(stream_interactor) { visible=true }; + } + return null; } } diff --git a/plugins/omemo/src/account_settings_entry.vala b/plugins/omemo/src/account_settings_entry.vala index c6871f6e..3866febe 100644 --- a/plugins/omemo/src/account_settings_entry.vala +++ b/plugins/omemo/src/account_settings_entry.vala @@ -15,8 +15,11 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry { return "OMEMO"; }} - public override Plugins.AccountSettingsWidget get_widget() { - return new AccountSettingWidget(plugin); + public override Plugins.AccountSettingsWidget? get_widget(WidgetType type) { + if (type == WidgetType.GTK) { + return new AccountSettingWidget(plugin); + } + return null; } } diff --git a/plugins/openpgp/src/account_settings_entry.vala b/plugins/openpgp/src/account_settings_entry.vala index c7d11d72..75220c30 100644 --- a/plugins/openpgp/src/account_settings_entry.vala +++ b/plugins/openpgp/src/account_settings_entry.vala @@ -16,8 +16,11 @@ public class AccountSettingsEntry : Plugins.AccountSettingsEntry { return "OpenPGP"; }} - public override Plugins.AccountSettingsWidget get_widget() { - return new AccountSettingsWidget(plugin); + public override Plugins.AccountSettingsWidget? get_widget(WidgetType type) { + if (type == WidgetType.GTK) { + return new AccountSettingsWidget(plugin); + } + return null; } } diff --git a/plugins/openpgp/src/contact_details_provider.vala b/plugins/openpgp/src/contact_details_provider.vala index 39b6de2c..b9cc4b42 100644 --- a/plugins/openpgp/src/contact_details_provider.vala +++ b/plugins/openpgp/src/contact_details_provider.vala @@ -4,8 +4,8 @@ using Dino.Entities; namespace Dino.Plugins.OpenPgp { -public class ContactDetailsProvider : Plugins.ContactDetailsProvider { - public override string id { get { return "pgp_info"; } } +public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object { + public string id { get { return "pgp_info"; } } private StreamInteractor stream_interactor; @@ -13,8 +13,8 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider { this.stream_interactor = stream_interactor; } - public override void populate(Conversation conversation, Plugins.ContactDetails contact_details) { - if (conversation.type_ == Conversation.Type.CHAT) { + public void populate(Conversation conversation, Plugins.ContactDetails contact_details, WidgetType type) { + if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK) { string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); if (key_id != null) { Gee.List<GPG.Key> keys = GPGHelper.get_keylist(key_id); |