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; AdwPreferencesGroup *group;
GtkWidget *row; 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); g_signal_connect (row, "file-loaded", G_CALLBACK (on_import_row_file_loaded_cb), self);
group = ADW_PREFERENCES_GROUP (adw_preferences_group_new ()); group = ADW_PREFERENCES_GROUP (adw_preferences_group_new ());
+22 -1
View File
@@ -38,6 +38,8 @@ struct _GcalImportFileRow
GFile *file; GFile *file;
GPtrArray *ical_components; GPtrArray *ical_components;
GPtrArray *ical_timezones; GPtrArray *ical_timezones;
GcalContext *context;
}; };
static void read_calendar_finished_cb (GObject *source_object, 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 enum
{ {
PROP_0, PROP_0,
PROP_CONTEXT,
PROP_FILE, PROP_FILE,
N_PROPS, N_PROPS,
}; };
@@ -298,6 +301,7 @@ gcal_import_file_row_finalize (GObject *object)
g_cancellable_cancel (self->cancellable); g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable); g_clear_object (&self->cancellable);
g_clear_object (&self->context);
g_clear_object (&self->file); g_clear_object (&self->file);
g_clear_pointer (&self->ical_components, g_ptr_array_unref); g_clear_pointer (&self->ical_components, g_ptr_array_unref);
g_clear_pointer (&self->ical_timezones, 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) switch (prop_id)
{ {
case PROP_CONTEXT:
g_value_set_object (value, self->context);
break;
case PROP_FILE: case PROP_FILE:
g_value_set_object (value, self->file); g_value_set_object (value, self->file);
break; break;
@@ -334,6 +342,11 @@ gcal_import_file_row_set_property (GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_CONTEXT:
g_assert (self->context == NULL);
self->context = g_value_dup_object (value);
break;
case PROP_FILE: case PROP_FILE:
g_assert (self->file == NULL); g_assert (self->file == NULL);
self->file = g_value_dup_object (value); self->file = g_value_dup_object (value);
@@ -364,6 +377,12 @@ gcal_import_file_row_class_init (GcalImportFileRowClass *klass)
1, 1,
G_TYPE_PTR_ARRAY); 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", properties[PROP_FILE] = g_param_spec_object ("file",
"An ICS file", "An ICS file",
"An ICS file", "An ICS file",
@@ -386,12 +405,14 @@ gcal_import_file_row_init (GcalImportFileRow *self)
} }
GtkWidget* GtkWidget*
gcal_import_file_row_new (GFile *file, gcal_import_file_row_new (GcalContext *context,
GFile *file,
GtkSizeGroup *title_sizegroup) GtkSizeGroup *title_sizegroup)
{ {
GcalImportFileRow *self; GcalImportFileRow *self;
self = g_object_new (GCAL_TYPE_IMPORT_FILE_ROW, self = g_object_new (GCAL_TYPE_IMPORT_FILE_ROW,
"context", context,
"file", file, "file", file,
NULL); NULL);
self->title_sizegroup = title_sizegroup; self->title_sizegroup = title_sizegroup;
+4 -1
View File
@@ -22,12 +22,15 @@
#include <adwaita.h> #include <adwaita.h>
#include "gcal-context.h"
G_BEGIN_DECLS G_BEGIN_DECLS
#define GCAL_TYPE_IMPORT_FILE_ROW (gcal_import_file_row_get_type()) #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) 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); GtkSizeGroup *title_sizegroup);
GPtrArray* gcal_import_file_row_get_ical_components (GcalImportFileRow *self); GPtrArray* gcal_import_file_row_get_ical_components (GcalImportFileRow *self);