window: Show a spinner while synchronizing
This commit is contained in:
@@ -48,4 +48,27 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- Icon -->
|
||||||
|
<object class="GtkStack" id="icon_stack">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="calendar_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="icon_name">x-office-calendar-symbolic</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">icon</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinner" id="refreshing_spinner">
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="tooltip_text" translatable="yes" context="tooltip">Synchronizing remote calendars…</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="name">spinner</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@@ -257,12 +257,6 @@
|
|||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="popover">calendar_popover</property>
|
<property name="popover">calendar_popover</property>
|
||||||
<property name="tooltip_text" translatable="yes">Manage your calendars</property>
|
<property name="tooltip_text" translatable="yes">Manage your calendars</property>
|
||||||
<child>
|
|
||||||
<object class="GtkImage" id="calendars_button_image">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="icon_name">x-office-calendar-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="pack_type">end</property>
|
<property name="pack_type">end</property>
|
||||||
|
|||||||
@@ -30,10 +30,15 @@ struct _GcalCalendarPopover
|
|||||||
GtkPopover parent;
|
GtkPopover parent;
|
||||||
|
|
||||||
GtkWidget *calendar_listbox;
|
GtkWidget *calendar_listbox;
|
||||||
|
GtkStack *icon_stack;
|
||||||
|
|
||||||
GcalContext *context;
|
GcalContext *context;
|
||||||
|
|
||||||
|
guint icon_changed_source_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static gboolean icon_change_timeout_cb (gpointer data);
|
||||||
|
|
||||||
G_DEFINE_TYPE (GcalCalendarPopover, gcal_calendar_popover, GTK_TYPE_POPOVER)
|
G_DEFINE_TYPE (GcalCalendarPopover, gcal_calendar_popover, GTK_TYPE_POPOVER)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -136,11 +141,35 @@ remove_calendar (GcalCalendarPopover *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
schedule_icon_change (GcalCalendarPopover *self)
|
||||||
|
{
|
||||||
|
if (self->icon_changed_source_id > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_debug ("Scheduling synchronization icon update");
|
||||||
|
|
||||||
|
self->icon_changed_source_id = g_timeout_add (500, icon_change_timeout_cb, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callbacks
|
* Callbacks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
icon_change_timeout_cb (gpointer data)
|
||||||
|
{
|
||||||
|
GcalCalendarPopover *self = GCAL_CALENDAR_POPOVER (data);
|
||||||
|
|
||||||
|
g_debug ("Updating calendar icon to spinner");
|
||||||
|
|
||||||
|
gtk_stack_set_visible_child_name (self->icon_stack, "spinner");
|
||||||
|
|
||||||
|
self->icon_changed_source_id = 0;
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
listbox_sort_func (GtkListBoxRow *row1,
|
listbox_sort_func (GtkListBoxRow *row1,
|
||||||
GtkListBoxRow *row2,
|
GtkListBoxRow *row2,
|
||||||
@@ -179,6 +208,24 @@ on_manager_calendar_removed_cb (GcalManager *manager,
|
|||||||
remove_calendar (self, calendar);
|
remove_calendar (self, calendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_manager_synchronizing_changed_cb (GcalManager *manager,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GcalCalendarPopover *self)
|
||||||
|
{
|
||||||
|
if (!gcal_manager_get_synchronizing (manager))
|
||||||
|
{
|
||||||
|
g_debug ("Updating calendar icon to calendar");
|
||||||
|
|
||||||
|
g_clear_handle_id (&self->icon_changed_source_id, g_source_remove);
|
||||||
|
gtk_stack_set_visible_child_name (self->icon_stack, "icon");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
schedule_icon_change (self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_listbox_row_activated_cb (GtkListBox *listbox,
|
on_listbox_row_activated_cb (GtkListBox *listbox,
|
||||||
GtkListBoxRow *row,
|
GtkListBoxRow *row,
|
||||||
@@ -201,6 +248,7 @@ gcal_calendar_popover_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
GcalCalendarPopover *self = (GcalCalendarPopover *)object;
|
GcalCalendarPopover *self = (GcalCalendarPopover *)object;
|
||||||
|
|
||||||
|
g_clear_handle_id (&self->icon_changed_source_id, g_source_remove);
|
||||||
g_clear_object (&self->context);
|
g_clear_object (&self->context);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gcal_calendar_popover_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gcal_calendar_popover_parent_class)->finalize (object);
|
||||||
@@ -253,7 +301,7 @@ gcal_calendar_popover_set_property (GObject *object,
|
|||||||
g_signal_connect (manager, "calendar-added", G_CALLBACK (on_manager_calendar_added_cb), object);
|
g_signal_connect (manager, "calendar-added", G_CALLBACK (on_manager_calendar_added_cb), object);
|
||||||
g_signal_connect (manager, "calendar-removed", G_CALLBACK (on_manager_calendar_removed_cb), object);
|
g_signal_connect (manager, "calendar-removed", G_CALLBACK (on_manager_calendar_removed_cb), object);
|
||||||
g_signal_connect (manager, "calendar-changed", G_CALLBACK (on_manager_calendar_changed_cb), object);
|
g_signal_connect (manager, "calendar-changed", G_CALLBACK (on_manager_calendar_changed_cb), object);
|
||||||
|
g_signal_connect (manager, "notify::synchronizing", G_CALLBACK (on_manager_synchronizing_changed_cb), object);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -288,6 +336,7 @@ gcal_calendar_popover_class_init (GcalCalendarPopoverClass *klass)
|
|||||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/calendar-popover.ui");
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/calendar-popover.ui");
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalCalendarPopover, calendar_listbox);
|
gtk_widget_class_bind_template_child (widget_class, GcalCalendarPopover, calendar_listbox);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GcalCalendarPopover, icon_stack);
|
||||||
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated_cb);
|
||||||
}
|
}
|
||||||
@@ -302,3 +351,11 @@ gcal_calendar_popover_init (GcalCalendarPopover *self)
|
|||||||
self,
|
self,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkWidget*
|
||||||
|
gcal_calendar_popover_get_icon (GcalCalendarPopover *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GCAL_IS_CALENDAR_POPOVER (self), NULL);
|
||||||
|
|
||||||
|
return GTK_WIDGET (self->icon_stack);
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,4 +27,6 @@ G_BEGIN_DECLS
|
|||||||
#define GCAL_TYPE_CALENDAR_POPOVER (gcal_calendar_popover_get_type())
|
#define GCAL_TYPE_CALENDAR_POPOVER (gcal_calendar_popover_get_type())
|
||||||
G_DECLARE_FINAL_TYPE (GcalCalendarPopover, gcal_calendar_popover, GCAL, CALENDAR_POPOVER, GtkPopover)
|
G_DECLARE_FINAL_TYPE (GcalCalendarPopover, gcal_calendar_popover, GCAL, CALENDAR_POPOVER, GtkPopover)
|
||||||
|
|
||||||
|
GtkWidget* gcal_calendar_popover_get_icon (GcalCalendarPopover *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@@ -106,11 +106,11 @@ struct _GcalWindow
|
|||||||
GtkWidget *notification_close_button;
|
GtkWidget *notification_close_button;
|
||||||
|
|
||||||
/* header_bar widets */
|
/* header_bar widets */
|
||||||
GtkWidget *menu_button;
|
|
||||||
GtkWidget *calendars_button;
|
|
||||||
GtkWidget *back_button;
|
GtkWidget *back_button;
|
||||||
GtkWidget *today_button;
|
GtkWidget *calendars_button;
|
||||||
GtkWidget *forward_button;
|
GtkWidget *forward_button;
|
||||||
|
GtkWidget *menu_button;
|
||||||
|
GtkWidget *today_button;
|
||||||
GtkWidget *views_switcher;
|
GtkWidget *views_switcher;
|
||||||
|
|
||||||
DzlSuggestionButton *search_button;
|
DzlSuggestionButton *search_button;
|
||||||
@@ -1034,7 +1034,6 @@ gcal_window_class_init (GcalWindowClass *klass)
|
|||||||
/* widgets */
|
/* widgets */
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, back_button);
|
gtk_widget_class_bind_template_child (widget_class, GcalWindow, back_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendars_button);
|
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendars_button);
|
||||||
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendar_popover);
|
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendar_popover);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, edit_dialog);
|
gtk_widget_class_bind_template_child (widget_class, GcalWindow, edit_dialog);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, forward_button);
|
gtk_widget_class_bind_template_child (widget_class, GcalWindow, forward_button);
|
||||||
@@ -1101,6 +1100,10 @@ gcal_window_init (GcalWindow *self)
|
|||||||
|
|
||||||
gtk_widget_init_template (GTK_WIDGET (self));
|
gtk_widget_init_template (GTK_WIDGET (self));
|
||||||
|
|
||||||
|
/* Calendar icon */
|
||||||
|
gtk_container_add (GTK_CONTAINER (self->calendars_button),
|
||||||
|
gcal_calendar_popover_get_icon (GCAL_CALENDAR_POPOVER (self->calendar_popover)));
|
||||||
|
|
||||||
self->views[GCAL_WINDOW_VIEW_WEEK] = self->week_view;
|
self->views[GCAL_WINDOW_VIEW_WEEK] = self->week_view;
|
||||||
self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
|
self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
|
||||||
self->views[GCAL_WINDOW_VIEW_YEAR] = self->year_view;
|
self->views[GCAL_WINDOW_VIEW_YEAR] = self->year_view;
|
||||||
|
|||||||
Reference in New Issue
Block a user