[Gpa-commits] r776 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 18 21:38:43 CEST 2007


Author: werner
Date: 2007-05-18 21:38:42 +0200 (Fri, 18 May 2007)
New Revision: 776

Modified:
   trunk/src/ChangeLog
   trunk/src/Makefile.am
   trunk/src/fileman.c
   trunk/src/fileman.h
   trunk/src/helpmenu.c
Log:
We can now drop a file into the file manager.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2007-05-02 19:05:02 UTC (rev 775)
+++ trunk/src/ChangeLog	2007-05-18 19:38:42 UTC (rev 776)
@@ -1,3 +1,17 @@
+2007-05-18  Werner Koch  <wk at g10code.com>
+
+	* fileman.h (_GpaFileManager, _GpaFileManagerClass): Move
+	definitions to ..
+	* fileman.c: .. implementation file.  Documentaion cleanups and
+	moved some functions for clarity.
+	(dnd_drop_handler, dnd_data_received_handler): New.
+	(gpa_file_manager_constructor): Connect DnD handler.
+
+2007-05-16  Werner Koch  <wk at g10code.com>
+
+	* helpmenu.c (help_about) [W32]: Point user to www.gpg4win.org.
+	(help_license): Capitalize a proper name.
+
 2007-05-02  Werner Koch  <wk at g10code.com>
 
 	* gpgmetools.c (string_to_utf8): Rewritten.

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2007-05-02 19:05:02 UTC (rev 775)
+++ trunk/src/Makefile.am	2007-05-18 19:38:42 UTC (rev 776)
@@ -21,6 +21,7 @@
 
 
 bin_PROGRAMS = gpa
+noinst_PROGRAMS = dndtest
 
 AM_CPPFLAGS = -I$(top_srcdir)/intl -I$(top_srcdir)/pixmaps
 AM_CFLAGS = $(GPGME_CFLAGS) $(GTK_CFLAGS)
@@ -92,3 +93,15 @@
 	      gpabackupop.h gpabackupop.c \
 	      gpakeyselector.h gpakeyselector.c \
 	      options.c
+
+
+dndtest_SOURCES = dndtest.c
+
+
+
+
+
+
+
+
+

Modified: trunk/src/fileman.c
===================================================================
--- trunk/src/fileman.c	2007-05-02 19:05:02 UTC (rev 775)
+++ trunk/src/fileman.c	2007-05-18 19:38:42 UTC (rev 776)
@@ -1,10 +1,11 @@
 /* fileman.c  -  The GNU Privacy Assistant
  *	Copyright (C) 2000, 2001 G-N-U GmbH.
+ *      Copyright (C) 2007 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
+ * 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.
  *
@@ -15,14 +16,15 @@
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
  */
 
 /*
  *	The file encryption/decryption/sign window
  */
 
-#include "gpa.h"
+#include "gpa.h"    /* Fixme - this does not belong here! */
 #include <config.h>
 
 #include <stdio.h>
@@ -50,26 +52,71 @@
 #include "gpafilesignop.h"
 #include "gpafileverifyop.h"
 
-static GpaFileManager *instance = NULL;
 
-typedef enum
+/* FIXME:  Move to a gloabl file.  */
+#ifndef DIM
+#define DIM(array) (sizeof (array) / sizeof (*array))
+#endif
+
+
+/* Object and class definition.  */
+struct _GpaFileManager
 {
+  GtkWindow parent;
+
+  GtkWidget *window;
+  GtkWidget *list_files;
+  GList *selection_sensitive_widgets;
+};
+
+struct _GpaFileManagerClass 
+{
+  GtkWindowClass parent_class;
+};
+
+
+
+/* There is only one instance of the file manage class.  Use a global
+   variable to keep track of it.  */
+static GpaFileManager *instance;
+
+/* We also need to save the parent class. */
+static GObjectClass *parent_class;
+
+/* Definition of the sensitivity function type.  */
+typedef gboolean (*sensitivity_func_t)(gpointer);
+
+
+/* Constants to define the file list. */
+enum
+{
   FILE_NAME_COLUMN,
   FILE_N_COLUMNS
-} FileColumn;
+};
 
 
+#define DND_TARGET_URI_LIST 0
+
+/* Drag and drop target list. */
+static GtkTargetEntry dnd_target_list[] = 
+  {
+    { "text/uri-list", 0, DND_TARGET_URI_LIST }
+  };
+
+
+
+
+/* Local prototypes */
+static GObject *gpa_file_manager_constructor 
+                         (GType type,
+                          guint n_construct_properties,
+                          GObjectConstructParam *construct_properties);
+
+
+
 /*
  * GtkWidget boilerplate.
  */
