diff options
author | Marvin W <git@larma.de> | 2017-03-13 15:34:17 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-03-13 15:34:17 +0100 |
commit | 2804799f61eb4c68c5cf88b9996d13a81fe6317d (patch) | |
tree | aafa39898d776d47293859d3afc90c57f744b2c9 | |
parent | bb811f8b29ed8be96664277d2b8ca8a1c9829602 (diff) | |
download | dino-2804799f61eb4c68c5cf88b9996d13a81fe6317d.tar.gz dino-2804799f61eb4c68c5cf88b9996d13a81fe6317d.zip |
Reduce GTK dependency to 3.16, fix dark theme
26 files changed, 65 insertions, 48 deletions
diff --git a/libdino/src/service/presence_manager.vala b/libdino/src/service/presence_manager.vala index fd78496f..6a8d77aa 100644 --- a/libdino/src/service/presence_manager.vala +++ b/libdino/src/service/presence_manager.vala @@ -47,9 +47,10 @@ public class PresenceManager : StreamInteractionModule, Object { return null; } ArrayList<Jid> ret = new ArrayList<Jid>(Jid.equals_func); - foreach (string resource in resources) { + resources.foreach((resource) => { ret.add(new Jid(resource)); - } + return true; + }); return ret; } return null; diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 839d5c50..ef78f446 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -44,7 +44,6 @@ set(RESOURCE_LIST menu_encryption.ui occupant_list.ui occupant_list_item.ui - style.css settings_dialog.ui unified_window.ui ) diff --git a/main/data/add_conversation/add_contact_dialog.ui b/main/data/add_conversation/add_contact_dialog.ui index 58c13e7f..1ac2745c 100644 --- a/main/data/add_conversation/add_contact_dialog.ui +++ b/main/data/add_conversation/add_contact_dialog.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiAddConversationChatAddContactDialog"> <property name="default_width">300</property> <property name="modal">True</property> diff --git a/main/data/add_conversation/add_groupchat_dialog.ui b/main/data/add_conversation/add_groupchat_dialog.ui index c6390374..4c58ed89 100644 --- a/main/data/add_conversation/add_groupchat_dialog.ui +++ b/main/data/add_conversation/add_groupchat_dialog.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiAddConversationConferenceAddGroupchatDialog"> <property name="default_width">400</property> <property name="modal">True</property> diff --git a/main/data/add_conversation/conference_details_fragment.ui b/main/data/add_conversation/conference_details_fragment.ui index 403d9a94..c9431728 100644 --- a/main/data/add_conversation/conference_details_fragment.ui +++ b/main/data/add_conversation/conference_details_fragment.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiAddConversationConferenceConferenceDetailsFragment"> <property name="visible">True</property> <child> diff --git a/main/data/add_conversation/list_row.ui b/main/data/add_conversation/list_row.ui index 8f011bb8..9b662412 100644 --- a/main/data/add_conversation/list_row.ui +++ b/main/data/add_conversation/list_row.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiAddConversationListRow" parent="GtkListBoxRow"> <property name="visible">True</property> <child> diff --git a/main/data/add_conversation/select_jid_fragment.ui b/main/data/add_conversation/select_jid_fragment.ui index 612f1597..6384edb0 100644 --- a/main/data/add_conversation/select_jid_fragment.ui +++ b/main/data/add_conversation/select_jid_fragment.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiAddConversationSelectJidFragment"> <property name="height_request">500</property> <property name="width_request">460</property> diff --git a/main/data/conversation_list_titlebar.ui b/main/data/conversation_list_titlebar.ui index 6a5996df..6be6ffc7 100644 --- a/main/data/conversation_list_titlebar.ui +++ b/main/data/conversation_list_titlebar.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiConversationListTitlebar" parent="GtkHeaderBar"> <property name="hexpand">False</property> <property name="visible">True</property> diff --git a/main/data/conversation_selector/chat_row_tooltip.ui b/main/data/conversation_selector/chat_row_tooltip.ui index 90fbd712..6596cd62 100644 --- a/main/data/conversation_selector/chat_row_tooltip.ui +++ b/main/data/conversation_selector/chat_row_tooltip.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <object class="GtkBox" id="main_box"> <property name="orientation">vertical</property> <property name="visible">True</property> diff --git a/main/data/conversation_selector/conversation_row.ui b/main/data/conversation_selector/conversation_row.ui index 5f8498e9..a932ed85 100644 --- a/main/data/conversation_selector/conversation_row.ui +++ b/main/data/conversation_selector/conversation_row.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiConversationSelectorConversationRow"> <property name="visible">True</property> <style> diff --git a/main/data/conversation_selector/view.ui b/main/data/conversation_selector/view.ui index 4bac39bc..0dd2d00f 100644 --- a/main/data/conversation_selector/view.ui +++ b/main/data/conversation_selector/view.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiConversationSelectorView"> <property name="can_focus">True</property> <property name="width_request">40</property> diff --git a/main/data/conversation_summary/message_item.ui b/main/data/conversation_summary/message_item.ui index f21b4969..eac97279 100644 --- a/main/data/conversation_summary/message_item.ui +++ b/main/data/conversation_summary/message_item.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiConversationSummaryMergedMessageItem"> <property name="hexpand">True</property> <property name="column-spacing">7</property> diff --git a/main/data/conversation_summary/view.ui b/main/data/conversation_summary/view.ui index 74fb507e..88905268 100644 --- a/main/data/conversation_summary/view.ui +++ b/main/data/conversation_summary/view.ui @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiConversationSummaryView"> <property name="expand">True</property> <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> <child> <object class="GtkScrolledWindow" id="scrolled"> <property name="visible">True</property> diff --git a/main/data/conversation_titlebar.ui b/main/data/conversation_titlebar.ui index e173bdf3..30779079 100644 --- a/main/data/conversation_titlebar.ui +++ b/main/data/conversation_titlebar.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiConversationTitlebar" parent="GtkHeaderBar"> <property name="title"></property> <property name="hexpand">True</property> diff --git a/main/data/manage_accounts/account_row.ui b/main/data/manage_accounts/account_row.ui index ab700daa..154c7ae4 100644 --- a/main/data/manage_accounts/account_row.ui +++ b/main/data/manage_accounts/account_row.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiManageAccountsAccountRow"> <property name="visible">True</property> <child> diff --git a/main/data/manage_accounts/add_account_dialog.ui b/main/data/manage_accounts/add_account_dialog.ui index dd5264f1..c38f624a 100644 --- a/main/data/manage_accounts/add_account_dialog.ui +++ b/main/data/manage_accounts/add_account_dialog.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiManageAccountsAddAccountDialog"> <property name="default_width">300</property> <property name="modal">True</property> diff --git a/main/data/menu_encryption.ui b/main/data/menu_encryption.ui index 216bdd92..7aae53ee 100644 --- a/main/data/menu_encryption.ui +++ b/main/data/menu_encryption.ui @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.20"/> + <requires lib="gtk+" version="3.16"/> <object class="GtkPopoverMenu" id="menu_encryption"> <property name="can_focus">False</property> <child> diff --git a/main/data/occupant_list.ui b/main/data/occupant_list.ui index deb4716e..60fb2dac 100644 --- a/main/data/occupant_list.ui +++ b/main/data/occupant_list.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiOccupantList"> <property name="visible">True</property> <child> diff --git a/main/data/occupant_list_item.ui b/main/data/occupant_list_item.ui index aabe8a05..34f4107f 100644 --- a/main/data/occupant_list_item.ui +++ b/main/data/occupant_list_item.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiOccupantListRow" parent="GtkListBoxRow"> <property name="visible">True</property> <child> diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui index 3b939216..51619c29 100644 --- a/main/data/settings_dialog.ui +++ b/main/data/settings_dialog.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiSettingsDialog"> <property name="modal">True</property> <property name="visible">True</property> diff --git a/main/data/style.css b/main/data/style.css deleted file mode 100644 index d143ffd3..00000000 --- a/main/data/style.css +++ /dev/null @@ -1,3 +0,0 @@ -scrolledwindow { - background-color: white; -}
\ No newline at end of file diff --git a/main/data/unified_window.ui b/main/data/unified_window.ui index 289c00cf..5ae01493 100644 --- a/main/data/unified_window.ui +++ b/main/data/unified_window.ui @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <requires lib="gtk+" version="3.0"/> <template class="DinoUiWindow"> <property name="default-width">1200</property> <property name="default-height">700</property> diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index fe930b82..8dbe176b 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -16,8 +16,6 @@ public class Dino.Ui.Application : Dino.Application { notifications = new Notifications(stream_interaction); notifications.start(); Environment.set_application_name("Dino"); - - load_css(); } public override void activate() { @@ -83,16 +81,5 @@ public class Dino.Ui.Application : Dino.Application { private void remove_connection(Account account) { stream_interaction.disconnect(account); } - - private void load_css() { - var css_provider = new Gtk.CssProvider (); - try { - var file = File.new_for_uri("resource:///org/dino-im/style.css"); - css_provider.load_from_file (file); - } catch (GLib.Error e) { - warning ("loading css: %s", e.message); - } - Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - } } diff --git a/main/src/ui/conversation_summary/merged_message_item.vala b/main/src/ui/conversation_summary/merged_message_item.vala index fa198d21..0270ef42 100644 --- a/main/src/ui/conversation_summary/merged_message_item.vala +++ b/main/src/ui/conversation_summary/merged_message_item.vala @@ -22,21 +22,50 @@ public class MergedMessageItem : Grid { [GtkChild] private Image received_image; [GtkChild] private TextView message_text_view; + private StreamInteractor stream_interactor; + private TextTag link_tag; + public MergedMessageItem(StreamInteractor stream_interactor, Conversation conversation, Message message) { this.conversation = conversation; this.from = message.from; this.initial_time = message.time; + this.stream_interactor = stream_interactor; setup_tags(); add_message(message); time_label.label = get_relative_time(initial_time.to_local()); - string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account); - name_label.set_markup(@"<span foreground=\"#$(Util.get_name_hex_color(display_name))\">$display_name</span>"); Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(30, 30, image.scale_factor)).draw_message(stream_interactor, message)); if (message.encryption != Encryption.NONE) { encryption_image.visible = true; encryption_image.set_from_icon_name("changes-prevent-symbolic", IconSize.SMALL_TOOLBAR); } + name_label.label = Util.get_message_display_name(stream_interactor, message, conversation.account); + + update_display_style(); + message_text_view.style_updated.connect(style_changed); + } + + private void style_changed() { + lock(message_text_view) { + message_text_view.style_updated.disconnect(style_changed); + update_display_style(); + message_text_view.style_updated.connect(style_changed); + } + } + + private void update_display_style() { + TextView tmp = new TextView(); + RGBA bg = tmp.get_style_context().get_background_color(StateFlags.NORMAL); + bool dark_theme = (bg.red < 0.5 && bg.green < 0.5 && bg.blue < 0.5); + + string display_name = Util.get_message_display_name(stream_interactor, messages[0], conversation.account); + name_label.set_markup(@"<span foreground=\"#$(Util.get_name_hex_color(display_name, dark_theme))\">$display_name</span>"); + + LinkButton lnk = new LinkButton("http://example.com"); + RGBA link_color = lnk.get_style_context().get_color(StateFlags.LINK); + link_tag.foreground_rgba = link_color; + + message_text_view.override_background_color(0, {0,0,0,0}); } public void update() { @@ -104,7 +133,7 @@ public class MergedMessageItem : Grid { } private void setup_tags() { - message_text_view.buffer.create_tag("url", underline: Pango.Underline.SINGLE, foreground: "blue"); + link_tag = message_text_view.buffer.create_tag("url", underline: Pango.Underline.SINGLE, foreground: "blue"); message_text_view.button_release_event.connect(open_url); message_text_view.motion_notify_event.connect(change_cursor_over_url); } diff --git a/main/src/ui/conversation_summary/view.vala b/main/src/ui/conversation_summary/view.vala index d2599041..87c553c5 100644 --- a/main/src/ui/conversation_summary/view.vala +++ b/main/src/ui/conversation_summary/view.vala @@ -27,7 +27,6 @@ public class View : Box { bool reloading = false; public View(StreamInteractor stream_interactor) { - Object(homogeneous : false, spacing : 0); this.stream_interactor = stream_interactor; scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify); scrolled.vadjustment.notify["value"].connect(on_value_notify); @@ -50,6 +49,23 @@ public class View : Box { } return true; }); + + update_background_color(); + this.style_updated.connect(style_changed); + } + + private void update_background_color() { + TextView tmp = new TextView(); + this.override_background_color(0, tmp.get_style_context().get_background_color(0)); + main.override_background_color(0, tmp.get_style_context().get_background_color(0)); + } + + private void style_changed() { + lock (main) { + this.style_updated.disconnect(style_changed); + update_background_color(); + this.style_updated.connect(style_changed); + } } public void initialize_for_conversation(Conversation? conversation) { @@ -129,7 +145,7 @@ public class View : Box { if (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1 || scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size scrolled.vadjustment.value = scrolled.vadjustment.upper - scrolled.vadjustment.page_size; // scroll down - } else if (scrolled.vadjustment.value < scrolled.vadjustment.upper - scrolled.vadjustment.page_size - 1){ + } else if (scrolled.vadjustment.value < scrolled.vadjustment.upper - scrolled.vadjustment.page_size - 1) { scrolled.vadjustment.value = scrolled.vadjustment.upper - was_upper + scrolled.vadjustment.value; // stay at same content } was_upper = scrolled.vadjustment.upper; diff --git a/main/src/ui/util.vala b/main/src/ui/util.vala index 0a294731..aad0817d 100644 --- a/main/src/ui/util.vala +++ b/main/src/ui/util.vala @@ -9,17 +9,21 @@ public class Util : Object { private const string[] tango_colors_light = {"FCE94F", "FCAF3E", "E9B96E", "8AE234", "729FCF", "AD7FA8", "EF2929"}; private const string[] tango_colors_medium = {"EDD400", "F57900", "C17D11", "73D216", "3465A4", "75507B", "CC0000"}; - private const string[] material_colors_500 = {"F44336", "E91E63", "9C27B0", "673AB7", "3f51B5", "2196F3", "03A9f4", "00BCD4", "009688", "4CAF50", "8BC34a", "CDDC39", "FFEB3B", "FFC107", "FF9800", "FF5722", "795548"}; - private const string[] material_colors_300 = {"E57373", "F06292", "BA68C8", "9575CD", "7986CB", "64B5F6", "4FC3F7", "4DD0E1", "4DB6AC", "81C784", "AED581", "DCE775", "FFF176", "FFD54F", "FFB74D", "FF8A65", "A1887F"}; - private const string[] material_colors_200 = {"EF9A9A", "F48FB1", "CE93D8", "B39DDB", "9FA8DA", "90CAF9", "81D4FA", "80DEEA", "80CBC4", "A5D6A7", "C5E1A5", "E6EE9C", "FFF59D", "FFE082", "FFCC80", "FFAB91", "BCAAA4"}; + private const string[] material_colors_500 = {"F44336", "E91E63", "9C27B0", "673AB7", "3f51B5", "2196F3", "03A9f4", "00BCD4", "009688", "4CAF50", "8BC34a", "CDDC39", "FFC107", "FF9800", "FF5722", "795548"}; + private const string[] material_colors_300 = {"E57373", "F06292", "BA68C8", "9575CD", "7986CB", "64B5F6", "4FC3F7", "4DD0E1", "4DB6AC", "81C784", "AED581", "DCE775", "FFD54F", "FFB74D", "FF8A65", "A1887F"}; + private const string[] material_colors_200 = {"EF9A9A", "F48FB1", "CE93D8", "B39DDB", "9FA8DA", "90CAF9", "81D4FA", "80DEEA", "80CBC4", "A5D6A7", "C5E1A5", "E6EE9C", "FFE082", "FFCC80", "FFAB91", "BCAAA4"}; public static string get_avatar_hex_color(string name) { return material_colors_300[name.hash() % material_colors_300.length]; // return tango_colors_light[name.hash() % tango_colors_light.length]; } - public static string get_name_hex_color(string name) { - return material_colors_500[name.hash() % material_colors_500.length]; + public static string get_name_hex_color(string name, bool dark_theme = false) { + if (dark_theme) { + return material_colors_300[name.hash() % material_colors_300.length]; + } else { + return material_colors_500[name.hash() % material_colors_500.length]; + } // return tango_colors_medium[name.hash() % tango_colors_medium.length]; } |