gimp r26002 - in branches/soc-2008-tagging: . app/widgets



Author: aurisj
Date: Sat Jun 28 12:26:06 2008
New Revision: 26002
URL: http://svn.gnome.org/viewvc/gimp?rev=26002&view=rev

Log:
2008-06-28  Aurimas JuÅka  <aurisj svn gnome org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimptagentry.[ch]: added GimpTagEntry widget.

	* app/widgets/gimpdatafactoryview.c: use GimpTagEntry instead of GtkEntry.



Added:
   branches/soc-2008-tagging/app/widgets/gimptagentry.c
   branches/soc-2008-tagging/app/widgets/gimptagentry.h
Modified:
   branches/soc-2008-tagging/ChangeLog
   branches/soc-2008-tagging/app/widgets/Makefile.am
   branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c
   branches/soc-2008-tagging/app/widgets/widgets-types.h

Modified: branches/soc-2008-tagging/app/widgets/Makefile.am
==============================================================================
--- branches/soc-2008-tagging/app/widgets/Makefile.am	(original)
+++ branches/soc-2008-tagging/app/widgets/Makefile.am	Sat Jun 28 12:26:06 2008
@@ -263,6 +263,8 @@
 	gimpstringaction.h		\
 	gimpstrokeeditor.c		\
 	gimpstrokeeditor.h		\
+	gimptagentry.c			\
+	gimptagentry.h			\
 	gimptemplateeditor.c		\
 	gimptemplateeditor.h		\
 	gimptemplateview.c		\

Modified: branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c	(original)
+++ branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c	Sat Jun 28 12:26:06 2008
@@ -44,6 +44,7 @@
 #include "gimpcontainergridview.h"
 #include "gimpcontainertreeview.h"
 #include "gimpdnd.h"
+#include "gimptagentry.h"
 #include "gimpviewrenderer.h"
 #include "gimpuimanager.h"
 #include "gimpwidgets-utils.h"
@@ -57,9 +58,6 @@
                                                      const gchar         *path,
                                                      const gchar         *name,
                                                      GimpDataFactoryView *view);
-static void   gimp_data_factory_view_query_tag      (GtkEntry            *entry,
-                                                     GimpDataFactoryView *factory_view);
-
 
 G_DEFINE_TYPE (GimpDataFactoryView, gimp_data_factory_view,
                GIMP_TYPE_CONTAINER_EDITOR)
@@ -136,7 +134,6 @@
 {
   GimpContainerEditor *editor;
   gchar               *str;
-  GtkWidget           *tag_query_box;
   GtkWidget           *tag_query_entry;
 
   g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE);
@@ -224,24 +221,17 @@
 
   gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor);
 
-  tag_query_box = gtk_hbox_new (FALSE, 0);
-  gtk_widget_show (tag_query_box);
-
-  tag_query_entry = gtk_entry_new ();
-  gtk_box_pack_end (GTK_BOX (tag_query_box), tag_query_entry,
-                    TRUE, TRUE, 0);
-  g_signal_connect (tag_query_entry, "activate",
-                    G_CALLBACK (gimp_data_factory_view_query_tag),
-                    factory_view);
+  tag_query_entry = gimp_tag_entry_new (GIMP_FILTERED_CONTAINER (factory_view->filtered_container),
+                                        GIMP_TAG_ENTRY_MODE_QUERY);
   gtk_widget_show (tag_query_entry);
 
   editor = GIMP_CONTAINER_EDITOR (factory_view);
 
   gtk_box_pack_start (GTK_BOX (editor->view),
-                      tag_query_box,
+                      tag_query_entry,
                       FALSE, FALSE, 0);
   gtk_box_reorder_child (GTK_BOX (editor->view),
-                         tag_query_box, 0);
+                         tag_query_entry, 0);
 
 
   return TRUE;
@@ -317,23 +307,4 @@
   gtk_tree_path_free (path);
 }
 
-static void
-gimp_data_factory_view_query_tag (GtkEntry                     *entry,
-                                  GimpDataFactoryView          *factory_view)
-{
-  GimpContainerEditor          *editor;
-  GQuark                        tag;
-  GList                        *tag_list = NULL;
-
-  editor = GIMP_CONTAINER_EDITOR (factory_view);
-
-  if (strlen (gtk_entry_get_text (entry)) > 0)
-    {
-      tag = g_quark_from_string (gtk_entry_get_text (entry));
-      tag_list = g_list_append (tag_list, GUINT_TO_POINTER (tag));
-    }
-
-  gimp_filtered_container_set_filter (GIMP_FILTERED_CONTAINER (factory_view->filtered_container),
-                                      tag_list);
-}
 

