mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-10-01 05:23:56 +00:00
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
This commit is contained in:
parent
0bba551772
commit
773fc4bdb7
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in a new issue