gimp r24710 - in branches/weskaggs: . app/core app/widgets



Author: weskaggs
Date: Fri Jan 25 18:30:27 2008
New Revision: 24710
URL: http://svn.gnome.org/viewvc/gimp?rev=24710&view=rev

Log:
Bill Skaggs  <weskaggs primate ucdavis edu>

	* app/core/gimpdatafactory.[ch]
	* app/widgets/gimpdatachooserdialog.[ch]: clean up code


Modified:
   branches/weskaggs/ChangeLog
   branches/weskaggs/app/core/gimpdatafactory.c
   branches/weskaggs/app/core/gimpdatafactory.h
   branches/weskaggs/app/widgets/gimpdatachooserdialog.c
   branches/weskaggs/app/widgets/gimpdatachooserdialog.h

Modified: branches/weskaggs/app/core/gimpdatafactory.c
==============================================================================
--- branches/weskaggs/app/core/gimpdatafactory.c	(original)
+++ branches/weskaggs/app/core/gimpdatafactory.c	Fri Jan 25 18:30:27 2008
@@ -143,10 +143,6 @@
   g_return_val_if_fail (loader_entries != NULL, NULL);
   g_return_val_if_fail (n_loader_entries > 0, NULL);
 
-  g_print ("Creating data factory\n");
-  g_print ("Path property is '%s'\n", path_property_name);
-  g_print ("Writable property is '%s'\n", writable_property_name);
-
   factory = g_object_new (GIMP_TYPE_DATA_FACTORY, NULL);
 
   factory->gimp                   = gimp;
@@ -671,6 +667,8 @@
   GHashTable          *cache   = context->cache;
   gint                 i;
 
+  context->data = NULL;
+
   if (factory->gimp->be_verbose)
     g_print ("gimp_data_factory_load_data: loading %s\n", file_data->filename);
 
@@ -693,7 +691,7 @@
     if (cache &&
         (cached_data = g_hash_table_lookup (cache, file_data->filename)))
       {
-        data = cached_data->data;
+        context->data = data = cached_data->data;
 
         load_from_disk = (data->mtime == 0 || data->mtime != file_data->mtime);
 
@@ -735,7 +733,7 @@
 
             for (list = data_list; list; list = g_list_next (list))
               {
-                data = list->data;
+                context->data = data = list->data;
 
                 gimp_data_set_filename (data, file_data->filename,
                                         writable, deletable);

Modified: branches/weskaggs/app/core/gimpdatafactory.h
==============================================================================
--- branches/weskaggs/app/core/gimpdatafactory.h	(original)
+++ branches/weskaggs/app/core/gimpdatafactory.h	Fri Jan 25 18:30:27 2008
@@ -54,6 +54,7 @@
 {
   GimpDataFactory *factory;
   GHashTable      *cache;
+  GimpData        *data;
 } GimpDataLoadContext;
 
 typedef struct _GimpDataFactoryClass  GimpDataFactoryClass;

Modified: branches/weskaggs/app/widgets/gimpdatachooserdialog.c
==============================================================================
--- branches/weskaggs/app/widgets/gimpdatachooserdialog.c	(original)
+++ branches/weskaggs/app/widgets/gimpdatachooserdialog.c	Fri Jan 25 18:30:27 2008
@@ -47,6 +47,7 @@
 #include "dialogs/dialogs.h"
 
 #include "gimpcontainereditor.h"
+#include "gimpcontainertreeview.h"
 #include "gimpdatafactoryview.h"
 #include "gimpdatachooserdialog.h"
 #include "gimpdialogfactory.h"
@@ -58,8 +59,6 @@
 
 static void        gimp_data_chooser_dialog_init          (GimpDataChooserDialog *dialog);
 
-static gchar *     gimp_data_chooser_dialog_get_filename  (GimpDataChooserDialog *dialog);
-
 static GtkWidget * gimp_data_chooser_dialog_path_view     (GimpDataChooserDialog *dialog,
                                                            GList                 *dirlist);
 
@@ -90,7 +89,6 @@
 static void
 gimp_data_chooser_dialog_init (GimpDataChooserDialog *dialog)
 {
-  dialog->filename        = NULL;
   dialog->factory_view    = NULL;
   dialog->working_factory = NULL;
 }
@@ -99,7 +97,7 @@
 
 gchar *
 gimp_data_chooser_dialog_new (GimpDataFactory *working_factory,
-                              GimpViewType      view_type)
+                              GimpViewType     view_type)
 {
   GtkWidget       *dialog;
   GtkWidget       *factory_view;
@@ -116,18 +114,16 @@
   GtkWidget       *path_view;
   GtkWidget       *hbox;
   GimpDocked      *docked;
+  GtkTreeIter      iter;
 
-  GimpContainerEditor *container_editor;
+  GimpContainerEditor   *container_editor;
+  GimpContainerTreeView *container_tree_view;
 
   g_object_get (working_factory->gimp->config,
                 working_factory->path_property_name,     &path,
                 working_factory->writable_property_name, &writable_path,
                 NULL);
 
-  g_print ("In data chooser dialog, for working factory:\n");
-  g_print ("Path is '%s'\n", path);
-  g_print ("Writable path is '%s'\n", writable_path);
-
   tmp = gimp_config_path_expand (path, TRUE, NULL);
   g_free (path);
   path = tmp;
@@ -179,15 +175,10 @@
   GIMP_DATA_CHOOSER_DIALOG (dialog)->working_factory = working_factory;
 
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                          GTK_STOCK_OPEN,   GTK_RESPONSE_OK,
+                          GTK_STOCK_CLOSE,   GTK_RESPONSE_OK,
                           NULL);
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                           GTK_RESPONSE_OK,
-                                           GTK_RESPONSE_CANCEL,
-                                           -1);
 
   gimp_help_connect (GTK_WIDGET (dialog),
                      gimp_standard_help_func, GIMP_HELP_HELP, dialog);
