2003-03-28 22:13:54 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
2005-06-05 06:36:05 +08:00
|
|
|
* gimpfontselectbutton.c
|
2003-03-28 22:13:54 +08:00
|
|
|
* 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"
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.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"
|
2005-06-05 06:36:05 +08:00
|
|
|
#include "gimpuimarshal.h"
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2003-06-17 17:43:14 +08:00
|
|
|
#include "libgimp-intl.h"
|
|
|
|
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
#define GIMP_FONT_SELECT_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_FONT_SELECT_BUTTON, GimpFontSelectButtonPrivate))
|
|
|
|
|
|
|
|
typedef struct _GimpFontSelectButtonPrivate GimpFontSelectButtonPrivate;
|
|
|
|
|
|
|
|
struct _GimpFontSelectButtonPrivate
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2006-01-25 22:35:56 +08:00
|
|
|
gchar *title;
|
2006-06-26 09:47:22 +08:00
|
|
|
|
2006-01-25 22:35:56 +08:00
|
|
|
gchar *font_name; /* local copy */
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2006-01-25 22:35:56 +08:00
|
|
|
GtkWidget *inside;
|
|
|
|
GtkWidget *label;
|
2006-06-26 09:47:22 +08:00
|
|
|
};
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FONT_SET,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_TITLE,
|
|
|
|
PROP_FONT_NAME
|
|
|
|
};
|
|
|
|
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
/* local function prototypes */
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
static void gimp_font_select_button_finalize (GObject *object);
|
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
static void gimp_font_select_button_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_font_select_button_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
static void gimp_font_select_button_clicked (GimpFontSelectButton *button);
|
2006-06-26 09:47:22 +08:00
|
|
|
|
|
|
|
static void gimp_font_select_button_callback (const gchar *font_name,
|
|
|
|
gboolean dialog_closing,
|
|
|
|
gpointer user_data);
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
static void gimp_font_select_drag_data_received (GimpFontSelectButton *button,
|
2006-06-26 09:47:22 +08:00
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection,
|
|
|
|
guint info,
|
|
|
|
guint time);
|
2005-03-23 18:51:33 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
static GtkWidget * gimp_font_select_button_create_inside (GimpFontSelectButton *button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-03-23 18:51:33 +08:00
|
|
|
|
|
|
|
static const GtkTargetEntry target = { "application/x-gimp-font-name", 0 };
|
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
static guint font_button_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
G_DEFINE_TYPE (GimpFontSelectButton, gimp_font_select_button,
|
|
|
|
GIMP_TYPE_SELECT_BUTTON)
|
2006-05-15 17:46:31 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_font_select_button_class_init (GimpFontSelectButtonClass *klass)
|
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpSelectButtonClass *select_button_class = GIMP_SELECT_BUTTON_CLASS (klass);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
object_class->finalize = gimp_font_select_button_finalize;
|
|
|
|
object_class->set_property = gimp_font_select_button_set_property;
|
|
|
|
object_class->get_property = gimp_font_select_button_get_property;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
select_button_class->select_destroy = gimp_font_select_destroy;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
klass->font_set = NULL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpFontSelectButton:title:
|
|
|
|
*
|
2006-06-26 09:47:22 +08:00
|
|
|
* The title to be used for the font selection popup dialog.
|
2005-06-05 06:36:05 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
|
|
|
*/
|
2006-06-26 09:47:22 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_TITLE,
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
"Title",
|
|
|
|
"The title to be used for the font selection popup dialog",
|
2005-06-05 06:36:05 +08:00
|
|
|
_("Font Selection"),
|
2006-01-31 00:10:56 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
2005-06-05 06:36:05 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpFontSelectButton:font-name:
|
|
|
|
*
|
|
|
|
* The name of the currently selected font.
|
|
|
|
*
|
2006-06-26 09:47:22 +08:00
|
|
|
* Since: GIMP 2.4
|
2005-06-05 06:36:05 +08:00
|
|
|
*/
|
2006-06-26 09:47:22 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_FONT_NAME,
|
|
|
|
g_param_spec_string ("font-name",
|
|
|
|
"Font name",
|
|
|
|
"The name of the currently selected font",
|
2005-06-05 06:36:05 +08:00
|
|
|
_("Sans"),
|
2006-01-31 00:10:56 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpFontSelectButton::font-set:
|
|
|
|
* @widget: the object which received the signal.
|
|
|
|
* @font_name: the name of the currently selected font.
|
|
|
|
* @dialog_closing: whether the dialog was closed or not.
|
|
|
|
*
|
|
|
|
* The ::font-set signal is emitted when the user selects a font.
|
|
|
|
*
|
2006-06-26 09:47:22 +08:00
|
|
|
* Since: GIMP 2.4
|
2005-06-05 06:36:05 +08:00
|
|
|
*/
|
|
|
|
font_button_signals[FONT_SET] =
|
|
|
|
g_signal_new ("font-set",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpFontSelectButtonClass, font_set),
|
|
|
|
NULL, NULL,
|
|
|
|
_gimpui_marshal_VOID__STRING_BOOLEAN,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_BOOLEAN);
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
g_type_class_add_private (object_class,
|
|
|
|
sizeof (GimpFontSelectButtonPrivate));
|
2005-06-05 06:36:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_init (GimpFontSelectButton *button)
|
2005-06-05 06:36:05 +08:00
|
|
|
{
|
2006-01-25 22:35:56 +08:00
|
|
|
GimpFontSelectButtonPrivate *priv;
|
2006-06-28 18:35:22 +08:00
|
|
|
|
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
2006-01-25 22:35:56 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
priv->font_name = NULL;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
priv->inside = gimp_font_select_button_create_inside (button);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), priv->inside);
|
2005-06-05 06:36:05 +08:00
|
|
|
}
|
2003-03-28 22:13:54 +08:00
|
|
|
|
|
|
|
/**
|
2005-06-05 06:36:05 +08:00
|
|
|
* gimp_font_select_button_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-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.
|
2006-06-26 09:47:22 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
2003-12-05 23:55:15 +08:00
|
|
|
GtkWidget *
|
2005-06-05 06:36:05 +08:00
|
|
|
gimp_font_select_button_new (const gchar *title,
|
|
|
|
const gchar *font_name)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2006-06-28 18:35:22 +08:00
|
|
|
GtkWidget *button;
|
2004-07-28 08:04:13 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
if (title)
|
2006-06-28 18:35:22 +08:00
|
|
|
button = g_object_new (GIMP_TYPE_FONT_SELECT_BUTTON,
|
|
|
|
"title", title,
|
|
|
|
"font-name", font_name,
|
|
|
|
NULL);
|
2005-06-05 06:36:05 +08:00
|
|
|
else
|
2006-06-28 18:35:22 +08:00
|
|
|
button = g_object_new (GIMP_TYPE_FONT_SELECT_BUTTON,
|
|
|
|
"font-name", font_name,
|
|
|
|
NULL);
|
2006-01-25 22:35:56 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
return button;
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-06-28 18:35:22 +08:00
|
|
|
* gimp_font_select_button_get_font:
|
|
|
|
* @button: A #GimpFontSelectButton
|
2005-06-05 06:36:05 +08:00
|
|
|
*
|
|
|
|
* Retrieves the name of currently selected font.
|
|
|
|
*
|
|
|
|
* Returns: an internal copy of the font name which must not be freed.
|
2003-03-28 22:13:54 +08:00
|
|
|
*
|
2006-06-26 09:47:22 +08:00
|
|
|
* Since: GIMP 2.4
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
2006-07-05 22:13:20 +08:00
|
|
|
const gchar *
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_get_font (GimpFontSelectButton *button)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpFontSelectButtonPrivate *priv;
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_FONT_SELECT_BUTTON (button), NULL);
|
2006-06-26 09:47:22 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
2006-06-26 09:47:22 +08:00
|
|
|
return priv->font_name;
|
2005-06-05 06:36:05 +08:00
|
|
|
}
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
/**
|
2006-06-28 18:35:22 +08:00
|
|
|
* gimp_font_select_button_set_font:
|
|
|
|
* @button: A #GimpFontSelectButton
|
2005-06-05 06:36:05 +08:00
|
|
|
* @font_name: Font name to set; %NULL means no change.
|
|
|
|
*
|
|
|
|
* Sets the current font for the font select button.
|
|
|
|
*
|
2006-06-26 09:47:22 +08:00
|
|
|
* Since: GIMP 2.4
|
2005-06-05 06:36:05 +08:00
|
|
|
*/
|
|
|
|
void
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_set_font (GimpFontSelectButton *button,
|
|
|
|
const gchar *font_name)
|
2005-06-05 06:36:05 +08:00
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpSelectButton *select_button;
|
2006-01-25 22:35:56 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
g_return_if_fail (GIMP_IS_FONT_SELECT_BUTTON (button));
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
select_button = GIMP_SELECT_BUTTON (button);
|
2006-01-25 22:35:56 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
if (select_button->temp_callback)
|
|
|
|
gimp_fonts_set_popup (select_button->temp_callback, font_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
else
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_callback (font_name, FALSE, button);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
static void
|
|
|
|
gimp_font_select_button_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpFontSelectButtonPrivate *priv;
|
|
|
|
|
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
g_free (priv->font_name);
|
|
|
|
priv->font_name = NULL;
|
|
|
|
|
|
|
|
g_free (priv->title);
|
|
|
|
priv->title = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gimp_font_select_button_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
static void
|
2005-06-05 06:36:05 +08:00
|
|
|
gimp_font_select_button_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-06-28 18:35:22 +08:00
|
|
|
GimpFontSelectButton *button = GIMP_FONT_SELECT_BUTTON (object);
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpFontSelectButtonPrivate *priv;
|
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_TITLE:
|
2006-01-25 22:35:56 +08:00
|
|
|
priv->title = g_value_dup_string (value);
|
2005-06-05 06:36:05 +08:00
|
|
|
break;
|
|
|
|
case PROP_FONT_NAME:
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_set_font (button,
|
|
|
|
g_value_get_string (value));
|
2005-06-05 06:36:05 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_font_select_button_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-06-28 18:35:22 +08:00
|
|
|
GimpFontSelectButton *button = GIMP_FONT_SELECT_BUTTON (object);
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpFontSelectButtonPrivate *priv;
|
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_TITLE:
|
2006-01-25 22:35:56 +08:00
|
|
|
g_value_set_string (value, priv->title);
|
2005-06-05 06:36:05 +08:00
|
|
|
break;
|
|
|
|
case PROP_FONT_NAME:
|
2006-01-25 22:35:56 +08:00
|
|
|
g_value_set_string (value, priv->font_name);
|
2005-06-05 06:36:05 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-26 09:47:22 +08:00
|
|
|
gimp_font_select_button_callback (const gchar *font_name,
|
|
|
|
gboolean dialog_closing,
|
|
|
|
gpointer user_data)
|
2003-07-01 23:06:06 +08:00
|
|
|
{
|
2006-06-28 18:35:22 +08:00
|
|
|
GimpFontSelectButton *button;
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpFontSelectButtonPrivate *priv;
|
|
|
|
GimpSelectButton *select_button;
|
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
button = GIMP_FONT_SELECT_BUTTON (user_data);
|
2006-06-26 09:47:22 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
|
|
|
select_button = GIMP_SELECT_BUTTON (button);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2006-01-25 22:35:56 +08:00
|
|
|
g_free (priv->font_name);
|
2006-06-26 09:47:22 +08:00
|
|
|
priv->font_name = g_strdup (font_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (priv->label), font_name);
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
if (dialog_closing)
|
|
|
|
select_button->temp_callback = NULL;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
g_signal_emit (button, font_button_signals[FONT_SET], 0,
|
2006-06-26 09:47:22 +08:00
|
|
|
font_name, dialog_closing);
|
2006-06-28 18:35:22 +08:00
|
|
|
g_object_notify (G_OBJECT (button), "font-name");
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_clicked (GimpFontSelectButton *button)
|
2003-07-01 23:06:06 +08:00
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GimpFontSelectButtonPrivate *priv;
|
|
|
|
GimpSelectButton *select_button;
|
2006-06-28 18:35:22 +08:00
|
|
|
|
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
|
|
|
select_button = GIMP_SELECT_BUTTON (button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
if (select_button->temp_callback)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2003-07-01 23:06:06 +08:00
|
|
|
/* calling gimp_fonts_set_popup() raises the dialog */
|
2006-06-26 09:47:22 +08:00
|
|
|
gimp_fonts_set_popup (select_button->temp_callback,
|
|
|
|
priv->font_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
select_button->temp_callback =
|
2006-01-25 22:35:56 +08:00
|
|
|
gimp_font_select_new (priv->title, priv->font_name,
|
2005-06-05 06:36:05 +08:00
|
|
|
gimp_font_select_button_callback,
|
2006-06-28 18:35:22 +08:00
|
|
|
button);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
}
|
2005-03-23 18:51:33 +08:00
|
|
|
|
|
|
|
static void
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_drag_data_received (GimpFontSelectButton *button,
|
2006-06-26 09:47:22 +08:00
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection,
|
|
|
|
guint info,
|
|
|
|
guint time)
|
2005-03-23 18:51:33 +08:00
|
|
|
{
|
2009-03-22 23:49:13 +08:00
|
|
|
gint length = gtk_selection_data_get_length (selection);
|
2005-07-25 21:53:00 +08:00
|
|
|
gchar *str;
|
2005-03-23 19:26:56 +08:00
|
|
|
|
2009-03-22 23:49:13 +08:00
|
|
|
if (gtk_selection_data_get_format (selection) != 8 || length < 1)
|
2005-03-23 18:51:33 +08:00
|
|
|
{
|
2009-03-22 23:49:13 +08:00
|
|
|
g_warning ("%s: received invalid font data", G_STRFUNC);
|
2005-03-23 18:51:33 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-03-22 23:49:13 +08:00
|
|
|
str = g_strndup ((const gchar *) gtk_selection_data_get_data (selection),
|
|
|
|
length);
|
2005-03-23 18:51:33 +08:00
|
|
|
|
2005-07-25 21:53:00 +08:00
|
|
|
if (g_utf8_validate (str, -1, NULL))
|
|
|
|
{
|
|
|
|
gint pid;
|
|
|
|
gpointer unused;
|
|
|
|
gint name_offset = 0;
|
|
|
|
|
|
|
|
if (sscanf (str, "%i:%p:%n", &pid, &unused, &name_offset) >= 2 &&
|
|
|
|
pid == gimp_getpid () && name_offset > 0)
|
|
|
|
{
|
|
|
|
gchar *name = str + name_offset;
|
|
|
|
|
2006-06-28 18:35:22 +08:00
|
|
|
gimp_font_select_button_set_font (button, name);
|
2005-07-25 21:53:00 +08:00
|
|
|
}
|
|
|
|
}
|
2005-03-23 18:51:33 +08:00
|
|
|
|
2005-07-25 21:53:00 +08:00
|
|
|
g_free (str);
|
2005-03-23 18:51:33 +08:00
|
|
|
}
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
static GtkWidget *
|
2006-06-26 09:47:22 +08:00
|
|
|
gimp_font_select_button_create_inside (GimpFontSelectButton *font_button)
|
2005-06-05 06:36:05 +08:00
|
|
|
{
|
2006-06-26 09:47:22 +08:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *image;
|
|
|
|
GimpFontSelectButtonPrivate *priv;
|
|
|
|
|
|
|
|
priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (font_button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
gtk_widget_push_composite_child ();
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
button = gtk_button_new ();
|
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2006-06-26 09:47:22 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), hbox);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_FONT, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
|
|
|
|
2006-01-25 22:35:56 +08:00
|
|
|
priv->label = gtk_label_new (priv->font_name);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), priv->label, TRUE, TRUE, 4);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
gtk_widget_show_all (button);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (button, "clicked",
|
|
|
|
G_CALLBACK (gimp_font_select_button_clicked),
|
|
|
|
font_button);
|
|
|
|
|
|
|
|
gtk_drag_dest_set (GTK_WIDGET (button),
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
&target, 1,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (button, "drag-data-received",
|
|
|
|
G_CALLBACK (gimp_font_select_drag_data_received),
|
|
|
|
font_button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
gtk_widget_pop_composite_child ();
|
|
|
|
|
2006-06-26 09:47:22 +08:00
|
|
|
return button;
|
2005-06-05 06:36:05 +08:00
|
|
|
}
|