mirror of https://github.com/GNOME/gimp.git
plug-ins/dbbrowser/Makefile.am plug-ins/dbbrowser/gimpprocbrowser.[ch]
2005-08-02 Michael Natterer <mitch@gimp.org> * plug-ins/dbbrowser/Makefile.am * plug-ins/dbbrowser/gimpprocbrowser.[ch] * plug-ins/dbbrowser/gimpprocview.[ch]: removed these files... * libgimp/Makefile.am * libgimp/gimpui.h * libgimp/gimpui.def * libgimp/gimpprocbrowserdialog.[ch] * libgimp/gimpprocview.[ch]: ...and added them here. Turned the procedure browser into a widget called GimpProcBrowserDialog and changed its API completely. Fixes bug #165009. * plug-ins/dbbrowser/plugin-browser.c * plug-ins/dbbrowser/procedure-browser.c * plug-ins/script-fu/Makefile.am * plug-ins/script-fu/script-fu-console.c: changed accordingly. * plug-ins/pygimp/Makefile.am * plug-ins/pygimp/procbrowser.c: ditto (#if 0'ed stuff so it compiles).
This commit is contained in:
parent
4182c8366f
commit
4d369ec2c0
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
||||||
|
2005-08-02 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/dbbrowser/Makefile.am
|
||||||
|
* plug-ins/dbbrowser/gimpprocbrowser.[ch]
|
||||||
|
* plug-ins/dbbrowser/gimpprocview.[ch]: removed these files...
|
||||||
|
|
||||||
|
* libgimp/Makefile.am
|
||||||
|
* libgimp/gimpui.h
|
||||||
|
* libgimp/gimpui.def
|
||||||
|
* libgimp/gimpprocbrowserdialog.[ch]
|
||||||
|
* libgimp/gimpprocview.[ch]: ...and added them here. Turned the
|
||||||
|
procedure browser into a widget called GimpProcBrowserDialog and
|
||||||
|
changed its API completely. Fixes bug #165009.
|
||||||
|
|
||||||
|
* plug-ins/dbbrowser/plugin-browser.c
|
||||||
|
* plug-ins/dbbrowser/procedure-browser.c
|
||||||
|
* plug-ins/script-fu/Makefile.am
|
||||||
|
* plug-ins/script-fu/script-fu-console.c: changed accordingly.
|
||||||
|
|
||||||
|
* plug-ins/pygimp/Makefile.am
|
||||||
|
* plug-ins/pygimp/procbrowser.c: ditto (#if 0'ed stuff so it compiles).
|
||||||
|
|
||||||
2005-08-02 Sven Neumann <sven@gimp.org>
|
2005-08-02 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/tools/gimpforegroundselectoptions.[ch]
|
* app/tools/gimpforegroundselectoptions.[ch]
|
||||||
|
|
|
@ -233,34 +233,38 @@ libgimpui_2_0_la_sources = \
|
||||||
gimpui.c \
|
gimpui.c \
|
||||||
gimpui.h \
|
gimpui.h \
|
||||||
gimpuitypes.h \
|
gimpuitypes.h \
|
||||||
gimpmenu.c \
|
|
||||||
gimpmenu.h \
|
|
||||||
gimpaspectpreview.c \
|
gimpaspectpreview.c \
|
||||||
gimpaspectpreview.h \
|
gimpaspectpreview.h \
|
||||||
gimpbrushmenu.c \
|
gimpbrushmenu.c \
|
||||||
gimpbrushmenu.h \
|
gimpbrushmenu.h \
|
||||||
|
gimpdrawablecombobox.c \
|
||||||
|
gimpdrawablecombobox.h \
|
||||||
gimpdrawablepreview.c \
|
gimpdrawablepreview.c \
|
||||||
gimpdrawablepreview.h \
|
gimpdrawablepreview.h \
|
||||||
|
gimpexport.c \
|
||||||
|
gimpexport.h \
|
||||||
gimpfontmenu.c \
|
gimpfontmenu.c \
|
||||||
gimpfontmenu.h \
|
gimpfontmenu.h \
|
||||||
gimpfontselectbutton.c \
|
gimpfontselectbutton.c \
|
||||||
gimpfontselectbutton.h \
|
gimpfontselectbutton.h \
|
||||||
gimpgradientmenu.c \
|
gimpgradientmenu.c \
|
||||||
gimpgradientmenu.h \
|
gimpgradientmenu.h \
|
||||||
|
gimpimagecombobox.c \
|
||||||
|
gimpimagecombobox.h \
|
||||||
|
gimpmenu.c \
|
||||||
|
gimpmenu.h \
|
||||||
gimppalettemenu.c \
|
gimppalettemenu.c \
|
||||||
gimppalettemenu.h \
|
gimppalettemenu.h \
|
||||||
gimppatternmenu.c \
|
gimppatternmenu.c \
|
||||||
gimppatternmenu.h \
|
gimppatternmenu.h \
|
||||||
gimpdrawablecombobox.c \
|
|
||||||
gimpdrawablecombobox.h \
|
|
||||||
gimpimagecombobox.c \
|
|
||||||
gimpimagecombobox.h \
|
|
||||||
gimppixbuf.c \
|
gimppixbuf.c \
|
||||||
gimppixbuf.h \
|
gimppixbuf.h \
|
||||||
|
gimpprocbrowserdialog.c \
|
||||||
|
gimpprocbrowserdialog.h \
|
||||||
|
gimpprocview.c \
|
||||||
|
gimpprocview.h \
|
||||||
gimpprogressbar.c \
|
gimpprogressbar.c \
|
||||||
gimpprogressbar.h \
|
gimpprogressbar.h
|
||||||
gimpexport.c \
|
|
||||||
gimpexport.h
|
|
||||||
|
|
||||||
libgimpui_2_0_la_built_sources = \
|
libgimpui_2_0_la_built_sources = \
|
||||||
gimpuimarshal.c \
|
gimpuimarshal.c \
|
||||||
|
@ -304,20 +308,22 @@ gimpinclude_HEADERS = \
|
||||||
\
|
\
|
||||||
gimpui.h \
|
gimpui.h \
|
||||||
gimpuitypes.h \
|
gimpuitypes.h \
|
||||||
gimpmenu.h \
|
|
||||||
gimpaspectpreview.h \
|
gimpaspectpreview.h \
|
||||||
gimpbrushmenu.h \
|
gimpbrushmenu.h \
|
||||||
|
gimpdrawablecombobox.h \
|
||||||
gimpdrawablepreview.h \
|
gimpdrawablepreview.h \
|
||||||
|
gimpexport.h \
|
||||||
gimpfontmenu.h \
|
gimpfontmenu.h \
|
||||||
gimpfontselectbutton.h \
|
gimpfontselectbutton.h \
|
||||||
gimpgradientmenu.h \
|
gimpgradientmenu.h \
|
||||||
|
gimpimagecombobox.h \
|
||||||
|
gimpmenu.h \
|
||||||
gimppalettemenu.h \
|
gimppalettemenu.h \
|
||||||
gimppatternmenu.h \
|
gimppatternmenu.h \
|
||||||
gimppixbuf.h \
|
gimppixbuf.h \
|
||||||
gimpprogressbar.h \
|
gimpprocbrowserdialog.h \
|
||||||
gimpdrawablecombobox.h \
|
gimpprocview.h \
|
||||||
gimpimagecombobox.h \
|
gimpprogressbar.h
|
||||||
gimpexport.h
|
|
||||||
|
|
||||||
libgimp_2_0_la_LDFLAGS = \
|
libgimp_2_0_la_LDFLAGS = \
|
||||||
-version-info $(LT_VERSION_INFO) \
|
-version-info $(LT_VERSION_INFO) \
|
||||||
|
|
|
@ -29,13 +29,15 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <libgimp/gimp.h>
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
#include <libgimp/gimpui.h>
|
|
||||||
|
|
||||||
#include "gimpprocbrowser.h"
|
#include "gimp.h"
|
||||||
|
|
||||||
|
#include "gimpuitypes.h"
|
||||||
|
#include "gimpprocbrowserdialog.h"
|
||||||
#include "gimpprocview.h"
|
#include "gimpprocview.h"
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
#define DBL_LIST_WIDTH 250
|
#define DBL_LIST_WIDTH 250
|
||||||
|
@ -43,6 +45,12 @@
|
||||||
#define DBL_HEIGHT 250
|
#define DBL_HEIGHT 250
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SELECTION_CHANGED,
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SEARCH_TYPE_ALL,
|
SEARCH_TYPE_ALL,
|
||||||
|
@ -62,95 +70,88 @@ enum
|
||||||
N_COLUMNS
|
N_COLUMNS
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
|
|
||||||
GtkWidget *browser;
|
|
||||||
|
|
||||||
GtkListStore *store;
|
|
||||||
GtkTreeView *tree_view;
|
|
||||||
|
|
||||||
/* the currently selected procedure */
|
|
||||||
gchar *proc_name;
|
|
||||||
gchar *proc_blurb;
|
|
||||||
gchar *proc_help;
|
|
||||||
gchar *proc_author;
|
|
||||||
gchar *proc_copyright;
|
|
||||||
gchar *proc_date;
|
|
||||||
GimpPDBProcType proc_type;
|
|
||||||
gint n_params;
|
|
||||||
gint n_return_vals;
|
|
||||||
GimpParamDef *params;
|
|
||||||
GimpParamDef *return_vals;
|
|
||||||
|
|
||||||
gboolean scheme_names;
|
|
||||||
GimpProcBrowserApplyCallback apply_callback;
|
|
||||||
gpointer user_data;
|
|
||||||
} GimpDBBrowser;
|
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
||||||
static void browser_selection_changed (GtkTreeSelection *sel,
|
static void gimp_proc_browser_dialog_class_init (GimpProcBrowserDialogClass *klass);
|
||||||
GimpDBBrowser *browser);
|
static void gimp_proc_browser_dialog_init (GimpProcBrowserDialog *dialog);
|
||||||
static void browser_row_activated (GtkTreeView *treeview,
|
|
||||||
GtkTreePath *path,
|
static void browser_selection_changed (GtkTreeSelection *sel,
|
||||||
GtkTreeViewColumn *column,
|
GimpProcBrowserDialog *dialog);
|
||||||
GimpDBBrowser *browser);
|
static void browser_row_activated (GtkTreeView *treeview,
|
||||||
static void browser_show_procedure (GimpDBBrowser *browser,
|
GtkTreePath *path,
|
||||||
gchar *proc_name);
|
GtkTreeViewColumn *column,
|
||||||
static void browser_search (GimpBrowser *browser,
|
GimpProcBrowserDialog *dialog);
|
||||||
const gchar *query_text,
|
static void browser_show_procedure (GimpProcBrowserDialog *dialog,
|
||||||
gint search_type,
|
const gchar *proc_name);
|
||||||
GimpDBBrowser *db_browser);
|
static void browser_search (GimpBrowser *browser,
|
||||||
static void browser_response (GtkWidget *widget,
|
const gchar *query_text,
|
||||||
gint response_id,
|
gint search_type,
|
||||||
GimpDBBrowser *browser);
|
GimpProcBrowserDialog *dialog);
|
||||||
static void browser_convert_string (gchar *str);
|
static void browser_convert_string (gchar *str);
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
static GimpDialogClass *parent_class = NULL;
|
||||||
|
static guint dialog_signals[LAST_SIGNAL] = { 0, };
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gimp_proc_browser_dialog_new (gboolean scheme_names,
|
GType
|
||||||
GimpProcBrowserApplyCallback apply_callback,
|
gimp_proc_browser_dialog_get_type (void)
|
||||||
gpointer user_data)
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (! type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo info =
|
||||||
|
{
|
||||||
|
sizeof (GimpProcBrowserDialogClass),
|
||||||
|
NULL, /* base_init */
|
||||||
|
NULL, /* base_finalize */
|
||||||
|
(GClassInitFunc) gimp_proc_browser_dialog_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (GimpProcBrowserDialog),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_proc_browser_dialog_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
type = g_type_register_static (GIMP_TYPE_DIALOG,
|
||||||
|
"GimpProcBrowserDialog",
|
||||||
|
&info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_proc_browser_dialog_class_init (GimpProcBrowserDialogClass *klass)
|
||||||
|
{
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
|
||||||
|
dialog_signals[SELECTION_CHANGED] =
|
||||||
|
g_signal_new ("selection-changed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET (GimpProcBrowserDialogClass,
|
||||||
|
selection_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
klass->selection_changed = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_proc_browser_dialog_init (GimpProcBrowserDialog *dialog)
|
||||||
{
|
{
|
||||||
GimpDBBrowser *browser;
|
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
browser = g_new0 (GimpDBBrowser, 1);
|
dialog->scheme_names = FALSE;
|
||||||
|
|
||||||
browser->scheme_names = scheme_names ? TRUE : FALSE;
|
dialog->browser = gimp_browser_new ();
|
||||||
browser->apply_callback = apply_callback;
|
gimp_browser_add_search_types (GIMP_BROWSER (dialog->browser),
|
||||||
browser->user_data = user_data;
|
|
||||||
|
|
||||||
browser->dialog = gimp_dialog_new (_("Procedure Browser"), "dbbrowser",
|
|
||||||
NULL, 0,
|
|
||||||
gimp_standard_help_func,
|
|
||||||
"plug-in-db-browser",
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (apply_callback)
|
|
||||||
{
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (browser->dialog),
|
|
||||||
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (browser->dialog),
|
|
||||||
GTK_RESPONSE_APPLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (browser->dialog),
|
|
||||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
|
|
||||||
|
|
||||||
g_signal_connect (browser->dialog, "response",
|
|
||||||
G_CALLBACK (browser_response),
|
|
||||||
browser);
|
|
||||||
|
|
||||||
browser->browser = gimp_browser_new ();
|
|
||||||
gimp_browser_add_search_types (GIMP_BROWSER (browser->browser),
|
|
||||||
_("by name"), SEARCH_TYPE_NAME,
|
_("by name"), SEARCH_TYPE_NAME,
|
||||||
_("by description"), SEARCH_TYPE_BLURB,
|
_("by description"), SEARCH_TYPE_BLURB,
|
||||||
_("by help"), SEARCH_TYPE_HELP,
|
_("by help"), SEARCH_TYPE_HELP,
|
||||||
|
@ -159,14 +160,14 @@ gimp_proc_browser_dialog_new (gboolean scheme_names,
|
||||||
_("by date"), SEARCH_TYPE_DATE,
|
_("by date"), SEARCH_TYPE_DATE,
|
||||||
_("by type"), SEARCH_TYPE_PROC_TYPE,
|
_("by type"), SEARCH_TYPE_PROC_TYPE,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (browser->browser), 12);
|
gtk_container_set_border_width (GTK_CONTAINER (dialog->browser), 12);
|
||||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (browser->dialog)->vbox),
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
|
||||||
browser->browser);
|
dialog->browser);
|
||||||
gtk_widget_show (browser->browser);
|
gtk_widget_show (dialog->browser);
|
||||||
|
|
||||||
g_signal_connect (browser->browser, "search",
|
g_signal_connect (dialog->browser, "search",
|
||||||
G_CALLBACK (browser_search),
|
G_CALLBACK (browser_search),
|
||||||
browser);
|
dialog);
|
||||||
|
|
||||||
/* list : list in a scrolled_win */
|
/* list : list in a scrolled_win */
|
||||||
|
|
||||||
|
@ -176,73 +177,102 @@ gimp_proc_browser_dialog_new (gboolean scheme_names,
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||||
GTK_POLICY_AUTOMATIC,
|
GTK_POLICY_AUTOMATIC,
|
||||||
GTK_POLICY_ALWAYS);
|
GTK_POLICY_ALWAYS);
|
||||||
gtk_box_pack_start (GTK_BOX (GIMP_BROWSER (browser->browser)->left_vbox),
|
gtk_box_pack_start (GTK_BOX (GIMP_BROWSER (dialog->browser)->left_vbox),
|
||||||
scrolled_window, TRUE, TRUE, 0);
|
scrolled_window, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (scrolled_window);
|
gtk_widget_show (scrolled_window);
|
||||||
|
|
||||||
browser->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
|
dialog->tree_view = gtk_tree_view_new ();
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
gtk_cell_renderer_text_set_fixed_height_from_font
|
gtk_cell_renderer_text_set_fixed_height_from_font
|
||||||
(GTK_CELL_RENDERER_TEXT (renderer), 1);
|
(GTK_CELL_RENDERER_TEXT (renderer), 1);
|
||||||
|
|
||||||
gtk_tree_view_insert_column_with_attributes (browser->tree_view,
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (dialog->tree_view),
|
||||||
-1, NULL,
|
-1, NULL,
|
||||||
renderer,
|
renderer,
|
||||||
"text", 0,
|
"text", 0,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_tree_view_set_headers_visible (browser->tree_view, FALSE);
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->tree_view), FALSE);
|
||||||
|
|
||||||
g_signal_connect (browser->tree_view, "row_activated",
|
g_signal_connect (dialog->tree_view, "row_activated",
|
||||||
G_CALLBACK (browser_row_activated),
|
G_CALLBACK (browser_row_activated),
|
||||||
browser);
|
dialog);
|
||||||
|
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (browser->tree_view),
|
gtk_widget_set_size_request (dialog->tree_view, DBL_LIST_WIDTH, DBL_HEIGHT);
|
||||||
DBL_LIST_WIDTH, DBL_HEIGHT);
|
gtk_container_add (GTK_CONTAINER (scrolled_window), dialog->tree_view);
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window),
|
gtk_widget_show (dialog->tree_view);
|
||||||
GTK_WIDGET (browser->tree_view));
|
|
||||||
gtk_widget_show (GTK_WIDGET (browser->tree_view));
|
|
||||||
|
|
||||||
selection = gtk_tree_view_get_selection (browser->tree_view);
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
|
||||||
|
|
||||||
g_signal_connect (selection, "changed",
|
g_signal_connect (selection, "changed",
|
||||||
G_CALLBACK (browser_selection_changed),
|
G_CALLBACK (browser_selection_changed),
|
||||||
browser);
|
dialog);
|
||||||
|
|
||||||
gtk_widget_set_size_request (GIMP_BROWSER (browser->browser)->right_vbox->parent->parent,
|
gtk_widget_set_size_request (GIMP_BROWSER (dialog->browser)->right_vbox->parent->parent,
|
||||||
DBL_WIDTH - DBL_LIST_WIDTH, -1);
|
DBL_WIDTH - DBL_LIST_WIDTH, -1);
|
||||||
|
}
|
||||||
|
|
||||||
/* now build the list */
|
|
||||||
|
|
||||||
gtk_widget_show (browser->dialog);
|
/* public functions */
|
||||||
|
|
||||||
/* initialize the "return" value (for "apply") */
|
GtkWidget *
|
||||||
|
gimp_proc_browser_dialog_new (gboolean scheme_names,
|
||||||
|
gboolean apply_button)
|
||||||
|
{
|
||||||
|
GimpProcBrowserDialog *dialog;
|
||||||
|
|
||||||
browser->proc_name = NULL;
|
dialog = g_object_new (GIMP_TYPE_PROC_BROWSER_DIALOG, NULL);
|
||||||
browser->proc_blurb = NULL;
|
|
||||||
browser->proc_help = NULL;
|
dialog->scheme_names = scheme_names ? TRUE : FALSE;
|
||||||
browser->proc_author = NULL;
|
|
||||||
browser->proc_copyright = NULL;
|
if (apply_button)
|
||||||
browser->proc_date = NULL;
|
{
|
||||||
browser->proc_type = 0;
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||||
browser->n_params = 0;
|
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
|
||||||
browser->n_return_vals = 0;
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
|
||||||
browser->params = NULL;
|
GTK_RESPONSE_APPLY);
|
||||||
browser->return_vals = NULL;
|
}
|
||||||
|
|
||||||
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||||
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
|
||||||
|
|
||||||
/* first search (all procedures) */
|
/* first search (all procedures) */
|
||||||
browser_search (GIMP_BROWSER (browser->browser), "", SEARCH_TYPE_ALL,
|
browser_search (GIMP_BROWSER (dialog->browser), "", SEARCH_TYPE_ALL,
|
||||||
browser);
|
dialog);
|
||||||
|
|
||||||
return browser->dialog;
|
return GTK_WIDGET (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
|
||||||
|
|
||||||
|
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
||||||
|
{
|
||||||
|
gchar *proc_name;
|
||||||
|
|
||||||
|
gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
|
||||||
|
COLUMN_PROC_NAME, &proc_name,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
return proc_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
browser_selection_changed (GtkTreeSelection *sel,
|
browser_selection_changed (GtkTreeSelection *sel,
|
||||||
GimpDBBrowser *browser)
|
GimpProcBrowserDialog *dialog)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
@ -250,74 +280,89 @@ browser_selection_changed (GtkTreeSelection *sel,
|
||||||
{
|
{
|
||||||
gchar *proc_name;
|
gchar *proc_name;
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (browser->store), &iter,
|
gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &iter,
|
||||||
COLUMN_PROC_NAME, &proc_name,
|
COLUMN_PROC_NAME, &proc_name,
|
||||||
-1);
|
-1);
|
||||||
browser_show_procedure (browser, proc_name);
|
browser_show_procedure (dialog, proc_name);
|
||||||
g_free (proc_name);
|
g_free (proc_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_signal_emit (dialog, dialog_signals[SELECTION_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
browser_row_activated (GtkTreeView *treeview,
|
browser_row_activated (GtkTreeView *treeview,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
GtkTreeViewColumn *column,
|
GtkTreeViewColumn *column,
|
||||||
GimpDBBrowser *browser)
|
GimpProcBrowserDialog *dialog)
|
||||||
{
|
{
|
||||||
browser_response (browser->dialog, GTK_RESPONSE_APPLY, browser);
|
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_APPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
browser_show_procedure (GimpDBBrowser *browser,
|
browser_show_procedure (GimpProcBrowserDialog *dialog,
|
||||||
gchar *proc_name)
|
const gchar *proc_name)
|
||||||
{
|
{
|
||||||
g_free (browser->proc_name);
|
gchar *name;
|
||||||
browser->proc_name = g_strdup (proc_name);
|
gchar *proc_blurb;
|
||||||
|
gchar *proc_help;
|
||||||
|
gchar *proc_author;
|
||||||
|
gchar *proc_copyright;
|
||||||
|
gchar *proc_date;
|
||||||
|
GimpPDBProcType proc_type;
|
||||||
|
gint n_params;
|
||||||
|
gint n_return_vals;
|
||||||
|
GimpParamDef *params;
|
||||||
|
GimpParamDef *return_vals;
|
||||||
|
|
||||||
if (browser->scheme_names)
|
name = g_strdup (proc_name);
|
||||||
browser_convert_string (browser->proc_name);
|
|
||||||
|
|
||||||
g_free (browser->proc_blurb);
|
if (dialog->scheme_names)
|
||||||
g_free (browser->proc_help);
|
browser_convert_string (name);
|
||||||
g_free (browser->proc_author);
|
|
||||||
g_free (browser->proc_copyright);
|
|
||||||
g_free (browser->proc_date);
|
|
||||||
|
|
||||||
gimp_destroy_paramdefs (browser->params, browser->n_params);
|
|
||||||
gimp_destroy_paramdefs (browser->return_vals, browser->n_return_vals);
|
|
||||||
|
|
||||||
gimp_procedural_db_proc_info (proc_name,
|
gimp_procedural_db_proc_info (proc_name,
|
||||||
&browser->proc_blurb,
|
&proc_blurb,
|
||||||
&browser->proc_help,
|
&proc_help,
|
||||||
&browser->proc_author,
|
&proc_author,
|
||||||
&browser->proc_copyright,
|
&proc_copyright,
|
||||||
&browser->proc_date,
|
&proc_date,
|
||||||
&browser->proc_type,
|
&proc_type,
|
||||||
&browser->n_params,
|
&n_params,
|
||||||
&browser->n_return_vals,
|
&n_return_vals,
|
||||||
&browser->params,
|
¶ms,
|
||||||
&browser->return_vals);
|
&return_vals);
|
||||||
|
|
||||||
gimp_browser_set_widget (GIMP_BROWSER (browser->browser),
|
gimp_browser_set_widget (GIMP_BROWSER (dialog->browser),
|
||||||
gimp_proc_view_new (browser->proc_name,
|
gimp_proc_view_new (name,
|
||||||
NULL,
|
NULL,
|
||||||
browser->proc_blurb,
|
proc_blurb,
|
||||||
browser->proc_help,
|
proc_help,
|
||||||
browser->proc_author,
|
proc_author,
|
||||||
browser->proc_copyright,
|
proc_copyright,
|
||||||
browser->proc_date,
|
proc_date,
|
||||||
browser->proc_type,
|
proc_type,
|
||||||
browser->n_params,
|
n_params,
|
||||||
browser->n_return_vals,
|
n_return_vals,
|
||||||
browser->params,
|
params,
|
||||||
browser->return_vals));
|
return_vals));
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
g_free (proc_blurb);
|
||||||
|
g_free (proc_help);
|
||||||
|
g_free (proc_author);
|
||||||
|
g_free (proc_copyright);
|
||||||
|
g_free (proc_date);
|
||||||
|
|
||||||
|
gimp_destroy_paramdefs (params, n_params);
|
||||||
|
gimp_destroy_paramdefs (return_vals, n_return_vals);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
browser_search (GimpBrowser *gimp_browser,
|
browser_search (GimpBrowser *browser,
|
||||||
const gchar *query_text,
|
const gchar *query_text,
|
||||||
gint search_type,
|
gint search_type,
|
||||||
GimpDBBrowser *browser)
|
GimpProcBrowserDialog *dialog)
|
||||||
{
|
{
|
||||||
gchar **proc_list;
|
gchar **proc_list;
|
||||||
gint num_procs;
|
gint num_procs;
|
||||||
|
@ -328,7 +373,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
GString *query = g_string_new ("");
|
GString *query = g_string_new ("");
|
||||||
const gchar *q = query_text;
|
const gchar *q = query_text;
|
||||||
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by name - please wait"));
|
_("Searching by name - please wait"));
|
||||||
|
|
||||||
while (*q)
|
while (*q)
|
||||||
|
@ -348,7 +393,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else if (search_type == SEARCH_TYPE_BLURB)
|
else if (search_type == SEARCH_TYPE_BLURB)
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by description - please wait"));
|
_("Searching by description - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", query_text, ".*", ".*", ".*", ".*", ".*",
|
gimp_procedural_db_query (".*", query_text, ".*", ".*", ".*", ".*", ".*",
|
||||||
|
@ -356,7 +401,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else if (search_type == SEARCH_TYPE_HELP)
|
else if (search_type == SEARCH_TYPE_HELP)
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by help - please wait"));
|
_("Searching by help - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", query_text, ".*", ".*", ".*", ".*",
|
gimp_procedural_db_query (".*", ".*", query_text, ".*", ".*", ".*", ".*",
|
||||||
|
@ -364,7 +409,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else if (search_type == SEARCH_TYPE_AUTHOR)
|
else if (search_type == SEARCH_TYPE_AUTHOR)
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by author - please wait"));
|
_("Searching by author - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", query_text, ".*", ".*", ".*",
|
gimp_procedural_db_query (".*", ".*", ".*", query_text, ".*", ".*", ".*",
|
||||||
|
@ -372,7 +417,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else if (search_type == SEARCH_TYPE_COPYRIGHT)
|
else if (search_type == SEARCH_TYPE_COPYRIGHT)
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by copyright - please wait"));
|
_("Searching by copyright - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", query_text, ".*", ".*",
|
gimp_procedural_db_query (".*", ".*", ".*", ".*", query_text, ".*", ".*",
|
||||||
|
@ -380,7 +425,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else if (search_type == SEARCH_TYPE_DATE)
|
else if (search_type == SEARCH_TYPE_DATE)
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by date - please wait"));
|
_("Searching by date - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", query_text, ".*",
|
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", query_text, ".*",
|
||||||
|
@ -388,7 +433,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else if (search_type == SEARCH_TYPE_PROC_TYPE)
|
else if (search_type == SEARCH_TYPE_PROC_TYPE)
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching by type - please wait"));
|
_("Searching by type - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", query_text,
|
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", query_text,
|
||||||
|
@ -396,7 +441,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser,
|
||||||
_("Searching - please wait"));
|
_("Searching - please wait"));
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
||||||
|
@ -424,7 +469,7 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (gimp_browser->count_label), str);
|
gtk_label_set_text (GTK_LABEL (browser->count_label), str);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
if (num_procs > 0)
|
if (num_procs > 0)
|
||||||
|
@ -433,22 +478,22 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
browser->store = gtk_list_store_new (N_COLUMNS,
|
dialog->store = gtk_list_store_new (N_COLUMNS,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
gtk_tree_view_set_model (browser->tree_view,
|
gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view),
|
||||||
GTK_TREE_MODEL (browser->store));
|
GTK_TREE_MODEL (dialog->store));
|
||||||
g_object_unref (browser->store);
|
g_object_unref (dialog->store);
|
||||||
|
|
||||||
for (i = 0; i < num_procs; i++)
|
for (i = 0; i < num_procs; i++)
|
||||||
{
|
{
|
||||||
str = g_strdup (proc_list[i]);
|
str = g_strdup (proc_list[i]);
|
||||||
|
|
||||||
if (browser->scheme_names)
|
if (dialog->scheme_names)
|
||||||
browser_convert_string (str);
|
browser_convert_string (str);
|
||||||
|
|
||||||
gtk_list_store_append (browser->store, &iter);
|
gtk_list_store_append (dialog->store, &iter);
|
||||||
gtk_list_store_set (browser->store, &iter,
|
gtk_list_store_set (dialog->store, &iter,
|
||||||
COLUMN_LABEL, str,
|
COLUMN_LABEL, str,
|
||||||
COLUMN_PROC_NAME, proc_list[i],
|
COLUMN_PROC_NAME, proc_list[i],
|
||||||
-1);
|
-1);
|
||||||
|
@ -459,64 +504,21 @@ browser_search (GimpBrowser *gimp_browser,
|
||||||
|
|
||||||
g_free (proc_list);
|
g_free (proc_list);
|
||||||
|
|
||||||
gtk_tree_view_columns_autosize (browser->tree_view);
|
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (dialog->tree_view));
|
||||||
|
|
||||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser->store),
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->store),
|
||||||
COLUMN_LABEL, GTK_SORT_ASCENDING);
|
COLUMN_LABEL, GTK_SORT_ASCENDING);
|
||||||
|
|
||||||
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (browser->store), &iter);
|
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &iter);
|
||||||
selection = gtk_tree_view_get_selection (browser->tree_view);
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view));
|
||||||
gtk_tree_selection_select_iter (selection, &iter);
|
gtk_tree_selection_select_iter (selection, &iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_tree_view_set_model (browser->tree_view, NULL);
|
gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view), NULL);
|
||||||
browser->store = NULL;
|
dialog->store = NULL;
|
||||||
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
gimp_browser_show_message (browser, _("No matches"));
|
||||||
_("No matches"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_response (GtkWidget *widget,
|
|
||||||
gint response_id,
|
|
||||||
GimpDBBrowser *browser)
|
|
||||||
{
|
|
||||||
switch (response_id)
|
|
||||||
{
|
|
||||||
case GTK_RESPONSE_APPLY:
|
|
||||||
if (browser->apply_callback)
|
|
||||||
browser->apply_callback (browser->proc_name,
|
|
||||||
browser->proc_blurb,
|
|
||||||
browser->proc_help,
|
|
||||||
browser->proc_author,
|
|
||||||
browser->proc_copyright,
|
|
||||||
browser->proc_date,
|
|
||||||
browser->proc_type,
|
|
||||||
browser->n_params,
|
|
||||||
browser->n_return_vals,
|
|
||||||
browser->params,
|
|
||||||
browser->return_vals,
|
|
||||||
browser->user_data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (browser->apply_callback)
|
|
||||||
{
|
|
||||||
/* we are called by another application:
|
|
||||||
* just destroy the dialog box
|
|
||||||
*/
|
|
||||||
gtk_widget_destroy (browser->dialog);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* we are in the plug_in:
|
|
||||||
* quit the gtk application
|
|
||||||
*/
|
|
||||||
gtk_main_quit ();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* gimpprocbrowserdialog.h
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dbbrowser_utils.h
|
||||||
|
* 0.08 26th sept 97 by Thomas NOEL <thomas@minet.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_PROC_BROWSER_DIALOG_H__
|
||||||
|
#define __GIMP_PROC_BROWSER_DIALOG_H__
|
||||||
|
|
||||||
|
#include <libgimpwidgets/gimpdialog.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_PROC_BROWSER_DIALOG (gimp_proc_browser_dialog_get_type ())
|
||||||
|
#define GIMP_PROC_BROWSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PROC_BROWSER_DIALOG, GimpProcBrowserDialog))
|
||||||
|
#define GIMP_PROC_BROWSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PROC_BROWSER_DIALOG, GimpProcBrowserDialogClass))
|
||||||
|
#define GIMP_IS_PROC_BROWSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PROC_BROWSER_DIALOG))
|
||||||
|
#define GIMP_IS_PROC_BROWSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PROC_BROWSER_DIALOG))
|
||||||
|
#define GIMP_PROC_BROWSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PROC_BROWSER_DIALOG, GimpProcBrowserDialogClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpProcBrowserDialog GimpProcBrowserDialog;
|
||||||
|
typedef struct _GimpProcBrowserDialogClass GimpProcBrowserDialogClass;
|
||||||
|
|
||||||
|
struct _GimpProcBrowserDialog
|
||||||
|
{
|
||||||
|
GimpDialog parent_instance;
|
||||||
|
|
||||||
|
gboolean scheme_names;
|
||||||
|
|
||||||
|
GtkWidget *browser;
|
||||||
|
|
||||||
|
GtkListStore *store;
|
||||||
|
GtkWidget *tree_view;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpProcBrowserDialogClass
|
||||||
|
{
|
||||||
|
GimpDialogClass parent_class;
|
||||||
|
|
||||||
|
void (* selection_changed) (GimpProcBrowserDialog *dialog);
|
||||||
|
|
||||||
|
/* Padding for future expansion */
|
||||||
|
void (* _gimp_reserved1) (void);
|
||||||
|
void (* _gimp_reserved2) (void);
|
||||||
|
void (* _gimp_reserved3) (void);
|
||||||
|
void (* _gimp_reserved4) (void);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_proc_browser_dialog_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GtkWidget * gimp_proc_browser_dialog_new (gboolean scheme_names,
|
||||||
|
gboolean apply_button);
|
||||||
|
|
||||||
|
gchar * gimp_proc_browser_dialog_get_selected (GimpProcBrowserDialog *dialog);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_PROC_BROWSER_DIALOG_H__ */
|
|
@ -29,12 +29,14 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <libgimp/gimp.h>
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
#include <libgimp/gimpui.h>
|
|
||||||
|
|
||||||
|
#include "gimp.h"
|
||||||
|
|
||||||
|
#include "gimpuitypes.h"
|
||||||
#include "gimpprocview.h"
|
#include "gimpprocview.h"
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
|
|
|
@ -37,6 +37,10 @@ EXPORTS
|
||||||
gimp_pattern_select_widget_close
|
gimp_pattern_select_widget_close
|
||||||
gimp_pattern_select_widget_new
|
gimp_pattern_select_widget_new
|
||||||
gimp_pattern_select_widget_set
|
gimp_pattern_select_widget_set
|
||||||
|
gimp_proc_browser_dialog_get_type
|
||||||
|
gimp_proc_browser_dialog_new
|
||||||
|
gimp_proc_browser_dialog_get_selected
|
||||||
|
gimp_proc_view_new
|
||||||
gimp_progress_bar_get_type
|
gimp_progress_bar_get_type
|
||||||
gimp_progress_bar_new
|
gimp_progress_bar_new
|
||||||
gimp_ui_init
|
gimp_ui_init
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include <libgimp/gimppalettemenu.h>
|
#include <libgimp/gimppalettemenu.h>
|
||||||
#include <libgimp/gimppatternmenu.h>
|
#include <libgimp/gimppatternmenu.h>
|
||||||
#include <libgimp/gimppixbuf.h>
|
#include <libgimp/gimppixbuf.h>
|
||||||
|
#include <libgimp/gimpprocbrowserdialog.h>
|
||||||
|
#include <libgimp/gimpprocview.h>
|
||||||
#include <libgimp/gimpprogressbar.h>
|
#include <libgimp/gimpprogressbar.h>
|
||||||
#include <libgimp/gimpdrawablecombobox.h>
|
#include <libgimp/gimpdrawablecombobox.h>
|
||||||
#include <libgimp/gimpimagecombobox.h>
|
#include <libgimp/gimpimagecombobox.h>
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include <libgimp/gimp.h>
|
#include <libgimp/gimp.h>
|
||||||
#include <libgimp/gimpui.h>
|
#include <libgimp/gimpui.h>
|
||||||
|
|
||||||
#include "gimpprocview.h"
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,6 @@
|
||||||
#include <libgimp/gimp.h>
|
#include <libgimp/gimp.h>
|
||||||
#include <libgimp/gimpui.h>
|
#include <libgimp/gimpui.h>
|
||||||
|
|
||||||
#include "gimpprocbrowser.h"
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,13 +113,13 @@ run (const gchar *name,
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
{
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
gimp_ui_init ("dbbrowser", FALSE);
|
gimp_ui_init ("dbbrowser", FALSE);
|
||||||
|
|
||||||
gtk_quit_add_destroy (1, (GtkObject *)
|
dialog = gimp_proc_browser_dialog_new (FALSE, FALSE);
|
||||||
gimp_proc_browser_dialog_new (FALSE, NULL, NULL));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
gtk_main ();
|
|
||||||
gdk_flush ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,8 @@ AM_LDFLAGS = $(mwindows)
|
||||||
|
|
||||||
libexecdir = $(gimpplugindir)/plug-ins
|
libexecdir = $(gimpplugindir)/plug-ins
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libgimpprocbrowser.la
|
|
||||||
libexec_PROGRAMS = plugin-browser procedure-browser
|
libexec_PROGRAMS = plugin-browser procedure-browser
|
||||||
|
|
||||||
libgimpprocbrowser_la_SOURCES = \
|
|
||||||
gimpprocbrowser.c \
|
|
||||||
gimpprocbrowser.h \
|
|
||||||
gimpprocview.c \
|
|
||||||
gimpprocview.h
|
|
||||||
|
|
||||||
plugin_browser_SOURCES = \
|
plugin_browser_SOURCES = \
|
||||||
plugin-browser.c
|
plugin-browser.c
|
||||||
|
|
||||||
|
@ -40,7 +33,6 @@ INCLUDES = \
|
||||||
-I$(includedir)
|
-I$(includedir)
|
||||||
|
|
||||||
LDADD = \
|
LDADD = \
|
||||||
libgimpprocbrowser.la \
|
|
||||||
$(libgimpui) \
|
$(libgimpui) \
|
||||||
$(libgimpwidgets) \
|
$(libgimpwidgets) \
|
||||||
$(libgimpconfig) \
|
$(libgimpconfig) \
|
||||||
|
|
|
@ -1,533 +0,0 @@
|
||||||
/* The GIMP -- an image manipulation program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* dbbrowser_utils.c
|
|
||||||
* 0.08 26th sept 97 by Thomas NOEL <thomas@minet.net>
|
|
||||||
*
|
|
||||||
* 98/12/13 Sven Neumann <sven@gimp.org> : added help display
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include <libgimp/gimp.h>
|
|
||||||
#include <libgimp/gimpui.h>
|
|
||||||
|
|
||||||
#include "gimpprocbrowser.h"
|
|
||||||
#include "gimpprocview.h"
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define DBL_LIST_WIDTH 250
|
|
||||||
#define DBL_WIDTH (DBL_LIST_WIDTH + 400)
|
|
||||||
#define DBL_HEIGHT 250
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SEARCH_TYPE_ALL,
|
|
||||||
SEARCH_TYPE_NAME,
|
|
||||||
SEARCH_TYPE_BLURB,
|
|
||||||
SEARCH_TYPE_HELP,
|
|
||||||
SEARCH_TYPE_AUTHOR,
|
|
||||||
SEARCH_TYPE_COPYRIGHT,
|
|
||||||
SEARCH_TYPE_DATE,
|
|
||||||
SEARCH_TYPE_PROC_TYPE
|
|
||||||
} SearchType;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
COLUMN_LABEL,
|
|
||||||
COLUMN_PROC_NAME,
|
|
||||||
N_COLUMNS
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GtkWidget *dialog;
|
|
||||||
|
|
||||||
GtkWidget *browser;
|
|
||||||
|
|
||||||
GtkListStore *store;
|
|
||||||
GtkTreeView *tree_view;
|
|
||||||
|
|
||||||
/* the currently selected procedure */
|
|
||||||
gchar *proc_name;
|
|
||||||
gchar *proc_blurb;
|
|
||||||
gchar *proc_help;
|
|
||||||
gchar *proc_author;
|
|
||||||
gchar *proc_copyright;
|
|
||||||
gchar *proc_date;
|
|
||||||
GimpPDBProcType proc_type;
|
|
||||||
gint n_params;
|
|
||||||
gint n_return_vals;
|
|
||||||
GimpParamDef *params;
|
|
||||||
GimpParamDef *return_vals;
|
|
||||||
|
|
||||||
gboolean scheme_names;
|
|
||||||
GimpProcBrowserApplyCallback apply_callback;
|
|
||||||
gpointer user_data;
|
|
||||||
} GimpDBBrowser;
|
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
|
||||||
|
|
||||||
static void browser_selection_changed (GtkTreeSelection *sel,
|
|
||||||
GimpDBBrowser *browser);
|
|
||||||
static void browser_row_activated (GtkTreeView *treeview,
|
|
||||||
GtkTreePath *path,
|
|
||||||
GtkTreeViewColumn *column,
|
|
||||||
GimpDBBrowser *browser);
|
|
||||||
static void browser_show_procedure (GimpDBBrowser *browser,
|
|
||||||
gchar *proc_name);
|
|
||||||
static void browser_search (GimpBrowser *browser,
|
|
||||||
const gchar *query_text,
|
|
||||||
gint search_type,
|
|
||||||
GimpDBBrowser *db_browser);
|
|
||||||
static void browser_response (GtkWidget *widget,
|
|
||||||
gint response_id,
|
|
||||||
GimpDBBrowser *browser);
|
|
||||||
static void browser_convert_string (gchar *str);
|
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gimp_proc_browser_dialog_new (gboolean scheme_names,
|
|
||||||
GimpProcBrowserApplyCallback apply_callback,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GimpDBBrowser *browser;
|
|
||||||
GtkWidget *scrolled_window;
|
|
||||||
GtkCellRenderer *renderer;
|
|
||||||
GtkTreeSelection *selection;
|
|
||||||
|
|
||||||
browser = g_new0 (GimpDBBrowser, 1);
|
|
||||||
|
|
||||||
browser->scheme_names = scheme_names ? TRUE : FALSE;
|
|
||||||
browser->apply_callback = apply_callback;
|
|
||||||
browser->user_data = user_data;
|
|
||||||
|
|
||||||
browser->dialog = gimp_dialog_new (_("Procedure Browser"), "dbbrowser",
|
|
||||||
NULL, 0,
|
|
||||||
gimp_standard_help_func,
|
|
||||||
"plug-in-db-browser",
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (apply_callback)
|
|
||||||
{
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (browser->dialog),
|
|
||||||
GTK_STOCK_APPLY, GTK_RESPONSE_APPLY);
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (browser->dialog),
|
|
||||||
GTK_RESPONSE_APPLY);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (browser->dialog),
|
|
||||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
|
|
||||||
|
|
||||||
g_signal_connect (browser->dialog, "response",
|
|
||||||
G_CALLBACK (browser_response),
|
|
||||||
browser);
|
|
||||||
|
|
||||||
browser->browser = gimp_browser_new ();
|
|
||||||
gimp_browser_add_search_types (GIMP_BROWSER (browser->browser),
|
|
||||||
_("by name"), SEARCH_TYPE_NAME,
|
|
||||||
_("by description"), SEARCH_TYPE_BLURB,
|
|
||||||
_("by help"), SEARCH_TYPE_HELP,
|
|
||||||
_("by author"), SEARCH_TYPE_AUTHOR,
|
|
||||||
_("by copyright"), SEARCH_TYPE_COPYRIGHT,
|
|
||||||
_("by date"), SEARCH_TYPE_DATE,
|
|
||||||
_("by type"), SEARCH_TYPE_PROC_TYPE,
|
|
||||||
NULL);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (browser->browser), 12);
|
|
||||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (browser->dialog)->vbox),
|
|
||||||
browser->browser);
|
|
||||||
gtk_widget_show (browser->browser);
|
|
||||||
|
|
||||||
g_signal_connect (browser->browser, "search",
|
|
||||||
G_CALLBACK (browser_search),
|
|
||||||
browser);
|
|
||||||
|
|
||||||
/* list : list in a scrolled_win */
|
|
||||||
|
|
||||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
||||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
||||||
GTK_SHADOW_IN);
|
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
||||||
GTK_POLICY_AUTOMATIC,
|
|
||||||
GTK_POLICY_ALWAYS);
|
|
||||||
gtk_box_pack_start (GTK_BOX (GIMP_BROWSER (browser->browser)->left_vbox),
|
|
||||||
scrolled_window, TRUE, TRUE, 0);
|
|
||||||
gtk_widget_show (scrolled_window);
|
|
||||||
|
|
||||||
browser->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
|
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
|
||||||
gtk_cell_renderer_text_set_fixed_height_from_font
|
|
||||||
(GTK_CELL_RENDERER_TEXT (renderer), 1);
|
|
||||||
|
|
||||||
gtk_tree_view_insert_column_with_attributes (browser->tree_view,
|
|
||||||
-1, NULL,
|
|
||||||
renderer,
|
|
||||||
"text", 0,
|
|
||||||
NULL);
|
|
||||||
gtk_tree_view_set_headers_visible (browser->tree_view, FALSE);
|
|
||||||
|
|
||||||
g_signal_connect (browser->tree_view, "row_activated",
|
|
||||||
G_CALLBACK (browser_row_activated),
|
|
||||||
browser);
|
|
||||||
|
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (browser->tree_view),
|
|
||||||
DBL_LIST_WIDTH, DBL_HEIGHT);
|
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window),
|
|
||||||
GTK_WIDGET (browser->tree_view));
|
|
||||||
gtk_widget_show (GTK_WIDGET (browser->tree_view));
|
|
||||||
|
|
||||||
selection = gtk_tree_view_get_selection (browser->tree_view);
|
|
||||||
|
|
||||||
g_signal_connect (selection, "changed",
|
|
||||||
G_CALLBACK (browser_selection_changed),
|
|
||||||
browser);
|
|
||||||
|
|
||||||
gtk_widget_set_size_request (GIMP_BROWSER (browser->browser)->right_vbox->parent->parent,
|
|
||||||
DBL_WIDTH - DBL_LIST_WIDTH, -1);
|
|
||||||
|
|
||||||
/* now build the list */
|
|
||||||
|
|
||||||
gtk_widget_show (browser->dialog);
|
|
||||||
|
|
||||||
/* initialize the "return" value (for "apply") */
|
|
||||||
|
|
||||||
browser->proc_name = NULL;
|
|
||||||
browser->proc_blurb = NULL;
|
|
||||||
browser->proc_help = NULL;
|
|
||||||
browser->proc_author = NULL;
|
|
||||||
browser->proc_copyright = NULL;
|
|
||||||
browser->proc_date = NULL;
|
|
||||||
browser->proc_type = 0;
|
|
||||||
browser->n_params = 0;
|
|
||||||
browser->n_return_vals = 0;
|
|
||||||
browser->params = NULL;
|
|
||||||
browser->return_vals = NULL;
|
|
||||||
|
|
||||||
/* first search (all procedures) */
|
|
||||||
browser_search (GIMP_BROWSER (browser->browser), "", SEARCH_TYPE_ALL,
|
|
||||||
browser);
|
|
||||||
|
|
||||||
return browser->dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_selection_changed (GtkTreeSelection *sel,
|
|
||||||
GimpDBBrowser *browser)
|
|
||||||
{
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
|
||||||
{
|
|
||||||
gchar *proc_name;
|
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (browser->store), &iter,
|
|
||||||
COLUMN_PROC_NAME, &proc_name,
|
|
||||||
-1);
|
|
||||||
browser_show_procedure (browser, proc_name);
|
|
||||||
g_free (proc_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_row_activated (GtkTreeView *treeview,
|
|
||||||
GtkTreePath *path,
|
|
||||||
GtkTreeViewColumn *column,
|
|
||||||
GimpDBBrowser *browser)
|
|
||||||
{
|
|
||||||
browser_response (browser->dialog, GTK_RESPONSE_APPLY, browser);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_show_procedure (GimpDBBrowser *browser,
|
|
||||||
gchar *proc_name)
|
|
||||||
{
|
|
||||||
g_free (browser->proc_name);
|
|
||||||
browser->proc_name = g_strdup (proc_name);
|
|
||||||
|
|
||||||
if (browser->scheme_names)
|
|
||||||
browser_convert_string (browser->proc_name);
|
|
||||||
|
|
||||||
g_free (browser->proc_blurb);
|
|
||||||
g_free (browser->proc_help);
|
|
||||||
g_free (browser->proc_author);
|
|
||||||
g_free (browser->proc_copyright);
|
|
||||||
g_free (browser->proc_date);
|
|
||||||
|
|
||||||
gimp_destroy_paramdefs (browser->params, browser->n_params);
|
|
||||||
gimp_destroy_paramdefs (browser->return_vals, browser->n_return_vals);
|
|
||||||
|
|
||||||
gimp_procedural_db_proc_info (proc_name,
|
|
||||||
&browser->proc_blurb,
|
|
||||||
&browser->proc_help,
|
|
||||||
&browser->proc_author,
|
|
||||||
&browser->proc_copyright,
|
|
||||||
&browser->proc_date,
|
|
||||||
&browser->proc_type,
|
|
||||||
&browser->n_params,
|
|
||||||
&browser->n_return_vals,
|
|
||||||
&browser->params,
|
|
||||||
&browser->return_vals);
|
|
||||||
|
|
||||||
gimp_browser_set_widget (GIMP_BROWSER (browser->browser),
|
|
||||||
gimp_proc_view_new (browser->proc_name,
|
|
||||||
NULL,
|
|
||||||
browser->proc_blurb,
|
|
||||||
browser->proc_help,
|
|
||||||
browser->proc_author,
|
|
||||||
browser->proc_copyright,
|
|
||||||
browser->proc_date,
|
|
||||||
browser->proc_type,
|
|
||||||
browser->n_params,
|
|
||||||
browser->n_return_vals,
|
|
||||||
browser->params,
|
|
||||||
browser->return_vals));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_search (GimpBrowser *gimp_browser,
|
|
||||||
const gchar *query_text,
|
|
||||||
gint search_type,
|
|
||||||
GimpDBBrowser *browser)
|
|
||||||
{
|
|
||||||
gchar **proc_list;
|
|
||||||
gint num_procs;
|
|
||||||
gchar *str;
|
|
||||||
|
|
||||||
if (search_type == SEARCH_TYPE_NAME)
|
|
||||||
{
|
|
||||||
GString *query = g_string_new ("");
|
|
||||||
const gchar *q = query_text;
|
|
||||||
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by name - please wait"));
|
|
||||||
|
|
||||||
while (*q)
|
|
||||||
{
|
|
||||||
if ((*q == '_') || (*q == '-'))
|
|
||||||
g_string_append (query, "[-_]");
|
|
||||||
else
|
|
||||||
g_string_append_c (query, *q);
|
|
||||||
|
|
||||||
q++;
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_procedural_db_query (query->str, ".*", ".*", ".*", ".*", ".*", ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
|
|
||||||
g_string_free (query, TRUE);
|
|
||||||
}
|
|
||||||
else if (search_type == SEARCH_TYPE_BLURB)
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by description - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", query_text, ".*", ".*", ".*", ".*", ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
else if (search_type == SEARCH_TYPE_HELP)
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by help - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", query_text, ".*", ".*", ".*", ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
else if (search_type == SEARCH_TYPE_AUTHOR)
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by author - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", query_text, ".*", ".*", ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
else if (search_type == SEARCH_TYPE_COPYRIGHT)
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by copyright - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", query_text, ".*", ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
else if (search_type == SEARCH_TYPE_DATE)
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by date - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", query_text, ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
else if (search_type == SEARCH_TYPE_PROC_TYPE)
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching by type - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", query_text,
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("Searching - please wait"));
|
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
|
||||||
&num_procs, &proc_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! query_text || strlen (query_text) == 0)
|
|
||||||
{
|
|
||||||
str = g_strdup_printf (_("%d Procedures"), num_procs);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (num_procs)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
str = g_strdup (_("No matches for your query"));
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
str = g_strdup (_("1 procedure matches your query"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
str = g_strdup_printf (_("%d procedures match your query"),
|
|
||||||
num_procs);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_label_set_text (GTK_LABEL (gimp_browser->count_label), str);
|
|
||||||
g_free (str);
|
|
||||||
|
|
||||||
if (num_procs > 0)
|
|
||||||
{
|
|
||||||
GtkTreeSelection *selection;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
browser->store = gtk_list_store_new (N_COLUMNS,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
gtk_tree_view_set_model (browser->tree_view,
|
|
||||||
GTK_TREE_MODEL (browser->store));
|
|
||||||
g_object_unref (browser->store);
|
|
||||||
|
|
||||||
for (i = 0; i < num_procs; i++)
|
|
||||||
{
|
|
||||||
str = g_strdup (proc_list[i]);
|
|
||||||
|
|
||||||
if (browser->scheme_names)
|
|
||||||
browser_convert_string (str);
|
|
||||||
|
|
||||||
gtk_list_store_append (browser->store, &iter);
|
|
||||||
gtk_list_store_set (browser->store, &iter,
|
|
||||||
COLUMN_LABEL, str,
|
|
||||||
COLUMN_PROC_NAME, proc_list[i],
|
|
||||||
-1);
|
|
||||||
|
|
||||||
g_free (str);
|
|
||||||
g_free (proc_list[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (proc_list);
|
|
||||||
|
|
||||||
gtk_tree_view_columns_autosize (browser->tree_view);
|
|
||||||
|
|
||||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser->store),
|
|
||||||
COLUMN_LABEL, GTK_SORT_ASCENDING);
|
|
||||||
|
|
||||||
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (browser->store), &iter);
|
|
||||||
selection = gtk_tree_view_get_selection (browser->tree_view);
|
|
||||||
gtk_tree_selection_select_iter (selection, &iter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_tree_view_set_model (browser->tree_view, NULL);
|
|
||||||
browser->store = NULL;
|
|
||||||
|
|
||||||
gimp_browser_show_message (GIMP_BROWSER (browser->browser),
|
|
||||||
_("No matches"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_response (GtkWidget *widget,
|
|
||||||
gint response_id,
|
|
||||||
GimpDBBrowser *browser)
|
|
||||||
{
|
|
||||||
switch (response_id)
|
|
||||||
{
|
|
||||||
case GTK_RESPONSE_APPLY:
|
|
||||||
if (browser->apply_callback)
|
|
||||||
browser->apply_callback (browser->proc_name,
|
|
||||||
browser->proc_blurb,
|
|
||||||
browser->proc_help,
|
|
||||||
browser->proc_author,
|
|
||||||
browser->proc_copyright,
|
|
||||||
browser->proc_date,
|
|
||||||
browser->proc_type,
|
|
||||||
browser->n_params,
|
|
||||||
browser->n_return_vals,
|
|
||||||
browser->params,
|
|
||||||
browser->return_vals,
|
|
||||||
browser->user_data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (browser->apply_callback)
|
|
||||||
{
|
|
||||||
/* we are called by another application:
|
|
||||||
* just destroy the dialog box
|
|
||||||
*/
|
|
||||||
gtk_widget_destroy (browser->dialog);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* we are in the plug_in:
|
|
||||||
* quit the gtk application
|
|
||||||
*/
|
|
||||||
gtk_main_quit ();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
browser_convert_string (gchar *str)
|
|
||||||
{
|
|
||||||
while (*str)
|
|
||||||
{
|
|
||||||
if (*str == '_')
|
|
||||||
*str = '-';
|
|
||||||
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/* The GIMP -- an image manipulation program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* dbbrowser_utils.h
|
|
||||||
* 0.08 26th sept 97 by Thomas NOEL <thomas@minet.net>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GIMP_PROC_BROWSER_H__
|
|
||||||
#define __GIMP_PROC_BROWSER_H__
|
|
||||||
|
|
||||||
|
|
||||||
typedef void (* GimpProcBrowserApplyCallback) (const gchar *proc_name,
|
|
||||||
const gchar *proc_blurb,
|
|
||||||
const gchar *proc_help,
|
|
||||||
const gchar *proc_author,
|
|
||||||
const gchar *proc_copyright,
|
|
||||||
const gchar *proc_date,
|
|
||||||
GimpPDBProcType proc_type,
|
|
||||||
gint n_params,
|
|
||||||
gint n_return_vals,
|
|
||||||
const GimpParamDef *params,
|
|
||||||
const GimpParamDef *return_vals,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget * gimp_proc_browser_dialog_new (gboolean scheme_names,
|
|
||||||
GimpProcBrowserApplyCallback apply_callback,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_PROC_BROWSER_H__ */
|
|
|
@ -1,299 +0,0 @@
|
||||||
/* The GIMP -- an image manipulation program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* dbbrowser_utils.c
|
|
||||||
* 0.08 26th sept 97 by Thomas NOEL <thomas@minet.net>
|
|
||||||
*
|
|
||||||
* 98/12/13 Sven Neumann <sven@gimp.org> : added help display
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#include <libgimp/gimp.h>
|
|
||||||
#include <libgimp/gimpui.h>
|
|
||||||
|
|
||||||
#include "gimpprocview.h"
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* local function prototypes */
|
|
||||||
|
|
||||||
static GtkWidget * gimp_proc_view_create_params (GimpParamDef *params,
|
|
||||||
gint n_params,
|
|
||||||
GtkSizeGroup *name_group,
|
|
||||||
GtkSizeGroup *type_group,
|
|
||||||
GtkSizeGroup *desc_group);
|
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gimp_proc_view_new (const gchar *name,
|
|
||||||
const gchar *menu_path,
|
|
||||||
const gchar *blurb,
|
|
||||||
const gchar *help,
|
|
||||||
const gchar *author,
|
|
||||||
const gchar *copyright,
|
|
||||||
const gchar *date,
|
|
||||||
GimpPDBProcType type,
|
|
||||||
gint n_params,
|
|
||||||
gint n_return_vals,
|
|
||||||
GimpParamDef *params,
|
|
||||||
GimpParamDef *return_vals)
|
|
||||||
{
|
|
||||||
GtkWidget *main_vbox;
|
|
||||||
GtkWidget *frame;
|
|
||||||
GtkWidget *vbox;
|
|
||||||
GtkWidget *table;
|
|
||||||
GtkWidget *label;
|
|
||||||
GtkSizeGroup *name_group;
|
|
||||||
GtkSizeGroup *type_group;
|
|
||||||
GtkSizeGroup *desc_group;
|
|
||||||
const gchar *type_str;
|
|
||||||
gint row;
|
|
||||||
|
|
||||||
if (blurb && strlen (blurb) < 2) blurb = NULL;
|
|
||||||
if (help && strlen (help) < 2) help = NULL;
|
|
||||||
if (author && strlen (author) < 2) author = NULL;
|
|
||||||
if (date && strlen (date) < 2) date = NULL;
|
|
||||||
if (copyright && strlen (copyright) < 2) copyright = NULL;
|
|
||||||
|
|
||||||
if (blurb && help && ! strcmp (blurb, help))
|
|
||||||
help = NULL;
|
|
||||||
|
|
||||||
main_vbox = gtk_vbox_new (FALSE, 12);
|
|
||||||
|
|
||||||
/* show the name */
|
|
||||||
|
|
||||||
frame = gimp_frame_new (name);
|
|
||||||
label = gtk_frame_get_label_widget (GTK_FRAME (frame));
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (frame);
|
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, 8);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
||||||
gtk_widget_show (vbox);
|
|
||||||
|
|
||||||
if (! gimp_enum_get_value (GIMP_TYPE_PDB_PROC_TYPE, type,
|
|
||||||
NULL, NULL, &type_str, NULL))
|
|
||||||
type_str = "UNKNOWN";
|
|
||||||
|
|
||||||
label = gtk_label_new (type_str);
|
|
||||||
gimp_label_set_attributes (GTK_LABEL (label),
|
|
||||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
||||||
-1);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
|
|
||||||
if (menu_path)
|
|
||||||
{
|
|
||||||
label = gtk_label_new_with_mnemonic (menu_path);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blurb)
|
|
||||||
{
|
|
||||||
label = gtk_label_new (blurb);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
}
|
|
||||||
|
|
||||||
name_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
||||||
type_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
||||||
desc_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
||||||
|
|
||||||
/* in parameters */
|
|
||||||
if (n_params)
|
|
||||||
{
|
|
||||||
frame = gimp_frame_new (_("Parameters"));
|
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (frame);
|
|
||||||
|
|
||||||
table = gimp_proc_view_create_params (params, n_params,
|
|
||||||
name_group, type_group, desc_group);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
||||||
gtk_widget_show (table);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* out parameters */
|
|
||||||
if (n_return_vals)
|
|
||||||
{
|
|
||||||
frame = gimp_frame_new (_("Return Values"));
|
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (frame);
|
|
||||||
|
|
||||||
table = gimp_proc_view_create_params (return_vals, n_return_vals,
|
|
||||||
name_group, type_group, desc_group);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
||||||
gtk_widget_show (table);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! help && ! author && ! date && ! copyright)
|
|
||||||
return main_vbox;
|
|
||||||
|
|
||||||
frame = gimp_frame_new (_("Additional Information"));
|
|
||||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (frame);
|
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, 8);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
||||||
gtk_widget_show (vbox);
|
|
||||||
|
|
||||||
/* show the help */
|
|
||||||
if (help)
|
|
||||||
{
|
|
||||||
label = gtk_label_new (help);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* show the author & the copyright */
|
|
||||||
|
|
||||||
if (! author && ! date && ! copyright)
|
|
||||||
return main_vbox;
|
|
||||||
|
|
||||||
table = gtk_table_new ((author != 0) + (date != 0) + (copyright != 0), 2,
|
|
||||||
FALSE);
|
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (table);
|
|
||||||
|
|
||||||
row = 0;
|
|
||||||
|
|
||||||
if (author)
|
|
||||||
{
|
|
||||||
label = gtk_label_new (author);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
|
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
|
||||||
_("Author:"), 0.0, 0.0,
|
|
||||||
label, 3, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (date)
|
|
||||||
{
|
|
||||||
label = gtk_label_new (date);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
|
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
|
||||||
_("Date:"), 0.0, 0.0,
|
|
||||||
label, 3, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (copyright)
|
|
||||||
{
|
|
||||||
label = gtk_label_new (copyright);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
|
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
|
|
||||||
_("Copyright:"), 0.0, 0.0,
|
|
||||||
label, 3, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return main_vbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* private functions */
|
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
gimp_proc_view_create_params (GimpParamDef *params,
|
|
||||||
gint n_params,
|
|
||||||
GtkSizeGroup *name_group,
|
|
||||||
GtkSizeGroup *type_group,
|
|
||||||
GtkSizeGroup *desc_group)
|
|
||||||
{
|
|
||||||
GtkWidget *table;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
table = gtk_table_new (n_params, 3, FALSE);
|
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
||||||
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
||||||
|
|
||||||
for (i = 0; i < n_params; i++)
|
|
||||||
{
|
|
||||||
GtkWidget *label;
|
|
||||||
const gchar *type;
|
|
||||||
gchar *upper;
|
|
||||||
|
|
||||||
/* name */
|
|
||||||
label = gtk_label_new (params[i].name);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_size_group_add_widget (name_group, label);
|
|
||||||
gtk_table_attach (GTK_TABLE (table), label,
|
|
||||||
0, 1, i, i + 1, GTK_FILL, GTK_FILL, 0, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
|
|
||||||
/* type */
|
|
||||||
if (! gimp_enum_get_value (GIMP_TYPE_PDB_ARG_TYPE, params[i].type,
|
|
||||||
NULL, &type, NULL, NULL))
|
|
||||||
upper = g_strdup ("UNKNOWN");
|
|
||||||
else
|
|
||||||
upper = g_ascii_strup (type, -1);
|
|
||||||
|
|
||||||
label = gtk_label_new (upper);
|
|
||||||
g_free (upper);
|
|
||||||
|
|
||||||
gimp_label_set_attributes (GTK_LABEL (label),
|
|
||||||
PANGO_ATTR_FAMILY, "monospace",
|
|
||||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
||||||
-1);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_size_group_add_widget (type_group, label);
|
|
||||||
gtk_table_attach (GTK_TABLE (table), label,
|
|
||||||
1, 2, i, i + 1, GTK_FILL, GTK_FILL, 0, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
|
|
||||||
/* description */
|
|
||||||
label = gtk_label_new (params[i].description);
|
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
|
||||||
gtk_size_group_add_widget (desc_group, label);
|
|
||||||
gtk_table_attach (GTK_TABLE (table), label,
|
|
||||||
2, 3, i, i + 1, GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
}
|
|
||||||
|
|
||||||
return table;
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* The GIMP -- an image manipulation program
|
|
||||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
||||||
*
|
|
||||||
* 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_PROC_VIEW_H__
|
|
||||||
#define __GIMP_PROC_VIEW_H__
|
|
||||||
|
|
||||||
|
|
||||||
GtkWidget * gimp_proc_view_new (const gchar *name,
|
|
||||||
const gchar *menu_path,
|
|
||||||
const gchar *blurb,
|
|
||||||
const gchar *help,
|
|
||||||
const gchar *author,
|
|
||||||
const gchar *copyright,
|
|
||||||
const gchar *date,
|
|
||||||
GimpPDBProcType type,
|
|
||||||
gint n_params,
|
|
||||||
gint n_return_vals,
|
|
||||||
GimpParamDef *params,
|
|
||||||
GimpParamDef *return_vals);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_PROC_VIEW_H__ */
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include <libgimp/gimp.h>
|
#include <libgimp/gimp.h>
|
||||||
#include <libgimp/gimpui.h>
|
#include <libgimp/gimpui.h>
|
||||||
|
|
||||||
#include "gimpprocview.h"
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,6 @@
|
||||||
#include <libgimp/gimp.h>
|
#include <libgimp/gimp.h>
|
||||||
#include <libgimp/gimpui.h>
|
#include <libgimp/gimpui.h>
|
||||||
|
|
||||||
#include "gimpprocbrowser.h"
|
|
||||||
|
|
||||||
#include "libgimp/stdplugins-intl.h"
|
#include "libgimp/stdplugins-intl.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,13 +113,13 @@ run (const gchar *name,
|
||||||
{
|
{
|
||||||
case GIMP_RUN_INTERACTIVE:
|
case GIMP_RUN_INTERACTIVE:
|
||||||
{
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
gimp_ui_init ("dbbrowser", FALSE);
|
gimp_ui_init ("dbbrowser", FALSE);
|
||||||
|
|
||||||
gtk_quit_add_destroy (1, (GtkObject *)
|
dialog = gimp_proc_browser_dialog_new (FALSE, FALSE);
|
||||||
gimp_proc_browser_dialog_new (FALSE, NULL, NULL));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
gtk_main ();
|
|
||||||
gdk_flush ();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSIO
|
||||||
libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
|
libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
|
||||||
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
||||||
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
||||||
libgimpprocbrowser = $(top_builddir)/plug-ins/dbbrowser/libgimpprocbrowser.la
|
|
||||||
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
|
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
|
||||||
|
|
||||||
SUBDIRS = plug-ins
|
SUBDIRS = plug-ins
|
||||||
|
@ -84,7 +83,6 @@ gimpprocbrowser_la_LDFLAGS = -module -avoid-version $(no_undefined) \
|
||||||
-export-symbols-regex initgimpprocbrowser
|
-export-symbols-regex initgimpprocbrowser
|
||||||
|
|
||||||
gimpprocbrowser_la_LIBADD = \
|
gimpprocbrowser_la_LIBADD = \
|
||||||
$(libgimpprocbrowser) \
|
|
||||||
$(libgimpui) \
|
$(libgimpui) \
|
||||||
$(libgimpwidgets) \
|
$(libgimpwidgets) \
|
||||||
$(libgimpconfig) \
|
$(libgimpconfig) \
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include <libgimpwidgets/gimpwidgets.h>
|
||||||
|
|
||||||
#include <pygobject.h>
|
#include <pygobject.h>
|
||||||
#include <pygtk/pygtk.h>
|
#include <pygtk/pygtk.h>
|
||||||
|
|
||||||
#include "pygimp-api.h"
|
#include "pygimp-api.h"
|
||||||
|
|
||||||
#include <plug-ins/dbbrowser/gimpprocbrowser.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -113,6 +113,7 @@ proxy_cleanup(gpointer data, GObject *obj)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
proc_browser_dialog_new(PyObject *self, PyObject *args, PyObject *kwargs)
|
proc_browser_dialog_new(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
PyObject *py_func = Py_None, *py_data = Py_None;
|
PyObject *py_func = Py_None, *py_data = Py_None;
|
||||||
GimpProcBrowserApplyCallback proxy_func = NULL;
|
GimpProcBrowserApplyCallback proxy_func = NULL;
|
||||||
ProxyData *proxy_data = NULL;
|
ProxyData *proxy_data = NULL;
|
||||||
|
@ -150,6 +151,7 @@ proc_browser_dialog_new(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
g_object_weak_ref(dlg, proxy_cleanup, proxy_data);
|
g_object_weak_ref(dlg, proxy_cleanup, proxy_data);
|
||||||
|
|
||||||
return pygobject_new(dlg);
|
return pygobject_new(dlg);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List of methods defined in the module */
|
/* List of methods defined in the module */
|
||||||
|
|
|
@ -6,7 +6,6 @@ libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
|
||||||
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
||||||
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
||||||
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
|
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
|
||||||
libgimpprocbrowser = $(top_builddir)/plug-ins/dbbrowser/libgimpprocbrowser.la
|
|
||||||
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
|
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
|
||||||
|
|
||||||
if OS_WIN32
|
if OS_WIN32
|
||||||
|
@ -52,7 +51,6 @@ REGEXREPL = $(top_builddir)/regexrepl/libregex.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDADD = \
|
LDADD = \
|
||||||
$(libgimpprocbrowser) \
|
|
||||||
$(libgimpui) \
|
$(libgimpui) \
|
||||||
$(libgimpwidgets) \
|
$(libgimpwidgets) \
|
||||||
$(libgimpconfig) \
|
$(libgimpconfig) \
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include "siod-wrapper.h"
|
#include "siod-wrapper.h"
|
||||||
#include "script-fu-console.h"
|
#include "script-fu-console.h"
|
||||||
|
|
||||||
#include <plug-ins/dbbrowser/gimpprocbrowser.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define TEXT_WIDTH 480
|
#define TEXT_WIDTH 480
|
||||||
#define TEXT_HEIGHT 400
|
#define TEXT_HEIGHT 400
|
||||||
|
@ -39,11 +37,18 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
GtkTextBuffer *console;
|
GtkTextBuffer *console;
|
||||||
GtkWidget *cc;
|
GtkWidget *cc;
|
||||||
GtkWidget *text_view;
|
GtkWidget *text_view;
|
||||||
|
GtkWidget *proc_browser;
|
||||||
|
|
||||||
gint32 input_id;
|
gint32 input_id;
|
||||||
|
|
||||||
|
GList *history;
|
||||||
|
gint history_len;
|
||||||
|
gint history_cur;
|
||||||
|
gint history_max;
|
||||||
} ConsoleInterface;
|
} ConsoleInterface;
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,15 +56,18 @@ typedef struct
|
||||||
* Local Functions
|
* Local Functions
|
||||||
*/
|
*/
|
||||||
static void script_fu_console_interface (void);
|
static void script_fu_console_interface (void);
|
||||||
static void script_fu_response (GtkWidget *widget,
|
static void script_fu_response (GtkWidget *widget,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
gpointer data);
|
ConsoleInterface *console);
|
||||||
static void script_fu_browse_callback (GtkWidget *widget,
|
static void script_fu_browse_callback (GtkWidget *widget,
|
||||||
gpointer data);
|
ConsoleInterface *console);
|
||||||
static gboolean script_fu_cc_is_empty (void);
|
static void script_fu_browse_response (GtkWidget *widget,
|
||||||
static gboolean script_fu_cc_key_function (GtkWidget *widget,
|
gint response_id,
|
||||||
GdkEventKey *event,
|
ConsoleInterface *console);
|
||||||
gpointer data);
|
static gboolean script_fu_cc_is_empty (ConsoleInterface *console);
|
||||||
|
static gboolean script_fu_cc_key_function (GtkWidget *widget,
|
||||||
|
GdkEventKey *event,
|
||||||
|
ConsoleInterface *console);
|
||||||
|
|
||||||
static void script_fu_open_siod_console (void);
|
static void script_fu_open_siod_console (void);
|
||||||
static void script_fu_close_siod_console (void);
|
static void script_fu_close_siod_console (void);
|
||||||
|
@ -70,18 +78,20 @@ static void script_fu_close_siod_console (void);
|
||||||
*/
|
*/
|
||||||
static ConsoleInterface cint =
|
static ConsoleInterface cint =
|
||||||
{
|
{
|
||||||
|
NULL, /* dialog */
|
||||||
NULL, /* console */
|
NULL, /* console */
|
||||||
NULL, /* current command */
|
NULL, /* current command */
|
||||||
NULL, /* text view */
|
NULL, /* text view */
|
||||||
|
NULL, /* proc browser */
|
||||||
|
|
||||||
-1 /* input id */
|
-1, /* input id */
|
||||||
|
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
50
|
||||||
};
|
};
|
||||||
|
|
||||||
static GList *history = NULL;
|
|
||||||
static gint history_len = 0;
|
|
||||||
static gint history_cur = 0;
|
|
||||||
static gint history_max = 50;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function definitions
|
* Function definitions
|
||||||
|
@ -133,34 +143,42 @@ script_fu_console_run (const gchar *name,
|
||||||
static void
|
static void
|
||||||
script_fu_console_interface (void)
|
script_fu_console_interface (void)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
ConsoleInterface *console;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
|
|
||||||
gimp_ui_init ("script-fu", FALSE);
|
gimp_ui_init ("script-fu", FALSE);
|
||||||
|
|
||||||
dialog = gimp_dialog_new (_("Script-Fu Console"), "script-fu-console",
|
console = &cint;
|
||||||
NULL, 0,
|
|
||||||
gimp_standard_help_func,
|
|
||||||
"plug-in-script-fu-console",
|
|
||||||
|
|
||||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
console->input_id = -1;
|
||||||
|
console->history = NULL;
|
||||||
|
console->history_len = 0;
|
||||||
|
console->history_cur = 0;
|
||||||
|
console->history_max = 50;
|
||||||
|
|
||||||
NULL);
|
console->dialog = gimp_dialog_new (_("Script-Fu Console"), "script-fu-console",
|
||||||
|
NULL, 0,
|
||||||
|
gimp_standard_help_func,
|
||||||
|
"plug-in-script-fu-console",
|
||||||
|
|
||||||
g_signal_connect (dialog, "response",
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
||||||
|
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect (console->dialog, "response",
|
||||||
G_CALLBACK (script_fu_response),
|
G_CALLBACK (script_fu_response),
|
||||||
NULL);
|
console);
|
||||||
g_signal_connect (dialog, "destroy",
|
g_signal_connect (console->dialog, "destroy",
|
||||||
G_CALLBACK (gtk_widget_destroyed),
|
G_CALLBACK (gtk_widget_destroyed),
|
||||||
&dialog);
|
&console->dialog);
|
||||||
|
|
||||||
/* The main vbox */
|
/* The main vbox */
|
||||||
vbox = gtk_vbox_new (FALSE, 12);
|
vbox = gtk_vbox_new (FALSE, 12);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
||||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (console->dialog)->vbox), vbox,
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
|
@ -172,26 +190,26 @@ script_fu_console_interface (void)
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (scrolled_window);
|
gtk_widget_show (scrolled_window);
|
||||||
|
|
||||||
cint.console = gtk_text_buffer_new (NULL);
|
console->console = gtk_text_buffer_new (NULL);
|
||||||
cint.text_view = gtk_text_view_new_with_buffer (cint.console);
|
console->text_view = gtk_text_view_new_with_buffer (console->console);
|
||||||
g_object_unref (cint.console);
|
g_object_unref (console->console);
|
||||||
|
|
||||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (cint.text_view), FALSE);
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (console->text_view), FALSE);
|
||||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (cint.text_view), 12);
|
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (console->text_view), 12);
|
||||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (cint.text_view), 12);
|
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (console->text_view), 12);
|
||||||
gtk_widget_set_size_request (cint.text_view, TEXT_WIDTH, TEXT_HEIGHT);
|
gtk_widget_set_size_request (console->text_view, TEXT_WIDTH, TEXT_HEIGHT);
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window), cint.text_view);
|
gtk_container_add (GTK_CONTAINER (scrolled_window), console->text_view);
|
||||||
gtk_widget_show (cint.text_view);
|
gtk_widget_show (console->text_view);
|
||||||
|
|
||||||
gtk_text_buffer_create_tag (cint.console, "strong",
|
gtk_text_buffer_create_tag (console->console, "strong",
|
||||||
"weight", PANGO_WEIGHT_BOLD,
|
"weight", PANGO_WEIGHT_BOLD,
|
||||||
"size", 12 * PANGO_SCALE,
|
"size", 12 * PANGO_SCALE,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_text_buffer_create_tag (cint.console, "emphasis",
|
gtk_text_buffer_create_tag (console->console, "emphasis",
|
||||||
"style", PANGO_STYLE_OBLIQUE,
|
"style", PANGO_STYLE_OBLIQUE,
|
||||||
"size", 10 * PANGO_SCALE,
|
"size", 10 * PANGO_SCALE,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_text_buffer_create_tag (cint.console, "weak",
|
gtk_text_buffer_create_tag (console->console, "weak",
|
||||||
"size", 10 * PANGO_SCALE,
|
"size", 10 * PANGO_SCALE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -209,11 +227,11 @@ script_fu_console_interface (void)
|
||||||
GtkTextIter cursor;
|
GtkTextIter cursor;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
gtk_text_buffer_get_end_iter (cint.console, &cursor);
|
gtk_text_buffer_get_end_iter (console->console, &cursor);
|
||||||
|
|
||||||
for (i = 0; greeting_texts[i]; i += 2)
|
for (i = 0; greeting_texts[i]; i += 2)
|
||||||
{
|
{
|
||||||
gtk_text_buffer_insert_with_tags_by_name (cint.console, &cursor,
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
||||||
greeting_texts[i + 1], -1,
|
greeting_texts[i + 1], -1,
|
||||||
greeting_texts[i],
|
greeting_texts[i],
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -225,14 +243,14 @@ script_fu_console_interface (void)
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
cint.cc = gtk_entry_new ();
|
console->cc = gtk_entry_new ();
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), cint.cc, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), console->cc, TRUE, TRUE, 0);
|
||||||
gtk_widget_grab_focus (cint.cc);
|
gtk_widget_grab_focus (console->cc);
|
||||||
gtk_widget_show (cint.cc);
|
gtk_widget_show (console->cc);
|
||||||
|
|
||||||
g_signal_connect (cint.cc, "key-press-event",
|
g_signal_connect (console->cc, "key-press-event",
|
||||||
G_CALLBACK (script_fu_cc_key_function),
|
G_CALLBACK (script_fu_cc_key_function),
|
||||||
NULL);
|
console);
|
||||||
|
|
||||||
button = gtk_button_new_with_mnemonic (_("_Browse..."));
|
button = gtk_button_new_with_mnemonic (_("_Browse..."));
|
||||||
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
||||||
|
@ -241,50 +259,94 @@ script_fu_console_interface (void)
|
||||||
|
|
||||||
g_signal_connect (button, "clicked",
|
g_signal_connect (button, "clicked",
|
||||||
G_CALLBACK (script_fu_browse_callback),
|
G_CALLBACK (script_fu_browse_callback),
|
||||||
NULL);
|
console);
|
||||||
|
|
||||||
/* Initialize the history */
|
/* Initialize the history */
|
||||||
history = g_list_append (history, NULL);
|
console->history = g_list_append (console->history, NULL);
|
||||||
history_len = 1;
|
console->history_len = 1;
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (console->dialog);
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
g_source_remove (cint.input_id);
|
g_source_remove (console->input_id);
|
||||||
|
|
||||||
if (dialog)
|
if (console->dialog)
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (console->dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
script_fu_response (GtkWidget *widget,
|
script_fu_response (GtkWidget *widget,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
gpointer data)
|
ConsoleInterface *console)
|
||||||
{
|
{
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_callback (const gchar *proc_name,
|
script_fu_browse_callback (GtkWidget *widget,
|
||||||
const gchar *proc_blurb,
|
ConsoleInterface *console)
|
||||||
const gchar *proc_help,
|
|
||||||
const gchar *proc_author,
|
|
||||||
const gchar *proc_copyright,
|
|
||||||
const gchar *proc_date,
|
|
||||||
GimpPDBProcType proc_type,
|
|
||||||
gint n_params,
|
|
||||||
gint n_return_vals,
|
|
||||||
const GimpParamDef *params,
|
|
||||||
const GimpParamDef *return_vals,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
gint i;
|
if (! console->proc_browser)
|
||||||
GString *text;
|
{
|
||||||
|
console->proc_browser = gimp_proc_browser_dialog_new (TRUE, TRUE);
|
||||||
|
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (console->proc_browser),
|
||||||
|
(gpointer) &console->proc_browser);
|
||||||
|
gtk_window_set_transient_for (GTK_WINDOW (console->proc_browser),
|
||||||
|
GTK_WINDOW (console->dialog));
|
||||||
|
|
||||||
|
g_signal_connect (console->proc_browser, "response",
|
||||||
|
G_CALLBACK (script_fu_browse_response),
|
||||||
|
console);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_window_present (GTK_WINDOW (console->proc_browser));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
script_fu_browse_response (GtkWidget *widget,
|
||||||
|
gint response_id,
|
||||||
|
ConsoleInterface *console)
|
||||||
|
{
|
||||||
|
GimpProcBrowserDialog *dialog = GIMP_PROC_BROWSER_DIALOG (widget);
|
||||||
|
gchar *proc_name;
|
||||||
|
gchar *proc_blurb;
|
||||||
|
gchar *proc_help;
|
||||||
|
gchar *proc_author;
|
||||||
|
gchar *proc_copyright;
|
||||||
|
gchar *proc_date;
|
||||||
|
GimpPDBProcType proc_type;
|
||||||
|
gint n_params;
|
||||||
|
gint n_return_vals;
|
||||||
|
GimpParamDef *params;
|
||||||
|
GimpParamDef *return_vals;
|
||||||
|
gint i;
|
||||||
|
GString *text;
|
||||||
|
|
||||||
|
if (response_id != GTK_RESPONSE_APPLY)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (widget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
proc_name = gimp_proc_browser_dialog_get_selected (dialog);
|
||||||
|
|
||||||
if (proc_name == NULL)
|
if (proc_name == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
gimp_procedural_db_proc_info (proc_name,
|
||||||
|
&proc_blurb,
|
||||||
|
&proc_help,
|
||||||
|
&proc_author,
|
||||||
|
&proc_copyright,
|
||||||
|
&proc_date,
|
||||||
|
&proc_type,
|
||||||
|
&n_params,
|
||||||
|
&n_return_vals,
|
||||||
|
¶ms,
|
||||||
|
&return_vals);
|
||||||
|
|
||||||
text = g_string_new ("(");
|
text = g_string_new ("(");
|
||||||
text = g_string_append (text, proc_name);
|
text = g_string_append (text, proc_name);
|
||||||
|
|
||||||
|
@ -296,22 +358,24 @@ apply_callback (const gchar *proc_name,
|
||||||
|
|
||||||
text = g_string_append_c (text, ')');
|
text = g_string_append_c (text, ')');
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (cint.cc), text->str);
|
gtk_entry_set_text (GTK_ENTRY (console->cc), text->str);
|
||||||
g_string_free (text, TRUE);
|
g_string_free (text, TRUE);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
g_free (proc_name);
|
||||||
script_fu_browse_callback (GtkWidget *widget,
|
g_free (proc_blurb);
|
||||||
gpointer data)
|
g_free (proc_help);
|
||||||
{
|
g_free (proc_author);
|
||||||
gtk_quit_add_destroy (1, (GtkObject *)
|
g_free (proc_copyright);
|
||||||
gimp_proc_browser_dialog_new (TRUE, apply_callback, NULL));
|
g_free (proc_date);
|
||||||
|
|
||||||
|
gimp_destroy_paramdefs (params, n_params);
|
||||||
|
gimp_destroy_paramdefs (return_vals, n_return_vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
script_fu_console_idle_scroll_end (gpointer data)
|
script_fu_console_idle_scroll_end (ConsoleInterface *console)
|
||||||
{
|
{
|
||||||
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
|
GtkAdjustment *adj = GTK_TEXT_VIEW (console->text_view)->vadjustment;
|
||||||
|
|
||||||
gtk_adjustment_set_value (adj, adj->upper - adj->page_size);
|
gtk_adjustment_set_value (adj, adj->upper - adj->page_size);
|
||||||
|
|
||||||
|
@ -319,12 +383,11 @@ script_fu_console_idle_scroll_end (gpointer data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
script_fu_console_scroll_end (void)
|
script_fu_console_scroll_end (ConsoleInterface *console)
|
||||||
{
|
{
|
||||||
/* the text view idle updates so we need to idle scroll too
|
/* the text view idle updates so we need to idle scroll too
|
||||||
*/
|
*/
|
||||||
g_idle_add (script_fu_console_idle_scroll_end,
|
g_idle_add ((GSourceFunc) script_fu_console_idle_scroll_end, console);
|
||||||
GTK_TEXT_VIEW (cint.text_view)->vadjustment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -338,15 +401,15 @@ script_fu_output_to_console (gchar *text)
|
||||||
"weak",
|
"weak",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
script_fu_console_scroll_end ();
|
script_fu_console_scroll_end (&cint);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
script_fu_cc_is_empty (void)
|
script_fu_cc_is_empty (ConsoleInterface *console)
|
||||||
{
|
{
|
||||||
const gchar *str;
|
const gchar *str;
|
||||||
|
|
||||||
if ((str = gtk_entry_get_text (GTK_ENTRY (cint.cc))) == NULL)
|
if ((str = gtk_entry_get_text (GTK_ENTRY (console->cc))) == NULL)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
while (*str)
|
while (*str)
|
||||||
|
@ -361,9 +424,9 @@ script_fu_cc_is_empty (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
script_fu_cc_key_function (GtkWidget *widget,
|
script_fu_cc_key_function (GtkWidget *widget,
|
||||||
GdkEventKey *event,
|
GdkEventKey *event,
|
||||||
gpointer data)
|
ConsoleInterface *console)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
gint direction = 0;
|
gint direction = 0;
|
||||||
|
@ -372,48 +435,50 @@ script_fu_cc_key_function (GtkWidget *widget,
|
||||||
switch (event->keyval)
|
switch (event->keyval)
|
||||||
{
|
{
|
||||||
case GDK_Return:
|
case GDK_Return:
|
||||||
if (script_fu_cc_is_empty ())
|
if (script_fu_cc_is_empty (console))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
list = g_list_nth (history, (g_list_length (history) - 1));
|
list = g_list_nth (console->history,
|
||||||
|
(g_list_length (console->history) - 1));
|
||||||
if (list->data)
|
if (list->data)
|
||||||
g_free (list->data);
|
g_free (list->data);
|
||||||
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (cint.cc)));
|
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
|
||||||
|
|
||||||
gtk_text_buffer_get_end_iter (cint.console, &cursor);
|
gtk_text_buffer_get_end_iter (console->console, &cursor);
|
||||||
|
|
||||||
gtk_text_buffer_insert_with_tags_by_name (cint.console, &cursor,
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
||||||
"\n=> ", -1,
|
"\n=> ", -1,
|
||||||
"strong",
|
"strong",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_text_buffer_insert_with_tags_by_name (cint.console, &cursor,
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
||||||
gtk_entry_get_text (GTK_ENTRY (cint.cc)), -1,
|
gtk_entry_get_text (GTK_ENTRY (console->cc)), -1,
|
||||||
"weak",
|
"weak",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_text_buffer_insert_with_tags_by_name (cint.console, &cursor,
|
gtk_text_buffer_insert_with_tags_by_name (console->console, &cursor,
|
||||||
"\n", -1,
|
"\n", -1,
|
||||||
"weak",
|
"weak",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
script_fu_console_scroll_end ();
|
script_fu_console_scroll_end (console);
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (cint.cc), "");
|
gtk_entry_set_text (GTK_ENTRY (console->cc), "");
|
||||||
|
|
||||||
siod_interpret_string ((char *) list->data);
|
siod_interpret_string ((char *) list->data);
|
||||||
gimp_displays_flush ();
|
gimp_displays_flush ();
|
||||||
|
|
||||||
history = g_list_append (history, NULL);
|
console->history = g_list_append (console->history, NULL);
|
||||||
if (history_len == history_max)
|
if (console->history_len == console->history_max)
|
||||||
{
|
{
|
||||||
history = g_list_remove (history, history->data);
|
console->history = g_list_remove (console->history,
|
||||||
if (history->data)
|
console->history->data);
|
||||||
g_free (history->data);
|
if (console->history->data)
|
||||||
|
g_free (console->history->data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
history_len++;
|
console->history_len++;
|
||||||
history_cur = g_list_length (history) - 1;
|
console->history_cur = g_list_length (console->history) - 1;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -447,24 +512,25 @@ script_fu_cc_key_function (GtkWidget *widget,
|
||||||
if (direction)
|
if (direction)
|
||||||
{
|
{
|
||||||
/* Make sure we keep track of the current one */
|
/* Make sure we keep track of the current one */
|
||||||
if (history_cur == g_list_length (history) - 1)
|
if (console->history_cur == g_list_length (console->history) - 1)
|
||||||
{
|
{
|
||||||
list = g_list_nth (history, history_cur);
|
list = g_list_nth (console->history, console->history_cur);
|
||||||
if (list->data)
|
if (list->data)
|
||||||
g_free (list->data);
|
g_free (list->data);
|
||||||
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (cint.cc)));
|
list->data = g_strdup (gtk_entry_get_text (GTK_ENTRY (console->cc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
history_cur += direction;
|
console->history_cur += direction;
|
||||||
if (history_cur < 0)
|
if (console->history_cur < 0)
|
||||||
history_cur = 0;
|
console->history_cur = 0;
|
||||||
if (history_cur >= history_len)
|
if (console->history_cur >= console->history_len)
|
||||||
history_cur = history_len - 1;
|
console->history_cur = console->history_len - 1;
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (cint.cc),
|
gtk_entry_set_text (GTK_ENTRY (console->cc),
|
||||||
(gchar *) (g_list_nth (history, history_cur))->data);
|
(gchar *) (g_list_nth (console->history,
|
||||||
|
console->history_cur))->data);
|
||||||
|
|
||||||
gtk_editable_set_position (GTK_EDITABLE (cint.cc), -1);
|
gtk_editable_set_position (GTK_EDITABLE (console->cc), -1);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue