summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2017-02-06 16:50:07 +0000
committerShlomi Fish <shlomif@shlomifish.org>2017-02-06 16:50:07 +0000
commit1232596134bcba8d19f2809ffdc84e3b5c33d3b3 (patch)
tree2fcb91d6fe9ef47a85ba3f73be10dc5dc7ee10a4 /src/widgets
parentMerged. (diff)
parentRemove some unneeded < C++11 fallback code (diff)
downloadinkscape-1232596134bcba8d19f2809ffdc84e3b5c33d3b3.tar.gz
inkscape-1232596134bcba8d19f2809ffdc84e3b5c33d3b3.zip
Merged.
(bzr r15369.1.18)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/desktop-widget.cpp218
-rw-r--r--src/widgets/desktop-widget.h4
-rw-r--r--src/widgets/gimp/ruler.cpp5
-rw-r--r--src/widgets/icon.cpp14
-rw-r--r--src/widgets/text-toolbar.cpp164
-rw-r--r--src/widgets/toolbox.cpp5
-rw-r--r--src/widgets/widget-sizes.h1
7 files changed, 370 insertions, 41 deletions
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 6b8ade0fb..682e4e103 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -54,7 +54,7 @@
#include "ui/uxmanager.h"
#include "util/ege-appear-time-tracker.h"
#include "sp-root.h"
-
+#include "attributes.h"
// We're in the "widgets" directory, so no need to explicitly prefix these:
#include "button.h"
#include "gimp/ruler.h"
@@ -62,16 +62,11 @@
#include "spw-utilities.h"
#include "toolbox.h"
#include "widget-sizes.h"
-
#include "verbs.h"
#include <gtkmm/cssprovider.h>
#include <gtkmm/paned.h>
#include <gtkmm/messagedialog.h>
-
-#if defined (SOLARIS) && (SOLARIS == 8)
-#include "round.h"
-using Inkscape::round;
-#endif
+#include <iomanip>
using Inkscape::UI::Widget::UnitTracker;
using Inkscape::UI::UXManager;
@@ -97,8 +92,20 @@ static void sp_update_guides_lock( GtkWidget *button, gpointer data );
static void cms_adjust_toggled( GtkWidget *button, gpointer data );
#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
static void cms_adjust_set_sensitive( SPDesktopWidget *dtw, bool enabled );
+static void sp_desktop_widget_rotate_document(GtkSpinButton *spin, SPDesktopWidget *dtw);
static void sp_desktop_widget_adjustment_value_changed (GtkAdjustment *adj, SPDesktopWidget *dtw);
+static gint sp_dtw_rotation_input (GtkSpinButton *spin, gdouble *new_val, gpointer data);
+static bool sp_dtw_rotation_output (GtkSpinButton *spin, gpointer data);
+static void sp_dtw_rotation_populate_popup (GtkEntry *entry, GtkMenu *menu, gpointer data);
+static void sp_dtw_rotate_minus_180 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_minus_135 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_minus_90 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_minus_45 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_0 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_45 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_90 (GtkMenuItem *item, SPDesktopWidget * data);
+static void sp_dtw_rotate_135 (GtkMenuItem *item, SPDesktopWidget * data);
static gdouble sp_dtw_zoom_value_to_display (gdouble value);
static gdouble sp_dtw_zoom_display_to_value (gdouble value);
static gint sp_dtw_zoom_input (GtkSpinButton *spin, gdouble *new_val, gpointer data);
@@ -585,6 +592,34 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
g_signal_connect (G_OBJECT (dtw->zoom_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->zoom_status);
dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "value_changed", G_CALLBACK (sp_dtw_zoom_value_changed), dtw);
dtw->zoom_update = g_signal_connect (G_OBJECT (dtw->zoom_status), "populate_popup", G_CALLBACK (sp_dtw_zoom_populate_popup), dtw);
+ auto css_provider_spinbutton = Gtk::CssProvider::create();
+ css_provider_spinbutton->load_from_data("* { padding-left: 2px; padding-right: 2px; padding-top: 0px; padding-bottom: 0px;}");
+ auto zoomstat = Glib::wrap(dtw->zoom_status);
+ zoomstat->set_name("ZoomStatus");
+ auto context_zoom = zoomstat->get_style_context();
+ context_zoom->add_provider(css_provider_spinbutton, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ // Rotate status spinbutton
+ dtw->rotation_status = gtk_spin_button_new_with_range (-360.0,360.0, 1.0);
+ gtk_widget_set_tooltip_text (dtw->rotation_status, _("Rotation. Can be interactive with CTRL+MMB"));
+ gtk_widget_set_size_request (dtw->rotation_status, STATUS_ROTATION_WIDTH, -1);
+ gtk_entry_set_width_chars (GTK_ENTRY (dtw->rotation_status), 7);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (dtw->rotation_status), FALSE);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (dtw->rotation_status), 2);
+ gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (dtw->rotation_status), GTK_UPDATE_ALWAYS);
+ g_signal_connect (G_OBJECT (dtw->rotation_status), "input", G_CALLBACK (sp_dtw_rotation_input), dtw);
+ g_signal_connect (G_OBJECT (dtw->rotation_status), "output", G_CALLBACK (sp_dtw_rotation_output), dtw);
+ g_object_set_data (G_OBJECT (dtw->rotation_status), "dtw", dtw->canvas);
+ g_signal_connect (G_OBJECT (dtw->rotation_status), "focus-in-event", G_CALLBACK (spinbutton_focus_in), dtw->rotation_status);
+ g_signal_connect (G_OBJECT (dtw->rotation_status), "key-press-event", G_CALLBACK (spinbutton_keypress), dtw->rotation_status);
+ dtw->rotation_update = g_signal_connect (G_OBJECT (dtw->rotation_status), "value_changed", G_CALLBACK (sp_desktop_widget_rotate_document), dtw);
+ dtw->rotation_update = g_signal_connect (G_OBJECT (dtw->rotation_status), "populate_popup", G_CALLBACK (sp_dtw_rotation_populate_popup), dtw);
+
+ auto rotstat = Glib::wrap(dtw->rotation_status);
+ rotstat->set_name("RotationStatus");
+ auto context_rotation = rotstat->get_style_context();
+ context_rotation->add_provider(css_provider_spinbutton, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
// Cursor coordinates
dtw->coord_status = gtk_grid_new();
@@ -611,12 +646,16 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
auto label_z = gtk_label_new(_("Z:"));
gtk_widget_set_name(label_z, "ZLabel");
+ auto label_r = gtk_label_new(_("R:"));
+ gtk_widget_set_name(label_r, "RLabel");
gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END);
gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), label_r, 5, 0, 1, 2);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->rotation_status, 6, 0, 1, 2);
sp_set_font_size_smaller (dtw->coord_status);
@@ -684,6 +723,11 @@ static void sp_desktop_widget_dispose(GObject *object)
g_signal_handlers_disconnect_matched (G_OBJECT (dtw->zoom_status), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dtw->zoom_status);
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_value_changed), dtw);
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->zoom_status), (gpointer) G_CALLBACK (sp_dtw_zoom_populate_popup), dtw);
+ g_signal_handlers_disconnect_by_func(G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK(sp_dtw_rotation_input), dtw);
+ g_signal_handlers_disconnect_by_func(G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK(sp_dtw_rotation_output), dtw);
+ g_signal_handlers_disconnect_matched (G_OBJECT (dtw->rotation_status), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, dtw->rotation_status);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK (sp_desktop_widget_rotate_document), dtw);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->rotation_status), (gpointer) G_CALLBACK (sp_dtw_rotation_populate_popup), dtw);
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas), (gpointer) G_CALLBACK (sp_desktop_widget_event), dtw);
g_signal_handlers_disconnect_by_func (G_OBJECT (dtw->canvas_tbl), (gpointer) G_CALLBACK (canvas_tbl_size_allocate), dtw);
@@ -1415,7 +1459,7 @@ void SPDesktopWidget::layoutWidgets()
} else {
gtk_widget_show_all (dtw->menubar);
}
-
+
if (!prefs->getBool(pref_root + "commands/state", true)) {
gtk_widget_hide (dtw->commands_toolbox);
} else {
@@ -1621,10 +1665,11 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview)
dtw->menubar = sp_ui_main_menubar (dtw->desktop);
gtk_widget_set_name(dtw->menubar, "MenuBar");
gtk_widget_show_all (dtw->menubar);
+ SPNamedView *nv = dtw->desktop->namedview;
gtk_box_pack_start (GTK_BOX (dtw->vbox), dtw->menubar, FALSE, FALSE, 0);
-
dtw->layoutWidgets();
-
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON (dtw->rotation_status), namedview->document_rotation);
+ sp_namedview_set_document_rotation(namedview);
std::vector<GtkWidget *> toolboxes;
toolboxes.push_back(dtw->tool_toolbox);
toolboxes.push_back(dtw->aux_toolbox);
@@ -1664,6 +1709,8 @@ sp_desktop_widget_update_rulers (SPDesktopWidget *dtw)
void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags)
{
SPNamedView *nv=SP_NAMEDVIEW(obj);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(this->rotation_status), desktop->namedview->document_rotation);
+ sp_namedview_set_document_rotation(nv);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
this->dt2r = 1. / nv->display_units->factor;
@@ -1689,9 +1736,16 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags)
if (GTK_IS_CONTAINER(i->data)) {
GList *grch = gtk_container_get_children (GTK_CONTAINER(i->data));
for (GList *j = grch; j != NULL; j = j->next) {
+
if (!GTK_IS_WIDGET(j->data)) // wasn't a widget
continue;
+ // Don't apply to text toolbar. We want to be able to
+ // use different units for text. (Bug 1562217)
+ const gchar* name = gtk_widget_get_name( (GTK_WIDGET(j->data)) );
+ if (strcmp( name, "TextToolbar") == 0)
+ continue;
+
gpointer t = sp_search_by_data_recursive(GTK_WIDGET(j->data), (gpointer) "tracker");
if (t == NULL) // didn't find any tracker data
continue;
@@ -1715,6 +1769,18 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags)
}
static void
+sp_desktop_widget_rotate_document(GtkSpinButton *spin, SPDesktopWidget *dtw)
+{
+ SPNamedView *nv = dtw->desktop->namedview;
+ double value = gtk_spin_button_get_value (spin);
+ if (!dtw->desktop->getDocument()->getRoot()->rotated && value != nv->document_rotation) {
+ sp_repr_set_svg_double(nv->getRepr(), "inkscape:document-rotation", value);
+ }
+ spinbutton_defocus (GTK_WIDGET(spin));
+}
+
+
+static void
sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWidget *dtw)
{
if (dtw->update)
@@ -1794,6 +1860,34 @@ sp_dtw_zoom_output (GtkSpinButton *spin, gpointer /*data*/)
return TRUE;
}
+static gint
+sp_dtw_rotation_input (GtkSpinButton *spin, gdouble *new_val, gpointer /*data*/)
+{
+ gdouble new_scrolled = gtk_spin_button_get_value (spin);
+ const gchar *b = gtk_entry_get_text (GTK_ENTRY (spin));
+ gdouble new_typed = atof (b);
+
+ if (new_scrolled == new_typed) { // the new value is set by scrolling
+ *new_val = new_scrolled;
+ } else { // the new value is typed in
+ *new_val = new_typed;
+ }
+
+ return TRUE;
+}
+
+static bool
+sp_dtw_rotation_output (GtkSpinButton *spin, gpointer /*data*/)
+{
+ gchar b[64];
+ double val = gtk_spin_button_get_value (spin);
+ std::ostringstream s;
+ s.imbue(std::locale(""));;
+ s << std::fixed << std::setprecision(2) << val << "º";
+ gtk_entry_set_text (GTK_ENTRY (spin), s.str().c_str());
+ return TRUE;
+}
+
static void
sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data)
{
@@ -1932,6 +2026,110 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
+
+static void
+sp_dtw_rotation_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data)
+{
+ GList *children, *iter;
+ GtkWidget *item;
+ SPDesktopWidget *dtw = static_cast<SPDesktopWidget*>(data);
+ children = gtk_container_get_children (GTK_CONTAINER (menu));
+ for ( iter = children ; iter ; iter = g_list_next (iter)) {
+ gtk_container_remove (GTK_CONTAINER (menu), GTK_WIDGET (iter->data));
+ }
+ g_list_free (children);
+
+ item = gtk_menu_item_new_with_label ("-180º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_180), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_label ("-135º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_135), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_label ("-90º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_90), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_label ("-45º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_minus_45), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_label ("0º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_0), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_label ("45º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_45), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+
+ item = gtk_menu_item_new_with_label ("90º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_90), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+
+ item = gtk_menu_item_new_with_label ("135º");
+ g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_rotate_135), dtw);
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+}
+
+static void
+sp_dtw_rotate_minus_180 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status),-180);
+}
+
+static void
+sp_dtw_rotate_minus_135 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), -135);
+}
+
+static void
+sp_dtw_rotate_minus_90 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), -90);
+}
+
+static void
+sp_dtw_rotate_minus_45 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), -45);
+}
+
+static void
+sp_dtw_rotate_0 (GtkMenuItem */*item*/,SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 0);
+}
+
+static void
+sp_dtw_rotate_45 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 45);
+}
+
+static void
+sp_dtw_rotate_90 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 90);
+}
+
+static void
+sp_dtw_rotate_135 (GtkMenuItem */*item*/, SPDesktopWidget * data)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON((data)->rotation_status), 135);
+}
+
static void
sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor)
{
diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h
index 08966ad5f..61c3b8b37 100644
--- a/src/widgets/desktop-widget.h
+++ b/src/widgets/desktop-widget.h
@@ -78,7 +78,7 @@ struct SPDesktopWidget {
GtkWidget *hbox;
- GtkWidget *menubar, *statusbar;
+ GtkWidget *menubar, *statusbar, *rotatebar;
Inkscape::UI::Dialogs::SwatchesPanel *panels;
@@ -97,7 +97,9 @@ struct SPDesktopWidget {
GtkWidget *select_status;
GtkWidget *select_status_eventbox;
GtkWidget *zoom_status;
+ GtkWidget *rotation_status;
gulong zoom_update;
+ gulong rotation_update;
Inkscape::UI::Widget::Dock *dock;
diff --git a/src/widgets/gimp/ruler.cpp b/src/widgets/gimp/ruler.cpp
index 2a71b5c08..6a1f7f903 100644
--- a/src/widgets/gimp/ruler.cpp
+++ b/src/widgets/gimp/ruler.cpp
@@ -34,11 +34,10 @@
#include <cstdio>
#include "ruler.h"
-#include "round.h"
#include <glibmm/i18n.h>
#include "util/units.h"
-#define ROUND(x) ((int) ((x) + 0.5))
+#define ROUND(x) ((int) round(x))
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
@@ -1217,7 +1216,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
// be e.g. 641.50000000000; rounding behaviour is not defined in such a case (see round.h)
// and jitter will be apparent (upon redrawing some of the lines on the ruler might jump a
// by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-))
- pos = gint(Inkscape::round((cur - lower) * increment + 1e-12));
+ pos = gint(round((cur - lower) * increment + 1e-12));
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index 1efa8f06b..885deaab7 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -35,6 +35,7 @@
#include "display/drawing.h"
#include "io/sys.h"
#include "sp-root.h"
+#include "sp-namedview.h"
#include "util/units.h"
#include "icon.h"
@@ -1163,6 +1164,19 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
CAIRO_FORMAT_ARGB32, psize, psize, stride);
Inkscape::DrawingContext dc(s, ua.min());
+ SPNamedView *nv = sp_document_namedview(doc, NULL);
+ float bg_r = SP_RGBA32_R_F(nv->pagecolor);
+ float bg_g = SP_RGBA32_G_F(nv->pagecolor);
+ float bg_b = SP_RGBA32_B_F(nv->pagecolor);
+ float bg_a = SP_RGBA32_A_F(nv->pagecolor);
+
+ cairo_t *cr = cairo_create(s);
+ cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a);
+ cairo_rectangle(cr, 0, 0, psize, psize);
+ cairo_fill(cr);
+ cairo_save(cr);
+ cairo_destroy(cr);
+
drawing.render(dc, ua);
cairo_surface_destroy(s);
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index ba79517d2..24665be37 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -301,10 +301,23 @@ static void sp_text_fontstyle_value_changed( Ink_ComboBoxEntry_Action *act, GObj
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
sp_desktop_set_style (desktop, css, true, true);
+
+
+ // If no selected objects, set default.
+ SPStyle query(SP_ACTIVE_DOCUMENT);
+ int result_style =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+ if (result_style == QUERY_STYLE_NOTHING) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ } else {
+ // Save for undo
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change font style"));
+ }
+
sp_repr_css_attr_unref (css);
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
- _("Text: Change font style"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -588,17 +601,14 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- // Only save if not relative unit
- if ( !is_relative(unit) ) {
- // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit so
- // we can save it (allows us to adjust line height value when unit changes).
- SPILength temp_length;
- Inkscape::CSSOStringStream temp_stream;
- temp_stream << 1 << unit->abbr;
- temp_length.read(temp_stream.str().c_str());
- prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit);
- g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit));
- }
+ // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit so
+ // we can save it (allows us to adjust line height value when unit changes).
+ SPILength temp_length;
+ Inkscape::CSSOStringStream temp_stream;
+ temp_stream << 1 << unit->abbr;
+ temp_length.read(temp_stream.str().c_str());
+ prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit);
+ g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit));
// Set css line height.
SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -701,16 +711,13 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl )
g_return_if_fail(unit != NULL);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- // Only save if not relative unit
- if ( !is_relative(unit) ) {
- // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit.
- SPILength temp_length;
- Inkscape::CSSOStringStream temp_stream;
- temp_stream << 1 << unit->abbr;
- temp_length.read(temp_stream.str().c_str());
- prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit);
- g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit));
- }
+ // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit.
+ SPILength temp_length;
+ Inkscape::CSSOStringStream temp_stream;
+ temp_stream << 1 << unit->abbr;
+ temp_length.read(temp_stream.str().c_str());
+ prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit);
+ g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit));
// Read current line height value
EgeAdjustmentAction *line_height_act =
@@ -723,7 +730,10 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl )
auto itemlist = selection->items();
// Convert between units
- if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) {
+ if ((unit->abbr == "" || unit->abbr == "em") &&
+ (old_unit == SP_CSS_UNIT_NONE || old_unit == SP_CSS_UNIT_EM)) {
+ // Do nothing
+ } else if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) {
line_height *= 0.5;
} else if ((unit->abbr) == "ex" && (old_unit == SP_CSS_UNIT_EM || old_unit == SP_CSS_UNIT_NONE) ) {
line_height *= 2.0;
@@ -1130,6 +1140,54 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
+static void sp_text_direction_changed( EgeSelectOneAction *act, GObject *tbl )
+{
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
+ int mode = ege_select_one_action_get_active( act );
+
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ switch (mode)
+ {
+ case 0:
+ {
+ sp_repr_css_set_property (css, "direction", "ltr");
+ break;
+ }
+
+ case 1:
+ {
+ sp_repr_css_set_property (css, "direction", "rtl");
+ break;
+ }
+ }
+
+ SPStyle query(SP_ACTIVE_DOCUMENT);
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+
+ // If querying returned nothing, update default style.
+ if (result_numbers == QUERY_STYLE_NOTHING)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
+ }
+
+ sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true);
+ if(result_numbers != QUERY_STYLE_NOTHING)
+ {
+ DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change direction"));
+ }
+ sp_repr_css_attr_unref (css);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
/*
* Set the default list of font sizes, scaled to the users preferred unit
*/
@@ -1170,8 +1228,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
std::cout << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl;
std::cout << "sp_text_toolbox_selection_changed: start " << count << std::endl;
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Inkscape::Selection *selection = desktop->getSelection();
+ Inkscape::Selection *selection = (SP_ACTIVE_DESKTOP)->getSelection();
auto itemlist0= selection->items();
for(auto i=itemlist0.begin();i!=itemlist0.end(); ++i) {
const gchar* id = (*i)->getId();
@@ -1494,6 +1551,15 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
ege_select_one_action_update_sensitive( textOrientationAction );
+ // Direction
+ int activeButton4 = 0;
+ if (query.direction.computed == SP_CSS_DIRECTION_LTR ) activeButton4 = 0;
+ if (query.direction.computed == SP_CSS_DIRECTION_RTL ) activeButton4 = 1;
+
+ EgeSelectOneAction* textDirectionAction =
+ EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextDirectionAction" ) );
+ ege_select_one_action_set_active( textDirectionAction, activeButton4 );
+
}
#ifdef DEBUG_TEXT
@@ -1926,6 +1992,52 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_changed), holder );
}
+
+ // Text direction (predominant direction of horizontal text).
+ {
+ GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
+
+ GtkTreeIter iter;
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("LTR"),
+ 1, _("Left to right text"),
+ 2, INKSCAPE_ICON("format-text-direction-horizontal"),
+ 3, true,
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("RTL"),
+ 1, _("Right to left text"),
+ 2, INKSCAPE_ICON("format-text-direction-r2l"),
+ 3, true,
+ -1 );
+
+ EgeSelectOneAction* act = ege_select_one_action_new( "TextDirectionAction", // Name
+ _("Text direction"), // Label
+ _("Text direction for normally horizontal text."), // Tooltip
+ NULL, // Icon name
+ GTK_TREE_MODEL(model) ); // Model
+
+ g_object_set( act, "short_label", "NotUsed", NULL );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "TextDirectAction", act );
+
+ ege_select_one_action_set_appearance( act, "full" );
+ ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
+ g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
+ ege_select_one_action_set_icon_column( act, 2 );
+ ege_select_one_action_set_icon_size( act, secondarySize );
+ ege_select_one_action_set_tooltip_column( act, 1 );
+ ege_select_one_action_set_sensitive_column( act, 3 );
+
+ gint mode = prefs->getInt("/tools/text/text_direction", 0);
+ ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_direction_changed), holder );
+ }
+
/* Line height unit tracker */
UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
tracker->prependUnit(unit_table.getUnit("")); // No unit
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 126eac9cd..016eafdaa 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -204,6 +204,7 @@ static struct {
SP_VERB_CONTEXT_ERASER_PREFS, "/tools/eraser", _("TBD")},
{ "/tools/lpetool", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar",
SP_VERB_CONTEXT_LPETOOL_PREFS, "/tools/lpetool", _("TBD")},
+ // If you change TextToolbar here, change it also in desktop-widget.cpp
{ "/tools/text", "text_toolbox", 0, sp_text_toolbox_prep, "TextToolbar",
SP_VERB_INVALID, 0, 0},
{ "/tools/dropper", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar",
@@ -529,6 +530,8 @@ static gchar const * ui_descr =
" <toolitem action='TextWritingModeAction' />"
" <separator />"
" <toolitem action='TextOrientationAction' />"
+ " <separator />"
+ " <toolitem action='TextDirectionAction' />"
" </toolbar>"
" <toolbar name='LPEToolToolbar'>"
@@ -1428,7 +1431,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
auto kludge = dataHolders[aux_toolboxes[i].type_name];
auto holder = gtk_grid_new();
- gtk_widget_set_name( holder, "ToolbarHolder" );
+ gtk_widget_set_name( holder, aux_toolboxes[i].ui_name );
gtk_grid_attach( GTK_GRID(holder), kludge, 2, 0, 1, 1);
gchar* tmp = g_strdup_printf( "/ui/%s", aux_toolboxes[i].ui_name );
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, tmp );
diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h
index 87c7ca2e0..186cf4730 100644
--- a/src/widgets/widget-sizes.h
+++ b/src/widgets/widget-sizes.h
@@ -28,6 +28,7 @@
#define STATUS_BAR_FONT_SIZE 10000
#define STATUS_ZOOM_WIDTH 57
+#define STATUS_ROTATION_WIDTH 57
#define SELECTED_STYLE_SB_WIDTH 48
#define SELECTED_STYLE_WIDTH 190