[Gpa-commits] r888 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu May 8 12:34:54 CEST 2008


Author: marcus
Date: 2008-05-08 12:34:53 +0200 (Thu, 08 May 2008)
New Revision: 888

Modified:
   trunk/src/ChangeLog
   trunk/src/filesigndlg.c
   trunk/src/filesigndlg.h
   trunk/src/gpafilesignop.c
   trunk/src/gpastreamsignop.c
Log:
2008-05-08  Marcus Brinkmann  <marcus at g10code.de>


	* filesigndlg.h (struct _GpaFileSignDialog): New members vbox_mode
	and force_sig_mode.
	(gpa_file_sign_dialog_new): Remove force_armor argument from
	prototype.
	(gpa_file_sign_dialog_set_armor)
	(gpa_file_sign_dialog_get_force_armor)
	(gpa_file_sign_dialog_set_force_armor)
	(gpa_file_sign_dialog_get_sig_mode)
	(gpa_file_sign_dialog_set_sig_mode)
	(gpa_file_sign_dialog_get_force_sig_mode)
	(gpa_file_sign_dialog_set_force_sig_mode): New prototypes.
	* gpastreamsignop.c (gpa_stream_sign_operation_ctor): Remove
	obsolete argument from gpa_file_sign_dialog_new.
	* gpafilesignop.c (gpa_file_sign_operation_constructor): Likewise.
	If OP->force_armor, set a couple of of properties on
	OP->sign_dialog.
	* filesigndlg.c: New properties PROP_ARMOR, PROP_SIG_MODE,
	PROP_FORCE_SIG_MODE.
	(gpa_file_sign_dialog_constructor): Call gtk_widget_show_all
	before gtk_widget_set_no_show_all.
	(gpa_file_sign_dialog_get_property): Handle new properties.
	(gpa_file_sign_dialog_set_property): Likewise.
	(gpa_file_sign_dialog_class_init): Likewise.
	(gpa_file_sign_dialog_constructor): Save vbox_mode for sig mode.
	Set no-show-all attribute on armor button.  Do not remove normal
	signing mode in simplified UI mode.
	(gpa_file_sign_dialog_new): Remove force_armor argument.
	(gpa_file_sign_dialog_get_sign_type): Rename to ...
	(gpa_file_sign_dialog_get_sig_mode): ... this.  Change callers as
	well.
	(gpa_file_sign_dialog_set_armor)
	(gpa_file_sign_dialog_get_force_armor)
	(gpa_file_sign_dialog_set_force_armor)
	(gpa_file_sign_dialog_get_sig_mode)
	(gpa_file_sign_dialog_set_sig_mode)
	(gpa_file_sign_dialog_get_force_sig_mode)
	(gpa_file_sign_dialog_set_force_sig_mode): New functions.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-05-07 15:13:01 UTC (rev 887)
+++ trunk/src/ChangeLog	2008-05-08 10:34:53 UTC (rev 888)
@@ -1,3 +1,44 @@
+2008-05-08  Marcus Brinkmann  <marcus at g10code.de>
+
+
+	* filesigndlg.h (struct _GpaFileSignDialog): New members vbox_mode
+	and force_sig_mode.
+	(gpa_file_sign_dialog_new): Remove force_armor argument from
+	prototype.
+	(gpa_file_sign_dialog_set_armor)
+	(gpa_file_sign_dialog_get_force_armor)
+	(gpa_file_sign_dialog_set_force_armor)
+	(gpa_file_sign_dialog_get_sig_mode)
+	(gpa_file_sign_dialog_set_sig_mode)
+	(gpa_file_sign_dialog_get_force_sig_mode)
+	(gpa_file_sign_dialog_set_force_sig_mode): New prototypes.
+	* gpastreamsignop.c (gpa_stream_sign_operation_ctor): Remove
+	obsolete argument from gpa_file_sign_dialog_new.
+	* gpafilesignop.c (gpa_file_sign_operation_constructor): Likewise.
+	If OP->force_armor, set a couple of of properties on
+	OP->sign_dialog.
+	* filesigndlg.c: New properties PROP_ARMOR, PROP_SIG_MODE,
+	PROP_FORCE_SIG_MODE.
+	(gpa_file_sign_dialog_constructor): Call gtk_widget_show_all
+	before gtk_widget_set_no_show_all.
+	(gpa_file_sign_dialog_get_property): Handle new properties.
+	(gpa_file_sign_dialog_set_property): Likewise.
+	(gpa_file_sign_dialog_class_init): Likewise.
+	(gpa_file_sign_dialog_constructor): Save vbox_mode for sig mode.
+	Set no-show-all attribute on armor button.  Do not remove normal
+	signing mode in simplified UI mode.
+	(gpa_file_sign_dialog_new): Remove force_armor argument.
+	(gpa_file_sign_dialog_get_sign_type): Rename to ...
+	(gpa_file_sign_dialog_get_sig_mode): ... this.  Change callers as
+	well.
+	(gpa_file_sign_dialog_set_armor)
+	(gpa_file_sign_dialog_get_force_armor)
+	(gpa_file_sign_dialog_set_force_armor)
+	(gpa_file_sign_dialog_get_sig_mode)
+	(gpa_file_sign_dialog_set_sig_mode)
+	(gpa_file_sign_dialog_get_force_sig_mode)
+	(gpa_file_sign_dialog_set_force_sig_mode): New functions.
+
 2008-05-07  Werner Koch  <wk at g10code.com>
 
 	* gpakeydeleteop.c (gpa_key_delete_operation_next): Init ERR.

