From ce99fe4f4bb4250af24160088c70bde732c7d75f Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 12 Jul 2021 16:15:50 +0200 Subject: [PATCH] Added dialog icons and added rounded edges on message dialog --- docs/custom_styling.md | 4 ++++ src/dialog.cpp | 25 +++++++++++++++++-------- src/directories.cpp | 6 +++++- src/notebook.cpp | 20 ++++++++++++++++---- src/project.cpp | 12 ++++++++---- src/window.cpp | 8 ++++++-- 6 files changed, 56 insertions(+), 19 deletions(-) diff --git a/docs/custom_styling.md b/docs/custom_styling.md index bf61a8c..3a099f4 100644 --- a/docs/custom_styling.md +++ b/docs/custom_styling.md @@ -38,6 +38,10 @@ was made with the following ~/.config/gtk-3.0/gtk.css: background: transparent; } +.juci_notebook { + background: transparent; +} + .juci_notebook :not(slider) { background-color: rgba(255, 255, 255, 0.8); } diff --git a/src/dialog.cpp b/src/dialog.cpp index f647098..407601c 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -13,11 +13,21 @@ Dialog::Message::Message(const std::string &text, std::function &&on_can set_type_hint(Gdk::WindowTypeHint::WINDOW_TYPE_HINT_NOTIFICATION); property_decorated() = false; set_skip_taskbar_hint(true); - - auto box = Gtk::manage(new Gtk::Box(Gtk::Orientation::ORIENTATION_VERTICAL)); + auto visual = get_screen()->get_rgba_visual(); + if(visual) + gtk_widget_set_visual(reinterpret_cast(gobj()), visual->gobj()); + get_style_context()->add_class("juci_message_window"); + + auto vbox = Gtk::manage(new Gtk::Box(Gtk::Orientation::ORIENTATION_VERTICAL)); + vbox->get_style_context()->add_class("juci_message_box"); + auto hbox = Gtk::manage(new Gtk::Box(Gtk::Orientation::ORIENTATION_HORIZONTAL)); + auto image = Gtk::manage(new Gtk::Image()); + image->set_from_icon_name("dialog-information", Gtk::BuiltinIconSize::ICON_SIZE_BUTTON); + hbox->pack_start(*image, Gtk::PackOptions::PACK_SHRINK); auto label = Gtk::manage(new Gtk::Label(text)); - label->set_padding(10, 10); - box->pack_start(*label); + label->set_padding(7, 7); + hbox->pack_start(*label); + vbox->pack_start(*hbox); if(on_cancel) { auto cancel_button = Gtk::manage(new Gtk::Button("Cancel")); cancel_button->signal_clicked().connect([label, on_cancel = std::move(on_cancel)] { @@ -25,12 +35,11 @@ Dialog::Message::Message(const std::string &text, std::function &&on_can if(on_cancel) on_cancel(); }); - box->pack_start(*cancel_button); + vbox->pack_start(*cancel_button); } if(show_progress_bar) - box->pack_start(progress_bar); - add(*box); - + vbox->pack_start(progress_bar); + add(*vbox); show_all_children(); show_now(); diff --git a/src/directories.cpp b/src/directories.cpp index 1297b8d..fd6b19e 100644 --- a/src/directories.cpp +++ b/src/directories.cpp @@ -431,9 +431,13 @@ Directories::Directories() : Gtk::ListViewText(1) { menu_item_delete.signal_activate().connect([this] { if(menu_popup_row_path.empty()) return; - Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Delete!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Delete?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::Image image; + image.set_from_icon_name("dialog-warning", Gtk::BuiltinIconSize::ICON_SIZE_DIALOG); + dialog.set_image(image); dialog.set_default_response(Gtk::RESPONSE_NO); dialog.set_secondary_text("Are you sure you want to delete " + filesystem::get_short_path(menu_popup_row_path).string() + "?"); + dialog.show_all(); int result = dialog.run(); if(result == Gtk::RESPONSE_YES) { boost::system::error_code ec; diff --git a/src/notebook.cpp b/src/notebook.cpp index 2af1e8b..84ceb92 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -224,9 +224,13 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position if(source_views_previous_size == source_views.size()) { // Install rust-analyzer auto install_rust_analyzer = [this](const std::string &command, bool &show_dialog) { - Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Install Rust language server", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Install Rust language server?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::Image image; + image.set_from_icon_name("dialog-question", Gtk::BuiltinIconSize::ICON_SIZE_DIALOG); + dialog.set_image(image); dialog.set_default_response(Gtk::RESPONSE_YES); dialog.set_secondary_text("Rust language server not found. Would you like to install rust-analyzer?"); + dialog.show_all(); int result = dialog.run(); dialog.hide(); if(result == Gtk::RESPONSE_YES) { @@ -615,9 +619,13 @@ void Notebook::install_rust() { static bool show_dialog = true; if(show_dialog) { show_dialog = false; - Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Install Rust", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Install Rust?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::Image image; + image.set_from_icon_name("dialog-question", Gtk::BuiltinIconSize::ICON_SIZE_DIALOG); + dialog.set_image(image); dialog.set_default_response(Gtk::RESPONSE_YES); dialog.set_secondary_text("Rust not found. Would you like to install Rust?"); + dialog.show_all(); int result = dialog.run(); dialog.hide(); if(result == Gtk::RESPONSE_YES) { @@ -925,9 +933,13 @@ void Notebook::set_current_view(Source::View *view) { } bool Notebook::save_modified_dialog(size_t index) { - Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::MessageDialog dialog(*static_cast(get_toplevel()), "Save file?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::Image image; + image.set_from_icon_name("document-save", Gtk::BuiltinIconSize::ICON_SIZE_DIALOG); + dialog.set_image(image); dialog.set_default_response(Gtk::RESPONSE_YES); - dialog.set_secondary_text("Do you want to save: " + get_view(index)->file_path.string() + " ?"); + dialog.set_secondary_text("Do you want to save " + filesystem::get_short_path(get_view(index)->file_path).string() + "?"); + dialog.show_all(); int result = dialog.run(); if(result == Gtk::RESPONSE_YES) { return save(index); diff --git a/src/project.cpp b/src/project.cpp index 27d8200..e5359ad 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -778,17 +778,21 @@ void Project::Clang::recreate_build() { bool has_debug_build = !debug_build_path.empty() && boost::filesystem::exists(debug_build_path, ec); if(has_default_build || has_debug_build) { - Gtk::MessageDialog dialog(*static_cast(Notebook::get().get_toplevel()), "Recreate Build", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); - dialog.set_default_response(Gtk::RESPONSE_NO); + Gtk::MessageDialog dialog(*static_cast(Notebook::get().get_toplevel()), "Recreate Build?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); + Gtk::Image image; + image.set_from_icon_name("dialog-question", Gtk::BuiltinIconSize::ICON_SIZE_DIALOG); + dialog.set_image(image); + dialog.set_default_response(Gtk::RESPONSE_YES); std::string message = "Are you sure you want to recreate "; if(has_default_build) - message += default_build_path.string(); + message += filesystem::get_short_path(default_build_path).string(); if(has_debug_build) { if(has_default_build) message += " and "; - message += debug_build_path.string(); + message += filesystem::get_short_path(debug_build_path).string(); } dialog.set_secondary_text(message + "?"); + dialog.show_all(); if(dialog.run() != Gtk::RESPONSE_YES) return; Usages::Clang::erase_all_caches_for_project(build->project_path, default_build_path); diff --git a/src/window.cpp b/src/window.cpp index c8b0830..1e4ab08 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -36,9 +36,9 @@ Window::Window() { if(screen->get_rgba_visual()) border_radius_style = "border-radius: 5px; "; #if GTK_VERSION_GE(3, 20) - std::string notebook_style(".juci_notebook tab {border-radius: 5px 5px 0 0; padding: 0 4px; margin: 0;}"); + std::string notebook_style(".juci_notebook {background: @theme_base_color;} .juci_notebook tab {border-radius: 5px 5px 0 0; padding: 0 4px; margin: 0;}"); #else - std::string notebook_style(".juci_notebook {-GtkNotebook-tab-overlap: 0px;} .juci_notebook tab {border-radius: 5px 5px 0 0; padding: 4px 4px;}"); + std::string notebook_style(".juci_notebook {background: @theme_base_color; -GtkNotebook-tab-overlap: 0px;} .juci_notebook tab {border-radius: 5px 5px 0 0; padding: 4px 4px;}"); #endif provider->load_from_data(R"( .juci_directories *:selected {border-left-color: inherit; color: inherit; background-color: rgba(128, 128, 128 , 0.2); background-image: inherit;} @@ -50,6 +50,10 @@ Window::Window() { .juci_tooltip_window {background-color: transparent;} .juci_tooltip_box {)" + border_radius_style + R"(padding: 3px;} + .juci_message_window {background-color: transparent;} + .juci_message_box {)" + + border_radius_style + + R"(background: @theme_bg_color; padding: 3px;} )"); get_style_context()->add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);