The auxiliary text is now presented as the subtitle of the dialog Signed-off-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx> --- src/resources/ui/virt-viewer-auth.ui | 148 ++++++++++++++++------------------- src/virt-viewer-auth.c | 35 +++++---- 2 files changed, 86 insertions(+), 97 deletions(-) diff --git a/src/resources/ui/virt-viewer-auth.ui b/src/resources/ui/virt-viewer-auth.ui index 2920780..367678d 100644 --- a/src/resources/ui/virt-viewer-auth.ui +++ b/src/resources/ui/virt-viewer-auth.ui @@ -1,160 +1,146 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.0 --> <interface> - <!-- interface-requires gtk+ 2.12 --> + <requires lib="gtk+" version="3.12"/> <object class="GtkDialog" id="auth"> + <property name="width_request">350</property> + <property name="height_request">1</property> <property name="can_focus">False</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">Authentication required</property> - <property name="modal">True</property> - <property name="window_position">center-on-parent</property> - <property name="destroy_with_parent">True</property> + <property name="border_width">12</property> <property name="type_hint">dialog</property> - <property name="skip_taskbar_hint">True</property> - <property name="skip_pager_hint">True</property> <child internal-child="vbox"> - <object class="GtkBox" id="dialog-vbox1"> - <property name="visible">True</property> + <object class="GtkBox"> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">2</property> <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> + <object class="GtkButtonBox"> <property name="can_focus">False</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="button-cancel"> - <property name="label" translatable="yes">_Cancel</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> + <placeholder/> </child> <child> - <object class="GtkButton" id="button-ok"> - <property name="label" translatable="yes">_OK</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">3</property> - </packing> + <placeholder/> </child> </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="message"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="label" translatable="yes">label</property> - <property name="use_markup">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> <property name="position">1</property> </packing> </child> <child> - <object class="GtkTable" id="table1"> + <object class="GtkGrid"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">6</property> + <property name="hexpand">True</property> <property name="row_spacing">6</property> + <property name="column_spacing">6</property> <child> - <object class="GtkLabel" id="prompt-password"> + <object class="GtkLabel" id="prompt-username"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Password:</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Username:</property> </object> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> </packing> </child> <child> - <object class="GtkLabel" id="prompt-username"> + <object class="GtkLabel" id="prompt-password"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Username:</property> + <property name="halign">end</property> + <property name="label" translatable="yes">Password:</property> </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> </child> <child> <object class="GtkEntry" id="cred-username"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="margin_left">4</property> + <property name="hexpand">True</property> + <signal name="activate" handler="button_ok_clicked" swapped="no"/> </object> <packing> <property name="left_attach">1</property> - <property name="right_attach">2</property> + <property name="top_attach">0</property> </packing> </child> <child> <object class="GtkEntry" id="cred-password"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="margin_left">4</property> + <property name="hexpand">True</property> <property name="visibility">False</property> <property name="activates_default">True</property> + <signal name="activate" handler="button_ok_clicked" swapped="no"/> </object> <packing> <property name="left_attach">1</property> - <property name="right_attach">2</property> <property name="top_attach">1</property> - <property name="bottom_attach">2</property> </packing> </child> <child> <object class="GtkCheckButton" id="show-password"> + <property name="label" translatable="yes">Show password</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="active">False</property> - <property name="label" translatable="yes">Show password</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="show_password" object="cred-password" swapped="no"/> </object> <packing> <property name="left_attach">1</property> - <property name="right_attach">2</property> <property name="top_attach">2</property> - <property name="bottom_attach">3</property> </packing> </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">0</property> </packing> </child> </object> </child> - <action-widgets> - <action-widget response="-6">button-cancel</action-widget> - <action-widget response="-5">button-ok</action-widget> - </action-widgets> + </object> + <object class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">emblem-ok-symbolic</property> + </object> + <object class="GtkHeaderBar" id="headerbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="title">Authentication required</property> + <property name="show_close_button">True</property> + <property name="decoration_layout">:close</property> + <child> + <object class="GtkButton" id="button-ok"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="image">image1</property> + <property name="always_show_image">True</property> + <signal name="clicked" handler="button_ok_clicked" object="auth" swapped="no"/> + </object> + <packing> + <property name="pack_type">end</property> + </packing> + </child> </object> </interface> diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c index 67c770c..73cc707 100644 --- a/src/virt-viewer-auth.c +++ b/src/virt-viewer-auth.c @@ -33,13 +33,23 @@ #include "virt-viewer-auth.h" #include "virt-viewer-util.h" -static void +void show_password(GtkCheckButton *check_button G_GNUC_UNUSED, GtkEntry *entry); +void button_ok_clicked(GtkButton *button G_GNUC_UNUSED, GtkDialog *dialog); + +void show_password(GtkCheckButton *check_button G_GNUC_UNUSED, GtkEntry *entry) { gtk_entry_set_visibility(entry, !gtk_entry_get_visibility(entry)); } +void +button_ok_clicked(GtkButton *button G_GNUC_UNUSED, + GtkDialog *dialog) +{ + gtk_dialog_response(dialog, GTK_RESPONSE_OK); +} + /* NOTE: if username is provided, and *username is non-NULL, the user input * field will be pre-filled with this value. The existing string will be freed * before setting the output parameter to the user-entered value. @@ -55,23 +65,19 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, GtkBuilder *creds = virt_viewer_util_load_ui("virt-viewer-auth.ui"); GtkWidget *credUsername; GtkWidget *credPassword; - GtkWidget *promptUsername; - GtkWidget *promptPassword; - GtkWidget *labelMessage; - GtkWidget *checkPassword; + GtkWidget *headerbar; int response; char *message; dialog = GTK_WIDGET(gtk_builder_get_object(creds, "auth")); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gtk_window_set_transient_for(GTK_WINDOW(dialog), window); + gtk_builder_connect_signals(creds, dialog); + + headerbar = GTK_WIDGET(gtk_builder_get_object(creds, "headerbar")); + gtk_window_set_titlebar(GTK_WINDOW(dialog), headerbar); - labelMessage = GTK_WIDGET(gtk_builder_get_object(creds, "message")); credUsername = GTK_WIDGET(gtk_builder_get_object(creds, "cred-username")); - promptUsername = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-username")); credPassword = GTK_WIDGET(gtk_builder_get_object(creds, "cred-password")); - promptPassword = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-password")); - checkPassword = GTK_WIDGET(gtk_builder_get_object(creds, "show-password")); gtk_widget_set_sensitive(credUsername, username != NULL); if (username && *username) { @@ -79,22 +85,19 @@ virt_viewer_auth_collect_credentials(GtkWindow *window, /* if username is pre-filled, move focus to password field */ gtk_widget_grab_focus(credPassword); } - gtk_widget_set_sensitive(promptUsername, username != NULL); gtk_widget_set_sensitive(credPassword, password != NULL); - gtk_widget_set_sensitive(promptPassword, password != NULL); - g_signal_connect(checkPassword, "clicked", G_CALLBACK(show_password), credPassword); if (address) { - message = g_strdup_printf(_("Authentication is required for the %s connection to:\n\n<b>%s</b>\n\n"), + message = g_strdup_printf(_("For the %s connection to '%s'"), type, address); } else { - message = g_strdup_printf(_("Authentication is required for the %s connection:\n"), + message = g_strdup_printf(_("For the %s connection"), type); } - gtk_label_set_markup(GTK_LABEL(labelMessage), message); + gtk_header_bar_set_subtitle(GTK_HEADER_BAR(headerbar), message); g_free(message); gtk_widget_show_all(dialog); -- 2.9.3 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list