Code

* on-canvas clip and mask editing :) in the object menu you can find how to edit...
[inkscape.git] / src / widgets / toolbox.cpp
index 31720b3e842c15fab32b85ebdb88b924a48a2879..fcf3e0ce6bd874917ee2b0730179a33b326adf6e 100644 (file)
@@ -40,6 +40,7 @@
 #include "widgets/spw-utilities.h"
 #include "widgets/spinbutton-events.h"
 #include "dialogs/text-edit.h"
+#include "dialogs/dialog-events.h"
 
 #include "ui/widget/style-swatch.h"
 
@@ -249,6 +250,7 @@ static gchar const * ui_descr =
         "    <toolitem action='StrokeToPath' />"
         "    <separator />"
         "    <toolitem action='NodesShowHandlesAction' />"
+        "    <toolitem action='NodesShowHelperpath' />"
         "    <separator />"
         "    <toolitem action='EditNextLPEParameterAction' />"
         "    <separator />"
@@ -506,7 +508,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi
     GtkAction* act = 0;
 
     SPAction* targetAction = verb->get_action(view);
-    InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), verb->get_image(), size  );
+    InkAction* inky = ink_action_new( verb->get_id(), _(verb->get_name()), verb->get_tip(), verb->get_image(), size  );
     act = GTK_ACTION(inky);
     gtk_action_set_sensitive( act, targetAction->sensitive );
 
@@ -844,6 +846,13 @@ static void toggle_show_handles (GtkToggleAction *act, gpointer /*data*/) {
     if (shape_editor) shape_editor->show_handles(show);
 }
 
+static void toggle_show_helperpath (GtkToggleAction *act, gpointer /*data*/) {
+    bool show = gtk_toggle_action_get_active( act );
+    prefs_set_int_attribute ("tools.nodes", "show_helperpath",  show ? 1 : 0);
+    ShapeEditor *shape_editor = get_current_shape_editor();
+    if (shape_editor) shape_editor->show_helperpath(show);
+}
+
 void sp_node_path_edit_nextLPEparam (GtkAction */*act*/, gpointer data) {
     sp_selection_next_patheffect_param( reinterpret_cast<SPDesktop*>(data) );
 }
@@ -1094,6 +1103,17 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
         gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.nodes", "show_handles", 1 ) );
     }
 
