X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Ftext-edit.cpp;h=b0ba2c2f00d4e172ca6e973fc9b2dcc502cbc28f;hb=724821145d62dee9f97465c706952582da6e432d;hp=27304bb1f79e90e8b4a0c4783c5c908604507150;hpb=cd4b3d6b35dc66928db5fd4880f9441d0e70bff9;p=inkscape.git diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index 27304bb1f..b0ba2c2f0 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -3,11 +3,12 @@ /** * \brief Text editing dialog * - * Author: + * Authors: * Lauris Kaplinski * bulia byak + * Johan Engelen * - * Copyright (C) 1999-2002 Lauris Kaplinski + * Copyright (C) 1999-2007 Authors * Copyright (C) 2000-2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -52,6 +53,7 @@ extern "C" { #include #define VB_MARGIN 4 +#define MIN_ONSCREEN_DISTANCE 50 static void sp_text_edit_dialog_selection_modified (Inkscape::Application *inkscape, Inkscape::Selection *sel, guint flags, GtkWidget *dlg); static void sp_text_edit_dialog_selection_changed (Inkscape::Application *inkscape, Inkscape::Selection *sel, GtkWidget *dlg); @@ -136,7 +138,6 @@ text_view_focus_out (GtkWidget *w, GdkEventKey *event, gpointer data) void sp_text_edit_dialog (void) { - if (!dlg) { gchar title[500]; @@ -144,8 +145,8 @@ sp_text_edit_dialog (void) dlg = sp_window_new (title, TRUE); if (x == -1000 || y == -1000) { - x = prefs_get_int_attribute (prefs_path, "x", 0); - y = prefs_get_int_attribute (prefs_path, "y", 0); + x = prefs_get_int_attribute (prefs_path, "x", -1000); + y = prefs_get_int_attribute (prefs_path, "y", -1000); } if (w ==0 || h == 0) { @@ -153,17 +154,17 @@ sp_text_edit_dialog (void) h = prefs_get_int_attribute (prefs_path, "h", 0); } - if (x<0) x=0; - if (y<0) y=0; +// if (x<0) x=0; +// if (y<0) y=0; - if (x != 0 || y != 0) { + if (w && h) + gtk_window_resize ((GtkWindow *) dlg, w, h); + if (x >= 0 && y >= 0 && (x < (gdk_screen_width()-MIN_ONSCREEN_DISTANCE)) && (y < (gdk_screen_height()-MIN_ONSCREEN_DISTANCE))) { gtk_window_move ((GtkWindow *) dlg, x, y); } else { gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); } - if (w && h) - gtk_window_resize ((GtkWindow *) dlg, w, h); sp_transientize (dlg); wd.win = dlg; @@ -270,6 +271,20 @@ sp_text_edit_dialog (void) gtk_box_pack_start (GTK_BOX (row), b, FALSE, FALSE, 0); g_object_set_data (G_OBJECT (dlg), "text_anchor_end", b); } + + // align justify + { + // TODO - replace with Inkscape-specific call + GtkWidget *px = gtk_image_new_from_stock ( GTK_STOCK_JUSTIFY_FILL, GTK_ICON_SIZE_LARGE_TOOLBAR ); + GtkWidget *b = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group))); + gtk_tooltips_set_tip (tt, b, _("Justify lines"), NULL); + gtk_button_set_relief (GTK_BUTTON (b), GTK_RELIEF_NONE); + g_signal_connect ( G_OBJECT (b), "toggled", G_CALLBACK (sp_text_edit_dialog_any_toggled), dlg ); + gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (b), FALSE); + gtk_container_add (GTK_CONTAINER (b), px); + gtk_box_pack_start (GTK_BOX (row), b, FALSE, FALSE, 0); + g_object_set_data (G_OBJECT (dlg), "text_anchor_justify", b); + } gtk_box_pack_start (GTK_BOX (l_vb), row, FALSE, FALSE, 0); } @@ -529,7 +544,7 @@ sp_get_text_dialog_style () sp_repr_css_set_property (css, "font-variant", c); Inkscape::CSSOStringStream os; - os << sp_font_selector_get_size (SP_FONT_SELECTOR (fontsel)); + os << sp_font_selector_get_size (SP_FONT_SELECTOR (fontsel)) << "px"; // must specify px, see inkscape bug 1221626 and 1610103 sp_repr_css_set_property (css, "font-size", os.str().c_str()); font->Unref(); @@ -539,18 +554,29 @@ sp_get_text_dialog_style () /* Layout */ GtkWidget *b = (GtkWidget*)g_object_get_data (G_OBJECT (dlg), "text_anchor_start"); + // Align Left if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) { sp_repr_css_set_property (css, "text-anchor", "start"); sp_repr_css_set_property (css, "text-align", "start"); } else { + // Align Center b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_middle"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) { sp_repr_css_set_property (css, "text-anchor", "middle"); sp_repr_css_set_property (css, "text-align", "center"); } else { - sp_repr_css_set_property (css, "text-anchor", "end"); - sp_repr_css_set_property (css, "text-align", "end"); + // Align Right + b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), + "text_anchor_end"); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))) { + sp_repr_css_set_property (css, "text-anchor", "end"); + sp_repr_css_set_property (css, "text-align", "end"); + } else { + // Align Justify + sp_repr_css_set_property (css, "text-anchor", "start"); + sp_repr_css_set_property (css, "text-align", "justify"); + } } } @@ -631,7 +657,8 @@ sp_text_edit_dialog_apply (GtkButton *button, GtkWidget *dlg) } // complete the transaction - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP)); + sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, + _("Set text style")); gtk_widget_set_sensitive (apply, FALSE); sp_repr_css_attr_unref (css); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE)); @@ -736,7 +763,11 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, GtkWidget *b; if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) { - b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_start" ); + if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) { + b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_justify" ); + } else { + b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_start" ); + } } else if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) { b = (GtkWidget*)g_object_get_data ( G_OBJECT (dlg), "text_anchor_middle" ); } else { @@ -802,7 +833,14 @@ sp_text_edit_dialog_text_changed (GtkTextBuffer *tb, GtkWidget *dlg) } // end of sp_text_edit_dialog_text_changed() - +void +sp_text_edit_dialog_default_set_insensitive () +{ + if (!dlg) return; + gpointer data = g_object_get_data (G_OBJECT (dlg), "default"); + if (!data) return; + gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE); +} static void sp_text_edit_dialog_font_changed ( SPFontSelector *fsel,