2003-03-28 22:13:54 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpfontmenu.c
|
|
|
|
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2003-03-28 22:13:54 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* 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.
|
2003-03-28 22:13:54 +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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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/>.
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-05-24 04:38:52 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2003-03-28 22:13:54 +08:00
|
|
|
#include "gimp.h"
|
2006-06-26 09:47:22 +08:00
|
|
|
|
|
|
|
#include "gimpuitypes.h"
|
|
|
|
#include "gimpfontselectbutton.h"
|
|
|
|
|
|
|
|
#undef GIMP_DISABLE_DEPRECATED
|
|
|
|
#include "gimpfontmenu.h"
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
typedef struct
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-05 06:36:05 +08:00
|
|
|
GimpRunFontCallback callback;
|
|
|
|
gpointer data;
|
2007-05-22 22:02:52 +08:00
|
|
|
} CompatCallbackData;
|
2003-03-28 22:13:54 +08:00
|
|
|
|
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
static void compat_callback (GimpFontSelectButton *font_button,
|
|
|
|
const gchar *font_name,
|
|
|
|
gboolean dialog_closing,
|
|
|
|
CompatCallbackData *data);
|
|
|
|
static void compat_callback_data_free (CompatCallbackData *data);
|
2005-03-23 18:51:33 +08:00
|
|
|
|
2003-03-28 22:13:54 +08:00
|
|
|
|
|
|
|
/**
|
2003-07-01 23:06:06 +08:00
|
|
|
* gimp_font_select_widget_new:
|
2006-06-26 09:47:22 +08:00
|
|
|
* @title: Title of the dialog to use or %NULL to use the default title.
|
2003-12-05 23:55:15 +08:00
|
|
|
* @font_name: Initial font name.
|
2003-07-01 23:06:06 +08:00
|
|
|
* @callback: A function to call when the selected font changes.
|
|
|
|
* @data: A pointer to arbitary data to be used in the call to @callback.
|
2003-03-28 22:13:54 +08:00
|
|
|
*
|
2003-07-01 23:06:06 +08:00
|
|
|
* Creates a new #GtkWidget that completely controls the selection of
|
|
|
|
* a font. This widget is suitable for placement in a table in a
|
2003-03-28 22:13:54 +08:00
|
|
|
* plug-in dialog.
|
|
|
|
*
|
2003-07-01 23:06:06 +08:00
|
|
|
* Returns: A #GtkWidget that you can use in your UI.
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
2003-12-05 23:55:15 +08:00
|
|
|
GtkWidget *
|
2003-07-01 23:06:06 +08:00
|
|
|
gimp_font_select_widget_new (const gchar *title,
|
2003-12-05 23:55:15 +08:00
|
|
|
const gchar *font_name,
|
2003-07-01 23:06:06 +08:00
|
|
|
GimpRunFontCallback callback,
|
|
|
|
gpointer data)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-05 06:36:05 +08:00
|
|
|
GtkWidget *font_button;
|
|
|
|
CompatCallbackData *compat_data;
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
g_return_val_if_fail (callback != NULL, NULL);
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
font_button = gimp_font_select_button_new (title, font_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
compat_data = g_slice_new (CompatCallbackData);
|
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
compat_data->callback = callback;
|
2007-05-22 22:02:52 +08:00
|
|
|
compat_data->data = data;
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
g_signal_connect_data (font_button, "font-set",
|
|
|
|
G_CALLBACK (compat_callback),
|
2007-05-22 22:02:52 +08:00
|
|
|
compat_data,
|
|
|
|
(GClosureNotify) compat_callback_data_free, 0);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
return font_button;
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-07-01 23:06:06 +08:00
|
|
|
* gimp_font_select_widget_close:
|
2003-03-28 22:13:54 +08:00
|
|
|
* @widget: A font select widget.
|
|
|
|
*
|
|
|
|
* Closes the popup window associated with @widget.
|
|
|
|
*/
|
|
|
|
void
|
2003-07-01 23:06:06 +08:00
|
|
|
gimp_font_select_widget_close (GtkWidget *widget)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-05 06:36:05 +08:00
|
|
|
g_return_if_fail (widget != NULL);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
gimp_select_button_close_popup (GIMP_SELECT_BUTTON (widget));
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-07-01 23:06:06 +08:00
|
|
|
* gimp_font_select_widget_set;
|
|
|
|
* @widget: A font select widget.
|
2003-12-05 23:55:15 +08:00
|
|
|
* @font_name: Font name to set; %NULL means no change.
|
2003-03-28 22:13:54 +08:00
|
|
|
*
|
2003-07-01 23:06:06 +08:00
|
|
|
* Sets the current font for the font select widget. Calls the
|
|
|
|
* callback function if one was supplied in the call to
|
|
|
|
* gimp_font_select_widget_new().
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
|
|
|
void
|
2003-07-01 23:06:06 +08:00
|
|
|
gimp_font_select_widget_set (GtkWidget *widget,
|
|
|
|
const gchar *font_name)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-05 06:36:05 +08:00
|
|
|
g_return_if_fail (widget != NULL);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_set_font (GIMP_FONT_SELECT_BUTTON (widget),
|
|
|
|
font_name);
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
|
2007-05-22 22:02:52 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
static void
|
2005-06-05 06:36:05 +08:00
|
|
|
compat_callback (GimpFontSelectButton *font_button,
|
|
|
|
const gchar *font_name,
|
|
|
|
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 (font_name, 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
|
|
|
}
|