~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimpactioneditor.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-10-06 13:30:41 UTC
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: james.westby@ubuntu.com-20081006133041-3panbkcanaymfsmp
Tags: upstream-2.6.0
ImportĀ upstreamĀ versionĀ 2.6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * gimpactioneditor.c
 
5
 * Copyright (C) 2008  Michael Natterer <mitch@gimp.org>
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include <gtk/gtk.h>
 
25
 
 
26
#include "libgimpwidgets/gimpwidgets.h"
 
27
 
 
28
#include "widgets-types.h"
 
29
 
 
30
#include "gimpactioneditor.h"
 
31
#include "gimpactionview.h"
 
32
#include "gimpuimanager.h"
 
33
 
 
34
#include "gimp-intl.h"
 
35
 
 
36
 
 
37
/*  local function prototypes  */
 
38
 
 
39
static void   gimp_action_editor_filter_clear   (GtkButton        *button,
 
40
                                                 GtkEntry         *entry);
 
41
static void   gimp_action_editor_filter_changed (GtkEntry         *entry,
 
42
                                                 GimpActionEditor *editor);
 
43
 
 
44
 
 
45
G_DEFINE_TYPE (GimpActionEditor, gimp_action_editor, GTK_TYPE_VBOX)
 
46
 
 
47
#define parent_class gimp_action_editor_parent_class
 
48
 
 
49
 
 
50
static void
 
51
gimp_action_editor_class_init (GimpActionEditorClass *klass)
 
52
{
 
53
}
 
54
 
 
55
static void
 
56
gimp_action_editor_init (GimpActionEditor *editor)
 
57
{
 
58
  GtkWidget *hbox;
 
59
  GtkWidget *entrybox;
 
60
  GtkWidget *label;
 
61
  GtkWidget *entry;
 
62
  GtkWidget *button;
 
63
  GtkWidget *image;
 
64
 
 
65
  gtk_box_set_spacing (GTK_BOX (editor), 12);
 
66
 
 
67
  hbox = gtk_hbox_new (FALSE, 6);
 
68
  gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
 
69
  gtk_widget_show (hbox);
 
70
 
 
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);
 
74
 
 
75
  entrybox = gtk_hbox_new (FALSE, 2);
 
76
  gtk_box_pack_start (GTK_BOX (hbox), entrybox, TRUE, TRUE, 0);
 
77
  gtk_widget_show (entrybox);
 
78
 
 
79
  entry = gtk_entry_new ();
 
80
  gtk_box_pack_start (GTK_BOX (entrybox), entry, TRUE, TRUE, 0);
 
81
  gtk_widget_show (entry);
 
82
 
 
83
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
 
84
 
 
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);
 
90
 
 
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);
 
94
 
 
95
  g_signal_connect (button, "clicked",
 
96
                    G_CALLBACK (gimp_action_editor_filter_clear),
 
97
                    entry);
 
98
 
 
99
  g_signal_connect (entry, "changed",
 
100
                    G_CALLBACK (gimp_action_editor_filter_changed),
 
101
                    editor);
 
102
}
 
103
 
 
104
GtkWidget *
 
105
gimp_action_editor_new (GimpUIManager *manager,
 
106
                        const gchar   *select_action,
 
107
                        gboolean       show_shortcuts)
 
108
{
 
109
  GimpActionEditor *editor;
 
110
  GtkWidget        *scrolled_window;
 
111
 
 
112
  g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL);
 
113
 
 
114
  editor = g_object_new (GIMP_TYPE_ACTION_EDITOR, NULL);
 
115
 
 
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),
 
120
                                       GTK_SHADOW_IN);
 
121
  gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 0);
 
122
  gtk_widget_show (scrolled_window);
 
123
 
 
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);
 
128
 
 
129
  return GTK_WIDGET (editor);
 
130
}
 
131
 
 
132
 
 
133
/*  private functions  */
 
134
 
 
135
static void
 
136
gimp_action_editor_filter_clear (GtkButton *button,
 
137
                                 GtkEntry  *entry)
 
138
{
 
139
  gtk_entry_set_text (entry, "");
 
140
}
 
141
 
 
142
static void
 
143
gimp_action_editor_filter_changed (GtkEntry         *entry,
 
144
                                   GimpActionEditor *editor)
 
145
{
 
146
  gimp_action_view_set_filter (GIMP_ACTION_VIEW (editor->view),
 
147
                               gtk_entry_get_text (entry));
 
148
}
 
149