Added: branches/soc-2008-tagging/app/widgets/gimptagentry.c
==============================================================================
--- (empty file)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.c	Sat Jun 28 12:26:06 2008
@@ -0,0 +1,142 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimptagentry.c
+ * Copyright (C) 2008 Aurimas JuÅka <aurisj svn gnome org>
+ *
+ * This program 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.
+ *
+ * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "widgets-types.h"
+
+#include "core/gimpcontainer.h"
+#include "core/gimpfilteredcontainer.h"
+#include "core/gimpcontext.h"
+#include "core/gimpviewable.h"
+
+#include "gimptagentry.h"
+
+
+static void     gimp_tag_entry_changed         (GtkEntry          *entry,
+                                                GimpTagEntry      *view);
+
+static void     gimp_tag_entry_query_tag       (GtkEntry             *entry);
+
+G_DEFINE_TYPE (GimpTagEntry, gimp_tag_entry, GTK_TYPE_ENTRY);
+
+#define parent_class gimp_tag_entry_parent_class
+
+
+static void
+gimp_tag_entry_class_init (GimpTagEntryClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+}
+
+static void
+gimp_tag_entry_init (GimpTagEntry *entry)
+{
+/*  completion = g_object_new (GTK_TYPE_ENTRY_COMPLETION,
+                             "inline-completion",  TRUE,
+                             "popup-single-match", FALSE,
+                             "popup-set-width",    FALSE,
+                             NULL);
+
+  store = gtk_list_store_new (GIMP_TAG_ENTRY_NUM_COLUMNS,
+                              GIMP_TYPE_VIEW_RENDERER,
+                              G_TYPE_STRING);
+
+  gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
+  g_object_unref (store);
+
+  gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+
+  g_signal_connect (completion, "match-selected",
+                    G_CALLBACK (gimp_tag_entry_match_selected),
+                    entry);
+
+  g_object_unref (completion); */
+
+  g_signal_connect (entry, "changed",
+                    G_CALLBACK (gimp_tag_entry_changed),
+                    entry);
+}
+
+GtkWidget *
+gimp_tag_entry_new (GimpFilteredContainer      *tagged_container,
+                    GimpTagEntryMode            mode)
+{
+  GimpTagEntry         *entry;
+
+  g_return_val_if_fail (tagged_container == NULL
+                        || GIMP_IS_FILTERED_CONTAINER (tagged_container),
+                        NULL);
+
+  entry = g_object_new (GIMP_TYPE_TAG_ENTRY, NULL);
+  entry->tagged_container = tagged_container;
+  entry->mode             = mode;
+
+  return GTK_WIDGET (entry);
+}
+
+static void
+gimp_tag_entry_changed (GtkEntry          *entry,
+                        GimpTagEntry      *view)
+{
+  GimpTagEntry         *tag_entry;
+
+  tag_entry = GIMP_TAG_ENTRY (entry);
+
+  switch (tag_entry->mode)
+    {
+      case GIMP_TAG_ENTRY_MODE_QUERY:
+          gimp_tag_entry_query_tag (entry);
+          break;
+    }
+}
+
+static void
+gimp_tag_entry_match_selected (GtkEntryCompletion *widget,
+                               GtkTreeModel       *model,
+                               GtkTreeIter        *iter,
+                               GimpTagEntry       *view)
+{
+}
+
+static void
+gimp_tag_entry_query_tag (GtkEntry             *entry)
+{
+  GimpTagEntry                 *tag_entry;
+  GQuark                        tag;
+  GList                        *tag_list = NULL;
+
+  tag_entry = GIMP_TAG_ENTRY (entry);
+
+  if (strlen (gtk_entry_get_text (entry)) > 0)
+    {
+      tag = g_quark_from_string (gtk_entry_get_text (entry));
+      tag_list = g_list_append (tag_list, GUINT_TO_POINTER (tag));
+    }
+
+  gimp_filtered_container_set_filter (GIMP_FILTERED_CONTAINER (tag_entry->tagged_container),
+                                      tag_list);
+}
+

Added: branches/soc-2008-tagging/app/widgets/gimptagentry.h
==============================================================================
--- (empty file)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.h	Sat Jun 28 12:26:06 2008
@@ -0,0 +1,62 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimptagentry.h
+ * Copyright (C) 2008 Aurimas JuÅka <aurisj svn gnome org>
+ *
+ * This program 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.
+ *
+ * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_TAG_ENTRY_H__
+#define __GIMP_TAG_ENTRY_H__
+
+
+#define GIMP_TYPE_TAG_ENTRY            (gimp_tag_entry_get_type ())
+#define GIMP_TAG_ENTRY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TAG_ENTRY, GimpTagEntry))
+#define GIMP_TAG_ENTRY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TAG_ENTRY, GimpTagEntryClass))
+#define GIMP_IS_TAG_ENTRY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTAINER_ENTRY))
+#define GIMP_IS_TAG_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_ENTRY))
+#define GIMP_TAG_ENTRY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TAG_ENTRY, GimpTagEntryClass))
+
+
+typedef enum
+{
+  GIMP_TAG_ENTRY_MODE_QUERY,
+  GIMP_TAG_ENTRY_MODE_ENTER,
+} GimpTagEntryMode;
+
+typedef struct _GimpTagEntryClass  GimpTagEntryClass;
+
+struct _GimpTagEntry
+{
+  GtkEntry                      parent_instance;
+
+  GimpFilteredContainer        *tagged_container;
+  GimpTagEntryMode              mode;
+};
+
+struct _GimpTagEntryClass
+{
+  GtkEntryClass   parent_class;
+};
+
+
+GType       gimp_tag_entry_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_tag_entry_new      (GimpFilteredContainer     *tagged_container,
+                                     GimpTagEntryMode           mode);
+
+
+#endif  /*  __GIMP_TAG_ENTRY_H__  */

Modified: branches/soc-2008-tagging/app/widgets/widgets-types.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/widgets-types.h	(original)
+++ branches/soc-2008-tagging/app/widgets/widgets-types.h	Sat Jun 28 12:26:06 2008
@@ -178,6 +178,7 @@
 typedef struct _GimpSettingsBox              GimpSettingsBox;
 typedef struct _GimpSizeBox                  GimpSizeBox;
 typedef struct _GimpStrokeEditor             GimpStrokeEditor;
+typedef struct _GimpTagEntry                 GimpTagEntry;
 typedef struct _GimpTemplateEditor           GimpTemplateEditor;
 typedef struct _GimpThumbBox                 GimpThumbBox;
 typedef struct _GimpUnitStore                GimpUnitStore;



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