Modified: trunk/src/filesigndlg.c
===================================================================
--- trunk/src/filesigndlg.c	2008-05-07 15:13:01 UTC (rev 887)
+++ trunk/src/filesigndlg.c	2008-05-08 10:34:53 UTC (rev 888)
@@ -40,7 +40,10 @@
 {
   PROP_0,
   PROP_WINDOW,
-  PROP_FORCE_ARMOR
+  PROP_FORCE_ARMOR,
+  PROP_ARMOR,
+  PROP_FORCE_SIG_MODE,
+  PROP_SIG_MODE
 };
 
 static GObjectClass *parent_class = NULL;
@@ -60,14 +63,26 @@
 			  gtk_window_get_transient_for (GTK_WINDOW (dialog)));
       break;
     case PROP_FORCE_ARMOR:
-      g_value_set_boolean (value, dialog->force_armor);
+      g_value_set_boolean (value,
+			   gpa_file_sign_dialog_get_force_armor (dialog));
       break;
+    case PROP_ARMOR:
+      g_value_set_boolean (value, gpa_file_sign_dialog_get_armor (dialog));
+      break;
+    case PROP_FORCE_SIG_MODE:
+      g_value_set_boolean (value,
+			   gpa_file_sign_dialog_get_force_sig_mode (dialog));
+      break;
+    case PROP_SIG_MODE:
+      g_value_set_int (value, gpa_file_sign_dialog_get_sig_mode (dialog));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     }
 }
 
+
 static void
 gpa_file_sign_dialog_set_property (GObject     *object,
 				   guint        prop_id,
@@ -83,8 +98,19 @@
 				    g_value_get_object (value));
       break;
     case PROP_FORCE_ARMOR:
-      dialog->force_armor = g_value_get_boolean (value);
+      gpa_file_sign_dialog_set_force_armor (dialog,
+					    g_value_get_boolean (value));
       break;
