From f5236f1d21463bd4cfb75bb106d0d97688b5b8e8 Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 6 Mar 2016 20:49:38 +0100 Subject: [PATCH] tint2conf: Show only one popup during long operations (issue #563) --- src/tint2conf/main.c | 4 ++-- src/tint2conf/properties.c | 30 ++++++++++++++++++++---------- src/tint2conf/properties.h | 3 ++- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/tint2conf/main.c b/src/tint2conf/main.c index 2a98a72..582b298 100644 --- a/src/tint2conf/main.c +++ b/src/tint2conf/main.c @@ -481,7 +481,7 @@ static void edit_current_theme() sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)); if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) { - GtkWidget *dialog = create_please_wait(); + create_please_wait(); process_events(); gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1); @@ -491,7 +491,7 @@ static void edit_current_theme() gtk_window_present(GTK_WINDOW(prop)); g_free(file); - gtk_widget_destroy(dialog); + destroy_please_wait(); } } diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index 4c9239d..37432a0 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -2209,7 +2209,7 @@ void set_current_icon_theme(const char *theme) void icon_theme_changed() { - GtkWidget *dialog = create_please_wait(); + create_please_wait(); process_events(); if (icon_theme) @@ -2227,7 +2227,7 @@ void icon_theme_changed() load_icons(all_apps); save_icon_cache(icon_theme); - gtk_widget_destroy(dialog); + destroy_please_wait(); } void launcher_icon_theme_changed(GtkWidget *widget, gpointer data) @@ -5380,15 +5380,17 @@ void create_tooltip(GtkWidget *parent) change_paragraph(parent); } -GtkWidget *create_please_wait() +static GtkWidget *please_wait_dialog = NULL; +void create_please_wait() { - GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, "%s", _("Loading...")); - gtk_window_set_title(GTK_WINDOW(dialog), _("Please wait...")); - gtk_window_set_deletable(GTK_WINDOW(dialog), FALSE); - gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 200); - gtk_widget_show_all(dialog); - gtk_widget_set_size_request(dialog, 300, 100); - return (GtkWidget*)dialog; + if (please_wait_dialog) + return; + please_wait_dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, "%s", _("Loading...")); + gtk_window_set_title(GTK_WINDOW(please_wait_dialog), _("Please wait...")); + gtk_window_set_deletable(GTK_WINDOW(please_wait_dialog), FALSE); + gtk_window_set_default_size(GTK_WINDOW(please_wait_dialog), 400, 200); + gtk_widget_show_all(please_wait_dialog); + gtk_widget_set_size_request(please_wait_dialog, 300, 100); } void process_events() @@ -5396,3 +5398,11 @@ void process_events() while (gtk_events_pending()) gtk_main_iteration_do(FALSE); } + +void destroy_please_wait() +{ + if (!please_wait_dialog) + return; + gtk_widget_destroy(please_wait_dialog); + please_wait_dialog = NULL; +} diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 2f4ec6d..d41372e 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -204,7 +204,8 @@ Executor *execp_get_last(); void execp_remove(int i); void execp_update_indices(); -GtkWidget *create_please_wait(); +void create_please_wait(); void process_events(); +void destroy_please_wait(); #endif