import-file-row: Receive a context

Modify the GcalImportFileRow struct to now have the
property GcalContext.
This commit is contained in:
Otávio Silva
2024-07-20 20:20:16 +00:00
committed by Georges Basile Stavracas Neto
parent f0d004c1e7
commit b8903657c5
3 changed files with 27 additions and 3 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ setup_files (GcalImportDialog *self,
AdwPreferencesGroup *group;
GtkWidget *row;
row = gcal_import_file_row_new (files[i], self->title_sizegroup);
row = gcal_import_file_row_new (self->context, files[i], self->title_sizegroup);
g_signal_connect (row, "file-loaded", G_CALLBACK (on_import_row_file_loaded_cb), self);
group = ADW_PREFERENCES_GROUP (adw_preferences_group_new ());
+22 -1
View File
@@ -38,6 +38,8 @@ struct _GcalImportFileRow
GFile *file;
GPtrArray *ical_components;
GPtrArray *ical_timezones;
GcalContext *context;
};
static void read_calendar_finished_cb (GObject *source_object,
@@ -49,6 +51,7 @@ G_DEFINE_TYPE (GcalImportFileRow, gcal_import_file_row, ADW_TYPE_BIN)
enum
{
PROP_0,
PROP_CONTEXT,
PROP_FILE,
N_PROPS,
};
@@ -298,6 +301,7 @@ gcal_import_file_row_finalize (GObject *object)
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
g_clear_object (&self->context);
g_clear_object (&self->file);
g_clear_pointer (&self->ical_components, g_ptr_array_unref);
g_clear_pointer (&self->ical_timezones, g_ptr_array_unref);
@@ -315,6 +319,10 @@ gcal_import_file_row_get_property (GObject *object,
switch (prop_id)
{
case PROP_CONTEXT:
g_value_set_object (value, self->context);
break;
case PROP_FILE:
g_value_set_object (value, self->file);
break;
@@ -334,6 +342,11 @@ gcal_import_file_row_set_property (GObject *object,
switch (prop_id)
{
case PROP_CONTEXT:
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
break;
case PROP_FILE:
g_assert (self->file == NULL);
self->file = g_value_dup_object (value);
@@ -364,6 +377,12 @@ gcal_import_file_row_class_init (GcalImportFileRowClass *klass)
1,
G_TYPE_PTR_ARRAY);
properties[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);
properties[PROP_FILE] = g_param_spec_object ("file",
"An ICS file",
"An ICS file",
@@ -386,12 +405,14 @@ gcal_import_file_row_init (GcalImportFileRow *self)
}
GtkWidget*
gcal_import_file_row_new (GFile *file,
gcal_import_file_row_new (GcalContext *context,
GFile *file,
GtkSizeGroup *title_sizegroup)
{
GcalImportFileRow *self;
self = g_object_new (GCAL_TYPE_IMPORT_FILE_ROW,
"context", context,
"file", file,
NULL);
self->title_sizegroup = title_sizegroup;
+4 -1
View File
@@ -22,12 +22,15 @@
#include <adwaita.h>
#include "gcal-context.h"
G_BEGIN_DECLS
#define GCAL_TYPE_IMPORT_FILE_ROW (gcal_import_file_row_get_type())
G_DECLARE_FINAL_TYPE (GcalImportFileRow, gcal_import_file_row, GCAL, IMPORT_FILE_ROW, AdwBin)
GtkWidget* gcal_import_file_row_new (GFile *file,
GtkWidget* gcal_import_file_row_new (GcalContext *context,
GFile *file,
GtkSizeGroup *title_sizegroup);
GPtrArray* gcal_import_file_row_get_ical_components (GcalImportFileRow *self);