window: handle reissue of in-app notification

For now we throw the first one away, and show the second. Eventually we
could handle this better.
This commit is contained in:
Erick Pérez Castellanos
2015-02-16 09:31:21 -05:00
parent 15604b13d8
commit 91defe22de
2 changed files with 38 additions and 28 deletions
+1 -1
View File
@@ -162,7 +162,7 @@
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="hide_notification" object="GcalWindow" swapped="no"/>
<signal name="clicked" handler="hide_notification" object="GcalWindow" swapped="yes"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
+37 -27
View File
@@ -53,6 +53,7 @@ typedef struct
{
/* timeout ids */
guint save_geometry_timeout_id;
guint notification_timeout;
/* upper level widgets */
GtkWidget *main_box;
@@ -171,8 +172,8 @@ static void create_notification (GcalWindow *w
gchar *message,
gchar *button_label);
static void hide_notification (GtkWidget *button,
gpointer user_data);
static void hide_notification (GcalWindow *window,
GtkWidget *button);
/* calendar management */
static void add_source (GcalManager *manager,
@@ -705,16 +706,20 @@ create_notification (GcalWindow *window,
}
static void
hide_notification (GtkWidget *button,
gpointer user_data)
hide_notification (GcalWindow *window,
GtkWidget *button)
{
GcalWindowPrivate *priv;
priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification),
FALSE);
GcalWindowPrivate *priv = gcal_window_get_instance_private (window);
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification), FALSE);
priv->notification_timeout = 0;
}
static gboolean
hide_notification_scheduled (gpointer window)
{
hide_notification (GCAL_WINDOW (window), NULL);
return FALSE;
}
static void
add_source (GcalManager *manager,
@@ -1023,22 +1028,26 @@ edit_dialog_closed (GtkDialog *dialog,
break;
case GCAL_RESPONSE_DELETE_EVENT:
/* delete the event */
create_notification (GCAL_WINDOW (user_data),
_("Event deleted"),
_("Undo"));
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification),
TRUE);
/* FIXME: this will crash if the notification is still open */
if (priv->event_to_delete != NULL)
g_free (priv->event_to_delete);
{
gcal_manager_remove_event (priv->manager, priv->event_to_delete->source, priv->event_to_delete->event_component);
g_clear_pointer (&(priv->event_to_delete), g_free);
create_notification (GCAL_WINDOW (user_data), _("Another event deleted"), _("Undo"));
}
else
{
create_notification (GCAL_WINDOW (user_data), _("Event deleted"), _("Undo"));
}
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification), TRUE);
if (priv->notification_timeout != 0)
g_source_remove (priv->notification_timeout);
priv->notification_timeout = g_timeout_add_seconds (5, hide_notification_scheduled, user_data);
priv->event_to_delete = g_new0 (GcalEventData, 1);
priv->event_to_delete->source =
gcal_edit_dialog_get_source (edit_dialog);
priv->event_to_delete->event_component =
gcal_edit_dialog_get_component (edit_dialog);
priv->event_to_delete->source = gcal_edit_dialog_get_source (edit_dialog);
priv->event_to_delete->event_component = gcal_edit_dialog_get_component (edit_dialog);
uuid = gcal_edit_dialog_get_event_uuid (edit_dialog);
/* hide widget of the event */
@@ -1112,9 +1121,9 @@ search_bar_revealer_toggled (GObject *object,
}
static void
remove_event (GtkWidget *notification,
GParamSpec *spec,
gpointer user_data)
remove_event (GtkWidget *notification,
GParamSpec *spec,
gpointer user_data)
{
GcalWindowPrivate *priv;
@@ -1149,12 +1158,13 @@ undo_remove_event (GtkButton *button,
widgets = gcal_view_get_children_by_uuid (GCAL_VIEW (priv->views[priv->active_view]), uuid);
g_list_foreach (widgets, (GFunc) gtk_widget_show, NULL);
g_object_unref (priv->event_to_delete->event_component);
g_clear_pointer (&(priv->event_to_delete), g_free);
g_list_free (widgets);
g_free (uuid);
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->notification),
FALSE);
g_source_remove (priv->notification_timeout);
hide_notification (GCAL_WINDOW (user_data), NULL);
}
}