-
-static GObject*
-gpa_file_manager_constructor (GType type,
-			      guint n_construct_properties,
-			      GObjectConstructParam *construct_properties);
-
-static GObjectClass *parent_class = NULL;
-
 static void
 gpa_file_manager_finalize (GObject *object)
 {  
@@ -122,6 +169,8 @@
   return fileman_type;
 }
 
+
+
 /*
  *	File manager methods
  */
@@ -158,21 +207,22 @@
 }
 
 
-/* Add file filename to the list and select it */
+/* Add file FILENAME to the file list of FILEMAN and select it */
 static gboolean
-add_file (GpaFileManager *fileman, const gchar *filename)
+add_file (GpaFileManager *fileman, const char *filename)
 {
-  GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model
-                                        (GTK_TREE_VIEW (fileman->list_files)));
+  GtkListStore *store;
   GtkTreeIter iter;
   GtkTreePath *path;
-  GtkTreeSelection *select = gtk_tree_view_get_selection 
-    (GTK_TREE_VIEW (fileman->list_files));
+  GtkTreeSelection *select;
 
-  /* Check for repeats */
+  store = GTK_LIST_STORE (gtk_tree_view_get_model
+                          (GTK_TREE_VIEW (fileman->list_files)));
+  select = gtk_tree_view_get_selection (GTK_TREE_VIEW (fileman->list_files));
+
+  /* Check for duplicates. */
   path = gtk_tree_path_new_first ();
-  gtk_tree_model_get_iter (GTK_TREE_MODEL (store),
-			   &iter, path);
+  gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path);
   while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter))
     {
       gchar *tmp;
@@ -183,23 +233,26 @@
       exists = g_str_equal (filename, tmp);
       g_free (tmp);
       if (exists)
-	  return FALSE;
+        return FALSE; /* This file is already in our list.  */
     }
   gtk_tree_path_free (path);
 
+  /* Append it to our list.  */
   gtk_list_store_append (store, &iter);
+
   /* FIXME: Add the file status when/if gpgme supports it */
   gtk_list_store_set (store, &iter,
                       FILE_NAME_COLUMN,
 		      g_filename_to_utf8 (filename, -1, NULL, NULL, NULL),
 		      -1);
-
+  
   /* Select the row */
   gtk_tree_selection_select_iter (select, &iter);
 
   return TRUE;
 }
 
+
 /* Add a file created by an operation to the list */
 static void
 file_created_cb (GpaFileOperation *op, const gchar *filename, gpointer data)
@@ -209,6 +262,7 @@
   add_file (fileman, filename);  
 }
 
+
 /* Do whatever is required with a file operation, to ensure proper clean up */
 static void
 register_operation (GpaFileManager *fileman, GpaFileOperation *op)
@@ -219,30 +273,87 @@
 		    G_CALLBACK (g_object_unref), NULL);
 }
 
+
+
 /*
- *	Callbacks
+ * Management of the selection sensitive widgets;
  */
 
