2008-09-05 18:37:06 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpactioneditor.c
|
|
|
|
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-09-05 18:37:06 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-09-05 18:37:06 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-09-05 18:37:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-02 05:28:18 +08:00
|
|
|
#include <gegl.h>
|
2008-09-05 18:37:06 +08:00
|
|
|
#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 */
|
|
|
|
|
2009-09-02 04:26:01 +08:00
|
|
|
static void gimp_action_editor_filter_clear (GtkEntry *entry);
|
2008-09-05 18:37:06 +08:00
|
|
|
static void gimp_action_editor_filter_changed (GtkEntry *entry,
|
|
|
|
GimpActionEditor *editor);
|
|
|
|
|
|
|
|
|
2010-10-30 21:44:46 +08:00
|
|
|
G_DEFINE_TYPE (GimpActionEditor, gimp_action_editor, GTK_TYPE_BOX)
|
2008-09-05 18:37:06 +08:00
|
|
|
|
|
|
|
#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 *label;
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
2010-10-30 21:44:46 +08:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
2008-09-05 18:37:06 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (editor), 12);
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2008-09-05 18:37:06 +08:00
|
|
|
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);
|
|
|
|
|
|
|
|
entry = gtk_entry_new ();
|
2009-09-02 04:26:01 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
2008-09-05 18:37:06 +08:00
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
|
|
|
|
|
2014-05-07 05:47:38 +08:00
|
|
|
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
|
|
|
|
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
|
2009-09-02 04:26:01 +08:00
|
|
|
gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
|
|
|
|
GTK_ENTRY_ICON_SECONDARY, TRUE);
|
|
|
|
gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
|
|
|
|
GTK_ENTRY_ICON_SECONDARY, FALSE);
|
2008-09-05 18:37:06 +08:00
|
|
|
|
2009-09-02 04:26:01 +08:00
|
|
|
g_signal_connect (entry, "icon-press",
|
2008-09-05 18:37:06 +08:00
|
|
|
G_CALLBACK (gimp_action_editor_filter_clear),
|
2009-09-02 04:26:01 +08:00
|
|
|
NULL);
|
2008-09-05 18:37:06 +08:00
|
|
|
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
|
2009-09-02 04:26:01 +08:00
|
|
|
gimp_action_editor_filter_clear (GtkEntry *entry)
|
2008-09-05 18:37:06 +08:00
|
|
|
{
|
|
|
|
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));
|
2009-09-02 04:26:01 +08:00
|
|
|
gtk_entry_set_icon_sensitive (entry,
|
|
|
|
GTK_ENTRY_ICON_SECONDARY,
|
|
|
|
gtk_entry_get_text_length (entry) > 0);
|
2008-09-05 18:37:06 +08:00
|
|
|
}
|
|
|
|
|