gimp r26870 - in trunk: . app/dialogs app/widgets



Author: mitch
Date: Fri Sep  5 10:37:06 2008
New Revision: 26870
URL: http://svn.gnome.org/viewvc/gimp?rev=26870&view=rev

Log:
2008-09-05  Michael Natterer  <mitch gimp org>

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpactioneditor.[ch]: new simple widget which
	contains a GimpActionView plus the search entry.

	* app/dialogs/keyboard-shortcuts-dialog.c: use the new widget
	instead of implementing the search entry here.

	* app/widgets/gimpcontrollereditor.c: use a GimpActionEditor
	instead of GimpActionView so the actions become searchable here
	too.



Added:
   trunk/app/widgets/gimpactioneditor.c
   trunk/app/widgets/gimpactioneditor.h
Modified:
   trunk/ChangeLog
   trunk/app/dialogs/keyboard-shortcuts-dialog.c
   trunk/app/widgets/Makefile.am
   trunk/app/widgets/gimpcontrollereditor.c
   trunk/app/widgets/widgets-types.h

Modified: trunk/app/dialogs/keyboard-shortcuts-dialog.c
==============================================================================
--- trunk/app/dialogs/keyboard-shortcuts-dialog.c	(original)
+++ trunk/app/dialogs/keyboard-shortcuts-dialog.c	Fri Sep  5 10:37:06 2008
@@ -26,7 +26,7 @@
 
 #include "core/gimp.h"
 
-#include "widgets/gimpactionview.h"
+#include "widgets/gimpactioneditor.h"
 #include "widgets/gimphelp-ids.h"
 #include "widgets/gimpuimanager.h"
 
@@ -35,34 +35,14 @@
 #include "gimp-intl.h"
 
 
