Commit 4d369ec2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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).
parent 4182c836
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>
* app/tools/gimpforegroundselectoptions.[ch]
......
......@@ -233,34 +233,38 @@ libgimpui_2_0_la_sources = \
gimpui.c \
gimpui.h \
gimpuitypes.h \
gimpmenu.c \
gimpmenu.h \
gimpaspectpreview.c \
gimpaspectpreview.h \
gimpbrushmenu.c \
gimpbrushmenu.h \
gimpdrawablecombobox.c \
gimpdrawablecombobox.h \
gimpdrawablepreview.c \
gimpdrawablepreview.h \
gimpexport.c \
gimpexport.h \
gimpfontmenu.c \
gimpfontmenu.h \
gimpfontselectbutton.c \
gimpfontselectbutton.h \
gimpgradientmenu.c \
gimpgradientmenu.h \
gimpimagecombobox.c \
gimpimagecombobox.h \
gimpmenu.c \
gimpmenu.h \
gimppalettemenu.c \
gimppalettemenu.h \
gimppatternmenu.c \
gimppatternmenu.h \
gimpdrawablecombobox.c \
gimpdrawablecombobox.h \
gimpimagecombobox.c \
gimpimagecombobox.h \
gimppixbuf.c \
gimppixbuf.h \
gimpprocbrowserdialog.c \
gimpprocbrowserdialog.h \
gimpprocview.c \
gimpprocview.h \
gimpprogressbar.c \
gimpprogressbar.h \
gimpexport.c \
gimpexport.h
gimpprogressbar.h
libgimpui_2_0_la_built_sources = \
gimpuimarshal.c \
......@@ -304,20 +308,22 @@ gimpinclude_HEADERS = \
\
gimpui.h \
gimpuitypes.h \
gimpmenu.h \
gimpaspectpreview.h \
gimpbrushmenu.h \
gimpdrawablecombobox.h \
gimpdrawablepreview.h \
gimpexport.h \
gimpfontmenu.h \
gimpfontselectbutton.h \
gimpgradientmenu.h \
gimpimagecombobox.h \
gimpmenu.h \
gimppalettemenu.h \
gimppatternmenu.h \
gimppixbuf.h \
gimpprogressbar.h \
gimpdrawablecombobox.h \
gimpimagecombobox.h \
gimpexport.h
gimpprocbrowserdialog.h \
gimpprocview.h \
gimpprogressbar.h
libgimp_2_0_la_LDFLAGS = \
-version-info $(LT_VERSION_INFO) \
......
This diff is collapsed.
/* 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
......@@ -21,27 +23,55 @@
* 0.08 26th sept 97 by Thomas NOEL <thomas@minet.net>
*/
#ifndef __GIMP_PROC_BROWSER_H__
#define __GIMP_PROC_BROWSER_H__
#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);
};
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);
GType gimp_proc_browser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_proc_browser_dialog_new (gboolean scheme_names,
gboolean apply_button);
GtkWidget * gimp_proc_browser_dialog_new (gboolean scheme_names,
GimpProcBrowserApplyCallback apply_callback,
gpointer user_data);
gchar * gimp_proc_browser_dialog_get_selected (GimpProcBrowserDialog *dialog);
#endif /* __GIMP_PROC_BROWSER_H__ */
#endif /* __GIMP_PROC_BROWSER_DIALOG_H__ */
......@@ -29,12 +29,14 @@
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gimp.h"
#include "gimpuitypes.h"
#include "gimpprocview.h"
#include "libgimp/stdplugins-intl.h"
#include "libgimp-intl.h"
/* local function prototypes */
......
......@@ -37,6 +37,10 @@ EXPORTS
gimp_pattern_select_widget_close
gimp_pattern_select_widget_new
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_new
gimp_ui_init
......@@ -36,6 +36,8 @@
#include <libgimp/gimppalettemenu.h>
#include <libgimp/gimppatternmenu.h>
#include <libgimp/gimppixbuf.h>
#include <libgimp/gimpprocbrowserdialog.h>
#include <libgimp/gimpprocview.h>
#include <libgimp/gimpprogressbar.h>
#include <libgimp/gimpdrawablecombobox.h>
#include <libgimp/gimpimagecombobox.h>
......
......@@ -31,8 +31,6 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "gimpprocview.h"
#include "libgimp/stdplugins-intl.h"
......
......@@ -46,8 +46,6 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "gimpprocbrowser.h"
#include "libgimp/stdplugins-intl.h"
......@@ -115,13 +113,13 @@ run (const gchar *name,
{
case GIMP_RUN_INTERACTIVE:
{
gimp_ui_init ("dbbrowser", FALSE);
GtkWidget *dialog;
gtk_quit_add_destroy (1, (GtkObject *)
gimp_proc_browser_dialog_new (FALSE, NULL, NULL));
gimp_ui_init ("dbbrowser", FALSE);
gtk_main ();
gdk_flush ();
dialog = gimp_proc_browser_dialog_new (FALSE, FALSE);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
break;
......
......@@ -16,15 +16,8 @@ AM_LDFLAGS = $(mwindows)
libexecdir = $(gimpplugindir)/plug-ins
noinst_LTLIBRARIES = libgimpprocbrowser.la
libexec_PROGRAMS = plugin-browser procedure-browser
libgimpprocbrowser_la_SOURCES = \
gimpprocbrowser.c \
gimpprocbrowser.h \
gimpprocview.c \
gimpprocview.h
plugin_browser_SOURCES = \
plugin-browser.c
......@@ -40,7 +33,6 @@ INCLUDES = \
-I$(includedir)
LDADD = \
libgimpprocbrowser.la \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpconfig) \
......
/* 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"));