-/*
- *  File/Open
- */
+/* Return true if a selection is active.  */
+static gboolean
+has_selection (gpointer param)
+{
+  GpaFileManager *fileman = param;
+
+  GtkTreeSelection *select = gtk_tree_view_get_selection 
+    (GTK_TREE_VIEW (fileman->list_files));
+
+  return (gtk_tree_selection_count_selected_rows (select) > 0);
+}
+
+/* Add WIDGET to the list of sensitive widgets of FILEMAN.  */
 static void
+add_selection_sensitive_widget (GpaFileManager *fileman,
+                                GtkWidget *widget,
+                                sensitivity_func_t callback)
+{
+  gtk_object_set_data (GTK_OBJECT (widget), "gpa_sensitivity", callback);
+  fileman->selection_sensitive_widgets \
+    = g_list_append(fileman->selection_sensitive_widgets, widget);
+}
+
+/* Update the sensitivity of the widget DATA and pass PARAM through to
+   the sensitivity callback. Usable as an iterator function in
+   g_list_foreach. */
+static void
+update_selection_sensitive_widget (gpointer data, gpointer param)
+{
+  sensitivity_func_t func;
+
+  func = gtk_object_get_data (GTK_OBJECT (data), "gpa_sensitivity");
+  gtk_widget_set_sensitive (GTK_WIDGET (data), func (param));
+}
+
+
+/* Call update_selection_sensitive_widget for all widgets in the list
+   of sensitive widgets and pass FILEMAN through as the user data
+   parameter.  */
+static void
+update_selection_sensitive_widgets (GpaFileManager *fileman)
+{
+  g_list_foreach (fileman->selection_sensitive_widgets,
+                  update_selection_sensitive_widget,
+                  (gpointer) fileman);
+}
+
+
+
+/* 
+   Actions as called by the menu items. 
+
+*/
+
+
+/* Handle menu item "File/Open".  */
+static void
 open_file (gpointer param)
 {
   GpaFileManager * fileman = param;
   gchar * filename;
 
-  filename = gpa_get_load_file_name (GTK_WIDGET (fileman), _("Open File"), NULL);
+  filename = gpa_get_load_file_name (GTK_WIDGET (fileman),
+                                     _("Open File"), NULL);
   if (filename)
     {
 
       if (!add_file (fileman, filename))
-          gpa_window_error (_("The file is already open."),
+        gpa_window_error (_("The file is already open."),
 			    GTK_WIDGET (fileman));
       g_free (filename);
     }
 }
 
+/* Handle menu item "File/Clear".  */
 static void
 close_all_files (gpointer param)
 {
@@ -253,11 +364,8 @@
   gtk_list_store_clear (store);
 }
 
-/*
- *  Verify Signed Files
- */
 
-
+/* Handle menu item "File/Verify".  */
 static void
 verify_files (gpointer param)
 {
@@ -275,10 +383,7 @@
 }
 
 
-/*
- * Sign Files
- */
-
+/* Handle menu item "File/Sign".  */
 static void
 sign_files (gpointer param)
 {
@@ -295,10 +400,8 @@
   register_operation (fileman, GPA_FILE_OPERATION (op));
 }
 
-/*
- * Encrypt Files
- */
 
+/* Handle menu item "File/Encrypt".  */
 static void
 encrypt_files (gpointer param)
 {
@@ -315,10 +418,8 @@
   register_operation (fileman, GPA_FILE_OPERATION (op));
 }
 
-/*
- * Decrypt Files
- */
 
+/* Handle menu item "File/Decrypt".  */
 static void
 decrypt_files (gpointer param)
 {
@@ -335,6 +436,8 @@
   register_operation (fileman, GPA_FILE_OPERATION (op));
 }
 
+
+/* Handle menu item "File/Close".  */
 static void
 close_window (gpointer param)
 {
@@ -342,6 +445,8 @@
   gtk_widget_destroy (GTK_WIDGET (fileman));
 }
 
+
+/* Handle menu item "Edit/Select All".  */
 static void
 fileman_select_all (gpointer param)
 {
@@ -351,113 +456,9 @@
 				 (GTK_TREE_VIEW (fileman->list_files)));
 }
 
