diff options
| author | Ted Gould <ted@gould.cx> | 2010-05-15 19:05:39 +0000 |
|---|---|---|
| committer | Ted Gould <ted@gould.cx> | 2010-05-15 19:05:39 +0000 |
| commit | 672afd6dd148c167ce8f5df23e35d15f888b9473 (patch) | |
| tree | 0d47f7e475daad3eedd7d89fbc5d183598044782 /src | |
| parent | Making an enable/disable flag for building with dbus (diff) | |
| parent | Fix tooltip error in the preferences (Bug #446723). (diff) | |
| download | inkscape-672afd6dd148c167ce8f5df23e35d15f888b9473.tar.gz inkscape-672afd6dd148c167ce8f5df23e35d15f888b9473.zip | |
Pulling in a more recent trunk
(bzr r8254.1.56)
Diffstat (limited to 'src')
34 files changed, 585 insertions, 302 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index cf2883116..37469fa73 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -794,9 +794,9 @@ void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Poin sc.grid_lines.push_back(dummy); } -void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const +void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { - SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), true); + SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); sc.points.push_back(dummy); } diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 4b1cd4834..58185e2e6 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -79,7 +79,7 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const; + void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasAxonomGrid *grid; }; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 3532c504a..a79a6b610 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -1030,9 +1030,9 @@ void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point co sc.grid_lines.push_back(dummy); } -void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const +void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { - SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), true); + SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); sc.points.push_back(dummy); } diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index daf28c15c..a11d77d1d 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -167,7 +167,7 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; - void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const; + void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasXYGrid *grid; }; diff --git a/src/document-subset.cpp b/src/document-subset.cpp index eb7265b2d..1988865d1 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -301,7 +301,7 @@ void DocumentSubset::Relations::remove(SPObject *obj, bool subtree) { /* remove obj's record */ _doRemove(obj); } - + changed_signal.emit(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 53a666e25..e075feb91 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -835,7 +835,13 @@ void Script::checkStderr (const Glib::ustring &data, textview->set_wrap_mode(Gtk::WRAP_WORD); textview->show(); - textview->get_buffer()->set_text(data.c_str()); + // Remove the last character + char *errormsg = (char*) data.c_str(); + while (*errormsg != '\0') errormsg++; + errormsg -= 1; + *errormsg = '\0'; + + textview->get_buffer()->set_text(_(data.c_str())); Gtk::ScrolledWindow * scrollwindow = new Gtk::ScrolledWindow(); scrollwindow->add(*textview); diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index f34fea64a..143d72362 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -132,7 +132,7 @@ XSLT::unload(Inkscape::Extension::Extension *module) { if (!module->loaded()) { return; } xsltFreeStylesheet(_stylesheet); - xmlFreeDoc(_parsedDoc); + // No need to use xmlfreedoc(_parsedDoc), it's handled by xsltFreeStylesheet(_stylesheet); return; } diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 11e3a8d97..5dce0f9e3 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -26,11 +26,11 @@ namespace Extension { ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0.0), _min(0.0), _max(10.0) { - const char * defaultval = NULL; + const gchar * defaultval = NULL; if (sp_repr_children(xml) != NULL) defaultval = sp_repr_children(xml)->content(); if (defaultval != NULL) { - _value = atof(defaultval); + _value = g_ascii_strtod (defaultval,NULL); } const char * maxval = xml->attribute("max"); diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 9796fc5da..11de93d68 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -665,7 +665,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp s.setTransformation(s.getPoint() - p); sc.points.push_back(s); } else { - Inkscape::SnappedPoint dummy(p + *snap_vector, Inkscape::SNAPSOURCE_OTHER_HANDLE, 0, Inkscape::SNAPTARGET_CONSTRAINED_ANGLE, Geom::L2(*snap_vector), 10000, true, false); + Inkscape::SnappedPoint dummy(p + *snap_vector, Inkscape::SNAPSOURCE_OTHER_HANDLE, 0, Inkscape::SNAPTARGET_CONSTRAINED_ANGLE, Geom::L2(*snap_vector), 10000, true, true, false); dummy.setTransformation(*snap_vector); sc.points.push_back(dummy); } diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp index 9121e3ee2..4f70521e0 100644 --- a/src/guide-snapper.cpp +++ b/src/guide-snapper.cpp @@ -74,16 +74,16 @@ void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point sc.guide_lines.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const +void Inkscape::GuideSnapper::_addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { - SnappedPoint dummy = SnappedPoint(origin, source, source_num, Inkscape::SNAPTARGET_GUIDE_ORIGIN, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), true); + SnappedPoint dummy = SnappedPoint(origin, source, source_num, Inkscape::SNAPTARGET_GUIDE_ORIGIN, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); sc.points.push_back(dummy); } -void Inkscape::GuideSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const +void Inkscape::GuideSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const { - SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GUIDE, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), true); + SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GUIDE, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true); sc.points.push_back(dummy); } diff --git a/src/guide-snapper.h b/src/guide-snapper.h index 5adac6e22..5de1b56a4 100644 --- a/src/guide-snapper.h +++ b/src/guide-snapper.h @@ -35,8 +35,8 @@ public: private: LineList _getSnapLines(Geom::Point const &p) const; void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const; - void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const; - void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const; + void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; }; } diff --git a/src/helper/sp-marshal.list b/src/helper/sp-marshal.list index 15ddb1ec4..1dc4dd65c 100644 --- a/src/helper/sp-marshal.list +++ b/src/helper/sp-marshal.list @@ -1,14 +1,5 @@ # marshallers for sodipodi -NONE:NONE -NONE:UINT -NONE:POINTER -NONE:POINTER,BOOLEAN NONE:POINTER,UINT -NONE:POINTER,DOUBLE -NONE:DOUBLE,DOUBLE -NONE:STRING,BOOL -BOOLEAN:NONE -BOOLEAN:UINT BOOLEAN:POINTER BOOLEAN:POINTER,UINT BOOLEAN:POINTER,POINTER diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 61d6bb9c4..cfaf09901 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -4,9 +4,12 @@ * Setting GtkEntryBox width in characters. * Passing a function for formatting cells. * Displaying a warning if text isn't in list. + * Setting names for GtkComboBoxEntry and GtkEntry (actionName_combobox, actionName_entry) + * to allow setting resources. * * Author(s): * Tavmjong Bah + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2010 Authors * @@ -34,7 +37,7 @@ static GtkWidget* create_tool_item( GtkAction* action ); static GtkWidget* create_menu_item( GtkAction* action ); // Internal -static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, gchar* target_text ); +static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ); // Callbacks static void combo_box_changed_cb( GtkComboBoxEntry* widget, gpointer data ); @@ -45,7 +48,8 @@ enum { PROP_MODEL = 1, PROP_COMBOBOX, PROP_ENTRY, - PROP_WIDTH, + PROP_ENTRY_WIDTH, + PROP_EXTRA_WIDTH, PROP_CELL_DATA_FUNC, PROP_POPUP }; @@ -86,8 +90,12 @@ static void ink_comboboxentry_action_set_property (GObject *object, guint proper action->entry = GTK_ENTRY( g_value_get_object( value )); break; - case PROP_WIDTH: - action->width = g_value_get_int( value ); + case PROP_ENTRY_WIDTH: + action->entry_width = g_value_get_int( value ); + break; + + case PROP_EXTRA_WIDTH: + action->extra_width = g_value_get_int( value ); break; case PROP_CELL_DATA_FUNC: @@ -122,8 +130,12 @@ static void ink_comboboxentry_action_get_property (GObject *object, guint proper g_value_set_object (value, action->entry); break; - case PROP_WIDTH: - g_value_set_int (value, action->width); + case PROP_ENTRY_WIDTH: + g_value_set_int (value, action->entry_width); + break; + + case PROP_EXTRA_WIDTH: + g_value_set_int (value, action->extra_width); break; case PROP_CELL_DATA_FUNC: @@ -141,7 +153,7 @@ static void ink_comboboxentry_action_get_property (GObject *object, guint proper static void ink_comboboxentry_action_connect_proxy (GtkAction *action, - GtkWidget *proxy) + GtkWidget *proxy) { /* Override any proxy properties. */ // if (GTK_IS_MENU_ITEM (proxy)) { @@ -171,72 +183,81 @@ static void ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass * ink_comboboxentry_action_parent_class = GTK_ACTION_CLASS(g_type_class_peek_parent (klass) ); g_object_class_install_property ( - gobject_class, - PROP_MODEL, - g_param_spec_object ("model", - "Tree Model", - "Tree Model", - GTK_TYPE_TREE_MODEL, - (GParamFlags)G_PARAM_READWRITE)); + gobject_class, + PROP_MODEL, + g_param_spec_object ("model", + "Tree Model", + "Tree Model", + GTK_TYPE_TREE_MODEL, + (GParamFlags)G_PARAM_READWRITE)); g_object_class_install_property ( - gobject_class, - PROP_COMBOBOX, - g_param_spec_object ("combobox", - "GtkComboBoxEntry", - "GtkComboBoxEntry", - GTK_TYPE_WIDGET, - (GParamFlags)G_PARAM_READABLE)); + gobject_class, + PROP_COMBOBOX, + g_param_spec_object ("combobox", + "GtkComboBoxEntry", + "GtkComboBoxEntry", + GTK_TYPE_WIDGET, + (GParamFlags)G_PARAM_READABLE)); g_object_class_install_property ( - gobject_class, - PROP_ENTRY, - g_param_spec_object ("entry", - "GtkEntry", - "GtkEntry", - GTK_TYPE_WIDGET, - (GParamFlags)G_PARAM_READABLE)); + gobject_class, + PROP_ENTRY, + g_param_spec_object ("entry", + "GtkEntry", + "GtkEntry", + GTK_TYPE_WIDGET, + (GParamFlags)G_PARAM_READABLE)); g_object_class_install_property ( - gobject_class, - PROP_WIDTH, - g_param_spec_int ("width", - "EntryBox width", - "EntryBox width (characters)", - -1.0, 100, -1.0, - (GParamFlags)G_PARAM_READWRITE)); + gobject_class, + PROP_ENTRY_WIDTH, + g_param_spec_int ("entry_width", + "EntryBox width", + "EntryBox width (characters)", + -1.0, 100, -1.0, + (GParamFlags)G_PARAM_READWRITE)); g_object_class_install_property ( - gobject_class, - PROP_CELL_DATA_FUNC, - g_param_spec_pointer ("cell_data_func", - "Cell Data Func", - "Cell Deta Function", - (GParamFlags)G_PARAM_READWRITE)); + gobject_class, + PROP_EXTRA_WIDTH, + g_param_spec_int ("extra_width", + "Extra width", + "Extra width (px)", + -1.0, 500, -1.0, + (GParamFlags)G_PARAM_READWRITE)); g_object_class_install_property ( - gobject_class, - PROP_POPUP, - g_param_spec_boolean ("popup", - "Entry Popup", - "Entry Popup", - false, - (GParamFlags)G_PARAM_READWRITE)); + gobject_class, + PROP_CELL_DATA_FUNC, + g_param_spec_pointer ("cell_data_func", + "Cell Data Func", + "Cell Deta Function", + (GParamFlags)G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_POPUP, + g_param_spec_boolean ("popup", + "Entry Popup", + "Entry Popup", + false, + (GParamFlags)G_PARAM_READWRITE)); // We need to know when GtkComboBoxEvent or Menu ready for reading signals[CHANGED] = g_signal_new( "changed", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(Ink_ComboBoxEntry_ActionClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(Ink_ComboBoxEntry_ActionClass, changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); // Probably not needed... originally to keep track of key-presses. signals[ACTIVATED] = g_signal_new( "activated", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(Ink_ComboBoxEntry_ActionClass, activated), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(Ink_ComboBoxEntry_ActionClass, activated), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } @@ -245,8 +266,12 @@ static void ink_comboboxentry_action_init (Ink_ComboBoxEntry_Action *action) action->active = -1; action->text = NULL; action->entry_completion = NULL; +#if !GTK_CHECK_VERSION(2,16,0) + action->indicator = NULL; +#endif action->popup = false; action->warning = NULL; + action->altx_name = NULL; } GType ink_comboboxentry_action_get_type () @@ -268,9 +293,9 @@ GType ink_comboboxentry_action_get_type () }; ink_comboboxentry_action_type = g_type_register_static (GTK_TYPE_ACTION, - "Ink_ComboBoxEntry_Action", - &ink_comboboxentry_action_info, - (GTypeFlags)0 ); + "Ink_ComboBoxEntry_Action", + &ink_comboboxentry_action_info, + (GTypeFlags)0 ); } return ink_comboboxentry_action_type; @@ -278,24 +303,26 @@ GType ink_comboboxentry_action_get_type () Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_id, - GtkTreeModel *model, - gint width, - void *cell_data_func ) + const gchar *label, + const gchar *tooltip, + const gchar *stock_id, + GtkTreeModel *model, + gint entry_width, + gint extra_width, + void *cell_data_func ) { g_return_val_if_fail (name != NULL, NULL); return (Ink_ComboBoxEntry_Action*)g_object_new (INK_COMBOBOXENTRY_TYPE_ACTION, - "name", name, - "label", label, - "tooltip", tooltip, - "stock-id", stock_id, - "model", model, - "width", width, - "cell_data_func", cell_data_func, - NULL); + "name", name, + "label", label, + "tooltip", tooltip, + "stock-id", stock_id, + "model", model, + "entry_width", entry_width, + "extra_width", extra_width, + "cell_data_func", cell_data_func, + NULL); } // Create a widget for a toolbar. @@ -307,11 +334,31 @@ GtkWidget* create_tool_item( GtkAction* action ) Ink_ComboBoxEntry_Action* ink_comboboxentry_action = INK_COMBOBOXENTRY_ACTION( action ); + gchar *action_name = g_strdup( gtk_action_get_name( action ) ); + gchar *combobox_name = g_strjoin( NULL, action_name, "_combobox", NULL ); + gchar *entry_name = g_strjoin( NULL, action_name, "_entry", NULL ); + g_free( action_name ); + item = GTK_WIDGET( gtk_tool_item_new() ); GtkWidget* comboBoxEntry = gtk_combo_box_entry_new_with_model( ink_comboboxentry_action->model, 0 ); - - gtk_container_add( GTK_CONTAINER(item), comboBoxEntry ); + // Name it so we can muck with it using an RC file + gtk_widget_set_name( comboBoxEntry, combobox_name ); + g_free( combobox_name ); + + { + GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); +#if GTK_CHECK_VERSION(2,16,0) + gtk_container_add( GTK_CONTAINER(align), comboBoxEntry ); +#else // GTK_CHECK_VERSION(2,16,0) + GtkWidget *hbox = gtk_hbox_new( FALSE, 0 ); + ink_comboboxentry_action->indicator = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_box_pack_start( GTK_BOX(hbox), comboBoxEntry, TRUE, TRUE, 0 ); + gtk_box_pack_start( GTK_BOX(hbox), ink_comboboxentry_action->indicator, FALSE, FALSE, 0 ); + gtk_container_add( GTK_CONTAINER(align), hbox ); +#endif // GTK_CHECK_VERSION(2,16,0) + gtk_container_add( GTK_CONTAINER(item), align ); + } ink_comboboxentry_action->combobox = GTK_COMBO_BOX_ENTRY(comboBoxEntry); @@ -325,23 +372,42 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_cell_layout_clear( GTK_CELL_LAYOUT( comboBoxEntry ) ); gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( comboBoxEntry ), cell, true ); gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT( comboBoxEntry ), cell, - GtkCellLayoutDataFunc (ink_comboboxentry_action->cell_data_func), - NULL, NULL ); + GtkCellLayoutDataFunc (ink_comboboxentry_action->cell_data_func), + NULL, NULL ); + } + + // Optionally widen the combobox width... which widens the drop-down list in list mode. + if( ink_comboboxentry_action->extra_width > 0 ) { + GtkRequisition req; + gtk_widget_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), &req ); + gtk_widget_set_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), + req.width + ink_comboboxentry_action->extra_width, -1 ); } // Get reference to GtkEntry and fiddle a bit with it. GtkWidget *child = gtk_bin_get_child( GTK_BIN(comboBoxEntry) ); + + // Name it so we can muck with it using an RC file + gtk_widget_set_name( child, entry_name ); + g_free( entry_name ); + if( child && GTK_IS_ENTRY( child ) ) { + ink_comboboxentry_action->entry = GTK_ENTRY(child); // Change width - if( ink_comboboxentry_action->width > 0 ) { - gtk_entry_set_width_chars (GTK_ENTRY (child), ink_comboboxentry_action->width ); + if( ink_comboboxentry_action->entry_width > 0 ) { + gtk_entry_set_width_chars (GTK_ENTRY (child), ink_comboboxentry_action->entry_width ); } // Add pop-up entry completion if required if( ink_comboboxentry_action->popup ) { - ink_comboboxentry_action_popup_enable( ink_comboboxentry_action ); + ink_comboboxentry_action_popup_enable( ink_comboboxentry_action ); + } + + // Add altx_name if required + if( ink_comboboxentry_action->altx_name ) { + g_object_set_data( G_OBJECT( child ), ink_comboboxentry_action->altx_name, ink_comboboxentry_action->entry ); } // Add signal for GtkEntry to check if finished typing. @@ -349,8 +415,10 @@ GtkWidget* create_tool_item( GtkAction* action ) } +#if GTK_CHECK_VERSION(2,16,0) gtk_action_connect_proxy( GTK_ACTION( action ), item ); - +#endif + gtk_widget_show_all( item ); } else { @@ -358,7 +426,7 @@ GtkWidget* create_tool_item( GtkAction* action ) item = ink_comboboxentry_action_parent_class->create_tool_item( action ); } - + return item; } @@ -369,7 +437,7 @@ GtkWidget* create_menu_item( GtkAction* action ) item = ink_comboboxentry_action_parent_class->create_menu_item( action ); g_warning( "ink_comboboxentry_action: create_menu_item not implemented" ); - // One can easily modify ege-select-one-action routine to implement this. + // One can easily modify ege-select-one-action routine to implement this. return item; } @@ -391,7 +459,7 @@ gchar* ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* actio return text; } -gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink_comboboxentry_action, gchar* text ) { +gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink_comboboxentry_action, const gchar* text ) { g_free( ink_comboboxentry_action->text ); ink_comboboxentry_action->text = g_strdup( text ); @@ -412,18 +480,27 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink // Show or hide warning if( ink_comboboxentry_action->active == -1 && ink_comboboxentry_action->warning != NULL ) { +#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_icon_name( ink_comboboxentry_action->entry, - GTK_ENTRY_ICON_SECONDARY, - GTK_STOCK_DIALOG_WARNING ); + GTK_ENTRY_ICON_SECONDARY, + GTK_STOCK_DIALOG_WARNING ); // Can't add tooltip until icon set gtk_entry_set_icon_tooltip_text( ink_comboboxentry_action->entry, - GTK_ENTRY_ICON_SECONDARY, - ink_comboboxentry_action->warning ); - + GTK_ENTRY_ICON_SECONDARY, + ink_comboboxentry_action->warning ); +#else // GTK_CHECK_VERSION(2,16,0) + gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, ink_comboboxentry_action->warning ); +#endif // GTK_CHECK_VERSION(2,16,0) } else { +#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_icon_name( GTK_ENTRY(ink_comboboxentry_action->entry), - GTK_ENTRY_ICON_SECONDARY, - NULL ); + GTK_ENTRY_ICON_SECONDARY, + NULL ); +#else // GTK_CHECK_VERSION(2,16,0) + gtk_image_set_from_stock( GTK_IMAGE(ink_comboboxentry_action->indicator), NULL, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_tooltip_text( ink_comboboxentry_action->indicator, NULL ); +#endif // GTK_CHECK_VERSION(2,16,0) } } @@ -432,13 +509,25 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink return found; } -void ink_comboboxentry_action_set_width( Ink_ComboBoxEntry_Action* action, gint width ) { +void ink_comboboxentry_action_set_entry_width( Ink_ComboBoxEntry_Action* action, gint entry_width ) { - action->width = width; + action->entry_width = entry_width; // Widget may not have been created.... if( action->entry ) { - gtk_entry_set_width_chars( GTK_ENTRY(action->entry), width ); + gtk_entry_set_width_chars( GTK_ENTRY(action->entry), entry_width ); + } +} + +void ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action, gint extra_width ) { + + action->extra_width = extra_width; + + // Widget may not have been created.... + if( action->combobox ) { + GtkRequisition req; + gtk_widget_size_request( GTK_WIDGET( action->combobox ), &req ); + gtk_widget_set_size_request( GTK_WIDGET( action->combobox ), req.width + action->extra_width, -1 ); } } @@ -472,26 +561,42 @@ void ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action ) if( action->entry_completion ) { gtk_object_destroy( GTK_OBJECT( action->entry_completion ) ); + action->entry_completion = 0; } } -void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, gchar* warning ) { +void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning ) { g_free( action->warning ); action->warning = g_strdup( warning ); // Widget may not have been created.... if( action->entry ) { +#if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_tooltip_text( GTK_ENTRY(action->entry), - GTK_ENTRY_ICON_SECONDARY, - action->warning ); + GTK_ENTRY_ICON_SECONDARY, + action->warning ); +#else // GTK_CHECK_VERSION(2,16,0) + gtk_image_set_from_stock( GTK_IMAGE(action->indicator), action->warning ? GTK_STOCK_DIALOG_WARNING : 0, GTK_ICON_SIZE_SMALL_TOOLBAR ); +#endif // GTK_CHECK_VERSION(2,16,0) + } +} + +void ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* action, const gchar* altx_name ) { + + g_free( action->altx_name ); + action->altx_name = g_strdup( altx_name ); + + // Widget may not have been created.... + if( action->entry ) { + g_object_set_data( G_OBJECT(action->entry), action->altx_name, action->entry ); } } // Internal --------------------------------------------------- // Return row of active text or -1 if not found. -gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, gchar* target_text ) { +gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ) { // Check if text in list gint row = 0; @@ -571,7 +676,7 @@ static void entry_activate_cb( GtkEntry* widget, gpointer data ) { } -static gboolean match_selected_cb( GtkEntryCompletion* widget, GtkTreeModel* model, GtkTreeIter* iter, gpointer data ) +static gboolean match_selected_cb( GtkEntryCompletion* /*widget*/, GtkTreeModel* model, GtkTreeIter* iter, gpointer data ) { // Get action Ink_ComboBoxEntry_Action *ink_comboboxentry_action = INK_COMBOBOXENTRY_ACTION( data ); @@ -583,7 +688,7 @@ static gboolean match_selected_cb( GtkEntryCompletion* widget, GtkTreeModel* mod // Set text in GtkEntry gtk_entry_set_text (GTK_ENTRY (entry), family ); - + // Set text in GtkAction g_free( ink_comboboxentry_action->text ); ink_comboboxentry_action->text = family; diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index 433eb2fdc..e080e6cdf 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -4,9 +4,12 @@ * Setting GtkEntryBox width in characters. * Passing a function for formatting cells. * Displaying a warning if text isn't in list. + * Setting names for GtkComboBoxEntry and GtkEntry (actionName_combobox, actionName_entry) + * to allow setting resources. * * Author(s): * Tavmjong Bah + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2010 Authors * @@ -46,14 +49,19 @@ struct _Ink_ComboBoxEntry_Action { GtkComboBoxEntry *combobox; GtkEntry *entry; GtkEntryCompletion *entry_completion; +#if !GTK_CHECK_VERSION(2,16,0) + GtkWidget *indicator; +#endif gpointer cell_data_func; // drop-down menu format - gint active; // Index of active menu item (-1 if not in list). - gchar *text; // Text of active menu item or entry box. - gint width; // Width of GtkComboBoxEntry in characters. - gboolean popup; // Do we pop-up an entry-completion dialog? - gchar *warning; // Text for warning that entry isn't in list. + gint active; // Index of active menu item (-1 if not in list). + gchar *text; // Text of active menu item or entry box. + gint entry_width;// Width of GtkEntry in characters. + gint extra_width;// Extra Width of GtkComboBox.. to widen drop-down list in list mode. + gboolean popup; // Do we pop-up an entry-completion dialog? + gchar *warning; // Text for warning that entry isn't in list. + gchar *altx_name; // Target for Alt-X keyboard shortcut. }; @@ -61,26 +69,30 @@ GType ink_comboboxentry_action_get_type (void); /** * Creates a GtkAction subclass that wraps a GtkComboBoxEntry object. - */ + */ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar *name, const gchar *label, const gchar *tooltip, const gchar *stock_id, GtkTreeModel *model, - gint width = -1, + gint entry_width = -1, + gint extra_width = -1, gpointer cell_data_func = NULL ); GtkTreeModel *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action ); GtkComboBoxEntry *ink_comboboxentry_action_get_comboboxentry( Ink_ComboBoxEntry_Action* action ); gchar* ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* action ); -gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, gchar* text ); +gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text ); -void ink_comboboxentry_action_set_width( Ink_ComboBoxEntry_Action* action, gint width ); +void ink_comboboxentry_action_set_entry_width( Ink_ComboBoxEntry_Action* action, gint entry_width ); +void ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action, gint extra_width ); void ink_comboboxentry_action_popup_enable( Ink_ComboBoxEntry_Action* action ); void ink_comboboxentry_action_popup_disable( Ink_ComboBoxEntry_Action* action ); -void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, gchar* warning ); +void ink_comboboxentry_action_set_warning( Ink_ComboBoxEntry_Action* action, const gchar* warning ); + +void ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* action, const gchar* altx_name ); #endif /* SEEN_INK_COMBOBOXENTRY_ACTION */ diff --git a/src/inkscape.cpp b/src/inkscape.cpp index d0f9a11fc..d876be6ec 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -56,7 +56,7 @@ using Inkscape::Extension::Internal::PrintWin32; #include "extension/init.h" #include "extension/output.h" #include "extension/system.h" -#include "helper/sp-marshal.h" +//#include "helper/sp-marshal.h" #include "inkscape-private.h" #include "io/sys.h" #include "message-stack.h" @@ -193,7 +193,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, modify_selection), NULL, NULL, - sp_marshal_NONE__POINTER_UINT, + g_cclosure_marshal_VOID__UINT_POINTER, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT); inkscape_signals[CHANGE_SELECTION] = g_signal_new ("change_selection", @@ -201,7 +201,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, change_selection), NULL, NULL, - sp_marshal_NONE__POINTER, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); inkscape_signals[CHANGE_SUBSELECTION] = g_signal_new ("change_subselection", @@ -209,7 +209,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, change_subselection), NULL, NULL, - sp_marshal_NONE__POINTER, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); inkscape_signals[SET_SELECTION] = g_signal_new ("set_selection", @@ -217,7 +217,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, set_selection), NULL, NULL, - sp_marshal_NONE__POINTER, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); inkscape_signals[SET_EVENTCONTEXT] = g_signal_new ("set_eventcontext", @@ -225,7 +225,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, set_eventcontext), NULL, NULL, - sp_marshal_NONE__POINTER, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); inkscape_signals[ACTIVATE_DESKTOP] = g_signal_new ("activate_desktop", @@ -233,7 +233,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, activate_desktop), NULL, NULL, - sp_marshal_NONE__POINTER, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); inkscape_signals[DEACTIVATE_DESKTOP] = g_signal_new ("deactivate_desktop", @@ -241,7 +241,7 @@ inkscape_class_init (Inkscape::ApplicationClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (Inkscape::ApplicationClass, deactivate_desktop), NULL, NULL, - sp_marshal_NONE__POINTER, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); inkscape_signals[SHUTDOWN_SIGNAL] = g_signal_new ("shut_down", diff --git a/src/knot.cpp b/src/knot.cpp index 04520ed22..10672e048 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -116,7 +116,7 @@ static void sp_knot_class_init(SPKnotClass *klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(SPKnotClass, clicked), NULL, NULL, - sp_marshal_NONE__UINT, + g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); @@ -125,7 +125,7 @@ static void sp_knot_class_init(SPKnotClass *klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(SPKnotClass, doubleclicked), NULL, NULL, - sp_marshal_NONE__UINT, + g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); @@ -134,7 +134,7 @@ static void sp_knot_class_init(SPKnotClass *klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(SPKnotClass, grabbed), NULL, NULL, - sp_marshal_NONE__UINT, + g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); @@ -143,7 +143,7 @@ static void sp_knot_class_init(SPKnotClass *klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(SPKnotClass, ungrabbed), NULL, NULL, - sp_marshal_NONE__UINT, + g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index 8c45c7e53..db7384622 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -142,6 +142,7 @@ LayerManager::~LayerManager() _layer_connection.disconnect(); _document_connection.disconnect(); _resource_connection.disconnect(); + _document = 0; } void LayerManager::setCurrentLayer( SPObject* obj ) @@ -315,7 +316,7 @@ void LayerManager::_rebuild() { LayerWatcher *eye = new LayerWatcher(this, layer, connection); _watchers.push_back( eye ); SP_OBJECT_REPR(layer)->addObserver(*eye); - + _addOne(layer); } } diff --git a/src/layer-manager.h b/src/layer-manager.h index 81f75e002..5b5d25eb2 100644 --- a/src/layer-manager.h +++ b/src/layer-manager.h @@ -32,11 +32,11 @@ public: void renameLayer( SPObject* obj, gchar const *label, bool uniquify ); sigc::connection connectCurrentLayerChanged(const sigc::slot<void, SPObject *> & slot) { - return _layer_changed_signal.connect(slot); + return _layer_changed_signal.connect(slot); } sigc::connection connectLayerDetailsChanged(const sigc::slot<void, SPObject *> & slot) { - return _details_changed_signal.connect(slot); + return _details_changed_signal.connect(slot); } private: diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index f2f025332..fc40643c8 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -50,7 +50,7 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc, // discern between grids and guides here Geom::Coord const dist_p1 = Geom::L2(p1 - p.getPoint()); if (dist_p1 < getSnapperTolerance()) { - _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum()); + _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum(), false); // Only relevant for guides; grids don't have an origin per line // Therefore _addSnappedLinesOrigin() will only be implemented for guides } @@ -104,13 +104,13 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, // This snappoint is therefore fully constrained, so there's no need // to look for additional intersections; just return the snapped point // and forget about the line - _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum()); + _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true); // For any line that's within range, we will also look at it's "point on line" p1. For guides // this point coincides with its origin; for grids this is of no use, but we cannot // discern between grids and guides here Geom::Coord const dist_p1 = Geom::L2(p1 - p.getPoint()); if (dist_p1 < getSnapperTolerance()) { - _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum()); + _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum(), true); // Only relevant for guides; grids don't have an origin per line // Therefore _addSnappedLinesOrigin() will only be implemented for guides } @@ -122,7 +122,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc, // Will only be overridden in the guide-snapper class, because grid lines don't have an origin; the // grid-snapper classes will use this default empty method -void Inkscape::LineSnapper::_addSnappedLinesOrigin(SnappedConstraints &/*sc*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/) const +void Inkscape::LineSnapper::_addSnappedLinesOrigin(SnappedConstraints &/*sc*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const { } diff --git a/src/line-snapper.h b/src/line-snapper.h index 429139421..1aa3526cc 100644 --- a/src/line-snapper.h +++ b/src/line-snapper.h @@ -52,9 +52,9 @@ private: virtual void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const = 0; // Will only be implemented for guide lines, because grid lines don't have an origin - virtual void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const; + virtual void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; - virtual void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const = 0; + virtual void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; }; } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 77449ddc3..536affb82 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -265,7 +265,7 @@ void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc, for (std::vector<SnapCandidatePoint>::const_iterator k = _points_to_snap_to->begin(); k != _points_to_snap_to->end(); k++) { Geom::Coord dist = Geom::L2((*k).getPoint() - p.getPoint()); if (dist < getSnapperTolerance() && dist < s.getSnapDistance()) { - s = SnappedPoint((*k).getPoint(), p.getSourceType(), p.getSourceNum(), (*k).getTargetType(), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, (*k).getTargetBBox()); + s = SnappedPoint((*k).getPoint(), p.getSourceType(), p.getSourceNum(), (*k).getTargetType(), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox()); success = true; } } @@ -299,7 +299,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s Geom::Coord dist = Geom::L2((*k).getPoint() - p_proj); // distance from node to the guide Geom::Coord dist2 = Geom::L2(p - p_proj); // distance from projection of node on the guide, to the mouse location if ((dist < tol && dist2 < tol) || getSnapperAlwaysSnap()) { - s = SnappedPoint((*k).getPoint(), SNAPSOURCE_GUIDE, 0, (*k).getTargetType(), dist, tol, getSnapperAlwaysSnap(), true, (*k).getTargetBBox()); + s = SnappedPoint((*k).getPoint(), SNAPSOURCE_GUIDE, 0, (*k).getTargetType(), dist, tol, getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox()); sc.points.push_back(s); } } diff --git a/src/snap.cpp b/src/snap.cpp index 8704ce3bb..c47f93ff1 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -201,7 +201,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapCandidatePoint const Geom::OptRect const &bbox_to_snap) const { if (!someSnapperMightSnap()) { - return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false); + return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false); } SnappedConstraints sc; @@ -365,7 +365,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint // First project the mouse pointer onto the constraint Geom::Point pp = constraint.projection(p.getPoint()); - Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::L2(pp - p.getPoint()), 0, false, false); + Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::L2(pp - p.getPoint()), 0, false, true, false); if (!someSnapperMightSnap()) { // Always return point on constraint @@ -648,7 +648,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( // the origin of the scaling, then it will scale purely in X or Y // We can therefore only calculate the scaling in this direction // and the scaling factor for the other direction should remain - // untouched (unless scaling is uniform ofcourse) + // untouched (unless scaling is uniform of course) for (int index = 0; index < 2; index++) { if (fabs(b[index]) > 1e-6) { // if SCALING CAN occur in this direction if (fabs(fabs(a[index]/b[index]) - fabs(transformation[index])) > 1e-12) { // if SNAPPING DID occur in this direction @@ -697,9 +697,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( g_assert_not_reached(); } - // When scaling, we're considering the best transformation in each direction separately. We will have a metric in each - // direction, whereas for all other transformation we only a single one-dimensional metric. That's why we need to handle - // the scaling metric differently if (best_snapped_point.isOtherSnapBetter(snapped_point, true)) { best_transformation = result; best_snapped_point = snapped_point; diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index d4ef0a83f..e7df3cfad 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -87,12 +87,12 @@ Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &cur // TODO: Investigate whether it is possible to use document coordinates everywhere // in the snapper code. Only the mouse position should be in desktop coordinates, I guess. // All paths are already in document coords and we are certainly not going to change THAT. - return SnappedPoint(best_p, Inkscape::SNAPSOURCE_UNDEFINED, primaryC->getSourceNum(), Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryDist, primaryC->getTolerance(), primaryC->getAlwaysSnap(), true, true, + return SnappedPoint(best_p, Inkscape::SNAPSOURCE_UNDEFINED, primaryC->getSourceNum(), Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryDist, primaryC->getTolerance(), primaryC->getAlwaysSnap(), true, false, true, secondaryDist, secondaryC->getTolerance(), secondaryC->getAlwaysSnap()); } // No intersection - return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false); + return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, false, NR_HUGE, 0, false); } // search for the closest snapped line diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index 9dde22a4e..da17ff81a 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -80,12 +80,12 @@ Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegmen Inkscape::SnappedLineSegment const *secondarySLS = use_this_as_primary ? &line : this; Geom::Coord primaryDist = use_this_as_primary ? Geom::L2(inters_pt - this->getPoint()) : Geom::L2(inters_pt - line.getPoint()); Geom::Coord secondaryDist = use_this_as_primary ? Geom::L2(inters_pt - line.getPoint()) : Geom::L2(inters_pt - this->getPoint()); - return SnappedPoint(inters_pt, SNAPSOURCE_UNDEFINED, primarySLS->getSourceNum(), SNAPTARGET_PATH_INTERSECTION, primaryDist, primarySLS->getTolerance(), primarySLS->getAlwaysSnap(), true, true, + return SnappedPoint(inters_pt, SNAPSOURCE_UNDEFINED, primarySLS->getSourceNum(), SNAPTARGET_PATH_INTERSECTION, primaryDist, primarySLS->getTolerance(), primarySLS->getAlwaysSnap(), true, false, true, secondaryDist, secondarySLS->getTolerance(), secondarySLS->getAlwaysSnap()); } // No intersection - return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false); + return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, false, NR_HUGE, 0, false); }; @@ -161,14 +161,14 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) Inkscape::SnappedLine const *secondarySL = use_this_as_primary ? &line : this; Geom::Coord primaryDist = use_this_as_primary ? Geom::L2(inters_pt - this->getPoint()) : Geom::L2(inters_pt - line.getPoint()); Geom::Coord secondaryDist = use_this_as_primary ? Geom::L2(inters_pt - line.getPoint()) : Geom::L2(inters_pt - this->getPoint()); - return SnappedPoint(inters_pt, Inkscape::SNAPSOURCE_UNDEFINED, primarySL->getSourceNum(), Inkscape::SNAPTARGET_UNDEFINED, primaryDist, primarySL->getTolerance(), primarySL->getAlwaysSnap(), true, true, + return SnappedPoint(inters_pt, Inkscape::SNAPSOURCE_UNDEFINED, primarySL->getSourceNum(), Inkscape::SNAPTARGET_UNDEFINED, primaryDist, primarySL->getTolerance(), primarySL->getAlwaysSnap(), true, false, true, secondaryDist, secondarySL->getTolerance(), secondarySL->getAlwaysSnap()); // The type of the snap target is yet undefined, as we cannot tell whether // we're snapping to grid or the guide lines; must be set by on a higher level } // No intersection - return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, NR_HUGE, 0, false); + return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPSOURCE_UNDEFINED, 0, SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, false, false, NR_HUGE, 0, false); } // search for the closest snapped line segment diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp index 508ec8f62..352f2dd1e 100644 --- a/src/snapped-point.cpp +++ b/src/snapped-point.cpp @@ -14,11 +14,12 @@ #include "preferences.h" // overloaded constructor -Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &fully_constrained, Geom::OptRect target_bbox) +Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained, Geom::OptRect target_bbox) : _point(p), _source(source), _source_num(source_num), _target(target), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a), _target_bbox(target_bbox) { // tolerance should never be smaller than 1 px, as it is used for normalization in isOtherSnapBetter. We don't want a division by zero. _at_intersection = false; + _constrained_snap = constrained_snap; _fully_constrained = fully_constrained; _second_distance = NR_HUGE; _second_tolerance = 1; @@ -27,13 +28,14 @@ Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const _pointer_distance = NR_HUGE; } -Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &fully_constrained) +Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained) : _target(target), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a) { _point = p.getPoint(); _source = p.getSourceType(); _source_num = p.getSourceNum(); _at_intersection = false; + _constrained_snap = constrained_snap; _fully_constrained = fully_constrained; _second_distance = NR_HUGE; _second_tolerance = 1; @@ -44,8 +46,8 @@ Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, Snap } -Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2) - : _point(p), _source(source), _source_num(source_num), _target(target), _at_intersection(at_intersection), _fully_constrained(fully_constrained), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a), +Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &constrained_snap, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2) + : _point(p), _source(source), _source_num(source_num), _target(target), _at_intersection(at_intersection), _constrained_snap(constrained_snap), _fully_constrained(fully_constrained), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a), _second_distance(d2), _second_tolerance(std::max(t2,1.0)), _second_always_snap(a2) { // tolerance should never be smaller than 1 px, as it is used for normalization in @@ -62,6 +64,7 @@ Inkscape::SnappedPoint::SnappedPoint() _source_num = 0, _target = SNAPTARGET_UNDEFINED, _at_intersection = false; + _constrained_snap = false; _fully_constrained = false; _distance = NR_HUGE; _tolerance = 1; @@ -155,7 +158,8 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth // however be very large. To compare these in a fair way, we will have to normalize these metrics first // The closest pointer distance will be normalized to 1.0; the other one will be > 1.0 // The snap distance will be normalized to 1.0 if it's equal to the snapper tolerance - double const norm_p = std::min(dist_pointer_this, dist_pointer_other); + double const norm_p = std::min(dist_pointer_this, dist_pointer_other) + 1; + // make sure norm_p is never too close to zero (e.g. when snapping the bbox-corner that was grabbed), by incr. with 1 double const norm_t_other = std::min(50.0, other_one.getTolerance()); double const norm_t_this = std::min(50.0, getTolerance()); dist_other = w * dist_pointer_other / norm_p + (1-w) * dist_other / norm_t_other; @@ -180,9 +184,9 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth // But in no case fall back from a snapper with "always snap" on to one with "always snap" off bool c2n = !other_one.getAlwaysSnap() && getAlwaysSnap(); // or, if we have a fully constrained snappoint (e.g. to a node or an intersection), while the previous one was only partly constrained (e.g. to a line) - bool c3 = other_one.getFullyConstrained() && !getFullyConstrained(); + bool c3 = (other_one.getFullyConstrained() && !other_one.getConstrainedSnap()) && !getFullyConstrained(); // Do not consider constrained snaps here, because these will always be fully constrained anyway // But in no case fall back; (has less priority than c3n, so it is allowed to fall back when c3 is true, see below) - bool c3n = !other_one.getFullyConstrained() && getFullyConstrained(); + bool c3n = !other_one.getFullyConstrained() && (getFullyConstrained() && !getConstrainedSnap()); // When both are fully constrained AND coincident, then prefer nodes over intersections bool d = other_one.getFullyConstrained() && getFullyConstrained() && (Geom::L2(other_one.getPoint() - getPoint()) < 1e-9); @@ -192,7 +196,7 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth // or, if it's just as close then consider the second distance bool c5a = (dist_other == dist_this); - bool c5b = other_one.getSecondSnapDistance() < getSecondSnapDistance(); + bool c5b = (other_one.getSecondSnapDistance() < getSecondSnapDistance()) && (getSecondSnapDistance() < NR_HUGE); // std::cout << other_one.getPoint() << " (Other one, dist = " << dist_other << ") vs. " << getPoint() << " (this one, dist = " << dist_this << ") ---> "; // std::cout << "c1 = " << c1 << " | c2 = " << c2 << " | c2n = " << c2n << " | c3 = " << c3 << " | c3n = " << c3n << " | c4 = " << c4 << " | c4n = " << c4n << " | c5a = " << c5a << " | c5b = " << c5b << std::endl; diff --git a/src/snapped-point.h b/src/snapped-point.h index 10d36f57e..05e954e1e 100644 --- a/src/snapped-point.h +++ b/src/snapped-point.h @@ -28,9 +28,9 @@ class SnappedPoint public: SnappedPoint(); SnappedPoint(Geom::Point const &p); - SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2); - SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &fully_constrained, Geom::OptRect target_bbox = Geom::OptRect()); - SnappedPoint(SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &fully_constrained); + SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &constrained_snap, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2); + SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained, Geom::OptRect target_bbox = Geom::OptRect()); + SnappedPoint(SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained); ~SnappedPoint(); Geom::Coord getSnapDistance() const {return _distance;} @@ -61,6 +61,7 @@ public: bool getAtIntersection() const {return _at_intersection;} bool getFullyConstrained() const {return _fully_constrained;} + bool getConstrainedSnap() const {return _constrained_snap;} bool getSnapped() const {return _distance < NR_HUGE;} Geom::Point getTransformation() const {return _transformation;} void setTransformation(Geom::Point const t) {_transformation = t;} @@ -97,6 +98,7 @@ protected: long _source_num; // Sequence number of the source point that snapped, if that point is part of a set of points. (starting at zero) SnapTargetType _target; // Describes to what we've snapped to bool _at_intersection; // If true, the snapped point is at an intersection + bool _constrained_snap; // If true, then the snapped point was found when looking for a constrained snap bool _fully_constrained; // When snapping for example to a node, then the snap will be "fully constrained". // When snapping to a line however, the snap is only partly constrained (i.e. only in one dimension) diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 7962390c2..9cd38e4b3 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -288,7 +288,14 @@ sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, uns * Geom::Translate(use->x.computed, use->y.computed) * transform ); - sp_item_invoke_bbox_full(child, bbox, ct, flags, FALSE); + Geom::OptRect optbbox; + sp_item_invoke_bbox_full(child, optbbox, ct, flags, FALSE); + if (optbbox) { + bbox->x0 = (*optbbox)[0][0]; + bbox->y0 = (*optbbox)[1][0]; + bbox->x1 = (*optbbox)[0][1]; + bbox->y1 = (*optbbox)[1][1]; + } } } diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index a210fe163..9a46254ab 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -7,7 +7,7 @@ * Other dudes from The Inkscape Organization * * Copyright (C) 2004 Bob Jamison - * Copyright (C) 2005 Jon A. Cruz + * Copyright (C) 2005,2010 Jon A. Cruz * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -18,6 +18,7 @@ #include <gtk/gtk.h> #include <glib/gmem.h> #include <glibmm/i18n.h> +#include <gtkmm/alignment.h> #include <gtkmm/buttonbox.h> #include <gtkmm/stock.h> @@ -42,7 +43,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, namespace Inkscape { namespace UI { -namespace Dialogs { +namespace Dialog { IconPreviewPanel &IconPreviewPanel::getInstance() @@ -80,9 +81,17 @@ void IconPreviewPanel::on_button_clicked(int which) */ IconPreviewPanel::IconPreviewPanel() : UI::Widget::Panel("", "/dialogs/iconpreview", SP_VERB_VIEW_ICON_PREVIEW), + deskTrack(), + desktop(0), + document(0), + timer(0), + pending(false), hot(1), - refreshButton(0), - selectionButton(0) + selectionButton(0), + desktopChangeConn(), + docReplacedConn(), + docModConn(), + selChangedConn() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); numEntries = 0; @@ -138,12 +147,18 @@ IconPreviewPanel::IconPreviewPanel() : Gtk::VBox* magBox = new Gtk::VBox(); - magBox->pack_start( magnified ); + Gtk::Frame *magFrame = Gtk::manage(new Gtk::Frame(_("Magnified:"))); + magFrame->add( magnified ); + + magBox->pack_start( *magFrame, Gtk::PACK_EXPAND_WIDGET ); magBox->pack_start( magLabel, Gtk::PACK_SHRINK ); - Gtk::VBox * verts = new Gtk::VBox(); - for ( int i = 0; i < numEntries; i++ ) { + Gtk::VBox *verts = new Gtk::VBox(); + Gtk::HBox *horiz = 0; + int previous = 0; + int avail = 0; + for ( int i = numEntries - 1; i >= 0; --i ) { pixMem[i] = new guchar[4 * sizes[i] * sizes[i]]; memset( pixMem[i], 0x00, 4 * sizes[i] * sizes[i] ); @@ -153,44 +168,86 @@ IconPreviewPanel::IconPreviewPanel() : Glib::ustring label(*labels[i]); buttons[i] = new Gtk::ToggleToolButton(label); buttons[i]->set_active( i == hot ); - buttons[i]->set_icon_widget(*images[i]); + Gtk::Frame *frame = new Gtk::Frame(); + frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN); + frame->add(*images[i]); + buttons[i]->set_icon_widget(*Gtk::manage(frame)); tips.set_tip((*buttons[i]), label); buttons[i]->signal_clicked().connect( sigc::bind<int>( sigc::mem_fun(*this, &IconPreviewPanel::on_button_clicked), i) ); - verts->add(*buttons[i]); + Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(0.5, 0.5, 0, 0)); + align->add(*buttons[i]); + + int pad = 12; + if ((avail == 0) && (previous == 0)) { + verts->pack_end(*align, Gtk::PACK_SHRINK); + previous = sizes[i]; + avail = sizes[i]; + } else { + if ((avail < pad) || ((sizes[i] > avail) && (sizes[i] < previous))) { + horiz = 0; + } + if ((horiz == 0) && (sizes[i] <= previous)) { + avail = previous; + } + if (sizes[i] <= avail) { + if (!horiz) { + horiz = Gtk::manage(new Gtk::HBox()); + avail = previous; + verts->pack_end(*horiz, Gtk::PACK_SHRINK); + } + horiz->pack_start(*align, Gtk::PACK_EXPAND_WIDGET); + avail -= sizes[i]; + avail -= pad; // a little extra for padding + } else { + horiz = 0; + verts->pack_end(*align, Gtk::PACK_SHRINK); + } + } } iconBox.pack_start(splitter); splitter.pack1( *magBox, true, true ); - splitter.pack2( *verts, false, false ); - + Gtk::Frame *actuals = Gtk::manage(new Gtk::Frame(_("Actual Size:"))); + actuals->add(*verts); + splitter.pack2( *actuals, false, false ); - //## The Refresh button - - Gtk::HButtonBox* holder = new Gtk::HButtonBox( Gtk::BUTTONBOX_END ); - _getContents()->pack_end(*holder, false, false); - - selectionButton = new Gtk::ToggleButton(_("Selection")); // , GTK_RESPONSE_APPLY - holder->pack_start( *selectionButton, false, false ); + selectionButton = new Gtk::CheckButton(_("Selection")); // , GTK_RESPONSE_APPLY + magBox->pack_start( *selectionButton, Gtk::PACK_SHRINK ); tips.set_tip((*selectionButton), _("Selection only or whole document")); selectionButton->signal_clicked().connect( sigc::mem_fun(*this, &IconPreviewPanel::modeToggled) ); gint val = prefs->getBool("/iconpreview/selectionOnly"); selectionButton->set_active( val != 0 ); - refreshButton = new Gtk::Button(Gtk::Stock::REFRESH); // , GTK_RESPONSE_APPLY - holder->pack_end( *refreshButton, false, false ); - tips.set_tip((*refreshButton), _("Refresh the icons")); - refreshButton->signal_clicked().connect( sigc::mem_fun(*this, &IconPreviewPanel::refreshPreview) ); - - _getContents()->pack_start(iconBox, Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(iconBox, Gtk::PACK_SHRINK); show_all_children(); + + // Connect this up last + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &IconPreviewPanel::setDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); +} + +IconPreviewPanel::~IconPreviewPanel() +{ + setDesktop(0); + if (timer) { + timer->stop(); + delete timer; + timer = 0; + } + + selChangedConn.disconnect(); + docModConn.disconnect(); + docReplacedConn.disconnect(); + desktopChangeConn.disconnect(); + deskTrack.disconnect(); } //######################################################################### @@ -198,11 +255,51 @@ IconPreviewPanel::IconPreviewPanel() : //######################################################################### +void IconPreviewPanel::setDesktop( SPDesktop* desktop ) +{ + Panel::setDesktop(desktop); + + SPDocument *newDoc = (desktop) ? desktop->doc() : 0; + + if ( desktop != this->desktop ) { + docReplacedConn.disconnect(); + selChangedConn.disconnect(); + + this->desktop = Panel::getDesktop(); + if ( this->desktop ) { + docReplacedConn = this->desktop->connectDocumentReplaced(sigc::hide<0>(sigc::mem_fun(this, &IconPreviewPanel::setDocument))); + if (this->desktop->selection) { + selChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(this, &IconPreviewPanel::queueRefresh))); + } + } + } + setDocument(newDoc); + deskTrack.setBase(desktop); +} + +void IconPreviewPanel::setDocument( SPDocument *document ) +{ + if (this->document != document) { + docModConn.disconnect(); + + this->document = document; + if (this->document) { + docModConn = this->document->connectModified(sigc::hide(sigc::mem_fun(this, &IconPreviewPanel::queueRefresh))); + queueRefresh(); + } + } +} + void IconPreviewPanel::refreshPreview() { SPDesktop *desktop = getDesktop(); - if ( desktop ) { - + if (!timer) { + timer = new Glib::Timer(); + } + if (timer->elapsed() < 0.1) { + // Do not refresh too quickly + queueRefresh(); + } else if ( desktop ) { if ( selectionButton && selectionButton->get_active() ) { Inkscape::Selection * sel = sp_desktop_selection(desktop); @@ -225,14 +322,38 @@ void IconPreviewPanel::refreshPreview() renderPreview(target); } } - } - else - { + } else { SPObject *target = desktop->currentRoot(); if ( target ) { renderPreview(target); } } + timer->reset(); + } +} + +bool IconPreviewPanel::refreshCB() +{ + bool callAgain = true; + if (!timer) { + timer = new Glib::Timer(); + } + if ( timer->elapsed() > 0.1 ) { + callAgain = false; + refreshPreview(); + pending = false; + } + return callAgain; +} + +void IconPreviewPanel::queueRefresh() +{ + if (!pending) { + pending = true; + if (!timer) { + timer = new Glib::Timer(); + } + Glib::signal_idle().connect( sigc::mem_fun(this, &IconPreviewPanel::refreshCB), Glib::PRIORITY_DEFAULT_IDLE ); } } @@ -289,7 +410,6 @@ void IconPreviewPanel::updateMagnify() magnified.get_parent()->queue_draw(); } - } //namespace Dialogs } //namespace UI } //namespace Inkscape diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 8f143725d..9de882569 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -7,6 +7,7 @@ * Other dudes from The Inkscape Organization * * Copyright (C) 2004,2005 The Inkscape Organization + * Copyright (C) 2010 Jon A. Cruz * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -23,12 +24,16 @@ #include <gtkmm/toggletoolbutton.h> #include "ui/widget/panel.h" +#include "desktop-tracker.h" struct SPObject; +namespace Glib { +class Timer; +} namespace Inkscape { namespace UI { -namespace Dialogs { +namespace Dialog { /** @@ -39,9 +44,11 @@ class IconPreviewPanel : public UI::Widget::Panel public: IconPreviewPanel(); //IconPreviewPanel(Glib::ustring const &label); + ~IconPreviewPanel(); static IconPreviewPanel& getInstance(); + void setDesktop( SPDesktop* desktop ); void refreshPreview(); void modeToggled(); @@ -50,9 +57,11 @@ private: IconPreviewPanel &operator=(IconPreviewPanel const &); // no assign - void on_button_clicked(int which); - void renderPreview( SPObject* obj ); - void updateMagnify(); + DesktopTracker deskTrack; + SPDesktop *desktop; + SPDocument *document; + Glib::Timer *timer; + bool pending; Gtk::Tooltips tips; @@ -66,13 +75,24 @@ private: Gtk::Image magnified; Gtk::Label magLabel; - Gtk::Button *refreshButton; Gtk::ToggleButton *selectionButton; guchar** pixMem; Gtk::Image** images; Glib::ustring** labels; Gtk::ToggleToolButton** buttons; + sigc::connection desktopChangeConn; + sigc::connection docReplacedConn; + sigc::connection docModConn; + sigc::connection selChangedConn; + + + void setDocument( SPDocument *document ); + void on_button_clicked(int which); + void renderPreview( SPObject* obj ); + void updateMagnify(); + void queueRefresh(); + bool refreshCB(); }; } //namespace Dialogs @@ -82,3 +102,14 @@ private: #endif // SEEN_ICON_PREVIEW_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 96f0a0f6e..3c48a7972 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -469,9 +469,8 @@ void InkscapePreferences::initPageTools() AddSelcueCheckbox(_page_tweak, "/tools/tweak", true); AddGradientCheckbox(_page_tweak, "/tools/tweak", false); - //Spray + //Spray this->AddPage(_page_spray, _("Spray"), iter_tools, PREFS_PAGE_TOOLS_SPRAY); - this->AddNewObjectsStyle(_page_spray, "/tools/spray", _("Paint objects with:")); AddSelcueCheckbox(_page_spray, "/tools/spray", true); AddGradientCheckbox(_page_spray, "/tools/spray", false); @@ -943,7 +942,7 @@ void InkscapePreferences::initPageCMS() _cms_proof_intent.init("/options/softproof/intent", intentLabels, intentValues, numIntents, 0); _page_cms.add_line( false, _("Device rendering intent:"), _cms_proof_intent, "", - _("The rendering intent to use to calibrate display output"), false); + _("The rendering intent to use to calibrate device output"), false); _cms_proof_blackpoint.init( _("Black point compensation"), "/options/softproof/bpc", false); _page_cms.add_line( false, "", _cms_proof_blackpoint, "", @@ -1096,7 +1095,7 @@ void InkscapePreferences::initPageSVGOutput() _page_svgoutput.add_group_header( _("Numbers")); _svgoutput_numericprecision.init("/options/svgoutput/numericprecision", 1.0, 16.0, 1.0, 2.0, 8.0, true, false); - _page_svgoutput.add_line( false, _("Numeric precision:"), _svgoutput_numericprecision, "", _("How many digits to write after the decimal dot"), false); + _page_svgoutput.add_line( false, _("Numeric precision:"), _svgoutput_numericprecision, "", _("Significant figures of the values written to the SVG file"), false); _svgoutput_minimumexponent.init("/options/svgoutput/minimumexponent", -32.0, -1, 1.0, 2.0, -8.0, true, false); _page_svgoutput.add_line( false, _("Minimum exponent:"), _svgoutput_minimumexponent, "", _("The smallest number written to SVG is 10 to the power of this exponent; anything smaller is written as zero"), false); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 98bf236fc..ff3a13ab2 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -4,7 +4,7 @@ * Authors: * Jon A. Cruz * - * Copyright (C) 2006 Jon A. Cruz + * Copyright (C) 2006,2010 Jon A. Cruz * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -41,10 +41,9 @@ namespace Inkscape { namespace UI { -namespace Dialogs { +namespace Dialog { -LayersPanel& -LayersPanel::getInstance() +LayersPanel& LayersPanel::getInstance() { return *new LayersPanel(); } @@ -73,28 +72,6 @@ public: SPObject* _target; }; -static gboolean layers_panel_activated(Inkscape::Application * /*inkscape*/, SPDesktop *desktop, gpointer data ) -{ - if ( data ) - { - LayersPanel* panel = reinterpret_cast<LayersPanel*>(data); - panel->setDesktop(desktop); - } - - return FALSE; -} - -static gboolean layers_panel_deactivated( GtkObject */*object*/, GdkEvent * /*event*/, gpointer data ) -{ - if ( data ) - { - LayersPanel* panel = reinterpret_cast<LayersPanel*>(data); - panel->setDesktop(NULL); - } - - return FALSE; -} - void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback ) { bool set = false; @@ -348,12 +325,12 @@ bool LayersPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIt void LayersPanel::_layersChanged() { // g_message("_layersChanged()"); - if(_desktop) { + if (_desktop) { SPDocument* document = _desktop->doc(); SPObject* root = document->root; if ( root ) { _selectedConnection.block(); - if ( _mgr && _mgr->includes( root ) ) { + if ( _desktop->layer_manager && _desktop->layer_manager->includes( root ) ) { SPObject* target = _desktop->currentLayer(); _store->clear(); @@ -369,10 +346,10 @@ void LayersPanel::_layersChanged() void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level ) { - if ( layer && (level < _maxNestDepth) ) { - unsigned int counter = _mgr->childCount(layer); + if ( _desktop && _desktop->layer_manager && layer && (level < _maxNestDepth) ) { + unsigned int counter = _desktop->layer_manager->childCount(layer); for ( unsigned int i = 0; i < counter; i++ ) { - SPObject *child = _mgr->nthChildOf(layer, i); + SPObject *child = _desktop->layer_manager->nthChildOf(layer, i); if ( child ) { #if DUMP_LAYERS g_message(" %3d layer:%p {%s} [%s]", level, child, child->id, child->label() ); @@ -416,15 +393,15 @@ SPObject* LayersPanel::_selectedLayer() void LayersPanel::_pushTreeSelectionToCurrent() { // TODO hunt down the possible API abuse in getting NULL - if ( _desktop && _desktop->currentRoot() ) { + if ( _desktop && _desktop->layer_manager && _desktop->currentRoot() ) { SPObject* inTree = _selectedLayer(); if ( inTree ) { SPObject* curr = _desktop->currentLayer(); if ( curr != inTree ) { - _mgr->setCurrentLayer( inTree ); + _desktop->layer_manager->setCurrentLayer( inTree ); } } else { - _mgr->setCurrentLayer( _desktop->doc()->root ); + _desktop->layer_manager->setCurrentLayer( _desktop->doc()->root ); } } } @@ -537,13 +514,13 @@ void LayersPanel::_handleButtonEvent(GdkEventButton* evt) void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& /*path*/, Gtk::TreeModel::iterator const& iter ) { Gtk::TreeModel::Row row = *iter; - if ( row ) { + if ( row && _desktop && _desktop->layer_manager) { SPObject* obj = row[_model->_colObject]; if ( obj ) { gchar const* oldLabel = obj->label(); Glib::ustring tmp = row[_model->_colLabel]; if ( oldLabel && oldLabel[0] && !tmp.empty() && (tmp != oldLabel) ) { - _mgr->renameLayer( obj, tmp.c_str(), FALSE ); + _desktop->layer_manager->renameLayer( obj, tmp.c_str(), FALSE ); row[_model->_colLabel] = obj->label(); } } @@ -583,13 +560,14 @@ bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*mod */ LayersPanel::LayersPanel() : UI::Widget::Panel("", "/dialogs/layers", SP_VERB_DIALOG_LAYERS), + deskTrack(), _maxNestDepth(20), - _mgr(0), _desktop(0), _model(0), _pending(0), _toggleEvent(0), - _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND) + _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND), + desktopChangeConn() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _maxNestDepth = prefs->getIntLimited("/dialogs/layers/maxDepth", 20, 1, 1000); @@ -724,14 +702,15 @@ LayersPanel::LayersPanel() : (*it)->set_sensitive( false ); } - g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK( layers_panel_activated ), this ); - g_signal_connect( G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK( layers_panel_deactivated ), this ); - setDesktop( targetDesktop ); show_all_children(); // restorePanelPrefs(); + + // Connect this up last + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &LayersPanel::setDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); } LayersPanel::~LayersPanel() @@ -743,6 +722,12 @@ LayersPanel::~LayersPanel() if ( _model ) { delete _model; + _model = 0; + } + + if (_pending) { + delete _pending; + _pending = 0; } if ( _toggleEvent ) @@ -750,6 +735,9 @@ LayersPanel::~LayersPanel() gdk_event_free( _toggleEvent ); _toggleEvent = 0; } + + desktopChangeConn.disconnect(); + deskTrack.disconnect(); } @@ -761,9 +749,6 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) _layerChangedConnection.disconnect(); _layerUpdatedConnection.disconnect(); _changedConnection.disconnect(); - if ( _mgr ) { - _mgr = 0; - } if ( _desktop ) { _desktop = 0; } @@ -772,11 +757,11 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) if ( _desktop ) { //setLabel( _desktop->doc()->name ); - _mgr = _desktop->layer_manager; - if ( _mgr ) { - _layerChangedConnection = _mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) ); - _layerUpdatedConnection = _mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) ); - _changedConnection = _mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) ); + LayerManager *mgr = _desktop->layer_manager; + if ( mgr ) { + _layerChangedConnection = mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) ); + _layerUpdatedConnection = mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) ); + _changedConnection = mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) ); } _layersChanged(); @@ -790,6 +775,7 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) g_message(" {%s} [%s]", layer->id, layer->label() ); } */ + deskTrack.setBase(desktop); } diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index 16b3be350..4f2a65435 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -4,7 +4,7 @@ * Authors: * Jon A. Cruz * - * Copyright (C) 2006 Jon A. Cruz + * Copyright (C) 2006,2010 Jon A. Cruz * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -25,6 +25,7 @@ //#include "ui/previewholder.h" #include "ui/widget/panel.h" #include "ui/widget/object-composite-settings.h" +#include "desktop-tracker.h" class SPObject; @@ -33,7 +34,7 @@ namespace Inkscape { class LayerManager; namespace UI { -namespace Dialogs { +namespace Dialog { /** @@ -46,7 +47,7 @@ public: virtual ~LayersPanel(); //virtual void setOrientation( Gtk::AnchorType how ); - + static LayersPanel& getInstance(); void setDesktop( SPDesktop* desktop ); @@ -100,8 +101,8 @@ private: // Internal sigc::connection _selectedConnection; + DesktopTracker deskTrack; int _maxNestDepth; - Inkscape::LayerManager* _mgr; SPDesktop* _desktop; ModelColumns* _model; InternalUIBounce* _pending; @@ -121,6 +122,7 @@ private: UI::Widget::StyleSubject::CurrentLayer _subject; UI::Widget::ObjectCompositeSettings _compositeSettings; + sigc::connection desktopChangeConn; }; diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index 008ad4970..535a4b534 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -115,7 +115,7 @@ sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SPXMLViewAttrListClass, row_changed), NULL, NULL, - sp_marshal_NONE__UINT, + g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 826fabb06..de97e9ea4 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -213,7 +213,7 @@ static struct { { "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar", SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")}, { "SPSprayContext", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar", - SP_VERB_CONTEXT_SPRAY_PREFS, "/tools/spray", N_("Color/opacity used for color spraying")}, + SP_VERB_INVALID, 0, 0}, { "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar", SP_VERB_INVALID, 0, 0}, { "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar", @@ -1507,7 +1507,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions { InkToggleAction* act = ink_toggle_action_new( "NodesShowTransformHandlesAction", _("Show Transform Handles"), - _("Show node transformation handles"), + _("Show transformation handles for selected nodes"), "node-transform", secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -1518,7 +1518,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions { InkToggleAction* act = ink_toggle_action_new( "NodesShowHandlesAction", _("Show Handles"), - _("Show the Bezier handles of selected nodes"), + _("Show Bezier handles of selected nodes"), INKSCAPE_ICON_SHOW_NODE_HANDLES, secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -1529,7 +1529,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions { InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath", _("Show Outline"), - _("Show the outline of the path"), + _("Show path outline (without path effects)"), INKSCAPE_ICON_SHOW_PATH_OUTLINE, secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); @@ -1540,7 +1540,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions { InkAction* inky = ink_action_new( "EditNextLPEParameterAction", _("Next path effect parameter"), - _("Show next path effect parameter for editing"), + _("Show next editable path effect parameter"), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT, secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop ); @@ -1551,7 +1551,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions { InkToggleAction* inky = ink_toggle_action_new( "ObjectEditClipPathAction", _("Edit clipping paths"), - _("Show editing controls for clipping paths of selected objects"), + _("Show clipping path(s) of selected object(s)"), INKSCAPE_ICON_PATH_CLIP_EDIT, secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -1562,7 +1562,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions { InkToggleAction* inky = ink_toggle_action_new( "ObjectEditMaskPathAction", _("Edit masks"), - _("Show editing controls for masks of selected objects"), + _("Show mask(s) of selected object(s)"), INKSCAPE_ICON_PATH_MASK_EDIT, secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); @@ -4639,8 +4639,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction /* Standard_deviation */ gchar const* labels[] = {_("(minimum scatter)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum scatter)")}; gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100}; + + //TRANSLATORS: only translate "string" in "context|string". + // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction", - _("Scatter"), _("Scatter:"), _("Increase to scatter sprayed objects."), + Q_("Toolbox|Scatter"), Q_("Toolbox|Scatter:"), _("Increase to scatter sprayed objects."), "/tools/spray/standard_deviation", 70, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation", 1, 100, 1.0, 10.0, @@ -4746,8 +4749,11 @@ static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction { /* Scale */ gchar const* labels[] = {_("(low scale variation)"), 0, 0, _("(default)"), 0, 0, _("(high scale variation)")}; gdouble values[] = {10, 25, 35, 50, 60, 80, 100}; + + //TRANSLATORS: only translate "string" in "context|string". + // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS EgeAdjustmentAction *eact = create_adjustment_action( "SprayScaleAction", - _("Scale"), _("Scale:"), + Q_("Toolbox|Scale"), Q_("Toolbox|Scale:"), // xgettext:no-c-format _("Variation in the scale of the sprayed objects. 0% for the same scale than the original object."), "/tools/spray/scale_variation", 0, @@ -6239,15 +6245,19 @@ static void cell_data_func(GtkCellLayout * /*cell_layout*/, Glib::ustring sample = prefs->getString("/tools/text/font_sample"); gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1); - std::stringstream markup; - markup << family_escaped << " <span foreground='gray' font_family='" - << family_escaped << "'>" << sample_escaped << "</span>"; - g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL); + std::stringstream markup; + markup << family_escaped << " <span foreground='gray' font_family='" + << family_escaped << "'>" << sample_escaped << "</span>"; + g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL); g_free(sample_escaped); } else { g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL); } + // This doesn't work for two reasons... it set both selected and not selected backgrounds + // to white.. which means that white foreground text is invisible. It also only effects + // the text region, leaving the padding untouched. + // g_object_set (G_OBJECT (cell), "cell-background", "white", "cell-background-set", true, NULL); g_free(family); g_free(family_escaped); @@ -7171,17 +7181,27 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction", _("Font Family"), - _("Select Font Family"), + _("Select Font Family (Alt-X to access)"), NULL, GTK_TREE_MODEL(model), - -1, // Set width + -1, // Entry width + 50, // Extra list width (gpointer)cell_data_func ); // Cell layout ink_comboboxentry_action_popup_enable( act ); // Enable entry completion gchar *const warning = _("Font not found on system"); ink_comboboxentry_action_set_warning( act, warning ); // Show icon with tooltip if missing font + ink_comboboxentry_action_set_altx_name( act, "altx-text" ); // Set Alt-X keyboard shortcut g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontfamily_value_changed), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); g_object_set_data( holder, "TextFontFamilyAction", act ); + + // Change style of drop-down from menu to list + gtk_rc_parse_string ( + "style \"dropdown-as-list-style\"\n" + "{\n" + " GtkComboBox::appears-as-list = 1\n" + "}\n" + "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\""); } /* Font size */ @@ -7349,8 +7369,8 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions GTK_WIDGET(desktop->canvas), /* focusTarget */ NULL, /* unit selector */ holder, /* dataKludge */ - FALSE, /* altx? */ - NULL, /* altx_mark? */ + FALSE, /* set alt-x keyboard shortcut? */ + NULL, /* altx_mark */ 0.0, 10.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */ labels, values, G_N_ELEMENTS(labels), /* drop down menu */ sp_text_lineheight_value_changed, /* callback */ @@ -7379,8 +7399,8 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions GTK_WIDGET(desktop->canvas), /* focusTarget */ NULL, /* unit selector */ holder, /* dataKludge */ - FALSE, /* altx? */ - NULL, /* altx_mark? */ + FALSE, /* set alt-x keyboard shortcut? */ + NULL, /* altx_mark */ -100.0, 100.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */ labels, values, G_N_ELEMENTS(labels), /* drop down menu */ sp_text_wordspacing_value_changed, /* callback */ @@ -7409,8 +7429,8 @@ static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions GTK_WIDGET(desktop->canvas), /* focusTarget */ NULL, /* unit selector */ holder, /* dataKludge */ - FALSE, /* altx? */ - NULL, /* altx_mark? */ + FALSE, /* set alt-x keyboard shortcut? */ + NULL, /* altx_mark */ -100.0, 100.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */ labels, values, G_N_ELEMENTS(labels), /* drop down menu */ sp_text_letterspacing_value_changed, /* callback */ |
