mirror of https://github.com/GNOME/gimp.git
Quick and dirty restore of browser functionality.
2005-08-02 Manish Singh <yosh@gimp.org> * plug-ins/pygimp/procbrowser.c: Quick and dirty restore of browser functionality.
This commit is contained in:
parent
40dd411be3
commit
00d1d29902
|
@ -1,3 +1,8 @@
|
||||||
|
2005-08-02 Manish Singh <yosh@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/pygimp/procbrowser.c: Quick and dirty restore of browser
|
||||||
|
functionality.
|
||||||
|
|
||||||
2005-08-02 Michael Natterer <mitch@gimp.org>
|
2005-08-02 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* libgimp/gimpuitypes.h: added GimpProcBrowserDialog typedef here.
|
* libgimp/gimpuitypes.h: added GimpProcBrowserDialog typedef here.
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <libgimpwidgets/gimpwidgets.h>
|
#include <libgimp/gimp.h>
|
||||||
|
#include <libgimp/gimpui.h>
|
||||||
|
|
||||||
#include <pygobject.h>
|
#include <pygobject.h>
|
||||||
#include <pygtk/pygtk.h>
|
#include <pygtk/pygtk.h>
|
||||||
|
@ -38,51 +39,57 @@ typedef struct
|
||||||
} ProxyData;
|
} ProxyData;
|
||||||
|
|
||||||
|
|
||||||
static GimpParamDef *
|
|
||||||
copy_paramdefs(const GimpParamDef *paramdefs, gint n_params)
|
|
||||||
{
|
|
||||||
GimpParamDef *copy;
|
|
||||||
|
|
||||||
copy = g_new(GimpParamDef, n_params);
|
|
||||||
|
|
||||||
while (n_params--)
|
|
||||||
{
|
|
||||||
copy[n_params].type = paramdefs[n_params].type;
|
|
||||||
copy[n_params].name = g_strdup(paramdefs[n_params].name);
|
|
||||||
copy[n_params].description = g_strdup(paramdefs[n_params].description);
|
|
||||||
}
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proxy_apply_callback(const gchar *name,
|
proxy_apply_callback(GtkWidget *widget,
|
||||||
const gchar *blurb,
|
gint response_id,
|
||||||
const gchar *help,
|
ProxyData *proxy_data)
|
||||||
const gchar *author,
|
|
||||||
const gchar *copyright,
|
|
||||||
const gchar *date,
|
|
||||||
GimpPDBProcType proc_type,
|
|
||||||
gint n_params,
|
|
||||||
gint n_return_vals,
|
|
||||||
const GimpParamDef *params,
|
|
||||||
const GimpParamDef *return_vals,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
ProxyData *proxy_data = user_data;
|
PyObject *pdb_func, *ret;
|
||||||
GimpParamDef *params_copy, *return_vals_copy;
|
gchar *name;
|
||||||
PyObject *pdb_func, *ret;
|
gchar *blurb;
|
||||||
|
gchar *help;
|
||||||
|
gchar *author;
|
||||||
|
gchar *copyright;
|
||||||
|
gchar *date;
|
||||||
|
GimpPDBProcType proc_type;
|
||||||
|
gint n_params;
|
||||||
|
gint n_return_vals;
|
||||||
|
GimpParamDef *params;
|
||||||
|
GimpParamDef *return_vals;
|
||||||
|
|
||||||
params_copy = copy_paramdefs(params, n_params);
|
if (response_id != GTK_RESPONSE_APPLY) {
|
||||||
return_vals_copy = copy_paramdefs(return_vals, n_return_vals);
|
if (proxy_data)
|
||||||
|
gtk_widget_destroy (widget);
|
||||||
|
else
|
||||||
|
gtk_main_quit ();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proxy_data == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
name = gimp_proc_browser_dialog_get_selected(GIMP_PROC_BROWSER_DIALOG (widget));
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gimp_procedural_db_proc_info(name, &blurb, &help, &author, ©right,
|
||||||
|
&date, &proc_type,
|
||||||
|
&n_params, &n_return_vals,
|
||||||
|
¶ms, &return_vals);
|
||||||
|
|
||||||
pdb_func = pygimp_pdb_function_new(name, blurb, help, author, copyright,
|
pdb_func = pygimp_pdb_function_new(name, blurb, help, author, copyright,
|
||||||
date, proc_type, n_params, n_return_vals,
|
date, proc_type, n_params, n_return_vals,
|
||||||
params_copy, return_vals_copy);
|
params, return_vals);
|
||||||
|
|
||||||
if (pdb_func == NULL) {
|
if (pdb_func == NULL) {
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
return;
|
|
||||||
|
gimp_destroy_paramdefs(params, n_params);
|
||||||
|
gimp_destroy_paramdefs(return_vals, n_return_vals);
|
||||||
|
|
||||||
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy_data->data)
|
if (proxy_data->data)
|
||||||
|
@ -97,13 +104,24 @@ proxy_apply_callback(const gchar *name,
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
|
||||||
Py_DECREF(pdb_func);
|
Py_DECREF(pdb_func);
|
||||||
|
|
||||||
|
bail:
|
||||||
|
g_free(name);
|
||||||
|
g_free(blurb);
|
||||||
|
g_free(help);
|
||||||
|
g_free(author);
|
||||||
|
g_free(copyright);
|
||||||
|
g_free(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proxy_cleanup(gpointer data, GObject *obj)
|
proxy_cleanup(gpointer data, GClosure *closure)
|
||||||
{
|
{
|
||||||
ProxyData *proxy_data = data;
|
ProxyData *proxy_data = data;
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return;
|
||||||
|
|
||||||
Py_DECREF(proxy_data->func);
|
Py_DECREF(proxy_data->func);
|
||||||
Py_XDECREF(proxy_data->data);
|
Py_XDECREF(proxy_data->data);
|
||||||
|
|
||||||
|
@ -113,11 +131,10 @@ 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;
|
|
||||||
ProxyData *proxy_data = NULL;
|
ProxyData *proxy_data = NULL;
|
||||||
GObject *dlg;
|
GObject *dlg;
|
||||||
|
gboolean has_apply = FALSE;
|
||||||
|
|
||||||
static char *kwlist[] = { "apply_callback", "data", NULL };
|
static char *kwlist[] = { "apply_callback", "data", NULL };
|
||||||
|
|
||||||
|
@ -127,7 +144,7 @@ proc_browser_dialog_new(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
|
|
||||||
if (py_func != Py_None) {
|
if (py_func != Py_None) {
|
||||||
if (PyCallable_Check(py_func))
|
if (PyCallable_Check(py_func))
|
||||||
proxy_func = proxy_apply_callback;
|
has_apply = TRUE;
|
||||||
else {
|
else {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"apply_callback must be a callable object or None");
|
"apply_callback must be a callable object or None");
|
||||||
|
@ -145,13 +162,15 @@ proc_browser_dialog_new(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg = G_OBJECT(gimp_proc_browser_dialog_new(FALSE, proxy_func, proxy_data));
|
dlg = G_OBJECT(gimp_proc_browser_dialog_new(FALSE, has_apply));
|
||||||
|
|
||||||
if (proxy_data)
|
g_signal_connect_data(dlg, "response",
|
||||||
g_object_weak_ref(dlg, proxy_cleanup, proxy_data);
|
G_CALLBACK(proxy_apply_callback), proxy_data,
|
||||||
|
proxy_cleanup, 0);
|
||||||
|
|
||||||
|
gtk_widget_show(GTK_WIDGET(dlg));
|
||||||
|
|
||||||
return pygobject_new(dlg);
|
return pygobject_new(dlg);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List of methods defined in the module */
|
/* List of methods defined in the module */
|
||||||
|
|
Loading…
Reference in New Issue