import-dialog: Port to AdwDialog
This also brings some other changes: * Enables closing the window using Escape * Fixes a few criticals Closes #1258
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
e00d8cbf66
commit
2038ff1da1
@@ -116,7 +116,7 @@ struct _GcalWindow
|
||||
GtkWidget *views_switcher;
|
||||
|
||||
GcalEventEditorDialog *event_editor;
|
||||
GtkWindow *import_dialog;
|
||||
GtkWidget *import_dialog;
|
||||
|
||||
/* new event popover widgets */
|
||||
GtkWidget *quick_add_popover;
|
||||
@@ -830,6 +830,7 @@ gcal_window_dispose (GObject *object)
|
||||
gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->date_chooser));
|
||||
|
||||
g_clear_pointer (&self->quick_add_popover, gtk_widget_unparent);
|
||||
g_clear_pointer (&self->import_dialog, gtk_widget_unparent);
|
||||
|
||||
if (self->delete_event_toast)
|
||||
adw_toast_dismiss (self->delete_event_toast);
|
||||
@@ -1220,11 +1221,10 @@ gcal_window_import_files (GcalWindow *self,
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WINDOW (self));
|
||||
|
||||
g_clear_pointer (&self->import_dialog, gtk_window_destroy);
|
||||
g_clear_pointer (&self->import_dialog, gtk_widget_unparent);
|
||||
|
||||
self->import_dialog = GTK_WINDOW (gcal_import_dialog_new_for_files (self->context, files, n_files));
|
||||
gtk_window_set_transient_for (self->import_dialog, GTK_WINDOW (self));
|
||||
gtk_window_present (self->import_dialog);
|
||||
self->import_dialog = gcal_import_dialog_new_for_files (self->context, files, n_files);
|
||||
adw_dialog_present (ADW_DIALOG (self->import_dialog), GTK_WIDGET (self));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (self->import_dialog), (gpointer *)&self->import_dialog);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ typedef struct
|
||||
|
||||
struct _GcalImportDialog
|
||||
{
|
||||
AdwWindow parent;
|
||||
AdwDialog parent;
|
||||
|
||||
GtkWidget *cancel_button;
|
||||
AdwComboRow *calendar_combo_row;
|
||||
@@ -64,7 +64,7 @@ static void on_import_row_file_loaded_cb (GcalImportFil
|
||||
GPtrArray *events,
|
||||
GcalImportDialog *self);
|
||||
|
||||
G_DEFINE_TYPE (GcalImportDialog, gcal_import_dialog, ADW_TYPE_WINDOW)
|
||||
G_DEFINE_TYPE (GcalImportDialog, gcal_import_dialog, ADW_TYPE_DIALOG)
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -185,7 +185,7 @@ on_events_created_cb (GObject *source_object,
|
||||
if (error)
|
||||
g_warning ("Error creating events: %s", error->message);
|
||||
|
||||
gtk_window_destroy (GTK_WINDOW (self));
|
||||
adw_dialog_close (ADW_DIALOG (self));
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
@@ -202,13 +202,6 @@ on_calendar_combo_row_selected_item_changed_cb (AdwComboRow *combo_row,
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
static void
|
||||
on_cancel_button_clicked_cb (GtkButton *button,
|
||||
GcalImportDialog *self)
|
||||
{
|
||||
gtk_window_destroy (GTK_WINDOW (self));
|
||||
}
|
||||
|
||||
static void
|
||||
on_combo_row_signal_factory_setup_cb (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item,
|
||||
@@ -397,7 +390,7 @@ on_import_row_file_loaded_cb (GcalImportFileRow *row,
|
||||
"Import %d events",
|
||||
self->n_events),
|
||||
self->n_events);
|
||||
gtk_window_set_title (GTK_WINDOW (self), title);
|
||||
adw_dialog_set_title (ADW_DIALOG (self), title);
|
||||
|
||||
gtk_widget_set_visible (GTK_WIDGET (row), TRUE);
|
||||
|
||||
@@ -508,7 +501,6 @@ gcal_import_dialog_class_init (GcalImportDialogClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, title_sizegroup);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_calendar_combo_row_selected_item_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_cancel_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_import_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_combo_row_signal_factory_bind_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_combo_row_signal_factory_setup_cb);
|
||||
@@ -529,7 +521,6 @@ gcal_import_dialog_new_for_files (GcalContext *context,
|
||||
|
||||
self = g_object_new (GCAL_TYPE_IMPORT_DIALOG,
|
||||
"context", context,
|
||||
"use-header-bar", TRUE,
|
||||
NULL);
|
||||
|
||||
setup_files (self, files, n_files);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GCAL_TYPE_IMPORT_DIALOG (gcal_import_dialog_get_type())
|
||||
G_DECLARE_FINAL_TYPE (GcalImportDialog, gcal_import_dialog, GCAL, IMPORT_DIALOG, AdwWindow)
|
||||
G_DECLARE_FINAL_TYPE (GcalImportDialog, gcal_import_dialog, GCAL, IMPORT_DIALOG, AdwDialog)
|
||||
|
||||
GtkWidget* gcal_import_dialog_new_for_files (GcalContext *context,
|
||||
GFile **files,
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GcalImportDialog" parent="AdwWindow">
|
||||
<template class="GcalImportDialog" parent="AdwDialog">
|
||||
<property name="title" translatable="yes">Import Files…</property>
|
||||
<property name="width-request">360</property>
|
||||
<property name="height-request">294</property>
|
||||
<property name="default-width">550</property>
|
||||
<property name="default-height">500</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="destroy-with-parent">True</property>
|
||||
<property name="content">
|
||||
<property name="content-width">500</property>
|
||||
<property name="content-height">500</property>
|
||||
<child>
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="GtkHeaderBar" id="headerbar">
|
||||
@@ -19,7 +15,7 @@
|
||||
<object class="GtkButton" id="cancel_button">
|
||||
<property name="label" translatable="yes">_Cancel</property>
|
||||
<property name="use-underline">True</property>
|
||||
<signal name="clicked" handler="on_cancel_button_clicked_cb" object="GcalImportDialog" swapped="no" />
|
||||
<property name="action-name">sheet.close</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
@@ -77,7 +73,19 @@
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</child>
|
||||
|
||||
<!-- Shortcuts -->
|
||||
<child>
|
||||
<object class="GtkShortcutController">
|
||||
<child>
|
||||
<object class="GtkShortcut">
|
||||
<property name="trigger">Escape</property>
|
||||
<property name="action">action(sheet.close)</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
<object class="GtkSizeGroup" id="title_sizegroup">
|
||||
|
||||
Reference in New Issue
Block a user