-/*
- * Toolbar actions.
- */
 
-static void
-toolbar_file_open (GtkWidget *widget, gpointer param)
-{
-  open_file (param);
-}
 
-static void
-toolbar_close_all (GtkWidget *widget, gpointer param)
-{
-  close_all_files (param);
-}
-
-static void
-toolbar_file_sign (GtkWidget *widget, gpointer param)
-{
-  sign_files (param);
-}
-
-static void
-toolbar_file_verify (GtkWidget *widget, gpointer param)
-{
-  verify_files (param);
-}
-
-static void
-toolbar_file_encrypt (GtkWidget *widget, gpointer param)
-{
-  encrypt_files (param);
-}
-
-static void
-toolbar_file_decrypt (GtkWidget *widget, gpointer param)
-{
-  decrypt_files (param);
-}
-
-#if 0
-static void
-toolbar_preferences (GtkWidget *widget, gpointer param)
-{
-  gpa_open_settings_dialog ();
-}
-#endif
-
-/*
- * Management of the selection sensitive widgets;
- */
-
-typedef gboolean (*SensitivityFunc)(gpointer);
-
-static
-gboolean has_selection (gpointer param)
-{
-  GpaFileManager *fileman = param;
-
-  GtkTreeSelection *select = gtk_tree_view_get_selection 
-    (GTK_TREE_VIEW (fileman->list_files));
-
-  return (gtk_tree_selection_count_selected_rows (select) > 0);
-}
-
-/* Add widget to the list of sensitive widgets of editor
- */
-
-static void
-add_selection_sensitive_widget (GpaFileManager *fileman,
-                                GtkWidget *widget,
-                                SensitivityFunc callback)
-{
-  gtk_object_set_data (GTK_OBJECT (widget), "gpa_sensitivity", callback);
-  fileman->selection_sensitive_widgets \
-    = g_list_append(fileman->selection_sensitive_widgets, widget);
-}
-
-/* Update the sensitivity of the widget data and pass param through to
- * the sensitivity callback. Usable as iterator function in
- * g_list_foreach */
-static void
-update_selection_sensitive_widget (gpointer data, gpointer param)
-{
-  SensitivityFunc func;
-
-  func = gtk_object_get_data (GTK_OBJECT (data), "gpa_sensitivity");
-  gtk_widget_set_sensitive (GTK_WIDGET (data), func (param));
-}
-
-
-/* Call update_selection_sensitive_widget for all widgets in the list of
- * sensitive widgets and pass editor through as the user data parameter
- */
-static void
-update_selection_sensitive_widgets (GpaFileManager *fileman)
-{
-  g_list_foreach (fileman->selection_sensitive_widgets,
-                  update_selection_sensitive_widget,
-                  (gpointer) fileman);
-}
-
-
-/*
- *	Construct the file manager window
- */
-
+/* Construct the file manager menu window and return that object. */
 static GtkWidget *
 fileman_menu_new (GpaFileManager *fileman)
 {
@@ -502,41 +503,85 @@
 				 sizeof(windows_menu) /sizeof(windows_menu[0]),
 				 windows_menu, fileman);
 
-  /* Disable buttons when no file is selected */
+  /* Disable buttons when no file is selected.   */
   item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
                                       _("/File/Sign"));
   if (item)
-    {
-      add_selection_sensitive_widget (fileman, item, has_selection);
-    }
+    add_selection_sensitive_widget (fileman, item, has_selection);
 
   item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
                                       _("/File/Verify"));
   if (item)
-    {
-      add_selection_sensitive_widget (fileman, item, has_selection);
-    }
+    add_selection_sensitive_widget (fileman, item, has_selection);
 
   item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
                                       _("/File/Encrypt"));
   if (item)
-    {
-      add_selection_sensitive_widget (fileman, item, has_selection);
-    }
+    add_selection_sensitive_widget (fileman, item, has_selection);
 
   item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
                                       _("/File/Decrypt"));
   if (item)
