2005-08-03 01:06:49 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2005-08-03 01:06:49 +08:00
|
|
|
* gimpprocbrowserdialog.c
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2005-08-03 01:06:49 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2005-08-03 01:06:49 +08:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
1997-11-25 06:05:25 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-08-03 01:06:49 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2005-08-03 01:06:49 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-01 23:38:59 +08:00
|
|
|
#include "config.h"
|
2000-02-28 08:45:58 +08:00
|
|
|
|
2000-08-22 07:11:47 +08:00
|
|
|
#include <string.h>
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2013-11-02 05:29:46 +08:00
|
|
|
#include <gegl.h>
|
2000-02-28 08:45:58 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2000-02-28 08:45:58 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
|
|
|
#include "gimpuitypes.h"
|
|
|
|
#include "gimpprocbrowserdialog.h"
|
2004-09-30 18:57:57 +08:00
|
|
|
#include "gimpprocview.h"
|
2000-02-28 08:45:58 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
#include "libgimp-intl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-28 08:45:58 +08:00
|
|
|
|
2010-07-07 17:48:10 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpprocbrowserdialog
|
|
|
|
* @title: GimpProcBrowserDialog
|
|
|
|
* @short_description: The dialog for the procedure and plugin browsers.
|
|
|
|
*
|
|
|
|
* The dialog for the procedure and plugin browsers.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2004-09-30 08:33:34 +08:00
|
|
|
#define DBL_LIST_WIDTH 250
|
2002-01-13 07:05:45 +08:00
|
|
|
#define DBL_WIDTH (DBL_LIST_WIDTH + 400)
|
2001-12-29 21:26:29 +08:00
|
|
|
#define DBL_HEIGHT 250
|
1998-03-23 07:36:35 +08:00
|
|
|
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SELECTION_CHANGED,
|
2005-08-18 21:55:14 +08:00
|
|
|
ROW_ACTIVATED,
|
2005-08-03 00:49:42 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2005-05-13 23:58:16 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SEARCH_TYPE_ALL,
|
|
|
|
SEARCH_TYPE_NAME,
|
2005-05-19 06:21:07 +08:00
|
|
|
SEARCH_TYPE_BLURB,
|
|
|
|
SEARCH_TYPE_HELP,
|
2019-08-11 23:03:03 +08:00
|
|
|
SEARCH_TYPE_AUTHORS,
|
2005-05-19 06:21:07 +08:00
|
|
|
SEARCH_TYPE_COPYRIGHT,
|
|
|
|
SEARCH_TYPE_DATE,
|
|
|
|
SEARCH_TYPE_PROC_TYPE
|
2005-05-13 23:58:16 +08:00
|
|
|
} SearchType;
|
|
|
|
|
2004-09-30 08:33:34 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLUMN_PROC_NAME,
|
|
|
|
N_COLUMNS
|
|
|
|
};
|
2000-02-28 08:45:58 +08:00
|
|
|
|
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
struct _GimpProcBrowserDialogPrivate
|
|
|
|
{
|
|
|
|
GtkWidget *browser;
|
|
|
|
|
|
|
|
GtkListStore *store;
|
|
|
|
GtkWidget *tree_view;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GET_PRIVATE(obj) (((GimpProcBrowserDialog *) (obj))->priv)
|
|
|
|
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
static void browser_selection_changed (GtkTreeSelection *sel,
|
|
|
|
GimpProcBrowserDialog *dialog);
|
|
|
|
static void browser_row_activated (GtkTreeView *treeview,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
GimpProcBrowserDialog *dialog);
|
|
|
|
static void browser_search (GimpBrowser *browser,
|
|
|
|
const gchar *query_text,
|
|
|
|
gint search_type,
|
|
|
|
GimpProcBrowserDialog *dialog);
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2004-09-30 08:33:34 +08:00
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpProcBrowserDialog, gimp_proc_browser_dialog,
|
|
|
|
GIMP_TYPE_DIALOG)
|
2004-09-30 08:33:34 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_proc_browser_dialog_parent_class
|
|
|
|
|
|
|
|
static guint dialog_signals[LAST_SIGNAL] = { 0, };
|
2004-09-30 08:33:34 +08:00
|
|
|
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
static void
|
|
|
|
gimp_proc_browser_dialog_class_init (GimpProcBrowserDialogClass *klass)
|
|
|
|
{
|
2005-08-18 21:55:14 +08:00
|
|
|
/**
|
|
|
|
* GimpProcBrowserDialog::selection-changed:
|
|
|
|
* @dialog: the object that received the signal
|
|
|
|
*
|
|
|
|
* Emitted when the selection in the contained #GtkTreeView changes.
|
|
|
|
*/
|
2005-08-03 00:49:42 +08:00
|
|
|
dialog_signals[SELECTION_CHANGED] =
|
|
|
|
g_signal_new ("selection-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpProcBrowserDialogClass,
|
|
|
|
selection_changed),
|
2020-01-12 18:06:05 +08:00
|
|
|
NULL, NULL, NULL,
|
2005-08-03 00:49:42 +08:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2005-08-18 21:55:14 +08:00
|
|
|
/**
|
|
|
|
* GimpProcBrowserDialog::row-activated:
|
|
|
|
* @dialog: the object that received the signal
|
|
|
|
*
|
|
|
|
* Emitted when one of the rows in the contained #GtkTreeView is activated.
|
|
|
|
*/
|
|
|
|
dialog_signals[ROW_ACTIVATED] =
|
|
|
|
g_signal_new ("row-activated",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GimpProcBrowserDialogClass,
|
|
|
|
row_activated),
|
2020-01-12 18:06:05 +08:00
|
|
|
NULL, NULL, NULL,
|
2005-08-18 21:55:14 +08:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
klass->selection_changed = NULL;
|
2005-08-18 21:55:14 +08:00
|
|
|
klass->row_activated = NULL;
|
2005-08-03 00:49:42 +08:00
|
|
|
}
|
2004-09-30 08:33:34 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
static void
|
|
|
|
gimp_proc_browser_dialog_init (GimpProcBrowserDialog *dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-05-06 20:26:02 +08:00
|
|
|
GimpProcBrowserDialogPrivate *priv;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkWidget *parent;
|
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
dialog->priv = gimp_proc_browser_dialog_get_instance_private (dialog);
|
2018-05-06 20:26:02 +08:00
|
|
|
|
|
|
|
priv = GET_PRIVATE (dialog);
|
1998-03-23 07:36:35 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
priv->browser = gimp_browser_new ();
|
|
|
|
gimp_browser_add_search_types (GIMP_BROWSER (priv->browser),
|
2005-05-19 06:21:07 +08:00
|
|
|
_("by name"), SEARCH_TYPE_NAME,
|
|
|
|
_("by description"), SEARCH_TYPE_BLURB,
|
|
|
|
_("by help"), SEARCH_TYPE_HELP,
|
2019-08-11 23:03:03 +08:00
|
|
|
_("by authors"), SEARCH_TYPE_AUTHORS,
|
2005-05-19 06:21:07 +08:00
|
|
|
_("by copyright"), SEARCH_TYPE_COPYRIGHT,
|
|
|
|
_("by date"), SEARCH_TYPE_DATE,
|
|
|
|
_("by type"), SEARCH_TYPE_PROC_TYPE,
|
|
|
|
NULL);
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (priv->browser), 12);
|
2010-10-30 20:56:00 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
2018-05-06 20:26:02 +08:00
|
|
|
priv->browser, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (priv->browser);
|
2001-07-30 08:46:09 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
g_signal_connect (priv->browser, "search",
|
2005-05-19 06:21:07 +08:00
|
|
|
G_CALLBACK (browser_search),
|
2005-08-03 00:49:42 +08:00
|
|
|
dialog);
|
2004-09-30 08:33:34 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* list : list in a scrolled_win */
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2002-01-13 07:05:45 +08:00
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
2002-01-14 15:41:07 +08:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
2004-01-15 07:10:45 +08:00
|
|
|
GTK_SHADOW_IN);
|
2002-01-13 07:05:45 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
2004-01-15 07:10:45 +08:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_browser_get_left_vbox (GIMP_BROWSER (priv->browser))),
|
2005-05-19 06:21:07 +08:00
|
|
|
scrolled_window, TRUE, TRUE, 0);
|
2002-01-13 07:05:45 +08:00
|
|
|
gtk_widget_show (scrolled_window);
|
1998-03-23 07:36:35 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
priv->tree_view = gtk_tree_view_new ();
|
2002-01-13 07:05:45 +08:00
|
|
|
|
2003-09-01 01:23:01 +08:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_cell_renderer_text_set_fixed_height_from_font
|
|
|
|
(GTK_CELL_RENDERER_TEXT (renderer), 1);
|
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (priv->tree_view),
|
2004-01-15 07:10:45 +08:00
|
|
|
-1, NULL,
|
|
|
|
renderer,
|
|
|
|
"text", 0,
|
|
|
|
NULL);
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
|
2002-01-13 07:05:45 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
g_signal_connect (priv->tree_view, "row_activated",
|
2005-05-13 23:58:16 +08:00
|
|
|
G_CALLBACK (browser_row_activated),
|
2005-08-03 00:49:42 +08:00
|
|
|
dialog);
|
2004-09-30 08:33:34 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_widget_set_size_request (priv->tree_view, DBL_LIST_WIDTH, DBL_HEIGHT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), priv->tree_view);
|
|
|
|
gtk_widget_show (priv->tree_view);
|
2003-03-22 09:12:48 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
|
2002-01-13 07:05:45 +08:00
|
|
|
|
2005-05-19 06:21:07 +08:00
|
|
|
g_signal_connect (selection, "changed",
|
2004-09-30 08:33:34 +08:00
|
|
|
G_CALLBACK (browser_selection_changed),
|
2005-08-03 00:49:42 +08:00
|
|
|
dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
parent = gtk_widget_get_parent (gimp_browser_get_right_vbox (GIMP_BROWSER (priv->browser)));
|
2009-03-23 06:36:43 +08:00
|
|
|
parent = gtk_widget_get_parent (parent);
|
|
|
|
|
2017-09-03 21:14:51 +08:00
|
|
|
gtk_widget_set_size_request (parent, DBL_WIDTH - DBL_LIST_WIDTH, -1);
|
2019-08-05 21:12:16 +08:00
|
|
|
|
|
|
|
/* first search (all procedures) */
|
|
|
|
browser_search (GIMP_BROWSER (dialog->priv->browser),
|
|
|
|
"", SEARCH_TYPE_ALL, dialog);
|
2005-08-03 00:49:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2005-09-28 01:11:01 +08:00
|
|
|
/**
|
2020-05-21 19:43:47 +08:00
|
|
|
* gimp_proc_browser_dialog_new: (skip)
|
2005-09-28 01:11:01 +08:00
|
|
|
* @title: The dialog's title.
|
|
|
|
* @role: The dialog's role, see gtk_window_set_role().
|
2019-08-08 06:05:56 +08:00
|
|
|
* @help_func: (scope async): The function which will be called if
|
|
|
|
* the user presses "F1".
|
2005-09-28 01:11:01 +08:00
|
|
|
* @help_id: The help_id which will be passed to @help_func.
|
|
|
|
* @...: A %NULL-terminated list destribing the action_area buttons.
|
|
|
|
*
|
|
|
|
* Create a new #GimpProcBrowserDialog.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: a newly created #GimpProcBrowserDialog.
|
2005-09-28 01:11:01 +08:00
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2005-09-28 01:11:01 +08:00
|
|
|
**/
|
2005-08-03 00:49:42 +08:00
|
|
|
GtkWidget *
|
2005-09-28 00:35:48 +08:00
|
|
|
gimp_proc_browser_dialog_new (const gchar *title,
|
|
|
|
const gchar *role,
|
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
...)
|
2005-08-03 00:49:42 +08:00
|
|
|
{
|
|
|
|
GimpProcBrowserDialog *dialog;
|
2005-09-28 00:35:48 +08:00
|
|
|
va_list args;
|
2019-05-30 17:46:12 +08:00
|
|
|
gboolean use_header_bar;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-09-28 00:35:48 +08:00
|
|
|
va_start (args, help_id);
|
|
|
|
|
2019-05-30 17:46:12 +08:00
|
|
|
g_object_get (gtk_settings_get_default (),
|
|
|
|
"gtk-dialogs-use-header", &use_header_bar,
|
|
|
|
NULL);
|
|
|
|
|
2005-09-28 00:35:48 +08:00
|
|
|
dialog = g_object_new (GIMP_TYPE_PROC_BROWSER_DIALOG,
|
2019-05-30 17:46:12 +08:00
|
|
|
"title", title,
|
|
|
|
"role", role,
|
|
|
|
"help-func", help_func,
|
|
|
|
"help-id", help_id,
|
|
|
|
"use-header-bar", use_header_bar,
|
2005-09-28 00:35:48 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_dialog_add_buttons_valist (GIMP_DIALOG (dialog), args);
|
|
|
|
|
|
|
|
va_end (args);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
return GTK_WIDGET (dialog);
|
|
|
|
}
|
|
|
|
|
2005-09-28 01:11:01 +08:00
|
|
|
/**
|
|
|
|
* gimp_proc_browser_dialog_get_selected:
|
|
|
|
* @dialog: a #GimpProcBrowserDialog
|
|
|
|
*
|
|
|
|
* Retrieves the name of the currently selected procedure.
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
* Returns: (nullable): The name of the selected procedure of %NULL if no
|
2005-09-28 01:11:01 +08:00
|
|
|
* procedure is selected.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2005-09-28 01:11:01 +08:00
|
|
|
**/
|
2005-08-03 00:49:42 +08:00
|
|
|
gchar *
|
|
|
|
gimp_proc_browser_dialog_get_selected (GimpProcBrowserDialog *dialog)
|
|
|
|
{
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROC_BROWSER_DIALOG (dialog), NULL);
|
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->tree_view));
|
2005-08-03 00:49:42 +08:00
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
|
|
|
{
|
|
|
|
gchar *proc_name;
|
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter,
|
2005-08-03 00:49:42 +08:00
|
|
|
COLUMN_PROC_NAME, &proc_name,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
return proc_name;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
return NULL;
|
2003-03-22 09:12:48 +08:00
|
|
|
}
|
|
|
|
|
2004-09-30 08:33:34 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2003-09-01 01:23:01 +08:00
|
|
|
static void
|
2005-08-03 00:49:42 +08:00
|
|
|
browser_selection_changed (GtkTreeSelection *sel,
|
|
|
|
GimpProcBrowserDialog *dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-09-30 08:33:34 +08:00
|
|
|
GtkTreeIter iter;
|
1998-03-22 18:03:12 +08:00
|
|
|
|
2002-01-13 07:05:45 +08:00
|
|
|
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
|
|
|
{
|
2004-09-30 08:33:34 +08:00
|
|
|
gchar *proc_name;
|
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter,
|
2004-09-30 08:33:34 +08:00
|
|
|
COLUMN_PROC_NAME, &proc_name,
|
2004-01-15 07:10:45 +08:00
|
|
|
-1);
|
2019-08-05 20:17:18 +08:00
|
|
|
|
|
|
|
gimp_browser_set_widget (GIMP_BROWSER (dialog->priv->browser),
|
2019-09-08 20:54:17 +08:00
|
|
|
gimp_proc_view_new (proc_name));
|
2019-08-05 20:17:18 +08:00
|
|
|
|
2004-09-30 08:33:34 +08:00
|
|
|
g_free (proc_name);
|
2002-01-13 07:05:45 +08:00
|
|
|
}
|
2005-08-03 00:49:42 +08:00
|
|
|
|
|
|
|
g_signal_emit (dialog, dialog_signals[SELECTION_CHANGED], 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void
|
2005-08-03 00:49:42 +08:00
|
|
|
browser_row_activated (GtkTreeView *treeview,
|
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
GimpProcBrowserDialog *dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-18 21:55:14 +08:00
|
|
|
g_signal_emit (dialog, dialog_signals[ROW_ACTIVATED], 0);
|
2004-09-30 08:33:34 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-05-13 23:58:16 +08:00
|
|
|
static void
|
2005-08-03 00:49:42 +08:00
|
|
|
browser_search (GimpBrowser *browser,
|
|
|
|
const gchar *query_text,
|
|
|
|
gint search_type,
|
|
|
|
GimpProcBrowserDialog *dialog)
|
2005-05-13 23:58:16 +08:00
|
|
|
{
|
2019-08-13 02:42:27 +08:00
|
|
|
GimpProcBrowserDialogPrivate *priv = GET_PRIVATE (dialog);
|
|
|
|
GimpPDB *pdb = gimp_get_pdb ();
|
|
|
|
gchar **proc_list = NULL;
|
2018-05-06 20:26:02 +08:00
|
|
|
gint num_procs;
|
|
|
|
gchar *str;
|
|
|
|
GRegex *regex;
|
2008-11-12 05:35:41 +08:00
|
|
|
|
|
|
|
/* first check if the query is a valid regex */
|
|
|
|
regex = g_regex_new (query_text, 0, 0, NULL);
|
|
|
|
|
|
|
|
if (! regex)
|
|
|
|
{
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), NULL);
|
|
|
|
priv->store = NULL;
|
2008-11-12 05:35:41 +08:00
|
|
|
|
2008-11-26 04:05:19 +08:00
|
|
|
gimp_browser_show_message (browser, _("No matches"));
|
|
|
|
|
2011-01-01 01:19:37 +08:00
|
|
|
gimp_browser_set_search_summary (browser,
|
|
|
|
_("Search term invalid or incomplete"));
|
2008-11-12 05:35:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_regex_unref (regex);
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-10-06 07:31:49 +08:00
|
|
|
switch (search_type)
|
2005-05-13 23:58:16 +08:00
|
|
|
{
|
2005-10-06 07:31:49 +08:00
|
|
|
case SEARCH_TYPE_ALL:
|
|
|
|
gimp_browser_show_message (browser, _("Searching"));
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", ".*", ".*", ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", ".*", ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-10-06 07:31:49 +08:00
|
|
|
case SEARCH_TYPE_NAME:
|
|
|
|
{
|
|
|
|
GString *query = g_string_new ("");
|
|
|
|
const gchar *q = query_text;
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-10-06 07:31:49 +08:00
|
|
|
gimp_browser_show_message (browser, _("Searching by name"));
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-10-06 07:31:49 +08:00
|
|
|
while (*q)
|
|
|
|
{
|
|
|
|
if ((*q == '_') || (*q == '-'))
|
|
|
|
g_string_append (query, "-");
|
|
|
|
else
|
|
|
|
g_string_append_c (query, *q);
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-10-06 07:31:49 +08:00
|
|
|
q++;
|
|
|
|
}
|
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
query->str, ".*", ".*", ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", ".*", ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
|
|
|
|
g_string_free (query, TRUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SEARCH_TYPE_BLURB:
|
|
|
|
gimp_browser_show_message (browser, _("Searching by description"));
|
2005-05-19 06:21:07 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", query_text, ".*", ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", ".*", ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SEARCH_TYPE_HELP:
|
|
|
|
gimp_browser_show_message (browser, _("Searching by help"));
|
2005-05-19 07:48:47 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", ".*", query_text, ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", ".*", ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
|
|
|
|
2019-08-11 23:03:03 +08:00
|
|
|
case SEARCH_TYPE_AUTHORS:
|
|
|
|
gimp_browser_show_message (browser, _("Searching by authors"));
|
2005-05-19 06:21:07 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", ".*", ".*", ".*", query_text,
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", ".*", ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SEARCH_TYPE_COPYRIGHT:
|
|
|
|
gimp_browser_show_message (browser, _("Searching by copyright"));
|
2005-05-19 06:21:07 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", ".*", ".*", ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
query_text, ".*", ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SEARCH_TYPE_DATE:
|
|
|
|
gimp_browser_show_message (browser, _("Searching by date"));
|
2005-05-19 06:21:07 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", ".*", ".*", ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", query_text, ".*");
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-10-06 07:31:49 +08:00
|
|
|
case SEARCH_TYPE_PROC_TYPE:
|
|
|
|
gimp_browser_show_message (browser, _("Searching by type"));
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2019-08-13 02:42:27 +08:00
|
|
|
proc_list = gimp_pdb_query_procedures (pdb,
|
|
|
|
".*", ".*", ".*", ".*", ".*",
|
2020-12-24 04:15:43 +08:00
|
|
|
".*", ".*", query_text);
|
2005-10-06 07:31:49 +08:00
|
|
|
break;
|
2005-05-13 23:58:16 +08:00
|
|
|
}
|
|
|
|
|
2020-12-24 04:15:43 +08:00
|
|
|
num_procs = g_strv_length (proc_list);
|
|
|
|
|
2005-07-06 09:51:17 +08:00
|
|
|
if (! query_text || strlen (query_text) == 0)
|
|
|
|
{
|
2005-11-02 22:45:06 +08:00
|
|
|
str = g_strdup_printf (dngettext (GETTEXT_PACKAGE "-libgimp",
|
|
|
|
"%d procedure",
|
|
|
|
"%d procedures",
|
|
|
|
num_procs), num_procs);
|
2005-07-06 09:51:17 +08:00
|
|
|
}
|
2005-05-13 23:58:16 +08:00
|
|
|
else
|
2005-07-06 09:51:17 +08:00
|
|
|
{
|
|
|
|
switch (num_procs)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
str = g_strdup (_("No matches for your query"));
|
|
|
|
break;
|
|
|
|
default:
|
2005-09-02 00:35:49 +08:00
|
|
|
str = g_strdup_printf (dngettext (GETTEXT_PACKAGE "-libgimp",
|
|
|
|
"%d procedure matches your query",
|
|
|
|
"%d procedures match your query",
|
|
|
|
num_procs), num_procs);
|
2005-07-06 09:51:17 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2011-01-01 01:19:37 +08:00
|
|
|
gimp_browser_set_search_summary (browser, str);
|
2005-05-13 23:58:16 +08:00
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
if (num_procs > 0)
|
|
|
|
{
|
2005-05-19 06:21:07 +08:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gint i;
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
priv->store = gtk_list_store_new (N_COLUMNS,
|
2005-08-03 00:49:42 +08:00
|
|
|
G_TYPE_STRING);
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view),
|
|
|
|
GTK_TREE_MODEL (priv->store));
|
|
|
|
g_object_unref (priv->store);
|
2005-05-13 23:58:16 +08:00
|
|
|
|
|
|
|
for (i = 0; i < num_procs; i++)
|
|
|
|
{
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_list_store_append (priv->store, &iter);
|
|
|
|
gtk_list_store_set (priv->store, &iter,
|
2005-05-13 23:58:16 +08:00
|
|
|
COLUMN_PROC_NAME, proc_list[i],
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
2012-11-28 04:16:26 +08:00
|
|
|
g_strfreev (proc_list);
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (priv->tree_view));
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->store),
|
2005-08-03 07:45:24 +08:00
|
|
|
COLUMN_PROC_NAME,
|
|
|
|
GTK_SORT_ASCENDING);
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter);
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
|
2005-05-19 06:21:07 +08:00
|
|
|
gtk_tree_selection_select_iter (selection, &iter);
|
2005-05-13 23:58:16 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-06 20:26:02 +08:00
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), NULL);
|
|
|
|
priv->store = NULL;
|
2005-05-13 23:58:16 +08:00
|
|
|
|
2005-08-03 00:49:42 +08:00
|
|
|
gimp_browser_show_message (browser, _("No matches"));
|
2002-06-14 07:40:55 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|