2005-05-18 16:48:47 -07:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2005-05-18 15:21:07 -07:00
|
|
|
*
|
|
|
|
|
* gimpbrowser.c
|
|
|
|
|
* Copyright (C) 2005 Michael Natterer <mitch@gimp.org>
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2005-05-18 16:48:47 -07:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-17 14:28:01 -08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2005-05-18 15:21:07 -07:00
|
|
|
*
|
2005-05-18 16:48:47 -07:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2005-05-18 15:21:07 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-05-18 16:48:47 -07:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
2005-05-18 15:21:07 -07:00
|
|
|
*
|
2005-05-18 16:48:47 -07:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-17 14:28:01 -08:00
|
|
|
* License along with this library. If not, see
|
2018-07-11 14:27:07 -07:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2005-05-18 15:21:07 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2013-11-01 14:32:06 -07:00
|
|
|
#include <gegl.h>
|
2005-05-18 15:21:07 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2005-05-18 16:48:47 -07:00
|
|
|
#include "gimpwidgetstypes.h"
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2005-07-05 18:51:17 -07:00
|
|
|
#include "gimpwidgets.h"
|
2005-05-18 16:48:47 -07:00
|
|
|
#include "gimpwidgetsmarshal.h"
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2005-05-18 16:48:47 -07:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
|
2010-07-05 09:01:28 -07:00
|
|
|
/**
|
|
|
|
|
* SECTION: gimpbrowser
|
|
|
|
|
* @title: GimpBrowser
|
|
|
|
|
* @short_description: A base class for a documentation browser.
|
|
|
|
|
*
|
|
|
|
|
* A base class for a documentation browser.
|
|
|
|
|
**/
|
|
|
|
|
|
2025-06-18 10:03:06 -07:00
|
|
|
#define GIMP_BROWSER_LEFT_MIN_WIDTH 250
|
|
|
|
|
#define GIMP_BROWSER_LEFT_MIN_HEIGHT 250
|
|
|
|
|
#define GIMP_BROWSER_RIGHT_MIN_WIDTH 400
|
|
|
|
|
#define GIMP_BROWSER_RIGHT_MIN_HEIGHT 250
|
2010-07-05 09:01:28 -07:00
|
|
|
|
2005-05-18 15:21:07 -07:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
SEARCH,
|
2025-11-08 14:53:14 -08:00
|
|
|
STOP_SEARCH,
|
2005-05-18 15:21:07 -07:00
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
struct _GimpBrowser
|
2010-12-31 09:19:37 -08:00
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
GtkPaned parent_instance;
|
|
|
|
|
|
2010-12-31 09:19:37 -08:00
|
|
|
GtkWidget *left_vbox;
|
|
|
|
|
|
|
|
|
|
GtkWidget *search_entry;
|
|
|
|
|
guint search_timeout_id;
|
|
|
|
|
|
|
|
|
|
GtkWidget *search_type_combo;
|
|
|
|
|
gint search_type;
|
|
|
|
|
|
|
|
|
|
GtkWidget *count_label;
|
|
|
|
|
|
|
|
|
|
GtkWidget *right_vbox;
|
|
|
|
|
GtkWidget *right_widget;
|
2024-10-16 11:35:05 -07:00
|
|
|
};
|
2010-12-31 09:19:37 -08:00
|
|
|
|
|
|
|
|
|
2010-10-14 08:47:48 -07:00
|
|
|
static void gimp_browser_dispose (GObject *object);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2009-05-24 08:24:28 -07:00
|
|
|
static void gimp_browser_combo_changed (GtkComboBox *combo,
|
|
|
|
|
GimpBrowser *browser);
|
|
|
|
|
static void gimp_browser_entry_changed (GtkEntry *entry,
|
2009-05-24 08:02:55 -07:00
|
|
|
GimpBrowser *browser);
|
2025-11-08 14:53:14 -08:00
|
|
|
static void gimp_browser_stop_search (GtkSearchEntry *entry,
|
|
|
|
|
GimpBrowser *browser);
|
2009-05-24 08:02:55 -07:00
|
|
|
static gboolean gimp_browser_search_timeout (gpointer data);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
G_DEFINE_TYPE (GimpBrowser, gimp_browser, GTK_TYPE_PANED)
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2005-12-20 12:35:23 -08:00
|
|
|
#define parent_class gimp_browser_parent_class
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
static guint browser_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_browser_class_init (GimpBrowserClass *klass)
|
|
|
|
|
{
|
2010-10-14 08:47:48 -07:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
browser_signals[SEARCH] =
|
|
|
|
|
g_signal_new ("search",
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2024-10-16 11:35:05 -07:00
|
|
|
0,
|
2005-05-18 15:21:07 -07:00
|
|
|
NULL, NULL,
|
2005-05-18 16:48:47 -07:00
|
|
|
_gimp_widgets_marshal_VOID__STRING_INT,
|
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
|
G_TYPE_STRING,
|
2005-05-18 15:21:07 -07:00
|
|
|
G_TYPE_INT);
|
|
|
|
|
|
2025-11-08 14:53:14 -08:00
|
|
|
/**
|
|
|
|
|
* GimpBrowser::stop-search:
|
|
|
|
|
* @browser: the object which received the signal
|
|
|
|
|
*
|
|
|
|
|
* This signal is emitted when the search operation was stopped by user input.
|
|
|
|
|
*/
|
|
|
|
|
browser_signals[STOP_SEARCH] =
|
|
|
|
|
g_signal_new ("stop-search",
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2010-10-14 08:47:48 -07:00
|
|
|
object_class->dispose = gimp_browser_dispose;
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_browser_init (GimpBrowser *browser)
|
|
|
|
|
{
|
2025-08-18 07:33:04 -07:00
|
|
|
GtkWidget *hbox = NULL;
|
|
|
|
|
GtkWidget *scrolled_window = NULL;
|
|
|
|
|
GtkWidget *viewport = NULL;
|
2018-05-03 03:51:36 -07:00
|
|
|
|
2010-12-31 09:19:37 -08:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (browser),
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->search_type = -1;
|
2010-12-31 09:19:37 -08:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->left_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2025-06-18 10:03:06 -07:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (browser->left_vbox), GIMP_BROWSER_LEFT_MIN_WIDTH, GIMP_BROWSER_LEFT_MIN_HEIGHT);
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_paned_pack1 (GTK_PANED (browser), browser->left_vbox, TRUE, FALSE);
|
|
|
|
|
gtk_widget_show (browser->left_vbox);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
/* search entry */
|
|
|
|
|
|
2011-09-30 01:50:50 -07:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (browser->left_vbox), hbox, FALSE, FALSE, 0);
|
2005-05-18 15:21:07 -07:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
2025-08-18 07:33:04 -07:00
|
|
|
browser->search_entry = gtk_search_entry_new ();
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), browser->search_entry, TRUE, TRUE, 0);
|
|
|
|
|
gtk_widget_show (browser->search_entry);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
g_signal_connect (browser->search_entry, "changed",
|
2005-05-18 15:21:07 -07:00
|
|
|
G_CALLBACK (gimp_browser_entry_changed),
|
|
|
|
|
browser);
|
2025-11-08 14:53:14 -08:00
|
|
|
g_signal_connect (browser->search_entry, "stop-search",
|
|
|
|
|
G_CALLBACK (gimp_browser_stop_search),
|
|
|
|
|
browser);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
/* count label */
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->count_label = gtk_label_new (_("No matches"));
|
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (browser->count_label), 0.0);
|
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (browser->count_label),
|
2005-07-05 18:51:17 -07:00
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
|
-1);
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_box_pack_end (GTK_BOX (browser->left_vbox), browser->count_label,
|
2005-05-18 15:21:07 -07:00
|
|
|
FALSE, FALSE, 0);
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_widget_show (browser->count_label);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
/* scrolled window */
|
|
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
2025-06-18 10:03:06 -07:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), GIMP_BROWSER_RIGHT_MIN_WIDTH, GIMP_BROWSER_RIGHT_MIN_HEIGHT);
|
2005-05-18 15:21:07 -07:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
2024-06-10 20:10:55 -07:00
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
gtk_paned_pack2 (GTK_PANED (browser), scrolled_window, TRUE, FALSE);
|
2005-05-18 15:21:07 -07:00
|
|
|
gtk_widget_show (scrolled_window);
|
|
|
|
|
|
2016-09-07 11:09:46 -07:00
|
|
|
viewport = gtk_viewport_new (NULL, NULL);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), viewport);
|
|
|
|
|
gtk_widget_show (viewport);
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (browser->right_vbox), 12);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (viewport), browser->right_vbox);
|
|
|
|
|
gtk_widget_show (browser->right_vbox);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_widget_grab_focus (browser->search_entry);
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-10-14 08:47:48 -07:00
|
|
|
gimp_browser_dispose (GObject *object)
|
2005-05-18 15:21:07 -07:00
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
GimpBrowser *browser = GIMP_BROWSER (object);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
if (browser->search_timeout_id)
|
2005-05-18 15:21:07 -07:00
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
g_source_remove (browser->search_timeout_id);
|
|
|
|
|
browser->search_timeout_id = 0;
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
2010-10-14 08:47:48 -07:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
2005-09-27 10:11:01 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_browser_new:
|
|
|
|
|
*
|
|
|
|
|
* Create a new #GimpBrowser widget.
|
|
|
|
|
*
|
2019-08-02 15:10:14 -07:00
|
|
|
* Returns: a newly created #GimpBrowser.
|
2005-09-27 10:11:01 -07:00
|
|
|
*
|
2015-05-31 12:18:09 -07:00
|
|
|
* Since: 2.4
|
2005-09-27 10:11:01 -07:00
|
|
|
**/
|
2005-05-18 15:21:07 -07:00
|
|
|
GtkWidget *
|
|
|
|
|
gimp_browser_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GIMP_TYPE_BROWSER, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-27 10:11:01 -07:00
|
|
|
/**
|
2020-05-21 04:43:47 -07:00
|
|
|
* gimp_browser_add_search_types: (skip)
|
2005-09-27 10:11:01 -07:00
|
|
|
* @browser: a #GimpBrowser widget
|
|
|
|
|
* @first_type_label: the label of the first search type
|
|
|
|
|
* @first_type_id: an integer that identifies the first search type
|
|
|
|
|
* @...: a %NULL-terminated list of more labels and ids.
|
|
|
|
|
*
|
|
|
|
|
* Populates the #GtkComboBox with search types.
|
|
|
|
|
*
|
2015-05-31 12:18:09 -07:00
|
|
|
* Since: 2.4
|
2005-09-27 10:11:01 -07:00
|
|
|
**/
|
2005-05-18 15:21:07 -07:00
|
|
|
void
|
|
|
|
|
gimp_browser_add_search_types (GimpBrowser *browser,
|
|
|
|
|
const gchar *first_type_label,
|
|
|
|
|
gint first_type_id,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BROWSER (browser));
|
|
|
|
|
g_return_if_fail (first_type_label != NULL);
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
if (! browser->search_type_combo)
|
2005-05-18 15:21:07 -07:00
|
|
|
{
|
|
|
|
|
GtkWidget *combo;
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start (args, first_type_id);
|
|
|
|
|
combo = gimp_int_combo_box_new_valist (first_type_label,
|
|
|
|
|
first_type_id,
|
|
|
|
|
args);
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
2018-04-29 08:35:33 -07:00
|
|
|
gtk_widget_set_focus_on_click (combo, FALSE);
|
2005-07-05 17:31:59 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->search_type_combo = combo;
|
|
|
|
|
browser->search_type = first_type_id;
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_box_pack_end (GTK_BOX (gtk_widget_get_parent (browser->search_entry)),
|
2008-06-28 08:09:46 -07:00
|
|
|
combo, FALSE, FALSE, 0);
|
2005-05-18 15:21:07 -07:00
|
|
|
gtk_widget_show (combo);
|
|
|
|
|
|
|
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->search_type,
|
2005-05-18 15:21:07 -07:00
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
2024-10-16 11:35:05 -07:00
|
|
|
&browser->search_type, NULL);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
2009-05-24 08:24:28 -07:00
|
|
|
G_CALLBACK (gimp_browser_combo_changed),
|
2005-05-18 15:21:07 -07:00
|
|
|
browser);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (browser->search_type_combo),
|
2005-05-18 15:21:07 -07:00
|
|
|
first_type_label, first_type_id,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-31 09:19:37 -08:00
|
|
|
/**
|
|
|
|
|
* gimp_browser_get_left_vbox:
|
|
|
|
|
* @browser: a #GimpBrowser widget
|
|
|
|
|
*
|
GIR: Try to return more specific GtkWidget subclass
In GTK, a common scheme is to let a function creating a specific widget
to return a `GtkWidget *`, rather than the specific subtype, since you
often need to call API of GtkWidget, avoiding some useless casts.
For bindings however (and especially bindings to compiled languages),
this is a bit annoying, as you have to explicitly change the type of the
return value (downcast), which is not trivial (or at least desirable) in
each language.
Luckily, we can use `(type ...)` annotation for this use case, leaving
the C API unchanged, while improving the experience for bindings.
2020-12-25 06:05:16 -08:00
|
|
|
* Returns: (transfer none) (type GtkBox): The left vbox.
|
2010-12-31 09:19:37 -08:00
|
|
|
*
|
2019-07-23 16:18:30 -07:00
|
|
|
* Since: 3.0
|
2010-12-31 09:19:37 -08:00
|
|
|
**/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gimp_browser_get_left_vbox (GimpBrowser *browser)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BROWSER (browser), NULL);
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
return browser->left_vbox;
|
2010-12-31 09:19:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_browser_get_right_vbox:
|
|
|
|
|
* @browser: a #GimpBrowser widget
|
|
|
|
|
*
|
GIR: Try to return more specific GtkWidget subclass
In GTK, a common scheme is to let a function creating a specific widget
to return a `GtkWidget *`, rather than the specific subtype, since you
often need to call API of GtkWidget, avoiding some useless casts.
For bindings however (and especially bindings to compiled languages),
this is a bit annoying, as you have to explicitly change the type of the
return value (downcast), which is not trivial (or at least desirable) in
each language.
Luckily, we can use `(type ...)` annotation for this use case, leaving
the C API unchanged, while improving the experience for bindings.
2020-12-25 06:05:16 -08:00
|
|
|
* Returns: (transfer none) (type GtkBox): The right vbox.
|
2010-12-31 09:19:37 -08:00
|
|
|
*
|
2019-07-23 16:18:30 -07:00
|
|
|
* Since: 3.0
|
2010-12-31 09:19:37 -08:00
|
|
|
**/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gimp_browser_get_right_vbox (GimpBrowser *browser)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_BROWSER (browser), NULL);
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
return browser->right_vbox;
|
2010-12-31 09:19:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gimp_browser_set_search_summary:
|
|
|
|
|
* @browser: a #GimpBrowser widget
|
|
|
|
|
* @summary: a string describing the search result
|
|
|
|
|
*
|
|
|
|
|
* Sets the search summary text.
|
|
|
|
|
*
|
2019-07-23 16:18:30 -07:00
|
|
|
* Since: 3.0
|
2010-12-31 09:19:37 -08:00
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
gimp_browser_set_search_summary (GimpBrowser *browser,
|
|
|
|
|
const gchar *summary)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BROWSER (browser));
|
|
|
|
|
g_return_if_fail (summary != NULL);
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_label_set_text (GTK_LABEL (browser->count_label), summary);
|
2010-12-31 09:19:37 -08:00
|
|
|
}
|
|
|
|
|
|
2005-09-27 10:11:01 -07:00
|
|
|
/**
|
|
|
|
|
* gimp_browser_set_widget:
|
|
|
|
|
* @browser: a #GimpBrowser widget
|
|
|
|
|
* @widget: a #GtkWidget
|
|
|
|
|
*
|
|
|
|
|
* Sets the widget to appear on the right side of the @browser.
|
|
|
|
|
*
|
2015-05-31 12:18:09 -07:00
|
|
|
* Since: 2.4
|
2005-09-27 10:11:01 -07:00
|
|
|
**/
|
2005-05-18 15:21:07 -07:00
|
|
|
void
|
|
|
|
|
gimp_browser_set_widget (GimpBrowser *browser,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BROWSER (browser));
|
2005-06-23 04:28:15 -07:00
|
|
|
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
if (widget == browser->right_widget)
|
2005-06-23 04:28:15 -07:00
|
|
|
return;
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
if (browser->right_widget)
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (browser->right_vbox),
|
|
|
|
|
browser->right_widget);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->right_widget = widget;
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2005-06-23 04:28:15 -07:00
|
|
|
if (widget)
|
|
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (browser->right_vbox), widget,
|
2005-06-23 04:28:15 -07:00
|
|
|
FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
}
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
2005-09-27 10:11:01 -07:00
|
|
|
/**
|
|
|
|
|
* gimp_browser_show_message:
|
|
|
|
|
* @browser: a #GimpBrowser widget
|
|
|
|
|
* @message: text message
|
|
|
|
|
*
|
|
|
|
|
* Displays @message in the right side of the @browser. Unless the right
|
|
|
|
|
* side already contains a #GtkLabel, the widget previously added with
|
|
|
|
|
* gimp_browser_set_widget() is removed and replaced by a #GtkLabel.
|
|
|
|
|
*
|
2015-05-31 12:18:09 -07:00
|
|
|
* Since: 2.4
|
2005-09-27 10:11:01 -07:00
|
|
|
**/
|
2005-05-18 15:21:07 -07:00
|
|
|
void
|
|
|
|
|
gimp_browser_show_message (GimpBrowser *browser,
|
|
|
|
|
const gchar *message)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_BROWSER (browser));
|
|
|
|
|
g_return_if_fail (message != NULL);
|
|
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
if (GTK_IS_LABEL (browser->right_widget))
|
2005-05-18 15:21:07 -07:00
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
gtk_label_set_text (GTK_LABEL (browser->right_widget), message);
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-10-05 16:31:49 -07:00
|
|
|
GtkWidget *label = gtk_label_new (message);
|
|
|
|
|
|
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
|
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
|
-1);
|
|
|
|
|
gimp_browser_set_widget (browser, label);
|
2005-05-18 15:21:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
|
gtk_main_iteration ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
|
|
static void
|
2009-05-24 08:24:28 -07:00
|
|
|
gimp_browser_queue_search (GimpBrowser *browser)
|
2005-05-18 15:21:07 -07:00
|
|
|
{
|
2024-10-16 11:35:05 -07:00
|
|
|
if (browser->search_timeout_id)
|
|
|
|
|
g_source_remove (browser->search_timeout_id);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->search_timeout_id =
|
2005-05-18 15:21:07 -07:00
|
|
|
g_timeout_add (100, gimp_browser_search_timeout, browser);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-24 08:24:28 -07:00
|
|
|
static void
|
|
|
|
|
gimp_browser_combo_changed (GtkComboBox *combo,
|
|
|
|
|
GimpBrowser *browser)
|
|
|
|
|
{
|
|
|
|
|
gimp_browser_queue_search (browser);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_browser_entry_changed (GtkEntry *entry,
|
|
|
|
|
GimpBrowser *browser)
|
|
|
|
|
{
|
|
|
|
|
gimp_browser_queue_search (browser);
|
2009-05-24 08:02:55 -07:00
|
|
|
}
|
|
|
|
|
|
2025-11-08 14:53:14 -08:00
|
|
|
static void
|
|
|
|
|
gimp_browser_stop_search (GtkSearchEntry *entry,
|
|
|
|
|
GimpBrowser *browser)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (browser, browser_signals[STOP_SEARCH], 0);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-18 15:21:07 -07:00
|
|
|
static gboolean
|
|
|
|
|
gimp_browser_search_timeout (gpointer data)
|
|
|
|
|
{
|
2025-08-18 07:33:04 -07:00
|
|
|
GimpBrowser *browser = GIMP_BROWSER (data);
|
|
|
|
|
const gchar *search_string = NULL;
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
search_string = gtk_entry_get_text (GTK_ENTRY (browser->search_entry));
|
2005-05-18 16:48:47 -07:00
|
|
|
|
|
|
|
|
if (! search_string)
|
|
|
|
|
search_string = "";
|
|
|
|
|
|
2010-12-31 09:19:37 -08:00
|
|
|
g_signal_emit (data, browser_signals[SEARCH], 0,
|
2024-10-16 11:35:05 -07:00
|
|
|
search_string, browser->search_type);
|
2005-05-18 15:21:07 -07:00
|
|
|
|
2024-10-16 11:35:05 -07:00
|
|
|
browser->search_timeout_id = 0;
|
2005-05-18 15:21:07 -07:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|