mirror of https://github.com/GNOME/gimp.git
trim the string only if necessary.
2003-02-20 Sven Neumann <sven@gimp.org> * libgimpbase/gimputils.c (gimp_utf8_strtrim): trim the string only if necessary. * app/text/gimptext.c: changed the default text to NULL. * app/widgets/gimptexteditor.[ch]: replaced Cancel and OK buttons with a single Close button and removed the callback. * app/widgets/gimppropwidgets.c: gtk_text_buffer_set_text() doesn't like NULL pointers, pass it an empty string instead. * app/tools/gimptexttool.c: create a new text layer as soon as the user starts editing.
This commit is contained in:
parent
94bdcbcc01
commit
df09eb68d3
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2003-02-20 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpbase/gimputils.c (gimp_utf8_strtrim): trim the string
|
||||
only if necessary.
|
||||
|
||||
* app/text/gimptext.c: changed the default text to NULL.
|
||||
|
||||
* app/widgets/gimptexteditor.[ch]: replaced Cancel and OK buttons
|
||||
with a single Close button and removed the callback.
|
||||
|
||||
* app/widgets/gimppropwidgets.c: gtk_text_buffer_set_text()
|
||||
doesn't like NULL pointers, pass it an empty string instead.
|
||||
|
||||
* app/tools/gimptexttool.c: create a new text layer as soon as the
|
||||
user starts editing.
|
||||
|
||||
2003-02-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
|
|
|
@ -122,7 +122,7 @@ gimp_text_class_init (GimpTextClass *klass)
|
|||
|
||||
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_TEXT,
|
||||
"text", NULL,
|
||||
"GIMP",
|
||||
NULL,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_FONT,
|
||||
"font", NULL,
|
||||
|
|
|
@ -57,36 +57,35 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_text_tool_class_init (GimpTextToolClass *klass);
|
||||
static void gimp_text_tool_init (GimpTextTool *tool);
|
||||
static void gimp_text_tool_class_init (GimpTextToolClass *klass);
|
||||
static void gimp_text_tool_init (GimpTextTool *tool);
|
||||
|
||||
static void text_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void text_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_text_tool_connect (GimpTextTool *tool,
|
||||
GimpText *text);
|
||||
static void gimp_text_tool_connect (GimpTextTool *tool,
|
||||
GimpText *text);
|
||||
|
||||
static void text_tool_create_layer (GimpTextTool *text_tool);
|
||||
static void text_tool_create_layer (GimpTextTool *text_tool);
|
||||
|
||||
static void text_tool_editor (GimpTextTool *text_tool);
|
||||
static void text_tool_editor_response (GtkWidget *editor,
|
||||
GtkResponseType response,
|
||||
gpointer data);
|
||||
static void text_tool_editor (GimpTextTool *text_tool);
|
||||
static void text_tool_buffer_changed (GtkTextBuffer *buffer,
|
||||
GimpTextTool *text_tool);
|
||||
|
||||
|
||||
/* local variables */
|
||||
|
@ -232,10 +231,10 @@ text_tool_button_press (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
gimp_text_tool_connect (GIMP_TEXT_TOOL (tool), text);
|
||||
|
||||
if (!text || text == text_tool->text)
|
||||
text_tool_editor (text_tool);
|
||||
|
||||
gimp_text_tool_connect (GIMP_TEXT_TOOL (tool), text);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -273,8 +272,6 @@ text_tool_create_layer (GimpTextTool *text_tool)
|
|||
|
||||
text = GIMP_TEXT (gimp_config_duplicate (G_OBJECT (options->text)));
|
||||
|
||||
gimp_text_tool_connect (text_tool, text);
|
||||
|
||||
layer = gimp_text_layer_new (gimage, text);
|
||||
|
||||
g_object_unref (text);
|
||||
|
@ -282,6 +279,8 @@ text_tool_create_layer (GimpTextTool *text_tool)
|
|||
if (!layer)
|
||||
return;
|
||||
|
||||
gimp_text_tool_connect (text_tool, text);
|
||||
|
||||
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TEXT,
|
||||
_("Add Text Layer"));
|
||||
|
||||
|
@ -327,13 +326,11 @@ gimp_text_tool_connect (GimpTextTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* text editor */
|
||||
|
||||
static void
|
||||
text_tool_editor (GimpTextTool *text_tool)
|
||||
{
|
||||
GimpTextOptions *options;
|
||||
GClosure *closure;
|
||||
|
||||
if (text_tool->editor)
|
||||
{
|
||||
|
@ -343,35 +340,24 @@ text_tool_editor (GimpTextTool *text_tool)
|
|||
|
||||
options = GIMP_TEXT_OPTIONS (GIMP_TOOL (text_tool)->tool_info->tool_options);
|
||||
|
||||
text_tool->editor = gimp_text_editor_new (options->buffer,
|
||||
_("GIMP Text Editor"),
|
||||
text_tool_editor_response,
|
||||
text_tool);
|
||||
text_tool->editor = gimp_text_editor_new (_("GIMP Text Editor"),
|
||||
options->buffer);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (text_tool->editor),
|
||||
(gpointer *) &text_tool->editor);
|
||||
|
||||
closure = g_cclosure_new (G_CALLBACK (text_tool_buffer_changed),
|
||||
text_tool, NULL);
|
||||
g_object_watch_closure (G_OBJECT (text_tool->editor), closure);
|
||||
g_signal_connect_closure (options->buffer, "changed", closure, FALSE);
|
||||
|
||||
gtk_widget_show (text_tool->editor);
|
||||
}
|
||||
|
||||
static void
|
||||
text_tool_editor_response (GtkWidget *editor,
|
||||
GtkResponseType response,
|
||||
gpointer data)
|
||||
text_tool_buffer_changed (GtkTextBuffer *buffer,
|
||||
GimpTextTool *text_tool)
|
||||
{
|
||||
gtk_widget_destroy (editor);
|
||||
|
||||
switch (response)
|
||||
{
|
||||
case GTK_RESPONSE_OK:
|
||||
{
|
||||
GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
|
||||
|
||||
if (! text_tool->text)
|
||||
text_tool_create_layer (text_tool);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (! text_tool->text)
|
||||
text_tool_create_layer (text_tool);
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ gimp_prop_boolean_option_menu_new (GObject *config,
|
|||
const gchar *false_text)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
gboolean value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
|
@ -185,24 +185,23 @@ gimp_prop_boolean_option_menu_new (GObject *config,
|
|||
property_name, &value,
|
||||
NULL);
|
||||
|
||||
optionmenu =
|
||||
gimp_option_menu_new2 (FALSE,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
GINT_TO_POINTER (value),
|
||||
menu = gimp_option_menu_new2 (FALSE,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
GINT_TO_POINTER (value),
|
||||
|
||||
true_text, GINT_TO_POINTER (TRUE), NULL,
|
||||
false_text, GINT_TO_POINTER (FALSE), NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
true_text, GINT_TO_POINTER (TRUE), NULL,
|
||||
false_text, GINT_TO_POINTER (FALSE), NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
set_param_spec (G_OBJECT (optionmenu), optionmenu, param_spec);
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_option_menu_notify),
|
||||
optionmenu);
|
||||
menu);
|
||||
|
||||
return optionmenu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -212,7 +211,7 @@ gimp_prop_enum_option_menu_new (GObject *config,
|
|||
gint maximum)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
gint value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
|
@ -226,30 +225,28 @@ gimp_prop_enum_option_menu_new (GObject *config,
|
|||
|
||||
if (minimum != maximum)
|
||||
{
|
||||
optionmenu =
|
||||
gimp_enum_option_menu_new_with_range (param_spec->value_type,
|
||||
minimum, maximum,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
menu = gimp_enum_option_menu_new_with_range (param_spec->value_type,
|
||||
minimum, maximum,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
}
|
||||
else
|
||||
{
|
||||
optionmenu =
|
||||
gimp_enum_option_menu_new (param_spec->value_type,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
menu = gimp_enum_option_menu_new (param_spec->value_type,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
}
|
||||
|
||||
gimp_option_menu_set_history (GTK_OPTION_MENU (optionmenu),
|
||||
gimp_option_menu_set_history (GTK_OPTION_MENU (menu),
|
||||
GINT_TO_POINTER (value));
|
||||
|
||||
set_param_spec (G_OBJECT (optionmenu), optionmenu, param_spec);
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_option_menu_notify),
|
||||
optionmenu);
|
||||
menu);
|
||||
|
||||
return optionmenu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -258,7 +255,7 @@ gimp_prop_paint_mode_menu_new (GObject *config,
|
|||
gboolean with_behind_mode)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
gint value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
|
@ -270,19 +267,18 @@ gimp_prop_paint_mode_menu_new (GObject *config,
|
|||
property_name, &value,
|
||||
NULL);
|
||||
|
||||
optionmenu =
|
||||
gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
with_behind_mode,
|
||||
value);
|
||||
menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
with_behind_mode,
|
||||
value);
|
||||
|
||||
set_param_spec (G_OBJECT (optionmenu), optionmenu, param_spec);
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_option_menu_notify),
|
||||
optionmenu);
|
||||
menu);
|
||||
|
||||
return optionmenu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -291,16 +287,16 @@ gimp_prop_option_menu_callback (GtkWidget *widget,
|
|||
{
|
||||
if (GTK_IS_MENU (widget->parent))
|
||||
{
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
|
||||
optionmenu = gtk_menu_get_attach_widget (GTK_MENU (widget->parent));
|
||||
menu = gtk_menu_get_attach_widget (GTK_MENU (widget->parent));
|
||||
|
||||
if (optionmenu)
|
||||
if (menu)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
gint value;
|
||||
|
||||
param_spec = get_param_spec (G_OBJECT (optionmenu));
|
||||
param_spec = get_param_spec (G_OBJECT (menu));
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
|
@ -1108,7 +1104,7 @@ gimp_prop_text_buffer_new (GObject *config,
|
|||
NULL);
|
||||
|
||||
text_buffer = gtk_text_buffer_new (NULL);
|
||||
gtk_text_buffer_set_text (text_buffer, value, -1);
|
||||
gtk_text_buffer_set_text (text_buffer, value ? value : "", -1);
|
||||
|
||||
g_free (value);
|
||||
|
||||
|
@ -1194,7 +1190,7 @@ gimp_prop_text_buffer_notify (GObject *config,
|
|||
gimp_prop_text_buffer_callback,
|
||||
config);
|
||||
|
||||
gtk_text_buffer_set_text (text_buffer, value, -1);
|
||||
gtk_text_buffer_set_text (text_buffer, value ? value : "", -1);
|
||||
|
||||
g_signal_handlers_unblock_by_func (text_buffer,
|
||||
gimp_prop_text_buffer_callback,
|
||||
|
|
|
@ -39,16 +39,12 @@ typedef struct _TextEditorData TextEditorData;
|
|||
|
||||
struct _TextEditorData
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *editor;
|
||||
GtkWidget *filesel;
|
||||
GimpTextEditorCallback callback;
|
||||
gpointer callback_data;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkWidget *editor;
|
||||
GtkWidget *filesel;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_text_editor_ok (TextEditorData *data);
|
||||
static void gimp_text_editor_cancel (TextEditorData *data);
|
||||
static void gimp_text_editor_load (GtkWidget *widget,
|
||||
TextEditorData *data);
|
||||
static void gimp_text_editor_load_ok (TextEditorData *data);
|
||||
|
@ -59,10 +55,8 @@ static void gimp_text_editor_clear (GtkWidget *widget,
|
|||
|
||||
|
||||
GtkWidget *
|
||||
gimp_text_editor_new (GtkTextBuffer *buffer,
|
||||
const gchar *title,
|
||||
GimpTextEditorCallback callback,
|
||||
gpointer callback_data)
|
||||
gimp_text_editor_new (const gchar *title,
|
||||
GtkTextBuffer *buffer)
|
||||
{
|
||||
GtkWidget *editor;
|
||||
GtkWidget *toolbar;
|
||||
|
@ -70,7 +64,8 @@ gimp_text_editor_new (GtkTextBuffer *buffer,
|
|||
GtkWidget *text_view;
|
||||
TextEditorData *data;
|
||||
|
||||
data = g_new0 (TextEditorData, 1);
|
||||
g_return_val_if_fail (title != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
|
||||
|
||||
editor = gimp_dialog_new (title, "text_editor",
|
||||
gimp_standard_help_func,
|
||||
|
@ -78,18 +73,15 @@ gimp_text_editor_new (GtkTextBuffer *buffer,
|
|||
GTK_WIN_POS_NONE,
|
||||
FALSE, TRUE, FALSE,
|
||||
|
||||
GTK_STOCK_CANCEL, gimp_text_editor_cancel,
|
||||
NULL, data, NULL, TRUE, TRUE,
|
||||
|
||||
GTK_STOCK_OK, gimp_text_editor_ok,
|
||||
NULL, data, NULL, TRUE, TRUE,
|
||||
|
||||
GTK_STOCK_CLOSE, gtk_widget_destroy,
|
||||
NULL, 1, NULL, TRUE, TRUE,
|
||||
|
||||
NULL);
|
||||
|
||||
data->buffer = buffer;
|
||||
data->editor = editor;
|
||||
data->callback = callback;
|
||||
data->callback_data = callback_data;
|
||||
data = g_new0 (TextEditorData, 1);
|
||||
|
||||
data->buffer = buffer;
|
||||
data->editor = editor;
|
||||
|
||||
g_object_weak_ref (G_OBJECT (editor), (GWeakNotify) g_free, data);
|
||||
|
||||
|
@ -125,26 +117,6 @@ gimp_text_editor_new (GtkTextBuffer *buffer,
|
|||
return editor;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_response (TextEditorData *data,
|
||||
GtkResponseType response)
|
||||
{
|
||||
if (data->callback)
|
||||
data->callback (data->editor, response, data->callback_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_ok (TextEditorData *data)
|
||||
{
|
||||
gimp_text_editor_response (data, GTK_RESPONSE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_cancel (TextEditorData *data)
|
||||
{
|
||||
gimp_text_editor_response (data, GTK_RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_load (GtkWidget *widget,
|
||||
TextEditorData *data)
|
||||
|
|
|
@ -23,14 +23,8 @@
|
|||
#define __GIMP_TEXT_EDITOR_H__
|
||||
|
||||
|
||||
typedef void (* GimpTextEditorCallback) (GtkWidget *editor,
|
||||
GtkResponseType response,
|
||||
gpointer data);
|
||||
|
||||
GtkWidget * gimp_text_editor_new (GtkTextBuffer *buffer,
|
||||
const gchar *title,
|
||||
GimpTextEditorCallback callback,
|
||||
gpointer callback_data);
|
||||
GtkWidget * gimp_text_editor_new (const gchar *title,
|
||||
GtkTextBuffer *buffer);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_EDITOR_H__ */
|
||||
|
|
|
@ -32,14 +32,15 @@
|
|||
/**
|
||||
* gimp_utf8_strtrim:
|
||||
* @str: an UTF-8 encoded string (or %NULL)
|
||||
* @max_chars: the maximum number of characters before the string get trimmed
|
||||
* @max_chars: the maximum number of characters before the string get
|
||||
* trimmed
|
||||
*
|
||||
* Creates a (possibly trimmed) copy of @str. The string is cut if it exceeds
|
||||
* @max_chars characters or on the first newline. The fact that the string was
|
||||
* trimmed is indicated by appending an ellipsis.
|
||||
* Creates a (possibly trimmed) copy of @str. The string is cut if it
|
||||
* exceeds @max_chars characters or on the first newline. The fact
|
||||
* that the string was trimmed is indicated by appending an ellipsis.
|
||||
*
|
||||
* Returns: A (possibly trimmed) copy of @str which should be freed using
|
||||
* g_free() when it is not needed any longer.
|
||||
* Returns: A (possibly trimmed) copy of @str which should be freed
|
||||
* using g_free() when it is not needed any longer.
|
||||
**/
|
||||
gchar *
|
||||
gimp_utf8_strtrim (const gchar *str,
|
||||
|
@ -76,7 +77,7 @@ gimp_utf8_strtrim (const gchar *str,
|
|||
break;
|
||||
}
|
||||
|
||||
if (p)
|
||||
if (*p)
|
||||
{
|
||||
gsize len = p - str;
|
||||
gchar *trimmed = g_new (gchar, len + e_len + 2);
|
||||
|
|
|
@ -173,7 +173,7 @@ gimp_prop_boolean_option_menu_new (GObject *config,
|
|||
const gchar *false_text)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
gboolean value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
|
@ -185,24 +185,23 @@ gimp_prop_boolean_option_menu_new (GObject *config,
|
|||
property_name, &value,
|
||||
NULL);
|
||||
|
||||
optionmenu =
|
||||
gimp_option_menu_new2 (FALSE,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
GINT_TO_POINTER (value),
|
||||
menu = gimp_option_menu_new2 (FALSE,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
GINT_TO_POINTER (value),
|
||||
|
||||
true_text, GINT_TO_POINTER (TRUE), NULL,
|
||||
false_text, GINT_TO_POINTER (FALSE), NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
true_text, GINT_TO_POINTER (TRUE), NULL,
|
||||
false_text, GINT_TO_POINTER (FALSE), NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
set_param_spec (G_OBJECT (optionmenu), optionmenu, param_spec);
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_option_menu_notify),
|
||||
optionmenu);
|
||||
menu);
|
||||
|
||||
return optionmenu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -212,7 +211,7 @@ gimp_prop_enum_option_menu_new (GObject *config,
|
|||
gint maximum)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
gint value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
|
@ -226,30 +225,28 @@ gimp_prop_enum_option_menu_new (GObject *config,
|
|||
|
||||
if (minimum != maximum)
|
||||
{
|
||||
optionmenu =
|
||||
gimp_enum_option_menu_new_with_range (param_spec->value_type,
|
||||
minimum, maximum,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
menu = gimp_enum_option_menu_new_with_range (param_spec->value_type,
|
||||
minimum, maximum,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
}
|
||||
else
|
||||
{
|
||||
optionmenu =
|
||||
gimp_enum_option_menu_new (param_spec->value_type,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
menu = gimp_enum_option_menu_new (param_spec->value_type,
|
||||
G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config);
|
||||
}
|
||||
|
||||
gimp_option_menu_set_history (GTK_OPTION_MENU (optionmenu),
|
||||
gimp_option_menu_set_history (GTK_OPTION_MENU (menu),
|
||||
GINT_TO_POINTER (value));
|
||||
|
||||
set_param_spec (G_OBJECT (optionmenu), optionmenu, param_spec);
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_option_menu_notify),
|
||||
optionmenu);
|
||||
menu);
|
||||
|
||||
return optionmenu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -258,7 +255,7 @@ gimp_prop_paint_mode_menu_new (GObject *config,
|
|||
gboolean with_behind_mode)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
gint value;
|
||||
|
||||
param_spec = check_param_spec (config, property_name,
|
||||
|
@ -270,19 +267,18 @@ gimp_prop_paint_mode_menu_new (GObject *config,
|
|||
property_name, &value,
|
||||
NULL);
|
||||
|
||||
optionmenu =
|
||||
gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
with_behind_mode,
|
||||
value);
|
||||
menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_option_menu_callback),
|
||||
config,
|
||||
with_behind_mode,
|
||||
value);
|
||||
|
||||
set_param_spec (G_OBJECT (optionmenu), optionmenu, param_spec);
|
||||
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
||||
|
||||
connect_notify (config, property_name,
|
||||
G_CALLBACK (gimp_prop_option_menu_notify),
|
||||
optionmenu);
|
||||
menu);
|
||||
|
||||
return optionmenu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -291,16 +287,16 @@ gimp_prop_option_menu_callback (GtkWidget *widget,
|
|||
{
|
||||
if (GTK_IS_MENU (widget->parent))
|
||||
{
|
||||
GtkWidget *optionmenu;
|
||||
GtkWidget *menu;
|
||||
|
||||
optionmenu = gtk_menu_get_attach_widget (GTK_MENU (widget->parent));
|
||||
menu = gtk_menu_get_attach_widget (GTK_MENU (widget->parent));
|
||||
|
||||
if (optionmenu)
|
||||
if (menu)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
gint value;
|
||||
|
||||
param_spec = get_param_spec (G_OBJECT (optionmenu));
|
||||
param_spec = get_param_spec (G_OBJECT (menu));
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
|
@ -1108,7 +1104,7 @@ gimp_prop_text_buffer_new (GObject *config,
|
|||
NULL);
|
||||
|
||||
text_buffer = gtk_text_buffer_new (NULL);
|
||||
gtk_text_buffer_set_text (text_buffer, value, -1);
|
||||
gtk_text_buffer_set_text (text_buffer, value ? value : "", -1);
|
||||
|
||||
g_free (value);
|
||||
|
||||
|
@ -1194,7 +1190,7 @@ gimp_prop_text_buffer_notify (GObject *config,
|
|||
gimp_prop_text_buffer_callback,
|
||||
config);
|
||||
|
||||
gtk_text_buffer_set_text (text_buffer, value, -1);
|
||||
gtk_text_buffer_set_text (text_buffer, value ? value : "", -1);
|
||||
|
||||
g_signal_handlers_unblock_by_func (text_buffer,
|
||||
gimp_prop_text_buffer_callback,
|
||||
|
|
Loading…
Reference in New Issue