+    case PROP_ARMOR:
+      gpa_file_sign_dialog_set_armor (dialog, g_value_get_boolean (value));
+      break;
+    case PROP_FORCE_SIG_MODE:
+      gpa_file_sign_dialog_set_force_sig_mode (dialog,
+					       g_value_get_boolean (value));
+      break;
+    case PROP_SIG_MODE:
+      gpa_file_sign_dialog_set_sig_mode (dialog, g_value_get_int (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -154,12 +180,11 @@
   vboxMode = gtk_vbox_new (FALSE, 0);
   gtk_container_set_border_width (GTK_CONTAINER (vboxMode), 5);
   gtk_container_add (GTK_CONTAINER (frameMode), vboxMode);
+  dialog->vbox_mode = vboxMode;
 
   radio_sign_comp = gtk_radio_button_new_with_mnemonic
     (NULL, _("Si_gn and compress"));
   gtk_box_pack_start (GTK_BOX (vboxMode), radio_sign_comp, FALSE, FALSE, 0);
-
-  gtk_widget_set_no_show_all (radio_sign_comp, TRUE);
   dialog->radio_comp = radio_sign_comp;
 
   radio_sign =
@@ -193,33 +218,23 @@
   gtk_container_add (GTK_CONTAINER (scrollerWho), clistWho);
   gtk_label_set_mnemonic_widget (GTK_LABEL (labelWho), clistWho);
 			      
-
   checkerArmor = gtk_check_button_new_with_mnemonic (_("A_rmor"));
   gtk_container_set_border_width (GTK_CONTAINER (checkerArmor), 5);
   gtk_box_pack_start (GTK_BOX (vboxSign), checkerArmor, FALSE, FALSE, 0);
+  /* Take care of any child widgets there might be.  */
+  gtk_widget_show_all (checkerArmor);
   gtk_widget_set_no_show_all (checkerArmor, TRUE);
   dialog->check_armor = checkerArmor;
-  if (dialog->force_armor)
-    {
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->check_armor),
-				    TRUE);
-      gtk_widget_set_sensitive (dialog->check_armor, FALSE);
-    }
 
   if (gpa_options_get_simplified_ui (gpa_options_get_instance ()))
-    {
-      gtk_widget_hide (dialog->radio_comp);
-      gtk_widget_hide (dialog->check_armor);
-    }
+    gtk_widget_hide (dialog->check_armor);
   else
-    {
-      gtk_widget_show (dialog->radio_comp);
-      gtk_widget_show (dialog->check_armor);
-    }
+    gtk_widget_show (dialog->check_armor);
 
   return object;
 }
 
+
 static void
 gpa_file_sign_dialog_class_init (GpaFileSignDialogClass *klass)
 {
@@ -239,14 +254,38 @@
 				   ("window", "Parent window",
 				    "Parent window", GTK_TYPE_WIDGET,
 				    G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
+
   g_object_class_install_property (object_class,
 				   PROP_FORCE_ARMOR,
 				   g_param_spec_boolean
 				   ("force-armor", "Force armor",
 				    "Force armor mode", FALSE,
-				    G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+				    G_PARAM_WRITABLE));
+
+  g_object_class_install_property (object_class,
+				   PROP_ARMOR,
+				   g_param_spec_boolean
+				   ("armor", "Armor mode",
+				    "Armor mode", FALSE,
+				    G_PARAM_WRITABLE));
+
+  g_object_class_install_property (object_class,
+				   PROP_FORCE_SIG_MODE,
+				   g_param_spec_boolean
+				   ("force-sig-mode", "Force signature mode",
+				    "Force signature mode", FALSE,
+				    G_PARAM_WRITABLE));
+
+  g_object_class_install_property (object_class,
+				   PROP_SIG_MODE,
+				   g_param_spec_int
+				   ("sig-mode", "Signature mode",
+				    "Signature mode", GPGME_SIG_MODE_NORMAL,
+				    GPGME_SIG_MODE_CLEAR, GPGME_SIG_MODE_NORMAL,
+				    G_PARAM_WRITABLE));
 }
 
+
 GType
 gpa_file_sign_dialog_get_type (void)
 {
@@ -275,21 +314,22 @@
   return sign_dialog_type;
 }
 
+
 /* API */
 
 GtkWidget *
-gpa_file_sign_dialog_new (GtkWidget *parent, gboolean force_armor)
+gpa_file_sign_dialog_new (GtkWidget *parent)
 {
   GpaFileSignDialog *dialog;
   
   dialog = g_object_new (GPA_FILE_SIGN_DIALOG_TYPE,
 			 "window", parent,
-			 "force-armor", force_armor,
 			 NULL);
 
   return GTK_WIDGET(dialog);
 }
 
+
 GList *
 gpa_file_sign_dialog_signers (GpaFileSignDialog *dialog)
 {
@@ -297,23 +337,110 @@
     (GPA_KEY_SELECTOR(dialog->clist_who));
 }
 
+
 gboolean 
 gpa_file_sign_dialog_get_armor (GpaFileSignDialog *dialog)
 {
-  return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->check_armor));
+  g_return_val_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog), FALSE);
+  g_return_val_if_fail (dialog->check_armor != NULL, FALSE);
+
+  return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->check_armor));
 }
 