-    {
-      add_selection_sensitive_widget (fileman, item, has_selection);
-    }
+    add_selection_sensitive_widget (fileman, item, has_selection);
 
-
   gpa_help_menu_add_to_factory (factory, GTK_WIDGET (fileman));
   gtk_window_add_accel_group (GTK_WINDOW (fileman), accel_group);
+
   return gtk_item_factory_get_widget (factory, "<main>");
 }
 
+
+
+/*
+ * Toolbar actions.
+ */
+
+static void
+toolbar_file_open (GtkWidget *widget, gpointer param)
+{
+  open_file (param);
+}
+
+static void
+toolbar_close_all (GtkWidget *widget, gpointer param)
+{
+  close_all_files (param);
+}
+
+static void
+toolbar_file_sign (GtkWidget *widget, gpointer param)
+{
+  sign_files (param);
+}
+
+static void
+toolbar_file_verify (GtkWidget *widget, gpointer param)
+{
+  verify_files (param);
+}
+
+static void
+toolbar_file_encrypt (GtkWidget *widget, gpointer param)
+{
+  encrypt_files (param);
+}
+
+static void
+toolbar_file_decrypt (GtkWidget *widget, gpointer param)
+{
+  decrypt_files (param);
+}
+
+#if 0
+static void
+toolbar_preferences (GtkWidget *widget, gpointer param)
+{
+  gpa_open_settings_dialog ();
+}
+#endif
+
+/* Construct the new toolbar object and return it.  Takes the file
+   manage object.  */
 static GtkWidget *
 fileman_toolbar_new (GpaFileManager *fileman)
 {
@@ -544,7 +589,7 @@
 
   toolbar = gtk_toolbar_new ();
   
-  /* Open */
+  /* Build the "Open" button.  */
   gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar), GTK_STOCK_OPEN,
                             _("Open a file"), _("open file"),
                             GTK_SIGNAL_FUNC (toolbar_file_open),
@@ -553,43 +598,47 @@
                             _("Close all files"), _("close files"),
                             GTK_SIGNAL_FUNC (toolbar_close_all),
                             fileman, -1);
-  /* Sign */
+  /* Build the "Sign" button.  */
   if ((icon = gpa_create_icon_widget (GTK_WIDGET (fileman), "sign")))
     {
       item = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Sign"),
-				      _("Sign the selected file"), _("sign file"),
+				      _("Sign the selected file"),
+                                      _("sign file"),
 				      icon,
 				      GTK_SIGNAL_FUNC (toolbar_file_sign),
 				      fileman);
       add_selection_sensitive_widget (fileman, item, has_selection);
     }
-  /* Verify */
+  /* Build the "Verify" button.  */
   if ((icon = gpa_create_icon_widget (GTK_WIDGET (fileman), "verify")))
     {
       item = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Verify"),
 				      _("Check signatures of selected file"), 
-				      _("verify file"), icon,
+				      _("verify file"),
+                                      icon,
 				      GTK_SIGNAL_FUNC (toolbar_file_verify), 
 				      fileman);
       add_selection_sensitive_widget (fileman, item, has_selection);
     }
-  /* Encrypt */
+  /* Build the "Encrypt" button.  */
   if ((icon = gpa_create_icon_widget (GTK_WIDGET (fileman), "encrypt")))
     {
       item = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Encrypt"),
 				      _("Encrypt the selected file"),
 				      _("encrypt file"),
-				      icon, GTK_SIGNAL_FUNC (toolbar_file_encrypt),
+				      icon,
+                                      GTK_SIGNAL_FUNC (toolbar_file_encrypt),
 				      fileman);
       add_selection_sensitive_widget (fileman, item, has_selection);
     }
