Complete migration to icaltimetype.
This commit is contained in:
+3
-3
@@ -29,7 +29,7 @@ Rough description of some internals of Gnome Calendar Application
|
|||||||
|
|
||||||
Has a list of ESourceGroup
|
Has a list of ESourceGroup
|
||||||
|
|
||||||
Has GDate *initial_date, *final_date
|
Has icaltimetype *initial_date, *final_date
|
||||||
For defining a range to get events from
|
For defining a range to get events from
|
||||||
Could have an active query representing the range (s-exp)
|
Could have an active query representing the range (s-exp)
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ Rough description of some internals of Gnome Calendar Application
|
|||||||
+ GcalView
|
+ GcalView
|
||||||
|
|
||||||
Has NavigationPane
|
Has NavigationPane
|
||||||
Has GDate: selected_date attribute
|
Has icaltimetype: selected_date attribute
|
||||||
|
|
||||||
Has child classes
|
Has child classes
|
||||||
1. GcalDayView
|
1. GcalDayView
|
||||||
@@ -100,7 +100,7 @@ Rough description of some internals of Gnome Calendar Application
|
|||||||
3. GcalMonthView
|
3. GcalMonthView
|
||||||
...
|
...
|
||||||
|
|
||||||
Has GDate attribute
|
Has icaltimetype attribute
|
||||||
For keeping actual date
|
For keeping actual date
|
||||||
|
|
||||||
Has set_view/update_view method
|
Has set_view/update_view method
|
||||||
|
|||||||
+42
-40
@@ -74,8 +74,8 @@ struct _GcalManagerPrivate
|
|||||||
GtkListStore *sources_model;
|
GtkListStore *sources_model;
|
||||||
|
|
||||||
/* The range of dates defining the query */
|
/* The range of dates defining the query */
|
||||||
GDate *initial_date;
|
icaltimetype *initial_date;
|
||||||
GDate *final_date;
|
icaltimetype *final_date;
|
||||||
|
|
||||||
/* The active query */
|
/* The active query */
|
||||||
gchar *query;
|
gchar *query;
|
||||||
@@ -134,6 +134,12 @@ gcal_manager_init (GcalManager *self)
|
|||||||
G_TYPE_BOOLEAN,
|
G_TYPE_BOOLEAN,
|
||||||
GDK_TYPE_COLOR);
|
GDK_TYPE_COLOR);
|
||||||
g_object_ref_sink (priv->sources_model);
|
g_object_ref_sink (priv->sources_model);
|
||||||
|
|
||||||
|
priv->initial_date = g_new(icaltimetype, 1);
|
||||||
|
*(priv->initial_date) = icaltime_from_timet (time (NULL), 0);
|
||||||
|
|
||||||
|
priv->final_date = g_new(icaltimetype, 1);
|
||||||
|
*(priv->final_date) = icaltime_from_timet (time (NULL), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -166,6 +172,8 @@ gcal_manager_constructed (GObject *object)
|
|||||||
COLUMN_ACTIVE, TRUE,
|
COLUMN_ACTIVE, TRUE,
|
||||||
COLUMN_COLOR, &color,
|
COLUMN_COLOR, &color,
|
||||||
-1);
|
-1);
|
||||||
|
priv->initial_date->month = priv->initial_date->month - 1;
|
||||||
|
priv->final_date->month = priv->final_date->month + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -507,56 +515,50 @@ gcal_manager_add_source (GcalManager *manager,
|
|||||||
* Since: 0.0.1
|
* Since: 0.0.1
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gcal_manager_set_new_range (GcalManager *manager,
|
gcal_manager_set_new_range (GcalManager *manager,
|
||||||
const GDate *initial_date,
|
const icaltimetype *initial_date,
|
||||||
const GDate *final_date)
|
const icaltimetype *final_date)
|
||||||
{
|
{
|
||||||
gboolean refresh_events = TRUE;
|
GcalManagerPrivate *priv;
|
||||||
|
gboolean refresh_events;
|
||||||
|
|
||||||
// /* updating query range */
|
priv = manager->priv;
|
||||||
// if (g_date_compare (manager->priv->initial_date, initial_date) > 0)
|
refresh_events = FALSE;
|
||||||
// {
|
|
||||||
// /* switch dates */
|
/* updating query range */
|
||||||
// refresh_events = TRUE;
|
if ((icaltime_compare (*(priv->initial_date), *initial_date)) == 1)
|
||||||
// }
|
{
|
||||||
// if (g_date_compare (manager->priv->final_date, final_date) < 0)
|
/* switch dates */
|
||||||
// {
|
*(priv->initial_date) = *initial_date;
|
||||||
// /* switch dates */
|
refresh_events = TRUE;
|
||||||
// refresh_events = TRUE;
|
}
|
||||||
// }
|
if (icaltime_compare (*(priv->final_date), *final_date) == -1)
|
||||||
|
{
|
||||||
|
/* switch dates */
|
||||||
|
*(priv->final_date) = *final_date;
|
||||||
|
refresh_events = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (refresh_events)
|
if (refresh_events)
|
||||||
{
|
{
|
||||||
/* rebuild query */
|
/* rebuild query */
|
||||||
GDateTime * first_datetime = g_date_time_new_local(g_date_get_year (initial_date),
|
gchar* since_iso8601 =
|
||||||
g_date_get_month (initial_date),
|
isodate_from_time_t (icaltime_as_timet (*(priv->initial_date)));
|
||||||
g_date_get_day (initial_date),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
time_t since = g_date_time_to_unix (first_datetime);
|
|
||||||
gchar* since_iso8601 = isodate_from_time_t (since);
|
|
||||||
|
|
||||||
GDateTime * last_datetime = g_date_time_new_local(g_date_get_year (final_date),
|
gchar* until_iso8601 =
|
||||||
g_date_get_month (final_date),
|
isodate_from_time_t (icaltime_as_timet (*(priv->final_date)));
|
||||||
g_date_get_day (final_date),
|
|
||||||
23,
|
|
||||||
59,
|
|
||||||
59);
|
|
||||||
gchar* until_iso8601 = isodate_from_time_t (
|
|
||||||
g_date_time_to_unix (last_datetime));
|
|
||||||
|
|
||||||
manager->priv->query = g_strdup_printf (
|
if (priv->query != NULL)
|
||||||
|
g_free (priv->query);
|
||||||
|
priv->query = g_strdup_printf (
|
||||||
"occur-in-time-range? (make-time \"%s\") "
|
"occur-in-time-range? (make-time \"%s\") "
|
||||||
"(make-time \"%s\")",
|
"(make-time \"%s\")",
|
||||||
since_iso8601,
|
since_iso8601,
|
||||||
until_iso8601);
|
until_iso8601);
|
||||||
|
|
||||||
g_date_time_unref (first_datetime);
|
g_print ("Loading events since %s until %s\nwith query %s\n",
|
||||||
g_date_time_unref (last_datetime);
|
since_iso8601,
|
||||||
|
until_iso8601,
|
||||||
g_print ("Loading events since %s until %s\n",
|
priv->query);
|
||||||
since_iso8601,
|
|
||||||
until_iso8601);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-8
@@ -23,6 +23,8 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include <libical/icaltime.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GCAL_TYPE_MANAGER (gcal_manager_get_type ())
|
#define GCAL_TYPE_MANAGER (gcal_manager_get_type ())
|
||||||
@@ -53,15 +55,15 @@ GType gcal_manager_get_type (void);
|
|||||||
|
|
||||||
GcalManager* gcal_manager_new (void);
|
GcalManager* gcal_manager_new (void);
|
||||||
|
|
||||||
GtkListStore* gcal_manager_get_sources_model (GcalManager *manager);
|
GtkListStore* gcal_manager_get_sources_model (GcalManager *manager);
|
||||||
|
|
||||||
gchar* gcal_manager_add_source (GcalManager *manager,
|
gchar* gcal_manager_add_source (GcalManager *manager,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *base_uri,
|
const gchar *base_uri,
|
||||||
const gchar *relative_uri);
|
const gchar *relative_uri);
|
||||||
void gcal_manager_set_new_range (GcalManager *manager,
|
void gcal_manager_set_new_range (GcalManager *manager,
|
||||||
const GDate *initial_date,
|
const icaltimetype *initial_date,
|
||||||
const GDate *final_date);
|
const icaltimetype *final_date);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
+31
-15
@@ -42,22 +42,24 @@ struct _GcalWindowPrivate
|
|||||||
GtkWidget *views [5];
|
GtkWidget *views [5];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gcal_window_constructed (GObject *object);
|
static void gcal_window_constructed (GObject *object);
|
||||||
|
|
||||||
static void _gcal_window_set_sources_view (GcalWindow *window);
|
GcalManager* _gcal_window_get_manager (GcalWindow *window);
|
||||||
|
|
||||||
static void _gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
static void _gcal_window_set_sources_view (GcalWindow *window);
|
||||||
GcalViewType view_type,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
static void _gcal_window_sources_shown (GcalMainToolbar *main_toolbar,
|
static void _gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
||||||
gboolean visible,
|
GcalViewType view_type,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
static void _gcal_window_sources_row_activated (GtkTreeView *tree_view,
|
static void _gcal_window_sources_shown (GcalMainToolbar *main_toolbar,
|
||||||
GtkTreePath *path,
|
gboolean visible,
|
||||||
GtkTreeViewColumn *column,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
static void _gcal_window_sources_row_activated (GtkTreeView *tree_view,
|
||||||
|
GtkTreePath *path,
|
||||||
|
GtkTreeViewColumn *column,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
G_DEFINE_TYPE(GcalWindow, gcal_window, GTK_TYPE_APPLICATION_WINDOW)
|
G_DEFINE_TYPE(GcalWindow, gcal_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||||
|
|
||||||
@@ -206,20 +208,27 @@ gcal_window_constructed (GObject *object)
|
|||||||
gtk_widget_show (embed);
|
gtk_widget_show (embed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GcalManager*
|
||||||
|
_gcal_window_get_manager (GcalWindow *window)
|
||||||
|
{
|
||||||
|
GcalApplication *app;
|
||||||
|
app = GCAL_APPLICATION (gtk_window_get_application (GTK_WINDOW (window)));
|
||||||
|
|
||||||
|
return gcal_application_get_manager (app);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gcal_window_set_sources_view (GcalWindow *window)
|
_gcal_window_set_sources_view (GcalWindow *window)
|
||||||
{
|
{
|
||||||
GcalWindowPrivate *priv;
|
GcalWindowPrivate *priv;
|
||||||
GcalApplication *app;
|
|
||||||
GcalManager *manager;
|
GcalManager *manager;
|
||||||
|
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
|
|
||||||
priv = window->priv;
|
priv = window->priv;
|
||||||
app = GCAL_APPLICATION (gtk_window_get_application (GTK_WINDOW (window)));
|
|
||||||
|
|
||||||
manager = gcal_application_get_manager (app);
|
manager = _gcal_window_get_manager (window);
|
||||||
priv->sources_view = gtk_tree_view_new_with_model (
|
priv->sources_view = gtk_tree_view_new_with_model (
|
||||||
GTK_TREE_MODEL (gcal_manager_get_sources_model (manager)));
|
GTK_TREE_MODEL (gcal_manager_get_sources_model (manager)));
|
||||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->sources_view),
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->sources_view),
|
||||||
@@ -278,7 +287,14 @@ _gcal_window_view_changed (GcalMainToolbar *main_toolbar,
|
|||||||
GcalViewType view_type,
|
GcalViewType view_type,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GcalWindow *window;
|
||||||
|
GcalManager *manager;
|
||||||
|
|
||||||
|
window = GCAL_WINDOW (user_data);
|
||||||
|
manager = _gcal_window_get_manager (window);
|
||||||
|
gcal_manager_set_new_range (manager, NULL, NULL);
|
||||||
g_print ("GcalViewType in GcalWindow %d\n", view_type);
|
g_print ("GcalViewType in GcalWindow %d\n", view_type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user