[gegl-edit] Added text box in "Add Operation" dialog to make finding operations easier



commit 06322aa2daaf6968ee6cfa53d62417beb528c091
Author: Isaac Wagner <isaacbw src gnome org>
Date:   Mon Aug 6 16:40:17 2012 -0400

    Added text box in "Add Operation" dialog to make finding operations easier

 gegl-edit/gegl-edit.c |   53 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/gegl-edit/gegl-edit.c b/gegl-edit/gegl-edit.c
index ff99d62..1cc5523 100644
--- a/gegl-edit/gegl-edit.c
+++ b/gegl-edit/gegl-edit.c
@@ -4,6 +4,7 @@
 #include <graph-gtk-node.h>
 #include "gegl-gtk-property-view.h"
 #include <stdlib.h>
+#include <string.h>
 
 #include "resources.h"
 
@@ -496,15 +497,53 @@ G_MODULE_EXPORT void activated_process_all(GtkMenuItem *menuitem, gpointer user_
     }
 }
 
+typedef struct {
+  GtkWidget *entry;
+  GtkListStore *list_store;
+  gboolean ignore_change;
+} AddDialogData;
+
+void changed_add_entry(GtkEntry *entry, AddDialogData *data) {
+  if(!data->ignore_change)
+    {
+      GtkListStore *store = data->list_store;
+      const gchar *str = gtk_entry_get_text(entry);
+
+      gtk_list_store_clear(store);
+
+      guint		n_ops;
+      gchar**	ops = gegl_list_operations(&n_ops);
+
+      GtkTreeIter	itr;
+
+      int	i;
+      for(i = 0; i < n_ops; i++) {
+	if(strstr(ops[i], str))
+	  {
+	    gtk_list_store_append(store, &itr);
+	    gtk_list_store_set(store, &itr, 0, ops[i], -1);
+	  }
+      }
+    }
+  else
+    {
+      data->ignore_change = FALSE;
+    }
+}
+
 G_MODULE_EXPORT void activated_add(GtkMenuItem *menuitem, gpointer user_data)
 {
   CallbackData *data = user_data;
 
+  AddDialogData *callback_data = g_new(AddDialogData, 1);
+  callback_data->ignore_change = FALSE;
+
   GtkWidget	*add_op_dialog = gtk_dialog_new_with_buttons("AddOperation", GTK_WINDOW(data->window), 
 							     GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 							     GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT, NULL);
   /////list/////////
   GtkListStore	*store	       = gtk_list_store_new(1, G_TYPE_STRING);
+  callback_data->list_store = store;
 
   guint		n_ops;
   gchar**	ops = gegl_list_operations(&n_ops);
@@ -519,10 +558,14 @@ G_MODULE_EXPORT void activated_add(GtkMenuItem *menuitem, gpointer user_data)
 
   /////////////////
 
+  GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+  gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(add_op_dialog))), GTK_WIDGET(vbox));
+
   GtkWidget	*text_entry = gtk_entry_new();
-  
-  //  gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(add_op_dialog))), text_entry);
-  //  gtk_widget_show(text_entry);
+  callback_data->entry = text_entry;
+  //connect to signal which narrows down tree as text is changed
+  g_signal_connect(text_entry, "changed", G_CALLBACK(changed_add_entry), callback_data);
+  gtk_box_pack_start(GTK_BOX(vbox), text_entry, FALSE, FALSE, 0);
   
   GtkWidget*	list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
 
@@ -541,8 +584,8 @@ G_MODULE_EXPORT void activated_add(GtkMenuItem *menuitem, gpointer user_data)
   gtk_widget_show(GTK_WIDGET(scrolls));
   gtk_container_add(GTK_CONTAINER(scrolls), list);
 
-  gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(add_op_dialog))), GTK_WIDGET(scrolls));
-  gtk_widget_show(list);
+  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scrolls), FALSE, FALSE, 0);
+  gtk_widget_show_all(vbox);
 
   //g_signal_connect(add_op_dialog, "response", add_operation_dialog, data);
 



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