2000-05-08 09:23:30 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2000-05-31 14:15:06 +08:00
|
|
|
*
|
|
|
|
* gimppatternmenu.c
|
2003-11-03 01:28:56 +08:00
|
|
|
* Copyright (C) 1998 Andy Thomas
|
1998-10-02 06:09:01 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
1999-11-18 05:13:50 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-10-02 06:09:01 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2000-05-08 09:23:30 +08:00
|
|
|
*
|
|
|
|
* This library 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
|
1998-10-02 06:09:01 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
1999-11-18 05:13:50 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2000-05-08 09:23:30 +08:00
|
|
|
*/
|
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-05-24 04:38:52 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
1998-10-02 06:09:01 +08:00
|
|
|
#include "gimp.h"
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
#include "gimpuitypes.h"
|
|
|
|
#include "gimppatternmenu.h"
|
2012-05-03 06:54:21 +08:00
|
|
|
#include "gimppatternselectbutton.h"
|
1998-10-02 06:09:01 +08:00
|
|
|
|
|
|
|
|
2010-07-07 17:48:10 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimppatternmenu
|
|
|
|
* @title: gimppatternmenu
|
|
|
|
* @short_description: A widget for selecting patterns.
|
|
|
|
*
|
|
|
|
* A widget for selecting patterns.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
typedef struct
|
2000-05-08 09:23:30 +08:00
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpRunPatternCallback callback;
|
|
|
|
gpointer data;
|
2007-05-22 22:02:52 +08:00
|
|
|
} CompatCallbackData;
|
1998-10-02 06:09:01 +08:00
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
|
|
|
|
static void compat_callback (GimpPatternSelectButton *pattern_button,
|
|
|
|
const gchar *pattern_name,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint bytes,
|
|
|
|
const guchar *mask_data,
|
|
|
|
gboolean dialog_closing,
|
|
|
|
CompatCallbackData *data);
|
|
|
|
static void compat_callback_data_free (CompatCallbackData *data);
|
2005-03-23 18:51:33 +08:00
|
|
|
|
2003-06-17 21:15:37 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
/**
|
|
|
|
* gimp_pattern_select_widget_new:
|
|
|
|
* @title: Title of the dialog to use or %NULL to use the default title.
|
2003-11-03 01:28:56 +08:00
|
|
|
* @pattern_name: Initial pattern name or %NULL to use current selection.
|
2003-07-01 23:06:06 +08:00
|
|
|
* @callback: A function to call when the selected pattern changes.
|
2013-01-27 23:52:38 +08:00
|
|
|
* @data: A pointer to arbitrary data to be used in the call to @callback.
|
2003-07-01 23:06:06 +08:00
|
|
|
*
|
|
|
|
* Creates a new #GtkWidget that completely controls the selection of
|
|
|
|
* a pattern. This widget is suitable for placement in a table in a
|
|
|
|
* plug-in dialog.
|
|
|
|
*
|
|
|
|
* Returns: A #GtkWidget that you can use in your UI.
|
|
|
|
*/
|
2003-11-03 01:28:56 +08:00
|
|
|
GtkWidget *
|
2003-07-01 23:06:06 +08:00
|
|
|
gimp_pattern_select_widget_new (const gchar *title,
|
2003-11-03 01:28:56 +08:00
|
|
|
const gchar *pattern_name,
|
2003-07-01 23:06:06 +08:00
|
|
|
GimpRunPatternCallback callback,
|
|
|
|
gpointer data)
|
1998-10-02 06:09:01 +08:00
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GtkWidget *pattern_button;
|
|
|
|
CompatCallbackData *compat_data;
|
1998-10-02 06:09:01 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
g_return_val_if_fail (callback != NULL, NULL);
|
2003-06-17 21:15:37 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
pattern_button = gimp_pattern_select_button_new (title, pattern_name);
|
2003-06-17 21:15:37 +08:00
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
compat_data = g_slice_new (CompatCallbackData);
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
compat_data->callback = callback;
|
2007-05-22 22:02:52 +08:00
|
|
|
compat_data->data = data;
|
2003-06-17 21:15:37 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
g_signal_connect_data (pattern_button, "pattern-set",
|
|
|
|
G_CALLBACK (compat_callback),
|
2007-05-22 22:02:52 +08:00
|
|
|
compat_data,
|
|
|
|
(GClosureNotify) compat_callback_data_free, 0);
|
2003-06-17 21:15:37 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
return pattern_button;
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_pattern_select_widget_close:
|
|
|
|
* @widget: A pattern select widget.
|
|
|
|
*
|
|
|
|
* Closes the popup window associated with @widget.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_pattern_select_widget_close (GtkWidget *widget)
|
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
g_return_if_fail (widget != NULL);
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
gimp_select_button_close_popup (GIMP_SELECT_BUTTON (widget));
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_pattern_select_widget_set:
|
|
|
|
* @widget: A pattern select widget.
|
2003-11-03 01:28:56 +08:00
|
|
|
* @pattern_name: Pattern name to set. NULL means no change.
|
2003-07-01 23:06:06 +08:00
|
|
|
*
|
|
|
|
* Sets the current pattern for the pattern select widget. Calls the
|
|
|
|
* callback function if one was supplied in the call to
|
|
|
|
* gimp_pattern_select_widget_new().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_pattern_select_widget_set (GtkWidget *widget,
|
|
|
|
const gchar *pattern_name)
|
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
g_return_if_fail (widget != NULL);
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_pattern_select_button_set_pattern (GIMP_PATTERN_SELECT_BUTTON (widget),
|
|
|
|
pattern_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
static void
|
2006-06-26 09:47:22 +08:00
|
|
|
compat_callback (GimpPatternSelectButton *pattern_button,
|
|
|
|
const gchar *pattern_name,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint bpp,
|
|
|
|
const guchar *mask_data,
|
|
|
|
gboolean dialog_closing,
|
2007-05-22 22:02:52 +08:00
|
|
|
CompatCallbackData *data)
|
2003-07-01 23:06:06 +08:00
|
|
|
{
|
2007-05-22 22:02:52 +08:00
|
|
|
data->callback (pattern_name, width, height, bpp, mask_data,
|
|
|
|
dialog_closing, data->data);
|
|
|
|
}
|
2005-03-23 18:51:33 +08:00
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
static void
|
|
|
|
compat_callback_data_free (CompatCallbackData *data)
|
|
|
|
{
|
|
|
|
g_slice_free (CompatCallbackData, data);
|
2005-03-23 18:51:33 +08:00
|
|
|
}
|