Commit 9ba57069 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

plug-ins/dbbrowser/Makefile.am new files holding more common code from the

2004-09-30  Michael Natterer  <mitch@gimp.org>

	* plug-ins/dbbrowser/Makefile.am
	* plug-ins/dbbrowser/gimpprocbox.c: new files holding more common
	code from the two browsers.

	* plug-ins/dbbrowser/gimpprocbrowser.c: use it.

	* plug-ins/dbbrowser/plugin-browser.c: ditto. Re-enabled sorting
	by all columns in both views. More cleanup.
parent 79fd36cf
2004-09-30 Michael Natterer <mitch@gimp.org>
* plug-ins/dbbrowser/Makefile.am
* plug-ins/dbbrowser/gimpprocbox.c: new files holding more common
code from the two browsers.
* plug-ins/dbbrowser/gimpprocbrowser.c: use it.
* plug-ins/dbbrowser/plugin-browser.c: ditto. Re-enabled sorting
by all columns in both views. More cleanup.
2004-09-30 Sven Neumann <sven@gimp.org>
* README: added missing linebreak.
......@@ -36,7 +47,7 @@
libgimpprocbrowser.a
* plug-ins/script-fu/script-fu-console.c: changed #includes
accordingly. Monir cleanup.
accordingly. Minor cleanup.
* tools/pdbgen/pdb/plug_in.pdb (plugins_query): fixed menu_path
return value. Was broken since the plug-in menu registering
......
......@@ -32,8 +32,9 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "gimpprocview.h"
#include "gimpprocbox.h"
#include "gimpprocbrowser.h"
#include "gimpprocview.h"
#include "libgimp/stdplugins-intl.h"
......@@ -59,8 +60,7 @@ typedef struct
GtkWidget *count_label;
GtkWidget *search_entry;
GtkWidget *descr_vbox;
GtkWidget *description;
GtkWidget *proc_box;
GtkListStore *store;
GtkWidget *tv;
......@@ -229,20 +229,11 @@ gimp_proc_browser_dialog_new (GimpProcBrowserApplyCallback apply_callback)
/* right = description */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_size_request (scrolled_window,
browser->proc_box = gimp_proc_box_new ();
gtk_widget_set_size_request (browser->proc_box,
DBL_WIDTH - DBL_LIST_WIDTH, -1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
gtk_paned_pack2 (GTK_PANED (paned), scrolled_window, TRUE, TRUE);
gtk_widget_show (scrolled_window);
browser->descr_vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (browser->descr_vbox), 12);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
browser->descr_vbox);
gtk_widget_show (browser->descr_vbox);
gtk_paned_pack2 (GTK_PANED (paned), browser->proc_box, TRUE, TRUE);
gtk_widget_show (browser->proc_box);
/* now build the list */
......@@ -250,7 +241,6 @@ gimp_proc_browser_dialog_new (GimpProcBrowserApplyCallback apply_callback)
/* initialize the "return" value (for "apply") */
browser->description = NULL;
browser->proc_name = NULL;
browser->scheme_proc_name = NULL;
browser->proc_blurb = NULL;
......@@ -306,8 +296,6 @@ static void
browser_show_procedure (GimpDBBrowser *browser,
gchar *proc_name)
{
GtkWidget *vbox;
g_free (browser->proc_name);
browser->proc_name = g_strdup (proc_name);
......@@ -335,51 +323,19 @@ browser_show_procedure (GimpDBBrowser *browser,
&browser->params,
&browser->return_vals);
vbox = gimp_proc_view_new (browser->scheme_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);
if (browser->description)
gtk_container_remove (GTK_CONTAINER (browser->descr_vbox),
browser->description);
gtk_box_pack_start (GTK_BOX (browser->descr_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
browser->description = vbox;
}
static void
dialog_show_message (GimpDBBrowser *browser,
const gchar *message)
{
if (GTK_IS_LABEL (browser->description))
{
gtk_label_set_text (GTK_LABEL (browser->description), message);
}
else
{
if (browser->description)
gtk_container_remove (GTK_CONTAINER (browser->descr_vbox),
browser->description);
browser->description = gtk_label_new (message);
gtk_box_pack_start (GTK_BOX (browser->descr_vbox),
browser->description, FALSE, FALSE, 0);
gtk_widget_show (browser->description);
}
while (gtk_events_pending ())
gtk_main_iteration ();
gimp_proc_box_set_widget (browser->proc_box,
gimp_proc_view_new (browser->scheme_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
......@@ -422,8 +378,8 @@ browser_response (GtkWidget *widget,
if (response_id == RESPONSE_SEARCH_NAME)
{
dialog_show_message (browser,
_("Searching by name - please wait"));
gimp_proc_box_show_message (browser->proc_box,
_("Searching by name - please wait"));
query = g_string_new ("");
query_text = gtk_entry_get_text (GTK_ENTRY (browser->search_entry));
......@@ -446,8 +402,8 @@ browser_response (GtkWidget *widget,
}
else if (response_id == RESPONSE_SEARCH_BLURB)
{
dialog_show_message (browser,
_("Searching by blurb - please wait"));
gimp_proc_box_show_message (browser->proc_box,
_("Searching by blurb - please wait"));
gimp_procedural_db_query (".*",
(gchar *) gtk_entry_get_text
......@@ -457,7 +413,8 @@ browser_response (GtkWidget *widget,
}
else
{
dialog_show_message (browser, _("Searching - please wait"));
gimp_proc_box_show_message (browser->proc_box,
_("Searching - please wait"));
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
......@@ -493,9 +450,10 @@ browser_response (GtkWidget *widget,
g_free (proc_list);
/* now sort the store */
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (browser->tv));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser->store),
0, GTK_SORT_ASCENDING);
COLUMN_LABEL, GTK_SORT_ASCENDING);
if (num_procs > 0)
{
......@@ -505,7 +463,7 @@ browser_response (GtkWidget *widget,
}
else
{
dialog_show_message (browser, _("No matches"));
gimp_proc_box_show_message (browser->proc_box, _("No matches"));
}
}
break;
......
This diff is collapsed.
......@@ -18,6 +18,8 @@ noinst_LIBRARIES = libgimpprocbrowser.a
libexec_PROGRAMS = plugin-browser procedure-browser
libgimpprocbrowser_a_SOURCES = \
gimpprocbox.c \
gimpprocbox.h \
gimpprocbrowser.c \
gimpprocbrowser.h \
gimpprocview.c \
......
/* 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.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gimpprocbox.h"
#include "libgimp/stdplugins-intl.h"
/* public functions */
GtkWidget *
gimp_proc_box_new (void)
{
GtkWidget *scrolled_window;
GtkWidget *vbox;
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
vbox);
gtk_widget_show (vbox);
g_object_set_data (G_OBJECT (scrolled_window), "vbox", vbox);
return scrolled_window;
}
void
gimp_proc_box_set_widget (GtkWidget *proc_box,
GtkWidget *widget)
{
GtkWidget *vbox;
GtkWidget *child;
vbox = g_object_get_data (G_OBJECT (proc_box), "vbox");
g_return_if_fail (GTK_IS_VBOX (vbox));
child = g_object_get_data (G_OBJECT (vbox), "child");
if (child)
gtk_container_remove (GTK_CONTAINER (vbox), child);
gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
g_object_set_data (G_OBJECT (vbox), "child", widget);
}
void
gimp_proc_box_show_message (GtkWidget *proc_box,
const gchar *message)
{
GtkWidget *vbox;
GtkWidget *child;
vbox = g_object_get_data (G_OBJECT (proc_box), "vbox");
g_return_if_fail (GTK_IS_VBOX (vbox));
child = g_object_get_data (G_OBJECT (vbox), "child");
if (GTK_IS_LABEL (child))
{
gtk_label_set_text (GTK_LABEL (child), message);
}
else
{
if (child)
gtk_container_remove (GTK_CONTAINER (vbox), child);
child = gtk_label_new (message);
gtk_box_pack_start (GTK_BOX (vbox), child, FALSE, FALSE, 0);
gtk_widget_show (child);
g_object_set_data (G_OBJECT (vbox), "child", child);
}
while (gtk_events_pending ())
gtk_main_iteration ();
}
/* 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_BOX_H__
#define __GIMP_PROC_BOX_H__
GtkWidget * gimp_proc_box_new (void);
void gimp_proc_box_set_widget (GtkWidget *proc_box,
GtkWidget *widget);
void gimp_proc_box_show_message (GtkWidget *proc_box,
const gchar *message);
#endif /* __GIMP_PROC_BOX_H__ */
......@@ -32,8 +32,9 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "gimpprocview.h"
#include "gimpprocbox.h"
#include "gimpprocbrowser.h"
#include "gimpprocview.h"
#include "libgimp/stdplugins-intl.h"
......@@ -59,8 +60,7 @@ typedef struct
GtkWidget *count_label;
GtkWidget *search_entry;
GtkWidget *descr_vbox;
GtkWidget *description;
GtkWidget *proc_box;
GtkListStore *store;
GtkWidget *tv;
......@@ -229,20 +229,11 @@ gimp_proc_browser_dialog_new (GimpProcBrowserApplyCallback apply_callback)
/* right = description */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_size_request (scrolled_window,
browser->proc_box = gimp_proc_box_new ();
gtk_widget_set_size_request (browser->proc_box,
DBL_WIDTH - DBL_LIST_WIDTH, -1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
gtk_paned_pack2 (GTK_PANED (paned), scrolled_window, TRUE, TRUE);
gtk_widget_show (scrolled_window);
browser->descr_vbox = gtk_vbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (browser->descr_vbox), 12);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
browser->descr_vbox);
gtk_widget_show (browser->descr_vbox);
gtk_paned_pack2 (GTK_PANED (paned), browser->proc_box, TRUE, TRUE);
gtk_widget_show (browser->proc_box);
/* now build the list */
......@@ -250,7 +241,6 @@ gimp_proc_browser_dialog_new (GimpProcBrowserApplyCallback apply_callback)
/* initialize the "return" value (for "apply") */
browser->description = NULL;
browser->proc_name = NULL;
browser->scheme_proc_name = NULL;
browser->proc_blurb = NULL;
......@@ -306,8 +296,6 @@ static void
browser_show_procedure (GimpDBBrowser *browser,
gchar *proc_name)
{
GtkWidget *vbox;
g_free (browser->proc_name);
browser->proc_name = g_strdup (proc_name);
......@@ -335,51 +323,19 @@ browser_show_procedure (GimpDBBrowser *browser,
&browser->params,
&browser->return_vals);
vbox = gimp_proc_view_new (browser->scheme_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);
if (browser->description)
gtk_container_remove (GTK_CONTAINER (browser->descr_vbox),
browser->description);
gtk_box_pack_start (GTK_BOX (browser->descr_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
browser->description = vbox;
}
static void
dialog_show_message (GimpDBBrowser *browser,
const gchar *message)
{
if (GTK_IS_LABEL (browser->description))
{
gtk_label_set_text (GTK_LABEL (browser->description), message);
}
else
{
if (browser->description)
gtk_container_remove (GTK_CONTAINER (browser->descr_vbox),
browser->description);
browser->description = gtk_label_new (message);
gtk_box_pack_start (GTK_BOX (browser->descr_vbox),
browser->description, FALSE, FALSE, 0);
gtk_widget_show (browser->description);
}
while (gtk_events_pending ())
gtk_main_iteration ();
gimp_proc_box_set_widget (browser->proc_box,
gimp_proc_view_new (browser->scheme_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
......@@ -422,8 +378,8 @@ browser_response (GtkWidget *widget,
if (response_id == RESPONSE_SEARCH_NAME)
{
dialog_show_message (browser,
_("Searching by name - please wait"));
gimp_proc_box_show_message (browser->proc_box,
_("Searching by name - please wait"));
query = g_string_new ("");
query_text = gtk_entry_get_text (GTK_ENTRY (browser->search_entry));
......@@ -446,8 +402,8 @@ browser_response (GtkWidget *widget,
}
else if (response_id == RESPONSE_SEARCH_BLURB)
{
dialog_show_message (browser,
_("Searching by blurb - please wait"));
gimp_proc_box_show_message (browser->proc_box,
_("Searching by blurb - please wait"));
gimp_procedural_db_query (".*",
(gchar *) gtk_entry_get_text
......@@ -457,7 +413,8 @@ browser_response (GtkWidget *widget,
}
else
{
dialog_show_message (browser, _("Searching - please wait"));
gimp_proc_box_show_message (browser->proc_box,
_("Searching - please wait"));
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
&num_procs, &proc_list);
......@@ -493,9 +450,10 @@ browser_response (GtkWidget *widget,
g_free (proc_list);
/* now sort the store */
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (browser->tv));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (browser->store),
0, GTK_SORT_ASCENDING);
COLUMN_LABEL, GTK_SORT_ASCENDING);
if (num_procs > 0)
{
......@@ -505,7 +463,7 @@ browser_response (GtkWidget *widget,
}
else
{
dialog_show_message (browser, _("No matches"));
gimp_proc_box_show_message (browser->proc_box, _("No matches"));
}
}
break;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment