[Gpa-commits] r853 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 19 00:12:24 CET 2008


Author: marcus
Date: 2008-03-19 00:12:21 +0100 (Wed, 19 Mar 2008)
New Revision: 853

Modified:
   trunk/src/ChangeLog
   trunk/src/clipboard.c
   trunk/src/gtktools.c
Log:
2008-03-19  Marcus Brinkmann  <marcus at g10code.de>

	* clipboard.c (gpa_clipboard_constructor): Create text_frame
	early.
	(gpa_clipboard_constructor): Don't pack ALIGN twice.
	(has_selection): Remove superfluous cast.
	* gtktools.c (struct _GPASaveFileNameDialog): Removed.
	(GPASaveFileNameDialog): Removed.
	(file_dialog_ok, file_dialog_cancel, file_dialog_destroy):
	Removed.
	(gpa_get_save_file_name, gpa_get_load_file_name): Reimplemented.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-03-18 21:42:25 UTC (rev 852)
+++ trunk/src/ChangeLog	2008-03-18 23:12:21 UTC (rev 853)
@@ -1,3 +1,15 @@
+2008-03-19  Marcus Brinkmann  <marcus at g10code.de>
+
+	* clipboard.c (gpa_clipboard_constructor): Create text_frame
+	early.
+	(gpa_clipboard_constructor): Don't pack ALIGN twice.
+	(has_selection): Remove superfluous cast.
+	* gtktools.c (struct _GPASaveFileNameDialog): Removed.
+	(GPASaveFileNameDialog): Removed.
+	(file_dialog_ok, file_dialog_cancel, file_dialog_destroy):
+	Removed.
+	(gpa_get_save_file_name, gpa_get_load_file_name): Reimplemented.
+
 2008-03-18  Marcus Brinkmann  <marcus at g10code.de>
 
 	* gpgmetools.h (gpa_open_output_direct): New prototype.

Modified: trunk/src/clipboard.c
===================================================================
--- trunk/src/clipboard.c	2008-03-18 21:42:25 UTC (rev 852)
+++ trunk/src/clipboard.c	2008-03-18 23:12:21 UTC (rev 853)
@@ -1,31 +1,26 @@
 /* clipboard.c  -  The GNU Privacy Assistant
- * Copyright (C) 2000, 2001 G-N-U GmbH.
- * Copyright (C) 2007, 2008 g10 Code GmbH
- *
- * This file is part of GPA
- *
- * GPA is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GPA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
+   Copyright (C) 2000, 2001 G-N-U GmbH.
+   Copyright (C) 2007, 2008 g10 Code GmbH
 
-/*
- *	The file encryption/decryption/sign window
- */
+   This file is part of GPA
 
-#include <config.h>
+   GPA is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
+   GPA is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -109,9 +104,7 @@
                           GObjectConstructParam *construct_properties);
 
 
-/*
- * GtkWidget boilerplate.
- */
+/* GtkWidget boilerplate.  */
 static void
 gpa_clipboard_finalize (GObject *object)
 {  
@@ -189,8 +182,7 @@
 {
   GpaClipboard *clipboard = param;
 
-  return gtk_text_buffer_get_has_selection
-    (GTK_TEXT_BUFFER (clipboard->text_buffer));
+  return gtk_text_buffer_get_has_selection (clipboard->text_buffer);
 }
 
 
@@ -1000,6 +992,7 @@
 
   clipboard->text_buffer
     = gtk_text_view_get_buffer (GTK_TEXT_VIEW (clipboard->text_view));
+  g_print ("text buffer: %p\n", clipboard->text_buffer);
 
 #ifndef MY_GTK_TEXT_BUFFER_NO_HAS_SELECTION
   /* A change in selection status causes a property change, which we
@@ -1068,6 +1061,11 @@
   /* Use a vbox to show the menu, toolbar and the text container.  */
   vbox = gtk_vbox_new (FALSE, 0);
 
+  /* We need to create the text_buffer before we create the menus and
+     the toolbar, because of widget sensitivity issues, which depend
+     on the selection status of the text_buffer.  */
+  text_frame = clipboard_text_new (clipboard);
+
   /* First comes the menu.  */
   menubar = clipboard_menu_new (clipboard);
   gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
@@ -1103,10 +1101,8 @@
 			     pl + 5, pr + 5);
   gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
 
-  text_frame = clipboard_text_new (clipboard);
   gtk_box_pack_start (GTK_BOX (text_box), text_frame, TRUE, TRUE, 0);
   gtk_container_add (GTK_CONTAINER (align), text_box);
-  gtk_box_pack_end (GTK_BOX (vbox), align, TRUE, TRUE, 0);
 
   gtk_container_add (GTK_CONTAINER (clipboard), vbox);
 

Modified: trunk/src/gtktools.c
===================================================================
--- trunk/src/gtktools.c	2008-03-18 21:42:25 UTC (rev 852)
+++ trunk/src/gtktools.c	2008-03-18 23:12:21 UTC (rev 853)
@@ -376,83 +376,62 @@
 }				/* gpa_window_message */
 
 
-/*
- * Modal file dialog
- */
-
-struct _GPASaveFileNameDialog {
-  GtkWidget * window;
-  gchar * filename;
-};
-typedef struct _GPASaveFileNameDialog GPASaveFileNameDialog;
-
-static void
-file_dialog_ok (gpointer param)
+/* Run the modal file selection dialog and return a new copy of the
+  filename if the user pressed OK and NULL otherwise.  */
+gchar *
+gpa_get_save_file_name (GtkWidget *parent, const gchar *title,
+			const gchar *directory)
 {
-  GPASaveFileNameDialog *dialog = param;
+  GtkWidget *dialog;
+  GtkResponseType response;
+  gchar *filename = NULL;
 
-  dialog->filename 
-      = (gchar *) gtk_file_selection_get_filename (GTK_FILE_SELECTION (dialog->window));
-  if( dialog->filename != NULL )
-	  dialog->filename = g_strdup (dialog->filename);
+  dialog = gtk_file_chooser_dialog_new
+    (title, parent, GTK_FILE_CHOOSER_ACTION_SAVE,
+     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+     GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
+  
+  /* Run the dialog until there is a valid response.  */
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+  if (response == GTK_RESPONSE_OK)
+    {
+      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+      if (filename)
+	filename = g_strdup (filename);
+    }
 
-  gtk_widget_destroy (dialog->window);
+  gtk_widget_destroy (dialog);
+  return filename;
 }
 
-static void
-file_dialog_cancel (gpointer param)
-{
-  GPASaveFileNameDialog * dialog = param;
-  dialog->filename = NULL;
-  gtk_widget_destroy (dialog->window);
-}
 
-static void
-file_dialog_destroy (GtkWidget * widget, gpointer param)
-{
-  gtk_main_quit ();
-}
-
-/* Run the modal file selection dialog and return a new copy of the
- * filename if the user pressed OK and NULL otherwise
- */
 gchar *
-gpa_get_save_file_name (GtkWidget * parent, const gchar * title,
-			const gchar * directory)
+gpa_get_load_file_name (GtkWidget *parent, const gchar *title,
+			const gchar *directory)
 {
-  GPASaveFileNameDialog dialog;
-  GtkWidget * window = gtk_file_selection_new (title);
+  GtkWidget *dialog;
+  GtkResponseType response;
+  gchar *filename = NULL;
 
-  dialog.window = window;
-  dialog.filename = NULL;
+  dialog = gtk_file_chooser_dialog_new
+    (title, parent, 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.  */
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+  if (response == GTK_RESPONSE_OK)
+    {
+      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+      if (filename)
+	filename = g_strdup (filename);
+    }
 
-  gtk_signal_connect (GTK_OBJECT (window), "destroy",
-		      GTK_SIGNAL_FUNC (file_dialog_destroy), NULL);
-
-  gtk_signal_connect_object (GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button),
-			     "clicked", GTK_SIGNAL_FUNC (file_dialog_ok),
-			     (gpointer) &dialog);
-  gtk_signal_connect_object (
-		      GTK_OBJECT (GTK_FILE_SELECTION (window)->cancel_button),
-		      "clicked", GTK_SIGNAL_FUNC (file_dialog_cancel),
-		      (gpointer) &dialog);
-
-  gtk_window_set_modal (GTK_WINDOW (window), TRUE);
-  gpa_window_show_centered (window, parent);
-
-  gtk_main ();
-
-  return dialog.filename;
+  gtk_widget_destroy (dialog);
+  return filename;
 }
 
-gchar *
-gpa_get_load_file_name (GtkWidget * parent, const gchar * title,
-			const gchar * directory)
-{
-  return gpa_get_save_file_name (parent, title, directory);
-}
 
-
 /* END of old unchecked code (wk 2008-03-07) */
 
 



More information about the Gpa-commits mailing list