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>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
#include "gimpui.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
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
#define GIMP_FONT_SELECT_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_FONT_SELECT_BUTTON, GimpFontSelectButtonPrivate))
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
struct _GimpFontSelectButtonPrivate
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2003-06-17 17:43:14 +08:00
|
|
|
gchar *title;
|
2005-06-05 06:36:05 +08:00
|
|
|
gchar *font_name; /* Local copy */
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
GtkWidget *inside;
|
2003-07-01 23:06:06 +08:00
|
|
|
GtkWidget *label;
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
const gchar *temp_font_callback;
|
|
|
|
};
|
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
|
|
|
|
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);
|
|
|
|
|
|
|
|
static void gimp_font_select_button_destroy (GtkObject *object);
|
|
|
|
static void gimp_font_select_button_clicked (GtkButton *button);
|
|
|
|
static void gimp_font_select_button_callback (const gchar *name,
|
2003-07-01 23:06:06 +08:00
|
|
|
gboolean closing,
|
|
|
|
gpointer data);
|
2003-06-17 17:43:14 +08:00
|
|
|
|
2005-03-23 18:51:33 +08:00
|
|
|
static void gimp_font_select_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection,
|
|
|
|
guint info,
|
|
|
|
guint time);
|
|
|
|
|
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 };
|
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE(GimpFontSelectButton,
|
|
|
|
gimp_font_select_button,
|
|
|
|
GTK_TYPE_BUTTON);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_font_select_button_class_init (GimpFontSelectButtonClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2005-06-26 20:53:31 +08:00
|
|
|
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
gobject_class->set_property = gimp_font_select_button_set_property;
|
|
|
|
gobject_class->get_property = gimp_font_select_button_get_property;
|
|
|
|
|
|
|
|
object_class->destroy = gimp_font_select_button_destroy;
|
|
|
|
|
|
|
|
widget_class->drag_data_received = gimp_font_select_drag_data_received;
|
|
|
|
|
|
|
|
button_class->clicked = gimp_font_select_button_clicked;
|
|
|
|
|
|
|
|
klass->font_set = NULL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpFontSelectButton:title:
|
|
|
|
*
|
|
|
|
* The title to be used for the font selection dialog.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TITLE,
|
|
|
|
g_param_spec_string ("title", NULL, NULL,
|
|
|
|
_("Font Selection"),
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GimpFontSelectButton:font-name:
|
|
|
|
*
|
|
|
|
* The name of the currently selected font.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class, PROP_FONT_NAME,
|
|
|
|
g_param_spec_string ("font-name", NULL, NULL,
|
|
|
|
_("Sans"),
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
|
|
|
g_type_class_add_private (object_class, sizeof (GimpFontSelectButtonPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_init (GimpFontSelectButton *button)
|
2005-06-05 06:36:05 +08:00
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
button->priv = GIMP_FONT_SELECT_BUTTON_GET_PRIVATE (button);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
button->priv->title = g_strdup(_("Font Selection"));
|
|
|
|
button->priv->font_name = g_strdup(_("Sans"));
|
|
|
|
button->priv->temp_font_callback = NULL;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
button->priv->inside = gimp_font_select_button_create_inside (button);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), button->priv->inside);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
gtk_drag_dest_set (GTK_WIDGET (button),
|
2005-06-05 06:36:05 +08:00
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
&target, 1,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
}
|
2003-03-28 22:13:54 +08:00
|
|
|
|
|
|
|
/**
|
2005-06-05 06:36:05 +08:00
|
|
|
* gimp_font_select_button_new:
|
2003-07-01 23:06:06 +08:00
|
|
|
* @title: Title of the dialog to use or %NULL means 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.
|
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
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
GtkWidget *button;
|
2004-07-28 08:04:13 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
if (title)
|
2005-06-26 20:53:31 +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
|
2005-06-26 20:53:31 +08:00
|
|
|
button = g_object_new (GIMP_TYPE_FONT_SELECT_BUTTON,
|
|
|
|
"font-name", font_name,
|
|
|
|
NULL);
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
return button;
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-06-05 06:36:05 +08:00
|
|
|
* gimp_font_select_button_close_popup:
|
2005-06-26 20:53:31 +08:00
|
|
|
* @button: A #GimpFontSelectButton
|
2003-03-28 22:13:54 +08:00
|
|
|
*
|
2005-06-26 20:53:31 +08:00
|
|
|
* Closes the popup window associated with @button.
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
|
|
|
void
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_close_popup (GimpFontSelectButton *button)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
g_return_if_fail (GIMP_IS_FONT_SELECT_BUTTON (button));
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
if (button->priv->temp_font_callback)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_destroy (button->priv->temp_font_callback);
|
|
|
|
button->priv->temp_font_callback = NULL;
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-06-05 06:36:05 +08:00
|
|
|
* gimp_font_select_button_get_font_name:
|
2005-06-26 20:53:31 +08:00
|
|
|
* @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
|
|
|
*
|
2005-06-05 06:36:05 +08:00
|
|
|
* Since: 2.4
|
2003-03-28 22:13:54 +08:00
|
|
|
*/
|
2005-06-05 06:36:05 +08:00
|
|
|
G_CONST_RETURN gchar *
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_get_font_name (GimpFontSelectButton *button)
|
2003-03-28 22:13:54 +08:00
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_FONT_SELECT_BUTTON (button), NULL);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
return button->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
|
|
|
/**
|
|
|
|
* gimp_font_select_button_set_font_name:
|
2005-06-26 20:53:31 +08:00
|
|
|
* @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.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
|
|
|
*/
|
|
|
|
void
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_set_font_name (GimpFontSelectButton *button,
|
2005-06-05 06:36:05 +08:00
|
|
|
const gchar *font_name)
|
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
g_return_if_fail (GIMP_IS_FONT_SELECT_BUTTON (button));
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
if (button->priv->temp_font_callback)
|
|
|
|
gimp_fonts_set_popup (button->priv->temp_font_callback, font_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
else
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_callback (font_name, FALSE, button);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
GimpFontSelectButton *button = GIMP_FONT_SELECT_BUTTON (object);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_TITLE:
|
2005-06-26 20:53:31 +08:00
|
|
|
g_free (button->priv->title);
|
|
|
|
button->priv->title = g_value_dup_string (value);
|
2005-06-05 06:36:05 +08:00
|
|
|
g_object_notify (object, "title");
|
|
|
|
break;
|
2005-06-26 20:53:31 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
case PROP_FONT_NAME:
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_set_font_name (button,
|
2005-06-05 06:36:05 +08:00
|
|
|
g_value_get_string (value));
|
|
|
|
break;
|
2005-06-26 20:53:31 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
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)
|
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
GimpFontSelectButton *button = GIMP_FONT_SELECT_BUTTON (object);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_TITLE:
|
2005-06-26 20:53:31 +08:00
|
|
|
g_value_set_string (value, button->priv->title);
|
2005-06-05 06:36:05 +08:00
|
|
|
break;
|
2005-06-26 20:53:31 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
case PROP_FONT_NAME:
|
2005-06-26 20:53:31 +08:00
|
|
|
g_value_set_string (value, button->priv->font_name);
|
2005-06-05 06:36:05 +08:00
|
|
|
break;
|
2005-06-26 20:53:31 +08:00
|
|
|
|
2005-06-05 06:36:05 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_font_select_button_callback (const gchar *name,
|
2003-07-01 23:06:06 +08:00
|
|
|
gboolean closing,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
GimpFontSelectButton *button = GIMP_FONT_SELECT_BUTTON (data);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
g_free (button->priv->font_name);
|
|
|
|
button->priv->font_name = g_strdup (name);
|
2003-07-01 23:06:06 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (button->priv->label), name);
|
2003-03-28 22:13:54 +08:00
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
if (closing)
|
2005-06-26 20:53:31 +08:00
|
|
|
button->priv->temp_font_callback = NULL;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
g_signal_emit (button, font_button_signals[FONT_SET], 0, name, closing);
|
|
|
|
g_object_notify (G_OBJECT (button), "font-name");
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-06-05 06:36:05 +08:00
|
|
|
gimp_font_select_button_clicked (GtkButton *button)
|
2003-07-01 23:06:06 +08:00
|
|
|
{
|
2005-06-05 06:36:05 +08:00
|
|
|
GimpFontSelectButton *font_button = GIMP_FONT_SELECT_BUTTON (button);
|
|
|
|
|
|
|
|
if (font_button->priv->temp_font_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 */
|
2005-06-05 06:36:05 +08:00
|
|
|
gimp_fonts_set_popup (font_button->priv->temp_font_callback,
|
|
|
|
font_button->priv->font_name);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-05 06:36:05 +08:00
|
|
|
font_button->priv->temp_font_callback =
|
|
|
|
gimp_font_select_new (font_button->priv->title,
|
|
|
|
font_button->priv->font_name,
|
|
|
|
gimp_font_select_button_callback,
|
2005-06-26 20:53:31 +08:00
|
|
|
button);
|
2003-03-28 22:13:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 23:06:06 +08:00
|
|
|
static void
|
2005-06-05 06:36:05 +08:00
|
|
|
gimp_font_select_button_destroy (GtkObject *object)
|
2003-07-01 23:06:06 +08:00
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
GimpFontSelectButton *button = GIMP_FONT_SELECT_BUTTON (object);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
if (button->priv->temp_font_callback)
|
2003-07-01 23:06:06 +08:00
|
|
|
{
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_destroy (button->priv->temp_font_callback);
|
|
|
|
button->priv->temp_font_callback = NULL;
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
g_free (button->priv->title);
|
|
|
|
button->priv->title = NULL;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
g_free (button->priv->font_name);
|
|
|
|
button->priv->font_name = NULL;
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
GTK_OBJECT_CLASS (gimp_font_select_button_parent_class)->destroy (object);
|
2003-07-01 23:06:06 +08:00
|
|
|
}
|
2005-03-23 18:51:33 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_font_select_drag_data_received (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GtkSelectionData *selection,
|
|
|
|
guint info,
|
|
|
|
guint time)
|
|
|
|
{
|
2005-07-25 21:53:00 +08:00
|
|
|
gchar *str;
|
2005-03-23 19:26:56 +08:00
|
|
|
|
2005-03-23 18:51:33 +08:00
|
|
|
if ((selection->format != 8) || (selection->length < 1))
|
|
|
|
{
|
|
|
|
g_warning ("Received invalid font data!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-03 06:15:33 +08:00
|
|
|
str = g_strndup ((const gchar *) selection->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;
|
|
|
|
|
|
|
|
gimp_font_select_button_set_font_name (GIMP_FONT_SELECT_BUTTON (widget),
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
}
|
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 *
|
2005-06-26 20:53:31 +08:00
|
|
|
gimp_font_select_button_create_inside (GimpFontSelectButton *button)
|
2005-06-05 06:36:05 +08:00
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
gtk_widget_push_composite_child ();
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
|
|
|
|
image = gtk_image_new_from_stock (GIMP_STOCK_FONT, GTK_ICON_SIZE_BUTTON);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
|
|
|
|
2005-06-26 20:53:31 +08:00
|
|
|
button->priv->label = gtk_label_new (button->priv->font_name);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button->priv->label, TRUE, TRUE, 4);
|
2005-06-05 06:36:05 +08:00
|
|
|
|
|
|
|
gtk_widget_show_all (hbox);
|
|
|
|
|
|
|
|
gtk_widget_pop_composite_child ();
|
|
|
|
|
|
|
|
return hbox;
|
|
|
|
}
|