@@ -216,20 +207,21 @@
                            G_CALLBACK (gimp_data_chooser_dialog_select_item),
                            dialog, 0);
 
-  if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
-    filename = gimp_data_chooser_dialog_get_filename (GIMP_DATA_CHOOSER_DIALOG (dialog));
+  /* we need to select something to work around a stupid gtk bug
+   * that automatically selects the first item if a treeview gets
+   * focus with nothing selected.
+   */
+  container_tree_view = GIMP_CONTAINER_TREE_VIEW (factory_view);
+  gtk_tree_model_get_iter_first (container_tree_view->model, &iter);
+  gtk_tree_selection_select_iter (container_tree_view->selection, &iter);
+
+  gimp_dialog_run (GIMP_DIALOG (dialog));
 
   gtk_widget_destroy (dialog);
   g_object_unref (context);
   return filename;
 }
 
-static gchar *
-gimp_data_chooser_dialog_get_filename (GimpDataChooserDialog *dialog)
-{
-  return dialog->filename;
-}
-
 static GtkWidget *
 gimp_data_chooser_dialog_path_view (GimpDataChooserDialog *dialog,
                                     GList                 *dirlist)
@@ -319,6 +311,7 @@
   GimpDataFactory     *factory;
   GimpDataFactory     *working_factory;
   GimpDataFactoryView *factory_view;
+  GimpContext         *user_context;
   gchar               *filename;
   gchar               *contents;
   gsize                length;
@@ -334,10 +327,10 @@
 
   g_return_val_if_fail (GIMP_IS_DATA_CHOOSER_DIALOG (dialog), FALSE);
 
-  factory_view = dialog->factory_view;
-  factory = factory_view->factory;
-  working_factory = dialog->working_factory;
-
+  factory_view     = dialog->factory_view;
+  factory          = factory_view->factory;
+  working_factory  = dialog->working_factory;
+  user_context     = gimp_get_user_context (working_factory->gimp);
   container_editor = GIMP_CONTAINER_EDITOR (factory_view);
 
   if (! GIMP_IS_DATA (data))
@@ -360,8 +353,6 @@
                 working_factory->writable_property_name, &writable_path,
                 NULL);
 
-  g_print ("writable path before expansion is '%s'\n", writable_path);
-
   tmp = gimp_config_path_expand (writable_path, TRUE, NULL);
   g_free (writable_path);
   writable_path = tmp;
@@ -389,7 +380,6 @@
     }
 
   g_stat (new_filename, &filestat);
-  g_print ("loading new file %s\n", new_filename);
 
   file_data.filename = new_filename;
   file_data.dirname  = writable_path;
@@ -407,12 +397,12 @@
   g_free (writable_path);
   g_free (basename);
 
-/*   if (data) */
-/*     { */
-/*       gimp_context_set_by_type (context, */
-/*                                 factory->container->children_type, */
-/*                                 GIMP_OBJECT (data)); */
-/*     } */
+  if (load_context.data)
+    {
+      gimp_context_set_by_type (user_context,
+                                factory->container->children_type,
+                                GIMP_OBJECT (load_context.data));
+    }
 
   return FALSE;
 }

Modified: branches/weskaggs/app/widgets/gimpdatachooserdialog.h
==============================================================================
--- branches/weskaggs/app/widgets/gimpdatachooserdialog.h	(original)
+++ branches/weskaggs/app/widgets/gimpdatachooserdialog.h	Fri Jan 25 18:30:27 2008
@@ -40,7 +40,6 @@
 
   GimpDataFactory      *working_factory;
   GimpDataFactoryView  *factory_view;
-  gchar                *filename;
 };
 
 struct _GimpDataChooserDialogClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]