+
+void
+gpa_file_sign_dialog_set_armor (GpaFileSignDialog *dialog, gboolean armor)
+{
+  g_return_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog));
+  g_return_if_fail (dialog->check_armor != NULL);
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->check_armor), armor);
+}
+
+
+gboolean
+gpa_file_sign_dialog_get_force_armor (GpaFileSignDialog *dialog)
+{
+  g_return_val_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog), FALSE);
+
+  return dialog->force_armor;
+}
+
+
+void
+gpa_file_sign_dialog_set_force_armor (GpaFileSignDialog *dialog,
+				      gboolean force_armor)
+{
+  g_return_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog));
+  g_return_if_fail (dialog->check_armor != NULL);
+
+  if (force_armor == dialog->force_armor)
+    return;
+
+  gtk_widget_set_sensitive (dialog->check_armor, ! force_armor);
+  dialog->force_armor = force_armor;
+}
+
+
+gboolean
+gpa_file_sign_dialog_get_force_sig_mode (GpaFileSignDialog *dialog)
+{
+  g_return_val_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog), FALSE);
+
+  return dialog->force_sig_mode;
+}
+
+
+void
+gpa_file_sign_dialog_set_force_sig_mode (GpaFileSignDialog *dialog,
+				      gboolean force_sig_mode)
+{
+  g_return_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog));
+  g_return_if_fail (dialog->vbox_mode != NULL);
+
+  if (force_sig_mode == dialog->force_sig_mode)
+    return;
+
+  gtk_widget_set_sensitive (dialog->vbox_mode, ! force_sig_mode);
+}
+
+
 gpgme_sig_mode_t 
-gpa_file_sign_dialog_get_sign_type (GpaFileSignDialog *dialog)
+gpa_file_sign_dialog_get_sig_mode (GpaFileSignDialog *dialog)
 {
-  gpgme_sig_mode_t sign_type = GPGME_SIG_MODE_NORMAL;
-  
+  gpgme_sig_mode_t sig_mode = GPGME_SIG_MODE_NORMAL;
+
+  g_return_val_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog),
+			GPGME_SIG_MODE_NORMAL);
+  g_return_val_if_fail (dialog->vbox_mode != NULL, GPGME_SIG_MODE_NORMAL);
+
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radio_comp)))
-    sign_type = GPGME_SIG_MODE_NORMAL;
+    sig_mode = GPGME_SIG_MODE_NORMAL;
   else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_sign)))
-    sign_type = GPGME_SIG_MODE_CLEAR;
+    sig_mode = GPGME_SIG_MODE_CLEAR;
   else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->radio_sep)))
-    sign_type = GPGME_SIG_MODE_DETACH;
+    sig_mode = GPGME_SIG_MODE_DETACH;
 
-  return sign_type;
+  return sig_mode;
 }
+
+
+void
+gpa_file_sign_dialog_set_sig_mode (GpaFileSignDialog *dialog,
+				   gpgme_sig_mode_t mode)
+{
+  GtkWidget *button = NULL;
+
+  g_return_if_fail (GPA_IS_FILE_SIGN_DIALOG (dialog));
+  g_return_if_fail (dialog->vbox_mode != NULL);
+
+  if (mode == GPGME_SIG_MODE_NORMAL)
+    button = dialog->radio_comp;
+  else if (mode == GPGME_SIG_MODE_CLEAR)
+    button = dialog->radio_sign;
+  else if (mode == GPGME_SIG_MODE_DETACH)
+    button = dialog->radio_sep;
+
+  if (button != NULL)
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+}

Modified: trunk/src/filesigndlg.h
===================================================================
--- trunk/src/filesigndlg.h	2008-05-07 15:13:01 UTC (rev 887)
+++ trunk/src/filesigndlg.h	2008-05-08 10:34:53 UTC (rev 888)
@@ -40,13 +40,16 @@
 {
   GtkDialog parent;
 
+  GtkWidget *vbox_mode;
   GtkWidget *radio_comp;
   GtkWidget *radio_sign;
   GtkWidget *radio_sep;
+
   GtkWidget *check_armor;
   GtkWidget *clist_who;
 
   gboolean force_armor;
+  gboolean force_sig_mode;
 };
 
 struct _GpaFileSignDialogClass
