Remove ECalDataModel and ECalDataModelSubscriber
Drop the bomb!
This commit is contained in:
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat, Inc. (www.redhat.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Milan Crha <mcrha@redhat.com>
|
||||
*/
|
||||
|
||||
#include "e-cal-data-model-subscriber.h"
|
||||
|
||||
G_DEFINE_INTERFACE (ECalDataModelSubscriber, e_cal_data_model_subscriber, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
e_cal_data_model_subscriber_default_init (ECalDataModelSubscriberInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* e_cal_data_model_subscriber_component_added:
|
||||
* @subscriber: an #ECalDataModelSubscriber
|
||||
* @client: an #ECalClient, which notifies about the component addition
|
||||
* @comp: an #ECalComponent which was added
|
||||
*
|
||||
* Notifies the @subscriber about an added component which belongs
|
||||
* to the time range used by the @subscriber.
|
||||
*
|
||||
* Note: The @subscriber can be frozen during these calls, to be able
|
||||
* to cumulate multiple changes and propagate them at once.
|
||||
**/
|
||||
void
|
||||
e_cal_data_model_subscriber_component_added (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
ECalComponent *comp)
|
||||
{
|
||||
ECalDataModelSubscriberInterface *iface;
|
||||
|
||||
g_return_if_fail (E_IS_CAL_DATA_MODEL_SUBSCRIBER (subscriber));
|
||||
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
|
||||
|
||||
iface = E_CAL_DATA_MODEL_SUBSCRIBER_GET_INTERFACE (subscriber);
|
||||
g_return_if_fail (iface->component_added != NULL);
|
||||
|
||||
iface->component_added (subscriber, client, comp);
|
||||
}
|
||||
|
||||
/**
|
||||
* e_cal_data_model_subscriber_component_modified:
|
||||
* @subscriber: an #ECalDataModelSubscriber
|
||||
* @client: an #ECalClient, which notifies about the component modification
|
||||
* @comp: an #ECalComponent which was modified
|
||||
*
|
||||
* Notifies the @subscriber about a modified component which belongs
|
||||
* to the time range used by the @subscriber.
|
||||
*
|
||||
* Note: The @subscriber can be frozen during these calls, to be able
|
||||
* to cumulate multiple changes and propagate them at once.
|
||||
**/
|
||||
void
|
||||
e_cal_data_model_subscriber_component_modified (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
ECalComponent *comp)
|
||||
{
|
||||
ECalDataModelSubscriberInterface *iface;
|
||||
|
||||
g_return_if_fail (E_IS_CAL_DATA_MODEL_SUBSCRIBER (subscriber));
|
||||
g_return_if_fail (E_IS_CAL_COMPONENT (comp));
|
||||
|
||||
iface = E_CAL_DATA_MODEL_SUBSCRIBER_GET_INTERFACE (subscriber);
|
||||
g_return_if_fail (iface->component_modified != NULL);
|
||||
|
||||
iface->component_modified (subscriber, client, comp);
|
||||
}
|
||||
|
||||
/**
|
||||
* e_cal_data_model_subscriber_component_removed:
|
||||
* @subscriber: an #ECalDataModelSubscriber
|
||||
* @client: an #ECalClient, which notifies about the component removal
|
||||
* @uid: UID of a removed component
|
||||
* @rid: RID of a removed component
|
||||
*
|
||||
* Notifies the @subscriber about a removed component identified
|
||||
* by @uid and @rid. This component may or may not be within
|
||||
* the time range specified by the @subscriber.
|
||||
*
|
||||
* Note: The @subscriber can be frozen during these calls, to be able
|
||||
* to cumulate multiple changes and propagate them at once.
|
||||
**/
|
||||
void
|
||||
e_cal_data_model_subscriber_component_removed (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
const gchar *uid,
|
||||
const gchar *rid)
|
||||
{
|
||||
ECalDataModelSubscriberInterface *iface;
|
||||
|
||||
g_return_if_fail (E_IS_CAL_DATA_MODEL_SUBSCRIBER (subscriber));
|
||||
|
||||
iface = E_CAL_DATA_MODEL_SUBSCRIBER_GET_INTERFACE (subscriber);
|
||||
g_return_if_fail (iface->component_removed != NULL);
|
||||
|
||||
iface->component_removed (subscriber, client, uid, rid);
|
||||
}
|
||||
|
||||
/**
|
||||
* e_cal_data_model_subscriber_freeze:
|
||||
* @subscriber: an #ECalDataModelSubscriber
|
||||
*
|
||||
* Tells the @subscriber that it'll be notified about multiple
|
||||
* changes. Once all the notifications are done,
|
||||
* a e_cal_data_model_subscriber_thaw() is called.
|
||||
*
|
||||
* Note: This function can be called multiple times/recursively, with
|
||||
* the same count of the e_cal_data_model_subscriber_thaw(), thus
|
||||
* count with it.
|
||||
**/
|
||||
void
|
||||
e_cal_data_model_subscriber_freeze (ECalDataModelSubscriber *subscriber)
|
||||
{
|
||||
ECalDataModelSubscriberInterface *iface;
|
||||
|
||||
g_return_if_fail (E_IS_CAL_DATA_MODEL_SUBSCRIBER (subscriber));
|
||||
|
||||
iface = E_CAL_DATA_MODEL_SUBSCRIBER_GET_INTERFACE (subscriber);
|
||||
g_return_if_fail (iface->freeze != NULL);
|
||||
|
||||
iface->freeze (subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* e_cal_data_model_subscriber_thaw:
|
||||
* @subscriber: an #ECalDataModelSubscriber
|
||||
*
|
||||
* A pair function for e_cal_data_model_subscriber_freeze(), which notifies
|
||||
* about the end of a content update.
|
||||
**/
|
||||
void
|
||||
e_cal_data_model_subscriber_thaw (ECalDataModelSubscriber *subscriber)
|
||||
{
|
||||
ECalDataModelSubscriberInterface *iface;
|
||||
|
||||
g_return_if_fail (E_IS_CAL_DATA_MODEL_SUBSCRIBER (subscriber));
|
||||
|
||||
iface = E_CAL_DATA_MODEL_SUBSCRIBER_GET_INTERFACE (subscriber);
|
||||
g_return_if_fail (iface->thaw != NULL);
|
||||
|
||||
iface->thaw (subscriber);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat, Inc. (www.redhat.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Milan Crha <mcrha@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef E_CAL_DATA_MODEL_SUBSCRIBER_H
|
||||
#define E_CAL_DATA_MODEL_SUBSCRIBER_H
|
||||
|
||||
#include <libecal/libecal.h>
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define E_TYPE_CAL_DATA_MODEL_SUBSCRIBER \
|
||||
(e_cal_data_model_subscriber_get_type ())
|
||||
#define E_CAL_DATA_MODEL_SUBSCRIBER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST \
|
||||
((obj), E_TYPE_CAL_DATA_MODEL_SUBSCRIBER, ECalDataModelSubscriber))
|
||||
#define E_CAL_DATA_MODEL_SUBSCRIBER_INTERFACE(cls) \
|
||||
(G_TYPE_CHECK_CLASS_CAST \
|
||||
((cls), E_TYPE_CAL_DATA_MODEL_SUBSCRIBER, ECalDataModelSubscriberInterface))
|
||||
#define E_IS_CAL_DATA_MODEL_SUBSCRIBER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE \
|
||||
((obj), E_TYPE_CAL_DATA_MODEL_SUBSCRIBER))
|
||||
#define E_IS_CAL_DATA_MODEL_SUBSCRIBER_INTERFACE(cls) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE \
|
||||
((cls), E_TYPE_CAL_DATA_MODEL_SUBSCRIBER))
|
||||
#define E_CAL_DATA_MODEL_SUBSCRIBER_GET_INTERFACE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_INTERFACE \
|
||||
((obj), E_TYPE_CAL_DATA_MODEL_SUBSCRIBER, ECalDataModelSubscriberInterface))
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _ECalDataModelSubscriber ECalDataModelSubscriber;
|
||||
typedef struct _ECalDataModelSubscriberInterface ECalDataModelSubscriberInterface;
|
||||
|
||||
struct _ECalDataModelSubscriberInterface {
|
||||
GTypeInterface parent_interface;
|
||||
|
||||
void (*component_added) (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
ECalComponent *comp);
|
||||
void (*component_modified) (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
ECalComponent *comp);
|
||||
void (*component_removed) (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
const gchar *uid,
|
||||
const gchar *rid);
|
||||
void (*freeze) (ECalDataModelSubscriber *subscriber);
|
||||
void (*thaw) (ECalDataModelSubscriber *subscriber);
|
||||
};
|
||||
|
||||
GType e_cal_data_model_subscriber_get_type (void) G_GNUC_CONST;
|
||||
void e_cal_data_model_subscriber_component_added (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
ECalComponent *comp);
|
||||
void e_cal_data_model_subscriber_component_modified (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
ECalComponent *comp);
|
||||
void e_cal_data_model_subscriber_component_removed (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
const gchar *uid,
|
||||
const gchar *rid);
|
||||
void e_cal_data_model_subscriber_freeze (ECalDataModelSubscriber *subscriber);
|
||||
void e_cal_data_model_subscriber_thaw (ECalDataModelSubscriber *subscriber);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* E_CAL_DATA_MODEL_SUBSCRIBER_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat, Inc. (www.redhat.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Milan Crha <mcrha@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef E_CAL_DATA_MODEL_H
|
||||
#define E_CAL_DATA_MODEL_H
|
||||
|
||||
#include <libecal/libecal.h>
|
||||
|
||||
#include "e-cal-data-model-subscriber.h"
|
||||
|
||||
/* Standard GObject macros */
|
||||
#define E_TYPE_CAL_DATA_MODEL \
|
||||
(e_cal_data_model_get_type ())
|
||||
#define E_CAL_DATA_MODEL(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST \
|
||||
((obj), E_TYPE_CAL_DATA_MODEL, ECalDataModel))
|
||||
#define E_CAL_DATA_MODEL_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_CAST \
|
||||
((cls), E_TYPE_CAL_DATA_MODEL, ECalDataModelClass))
|
||||
#define E_IS_CAL_DATA_MODEL(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE \
|
||||
((obj), E_TYPE_CAL_DATA_MODEL))
|
||||
#define E_IS_CAL_DATA_MODEL_CLASS(cls) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE \
|
||||
((cls), E_TYPE_CAL_DATA_MODEL))
|
||||
#define E_CAL_DATA_MODEL_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS \
|
||||
((obj), E_TYPE_CAL_DATA_MODEL, ECalDataModelClass))
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
E_CAL_DATA_MODEL_VIEW_STATE_START,
|
||||
E_CAL_DATA_MODEL_VIEW_STATE_PROGRESS,
|
||||
E_CAL_DATA_MODEL_VIEW_STATE_COMPLETE,
|
||||
E_CAL_DATA_MODEL_VIEW_STATE_STOP
|
||||
} ECalDataModelViewState;
|
||||
|
||||
typedef struct _ECalDataModel ECalDataModel;
|
||||
typedef struct _ECalDataModelClass ECalDataModelClass;
|
||||
typedef struct _ECalDataModelPrivate ECalDataModelPrivate;
|
||||
|
||||
struct _ECalDataModel {
|
||||
GObject parent;
|
||||
ECalDataModelPrivate *priv;
|
||||
};
|
||||
|
||||
struct _ECalDataModelClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (* view_state_changed) (ECalDataModel *data_model,
|
||||
ECalClientView *view,
|
||||
ECalDataModelViewState state,
|
||||
guint percent,
|
||||
const gchar *message,
|
||||
const GError *error);
|
||||
};
|
||||
|
||||
typedef void (* EThreadJobFunc) (gpointer user_data,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
typedef GCancellable * (* ECalDataModelSubmitThreadJobFunc)
|
||||
(EThreadJobFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify free_user_data);
|
||||
|
||||
GType e_cal_data_model_get_type (void);
|
||||
ECalDataModel * e_cal_data_model_new (ECalDataModelSubmitThreadJobFunc func);
|
||||
ECalDataModel * e_cal_data_model_new_clone (ECalDataModel *src_data_model);
|
||||
GCancellable * e_cal_data_model_submit_thread_job
|
||||
(ECalDataModel *data_model,
|
||||
EThreadJobFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify free_user_data);
|
||||
gboolean e_cal_data_model_get_disposing (ECalDataModel *data_model);
|
||||
void e_cal_data_model_set_disposing (ECalDataModel *data_model,
|
||||
gboolean disposing);
|
||||
gboolean e_cal_data_model_get_expand_recurrences
|
||||
(ECalDataModel *data_model);
|
||||
void e_cal_data_model_set_expand_recurrences
|
||||
(ECalDataModel *data_model,
|
||||
gboolean expand_recurrences);
|
||||
gboolean e_cal_data_model_get_skip_cancelled
|
||||
(ECalDataModel *data_model);
|
||||
void e_cal_data_model_set_skip_cancelled
|
||||
(ECalDataModel *data_model,
|
||||
gboolean expand_recurrences);
|
||||
ICalTimezone * e_cal_data_model_get_timezone (ECalDataModel *data_model);
|
||||
void e_cal_data_model_set_timezone (ECalDataModel *data_model,
|
||||
ICalTimezone *zone);
|
||||
void e_cal_data_model_set_filter (ECalDataModel *data_model,
|
||||
const gchar *sexp);
|
||||
gchar * e_cal_data_model_dup_filter (ECalDataModel *data_model);
|
||||
void e_cal_data_model_add_client (ECalDataModel *data_model,
|
||||
ECalClient *client);
|
||||
void e_cal_data_model_remove_client (ECalDataModel *data_model,
|
||||
const gchar *uid);
|
||||
ECalClient * e_cal_data_model_ref_client (ECalDataModel *data_model,
|
||||
const gchar *uid);
|
||||
GList * e_cal_data_model_get_clients (ECalDataModel *data_model);
|
||||
GSList * e_cal_data_model_get_components (ECalDataModel *data_model,
|
||||
time_t in_range_start,
|
||||
time_t in_range_end);
|
||||
|
||||
typedef gboolean (* ECalDataModelForeachFunc) (ECalDataModel *data_model,
|
||||
ECalClient *client,
|
||||
const ECalComponentId *id,
|
||||
ECalComponent *comp,
|
||||
time_t instance_start,
|
||||
time_t instance_end,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean e_cal_data_model_foreach_component
|
||||
(ECalDataModel *data_model,
|
||||
time_t in_range_start,
|
||||
time_t in_range_end,
|
||||
ECalDataModelForeachFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
void e_cal_data_model_subscribe (ECalDataModel *data_model,
|
||||
ECalDataModelSubscriber *subscriber,
|
||||
time_t range_start,
|
||||
time_t range_end);
|
||||
void e_cal_data_model_unsubscribe (ECalDataModel *data_model,
|
||||
ECalDataModelSubscriber *subscriber);
|
||||
gboolean e_cal_data_model_get_subscriber_range
|
||||
(ECalDataModel *data_model,
|
||||
ECalDataModelSubscriber *subscriber,
|
||||
time_t *range_start,
|
||||
time_t *range_end);
|
||||
void e_cal_data_model_freeze_views_update
|
||||
(ECalDataModel *data_model);
|
||||
void e_cal_data_model_thaw_views_update
|
||||
(ECalDataModel *data_model);
|
||||
gboolean e_cal_data_model_is_views_update_frozen
|
||||
(ECalDataModel *data_model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* E_CAL_DATA_MODEL_H */
|
||||
@@ -1,23 +0,0 @@
|
||||
contrib_incs += [ include_directories('.') ]
|
||||
|
||||
libevolution_files = files(
|
||||
'e-cal-data-model.c',
|
||||
'e-cal-data-model-subscriber.c'
|
||||
)
|
||||
|
||||
libevolution_deps = [
|
||||
libecal_dep,
|
||||
libedataserver_dep,
|
||||
]
|
||||
|
||||
libevolution = static_library(
|
||||
'evolution',
|
||||
dependencies: libevolution_deps,
|
||||
sources: libevolution_files,
|
||||
pic: true,
|
||||
)
|
||||
|
||||
libevolution_dep = declare_dependency(
|
||||
link_with: libevolution,
|
||||
include_directories: include_directories('.'),
|
||||
)
|
||||
@@ -1,3 +0,0 @@
|
||||
contrib_incs = []
|
||||
|
||||
subdir('evolution')
|
||||
@@ -189,7 +189,6 @@ src_dir = join_paths(meson.source_root(), 'src')
|
||||
###########
|
||||
|
||||
subdir('build-aux')
|
||||
subdir('contrib')
|
||||
subdir('data')
|
||||
subdir('src')
|
||||
subdir('po')
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#ifndef __GCAL_MANAGER_H__
|
||||
#define __GCAL_MANAGER_H__
|
||||
|
||||
#include "e-cal-data-model.h"
|
||||
#include "gcal-calendar.h"
|
||||
#include "gcal-event.h"
|
||||
#include "gcal-types.h"
|
||||
|
||||
@@ -4,7 +4,6 @@ gcal_deps = [
|
||||
gsettings_desktop_schemas_dep,
|
||||
libedataserverui_dep,
|
||||
libedataserver_dep,
|
||||
libevolution_dep,
|
||||
libecal_dep,
|
||||
libdazzle_dep,
|
||||
libsoup_dep,
|
||||
@@ -84,9 +83,6 @@ calendar_incs = [
|
||||
include_directories('weather'),
|
||||
]
|
||||
|
||||
calendar_incs += contrib_incs
|
||||
|
||||
|
||||
###################
|
||||
# Private library #
|
||||
###################
|
||||
@@ -130,7 +126,6 @@ sources = files(
|
||||
'search/gcal-search-model.c',
|
||||
'utils/gcal-date-time-utils.c',
|
||||
'utils/gcal-source-discoverer.c',
|
||||
'utils/gcal-thread-utils.c',
|
||||
'utils/gcal-utils.c',
|
||||
'views/gcal-month-cell.c',
|
||||
'views/gcal-month-popover.c',
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/* gcal-thread-utils.c
|
||||
*
|
||||
* Copyright 2019 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "gcal-thread-utils.h"
|
||||
|
||||
/* Code kindly provided by Milan Crha */
|
||||
|
||||
typedef struct {
|
||||
EThreadJobFunc func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify free_user_data;
|
||||
|
||||
GCancellable *cancellable;
|
||||
GError *error;
|
||||
} ThreadJobData;
|
||||
|
||||
static void
|
||||
thread_job_data_free (gpointer ptr)
|
||||
{
|
||||
ThreadJobData *tjd = ptr;
|
||||
|
||||
if (tjd != NULL)
|
||||
{
|
||||
/* This should go to UI with more info/description,
|
||||
* if it is not G_IOI_ERROR_CANCELLED */
|
||||
if (tjd->error != NULL && !g_error_matches (tjd->error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Job failed: %s\n", tjd->error->message);
|
||||
|
||||
if (tjd->free_user_data != NULL)
|
||||
tjd->free_user_data (tjd->user_data);
|
||||
|
||||
g_clear_object (&tjd->cancellable);
|
||||
g_clear_error (&tjd->error);
|
||||
g_free (tjd);
|
||||
}
|
||||
}
|
||||
|
||||
static gpointer
|
||||
thread_job_thread (gpointer user_data)
|
||||
{
|
||||
ThreadJobData *tjd = user_data;
|
||||
|
||||
g_return_val_if_fail (tjd != NULL, NULL);
|
||||
|
||||
if (tjd->func != NULL)
|
||||
tjd->func (tjd->user_data, tjd->cancellable, &tjd->error);
|
||||
|
||||
thread_job_data_free (tjd);
|
||||
|
||||
return g_thread_self ();
|
||||
}
|
||||
|
||||
GCancellable*
|
||||
gcal_thread_submit_job (EThreadJobFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify free_user_data)
|
||||
{
|
||||
ThreadJobData *tjd;
|
||||
GThread *thread;
|
||||
GCancellable *cancellable;
|
||||
|
||||
cancellable = g_cancellable_new ();
|
||||
|
||||
tjd = g_new0 (ThreadJobData, 1);
|
||||
tjd->func = func;
|
||||
tjd->user_data = user_data;
|
||||
tjd->free_user_data = free_user_data;
|
||||
/* user should be able to cancel this cancellable somehow */
|
||||
tjd->cancellable = g_object_ref (cancellable);
|
||||
tjd->error = NULL;
|
||||
|
||||
thread = g_thread_try_new (NULL, thread_job_thread, tjd, &tjd->error);
|
||||
if (thread != NULL)
|
||||
{
|
||||
g_thread_unref (thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
thread_job_data_free (tjd);
|
||||
g_clear_object (&cancellable);
|
||||
}
|
||||
|
||||
return cancellable;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* gcal-thread-utils.h
|
||||
*
|
||||
* Copyright 2019 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "e-cal-data-model.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GCancellable* gcal_thread_submit_job (EThreadJobFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify free_user_data);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -20,7 +20,6 @@
|
||||
#define __GCAL_UTILS_H__
|
||||
|
||||
#include "gcal-date-time-utils.h"
|
||||
#include "gcal-thread-utils.h"
|
||||
#include "gcal-manager.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#define G_LOG_DOMAIN "GcalMonthView"
|
||||
|
||||
#include "config.h"
|
||||
#include "e-cal-data-model-subscriber.h"
|
||||
#include "gcal-application.h"
|
||||
#include "gcal-clock.h"
|
||||
#include "gcal-context.h"
|
||||
|
||||
Reference in New Issue
Block a user