[gnome-calendar] event-widget: Receive a context
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] event-widget: Receive a context
- Date: Thu, 25 Apr 2019 19:57:53 +0000 (UTC)
commit 54506973fcd6b6a0a3d21cb4530ed39c6dc4ef2d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Apr 24 15:06:21 2019 -0300
event-widget: Receive a context
src/gcal-event-widget.c | 32 ++++++++++++++++++++++++++++++--
src/gcal-event-widget.h | 5 +++--
src/views/gcal-month-popover.c | 2 +-
src/views/gcal-month-view.c | 4 ++--
src/views/gcal-week-grid.c | 1 +
src/views/gcal-week-header.c | 2 +-
src/views/gcal-year-view.c | 2 +-
7 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index 01c726ef..394da268 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -23,6 +23,7 @@
#include <string.h>
#include "gcal-application.h"
+#include "gcal-context.h"
#include "gcal-clock.h"
#include "gcal-event-widget.h"
#include "gcal-utils.h"
@@ -63,11 +64,14 @@ struct _GcalEventWidget
gboolean vertical_labels;
gboolean button_pressed;
+
+ GcalContext *context;
};
enum
{
PROP_0,
+ PROP_CONTEXT,
PROP_DATE_END,
PROP_DATE_START,
PROP_EVENT,
@@ -773,6 +777,11 @@ gcal_event_widget_set_property (GObject *object,
switch (property_id)
{
+ case PROP_CONTEXT:
+ g_assert (self->context == NULL);
+ self->context = g_value_dup_object (value);
+ break;
+
case PROP_DATE_END:
gcal_event_widget_set_date_end (self, g_value_get_boxed (value));
break;
@@ -807,6 +816,10 @@ gcal_event_widget_get_property (GObject *object,
switch (property_id)
{
+ case PROP_CONTEXT:
+ g_value_set_object (value, self->context);
+ break;
+
case PROP_DATE_END:
g_value_set_boxed (value, self->dt_end);
break;
@@ -842,6 +855,7 @@ gcal_event_widget_finalize (GObject *object)
/* releasing properties */
g_clear_pointer (&self->css_class, g_free);
g_clear_object (&self->event);
+ g_clear_object (&self->context);
/* remove timeouts */
if (self->vertical_label_source_id > 0)
@@ -876,6 +890,18 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass)
widget_class->unmap = gcal_event_widget_unmap;
widget_class->unrealize = gcal_event_widget_unrealize;
+ /**
+ * GcalEventWidget::context:
+ *
+ * The context of the event.
+ */
+ g_object_class_install_property (object_class,
+ PROP_CONTEXT,
+ g_param_spec_object ("context",
+ "Context",
+ "Context",
+ GCAL_TYPE_CONTEXT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
/**
* GcalEventWidget::date-end:
*
@@ -983,9 +1009,11 @@ gcal_event_widget_init (GcalEventWidget *self)
}
GtkWidget*
-gcal_event_widget_new (GcalEvent *event)
+gcal_event_widget_new (GcalContext *context,
+ GcalEvent *event)
{
return g_object_new (GCAL_TYPE_EVENT_WIDGET,
+ "context", context,
"event", event,
NULL);
}
@@ -1120,7 +1148,7 @@ gcal_event_widget_clone (GcalEventWidget *widget)
{
GtkWidget *new_widget;
- new_widget = gcal_event_widget_new (widget->event);
+ new_widget = gcal_event_widget_new (widget->context, widget->event);
gcal_event_widget_set_read_only (GCAL_EVENT_WIDGET (new_widget), widget->read_only);
return new_widget;
diff --git a/src/gcal-event-widget.h b/src/gcal-event-widget.h
index 854d8894..72e0a0ab 100644
--- a/src/gcal-event-widget.h
+++ b/src/gcal-event-widget.h
@@ -20,7 +20,7 @@
#define __GCAL_EVENT_WIDGET_H__
#include "gcal-event.h"
-#include "gcal-manager.h"
+#include "gcal-context.h"
#include <gtk/gtk.h>
@@ -32,7 +32,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GcalEventWidget, gcal_event_widget, GCAL, EVENT_WIDGET, GtkBin)
-GtkWidget* gcal_event_widget_new (GcalEvent *event);
+GtkWidget* gcal_event_widget_new (GcalContext *context,
+ GcalEvent *event);
GcalEvent* gcal_event_widget_get_event (GcalEventWidget *self);
diff --git a/src/views/gcal-month-popover.c b/src/views/gcal-month-popover.c
index bc107811..e2b218ab 100644
--- a/src/views/gcal-month-popover.c
+++ b/src/views/gcal-month-popover.c
@@ -345,7 +345,7 @@ update_event_list (GcalMonthPopover *self)
event_end = g_date_time_add_days (event_start, 1);
- event_widget = gcal_event_widget_new (event);
+ event_widget = gcal_event_widget_new (self->context, event);
gcal_event_widget_set_date_start (GCAL_EVENT_WIDGET (event_widget), event_start);
gcal_event_widget_set_date_end (GCAL_EVENT_WIDGET (event_widget), event_end);
diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c
index 3161aba9..433ef3d5 100644
--- a/src/views/gcal-month-view.c
+++ b/src/views/gcal-month-view.c
@@ -1254,7 +1254,7 @@ gcal_month_view_component_added (ECalDataModelSubscriber *subscriber,
GCAL_RETURN ();
}
- event_widget = gcal_event_widget_new (event);
+ event_widget = gcal_event_widget_new (self->context, event);
gcal_event_widget_set_read_only (GCAL_EVENT_WIDGET (event_widget), e_client_is_readonly (E_CLIENT
(client)));
gtk_widget_show (event_widget);
@@ -1289,7 +1289,7 @@ gcal_month_view_component_modified (ECalDataModelSubscriber *subscriber,
GCAL_RETURN ();
}
- new_widget = gcal_event_widget_new (event);
+ new_widget = gcal_event_widget_new (self->context, event);
l = g_hash_table_lookup (self->children, gcal_event_get_uid (event));
diff --git a/src/views/gcal-week-grid.c b/src/views/gcal-week-grid.c
index 0d03c8c5..5572799a 100644
--- a/src/views/gcal-week-grid.c
+++ b/src/views/gcal-week-grid.c
@@ -1166,6 +1166,7 @@ gcal_week_grid_add_event (GcalWeekGrid *self,
g_object_ref (event);
widget = g_object_new (GCAL_TYPE_EVENT_WIDGET,
+ "context", self->context,
"event", event,
"orientation", GTK_ORIENTATION_VERTICAL,
NULL);
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index 6745412d..211b6fa3 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -735,7 +735,7 @@ add_event_to_grid (GcalWeekHeader *self,
move_events_at_column (self, DOWN, start, position);
/* Add the event to the grid */
- widget = gcal_event_widget_new (event);
+ widget = gcal_event_widget_new (self->context, event);
setup_event_widget (self, widget);
gtk_grid_attach (GTK_GRID (self->grid),
diff --git a/src/views/gcal-year-view.c b/src/views/gcal-year-view.c
index 0c097f38..b268192f 100644
--- a/src/views/gcal-year-view.c
+++ b/src/views/gcal-year-view.c
@@ -319,7 +319,7 @@ add_event_to_day_array (GcalYearView *year_view,
manager = gcal_context_get_manager (year_view->context);
is_readonly = !gcal_manager_is_client_writable (manager, gcal_event_get_source (event));
- child_widget = gcal_event_widget_new (event);
+ child_widget = gcal_event_widget_new (year_view->context, event);
gcal_event_widget_set_read_only (GCAL_EVENT_WIDGET (child_widget), is_readonly);
dt_start = gcal_event_get_date_start (event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]