[gnome-calendar] Added done-edit signal to GcalToolbar.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] Added done-edit signal to GcalToolbar.
- Date: Tue, 3 Jul 2012 19:54:14 +0000 (UTC)
commit caf77599aadf232eb432a95a1ac8206de0c93cb5
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Sun Jul 1 02:57:28 2012 -0400
Added done-edit signal to GcalToolbar.
Connected ::done-edit to GcalEventView widget.
Minor geometry fixes.
src/gcal-editable-reminder.c | 1 -
src/gcal-event-view.c | 38 +++++++++++++++++++++++++++++---------
src/gcal-toolbar.c | 31 ++++++++++++++++++++++++++-----
src/gcal-toolbar.h | 1 +
src/gcal-window.c | 35 ++++++++++++++++++++++++++++++-----
5 files changed, 86 insertions(+), 20 deletions(-)
---
diff --git a/src/gcal-editable-reminder.c b/src/gcal-editable-reminder.c
index a541a80..f75f117 100644
--- a/src/gcal-editable-reminder.c
+++ b/src/gcal-editable-reminder.c
@@ -115,7 +115,6 @@ gcal_editable_reminder_constructed (GObject *object)
"orientation", GTK_ORIENTATION_VERTICAL,
"row-spacing", 6,
"column-spacing", 6,
- "vexpand", FALSE,
"valign", GTK_ALIGN_START,
NULL);
gtk_grid_attach (GTK_GRID (priv->edit_widget), priv->left_box, 0, 0, 1, 1);
diff --git a/src/gcal-event-view.c b/src/gcal-event-view.c
index 61d8ed1..4913bc2 100644
--- a/src/gcal-event-view.c
+++ b/src/gcal-event-view.c
@@ -50,6 +50,8 @@ struct _GcalEventViewPrivate
GtkWidget *attending_maybe;
GtkWidget *attending_no;
+ GtkWidget *delete_button;
+
GcalManager *manager;
};
@@ -147,7 +149,7 @@ gcal_event_view_constructed (GObject *object)
what = gtk_label_new (_("What"));
gtk_widget_set_halign (what, GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (object), what, 0, 0, 1, 1);
- gtk_grid_attach (GTK_GRID (object), priv->e_what, 1, 0, 3, 1);
+ gtk_grid_attach (GTK_GRID (object), priv->e_what, 1, 0, 1, 1);
when = gtk_label_new (_("When"));
gtk_widget_set_valign (when, GTK_ALIGN_START);
@@ -158,33 +160,43 @@ gcal_event_view_constructed (GObject *object)
where = gtk_label_new (_("Where"));
gtk_widget_set_halign (where, GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (object), where, 0, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (object), priv->e_where, 1, 2, 3, 1);
+ gtk_grid_attach (GTK_GRID (object), priv->e_where, 1, 2, 1, 1);
calendar = gtk_label_new (_("Calendar"));
gtk_widget_set_halign (calendar, GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (object), calendar, 0, 3, 1, 1);
- gtk_grid_attach (GTK_GRID (object), priv->cb_cal, 1, 3, 3, 1);
+ gtk_grid_attach (GTK_GRID (object), priv->cb_cal, 1, 3, 1, 1);
desc = gtk_label_new (_("Description"));
gtk_widget_set_halign (desc, GTK_ALIGN_END);
gtk_widget_set_valign (desc, GTK_ALIGN_START);
gtk_grid_attach (GTK_GRID (object), desc, 0, 4, 1, 1);
- gtk_grid_attach (GTK_GRID (object), priv->t_desc, 1, 4, 3, 1);
+ gtk_grid_attach (GTK_GRID (object), priv->t_desc, 1, 4, 1, 1);
rem = gtk_label_new (_("Reminders"));
gtk_widget_set_halign (rem, GTK_ALIGN_END);
gtk_widget_set_valign (rem, GTK_ALIGN_START);
gtk_grid_attach (GTK_GRID (object), rem, 0, 5, 1, 1);
- gtk_grid_attach (GTK_GRID (object), priv->reminders, 1, 5, 3, 1);
+ gtk_grid_attach (GTK_GRID (object), priv->reminders, 1, 5, 1, 1);
attending = gtk_label_new (_("Attending"));
gtk_widget_set_halign (attending, GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (object), attending, 0, 6, 1, 1);
- gtk_grid_attach (GTK_GRID (object), attending_box, 1, 6, 3, 1);
-
- gtk_grid_set_row_spacing (GTK_GRID (object), 12);
- gtk_grid_set_column_spacing (GTK_GRID (object), 12);
+ gtk_grid_attach (GTK_GRID (object), attending_box, 1, 6, 1, 1);
+
+ priv->delete_button = gtk_button_new_with_label (_("Delete Event"));
+ gtk_widget_set_halign (priv->delete_button, GTK_ALIGN_START);
+ gtk_widget_set_valign (priv->delete_button, GTK_ALIGN_END);
+ gtk_widget_set_hexpand (priv->delete_button, FALSE);
+ gtk_grid_attach (GTK_GRID (object), priv->delete_button, 1, 7, 1, 1);
+
+ g_object_set (object,
+ "row-spacing", 12,
+ "column-spacing", 12,
+ NULL);
gtk_widget_show_all (GTK_WIDGET (object));
+
+ gtk_widget_hide (priv->delete_button);
}
static void
@@ -282,6 +294,9 @@ gcal_event_view_update (GcalEventView *view)
GCAL_EDITABLE_REMINDER (priv->reminders),
reminders);
+ /* since this loading is for viewing, we hide delete_button */
+ gtk_widget_hide (priv->delete_button);
+
g_free (description);
g_free (when);
g_free (summary);
@@ -381,6 +396,9 @@ gcal_event_view_enter_edit_mode (GcalEventView *view)
g_slist_foreach (priv->e_widgets,
(GFunc) gcal_editable_enter_edit_mode,
NULL);
+
+ /* showing delete button */
+ gtk_widget_show (priv->delete_button);
}
/**
@@ -402,4 +420,6 @@ gcal_event_view_leave_edit_mode (GcalEventView *view)
g_slist_foreach (priv->e_widgets,
(GFunc) gcal_editable_leave_edit_mode,
NULL);
+
+ gtk_widget_hide (priv->delete_button);
}
diff --git a/src/gcal-toolbar.c b/src/gcal-toolbar.c
index 582d449..4016203 100644
--- a/src/gcal-toolbar.c
+++ b/src/gcal-toolbar.c
@@ -49,6 +49,7 @@ enum
BACK,
EDIT_EVENT,
+ DONE_EDIT,
NUM_SIGNALS
};
@@ -139,6 +140,16 @@ gcal_toolbar_class_init (GcalToolbarClass *klass)
G_TYPE_NONE,
0);
+ signals[DONE_EDIT] = g_signal_new ("done-edit",
+ GCAL_TYPE_TOOLBAR,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcalToolbarClass,
+ done_edit),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_type_class_add_private ((gpointer) klass, sizeof(GcalToolbarPrivate));
}
@@ -430,19 +441,22 @@ gcal_toolbar_set_event_mode (GcalToolbar *toolbar)
/* edit */
if (priv->edit_button == NULL)
{
- priv->edit_button = gtk_button_new_with_label (_("Edit"));
+ priv->edit_button = gtk_toggle_button_new_with_label (_("Edit"));
g_object_ref_sink (priv->edit_button);
context = gtk_widget_get_style_context (priv->edit_button);
gtk_style_context_add_class (context, "raised");
g_signal_connect (priv->edit_button,
- "clicked",
+ "toggled",
G_CALLBACK (gcal_toolbar_event_edited),
toolbar);
}
/* reset morphing edit_button */
gtk_button_set_label (GTK_BUTTON (priv->edit_button), _("Edit"));
+ g_signal_handlers_block_by_func (priv->edit_button, gcal_toolbar_event_edited, toolbar);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->edit_button), FALSE);
+ g_signal_handlers_unblock_by_func (priv->edit_button, gcal_toolbar_event_edited, toolbar);
gtk_container_add (GTK_CONTAINER (priv->right_item), priv->edit_button);
gtk_widget_show_all (priv->edit_button);
@@ -506,9 +520,16 @@ gcal_toolbar_event_edited (GtkWidget *button,
priv = toolbar->priv;
/* morphing edit_button */
- gtk_button_set_label (GTK_BUTTON (priv->edit_button), _("Done"));
-
- g_signal_emit (toolbar, signals[EDIT_EVENT], 0);
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ {
+ g_signal_emit (toolbar, signals[EDIT_EVENT], 0);
+ gtk_button_set_label (GTK_BUTTON (priv->edit_button), _("Done"));
+ }
+ else
+ {
+ g_signal_emit (toolbar, signals[DONE_EDIT], 0);
+ gtk_button_set_label (GTK_BUTTON (priv->edit_button), _("Edit"));
+ }
}
/* Public API */
diff --git a/src/gcal-toolbar.h b/src/gcal-toolbar.h
index 6ceb55a..2767744 100644
--- a/src/gcal-toolbar.h
+++ b/src/gcal-toolbar.h
@@ -48,6 +48,7 @@ struct _GcalToolbarClass
void (*back) (GcalToolbar *toolbar);
void (*edit_event) (GcalToolbar *toolbar);
+ void (*done_edit) (GcalToolbar *toolbar);
};
struct _GcalToolbar
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 662e37b..e3d5b68 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -74,6 +74,9 @@ static void gcal_window_back_last_view (GcalToolbar *main_to
static void gcal_window_edit_event (GcalToolbar *main_toolbar,
gpointer user_data);
+static void gcal_window_done_edit_event (GcalToolbar *main_toolbar,
+ gpointer user_data);
+
static void gcal_window_sources_row_activated (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
@@ -253,6 +256,10 @@ gcal_window_constructed (GObject *object)
"edit-event",
G_CALLBACK (gcal_window_edit_event),
object);
+ g_signal_connect (priv->main_toolbar,
+ "done-edit",
+ G_CALLBACK (gcal_window_done_edit_event),
+ object);
gtk_widget_show (embed);
}
@@ -342,11 +349,13 @@ gcal_window_init_event_view (GcalWindow *window)
priv->add_view = gcal_event_view_new_with_manager (
gcal_window_get_manager (window));
- gtk_widget_set_hexpand (priv->add_view, TRUE);
- gtk_widget_set_vexpand (priv->add_view, TRUE);
- gtk_widget_set_margin_top (priv->add_view, 10);
- gtk_widget_set_margin_left (priv->add_view, 20);
- gtk_widget_set_margin_right (priv->add_view, 20);
+ g_object_set (priv->add_view,
+ "hexpand", TRUE,
+ "vexpand", TRUE,
+ "margin-top", 10,
+ "margin-left", 20,
+ "margin-right", 20,
+ NULL);
gtk_widget_show (priv->add_view);
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
@@ -421,6 +430,10 @@ gcal_window_add_event (GcalToolbar *main_toolbar,
gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), priv->add_view));
}
+/*
+ * FIXME: Take into account the event we're viewing could be in edit-mode and we
+ * need to advice the user and offers him to save/discard the changes
+ */
static void
gcal_window_back_last_view (GcalToolbar *main_toolbar,
gpointer user_data)
@@ -457,6 +470,8 @@ gcal_window_edit_event (GcalToolbar *main_toolbar,
if (priv->add_view == NULL)
gcal_window_init_event_view (GCAL_WINDOW (user_data));
+ //FIXME: check here, maybe this isn't need since edit-event
+ //can be triggered only from add_view
gtk_notebook_set_current_page (
GTK_NOTEBOOK (priv->notebook),
gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), priv->add_view));
@@ -464,6 +479,16 @@ gcal_window_edit_event (GcalToolbar *main_toolbar,
}
static void
+gcal_window_done_edit_event (GcalToolbar *main_toolbar,
+ gpointer user_data)
+{
+ GcalWindowPrivate *priv;
+
+ priv = GCAL_WINDOW (user_data)->priv;
+ gcal_event_view_leave_edit_mode (GCAL_EVENT_VIEW (priv->add_view));
+}
+
+static void
gcal_window_sources_row_activated (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]