+    {
+        InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath",
+                                                      _("Show Outline"),
+                                                      _("Show the outline of the path"),
+                                                      "nodes_show_helperpath",
+                                                      Inkscape::ICON_SIZE_DECORATION );
+        gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+        g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_helperpath), desktop );
+        gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.nodes", "show_helperpath", 0 ) );
+    }
+
     {
         InkAction* inky = ink_action_new( "EditNextLPEParameterAction",
                                           _("Next Path Effect Parameter"),
@@ -1717,6 +1737,9 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n
 
     GtkAdjustment *adj = 0;
 
+    gchar const *flatsidedstr = prefs_get_string_attribute( "tools.shapes.star", "isflatsided" );
+    bool isFlatSided = flatsidedstr ? (strcmp(flatsidedstr, "false") != 0) : true;
+
     if (!strcmp(name, "inkscape:randomized")) {
         adj = GTK_ADJUSTMENT( gtk_object_get_data(GTK_OBJECT(tbl), "randomized") );
         gtk_adjustment_set_value(adj, sp_repr_get_double_attribute(repr, "inkscape:randomized", 0.0));
@@ -1734,7 +1757,7 @@ static void star_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const *n
             ege_select_one_action_set_active( flat_action, 0 );
             gtk_action_set_sensitive( prop_action, FALSE );
         }
-    } else if (!strcmp(name, "sodipodi:r1") || !strcmp(name, "sodipodi:r2")) {
+    } else if ((!strcmp(name, "sodipodi:r1") || !strcmp(name, "sodipodi:r2")) && (!isFlatSided) ) {
         adj = (GtkAdjustment*)gtk_object_get_data(GTK_OBJECT(tbl), "proportion");
         gdouble r1 = sp_repr_get_double_attribute(repr, "sodipodi:r1", 1.0);
         gdouble r2 = sp_repr_get_double_attribute(repr, "sodipodi:r2", 1.0);
@@ -3954,7 +3977,8 @@ sp_text_letter_rotation_changed(GtkAdjustment *adj, GtkWidget *tbl)
 
 namespace {
 
-bool visible = false;
+bool popdown_visible = false;
+bool popdown_hasfocus = false;
 
 void
 sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *tbl)
@@ -4143,13 +4167,10 @@ sp_text_toolbox_family_changed (GtkTreeSelection    *selection,
 {
     SPDesktop    *desktop = SP_ACTIVE_DESKTOP;
     GtkTreeModel *model = 0;
-    GtkWidget    *popdown = GTK_WIDGET (g_object_get_data (tbl, "family-popdown-window"));
     GtkWidget    *entry = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
     GtkTreeIter   iter;
     char         *family = 0;
 
-    (void)popdown;
-
     gdk_pointer_ungrab (GDK_CURRENT_TIME);
     gdk_keyboard_ungrab (GDK_CURRENT_TIME);
 
@@ -4172,7 +4193,7 @@ sp_text_toolbox_family_changed (GtkTreeSelection    *selection,
 
     int result_fontspec =
         sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
-    
+
     font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
     
     SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -4180,7 +4201,7 @@ sp_text_toolbox_family_changed (GtkTreeSelection    *selection,
     
     // First try to get the font spec from the stored value
     Glib::ustring fontSpec = query->text->font_specification.set ?  query->text->font_specification.value : "";
-    
+
     if (fontSpec.empty()) {
         // Construct a new font specification if it does not yet exist
         font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
@@ -4220,7 +4241,7 @@ sp_text_toolbox_family_changed (GtkTreeSelection    *selection,
         }
     }
 
-    // If querying returned nothing, read the style from the text tool prefs (default style for new texts)
+    // If querying returned nothing, set the default style of the tool (for new texts)
     if (result_fontspec == QUERY_STYLE_NOTHING)
     {
         sp_repr_css_change (inkscape_get_repr (INKSCAPE, "tools.text"), css, "style");
@@ -4482,10 +4503,19 @@ sp_text_toolbox_family_list_keypress (GtkWidget *w, GdkEventKey *event, GObject
         case GDK_Return:
         case GDK_Escape: // defocus
             gtk_widget_hide (w);
-            visible = false;
+            popdown_visible = false;
             gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
             return TRUE; // I consumed the event
             break;
+        case GDK_w: 
+        case GDK_W: 
+            if (event->state & GDK_CONTROL_MASK) {
+                gtk_widget_hide (w);
+                popdown_visible = false;
+                gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+                return TRUE; // I consumed the event
+            }
+            break;
     }
     return FALSE;
 }
@@ -4595,11 +4625,12 @@ sp_text_toolbox_text_popdown_clicked    (GtkButton          */*button*/,
     GtkWidget *widget = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
     int x, y;
 
-    if (!visible)
+    if (!popdown_visible)
     {
         gdk_window_get_origin (widget->window, &x, &y);
         gtk_window_move (GTK_WINDOW (popdown), x, y + widget->allocation.height + 2); //2px of grace space
         gtk_widget_show_all (popdown);
+        //sp_transientize (popdown);
 
         gdk_pointer_grab (widget->window, TRUE,
                           GdkEventMask (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -4609,14 +4640,16 @@ sp_text_toolbox_text_popdown_clicked    (GtkButton          */*button*/,
 
         gdk_keyboard_grab (widget->window, TRUE, GDK_CURRENT_TIME);
 
-        visible = true;
+        popdown_visible = true;
     }
     else
     {
+        SPDesktop *desktop = SP_ACTIVE_DESKTOP;
         gdk_pointer_ungrab (GDK_CURRENT_TIME);
         gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+        gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
         gtk_widget_hide (popdown);
-        visible = false;
+        popdown_visible = false;
     }
 }
 
@@ -4636,12 +4669,26 @@ sp_text_toolbox_popdown_focus_out (GtkWidget        *popdown,
 {
     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
 
-    gtk_widget_hide (popdown);
-    visible = false;
-    gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+    if (popdown_hasfocus) {
+        gtk_widget_hide (popdown);
+        popdown_hasfocus = false;
+        popdown_visible = false;
+        gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+        return TRUE;
+    }
+    return FALSE;
+}
+
+gboolean
+sp_text_toolbox_popdown_focus_in (GtkWidget        *popdown,
+                                   GdkEventFocus    */*event*/,
+                                   GObject          */*tbl*/)
+{
+    popdown_hasfocus = true;
     return TRUE;
 }
 
+
 void
 cell_data_func  (GtkTreeViewColumn */*column*/,
                  GtkCellRenderer   *cell,
@@ -4742,6 +4789,7 @@ sp_text_toolbox_new (SPDesktop *desktop)
     g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (sp_text_toolbox_text_popdown_clicked), tbl);
 
     g_signal_connect (G_OBJECT (window), "focus-out-event", G_CALLBACK (sp_text_toolbox_popdown_focus_out), tbl);
+    g_signal_connect (G_OBJECT (window), "focus-in-event", G_CALLBACK (sp_text_toolbox_popdown_focus_in), tbl);
     g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK(sp_text_toolbox_family_list_keypress), tbl);
 
     GtkTreeSelection *tselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
@@ -5277,7 +5325,9 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
 
     // Create the units menu.
     UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
-    tracker->setActiveUnit(sp_unit_get_by_abbreviation(prefs_get_string_attribute("tools.paintbucket", "offsetunits")));
+    const gchar *stored_unit = prefs_get_string_attribute("tools.paintbucket", "offsetunits");
+    if (stored_unit)
+        tracker->setActiveUnit(sp_unit_get_by_abbreviation(stored_unit));
     g_object_set_data( holder, "tracker", tracker );
     {
         GtkAction* act = tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") );