gimp r25997 - in branches/soc-2008-tagging/app: core widgets
- From: aurisj svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25997 - in branches/soc-2008-tagging/app: core widgets
- Date: Fri, 27 Jun 2008 20:43:05 +0000 (UTC)
Author: aurisj
Date: Fri Jun 27 20:43:05 2008
New Revision: 25997
URL: http://svn.gnome.org/viewvc/gimp?rev=25997&view=rev
Log:
2008-06-27 Aurimas JuÅka <aurisj svn gnome org> commiting rest of the files ommited by commit script.
Added:
branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c
branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h
Modified:
branches/soc-2008-tagging/app/core/core-types.h
branches/soc-2008-tagging/app/widgets/gimpbrushfactoryview.c
branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.c
branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.h
Modified: branches/soc-2008-tagging/app/core/core-types.h
==============================================================================
--- branches/soc-2008-tagging/app/core/core-types.h (original)
+++ branches/soc-2008-tagging/app/core/core-types.h Fri Jun 27 20:43:05 2008
@@ -65,6 +65,7 @@
/* containers */
typedef struct _GimpContainer GimpContainer;
+typedef struct _GimpFilteredContainer GimpFilteredContainer;
typedef struct _GimpList GimpList;
typedef struct _GimpDocumentList GimpDocumentList;
typedef struct _GimpToolPresets GimpToolPresets;
Added: branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c
==============================================================================
--- (empty file)
+++ branches/soc-2008-tagging/app/core/gimpfilteredcontainer.c Fri Jun 27 20:43:05 2008
@@ -0,0 +1,179 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
+ *
+ * gimpfilteredcontainer.c
+ * Copyright (C) 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 <stdlib.h>
+#include <string.h> /* strcmp */
+
+#include <glib-object.h>
+
+#include "core-types.h"
+
+#include "gimptagged.h"
+#include "gimplist.h"
+#include "gimpfilteredcontainer.h"
+
+
+static gint64 gimp_filtered_container_get_memsize (GimpObject *object,
+ gint64 *gui_size);
+
+static gboolean gimp_filtered_container_object_matches (GimpFilteredContainer *filtered_container,
+ GimpObject *object);
+
+static void gimp_filtered_container_filter (GimpFilteredContainer *filtered_container);
+
+
+
+G_DEFINE_TYPE (GimpFilteredContainer, gimp_filtered_container, GIMP_TYPE_LIST)
+
+#define parent_class gimp_filtered_container_parent_class
+
+
+static void
+gimp_filtered_container_class_init (GimpFilteredContainerClass *klass)
+{
+ GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
+
+ gimp_object_class->get_memsize = gimp_filtered_container_get_memsize;
+}
+
+static void
+gimp_filtered_container_init (GimpFilteredContainer *filtered_container)
+{
+ filtered_container->src_container = NULL;
+ filtered_container->filter = NULL;
+}
+
+static gint64
+gimp_filtered_container_get_memsize (GimpObject *object,
+ gint64 *gui_size)
+{
+ GimpFilteredContainer *filtered_container = GIMP_FILTERED_CONTAINER (object);
+ gint64 memsize = 0;
+
+ memsize += (gimp_container_num_children (GIMP_CONTAINER (filtered_container)) *
+ sizeof (GList));
+
+ return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
+ gui_size);
+}
+
+/**
+ * gimp_filtered_container_new:
+ * @src_container: container to be filtered.
+ *
+ * Creates a new #GimpFilteredContainer object. Since #GimpFilteredContainer is a #GimpContainer
+ * implementation, it holds GimpObjects. It filters @src_container for objects containing
+ * all of the filtering tags. Syncronization with @src_container data is performed
+ * automatically.
+ *
+ * Return value: a new #GimpFilteredContainer object
+ **/
+GimpContainer *
+gimp_filtered_container_new (GimpContainer *src_container)
+{
+ GimpFilteredContainer *filtered_container;
+ GType children_type;
+
+ children_type = gimp_container_children_type (src_container);
+
+ filtered_container = g_object_new (GIMP_TYPE_FILTERED_CONTAINER,
+ "children-type", children_type,
+ "policy", GIMP_CONTAINER_POLICY_WEAK,
+ "unique-names", FALSE,
+ NULL);
+
+ filtered_container->src_container = src_container;
+ GIMP_CONTAINER (filtered_container)->children_type = children_type;
+
+ gimp_filtered_container_filter (filtered_container);
+
+ return GIMP_CONTAINER (filtered_container);
+}
+
+void
+gimp_filtered_container_set_filter (GimpFilteredContainer *filtered_container,
+ GList *tags)
+{
+ filtered_container->filter = tags;
+
+ gimp_container_freeze (GIMP_CONTAINER (filtered_container));
+ gimp_container_clear (GIMP_CONTAINER (filtered_container));
+ gimp_filtered_container_filter (filtered_container);
+ gimp_container_thaw (GIMP_CONTAINER (filtered_container));
+}
+
+GList *
+gimp_filtered_container_get_filter (GimpFilteredContainer *filtered_container)
+{
+ return filtered_container->filter;
+}
+
+static gboolean
+gimp_filtered_container_object_matches (GimpFilteredContainer *filtered_container,
+ GimpObject *object)
+{
+ GList *filter_tag;
+ GList *object_tag;
+
+ filter_tag = filtered_container->filter;
+ while (filter_tag)
+ {
+ object_tag = gimp_tagged_get_tags (GIMP_TAGGED (object));
+ while (object_tag)
+ {
+ if (object_tag->data == filter_tag->data)
+ {
+ break;
+ }
+ object_tag = g_list_next (object_tag);
+ }
+
+ if (! object_tag)
+ {
+ return FALSE;
+ }
+
+ filter_tag = g_list_next (filter_tag);
+ }
+
+ return TRUE;
+}
+
+static void
+add_filtered_item (GimpObject *object,
+ GimpFilteredContainer *filtered_container)
+{
+ if (gimp_filtered_container_object_matches (filtered_container,
+ object))
+ {
+ gimp_container_add (GIMP_CONTAINER (filtered_container), object);
+ }
+}
+
+static void
+gimp_filtered_container_filter (GimpFilteredContainer *filtered_container)
+{
+ gimp_container_foreach (filtered_container->src_container,
+ (GFunc) add_filtered_item, filtered_container);
+}
+
Added: branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h
==============================================================================
--- (empty file)
+++ branches/soc-2008-tagging/app/core/gimpfilteredcontainer.h Fri Jun 27 20:43:05 2008
@@ -0,0 +1,62 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
+ *
+ * gimpfilteredcontainer.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_FILTERED_CONTAINER_H__
+#define __GIMP_FILTERED_CONTAINER_H__
+
+
+#include "gimplist.h"
+
+
+#define GIMP_TYPE_FILTERED_CONTAINER (gimp_filtered_container_get_type ())
+#define GIMP_FILTERED_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FILTERED_CONTAINER, GimpFilteredContainer))
+#define GIMP_FILTERED_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FILTERED_CONTAINER, GimpFilteredContainerClass))
+#define GIMP_IS_FILTERED_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_FILTERED_CONTAINER))
+#define GIMP_FILTERED_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FILTERED_CONTAINER, GimpFilteredContainerClass))
+
+
+typedef struct _GimpFilteredContainerClass GimpFilteredContainerClass;
+
+struct _GimpFilteredContainer
+{
+ GimpList parent_instance;
+
+ GimpContainer *src_container;
+ GList *filter;
+};
+
+struct _GimpFilteredContainerClass
+{
+ GimpContainerClass parent_class;
+};
+
+
+GType gimp_filtered_container_get_type (void) G_GNUC_CONST;
+
+GimpContainer * gimp_filtered_container_new (GimpContainer *src_container);
+
+void gimp_filtered_container_set_filter (GimpFilteredContainer *container,
+ GList *tags);
+
+GList * gimp_filtered_container_get_filter (GimpFilteredContainer *container);
+
+
+#endif /* __GIMP_FILTERED_CONTAINER_H__ */
Modified: branches/soc-2008-tagging/app/widgets/gimpbrushfactoryview.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpbrushfactoryview.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimpbrushfactoryview.c Fri Jun 27 20:43:05 2008
@@ -104,7 +104,7 @@
{
GimpContainer *container;
- container = gimp_container_view_get_container (editor->view);
+ container = GIMP_DATA_FACTORY_VIEW (editor)->factory->container;
gimp_container_remove_handler (container,
view->spacing_changed_handler_id);
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 Fri Jun 27 20:43:05 2008
@@ -36,6 +36,7 @@
#include "core/gimpcontext.h"
#include "core/gimpdata.h"
#include "core/gimpdatafactory.h"
+#include "core/gimpfilteredcontainer.h"
#include "core/gimpmarshal.h"
#include "gimpcontainerview.h"
@@ -56,6 +57,8 @@
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,
@@ -80,6 +83,8 @@
view->duplicate_button = NULL;
view->delete_button = NULL;
view->refresh_button = NULL;
+
+ view->filtered_container = NULL;
}
GtkWidget *
@@ -97,6 +102,7 @@
factory_view = g_object_new (GIMP_TYPE_DATA_FACTORY_VIEW, NULL);
+
if (! gimp_data_factory_view_construct (factory_view,
view_type,
factory,
@@ -112,6 +118,7 @@
return NULL;
}
+
return GTK_WIDGET (factory_view);
}
@@ -129,6 +136,8 @@
{
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);
g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE);
@@ -139,10 +148,11 @@
FALSE);
factory_view->factory = factory;
+ factory_view->filtered_container = gimp_filtered_container_new (factory->container);
if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (factory_view),
view_type,
- factory->container, context,
+ factory_view->filtered_container, context,
view_size, view_border_width,
menu_factory, menu_identifier,
ui_identifier))
@@ -214,6 +224,26 @@
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);
+ gtk_widget_show (tag_query_entry);
+
+ editor = GIMP_CONTAINER_EDITOR (factory_view);
+
+ gtk_box_pack_start (GTK_BOX (editor->view),
+ tag_query_box,
+ FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX (editor->view),
+ tag_query_box, 0);
+
+
return TRUE;
}
@@ -286,3 +316,24 @@
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);
+}
+
Modified: branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.h
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.h (original)
+++ branches/soc-2008-tagging/app/widgets/gimpdatafactoryview.h Fri Jun 27 20:43:05 2008
@@ -41,6 +41,7 @@
GimpContainerEditor parent_instance;
GimpDataFactory *factory;
+ GimpContainer *filtered_container;
GtkWidget *edit_button;
GtkWidget *new_button;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]