-  /* Decrypt */
+  /* Build the "Decrypt" button.  */
   if ((icon = gpa_create_icon_widget (GTK_WIDGET (fileman), "decrypt")))
     {
       item = gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), _("Decrypt"),
 				      _("Decrypt the selected file"),
 				      _("decrypt file"),
-				      icon, GTK_SIGNAL_FUNC (toolbar_file_decrypt),
+				      icon, 
+                                      GTK_SIGNAL_FUNC (toolbar_file_decrypt),
 				      fileman);
       add_selection_sensitive_widget (fileman, item, has_selection);
     }
@@ -620,6 +669,87 @@
   return toolbar;
 }
 
+
+
+/* 
+     Drag and Drop handler
+ */
+
+
+/* Handler for "drag-drop".  This signal is emitted when the user
+   drops the selection.  */
+static gboolean
+dnd_drop_handler (GtkWidget *widget, GdkDragContext *context, 
+                  gint x, gint y, guint time, gpointer user_data)
+{
+  GdkAtom  target_type;
+        
+  /* If the source offers a target we request the data from her. */
+  if (context->targets)
+    {
+      target_type = GDK_POINTER_TO_ATOM 
+        (g_list_nth_data (context->targets, DND_TARGET_URI_LIST));
+      gtk_drag_get_data (widget, context, target_type, time);
+      
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+
+/* Handler for "drag-data-received".  This signal is emitted when the
+   data has been received from the source.  */
+static void
+dnd_data_received_handler (GtkWidget *widget, GdkDragContext *context,
+                           gint x, gint y, GtkSelectionData *selection_data,
+                           guint target_type, guint time, gpointer user_data)
+{       
+  GpaFileManager *fileman = user_data;
+  gboolean dnd_success = FALSE;
+  gboolean delete_selection_data = FALSE;
+        
+  /* Is that usable by us?  */
+  if (selection_data && selection_data->length >= 0 )
+    {
+      if (context->action == GDK_ACTION_MOVE)
+        delete_selection_data = TRUE;
+      
+      /* Check that we got a format we can use.  */
+      if (target_type == DND_TARGET_URI_LIST)
+        {
+          char *p = selection_data->data;
+          char **list;
+          int i;
+
+          list = g_uri_list_extract_uris (p);
+          for (i=0; list && list[i]; i++)
+            {
+              char *name = g_filename_from_uri (list[i], NULL, NULL);
+              if (name)
+                {
+                  /* Canonical line endings are required for an uri-list. */
+                  if ((p = strchr (name, '\r')))
+                    *p = 0;
+                  add_file (fileman, name);
+                  g_free (name);
+                }
+            }
+          g_strfreev (list);
+          dnd_success = TRUE;
+        }
+    }
+
+  /* Finish the DnD processing.  */
+  gtk_drag_finish (context, dnd_success, delete_selection_data, time);
+}
+
+
+
+
+
+
+/* Construct the file list object.  */
 static GtkWidget *
 file_list_new (GpaFileManager * fileman)
 {
@@ -655,15 +785,18 @@
   gtk_container_add (GTK_CONTAINER (scrollerFile), list);
 
   return scrollerFile;
-} /* gpa_window_file_new */
+} 
 
 
+/* Callback for the destroy signal.  */
 static void
 file_manager_closed (GtkWidget *widget, gpointer param)
 {
   instance = NULL;
 }
 
+
+/* Construct a new class object of GpaFileManager.  */
 static GObject*
 gpa_file_manager_constructor (GType type,
 			      guint n_construct_properties,
@@ -673,43 +806,63 @@
   GpaFileManager *fileman;
   GtkWidget *vbox;
   GtkWidget *menubar;
-  GtkWidget *fileBox;
+  GtkWidget *file_box;
   GtkWidget *file_frame;
   GtkWidget *toolbar;
 
-  /* Invoke parent's constructor */
+  /* Invoke parent's constructor.  */
   object = parent_class->constructor (type,
 				      n_construct_properties,
 				      construct_properties);
   fileman = GPA_FILE_MANAGER (object);
-  /* Initialize */
+
+  /* Initialize.  */
   gtk_window_set_title (GTK_WINDOW (fileman),
 			_("GNU Privacy Assistant - File Manager"));
   gtk_widget_set_usize (GTK_WIDGET (fileman), 640, 480);
-  /* Realize the window so that we can create pixmaps without warnings */
+  /* Realize the window so that we can create pixmaps without warnings.  */
   gtk_widget_realize (GTK_WIDGET (fileman));
 
+  /* Use a vbox to show the menu, toolbar and the file container.  */
   vbox = gtk_vbox_new (FALSE, 0);
+
+  /* First comes the menu.  */
   menubar = fileman_menu_new (fileman);
   gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0);
 
-  /* set up the toolbar */
+  /* Second the toolbar.  */
   toolbar = fileman_toolbar_new(fileman);
   gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0);
