void dlg_password (GtkWidget *widget, gpointer callback_data) { FrWindow *window = callback_data; DialogData *data; GtkWidget *content_area; char *basename; char *title; data = g_new0 (DialogData, 1); data->window = window; data->builder = _gtk_builder_new_from_resource ("password.ui"); if (data->builder == NULL) { g_free (data); return; } /* Set widgets data. */ data->dialog = g_object_new (GTK_TYPE_DIALOG, "transient-for", GTK_WINDOW (window), "modal", TRUE, "use-header-bar", _gtk_settings_get_dialogs_use_header (), NULL); content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog)); gtk_container_add (GTK_CONTAINER (content_area), GET_WIDGET ("password_vbox")); gtk_dialog_add_buttons (GTK_DIALOG (data->dialog), _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL, _GTK_LABEL_SAVE, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK); gtk_style_context_add_class (gtk_widget_get_style_context (gtk_dialog_get_widget_for_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK)), GTK_STYLE_CLASS_SUGGESTED_ACTION); basename = _g_file_get_display_basename (fr_archive_get_file (window->archive)); title = g_strdup_printf (_("Enter a password for “%s”"), basename); gtk_label_set_text (GTK_LABEL (GET_WIDGET ("title_label")), title); g_free (title); g_free (basename); _gtk_entry_use_as_password_entry (GTK_ENTRY (GET_WIDGET ("password_entry"))); _gtk_entry_set_locale_text (GTK_ENTRY (GET_WIDGET ("password_entry")), fr_window_get_password (window)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("encrypt_header_checkbutton")), fr_window_get_encrypt_header (window)); if (! fr_archive_is_capable_of (window->archive, FR_ARCHIVE_CAN_ENCRYPT_HEADER)) { gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("encrypt_header_checkbutton")), TRUE); gtk_widget_set_sensitive (GET_WIDGET ("encrypt_header_checkbutton"), FALSE); } /* Set the signals handlers. */ g_signal_connect ((data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect ((data->dialog), "response", G_CALLBACK (response_cb), data); /* Run dialog. */ gtk_widget_grab_focus (GET_WIDGET ("password_entry")); gtk_widget_show (data->dialog); }
void dlg_password (GtkWidget *widget, gpointer callback_data) { FrWindow *window = callback_data; DialogData *data; data = g_new0 (DialogData, 1); data->builder = _gtk_builder_new_from_file ("password.ui"); if (data->builder == NULL) { g_free (data); return; } data->window = window; /* Get the widgets. */ data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog"); data->pw_password_entry = _gtk_builder_get_widget (data->builder, "pw_password_entry"); data->pw_encrypt_header_checkbutton = _gtk_builder_get_widget (data->builder, "pw_encrypt_header_checkbutton"); /* Set widgets data. */ _gtk_entry_set_locale_text (GTK_ENTRY (data->pw_password_entry), fr_window_get_password (window)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->pw_encrypt_header_checkbutton), fr_window_get_encrypt_header (window)); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (G_OBJECT (data->dialog), "response", G_CALLBACK (response_cb), data); /* Run dialog. */ gtk_widget_grab_focus (data->pw_password_entry); if (gtk_widget_get_realized (GTK_WIDGET (window))) gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window)); gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE); gtk_widget_show (data->dialog); }