calendar-editor/new-calendar: Port authorization window to AdwMessageDialog
Replaces the AdwWindow authorization window with an AdwMessageDialog Fixes #1044
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
38455a074f
commit
779e3cd080
@@ -50,9 +50,7 @@ struct _GcalNewCalendarPage
|
|||||||
GtkEntry *calendar_address_entry;
|
GtkEntry *calendar_address_entry;
|
||||||
EntryState calendar_address_entry_state;
|
EntryState calendar_address_entry_state;
|
||||||
GcalFileChooserButton *calendar_file_chooser_button;
|
GcalFileChooserButton *calendar_file_chooser_button;
|
||||||
GtkWidget *credentials_cancel_button;
|
AdwMessageDialog *credentials_dialog;
|
||||||
GtkWidget *credentials_connect_button;
|
|
||||||
GtkWindow *credentials_dialog;
|
|
||||||
GtkEntry *credentials_password_entry;
|
GtkEntry *credentials_password_entry;
|
||||||
GtkEntry *credentials_user_entry;
|
GtkEntry *credentials_user_entry;
|
||||||
GtkColorDialogButton *local_calendar_color_button;
|
GtkColorDialogButton *local_calendar_color_button;
|
||||||
@@ -260,15 +258,6 @@ discover_sources (GcalNewCalendarPage *self)
|
|||||||
GCAL_EXIT;
|
GCAL_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
hide_credentials_dialog (GcalNewCalendarPage *self)
|
|
||||||
{
|
|
||||||
gtk_editable_set_text (GTK_EDITABLE (self->credentials_user_entry), "");
|
|
||||||
gtk_editable_set_text (GTK_EDITABLE (self->credentials_password_entry), "");
|
|
||||||
|
|
||||||
gtk_window_close (self->credentials_dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callbacks
|
* Callbacks
|
||||||
*/
|
*/
|
||||||
@@ -350,8 +339,8 @@ sources_discovered_cb (GObject *source_object,
|
|||||||
g_debug ("Unauthorized, asking for credentials...");
|
g_debug ("Unauthorized, asking for credentials...");
|
||||||
|
|
||||||
root = gtk_widget_get_root (GTK_WIDGET (self));
|
root = gtk_widget_get_root (GTK_WIDGET (self));
|
||||||
gtk_window_set_transient_for (self->credentials_dialog, GTK_WINDOW (root));
|
gtk_window_set_transient_for (GTK_WINDOW (self->credentials_dialog), GTK_WINDOW (root));
|
||||||
gtk_window_present (self->credentials_dialog);
|
gtk_window_present (GTK_WINDOW (self->credentials_dialog));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -430,23 +419,17 @@ on_calendar_address_activated_cb (GtkEntry *entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_credential_button_clicked_cb (GtkWidget *button,
|
on_credentials_dialog_response_cb (AdwMessageDialog *dialog,
|
||||||
|
const gchar *response,
|
||||||
GcalNewCalendarPage *self)
|
GcalNewCalendarPage *self)
|
||||||
{
|
{
|
||||||
if (button == self->credentials_connect_button)
|
if (g_str_equal (response, "connect"))
|
||||||
discover_sources (self);
|
discover_sources (self);
|
||||||
else
|
else if (g_str_equal (response, "cancel"))
|
||||||
update_url_entry_state (self, ENTRY_STATE_INVALID);
|
update_url_entry_state (self, ENTRY_STATE_INVALID);
|
||||||
|
|
||||||
hide_credentials_dialog (self);
|
gtk_editable_set_text (GTK_EDITABLE (self->credentials_user_entry), "");
|
||||||
}
|
gtk_editable_set_text (GTK_EDITABLE (self->credentials_password_entry), "");
|
||||||
|
|
||||||
static void
|
|
||||||
on_credential_entry_activate_cb (GtkEntry *entry,
|
|
||||||
GcalNewCalendarPage *self)
|
|
||||||
{
|
|
||||||
discover_sources (self);
|
|
||||||
hide_credentials_dialog (self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -650,8 +633,6 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
|
|||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, add_button);
|
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, add_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_address_entry);
|
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_address_entry);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_file_chooser_button);
|
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, calendar_file_chooser_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_cancel_button);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_connect_button);
|
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_dialog);
|
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_dialog);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_password_entry);
|
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_password_entry);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_user_entry);
|
gtk_widget_class_bind_template_child (widget_class, GcalNewCalendarPage, credentials_user_entry);
|
||||||
@@ -662,8 +643,7 @@ gcal_new_calendar_page_class_init (GcalNewCalendarPageClass *klass)
|
|||||||
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_add_button_clicked_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_add_button_clicked_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_calendar_address_activated_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_calendar_address_activated_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_credential_button_clicked_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_credentials_dialog_response_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_credential_entry_activate_cb);
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_file_chooser_button_file_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_file_chooser_button_file_changed_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_name_row_text_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_name_row_text_changed_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_color_button_rgba_changed_cb);
|
gtk_widget_class_bind_template_callback (widget_class, on_local_calendar_color_button_rgba_changed_cb);
|
||||||
|
|||||||
@@ -209,110 +209,36 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Credentials popover -->
|
<!-- Credentials popover -->
|
||||||
<object class="AdwWindow" id="credentials_dialog">
|
<object class="AdwMessageDialog" id="credentials_dialog">
|
||||||
<property name="title" translatable="yes">Credentials</property>
|
<property name="heading" translatable="true">Credentials</property>
|
||||||
<property name="modal">True</property>
|
<property name="extra-child">
|
||||||
<property name="hide-on-close">True</property>
|
<object class="AdwClamp">
|
||||||
<property name="default-width">350</property>
|
<child>
|
||||||
<property name="default-height">150</property>
|
<object class="GtkListBox">
|
||||||
|
<child>
|
||||||
<property name="content">
|
<object class="AdwEntryRow" id="credentials_user_entry">
|
||||||
<object class="AdwToolbarView">
|
<property name="title" translatable="true">User</property>
|
||||||
<child type="top">
|
|
||||||
<object class="GtkHeaderBar">
|
|
||||||
<property name="show-title-buttons">False</property>
|
|
||||||
|
|
||||||
<child type="start">
|
|
||||||
<object class="GtkButton" id="credentials_cancel_button">
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="label" translatable="yes">Cancel</property>
|
|
||||||
<signal name="clicked" handler="on_credential_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
<child type="end">
|
<object class="AdwEntryRow" id="credentials_password_entry">
|
||||||
<object class="GtkButton" id="credentials_connect_button">
|
<property name="title" translatable="true">Password</property>
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="label" translatable="yes">Connect</property>
|
|
||||||
<signal name="clicked" handler="on_credential_button_clicked_cb" object="GcalNewCalendarPage" swapped="no" />
|
|
||||||
<style>
|
|
||||||
<class name="suggested-action" />
|
|
||||||
</style>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<style>
|
||||||
|
<class name="boxed-list"/>
|
||||||
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<property name="content">
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="margin-top">12</property>
|
|
||||||
<property name="margin-bottom">12</property>
|
|
||||||
<property name="margin-start">12</property>
|
|
||||||
<property name="margin-end">12</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkGrid" id="credentials_grid">
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="margin-top">12</property>
|
|
||||||
<property name="margin-bottom">12</property>
|
|
||||||
<property name="margin-start">12</property>
|
|
||||||
<property name="margin-end">12</property>
|
|
||||||
<property name="row_spacing">6</property>
|
|
||||||
<property name="column_spacing">12</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="credentials_user_dim_label">
|
|
||||||
<property name="label" translatable="yes">User</property>
|
|
||||||
<property name="xalign">1</property>
|
|
||||||
<layout>
|
|
||||||
<property name="column">0</property>
|
|
||||||
<property name="row">0</property>
|
|
||||||
</layout>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label" />
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="credentials_password_dim_label">
|
|
||||||
<property name="label" translatable="yes">Password</property>
|
|
||||||
<property name="xalign">1</property>
|
|
||||||
<layout>
|
|
||||||
<property name="column">0</property>
|
|
||||||
<property name="row">1</property>
|
|
||||||
</layout>
|
|
||||||
<style>
|
|
||||||
<class name="dim-label" />
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="credentials_user_entry">
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<signal name="activate" handler="on_credential_entry_activate_cb" object="GcalNewCalendarPage" swapped="no" />
|
|
||||||
<layout>
|
|
||||||
<property name="column">1</property>
|
|
||||||
<property name="row">0</property>
|
|
||||||
</layout>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="credentials_password_entry">
|
|
||||||
<property name="hexpand">True</property>
|
|
||||||
<property name="visibility">False</property>
|
|
||||||
<signal name="activate" handler="on_credential_entry_activate_cb" object="GcalNewCalendarPage" swapped="no" />
|
|
||||||
<layout>
|
|
||||||
<property name="column">1</property>
|
|
||||||
<property name="row">1</property>
|
|
||||||
</layout>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
</object>
|
|
||||||
</property>
|
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
<responses>
|
||||||
|
<response id="cancel" translatable="yes">_Cancel</response>
|
||||||
|
<response id="connect" translatable="yes" appearance="suggested">_Connect</response>
|
||||||
|
</responses>
|
||||||
|
<property name="default-response">connect</property>
|
||||||
|
<property name="close-response">cancel</property>
|
||||||
|
<signal name="response" handler="on_credentials_dialog_response_cb" object="GcalNewCalendarPage" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
Reference in New Issue
Block a user