-  
-  fileBox = gtk_hbox_new (TRUE, 0);
-  gtk_container_set_border_width (GTK_CONTAINER (fileBox), 5);
+
+  /* Third a hbox with the file list.  */
+  file_box = gtk_hbox_new (TRUE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (file_box), 5);
   file_frame = file_list_new (fileman);
-  gtk_box_pack_start (GTK_BOX (fileBox), file_frame, TRUE, TRUE, 0);
-  gtk_box_pack_end (GTK_BOX (vbox), fileBox, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (file_box), file_frame, TRUE, TRUE, 0);
+  gtk_box_pack_end (GTK_BOX (vbox), file_box, TRUE, TRUE, 0);
   gtk_container_add (GTK_CONTAINER (fileman), vbox);
 
-  g_signal_connect (object, "destroy", G_CALLBACK (file_manager_closed),
-		    object);
+  g_signal_connect (object, "destroy",
+                    G_CALLBACK (file_manager_closed), object);
 
+
+  /* Make the file box a DnD destination. */
+  gtk_drag_dest_set (file_box,
+                     (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT),
+                     dnd_target_list,
+                     DIM (dnd_target_list),
+                     GDK_ACTION_COPY);
+  g_signal_connect (file_box, "drag-drop",
+                    G_CALLBACK (dnd_drop_handler), fileman);
+  g_signal_connect (file_box, "drag-data-received", 
+                    G_CALLBACK (dnd_data_received_handler), fileman);
+
+
   return object;
 }
 
