mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
replaced with an UTF-8 safe rewrite.
2003-02-05 Sven Neumann <sven@gimp.org> * app/core/gimpobject.c (gimp_object_set_name_safe): replaced with an UTF-8 safe rewrite. * app/widgets/gimpwidgets-utils.c (gimp_table_attach_stock): hacked to allow being used with non-existent stock_ids (for prototyping). * app/widgets/gimpenummenu.c: set the radio button mode correctly. * app/widgets/gimpfontselection.c: tweaked spacing. * app/tools/gimptextoptions.c: added controls for justification and indentation. Removed letter-spacing control for now. * app/text/gimptextlayer.[ch]: rerender the text layer from a low priority idle function.
This commit is contained in:
parent
f8c7174bcb
commit
01cd65071c
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2003-02-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpobject.c (gimp_object_set_name_safe): replaced with
|
||||
an UTF-8 safe rewrite.
|
||||
|
||||
* app/widgets/gimpwidgets-utils.c (gimp_table_attach_stock): hacked
|
||||
to allow being used with non-existent stock_ids (for prototyping).
|
||||
|
||||
* app/widgets/gimpenummenu.c: set the radio button mode correctly.
|
||||
|
||||
* app/widgets/gimpfontselection.c: tweaked spacing.
|
||||
|
||||
* app/tools/gimptextoptions.c: added controls for justification and
|
||||
indentation. Removed letter-spacing control for now.
|
||||
|
||||
* app/text/gimptextlayer.[ch]: rerender the text layer from a low
|
||||
priority idle function.
|
||||
|
||||
2003-02-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/paint/gimpairbrush.c
|
||||
|
|
|
@ -240,46 +240,58 @@ gimp_object_set_name (GimpObject *object,
|
|||
/* A safe version of gimp_object_set_name() that takes care
|
||||
* of newlines and overly long names.
|
||||
*/
|
||||
#define MAX_NAME_LEN 32
|
||||
#define MAX_NAME_LEN 30
|
||||
|
||||
void
|
||||
gimp_object_set_name_safe (GimpObject *object,
|
||||
const gchar *name)
|
||||
{
|
||||
gchar *newline;
|
||||
gsize len;
|
||||
/* FIXME: should to make this translatable */
|
||||
static const gchar *ellipsis = "...";
|
||||
static const gint e_len = 3;
|
||||
|
||||
g_return_if_fail (GIMP_IS_OBJECT (object));
|
||||
|
||||
if (name)
|
||||
{
|
||||
newline = strchr (name, '\n');
|
||||
const gchar *p;
|
||||
const gchar *newline = NULL;
|
||||
gint chars = 0;
|
||||
gunichar unichar;
|
||||
|
||||
if (newline)
|
||||
len = newline - name + 1;
|
||||
else
|
||||
len = strlen (name);
|
||||
|
||||
if (len > MAX_NAME_LEN)
|
||||
newline = NULL;
|
||||
|
||||
if (newline || len > MAX_NAME_LEN)
|
||||
for (p = name; p && !newline; p = g_utf8_next_char (p))
|
||||
{
|
||||
gchar *safe_name;
|
||||
|
||||
len = MIN (len, MAX_NAME_LEN);
|
||||
if (++chars > MAX_NAME_LEN)
|
||||
break;
|
||||
|
||||
safe_name = g_new (gchar, len + 4);
|
||||
unichar = g_utf8_get_char (p);
|
||||
|
||||
switch (g_unichar_break_type (unichar))
|
||||
{
|
||||
case G_UNICODE_BREAK_MANDATORY:
|
||||
case G_UNICODE_BREAK_LINE_FEED:
|
||||
newline = p;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
gchar safe_name[MAX_NAME_LEN * 6 + e_len + 1];
|
||||
gsize len;
|
||||
|
||||
len = p - name;
|
||||
|
||||
memcpy (safe_name, name, len);
|
||||
if (newline)
|
||||
safe_name[len-1] = ' ';
|
||||
|
||||
g_strlcpy (safe_name + len, "...", 4);
|
||||
g_strlcpy (safe_name + len, ellipsis, e_len + 1);
|
||||
|
||||
gimp_object_set_name (object, safe_name);
|
||||
|
||||
g_free (safe_name);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,15 @@
|
|||
|
||||
static void gimp_text_layer_class_init (GimpTextLayerClass *klass);
|
||||
static void gimp_text_layer_init (GimpTextLayer *layer);
|
||||
static void gimp_text_layer_finalize (GObject *object);
|
||||
static void gimp_text_layer_dispose (GObject *object);
|
||||
|
||||
static gsize gimp_text_layer_get_memsize (GimpObject *object);
|
||||
static TempBuf * gimp_text_layer_get_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
static void gimp_text_layer_notify_text (GimpTextLayer *layer);
|
||||
static gboolean gimp_text_layer_idle_render (GimpTextLayer *layer);
|
||||
static gboolean gimp_text_layer_render (GimpTextLayer *layer);
|
||||
static void gimp_text_layer_render_layout (GimpTextLayer *layer,
|
||||
GimpTextLayout *layout);
|
||||
|
@ -97,7 +99,7 @@ gimp_text_layer_class_init (GimpTextLayerClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_text_layer_finalize;
|
||||
object_class->dispose = gimp_text_layer_dispose;
|
||||
|
||||
gimp_object_class->get_memsize = gimp_text_layer_get_memsize;
|
||||
|
||||
|
@ -111,19 +113,24 @@ gimp_text_layer_init (GimpTextLayer *layer)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_text_layer_finalize (GObject *object)
|
||||
gimp_text_layer_dispose (GObject *object)
|
||||
{
|
||||
GimpTextLayer *layer;
|
||||
|
||||
layer = GIMP_TEXT_LAYER (object);
|
||||
|
||||
if (layer->idle_render_id)
|
||||
{
|
||||
g_source_remove (layer->idle_render_id);
|
||||
layer->idle_render_id = 0;
|
||||
}
|
||||
if (layer->text)
|
||||
{
|
||||
g_object_unref (layer->text);
|
||||
layer->text = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
GimpLayer *
|
||||
|
@ -148,16 +155,16 @@ gimp_text_layer_new (GimpImage *image,
|
|||
|
||||
layer->text = g_object_ref (text);
|
||||
|
||||
g_signal_connect_object (text, "notify",
|
||||
G_CALLBACK (gimp_text_layer_render),
|
||||
layer, G_CONNECT_SWAPPED);
|
||||
|
||||
if (!gimp_text_layer_render (layer))
|
||||
{
|
||||
g_object_unref (layer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_signal_connect_object (text, "notify",
|
||||
G_CALLBACK (gimp_text_layer_notify_text),
|
||||
layer, G_CONNECT_SWAPPED);
|
||||
|
||||
return GIMP_LAYER (layer);
|
||||
}
|
||||
|
||||
|
@ -197,6 +204,28 @@ gimp_text_layer_get_preview (GimpViewable *viewable,
|
|||
width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_layer_notify_text (GimpTextLayer *layer)
|
||||
{
|
||||
if (layer->idle_render_id)
|
||||
return;
|
||||
|
||||
layer->idle_render_id =
|
||||
g_idle_add_full (G_PRIORITY_LOW,
|
||||
(GSourceFunc) gimp_text_layer_idle_render, layer,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_text_layer_idle_render (GimpTextLayer *layer)
|
||||
{
|
||||
layer->idle_render_id = 0;
|
||||
|
||||
gimp_text_layer_render (layer);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_text_layer_render (GimpTextLayer *layer)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ struct _GimpTextLayer
|
|||
GimpLayer layer;
|
||||
|
||||
GimpText *text;
|
||||
guint idle_render_id;
|
||||
};
|
||||
|
||||
struct _GimpTextLayerClass
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "text/gimptext.h"
|
||||
|
||||
#include "widgets/gimpcolorpanel.h"
|
||||
#include "widgets/gimpfontselection.h"
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
#include "widgets/gimptexteditor.h"
|
||||
|
@ -101,6 +102,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
GtkWidget *button;
|
||||
GtkWidget *unit_menu;
|
||||
GtkWidget *font_selection;
|
||||
GtkWidget *box;
|
||||
GtkWidget *spinbutton;
|
||||
gint digits;
|
||||
|
||||
|
@ -110,10 +112,9 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
|
||||
vbox = tool_options->main_vbox;
|
||||
|
||||
table = gtk_table_new (4, 4, FALSE);
|
||||
table = gtk_table_new (4, 6, FALSE);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 3, 12);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
|
@ -140,20 +141,27 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
|
||||
button = gimp_prop_color_button_new (G_OBJECT (options->text),
|
||||
"color", _("Text Color"),
|
||||
48, 24, GIMP_COLOR_AREA_FLAT);
|
||||
48, 24, GIMP_COLOR_AREA_FLAT);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
|
||||
GIMP_CONTEXT (options));
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
||||
_("Color:"), 1.0, 0.5, button, 2, TRUE);
|
||||
|
||||
spinbutton = gimp_prop_spin_button_new (G_OBJECT (options->text),
|
||||
"letter-spacing", 0.1, 1.0, 2);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
|
||||
gimp_table_attach_stock (GTK_TABLE (table), 0, 3,
|
||||
GIMP_STOCK_LETTER_SPACING, spinbutton);
|
||||
box = gimp_prop_enum_stock_box_new (G_OBJECT (options->text),
|
||||
"justify", "gtk-justify", 0, 0);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
||||
_("Justify:"), 1.0, 0.5, box, 2, TRUE);
|
||||
|
||||
spinbutton = gimp_prop_spin_button_new (G_OBJECT (options->text),
|
||||
"line-spacing", 0.1, 1.0, 2);
|
||||
"indent", 1.0, 10.0, 1);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
|
||||
gimp_table_attach_stock (GTK_TABLE (table), 0, 4,
|
||||
_("Indentation"), spinbutton);
|
||||
|
||||
spinbutton = gimp_prop_spin_button_new (G_OBJECT (options->text),
|
||||
"line-spacing", 1.0, 10.0, 1);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5);
|
||||
gimp_table_attach_stock (GTK_TABLE (table), 0, 5,
|
||||
GIMP_STOCK_LINE_SPACING, spinbutton);
|
||||
}
|
||||
|
||||
|
|
|
@ -577,7 +577,7 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
|
|||
|
||||
enum_class = g_type_class_ref (enum_type);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
g_object_weak_ref (G_OBJECT (hbox),
|
||||
(GWeakNotify) g_type_class_unref, enum_class);
|
||||
|
||||
|
@ -590,6 +590,8 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
|
|||
continue;
|
||||
|
||||
button = gtk_radio_button_new (group);
|
||||
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
|
||||
if (first_button && *first_button == NULL)
|
||||
*first_button = button;
|
||||
|
|
|
@ -145,6 +145,8 @@ gimp_font_selection_init (GimpFontSelection *fontsel)
|
|||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (fontsel), 2);
|
||||
|
||||
fontsel->context = NULL;
|
||||
|
||||
fontsel->entry = gtk_entry_new ();
|
||||
|
|
|
@ -254,15 +254,22 @@ gimp_table_attach_stock (GtkTable *table,
|
|||
g_return_if_fail (GTK_IS_TABLE (table));
|
||||
g_return_if_fail (stock_id != NULL);
|
||||
|
||||
if (! gtk_stock_lookup (stock_id, &item))
|
||||
return;
|
||||
if (gtk_stock_lookup (stock_id, &item))
|
||||
{
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
|
||||
label = gtk_label_new_with_mnemonic (item.label);
|
||||
}
|
||||
else
|
||||
{
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_MISSING_IMAGE,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
label = gtk_label_new_with_mnemonic (stock_id);
|
||||
}
|
||||
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_table_attach (table, image, column, column + 1, row, row + 1,
|
||||
GTK_SHRINK, GTK_SHRINK, 0, 0);
|
||||
gtk_widget_show (image);
|
||||
|
||||
label = gtk_label_new_with_mnemonic (item.label);
|
||||
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_table_attach (table, label, column + 1, column + 2, row, row + 1,
|
||||
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
||||
|
|
Loading…
Reference in a new issue