-static void
-keyboard_shortcuts_dialog_filter_clear (GtkButton *button,
-                                        GtkEntry  *entry)
-{
-  gtk_entry_set_text (entry, "");
-}
-
-static void
-keyboard_shortcuts_dialog_filter_changed (GtkEntry       *entry,
-                                          GimpActionView *view)
-{
-  gimp_action_view_set_filter (view, gtk_entry_get_text (entry));
-}
-
 GtkWidget *
 keyboard_shortcuts_dialog_new (Gimp *gimp)
 {
   GtkWidget *dialog;
   GtkWidget *vbox;
-  GtkWidget *hbox;
-  GtkWidget *entrybox;
-  GtkWidget *label;
-  GtkWidget *entry;
-  GtkWidget *button;
-  GtkWidget *image;
-  GtkWidget *scrolled_window;
-  GtkWidget *view;
+  GtkWidget *editor;
   GtkWidget *box;
+  GtkWidget *button;
 
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
 
@@ -85,55 +65,10 @@
   gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
   gtk_widget_show (vbox);
 
-  hbox = gtk_hbox_new (FALSE, 6);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
-  gtk_widget_show (hbox);
-
-  label = gtk_label_new_with_mnemonic (_("_Search:"));
-  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-  gtk_widget_show (label);
-
-  entrybox = gtk_hbox_new (FALSE, 2);
-  gtk_box_pack_start (GTK_BOX (hbox), entrybox, TRUE, TRUE, 0);
-  gtk_widget_show (entrybox);
-
-  entry = gtk_entry_new ();
-  gtk_box_pack_start (GTK_BOX (entrybox), entry, TRUE, TRUE, 0);
-  gtk_widget_show (entry);
-
-  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
-
-  button = gtk_button_new ();
-  GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
-  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-  gtk_box_pack_start (GTK_BOX (entrybox), button, FALSE, FALSE, 0);
-  gtk_widget_show (button);
-
-  image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
-  gtk_container_add (GTK_CONTAINER (button), image);
-  gtk_widget_show (image);
-
-  g_signal_connect (button, "clicked",
-                    G_CALLBACK (keyboard_shortcuts_dialog_filter_clear),
-                    entry);
-
-  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
-                                       GTK_SHADOW_IN);
-  gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
-  gtk_widget_show (scrolled_window);
-
-  view = gimp_action_view_new (gimp_ui_managers_from_name ("<Image>")->data,
-                               NULL, TRUE);
-  gtk_widget_set_size_request (view, 300, 400);
-  gtk_container_add (GTK_CONTAINER (scrolled_window), view);
-  gtk_widget_show (view);
-
-  g_signal_connect (entry, "changed",
-                    G_CALLBACK (keyboard_shortcuts_dialog_filter_changed),
-                    view);
+  editor = gimp_action_editor_new (gimp_ui_managers_from_name ("<Image>")->data,
+                                   NULL, TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), editor, TRUE, TRUE, 0);
+  gtk_widget_show (editor);
 
   box = gimp_hint_box_new (_("To edit a shortcut key, click on the "
                              "corresponding row and type a new "

Modified: trunk/app/widgets/Makefile.am
==============================================================================
--- trunk/app/widgets/Makefile.am	(original)
+++ trunk/app/widgets/Makefile.am	Fri Sep  5 10:37:06 2008
@@ -20,6 +20,8 @@
 	widgets-types.h			\
 	gimpaction.c			\
 	gimpaction.h			\
+	gimpactioneditor.c		\
+	gimpactioneditor.h		\
 	gimpactionfactory.c		\
 	gimpactionfactory.h		\
 	gimpactiongroup.c		\

Added: trunk/app/widgets/gimpactioneditor.c
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimpactioneditor.c	Fri Sep  5 10:37:06 2008
@@ -0,0 +1,149 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpactioneditor.c
+ * Copyright (C) 2008  Michael Natterer <mitch gimp 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 <gtk/gtk.h>
+
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "widgets-types.h"
+
+#include "gimpactioneditor.h"
+#include "gimpactionview.h"
+#include "gimpuimanager.h"
+
+#include "gimp-intl.h"
+
+
+/*  local function prototypes  */
+
+static void   gimp_action_editor_filter_clear   (GtkButton        *button,
+                                                 GtkEntry         *entry);
+static void   gimp_action_editor_filter_changed (GtkEntry         *entry,
+                                                 GimpActionEditor *editor);
+
+
+G_DEFINE_TYPE (GimpActionEditor, gimp_action_editor, GTK_TYPE_VBOX)
+
+#define parent_class gimp_action_editor_parent_class
+
+
+static void
+gimp_action_editor_class_init (GimpActionEditorClass *klass)
+{
+}
+
+static void
+gimp_action_editor_init (GimpActionEditor *editor)
+{
+  GtkWidget *hbox;
+  GtkWidget *entrybox;
+  GtkWidget *label;
+  GtkWidget *entry;
+  GtkWidget *button;
+  GtkWidget *image;
+
+  gtk_box_set_spacing (GTK_BOX (editor), 12);
+
+  hbox = gtk_hbox_new (FALSE, 6);
+  gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
+  gtk_widget_show (hbox);
+
+  label = gtk_label_new_with_mnemonic (_("_Search:"));
+  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+  gtk_widget_show (label);
+
+  entrybox = gtk_hbox_new (FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (hbox), entrybox, TRUE, TRUE, 0);
+  gtk_widget_show (entrybox);
+
+  entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX (entrybox), entry, TRUE, TRUE, 0);
+  gtk_widget_show (entry);
+
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  button = gtk_button_new ();
+  GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
+  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+  gtk_box_pack_start (GTK_BOX (entrybox), button, FALSE, FALSE, 0);
+  gtk_widget_show (button);
+
+  image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
+  gtk_container_add (GTK_CONTAINER (button), image);
+  gtk_widget_show (image);
+
+  g_signal_connect (button, "clicked",
+                    G_CALLBACK (gimp_action_editor_filter_clear),
+                    entry);
+
+  g_signal_connect (entry, "changed",
+                    G_CALLBACK (gimp_action_editor_filter_changed),
+                    editor);
+}
+
+GtkWidget *
+gimp_action_editor_new (GimpUIManager *manager,
+                        const gchar   *select_action,
+                        gboolean       show_shortcuts)
+{
+  GimpActionEditor *editor;
+  GtkWidget        *scrolled_window;
+
+  g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL);
+
+  editor = g_object_new (GIMP_TYPE_ACTION_EDITOR, NULL);
+
+  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+                                       GTK_SHADOW_IN);
+  gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 0);
+  gtk_widget_show (scrolled_window);
+
+  editor->view = gimp_action_view_new (manager, select_action, show_shortcuts);
+  gtk_widget_set_size_request (editor->view, 300, 400);
+  gtk_container_add (GTK_CONTAINER (scrolled_window), editor->view);
+  gtk_widget_show (editor->view);
+
+  return GTK_WIDGET (editor);
+}
+
+
+/*  private functions  */
+
+static void
+gimp_action_editor_filter_clear (GtkButton *button,
+                                 GtkEntry  *entry)
+{
+  gtk_entry_set_text (entry, "");
+}
+
+static void
+gimp_action_editor_filter_changed (GtkEntry         *entry,
+                                   GimpActionEditor *editor)
+{
+  gimp_action_view_set_filter (GIMP_ACTION_VIEW (editor->view),
+                               gtk_entry_get_text (entry));
+}
+