+
+
 static GpaFileManager *
 gpa_fileman_new ()
 {
@@ -723,7 +876,8 @@
 
 /* API */
 
-GtkWidget * gpa_file_manager_get_instance (void)
+GtkWidget *
+gpa_file_manager_get_instance (void)
 {
   if (!instance)
     {

Modified: trunk/src/fileman.h
===================================================================
--- trunk/src/fileman.h	2007-05-02 19:05:02 UTC (rev 775)
+++ trunk/src/fileman.h	2007-05-18 19:38:42 UTC (rev 776)
@@ -1,5 +1,6 @@
 /* fileman.h  -  The GNU Privacy Assistant
  *	Copyright (C) 2000 G-N-U GmbH.
+ *      Copyright (C) 2007 g10 Code GmbH
  *
  * This file is part of GPA
  *
@@ -15,7 +16,8 @@
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
  */
 
 #ifndef FILEMAN_H
@@ -23,39 +25,41 @@
 
 #include <gtk/gtk.h>
 
-/* GObject stuff */
-#define GPA_FILE_MANAGER_TYPE	  (gpa_file_manager_get_type ())
-#define GPA_FILE_MANAGER(obj)	  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_FILE_MANAGER_TYPE, GpaFileManager))
-#define GPA_FILE_MANAGER_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), GPA_FILE_MANAGER_TYPE, GpaFileManagerClass))
-#define GPA_IS_FILE_MANAGER(obj)	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_FILE_MANAGER_TYPE))
-#define GPA_IS_FILE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_FILE_MANAGER_TYPE))
-#define GPA_FILE_MANAGER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GPA_FILE_MANAGER_TYPE, GpaFileManagerClass))
-
+/* Declare the Object. */
 typedef struct _GpaFileManager GpaFileManager;
 typedef struct _GpaFileManagerClass GpaFileManagerClass;
 
-struct _GpaFileManager {
-  GtkWindow parent;
+GType gpa_file_manager_get_type (void) G_GNUC_CONST;
 
-  GtkWidget *window;
-  GtkWidget *list_files;
-  GList *selection_sensitive_widgets;
-};
+#define GPA_FILE_MANAGER_TYPE	  (gpa_file_manager_get_type ())
 
-struct _GpaFileManagerClass {
-  GtkWindowClass parent_class;
-};
+#define GPA_FILE_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPA_FILE_MANAGER_TYPE, GpaFileManager))
 
-GType gpa_file_manager_get_type (void) G_GNUC_CONST;
+#define GPA_FILE_MANAGER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass),  \
+                            GPA_FILE_MANAGER_TYPE, GpaFileManagerClass))
 
-/* API */
+#define GPA_IS_FILE_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPA_FILE_MANAGER_TYPE))
 
-GtkWidget * gpa_file_manager_get_instance (void);
+#define GPA_IS_FILE_MANAGER_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), GPA_FILE_MANAGER_TYPE))
 
+#define GPA_FILE_MANAGER_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj),    \
+                              GPA_FILE_MANAGER_TYPE, GpaFileManagerClass))
+
+
+
+/*  Our own API.  */
+
+GtkWidget *gpa_file_manager_get_instance (void);
+
 gboolean gpa_file_manager_is_open (void);
 
 void gpa_file_manager_open_file (GpaFileManager *fileman,
-				 const gchar *filename);
+				 const char *filename);
 
 
-#endif /* FILEMAN_H */
+#endif /*FILEMAN_H*/

Modified: trunk/src/helpmenu.c
===================================================================
--- trunk/src/helpmenu.c	2007-05-02 19:05:02 UTC (rev 775)
+++ trunk/src/helpmenu.c	2007-05-18 19:38:42 UTC (rev 776)
@@ -277,7 +277,7 @@
       gtk_widget_show (scroll_area);
 #endif
 
-      label = gtk_label_new (_("GPA is free software under the"));
+      label = gtk_label_new (_("GPA is Free Software under the"));
       gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
       gtk_widget_show (label);
 
@@ -289,7 +289,11 @@
       gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
       gtk_widget_show (label);
 
+#ifdef HAVE_W32_SYSTEM
+      label = gtk_label_new (_("http://www.gpg4win.org"));
+#else
       label = gtk_label_new (_("http://www.gnupg.org"));
+#endif
       gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
       gtk_widget_show (label);
 
@@ -371,7 +375,7 @@
   windowLicense = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gpa_windowKeeper_set_window (keeper, windowLicense);
   gtk_window_set_title (GTK_WINDOW (windowLicense),
-			_("GNU general public license"));
+			_("GNU General Public License"));
   accelGroup = gtk_accel_group_new ();
   gtk_window_add_accel_group (GTK_WINDOW (windowLicense), accelGroup);
   gtk_signal_connect (GTK_OBJECT (windowLicense), "destroy",
@@ -398,7 +402,7 @@
   gtk_adjustment_set_value (gtk_scrolled_window_get_vadjustment
 			    (GTK_SCROLLED_WINDOW (licenseScrolled)), 0.0);
   gpa_connect_by_accelerator (GTK_LABEL (labelGPL), textGPL, accelGroup,
-			      _("_GNU general public license"));
+			      _("_GNU General Public License"));
   gtk_box_pack_start (GTK_BOX (hboxGPL), licenseScrolled, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (vboxGPL), hboxGPL, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (vboxLicense), vboxGPL, TRUE, TRUE, 0);



More information about the Gpa-commits mailing list