Browse Source

Added dialog icons and added rounded edges on message dialog

pipelines/353213535
eidheim 4 years ago
parent
commit
ce99fe4f4b
  1. 4
      docs/custom_styling.md
  2. 25
      src/dialog.cpp
  3. 6
      src/directories.cpp
  4. 20
      src/notebook.cpp
  5. 12
      src/project.cpp
  6. 8
      src/window.cpp

4
docs/custom_styling.md

@ -38,6 +38,10 @@ was made with the following ~/.config/gtk-3.0/gtk.css:
background: transparent; background: transparent;
} }
.juci_notebook {
background: transparent;
}
.juci_notebook :not(slider) { .juci_notebook :not(slider) {
background-color: rgba(255, 255, 255, 0.8); background-color: rgba(255, 255, 255, 0.8);
} }

25
src/dialog.cpp

@ -13,11 +13,21 @@ Dialog::Message::Message(const std::string &text, std::function<void()> &&on_can
set_type_hint(Gdk::WindowTypeHint::WINDOW_TYPE_HINT_NOTIFICATION); set_type_hint(Gdk::WindowTypeHint::WINDOW_TYPE_HINT_NOTIFICATION);
property_decorated() = false; property_decorated() = false;
set_skip_taskbar_hint(true); set_skip_taskbar_hint(true);
auto visual = get_screen()->get_rgba_visual();
auto box = Gtk::manage(new Gtk::Box(Gtk::Orientation::ORIENTATION_VERTICAL)); if(visual)
gtk_widget_set_visual(reinterpret_cast<GtkWidget *>(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)); auto label = Gtk::manage(new Gtk::Label(text));
label->set_padding(10, 10); label->set_padding(7, 7);
box->pack_start(*label); hbox->pack_start(*label);
vbox->pack_start(*hbox);
if(on_cancel) { if(on_cancel) {
auto cancel_button = Gtk::manage(new Gtk::Button("Cancel")); auto cancel_button = Gtk::manage(new Gtk::Button("Cancel"));
cancel_button->signal_clicked().connect([label, on_cancel = std::move(on_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<void()> &&on_can
if(on_cancel) if(on_cancel)
on_cancel(); on_cancel();
}); });
box->pack_start(*cancel_button); vbox->pack_start(*cancel_button);
} }
if(show_progress_bar) if(show_progress_bar)
box->pack_start(progress_bar); vbox->pack_start(progress_bar);
add(*box); add(*vbox);
show_all_children(); show_all_children();
show_now(); show_now();

6
src/directories.cpp

@ -431,9 +431,13 @@ Directories::Directories() : Gtk::ListViewText(1) {
menu_item_delete.signal_activate().connect([this] { menu_item_delete.signal_activate().connect([this] {
if(menu_popup_row_path.empty()) if(menu_popup_row_path.empty())
return; return;
Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(get_toplevel()), "Delete!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(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_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.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(); int result = dialog.run();
if(result == Gtk::RESPONSE_YES) { if(result == Gtk::RESPONSE_YES) {
boost::system::error_code ec; boost::system::error_code ec;

20
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()) { if(source_views_previous_size == source_views.size()) {
// Install rust-analyzer // Install rust-analyzer
auto install_rust_analyzer = [this](const std::string &command, bool &show_dialog) { auto install_rust_analyzer = [this](const std::string &command, bool &show_dialog) {
Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(get_toplevel()), "Install Rust language server", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(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_default_response(Gtk::RESPONSE_YES);
dialog.set_secondary_text("Rust language server not found. Would you like to install rust-analyzer?"); dialog.set_secondary_text("Rust language server not found. Would you like to install rust-analyzer?");
dialog.show_all();
int result = dialog.run(); int result = dialog.run();
dialog.hide(); dialog.hide();
if(result == Gtk::RESPONSE_YES) { if(result == Gtk::RESPONSE_YES) {
@ -615,9 +619,13 @@ void Notebook::install_rust() {
static bool show_dialog = true; static bool show_dialog = true;
if(show_dialog) { if(show_dialog) {
show_dialog = false; show_dialog = false;
Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(get_toplevel()), "Install Rust", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(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_default_response(Gtk::RESPONSE_YES);
dialog.set_secondary_text("Rust not found. Would you like to install Rust?"); dialog.set_secondary_text("Rust not found. Would you like to install Rust?");
dialog.show_all();
int result = dialog.run(); int result = dialog.run();
dialog.hide(); dialog.hide();
if(result == Gtk::RESPONSE_YES) { 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) { bool Notebook::save_modified_dialog(size_t index) {
Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(get_toplevel()), "Save file!", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(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_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(); int result = dialog.run();
if(result == Gtk::RESPONSE_YES) { if(result == Gtk::RESPONSE_YES) {
return save(index); return save(index);

12
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); bool has_debug_build = !debug_build_path.empty() && boost::filesystem::exists(debug_build_path, ec);
if(has_default_build || has_debug_build) { if(has_default_build || has_debug_build) {
Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(Notebook::get().get_toplevel()), "Recreate Build", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO); Gtk::MessageDialog dialog(*static_cast<Gtk::Window *>(Notebook::get().get_toplevel()), "Recreate Build?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO);
dialog.set_default_response(Gtk::RESPONSE_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 "; std::string message = "Are you sure you want to recreate ";
if(has_default_build) if(has_default_build)
message += default_build_path.string(); message += filesystem::get_short_path(default_build_path).string();
if(has_debug_build) { if(has_debug_build) {
if(has_default_build) if(has_default_build)
message += " and "; message += " and ";
message += debug_build_path.string(); message += filesystem::get_short_path(debug_build_path).string();
} }
dialog.set_secondary_text(message + "?"); dialog.set_secondary_text(message + "?");
dialog.show_all();
if(dialog.run() != Gtk::RESPONSE_YES) if(dialog.run() != Gtk::RESPONSE_YES)
return; return;
Usages::Clang::erase_all_caches_for_project(build->project_path, default_build_path); Usages::Clang::erase_all_caches_for_project(build->project_path, default_build_path);

8
src/window.cpp

@ -36,9 +36,9 @@ Window::Window() {
if(screen->get_rgba_visual()) if(screen->get_rgba_visual())
border_radius_style = "border-radius: 5px; "; border_radius_style = "border-radius: 5px; ";
#if GTK_VERSION_GE(3, 20) #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 #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 #endif
provider->load_from_data(R"( 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;} .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_window {background-color: transparent;}
.juci_tooltip_box {)" + border_radius_style + .juci_tooltip_box {)" + border_radius_style +
R"(padding: 3px;} 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); get_style_context()->add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

Loading…
Cancel
Save