view: update interface code
This commit updates GcalView interface to use modern GLib API and, consequently, removes tons of obsolete code.
This commit is contained in:
+52
-68
@@ -3,6 +3,7 @@
|
||||
* gcal-view.c
|
||||
*
|
||||
* Copyright (C) 2015 - Erick Pérez Castellanos
|
||||
* 2016 - Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,70 +24,53 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
G_DEFINE_INTERFACE (GcalView, gcal_view, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gcal_view_base_init (gpointer g_iface)
|
||||
gcal_view_default_init (GcalViewInterface *iface)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
/**
|
||||
* GcalView::active-date:
|
||||
*
|
||||
* The active date of the view.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_boxed ("active-date",
|
||||
"The active date",
|
||||
"The active/selecetd date in the view",
|
||||
ICAL_TIME_TYPE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/* create interface signals && properties here. */
|
||||
g_object_interface_install_property (
|
||||
g_iface,
|
||||
g_param_spec_boxed ("active-date",
|
||||
"The active date",
|
||||
"The active/selecetd date in the view",
|
||||
ICAL_TIME_TYPE,
|
||||
G_PARAM_READWRITE));
|
||||
/**
|
||||
* GcalView::create-event:
|
||||
*
|
||||
* Emitted when the view wants to create an event.
|
||||
*/
|
||||
g_signal_new ("create-event",
|
||||
GCAL_TYPE_VIEW,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GcalViewInterface, create_event),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE,
|
||||
4,
|
||||
G_TYPE_POINTER,
|
||||
G_TYPE_POINTER,
|
||||
G_TYPE_DOUBLE,
|
||||
G_TYPE_DOUBLE);
|
||||
|
||||
g_signal_new ("create-event",
|
||||
GCAL_TYPE_VIEW,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GcalViewIface,
|
||||
create_event),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE,
|
||||
4,
|
||||
G_TYPE_POINTER,
|
||||
G_TYPE_POINTER,
|
||||
G_TYPE_DOUBLE,
|
||||
G_TYPE_DOUBLE);
|
||||
|
||||
g_signal_new ("create-event-detailed", GCAL_TYPE_VIEW, G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GcalViewIface, create_event_detailed),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GType
|
||||
gcal_view_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
if (type == 0)
|
||||
{
|
||||
const GTypeInfo info =
|
||||
{
|
||||
sizeof (GcalViewIface),
|
||||
gcal_view_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
0,
|
||||
0, /* n_preallocs */
|
||||
NULL /* instance_init */
|
||||
};
|
||||
type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
"GcalView",
|
||||
&info,
|
||||
0);
|
||||
g_type_interface_add_prerequisite (type,
|
||||
G_TYPE_OBJECT);
|
||||
}
|
||||
return type;
|
||||
/**
|
||||
* GcalView::create-event-detailed:
|
||||
*
|
||||
* Emitted when the view wants to create an event and immediately
|
||||
* edit it.
|
||||
*/
|
||||
g_signal_new ("create-event-detailed",
|
||||
GCAL_TYPE_VIEW,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GcalViewInterface, create_event_detailed),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -121,9 +105,9 @@ icaltimetype*
|
||||
gcal_view_get_initial_date (GcalView *view)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
|
||||
g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_initial_date, NULL);
|
||||
g_return_val_if_fail (GCAL_VIEW_GET_IFACE (view)->get_initial_date, NULL);
|
||||
|
||||
return GCAL_VIEW_GET_INTERFACE (view)->get_initial_date (view);
|
||||
return GCAL_VIEW_GET_IFACE (view)->get_initial_date (view);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,9 +122,9 @@ icaltimetype*
|
||||
gcal_view_get_final_date (GcalView *view)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
|
||||
g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_final_date, NULL);
|
||||
g_return_val_if_fail (GCAL_VIEW_GET_IFACE (view)->get_final_date, NULL);
|
||||
|
||||
return GCAL_VIEW_GET_INTERFACE (view)->get_final_date (view);
|
||||
return GCAL_VIEW_GET_IFACE (view)->get_final_date (view);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,9 +137,9 @@ void
|
||||
gcal_view_clear_marks (GcalView *view)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_VIEW (view));
|
||||
g_return_if_fail (GCAL_VIEW_GET_INTERFACE (view)->clear_marks);
|
||||
g_return_if_fail (GCAL_VIEW_GET_IFACE (view)->clear_marks);
|
||||
|
||||
GCAL_VIEW_GET_INTERFACE (view)->clear_marks (view);
|
||||
GCAL_VIEW_GET_IFACE (view)->clear_marks (view);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +156,7 @@ gcal_view_get_children_by_uuid (GcalView *view,
|
||||
const gchar *uuid)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_VIEW (view), NULL);
|
||||
g_return_val_if_fail (GCAL_VIEW_GET_INTERFACE (view)->get_children_by_uuid, NULL);
|
||||
g_return_val_if_fail (GCAL_VIEW_GET_IFACE (view)->get_children_by_uuid, NULL);
|
||||
|
||||
return GCAL_VIEW_GET_INTERFACE (view)->get_children_by_uuid (view, uuid);
|
||||
return GCAL_VIEW_GET_IFACE (view)->get_children_by_uuid (view, uuid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user