gimp r26882 - in branches/soc-2008-text: . app/actions app/tools menus
- From: weskaggs svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26882 - in branches/soc-2008-text: . app/actions app/tools menus
- Date: Fri, 5 Sep 2008 22:16:13 +0000 (UTC)
Author: weskaggs
Date: Fri Sep 5 22:16:12 2008
New Revision: 26882
URL: http://svn.gnome.org/viewvc/gimp?rev=26882&view=rev
Log:
Bill Skaggs <weskaggs gmail com>
* app/actions/text-tool-actions.c: implemented "update" function
for the text tool context menu. First pass, needs some
adjustments.
* app/tools/gimptextoptions.[ch]
* app/actions/text-tool-commands.[ch]
* app/actions/text-tool-actions.h
* menus/text-tool-menu.xml: moved "text to path" from
a button in tool options to an entry in the context menu.
* app/tools/gimptexttool.[ch]: changes resulting from
both of the previous things.
Modified:
branches/soc-2008-text/ChangeLog
branches/soc-2008-text/app/actions/text-tool-actions.c
branches/soc-2008-text/app/actions/text-tool-commands.c
branches/soc-2008-text/app/actions/text-tool-commands.h
branches/soc-2008-text/app/tools/gimptextoptions.c
branches/soc-2008-text/app/tools/gimptextoptions.h
branches/soc-2008-text/app/tools/gimptexttool.c
branches/soc-2008-text/app/tools/gimptexttool.h
branches/soc-2008-text/menus/text-tool-menu.xml
Modified: branches/soc-2008-text/app/actions/text-tool-actions.c
==============================================================================
--- branches/soc-2008-text/app/actions/text-tool-actions.c (original)
+++ branches/soc-2008-text/app/actions/text-tool-actions.c Fri Sep 5 22:16:12 2008
@@ -24,10 +24,17 @@
#include "actions-types.h"
+#include "core/gimpdrawable.h"
+
#include "widgets/gimpactiongroup.h"
#include "widgets/gimptexteditor.h"
#include "widgets/gimphelp-ids.h"
+#include "display/gimpdisplay.h"
+
+#include "tools/gimptool.h"
+#include "tools/gimptexttool.h"
+
#include "text-tool-actions.h"
#include "text-tool-commands.h"
@@ -57,7 +64,7 @@
{ "text-tool-delete", GTK_STOCK_DELETE,
N_("Delete selected"), NULL, NULL,
- G_CALLBACK (text_tool_delete_cmd_callback),
+ G_CALLBACK (text_tool_delete_cmd_callback),
NULL },
{ "text-tool-load", GTK_STOCK_OPEN,
@@ -72,6 +79,12 @@
G_CALLBACK (text_tool_clear_cmd_callback),
NULL },
+ { "text-tool-path-from-text", GIMP_STOCK_PATH,
+ N_("Path from Text"), "",
+ N_("Create a path from the outlines of the current text"),
+ G_CALLBACK (text_tool_path_from_text_callback),
+ NULL },
+
{ "text-tool-input-methods", NULL,
N_("Input Methods"), NULL, NULL, NULL,
NULL }
@@ -108,9 +121,52 @@
G_CALLBACK (text_tool_direction_cmd_callback));
}
+/*
+ * The following code is written on the assumption that this is for a context
+ * menu, activated by right-clicking in a text layer. Therefore, the tool
+ * must have a display. If for any reason the code is adapted to a different
+ * situation, some existence testing will need to be added.
+ */
void
text_tool_actions_update (GimpActionGroup *group,
gpointer data)
{
- /* Things will be added here soon*/
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GimpImage *image = GIMP_TOOL (text_tool)->display->image;
+ GimpLayer *layer = NULL;
+ gboolean text_layer = FALSE;
+ gboolean text_sel = FALSE; /* some text is selected */
+ gboolean clip = FALSE; /* clipboard has text available */
+
+ layer = gimp_image_get_active_layer (image);
+
+ if (layer)
+ text_layer = gimp_drawable_is_text_layer (GIMP_DRAWABLE (layer));
+
+ text_sel = gimp_text_tool_get_has_text_selection (text_tool);
+
+ /*
+ * see whether there is text available for pasting
+ */
+ {
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ clip = gtk_clipboard_wait_is_text_available (clipboard);
+ }
+
+#define SET_VISIBLE(action,condition) \
+ gimp_action_group_set_action_visible (group, action, (condition) != 0)
+#define SET_SENSITIVE(action,condition) \
+ gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
+#define SET_ACTIVE(action,condition) \
+ gimp_action_group_set_action_active (group, action, (condition) != 0)
+
+ SET_SENSITIVE ("text-tool-cut", text_sel);
+ SET_SENSITIVE ("text-tool-copy", text_sel);
+ SET_SENSITIVE ("text-tool-paste", clip);
+ SET_SENSITIVE ("text-tool-delete", text_sel);
+ SET_SENSITIVE ("text-tool-clear", text_layer);
+ SET_SENSITIVE ("text-tool-load", image);
+ SET_SENSITIVE ("text-tool-path-from-text", text_layer);
}
Modified: branches/soc-2008-text/app/actions/text-tool-commands.c
==============================================================================
--- branches/soc-2008-text/app/actions/text-tool-commands.c (original)
+++ branches/soc-2008-text/app/actions/text-tool-commands.c Fri Sep 5 22:16:12 2008
@@ -52,7 +52,7 @@
text_tool_cut_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
gimp_text_tool_clipboard_cut (text_tool);
}
@@ -60,7 +60,7 @@
text_tool_copy_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
gimp_text_tool_clipboard_copy (text_tool, TRUE);
}
@@ -68,7 +68,7 @@
text_tool_paste_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
gimp_text_tool_clipboard_paste (text_tool, TRUE);
}
@@ -76,7 +76,7 @@
text_tool_delete_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
if (gtk_text_buffer_get_has_selection (text_tool->text_buffer))
gimp_text_tool_delete_text (text_tool);
}
@@ -134,15 +134,24 @@
text_tool_clear_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
GtkTextIter start, end;
-
+
gtk_text_buffer_get_bounds (text_tool->text_buffer, &start, &end);
gtk_text_buffer_select_range (text_tool->text_buffer, &start, &end);
gimp_text_tool_delete_text (text_tool);
}
void
+text_tool_path_from_text_callback (GtkAction *action,
+ gpointer data)
+{
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+
+ gimp_text_tool_create_vectors (text_tool);
+}
+
+void
text_tool_direction_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data)
Modified: branches/soc-2008-text/app/actions/text-tool-commands.h
==============================================================================
--- branches/soc-2008-text/app/actions/text-tool-commands.h (original)
+++ branches/soc-2008-text/app/actions/text-tool-commands.h Fri Sep 5 22:16:12 2008
@@ -20,21 +20,23 @@
#define __TEXT_TOOL_COMMANDS_H__
-void text_tool_cut_cmd_callback (GtkAction *action,
- gpointer data);
-void text_tool_copy_cmd_callback (GtkAction *action,
- gpointer data);
+void text_tool_cut_cmd_callback (GtkAction *action,
+ gpointer data);
+void text_tool_copy_cmd_callback (GtkAction *action,
+ gpointer data);
void text_tool_paste_cmd_callback (GtkAction *action,
gpointer data);
-void text_tool_delete_cmd_callback (GtkAction *action,
+void text_tool_delete_cmd_callback (GtkAction *action,
+ gpointer data);
+void text_tool_load_cmd_callback (GtkAction *action,
+ gpointer data);
+void text_tool_clear_cmd_callback (GtkAction *action,
+ gpointer data);
+void text_tool_path_from_text_callback (GtkAction *action,
+ gpointer data);
+void text_tool_direction_cmd_callback (GtkAction *action,
+ GtkAction *current,
gpointer data);
-void text_tool_load_cmd_callback (GtkAction *action,
- gpointer data);
-void text_tool_clear_cmd_callback (GtkAction *action,
- gpointer data);
-void text_tool_direction_cmd_callback (GtkAction *action,
- GtkAction *current,
- gpointer data);
#endif /* __TEXT_TOOL_COMMANDS_H__ */
Modified: branches/soc-2008-text/app/tools/gimptextoptions.c
==============================================================================
--- branches/soc-2008-text/app/tools/gimptextoptions.c (original)
+++ branches/soc-2008-text/app/tools/gimptextoptions.c Fri Sep 5 22:16:12 2008
@@ -62,6 +62,7 @@
PROP_INDENTATION,
PROP_LINE_SPACING,
PROP_LETTER_SPACING,
+ PROP_USE_EDITOR,
PROP_FONT_VIEW_TYPE,
PROP_FONT_VIEW_SIZE
@@ -173,6 +174,14 @@
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_DEFAULTS);
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_EDITOR,
+ "use-editor",
+ N_("Use an external editor window for text "
+ "entry, instead of direct-on-canvas "
+ "editing"),
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_FONT_VIEW_TYPE,
"font-view-type", NULL,
GIMP_TYPE_VIEW_TYPE,
@@ -192,7 +201,6 @@
gimp_text_options_init (GimpTextOptions *options)
{
options->size_entry = NULL;
- options->to_vectors_button = NULL;
options->along_vectors_button = NULL;
}
@@ -240,6 +248,10 @@
g_value_set_double (value, options->letter_spacing);
break;
+ case PROP_USE_EDITOR:
+ g_value_set_boolean (value, options->use_editor);
+ break;
+
case PROP_FONT_VIEW_TYPE:
g_value_set_enum (value, options->font_view_type);
break;
@@ -298,6 +310,10 @@
options->letter_spacing = g_value_get_double (value);
break;
+ case PROP_USE_EDITOR:
+ options->use_editor = g_value_get_boolean (value);
+ break;
+
case PROP_FONT_VIEW_TYPE:
options->font_view_type = g_value_get_enum (value);
break;
@@ -458,6 +474,10 @@
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
+ button = gimp_prop_check_button_new (config, "use-editor", _("Use editor"));
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
+
button = gimp_prop_check_button_new (config, "hinting", _("Hinting"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
@@ -516,14 +536,6 @@
gimp_table_attach_stock (GTK_TABLE (table), row++,
GIMP_STOCK_LETTER_SPACING, spinbutton, 1, TRUE);
- /* Create a path from the current text */
- button = gtk_button_new_with_label (_("Path from Text"));
- gtk_box_pack_end (GTK_BOX (main_vbox), button, FALSE, FALSE, 0);
- gtk_widget_set_sensitive (button, FALSE);
- gtk_widget_show (button);
-
- options->to_vectors_button = button;
-
button = gtk_button_new_with_label (_("Text along Path"));
gtk_box_pack_end (GTK_BOX (main_vbox), button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (button, FALSE);
Modified: branches/soc-2008-text/app/tools/gimptextoptions.h
==============================================================================
--- branches/soc-2008-text/app/tools/gimptextoptions.h (original)
+++ branches/soc-2008-text/app/tools/gimptextoptions.h Fri Sep 5 22:16:12 2008
@@ -53,9 +53,10 @@
GimpViewType font_view_type;
GimpViewSize font_view_size;
+ gboolean use_editor;
+
/* options gui */
GtkWidget *size_entry;
- GtkWidget *to_vectors_button;
GtkWidget *along_vectors_button;
};
Modified: branches/soc-2008-text/app/tools/gimptexttool.c
==============================================================================
--- branches/soc-2008-text/app/tools/gimptexttool.c (original)
+++ branches/soc-2008-text/app/tools/gimptexttool.c Fri Sep 5 22:16:12 2008
@@ -131,7 +131,6 @@
static gboolean gimp_text_tool_idle_apply (GimpTextTool *text_tool);
static void gimp_text_tool_apply (GimpTextTool *text_tool);
-static void gimp_text_tool_create_vectors (GimpTextTool *text_tool);
static void gimp_text_tool_create_vectors_warped
(GimpTextTool *text_tool);
static void gimp_text_tool_create_layer (GimpTextTool *text_tool,
@@ -422,7 +421,7 @@
if (x1 <= cx && x2 >= cx && y1 <= cy && y2 >= cy)
{
text_tool->text_cursor_changing = TRUE;
- gimp_rectangle_tool_set_function (rect_tool, GIMP_RECTANGLE_TOOL_DEAD);
+ gimp_rectangle_tool_set_function (rect_tool, GIMP_RECTANGLE_TOOL_DEAD);
gimp_tool_control_activate (tool->control);
}
else
@@ -559,7 +558,6 @@
"y2", &y2,
NULL);
-
if (gtk_text_buffer_get_has_selection (text_tool->text_buffer))
gimp_text_tool_clipboard_copy (text_tool, FALSE);
text_tool->text_cursor_changing = FALSE;
@@ -677,7 +675,7 @@
if (offset == old_cursor_offset)
return;
-
+
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
gtk_text_buffer_get_iter_at_offset (text_tool->text_buffer,
&cursor, offset);
@@ -857,14 +855,6 @@
if (text_tool->pending)
gimp_text_tool_apply (text_tool);
- if (options->to_vectors_button)
- {
- gtk_widget_set_sensitive (options->to_vectors_button, FALSE);
- g_signal_handlers_disconnect_by_func (options->to_vectors_button,
- gimp_text_tool_create_vectors,
- text_tool);
- }
-
if (options->along_vectors_button)
{
gtk_widget_set_sensitive (options->along_vectors_button,
@@ -894,14 +884,6 @@
G_CALLBACK (gimp_text_tool_text_notify),
text_tool);
- if (options->to_vectors_button)
- {
- g_signal_connect_swapped (options->to_vectors_button, "clicked",
- G_CALLBACK (gimp_text_tool_create_vectors),
- text_tool);
- gtk_widget_set_sensitive (options->to_vectors_button, TRUE);
- }
-
if (options->along_vectors_button)
{
g_signal_connect_swapped (options->along_vectors_button, "clicked",
@@ -1160,7 +1142,7 @@
gimp_text_tool_update_layout (text_tool);
}
-static void
+void
gimp_text_tool_create_vectors (GimpTextTool *text_tool)
{
GimpVectors *vectors;
@@ -1335,10 +1317,11 @@
"/text-tool-popup/text-tool-input-methods");
im_menu = gtk_menu_new ();
- gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (text_tool->im_context), GTK_MENU_SHELL (im_menu));
+ gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (text_tool->im_context),
+ GTK_MENU_SHELL (im_menu));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (im_menuitem), im_menu);
gtk_widget_show (im_menuitem);
-
+
g_signal_connect (text_tool, "show-popup",
G_CALLBACK (gimp_text_tool_show_context_menu), NULL);
@@ -2206,12 +2189,23 @@
NULL, NULL, NULL, NULL);
return;
}
+
+ gimp_ui_manager_update (text_tool->ui_manager, text_tool);
gimp_ui_manager_ui_popup (text_tool->ui_manager,
"/text-tool-popup",
GTK_WIDGET (shell),
NULL, NULL, NULL, NULL);
}
+gboolean
+gimp_text_tool_get_has_text_selection (GimpTextTool *text_tool)
+{
+ if (text_tool->text_buffer)
+ return gtk_text_buffer_get_has_selection (text_tool->text_buffer);
+ else
+ return FALSE;
+}
+
void
gimp_text_tool_clipboard_cut (GimpTextTool *text_tool)
{
Modified: branches/soc-2008-text/app/tools/gimptexttool.h
==============================================================================
--- branches/soc-2008-text/app/tools/gimptexttool.h (original)
+++ branches/soc-2008-text/app/tools/gimptexttool.h Fri Sep 5 22:16:12 2008
@@ -89,4 +89,7 @@
void gimp_text_tool_clipboard_copy (GimpTextTool *text_tool, gboolean use_CLIPBOARD);
void gimp_text_tool_clipboard_paste (GimpTextTool *text_tool, gboolean use_CLIPBOARD);
+gboolean gimp_text_tool_get_has_text_selection (GimpTextTool *text_tool);
+void gimp_text_tool_create_vectors (GimpTextTool *text_tool);
+
#endif /* __GIMP_TEXT_TOOL_H__ */
Modified: branches/soc-2008-text/menus/text-tool-menu.xml
==============================================================================
--- branches/soc-2008-text/menus/text-tool-menu.xml (original)
+++ branches/soc-2008-text/menus/text-tool-menu.xml Fri Sep 5 22:16:12 2008
@@ -11,6 +11,8 @@
<menuitem action="text-tool-load" />
<menuitem action="text-tool-clear" />
<separator />
+ <menuitem action="text-tool-path-from-text" />
+ <separator />
<menuitem action="text-tool-direction-ltr" />
<menuitem action="text-tool-direction-rtl" />
<separator />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]