Added: trunk/app/widgets/gimpactioneditor.h
==============================================================================
--- (empty file)
+++ trunk/app/widgets/gimpactioneditor.h	Fri Sep  5 10:37:06 2008
@@ -0,0 +1,56 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpactioneditor.h
+ * Copyright (C) 2008  Michael Natterer <mitch gimp 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_ACTION_EDITOR_H__
+#define __GIMP_ACTION_EDITOR_H__
+
+
+#define GIMP_TYPE_ACTION_EDITOR            (gimp_action_editor_get_type ())
+#define GIMP_ACTION_EDITOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ACTION_EDITOR, GimpActionEditor))
+#define GIMP_ACTION_EDITOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ACTION_EDITOR, GimpActionEditorClass))
+#define GIMP_IS_ACTION_EDITOR(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ACTION_EDITOR))
+#define GIMP_IS_ACTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ACTION_EDITOR))
+#define GIMP_ACTION_EDITOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ACTION_EDITOR, GimpActionEditorClass))
+
+
+typedef struct _GimpActionEditorClass GimpActionEditorClass;
+
+struct _GimpActionEditor
+{
+  GtkVBox    parent_instance;
+
+  GtkWidget *view;
+};
+
+struct _GimpActionEditorClass
+{
+  GtkVBoxClass  parent_class;
+};
+
+
+GType       gimp_action_editor_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_action_editor_new      (GimpUIManager *manager,
+                                         const gchar   *select_action,
+                                         gboolean       show_shortcuts);
+
+
+#endif  /*  __GIMP_ACTION_EDITOR_H__  */

Modified: trunk/app/widgets/gimpcontrollereditor.c
==============================================================================
--- trunk/app/widgets/gimpcontrollereditor.c	(original)
+++ trunk/app/widgets/gimpcontrollereditor.c	Fri Sep  5 10:37:06 2008
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
  *
  * gimpcontrollereditor.c
- * Copyright (C) 2004 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2004-2008 Michael Natterer <mitch gimp 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
@@ -34,6 +34,7 @@
 
 #include "core/gimpcontext.h"
 
+#include "gimpactioneditor.h"
 #include "gimpactionview.h"
 #include "gimpcontrollereditor.h"
 #include "gimpcontrollerinfo.h"
@@ -654,7 +655,6 @@
 
   if (event_name)
     {
-      GtkWidget *scrolled_window;
       GtkWidget *view;
       gchar     *title;
 
@@ -694,25 +694,18 @@
                         G_CALLBACK (gimp_controller_editor_edit_response),
                         editor);
 
-      scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-      gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
-                                           GTK_SHADOW_IN);
-      gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 12);
+      view = gimp_action_editor_new (gimp_ui_managers_from_name ("<Image>")->data,
+                                     action_name, FALSE);
+      gtk_container_set_border_width (GTK_CONTAINER (view), 12);
       gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editor->edit_dialog)->vbox),
-                         scrolled_window);
-      gtk_widget_show (scrolled_window);
-
-      view = gimp_action_view_new (gimp_ui_managers_from_name ("<Image>")->data,
-                                   action_name, FALSE);
-      gtk_widget_set_size_request (view, 300, 400);
-      gtk_container_add (GTK_CONTAINER (scrolled_window), view);
+                         view);
       gtk_widget_show (view);
 
-      g_signal_connect (view, "row-activated",
+      g_signal_connect (GIMP_ACTION_EDITOR (view)->view, "row-activated",
                         G_CALLBACK (gimp_controller_editor_edit_activated),
                         editor);
 
-      editor->edit_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+      editor->edit_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (GIMP_ACTION_EDITOR (view)->view));
 
       g_object_add_weak_pointer (G_OBJECT (editor->edit_sel),
                                  (gpointer) &editor->edit_sel);

Modified: trunk/app/widgets/widgets-types.h
==============================================================================
--- trunk/app/widgets/widgets-types.h	(original)
+++ trunk/app/widgets/widgets-types.h	Fri Sep  5 10:37:06 2008
@@ -149,6 +149,7 @@
 
 /*  misc widgets  */
 
+typedef struct _GimpActionEditor             GimpActionEditor;
 typedef struct _GimpActionView               GimpActionView;
 typedef struct _GimpBlobEditor               GimpBlobEditor;
 typedef struct _GimpColorBar                 GimpColorBar;



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