From e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sat, 11 Mar 2017 23:52:12 +0100 Subject: [PATCH] Move UI code into main dir --- cmake/CompileGResources.cmake | 12 +-- libdino/CMakeLists.txt | 69 +------------ .../data/{manage_accounts => }/pgp_stack.ui | 0 libdino/src/application.vala | 89 ---------------- libdino/src/service/pgp_manager.vala | 2 +- main/CMakeLists.txt | 86 +++++++++++++++- .../add_conversation/add_contact_dialog.ui | 0 .../add_conversation/add_groupchat_dialog.ui | 0 .../conference_details_fragment.ui | 0 .../data/add_conversation/list_row.ui | 0 .../add_conversation/select_jid_fragment.ui | 0 {libdino => main}/data/chat_input.ui | 0 .../data/conversation_list_titlebar.ui | 0 .../conversation_selector/chat_row_tooltip.ui | 0 .../conversation_selector/conversation_row.ui | 0 .../data/conversation_selector/view.ui | 0 .../data/conversation_summary/message_item.ui | 0 .../data/conversation_summary/view.ui | 0 .../data/conversation_titlebar.ui | 0 {libdino => main}/data/gschemas.compiled | Bin {libdino => main}/data/img/double_tick.svg | 0 {libdino => main}/data/img/send.svg | 0 {libdino => main}/data/img/status_away.svg | 0 {libdino => main}/data/img/status_chat.svg | 0 {libdino => main}/data/img/status_dnd.svg | 0 {libdino => main}/data/img/status_online.svg | 0 {libdino => main}/data/img/tick.svg | 0 .../data/manage_accounts/account_row.ui | 0 .../manage_accounts/add_account_dialog.ui | 0 .../data/manage_accounts/dialog.ui | 0 {libdino => main}/data/menu_add.ui | 0 {libdino => main}/data/menu_app.ui | 0 {libdino => main}/data/menu_conversation.ui | 0 {libdino => main}/data/menu_encryption.ui | 0 {libdino => main}/data/occupant_list.ui | 0 {libdino => main}/data/occupant_list_item.ui | 0 {libdino => main}/data/settings.gschema.xml | 0 {libdino => main}/data/settings_dialog.ui | 0 {libdino => main}/data/style.css | 0 {libdino => main}/data/unified_window.ui | 0 main/src/main.vala | 2 +- .../chat/add_contact_dialog.vala | 0 .../src/ui/add_conversation/chat/dialog.vala | 0 .../ui/add_conversation/chat/roster_list.vala | 0 .../conference/add_groupchat_dialog.vala | 0 .../conference_details_fragment.vala | 0 .../conference/conference_list.vala | 0 .../add_conversation/conference/dialog.vala | 0 .../src/ui/add_conversation/list_row.vala | 0 .../add_conversation/select_jid_fragment.vala | 0 main/src/ui/application.vala | 97 ++++++++++++++++++ .../src/ui/avatar_generator.vala | 0 {libdino => main}/src/ui/chat_input.vala | 0 .../src/ui/conversation_list_titlebar.vala | 0 .../ui/conversation_selector/chat_row.vala | 0 .../conversation_row.vala | 0 .../conversation_selector/groupchat_row.vala | 0 .../src/ui/conversation_selector/list.vala | 0 .../src/ui/conversation_selector/view.vala | 0 .../merged_message_item.vala | 0 .../merged_status_item.vala | 0 .../ui/conversation_summary/status_item.vala | 0 .../src/ui/conversation_summary/view.vala | 0 .../src/ui/conversation_titlebar.vala | 0 .../src/ui/manage_accounts/account_row.vala | 0 .../manage_accounts/add_account_dialog.vala | 0 .../src/ui/manage_accounts/dialog.vala | 0 {libdino => main}/src/ui/notifications.vala | 0 {libdino => main}/src/ui/occupant_list.vala | 0 .../src/ui/occupant_list_row.vala | 0 {libdino => main}/src/ui/settings_dialog.vala | 0 {libdino => main}/src/ui/unified_window.vala | 0 {libdino => main}/src/ui/util.vala | 0 73 files changed, 191 insertions(+), 166 deletions(-) rename libdino/data/{manage_accounts => }/pgp_stack.ui (100%) rename {libdino => main}/data/add_conversation/add_contact_dialog.ui (100%) rename {libdino => main}/data/add_conversation/add_groupchat_dialog.ui (100%) rename {libdino => main}/data/add_conversation/conference_details_fragment.ui (100%) rename {libdino => main}/data/add_conversation/list_row.ui (100%) rename {libdino => main}/data/add_conversation/select_jid_fragment.ui (100%) rename {libdino => main}/data/chat_input.ui (100%) rename {libdino => main}/data/conversation_list_titlebar.ui (100%) rename {libdino => main}/data/conversation_selector/chat_row_tooltip.ui (100%) rename {libdino => main}/data/conversation_selector/conversation_row.ui (100%) rename {libdino => main}/data/conversation_selector/view.ui (100%) rename {libdino => main}/data/conversation_summary/message_item.ui (100%) rename {libdino => main}/data/conversation_summary/view.ui (100%) rename {libdino => main}/data/conversation_titlebar.ui (100%) rename {libdino => main}/data/gschemas.compiled (100%) rename {libdino => main}/data/img/double_tick.svg (100%) rename {libdino => main}/data/img/send.svg (100%) rename {libdino => main}/data/img/status_away.svg (100%) rename {libdino => main}/data/img/status_chat.svg (100%) rename {libdino => main}/data/img/status_dnd.svg (100%) rename {libdino => main}/data/img/status_online.svg (100%) rename {libdino => main}/data/img/tick.svg (100%) rename {libdino => main}/data/manage_accounts/account_row.ui (100%) rename {libdino => main}/data/manage_accounts/add_account_dialog.ui (100%) rename {libdino => main}/data/manage_accounts/dialog.ui (100%) rename {libdino => main}/data/menu_add.ui (100%) rename {libdino => main}/data/menu_app.ui (100%) rename {libdino => main}/data/menu_conversation.ui (100%) rename {libdino => main}/data/menu_encryption.ui (100%) rename {libdino => main}/data/occupant_list.ui (100%) rename {libdino => main}/data/occupant_list_item.ui (100%) rename {libdino => main}/data/settings.gschema.xml (100%) rename {libdino => main}/data/settings_dialog.ui (100%) rename {libdino => main}/data/style.css (100%) rename {libdino => main}/data/unified_window.ui (100%) rename {libdino => main}/src/ui/add_conversation/chat/add_contact_dialog.vala (100%) rename {libdino => main}/src/ui/add_conversation/chat/dialog.vala (100%) rename {libdino => main}/src/ui/add_conversation/chat/roster_list.vala (100%) rename {libdino => main}/src/ui/add_conversation/conference/add_groupchat_dialog.vala (100%) rename {libdino => main}/src/ui/add_conversation/conference/conference_details_fragment.vala (100%) rename {libdino => main}/src/ui/add_conversation/conference/conference_list.vala (100%) rename {libdino => main}/src/ui/add_conversation/conference/dialog.vala (100%) rename {libdino => main}/src/ui/add_conversation/list_row.vala (100%) rename {libdino => main}/src/ui/add_conversation/select_jid_fragment.vala (100%) create mode 100644 main/src/ui/application.vala rename {libdino => main}/src/ui/avatar_generator.vala (100%) rename {libdino => main}/src/ui/chat_input.vala (100%) rename {libdino => main}/src/ui/conversation_list_titlebar.vala (100%) rename {libdino => main}/src/ui/conversation_selector/chat_row.vala (100%) rename {libdino => main}/src/ui/conversation_selector/conversation_row.vala (100%) rename {libdino => main}/src/ui/conversation_selector/groupchat_row.vala (100%) rename {libdino => main}/src/ui/conversation_selector/list.vala (100%) rename {libdino => main}/src/ui/conversation_selector/view.vala (100%) rename {libdino => main}/src/ui/conversation_summary/merged_message_item.vala (100%) rename {libdino => main}/src/ui/conversation_summary/merged_status_item.vala (100%) rename {libdino => main}/src/ui/conversation_summary/status_item.vala (100%) rename {libdino => main}/src/ui/conversation_summary/view.vala (100%) rename {libdino => main}/src/ui/conversation_titlebar.vala (100%) rename {libdino => main}/src/ui/manage_accounts/account_row.vala (100%) rename {libdino => main}/src/ui/manage_accounts/add_account_dialog.vala (100%) rename {libdino => main}/src/ui/manage_accounts/dialog.vala (100%) rename {libdino => main}/src/ui/notifications.vala (100%) rename {libdino => main}/src/ui/occupant_list.vala (100%) rename {libdino => main}/src/ui/occupant_list_row.vala (100%) rename {libdino => main}/src/ui/settings_dialog.vala (100%) rename {libdino => main}/src/ui/unified_window.vala (100%) rename {libdino => main}/src/ui/util.vala (100%) diff --git a/cmake/CompileGResources.cmake b/cmake/CompileGResources.cmake index e9a8d179..14d2b2c8 100644 --- a/cmake/CompileGResources.cmake +++ b/cmake/CompileGResources.cmake @@ -131,16 +131,16 @@ function(COMPILE_GRESOURCES output xml_out) ("${res}" STREQUAL "TOPIXDATA"))) add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/resources/${res}" - COMMAND ${CMAKE_COMMAND} -E copy "${CG_ARG_SOURCE_DIR}/${res}" "${CMAKE_BINARY_DIR}/resources/${res}" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/resources/${res}" + COMMAND ${CMAKE_COMMAND} -E copy "${CG_ARG_SOURCE_DIR}/${res}" "${CMAKE_CURRENT_BINARY_DIR}/resources/${res}" MAIN_DEPENDENCY "${CG_ARG_SOURCE_DIR}/${res}") - list(APPEND CG_RESOURCES_DEPENDENCIES "${CMAKE_BINARY_DIR}/resources/${res}") + list(APPEND CG_RESOURCES_DEPENDENCIES "${CMAKE_CURRENT_BINARY_DIR}/resources/${res}") endif() endforeach() # Construct .gresource.xml path. - set(CG_XML_FILE_PATH "${CMAKE_BINARY_DIR}/resources/.gresource.xml") + set(CG_XML_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/resources/.gresource.xml") # Generate gresources XML target. list(APPEND CG_CMAKE_SCRIPT_ARGS "-D") @@ -186,13 +186,13 @@ function(COMPILE_GRESOURCES output xml_out) COMMAND ${CMAKE_COMMAND} ARGS ${CG_CMAKE_SCRIPT_ARGS} DEPENDS ${CG_RESOURCES_DEPENDENCIES} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT ${CG_XML_CUSTOM_COMMAND_COMMENT}) # Create target manually if not set (to make sure glib-compile-resources # doesn't change behaviour with it's naming standards). if (NOT CG_ARG_TARGET) - set(CG_ARG_TARGET "${CMAKE_BINARY_DIR}/resources") + set(CG_ARG_TARGET "${CMAKE_CURRENT_BINARY_DIR}/resources") set(CG_ARG_TARGET "${CG_ARG_TARGET}.${CG_TARGET_FILE_ENDING}") endif() diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt index ece8a56f..15a434e9 100644 --- a/libdino/CMakeLists.txt +++ b/libdino/CMakeLists.txt @@ -9,52 +9,19 @@ set(LIBDINO_PACKAGES glib-2.0 gtk+-3.0 gmodule-2.0 - libnotify sqlite3 ) pkg_check_modules(LIBDINO REQUIRED ${LIBDINO_PACKAGES}) set(RESOURCE_LIST - img/double_tick.svg - img/status_away.svg - img/status_chat.svg - img/status_dnd.svg - img/status_online.svg - img/tick.svg - - add_conversation/add_contact_dialog.ui - add_conversation/add_groupchat_dialog.ui - add_conversation/conference_details_fragment.ui - add_conversation/list_row.ui - add_conversation/select_jid_fragment.ui - chat_input.ui - conversation_list_titlebar.ui - conversation_selector/view.ui - conversation_selector/chat_row_tooltip.ui - conversation_selector/conversation_row.ui - conversation_summary/message_item.ui - conversation_summary/view.ui - conversation_titlebar.ui - manage_accounts/account_row.ui - manage_accounts/add_account_dialog.ui - manage_accounts/dialog.ui - manage_accounts/pgp_stack.ui - menu_add.ui - menu_app.ui - menu_conversation.ui - menu_encryption.ui - occupant_list.ui - occupant_list_item.ui - style.css - settings_dialog.ui - unified_window.ui + pgp_stack.ui ) compile_gresources( LIBDINO_GRESOURCES_TARGET LIBDINO_GRESOURCES_XML - TARGET ${CMAKE_BINARY_DIR}/resources/resources.c + TARGET ${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c TYPE EMBED_C RESOURCES ${RESOURCE_LIST} PREFIX /org/dino-im @@ -96,38 +63,6 @@ SOURCES src/service/stream_interactor.vala src/settings.vala - - src/ui/add_conversation/chat/add_contact_dialog.vala - src/ui/add_conversation/chat/roster_list.vala - src/ui/add_conversation/chat/dialog.vala - src/ui/add_conversation/conference/add_groupchat_dialog.vala - src/ui/add_conversation/conference/conference_details_fragment.vala - src/ui/add_conversation/conference/conference_list.vala - src/ui/add_conversation/conference/dialog.vala - src/ui/add_conversation/list_row.vala - src/ui/add_conversation/select_jid_fragment.vala - src/ui/avatar_generator.vala - src/ui/chat_input.vala - src/ui/conversation_list_titlebar.vala - src/ui/conversation_selector/chat_row.vala - src/ui/conversation_selector/conversation_row.vala - src/ui/conversation_selector/groupchat_row.vala - src/ui/conversation_selector/list.vala - src/ui/conversation_selector/view.vala - src/ui/conversation_summary/merged_message_item.vala - src/ui/conversation_summary/merged_status_item.vala - src/ui/conversation_summary/status_item.vala - src/ui/conversation_summary/view.vala - src/ui/conversation_titlebar.vala - src/ui/manage_accounts/account_row.vala - src/ui/manage_accounts/add_account_dialog.vala - src/ui/manage_accounts/dialog.vala - src/ui/notifications.vala - src/ui/occupant_list.vala - src/ui/occupant_list_row.vala - src/ui/settings_dialog.vala - src/ui/unified_window.vala - src/ui/util.vala CUSTOM_VAPIS "${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi" "${CMAKE_BINARY_DIR}/exports/qlite.vapi" diff --git a/libdino/data/manage_accounts/pgp_stack.ui b/libdino/data/pgp_stack.ui similarity index 100% rename from libdino/data/manage_accounts/pgp_stack.ui rename to libdino/data/pgp_stack.ui diff --git a/libdino/src/application.vala b/libdino/src/application.vala index 2acb1479..eb8160a9 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -1,7 +1,6 @@ using Gtk; using Dino.Entities; -using Dino.Ui; public class Dino.Application : Gtk.Application { @@ -9,13 +8,6 @@ public class Dino.Application : Gtk.Application { public StreamInteractor stream_interaction; public Plugins.Registry plugin_registry = new Plugins.Registry(); - private Notifications notifications; - private UnifiedWindow? window; - private ConversationSelector.View? filterable_conversation_list; - private ConversationSelector.List? conversation_list; - private ConversationSummary.View? conversation_frame; - private ChatInput? chat_input; - public Application() { this.db = new Database("store.sqlite3"); this.stream_interaction = new StreamInteractor(db); @@ -29,87 +21,6 @@ public class Dino.Application : Gtk.Application { RosterManager.start(stream_interaction); ConversationManager.start(stream_interaction, db); ChatInteraction.start(stream_interaction); - - Notify.init("dino"); - notifications = new Notifications(stream_interaction); - notifications.start(); - - load_css(); - } - - public override void activate() { - create_set_app_menu(); - create_window(); - window.show_all(); - restore(); - } - - private void create_window() { - window = new UnifiedWindow(this, stream_interaction); - - filterable_conversation_list = window.filterable_conversation_list; - conversation_list = window.filterable_conversation_list.conversation_list; - conversation_frame = window.conversation_frame; - chat_input = window.chat_input; - } - - private void show_accounts_window() { - ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db); - dialog.set_transient_for(window); - dialog.account_enabled.connect(add_connection); - dialog.account_disabled.connect(remove_connection); - dialog.show(); - } - - private void show_settings_window() { - SettingsDialog dialog = new SettingsDialog(); - dialog.set_transient_for(window); - dialog.show(); - } - - private void create_set_app_menu() { - SimpleAction accounts_action = new SimpleAction("accounts", null); - accounts_action.activate.connect(show_accounts_window); - add_action(accounts_action); - - SimpleAction settings_action = new SimpleAction("settings", null); - settings_action.activate.connect(show_settings_window); - add_action(settings_action); - - SimpleAction quit_action = new SimpleAction("quit", null); - quit_action.activate.connect(quit); - add_action(quit_action); - add_accelerator("Q", "app.quit", null); - - Builder builder = new Builder.from_resource("/org/dino-im/menu_app.ui"); - MenuModel menu = builder.get_object("menu_app") as MenuModel; - - set_app_menu(menu); - } - - private void restore() { - foreach (Account account in db.get_accounts()) { - if (account.enabled) add_connection(account); - } - } - - private void add_connection(Account account) { - stream_interaction.connect(account); - } - - 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/libdino/src/service/pgp_manager.vala b/libdino/src/service/pgp_manager.vala index a91feac6..447c1f7f 100644 --- a/libdino/src/service/pgp_manager.vala +++ b/libdino/src/service/pgp_manager.vala @@ -43,7 +43,7 @@ namespace Dino { } } - [GtkTemplate (ui = "/org/dino-im/manage_accounts/pgp_stack.ui")] + [GtkTemplate (ui = "/org/dino-im/pgp_stack.ui")] private class AccountSettingsWidget : Gtk.Stack, Plugins.AccountSettingsWidget { [GtkChild] private Gtk.Label pgp_label; [GtkChild] private Gtk.Button pgp_button; diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index ce00206e..6547f752 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,6 +1,7 @@ find_package(Vala REQUIRED) find_package(PkgConfig REQUIRED) include(${VALA_USE_FILE}) +include(GlibCompileResourcesSupport) set(MAIN_PACKAGES gee-0.8 @@ -8,20 +9,101 @@ set(MAIN_PACKAGES glib-2.0 gtk+-3.0 gmodule-2.0 + libnotify sqlite3 ) pkg_check_modules(MAIN REQUIRED ${MAIN_PACKAGES}) +set(RESOURCE_LIST + img/double_tick.svg + img/status_away.svg + img/status_chat.svg + img/status_dnd.svg + img/status_online.svg + img/tick.svg + + add_conversation/add_contact_dialog.ui + add_conversation/add_groupchat_dialog.ui + add_conversation/conference_details_fragment.ui + add_conversation/list_row.ui + add_conversation/select_jid_fragment.ui + chat_input.ui + conversation_list_titlebar.ui + conversation_selector/view.ui + conversation_selector/chat_row_tooltip.ui + conversation_selector/conversation_row.ui + conversation_summary/message_item.ui + conversation_summary/view.ui + conversation_titlebar.ui + manage_accounts/account_row.ui + manage_accounts/add_account_dialog.ui + manage_accounts/dialog.ui + menu_add.ui + menu_app.ui + menu_conversation.ui + menu_encryption.ui + occupant_list.ui + occupant_list_item.ui + style.css + settings_dialog.ui + unified_window.ui +) + +compile_gresources( + MAIN_GRESOURCES_TARGET + MAIN_GRESOURCES_XML + TARGET ${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c + TYPE EMBED_C + RESOURCES ${RESOURCE_LIST} + PREFIX /org/dino-im + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data +) + vala_precompile(MAIN_VALA_C SOURCES src/main.vala + + src/ui/application.vala + src/ui/add_conversation/chat/add_contact_dialog.vala + src/ui/add_conversation/chat/roster_list.vala + src/ui/add_conversation/chat/dialog.vala + src/ui/add_conversation/conference/add_groupchat_dialog.vala + src/ui/add_conversation/conference/conference_details_fragment.vala + src/ui/add_conversation/conference/conference_list.vala + src/ui/add_conversation/conference/dialog.vala + src/ui/add_conversation/list_row.vala + src/ui/add_conversation/select_jid_fragment.vala + src/ui/avatar_generator.vala + src/ui/chat_input.vala + src/ui/conversation_list_titlebar.vala + src/ui/conversation_selector/chat_row.vala + src/ui/conversation_selector/conversation_row.vala + src/ui/conversation_selector/groupchat_row.vala + src/ui/conversation_selector/list.vala + src/ui/conversation_selector/view.vala + src/ui/conversation_summary/merged_message_item.vala + src/ui/conversation_summary/merged_status_item.vala + src/ui/conversation_summary/status_item.vala + src/ui/conversation_summary/view.vala + src/ui/conversation_titlebar.vala + src/ui/manage_accounts/account_row.vala + src/ui/manage_accounts/add_account_dialog.vala + src/ui/manage_accounts/dialog.vala + src/ui/notifications.vala + src/ui/occupant_list.vala + src/ui/occupant_list_row.vala + src/ui/settings_dialog.vala + src/ui/unified_window.vala + src/ui/util.vala CUSTOM_VAPIS ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi ${CMAKE_BINARY_DIR}/exports/qlite.vapi ${CMAKE_BINARY_DIR}/exports/dino_internal.vapi PACKAGES ${MAIN_PACKAGES} +GRESOURCES + ${MAIN_GRESOURCES_XML} OPTIONS --target-glib=2.38 ${GLOBAL_DEBUG_FLAGS} @@ -30,6 +112,6 @@ OPTIONS set(CFLAGS ${VALA_CFLAGS} ${MAIN_CFLAGS}) add_definitions(${CFLAGS}) -add_executable(dino ${MAIN_VALA_C}) +add_executable(dino ${MAIN_VALA_C} ${MAIN_GRESOURCES_TARGET}) add_dependencies(dino dino-vapi) -target_link_libraries(dino libdino) \ No newline at end of file +target_link_libraries(dino libdino ${MAIN_LIBRARIES}) \ No newline at end of file diff --git a/libdino/data/add_conversation/add_contact_dialog.ui b/main/data/add_conversation/add_contact_dialog.ui similarity index 100% rename from libdino/data/add_conversation/add_contact_dialog.ui rename to main/data/add_conversation/add_contact_dialog.ui diff --git a/libdino/data/add_conversation/add_groupchat_dialog.ui b/main/data/add_conversation/add_groupchat_dialog.ui similarity index 100% rename from libdino/data/add_conversation/add_groupchat_dialog.ui rename to main/data/add_conversation/add_groupchat_dialog.ui diff --git a/libdino/data/add_conversation/conference_details_fragment.ui b/main/data/add_conversation/conference_details_fragment.ui similarity index 100% rename from libdino/data/add_conversation/conference_details_fragment.ui rename to main/data/add_conversation/conference_details_fragment.ui diff --git a/libdino/data/add_conversation/list_row.ui b/main/data/add_conversation/list_row.ui similarity index 100% rename from libdino/data/add_conversation/list_row.ui rename to main/data/add_conversation/list_row.ui diff --git a/libdino/data/add_conversation/select_jid_fragment.ui b/main/data/add_conversation/select_jid_fragment.ui similarity index 100% rename from libdino/data/add_conversation/select_jid_fragment.ui rename to main/data/add_conversation/select_jid_fragment.ui diff --git a/libdino/data/chat_input.ui b/main/data/chat_input.ui similarity index 100% rename from libdino/data/chat_input.ui rename to main/data/chat_input.ui diff --git a/libdino/data/conversation_list_titlebar.ui b/main/data/conversation_list_titlebar.ui similarity index 100% rename from libdino/data/conversation_list_titlebar.ui rename to main/data/conversation_list_titlebar.ui diff --git a/libdino/data/conversation_selector/chat_row_tooltip.ui b/main/data/conversation_selector/chat_row_tooltip.ui similarity index 100% rename from libdino/data/conversation_selector/chat_row_tooltip.ui rename to main/data/conversation_selector/chat_row_tooltip.ui diff --git a/libdino/data/conversation_selector/conversation_row.ui b/main/data/conversation_selector/conversation_row.ui similarity index 100% rename from libdino/data/conversation_selector/conversation_row.ui rename to main/data/conversation_selector/conversation_row.ui diff --git a/libdino/data/conversation_selector/view.ui b/main/data/conversation_selector/view.ui similarity index 100% rename from libdino/data/conversation_selector/view.ui rename to main/data/conversation_selector/view.ui diff --git a/libdino/data/conversation_summary/message_item.ui b/main/data/conversation_summary/message_item.ui similarity index 100% rename from libdino/data/conversation_summary/message_item.ui rename to main/data/conversation_summary/message_item.ui diff --git a/libdino/data/conversation_summary/view.ui b/main/data/conversation_summary/view.ui similarity index 100% rename from libdino/data/conversation_summary/view.ui rename to main/data/conversation_summary/view.ui diff --git a/libdino/data/conversation_titlebar.ui b/main/data/conversation_titlebar.ui similarity index 100% rename from libdino/data/conversation_titlebar.ui rename to main/data/conversation_titlebar.ui diff --git a/libdino/data/gschemas.compiled b/main/data/gschemas.compiled similarity index 100% rename from libdino/data/gschemas.compiled rename to main/data/gschemas.compiled diff --git a/libdino/data/img/double_tick.svg b/main/data/img/double_tick.svg similarity index 100% rename from libdino/data/img/double_tick.svg rename to main/data/img/double_tick.svg diff --git a/libdino/data/img/send.svg b/main/data/img/send.svg similarity index 100% rename from libdino/data/img/send.svg rename to main/data/img/send.svg diff --git a/libdino/data/img/status_away.svg b/main/data/img/status_away.svg similarity index 100% rename from libdino/data/img/status_away.svg rename to main/data/img/status_away.svg diff --git a/libdino/data/img/status_chat.svg b/main/data/img/status_chat.svg similarity index 100% rename from libdino/data/img/status_chat.svg rename to main/data/img/status_chat.svg diff --git a/libdino/data/img/status_dnd.svg b/main/data/img/status_dnd.svg similarity index 100% rename from libdino/data/img/status_dnd.svg rename to main/data/img/status_dnd.svg diff --git a/libdino/data/img/status_online.svg b/main/data/img/status_online.svg similarity index 100% rename from libdino/data/img/status_online.svg rename to main/data/img/status_online.svg diff --git a/libdino/data/img/tick.svg b/main/data/img/tick.svg similarity index 100% rename from libdino/data/img/tick.svg rename to main/data/img/tick.svg diff --git a/libdino/data/manage_accounts/account_row.ui b/main/data/manage_accounts/account_row.ui similarity index 100% rename from libdino/data/manage_accounts/account_row.ui rename to main/data/manage_accounts/account_row.ui diff --git a/libdino/data/manage_accounts/add_account_dialog.ui b/main/data/manage_accounts/add_account_dialog.ui similarity index 100% rename from libdino/data/manage_accounts/add_account_dialog.ui rename to main/data/manage_accounts/add_account_dialog.ui diff --git a/libdino/data/manage_accounts/dialog.ui b/main/data/manage_accounts/dialog.ui similarity index 100% rename from libdino/data/manage_accounts/dialog.ui rename to main/data/manage_accounts/dialog.ui diff --git a/libdino/data/menu_add.ui b/main/data/menu_add.ui similarity index 100% rename from libdino/data/menu_add.ui rename to main/data/menu_add.ui diff --git a/libdino/data/menu_app.ui b/main/data/menu_app.ui similarity index 100% rename from libdino/data/menu_app.ui rename to main/data/menu_app.ui diff --git a/libdino/data/menu_conversation.ui b/main/data/menu_conversation.ui similarity index 100% rename from libdino/data/menu_conversation.ui rename to main/data/menu_conversation.ui diff --git a/libdino/data/menu_encryption.ui b/main/data/menu_encryption.ui similarity index 100% rename from libdino/data/menu_encryption.ui rename to main/data/menu_encryption.ui diff --git a/libdino/data/occupant_list.ui b/main/data/occupant_list.ui similarity index 100% rename from libdino/data/occupant_list.ui rename to main/data/occupant_list.ui diff --git a/libdino/data/occupant_list_item.ui b/main/data/occupant_list_item.ui similarity index 100% rename from libdino/data/occupant_list_item.ui rename to main/data/occupant_list_item.ui diff --git a/libdino/data/settings.gschema.xml b/main/data/settings.gschema.xml similarity index 100% rename from libdino/data/settings.gschema.xml rename to main/data/settings.gschema.xml diff --git a/libdino/data/settings_dialog.ui b/main/data/settings_dialog.ui similarity index 100% rename from libdino/data/settings_dialog.ui rename to main/data/settings_dialog.ui diff --git a/libdino/data/style.css b/main/data/style.css similarity index 100% rename from libdino/data/style.css rename to main/data/style.css diff --git a/libdino/data/unified_window.ui b/main/data/unified_window.ui similarity index 100% rename from libdino/data/unified_window.ui rename to main/data/unified_window.ui diff --git a/main/src/main.vala b/main/src/main.vala index 21e45bf4..d0e47213 100644 --- a/main/src/main.vala +++ b/main/src/main.vala @@ -5,7 +5,7 @@ namespace Dino { void main(string[] args) { Gtk.init(ref args); - Application app = new Application(); + Dino.Ui.Application app = new Dino.Ui.Application(); Plugins.Loader loader = new Plugins.Loader(); foreach(string plugin in new string[]{}) { try { diff --git a/libdino/src/ui/add_conversation/chat/add_contact_dialog.vala b/main/src/ui/add_conversation/chat/add_contact_dialog.vala similarity index 100% rename from libdino/src/ui/add_conversation/chat/add_contact_dialog.vala rename to main/src/ui/add_conversation/chat/add_contact_dialog.vala diff --git a/libdino/src/ui/add_conversation/chat/dialog.vala b/main/src/ui/add_conversation/chat/dialog.vala similarity index 100% rename from libdino/src/ui/add_conversation/chat/dialog.vala rename to main/src/ui/add_conversation/chat/dialog.vala diff --git a/libdino/src/ui/add_conversation/chat/roster_list.vala b/main/src/ui/add_conversation/chat/roster_list.vala similarity index 100% rename from libdino/src/ui/add_conversation/chat/roster_list.vala rename to main/src/ui/add_conversation/chat/roster_list.vala diff --git a/libdino/src/ui/add_conversation/conference/add_groupchat_dialog.vala b/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala similarity index 100% rename from libdino/src/ui/add_conversation/conference/add_groupchat_dialog.vala rename to main/src/ui/add_conversation/conference/add_groupchat_dialog.vala diff --git a/libdino/src/ui/add_conversation/conference/conference_details_fragment.vala b/main/src/ui/add_conversation/conference/conference_details_fragment.vala similarity index 100% rename from libdino/src/ui/add_conversation/conference/conference_details_fragment.vala rename to main/src/ui/add_conversation/conference/conference_details_fragment.vala diff --git a/libdino/src/ui/add_conversation/conference/conference_list.vala b/main/src/ui/add_conversation/conference/conference_list.vala similarity index 100% rename from libdino/src/ui/add_conversation/conference/conference_list.vala rename to main/src/ui/add_conversation/conference/conference_list.vala diff --git a/libdino/src/ui/add_conversation/conference/dialog.vala b/main/src/ui/add_conversation/conference/dialog.vala similarity index 100% rename from libdino/src/ui/add_conversation/conference/dialog.vala rename to main/src/ui/add_conversation/conference/dialog.vala diff --git a/libdino/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala similarity index 100% rename from libdino/src/ui/add_conversation/list_row.vala rename to main/src/ui/add_conversation/list_row.vala diff --git a/libdino/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala similarity index 100% rename from libdino/src/ui/add_conversation/select_jid_fragment.vala rename to main/src/ui/add_conversation/select_jid_fragment.vala diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala new file mode 100644 index 00000000..1adccf8e --- /dev/null +++ b/main/src/ui/application.vala @@ -0,0 +1,97 @@ +using Gtk; + +using Dino.Entities; +using Dino.Ui; + +public class Dino.Ui.Application : Dino.Application { + private Notifications notifications; + private UnifiedWindow? window; + private ConversationSelector.View? filterable_conversation_list; + private ConversationSelector.List? conversation_list; + private ConversationSummary.View? conversation_frame; + private ChatInput? chat_input; + + public Application() { + Notify.init("dino"); + notifications = new Notifications(stream_interaction); + notifications.start(); + + load_css(); + } + + public override void activate() { + create_set_app_menu(); + create_window(); + window.show_all(); + restore(); + } + + private void create_window() { + window = new UnifiedWindow(this, stream_interaction); + + filterable_conversation_list = window.filterable_conversation_list; + conversation_list = window.filterable_conversation_list.conversation_list; + conversation_frame = window.conversation_frame; + chat_input = window.chat_input; + } + + private void show_accounts_window() { + ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db); + dialog.set_transient_for(window); + dialog.account_enabled.connect(add_connection); + dialog.account_disabled.connect(remove_connection); + dialog.show(); + } + + private void show_settings_window() { + SettingsDialog dialog = new SettingsDialog(); + dialog.set_transient_for(window); + dialog.show(); + } + + private void create_set_app_menu() { + SimpleAction accounts_action = new SimpleAction("accounts", null); + accounts_action.activate.connect(show_accounts_window); + add_action(accounts_action); + + SimpleAction settings_action = new SimpleAction("settings", null); + settings_action.activate.connect(show_settings_window); + add_action(settings_action); + + SimpleAction quit_action = new SimpleAction("quit", null); + quit_action.activate.connect(quit); + add_action(quit_action); + add_accelerator("Q", "app.quit", null); + + Builder builder = new Builder.from_resource("/org/dino-im/menu_app.ui"); + MenuModel menu = builder.get_object("menu_app") as MenuModel; + + set_app_menu(menu); + } + + private void restore() { + foreach (Account account in db.get_accounts()) { + if (account.enabled) add_connection(account); + } + } + + private void add_connection(Account account) { + stream_interaction.connect(account); + } + + 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/libdino/src/ui/avatar_generator.vala b/main/src/ui/avatar_generator.vala similarity index 100% rename from libdino/src/ui/avatar_generator.vala rename to main/src/ui/avatar_generator.vala diff --git a/libdino/src/ui/chat_input.vala b/main/src/ui/chat_input.vala similarity index 100% rename from libdino/src/ui/chat_input.vala rename to main/src/ui/chat_input.vala diff --git a/libdino/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala similarity index 100% rename from libdino/src/ui/conversation_list_titlebar.vala rename to main/src/ui/conversation_list_titlebar.vala diff --git a/libdino/src/ui/conversation_selector/chat_row.vala b/main/src/ui/conversation_selector/chat_row.vala similarity index 100% rename from libdino/src/ui/conversation_selector/chat_row.vala rename to main/src/ui/conversation_selector/chat_row.vala diff --git a/libdino/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala similarity index 100% rename from libdino/src/ui/conversation_selector/conversation_row.vala rename to main/src/ui/conversation_selector/conversation_row.vala diff --git a/libdino/src/ui/conversation_selector/groupchat_row.vala b/main/src/ui/conversation_selector/groupchat_row.vala similarity index 100% rename from libdino/src/ui/conversation_selector/groupchat_row.vala rename to main/src/ui/conversation_selector/groupchat_row.vala diff --git a/libdino/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala similarity index 100% rename from libdino/src/ui/conversation_selector/list.vala rename to main/src/ui/conversation_selector/list.vala diff --git a/libdino/src/ui/conversation_selector/view.vala b/main/src/ui/conversation_selector/view.vala similarity index 100% rename from libdino/src/ui/conversation_selector/view.vala rename to main/src/ui/conversation_selector/view.vala diff --git a/libdino/src/ui/conversation_summary/merged_message_item.vala b/main/src/ui/conversation_summary/merged_message_item.vala similarity index 100% rename from libdino/src/ui/conversation_summary/merged_message_item.vala rename to main/src/ui/conversation_summary/merged_message_item.vala diff --git a/libdino/src/ui/conversation_summary/merged_status_item.vala b/main/src/ui/conversation_summary/merged_status_item.vala similarity index 100% rename from libdino/src/ui/conversation_summary/merged_status_item.vala rename to main/src/ui/conversation_summary/merged_status_item.vala diff --git a/libdino/src/ui/conversation_summary/status_item.vala b/main/src/ui/conversation_summary/status_item.vala similarity index 100% rename from libdino/src/ui/conversation_summary/status_item.vala rename to main/src/ui/conversation_summary/status_item.vala diff --git a/libdino/src/ui/conversation_summary/view.vala b/main/src/ui/conversation_summary/view.vala similarity index 100% rename from libdino/src/ui/conversation_summary/view.vala rename to main/src/ui/conversation_summary/view.vala diff --git a/libdino/src/ui/conversation_titlebar.vala b/main/src/ui/conversation_titlebar.vala similarity index 100% rename from libdino/src/ui/conversation_titlebar.vala rename to main/src/ui/conversation_titlebar.vala diff --git a/libdino/src/ui/manage_accounts/account_row.vala b/main/src/ui/manage_accounts/account_row.vala similarity index 100% rename from libdino/src/ui/manage_accounts/account_row.vala rename to main/src/ui/manage_accounts/account_row.vala diff --git a/libdino/src/ui/manage_accounts/add_account_dialog.vala b/main/src/ui/manage_accounts/add_account_dialog.vala similarity index 100% rename from libdino/src/ui/manage_accounts/add_account_dialog.vala rename to main/src/ui/manage_accounts/add_account_dialog.vala diff --git a/libdino/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala similarity index 100% rename from libdino/src/ui/manage_accounts/dialog.vala rename to main/src/ui/manage_accounts/dialog.vala diff --git a/libdino/src/ui/notifications.vala b/main/src/ui/notifications.vala similarity index 100% rename from libdino/src/ui/notifications.vala rename to main/src/ui/notifications.vala diff --git a/libdino/src/ui/occupant_list.vala b/main/src/ui/occupant_list.vala similarity index 100% rename from libdino/src/ui/occupant_list.vala rename to main/src/ui/occupant_list.vala diff --git a/libdino/src/ui/occupant_list_row.vala b/main/src/ui/occupant_list_row.vala similarity index 100% rename from libdino/src/ui/occupant_list_row.vala rename to main/src/ui/occupant_list_row.vala diff --git a/libdino/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala similarity index 100% rename from libdino/src/ui/settings_dialog.vala rename to main/src/ui/settings_dialog.vala diff --git a/libdino/src/ui/unified_window.vala b/main/src/ui/unified_window.vala similarity index 100% rename from libdino/src/ui/unified_window.vala rename to main/src/ui/unified_window.vala diff --git a/libdino/src/ui/util.vala b/main/src/ui/util.vala similarity index 100% rename from libdino/src/ui/util.vala rename to main/src/ui/util.vala