1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
5
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
#include "libgimpwidgets/gimpwidgets.h"
28
#include "widgets-types.h"
30
#include "gimpactioneditor.h"
31
#include "gimpactionview.h"
32
#include "gimpuimanager.h"
34
#include "gimp-intl.h"
37
/* local function prototypes */
39
static void gimp_action_editor_filter_clear (GtkButton *button,
41
static void gimp_action_editor_filter_changed (GtkEntry *entry,
42
GimpActionEditor *editor);
45
G_DEFINE_TYPE (GimpActionEditor, gimp_action_editor, GTK_TYPE_VBOX)
47
#define parent_class gimp_action_editor_parent_class
51
gimp_action_editor_class_init (GimpActionEditorClass *klass)
56
gimp_action_editor_init (GimpActionEditor *editor)
65
gtk_box_set_spacing (GTK_BOX (editor), 12);
67
hbox = gtk_hbox_new (FALSE, 6);
68
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
69
gtk_widget_show (hbox);
71
label = gtk_label_new_with_mnemonic (_("_Search:"));
72
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
73
gtk_widget_show (label);
75
entrybox = gtk_hbox_new (FALSE, 2);
76
gtk_box_pack_start (GTK_BOX (hbox), entrybox, TRUE, TRUE, 0);
77
gtk_widget_show (entrybox);
79
entry = gtk_entry_new ();
80
gtk_box_pack_start (GTK_BOX (entrybox), entry, TRUE, TRUE, 0);
81
gtk_widget_show (entry);
83
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
85
button = gtk_button_new ();
86
GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
87
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
88
gtk_box_pack_start (GTK_BOX (entrybox), button, FALSE, FALSE, 0);
89
gtk_widget_show (button);
91
image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_MENU);
92
gtk_container_add (GTK_CONTAINER (button), image);
93
gtk_widget_show (image);
95
g_signal_connect (button, "clicked",
96
G_CALLBACK (gimp_action_editor_filter_clear),
99
g_signal_connect (entry, "changed",
100
G_CALLBACK (gimp_action_editor_filter_changed),
105
gimp_action_editor_new (GimpUIManager *manager,
106
const gchar *select_action,
107
gboolean show_shortcuts)
109
GimpActionEditor *editor;
110
GtkWidget *scrolled_window;
112
g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL);
114
editor = g_object_new (GIMP_TYPE_ACTION_EDITOR, NULL);
116
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
117
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
118
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
119
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
121
gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 0);
122
gtk_widget_show (scrolled_window);
124
editor->view = gimp_action_view_new (manager, select_action, show_shortcuts);
125
gtk_widget_set_size_request (editor->view, 300, 400);
126
gtk_container_add (GTK_CONTAINER (scrolled_window), editor->view);
127
gtk_widget_show (editor->view);
129
return GTK_WIDGET (editor);
133
/* private functions */
136
gimp_action_editor_filter_clear (GtkButton *button,
139
gtk_entry_set_text (entry, "");
143
gimp_action_editor_filter_changed (GtkEntry *entry,
144
GimpActionEditor *editor)
146
gimp_action_view_set_filter (GIMP_ACTION_VIEW (editor->view),
147
gtk_entry_get_text (entry));