Added to GcalMonthView class GcalView interface implementation.
This commit is contained in:
+27
-1
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "gcal-month-view.h"
|
||||
#include "gcal-utils.h"
|
||||
#include "gcal-view.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
@@ -53,6 +54,11 @@ const char* weekdays [] =
|
||||
"Sat"
|
||||
};
|
||||
|
||||
static void _gcal_view_interface_init (GcalViewIface *iface);
|
||||
|
||||
static gboolean _gcal_month_view_is_in_range (GcalView *view,
|
||||
icaltimetype *date);
|
||||
|
||||
static void gcal_month_view_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
@@ -86,7 +92,12 @@ static void _gcal_month_view_draw_month_grid (GcalMonthView *mont_vie
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
G_DEFINE_TYPE(GcalMonthView, gcal_month_view, GTK_TYPE_WIDGET)
|
||||
G_DEFINE_TYPE_WITH_CODE (GcalMonthView,
|
||||
gcal_month_view,
|
||||
GTK_TYPE_WIDGET,
|
||||
G_IMPLEMENT_INTERFACE (GCAL_TYPE_VIEW,
|
||||
_gcal_view_interface_init));
|
||||
|
||||
|
||||
static void gcal_month_view_class_init (GcalMonthViewClass *klass)
|
||||
{
|
||||
@@ -130,6 +141,21 @@ static void gcal_month_view_init (GcalMonthView *self)
|
||||
GcalMonthViewPrivate);
|
||||
}
|
||||
|
||||
static void
|
||||
_gcal_view_interface_init (GcalViewIface *iface)
|
||||
{
|
||||
iface->is_in_range = _gcal_month_view_is_in_range;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gcal_month_view_is_in_range (GcalView *view,
|
||||
icaltimetype *date)
|
||||
{
|
||||
g_debug ("Implementation of is_in_range called");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gcal_month_view_set_property (GObject *object,
|
||||
guint property_id,
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ typedef enum
|
||||
GCAL_VIEW_TYPE_MONTHLY,
|
||||
GCAL_VIEW_TYPE_YEARLY,
|
||||
GCAL_VIEW_TYPE_LIST,
|
||||
} GcalViewType;
|
||||
} GcalViewTypeEnum;
|
||||
|
||||
void gcal_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view,
|
||||
gboolean should_activate);
|
||||
|
||||
+10
-13
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "gcal-view.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
static void
|
||||
gcal_view_base_init (gpointer g_iface)
|
||||
{
|
||||
@@ -40,8 +42,8 @@ gcal_view_get_type (void)
|
||||
{
|
||||
const GTypeInfo info =
|
||||
{
|
||||
sizeof (GcalViewInterface),
|
||||
NULL, /* base_init */
|
||||
sizeof (GcalViewIface),
|
||||
gcal_view_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
@@ -50,19 +52,12 @@ gcal_view_get_type (void)
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
const GInterfaceInfo view_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gcal_view_base_init,
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
type = g_type_register_static (G_TYPE_OBJECT,
|
||||
"GcalViewType",
|
||||
type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
"GcalView",
|
||||
&info,
|
||||
0);
|
||||
g_type_add_interface_static (type,
|
||||
GCAL_TYPE_VIEW,
|
||||
&view_info);
|
||||
g_type_interface_add_prerequisite (type,
|
||||
G_TYPE_OBJECT);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -71,5 +66,7 @@ gboolean
|
||||
gcal_view_is_in_range (GcalView *view,
|
||||
icaltimetype *date)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_VIEW (view), FALSE);
|
||||
|
||||
return GCAL_VIEW_GET_INTERFACE (view)->is_in_range (view, date);
|
||||
}
|
||||
|
||||
+3
-3
@@ -29,13 +29,13 @@ G_BEGIN_DECLS
|
||||
#define GCAL_TYPE_VIEW (gcal_view_get_type ())
|
||||
#define GCAL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCAL_TYPE_VIEW, GcalView))
|
||||
#define GCAL_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCAL_TYPE_VIEW))
|
||||
#define GCAL_VIEW_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GCAL_TYPE_VIEW, GcalViewInterface))
|
||||
#define GCAL_VIEW_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GCAL_TYPE_VIEW, GcalViewIface))
|
||||
|
||||
|
||||
typedef struct _GcalView GcalView;
|
||||
typedef struct _GcalViewInterface GcalViewInterface;
|
||||
typedef struct _GcalViewIface GcalViewIface;
|
||||
|
||||
struct _GcalViewInterface
|
||||
struct _GcalViewIface
|
||||
{
|
||||
GTypeInterface parent_iface;
|
||||
|
||||
|
||||
+29
-12
@@ -22,6 +22,7 @@
|
||||
#include "gcal-floating-container.h"
|
||||
#include "gcal-main-toolbar.h"
|
||||
#include "gcal-month-view.h"
|
||||
#include "gcal-view.h"
|
||||
#include "gcal-utils.h"
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
@@ -33,15 +34,15 @@
|
||||
|
||||
struct _GcalWindowPrivate
|
||||
{
|
||||
ClutterActor *main_toolbar;
|
||||
ClutterActor *notebook_actor;
|
||||
ClutterActor *sources_actor;
|
||||
ClutterActor *main_toolbar;
|
||||
ClutterActor *notebook_actor;
|
||||
ClutterActor *sources_actor;
|
||||
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *sources_view;
|
||||
GtkWidget *views [5];
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *sources_view;
|
||||
GtkWidget *views [5];
|
||||
|
||||
GcalViewType active_view;
|
||||
GcalViewTypeEnum active_view;
|
||||
};
|
||||
|
||||
static void gcal_window_constructed (GObject *object);
|
||||
@@ -51,7 +52,7 @@ GcalManager* _gcal_window_get_manager (GcalWindow *window);
|
||||
static void _gcal_window_set_sources_view (GcalWindow *window);
|
||||
|
||||
static void _gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
||||
GcalViewType view_type,
|
||||
GcalViewTypeEnum view_type,
|
||||
gpointer user_data);
|
||||
|
||||
static void _gcal_window_sources_shown (GcalMainToolbar *main_toolbar,
|
||||
@@ -300,9 +301,9 @@ _gcal_window_set_sources_view (GcalWindow *window)
|
||||
}
|
||||
|
||||
static void
|
||||
_gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
||||
GcalViewType view_type,
|
||||
gpointer user_data)
|
||||
_gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
||||
GcalViewTypeEnum view_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalWindowPrivate *priv;
|
||||
GcalManager *manager;
|
||||
@@ -322,7 +323,7 @@ _gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
||||
|
||||
manager = _gcal_window_get_manager (GCAL_WINDOW (user_data));
|
||||
gcal_manager_set_new_range (manager, first_day, last_day);
|
||||
g_debug ("GcalViewType in GcalWindow %d", priv->active_view);
|
||||
g_debug ("GcalViewTypeEnum in GcalWindow %d", priv->active_view);
|
||||
g_free (first_day);
|
||||
g_free (last_day);
|
||||
}
|
||||
@@ -394,12 +395,15 @@ _gcal_window_events_added (GcalManager *manager,
|
||||
gpointer events_list,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalWindowPrivate *priv;
|
||||
GSList *l;
|
||||
icaltimetype *starting_date;
|
||||
gchar **tokens;
|
||||
gchar *source_uid;
|
||||
gchar *event_uid;
|
||||
|
||||
priv = GCAL_WINDOW (user_data)->priv;
|
||||
|
||||
g_debug ("[IWEA]: obtained %d events", g_slist_length (events_list));
|
||||
for (l = events_list; l != NULL; l = l->next)
|
||||
{
|
||||
@@ -411,6 +415,19 @@ _gcal_window_events_added (GcalManager *manager,
|
||||
source_uid,
|
||||
event_uid);
|
||||
g_debug ("starts on %s", icaltime_as_ical_string (*starting_date));
|
||||
g_debug ("GcalViewTypeEnum in GcalWindow %d", priv->active_view);
|
||||
/* FIXME: here priv->views[priv->active_view] instead of hardcoding
|
||||
* GCAL_VIEW_TYPE_MONTHLY */
|
||||
if (gcal_view_is_in_range (
|
||||
GCAL_VIEW (priv->views[GCAL_VIEW_TYPE_MONTHLY]),
|
||||
starting_date))
|
||||
{
|
||||
g_debug ("Returned true call on interface function");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_debug ("Returned false call on interface func");
|
||||
}
|
||||
|
||||
g_free (starting_date);
|
||||
g_strfreev (tokens);
|
||||
|
||||
Reference in New Issue
Block a user