[Gpa-commits] r852 - trunk/src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 18 22:42:27 CET 2008
Author: marcus
Date: 2008-03-18 22:42:25 +0100 (Tue, 18 Mar 2008)
New Revision: 852
Modified:
trunk/src/ChangeLog
trunk/src/gpaexportfileop.c
trunk/src/gpaimportfileop.c
trunk/src/gpgmetools.c
trunk/src/gpgmetools.h
Log:
2008-03-18 Marcus Brinkmann <marcus at g10code.de>
* gpgmetools.h (gpa_open_output_direct): New prototype.
* gpgmetools.c (gpa_open_output_direct): New function.
* gpaimportfileop.c (gpa_import_file_operation_get_source): Use
the GtkFileChooserDialog widget instead of GtkFileSelection. Fix
loop logic.
* gpaexportfileop.c (gpa_export_file_operation_get_destination):
Likewise. Use gpa_open_output_direct instead of
gpa_open_output.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2008-03-18 18:10:09 UTC (rev 851)
+++ trunk/src/ChangeLog 2008-03-18 21:42:25 UTC (rev 852)
@@ -1,5 +1,14 @@
2008-03-18 Marcus Brinkmann <marcus at g10code.de>
+ * gpgmetools.h (gpa_open_output_direct): New prototype.
+ * gpgmetools.c (gpa_open_output_direct): New function.
+ * gpaimportfileop.c (gpa_import_file_operation_get_source): Use
+ the GtkFileChooserDialog widget instead of GtkFileSelection. Fix
+ loop logic.
+ * gpaexportfileop.c (gpa_export_file_operation_get_destination):
+ Likewise. Use gpa_open_output_direct instead of
+ gpa_open_output.
+
* gpawidgets.c (gpa_expiry_frame_new): Replace editable GtkCombo
by uneditable GtkComboBox.
(gpa_expiry_frame_dont): Don't change the "after" widgets, just
Modified: trunk/src/gpaexportfileop.c
===================================================================
--- trunk/src/gpaexportfileop.c 2008-03-18 18:10:09 UTC (rev 851)
+++ trunk/src/gpaexportfileop.c 2008-03-18 21:42:25 UTC (rev 852)
@@ -1,5 +1,6 @@
/* gpaexportfileop.c - The GpaExportFileOperation object.
- * Copyright (C) 2003, Miguel Coca.
+ * Copyright (C) 2003, Miguel Coca.
+ * Copyright (C) 2008 g10 Code GmbH.
*
* This file is part of GPA
*
@@ -130,35 +131,44 @@
gboolean *armor)
{
GpaExportFileOperation *op = GPA_EXPORT_FILE_OPERATION (operation);
- GtkWidget *dialog = gtk_file_selection_new (_("Export public keys to file"));
+ GtkWidget *dialog;
GtkResponseType response;
+ GtkWidget *armor_check = NULL;
- /* Customize the dialog, adding the "armor" option */
- GtkWidget *armor_check = gtk_check_button_new_with_mnemonic (_("_armor"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (armor_check), *armor);
- if (!gpa_options_get_simplified_ui (gpa_options_get_instance ()))
+ dialog = gtk_file_chooser_dialog_new
+ (_("Export public keys to file"), GTK_WINDOW (GPA_OPERATION (op)->window),
+ GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
+ TRUE);
+
+ /* Customize the dialog, adding the "armor" option. */
+ if (! gpa_options_get_simplified_ui (gpa_options_get_instance ()))
{
- GtkWidget *vbox = GTK_DIALOG (dialog)->vbox;
- gtk_box_pack_start (GTK_BOX (vbox), armor_check, FALSE, FALSE, 0);
+ GtkWidget *armor_check;
+
+ armor_check = gtk_check_button_new_with_mnemonic (_("_armor"));
gtk_widget_show_all (armor_check);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (armor_check), *armor);
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog),
+ armor_check);
}
- /* Run the dialog until there is a valid response */
+ /* Run the dialog until there is a valid response. */
do
{
response = gtk_dialog_run (GTK_DIALOG (dialog));
- /* Save the selected file, free'ing the previous value if required */
+ /* Save the selected file, free'ing the previous value if required. */
if (op->file)
- {
- g_free (op->file);
- }
- op->file = g_strdup (gtk_file_selection_get_filename
- (GTK_FILE_SELECTION (dialog)));
- *armor = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (armor_check));
+ g_free (op->file);
+ op->file = g_strdup (gtk_file_chooser_get_filename
+ (GTK_FILE_CHOOSER (dialog)));
+ *armor = (armor_check == NULL) ? TRUE
+ : gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (armor_check));
}
- while (response != GTK_RESPONSE_CANCEL &&
- (op->fd = gpa_open_output
- (op->file, dest, GPA_OPERATION (op)->window)) == -1);
+ while (response == GTK_RESPONSE_OK
+ && (op->fd = gpa_open_output_direct
+ (op->file, dest, GPA_OPERATION (op)->window)) == -1);
gtk_widget_destroy (dialog);
return (response == GTK_RESPONSE_OK);
Modified: trunk/src/gpaimportfileop.c
===================================================================
--- trunk/src/gpaimportfileop.c 2008-03-18 18:10:09 UTC (rev 851)
+++ trunk/src/gpaimportfileop.c 2008-03-18 21:42:25 UTC (rev 852)
@@ -1,5 +1,6 @@
/* gpaimportfileop.c - The GpaImportFileOperation object.
- * Copyright (C) 2003, Miguel Coca.
+ * Copyright (C) 2003, Miguel Coca.
+ * Copyright (C) 2008 g10 Code GmbH.
*
* This file is part of GPA
*
@@ -44,13 +45,9 @@
/* Cleanup */
if (op->fd != -1)
- {
- close (op->fd);
- }
+ close (op->fd);
if (op->file)
- {
- g_free (op->file);
- }
+ g_free (op->file);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -128,24 +125,28 @@
gpgme_data_t *source)
{
GpaImportFileOperation *op = GPA_IMPORT_FILE_OPERATION (operation);
- GtkWidget *dialog = gtk_file_selection_new (_("Import public keys from file"));
+ GtkWidget *dialog;
GtkResponseType response;
- /* Run the dialog until there is a valid response */
+ dialog = gtk_file_chooser_dialog_new
+ (_("Import public keys from file"),
+ GTK_WINDOW (GPA_OPERATION (op)->window),
+ GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+
+ /* Run the dialog until there is a valid response. */
do
{
response = gtk_dialog_run (GTK_DIALOG (dialog));
- /* Save the selected file, free'ing the previous value if required */
+ /* Save the selected file, free'ing the previous value if required. */
if (op->file)
- {
- g_free (op->file);
- }
- op->file = g_strdup (gtk_file_selection_get_filename
- (GTK_FILE_SELECTION (dialog)));
+ g_free (op->file);
+ op->file = g_strdup (gtk_file_chooser_get_filename
+ (GTK_FILE_CHOOSER (dialog)));
}
- while (response != GTK_RESPONSE_CANCEL &&
- (op->fd = gpa_open_input
- (op->file, source, GPA_OPERATION (op)->window)) == -1);
+ while (response == GTK_RESPONSE_OK
+ && (op->fd = gpa_open_input
+ (op->file, source, GPA_OPERATION (op)->window)) == -1);
gtk_widget_destroy (dialog);
return (response == GTK_RESPONSE_OK);
Modified: trunk/src/gpgmetools.c
===================================================================
--- trunk/src/gpgmetools.c 2008-03-18 18:10:09 UTC (rev 851)
+++ trunk/src/gpgmetools.c 2008-03-18 21:42:25 UTC (rev 852)
@@ -177,36 +177,43 @@
int
-gpa_open_output (const char *filename, gpgme_data_t *data, GtkWidget *parent)
+gpa_open_output_direct (const char *filename, gpgme_data_t *data,
+ GtkWidget *parent)
{
int target = -1;
-
- if (check_overwriting (filename, parent))
+ gpg_error_t err;
+
+ target = g_open (filename,
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ if (target == -1)
{
- gpg_error_t err;
-
- target = g_open (filename,
- O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
- if (target == -1)
- {
- gchar *message;
- message = g_strdup_printf ("%s: %s", filename, strerror(errno));
- gpa_window_error (message, parent);
- g_free (message);
- }
- err = gpgme_data_new_from_fd (data, target);
- if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
- {
- close (target);
- target = -1;
- }
+ gchar *message;
+ message = g_strdup_printf ("%s: %s", filename, strerror(errno));
+ gpa_window_error (message, parent);
+ g_free (message);
}
+ err = gpgme_data_new_from_fd (data, target);
+ if (gpg_err_code (err) != GPG_ERR_NO_ERROR)
+ {
+ close (target);
+ target = -1;
+ }
return target;
}
int
+gpa_open_output (const char *filename, gpgme_data_t *data, GtkWidget *parent)
+{
+ if (! check_overwriting (filename, parent))
+ return -1;
+
+ return gpa_open_output_direct (filename, data, parent);
+}
+
+
+int
gpa_open_input (const char *filename, gpgme_data_t *data, GtkWidget *parent)
{
gpg_error_t err;
Modified: trunk/src/gpgmetools.h
===================================================================
--- trunk/src/gpgmetools.h 2008-03-18 18:10:09 UTC (rev 851)
+++ trunk/src/gpgmetools.h 2008-03-18 21:42:25 UTC (rev 852)
@@ -92,7 +92,9 @@
/* Create a new gpgme_data_t from a file for writing, and return the
file descriptor for the file. Always reports all errors to the
- user. */
+ user. The _direct variant does not check for overwriting. */
+int gpa_open_output_direct (const char *filename, gpgme_data_t *data,
+ GtkWidget *parent);
int gpa_open_output (const char *filename, gpgme_data_t *data,
GtkWidget *parent);
More information about the Gpa-commits
mailing list