summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-11-12 16:32:28 +0100
committerCarlos Soriano <csoriano@gnome.org>2015-11-12 21:43:11 +0100
commite5163bab0c95e4490a0d90618093f483d34a299c (patch)
treea0d3b8b3042b5baa50394101838c4e57597a9b53 /src
parenta5eff664b94e71e1128bc44f165c51f2a325f22e (diff)
downloadnautilus-e5163bab0c95e4490a0d90618093f483d34a299c.tar.gz
toolbar: avoid empty operations popover
We need to check that all windows have the popover hidden to remove the operations, if not, what happens is that if one of the windows has it hidden it removes its operations and all the other popovers become empty. The code is not very beautiful since we have to access all the toolbars of all the windows, which is kind of breaking the design, but well... creating a "operations toolbar manager" just for this looks overkill. https://bugzilla.gnome.org/show_bug.cgi?id=756560
Diffstat (limited to 'src')
-rw-r--r--src/nautilus-toolbar.c38
-rw-r--r--src/nautilus-toolbar.h2
2 files changed, 37 insertions, 3 deletions
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 2f02e74fa..20a204532 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -30,6 +30,7 @@
#include "nautilus-pathbar.h"
#include "nautilus-window.h"
#include "nautilus-progress-info-widget.h"
+#include "nautilus-application.h"
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
@@ -473,13 +474,38 @@ add_operations_button_attention_style (NautilusToolbar *self)
self);
}
+/* It's not the most beautiful solution, but we need to check wheter all windows
+ * have it's button inactive, so the toolbar can schedule to remove the operations
+ * only in that case to avoid other windows to show an empty popover in the oposite
+ * case */
+static gboolean
+is_all_windows_operations_buttons_inactive ()
+{
+ GApplication *application;
+ GList *windows;
+ GList *l;
+ GtkWidget *toolbar;
+
+ application = g_application_get_default ();
+ windows = nautilus_application_get_windows (NAUTILUS_APPLICATION (application));
+
+ for (l = windows; l != NULL; l = l->next) {
+ toolbar = nautilus_window_get_toolbar (NAUTILUS_WINDOW (l->data));
+ if (nautilus_toolbar_is_operations_button_active (NAUTILUS_TOOLBAR (toolbar))) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
static void
on_progress_info_cancelled (NautilusToolbar *self)
{
/* Update the pie chart progress */
gtk_widget_queue_draw (self->priv->operations_icon);
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) {
+ if (is_all_windows_operations_buttons_inactive ()) {
schedule_remove_finished_operations (self);
}
}
@@ -501,7 +527,7 @@ on_progress_info_finished (NautilusToolbar *self,
/* Update the pie chart progress */
gtk_widget_queue_draw (self->priv->operations_icon);
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) {
+ if (is_all_windows_operations_buttons_inactive ()){
schedule_remove_finished_operations (self);
}
@@ -720,7 +746,7 @@ static void
on_operations_button_toggled (NautilusToolbar *self)
{
unschedule_remove_finished_operations (self);
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) {
+ if (is_all_windows_operations_buttons_inactive ()) {
schedule_remove_finished_operations (self);
} else {
update_operations (self);
@@ -988,3 +1014,9 @@ nautilus_toolbar_set_active_slot (NautilusToolbar *toolbar,
}
}
+
+gboolean
+nautilus_toolbar_is_operations_button_active (NautilusToolbar *self)
+{
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button));
+}
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index c66ef91b7..3e0266fc7 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -75,4 +75,6 @@ void nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
void nautilus_toolbar_set_active_slot (NautilusToolbar *toolbar,
NautilusWindowSlot *slot);
+gboolean nautilus_toolbar_is_operations_button_active (NautilusToolbar *toolbar);
+
#endif /* __NAUTILUS_TOOLBAR_H__ */