@@ -58,12 +61,25 @@
 
 /* API */
 
-GtkWidget *gpa_file_sign_dialog_new (GtkWidget *parent, gboolean force_armor);
+GtkWidget *gpa_file_sign_dialog_new (GtkWidget *parent);
 
 GList *gpa_file_sign_dialog_signers (GpaFileSignDialog *dialog);
 
+gboolean gpa_file_sign_dialog_get_force_armor (GpaFileSignDialog *dialog);
+void gpa_file_sign_dialog_set_force_armor (GpaFileSignDialog *dialog,
+					   gboolean force_armor);
+
 gboolean gpa_file_sign_dialog_get_armor (GpaFileSignDialog *dialog);
+void gpa_file_sign_dialog_set_armor (GpaFileSignDialog *dialog,
+				     gboolean armor);
 
-gpgme_sig_mode_t gpa_file_sign_dialog_get_sign_type (GpaFileSignDialog *dialog);
+gboolean gpa_file_sign_dialog_get_force_sig_mode (GpaFileSignDialog *dialog);
+void gpa_file_sign_dialog_set_force_sig_mode (GpaFileSignDialog *dialog,
+					   gboolean force_sig_mode);
 
+gpgme_sig_mode_t gpa_file_sign_dialog_get_sig_mode (GpaFileSignDialog *dialog);
+void gpa_file_sign_dialog_set_sig_mode (GpaFileSignDialog *dialog,
+					gpgme_sig_mode_t mode);
+
+
 #endif /* FILESIGNDLG_H */

Modified: trunk/src/gpafilesignop.c
===================================================================
--- trunk/src/gpafilesignop.c	2008-05-07 15:13:01 UTC (rev 887)
+++ trunk/src/gpafilesignop.c	2008-05-08 10:34:53 UTC (rev 888)
@@ -134,8 +134,17 @@
   op = GPA_FILE_SIGN_OPERATION (object);
   /* Initialize */
   /* Create the "Sign" dialog */
-  op->sign_dialog = gpa_file_sign_dialog_new (GPA_OPERATION (op)->window,
-					      op->force_armor);
+  op->sign_dialog = gpa_file_sign_dialog_new (GPA_OPERATION (op)->window);
+  if (op->force_armor)
+    {
+      /* FIXME: Currently, force_armor means also force cleartext sig mode.  */
+      GpaFileSignDialog *dialog = GPA_FILE_SIGN_DIALOG (op->sign_dialog);
+      gpa_file_sign_dialog_set_armor (dialog, TRUE);
+      gpa_file_sign_dialog_set_force_armor (dialog, TRUE);
+      gpa_file_sign_dialog_set_sig_mode (dialog, GPGME_SIG_MODE_CLEAR);
+      gpa_file_sign_dialog_set_force_sig_mode (dialog, TRUE);
+    }
+
   g_signal_connect (G_OBJECT (op->sign_dialog), "response",
 		    G_CALLBACK (gpa_file_sign_operation_response_cb), op);
   /* Connect to the "done" signal */
@@ -478,7 +487,7 @@
 	(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
       GList *signers = gpa_file_sign_dialog_signers 
 	(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
-      op->sign_type = gpa_file_sign_dialog_get_sign_type
+      op->sign_type = gpa_file_sign_dialog_get_sig_mode
 	(GPA_FILE_SIGN_DIALOG (op->sign_dialog));
       
       /* Set the armor value */

Modified: trunk/src/gpastreamsignop.c
===================================================================
--- trunk/src/gpastreamsignop.c	2008-05-07 15:13:01 UTC (rev 887)
+++ trunk/src/gpastreamsignop.c	2008-05-08 10:34:53 UTC (rev 888)
@@ -148,8 +148,8 @@
 				      construct_properties);
   op = GPA_STREAM_SIGN_OPERATION (object);
 
-  op->sign_dialog = gpa_file_sign_dialog_new (GPA_OPERATION (op)->window,
-                                              0);
+  op->sign_dialog = gpa_file_sign_dialog_new (GPA_OPERATION (op)->window);
+  /* FIXME: MBSIGN */
   g_signal_connect (G_OBJECT (op->sign_dialog), "response",
                     G_CALLBACK (response_cb), op);
 



More information about the Gpa-commits mailing list