diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-03 00:10:02 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-03 00:10:02 +0000 |
| commit | d2df0412f728dd5bb54537dfdfe7c35b34d40e0e (patch) | |
| tree | e2703384779e83312c456399999997fcc289c5cf /src/ui/widget | |
| parent | Merge branch 'master' into powerpencil (diff) | |
| parent | change assignment to equality (diff) | |
| download | inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.tar.gz inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.zip | |
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/color-notebook.cpp | 5 | ||||
| -rw-r--r-- | src/ui/widget/color-preview.cpp | 45 | ||||
| -rw-r--r-- | src/ui/widget/makefile.in | 17 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 14 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.h | 2 | ||||
| -rw-r--r-- | src/ui/widget/panel.cpp | 1 | ||||
| -rw-r--r-- | src/ui/widget/preferences-widget.cpp | 31 | ||||
| -rw-r--r-- | src/ui/widget/preferences-widget.h | 12 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.cpp | 7 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 11 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.h | 2 | ||||
| -rw-r--r-- | src/ui/widget/spinbutton.cpp | 2 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.cpp | 51 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.h | 6 |
14 files changed, 113 insertions, 93 deletions
diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index a4df8187f..ba333d0ed 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -22,6 +22,7 @@ #include <glibmm/i18n.h> #include <gtkmm/label.h> #include <gtkmm/notebook.h> +#include <gtkmm/radiobutton.h> #include "preferences.h" #include "widgets/spw-utilities.h" @@ -325,8 +326,8 @@ void ColorNotebook::_addPage(Page &page) _buttons[page_num] = gtk_radio_button_new_with_label(NULL, mode_name.c_str()); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(_buttons[page_num]), FALSE); if (page_num > 0) { - GSList *group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(_buttons[0])); - gtk_radio_button_set_group(GTK_RADIO_BUTTON(_buttons[page_num]), group); + auto g = Glib::wrap(GTK_RADIO_BUTTON(_buttons[0]))->get_group(); + Glib::wrap(GTK_RADIO_BUTTON(_buttons[page_num]))->set_group(g); } gtk_widget_show(_buttons[page_num]); gtk_box_pack_start(GTK_BOX(_buttonbox), _buttons[page_num], TRUE, TRUE, 0); diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index c9b6e56d2..54b2991f0 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -11,6 +11,7 @@ #include "ui/widget/color-preview.h" #include "display/cairo-utils.h" +#include <cairo.h> #define SPCP_DEFAULT_WIDTH 32 #define SPCP_DEFAULT_HEIGHT 12 @@ -70,45 +71,45 @@ ColorPreview::setRgba32 (guint32 rgba) bool ColorPreview::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { - GdkRectangle warea, carea; - gint w2; - + double x, y, width, height; const Gtk::Allocation& allocation = get_allocation(); - warea.x = allocation.get_x(); - warea.y = allocation.get_y(); - warea.width = allocation.get_width(); - warea.height = allocation.get_height(); + x = 0; + y = 0; + width = allocation.get_width()/2.0; + height = allocation.get_height(); + + double radius = height / 7.5; + double degrees = M_PI / 180.0; + cairo_new_sub_path (cr->cobj()); + cairo_line_to(cr->cobj(), width, 0); + cairo_line_to(cr->cobj(), width, height); + cairo_arc (cr->cobj(), x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees); + cairo_arc (cr->cobj(), x + radius, y + radius, radius, 180 * degrees, 270 * degrees); + cairo_close_path (cr->cobj()); /* Transparent area */ - w2 = warea.width / 2; - - carea.x = warea.x; - carea.y = warea.y; - carea.width = w2; - carea.height = warea.height; - cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard(); - cr->rectangle(carea.x, carea.y, carea.width, carea.height); cairo_set_source(cr->cobj(), checkers); cr->fill_preserve(); ink_cairo_set_source_rgba32(cr->cobj(), _rgba); cr->fill(); - cairo_pattern_destroy(checkers); /* Solid area */ - carea.x = warea.x + w2; - carea.y = warea.y; - carea.width = warea.width - w2; - carea.height = warea.height; + x = width; - cr->rectangle(carea.x, carea.y, carea.width, carea.height); + cairo_new_sub_path (cr->cobj()); + cairo_arc (cr->cobj(), x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees); + cairo_arc (cr->cobj(), x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees); + cairo_line_to(cr->cobj(), x, height); + cairo_line_to(cr->cobj(), x, y); + cairo_close_path (cr->cobj()); ink_cairo_set_source_rgba32(cr->cobj(), _rgba | 0xff); cr->fill(); - + return true; } diff --git a/src/ui/widget/makefile.in b/src/ui/widget/makefile.in deleted file mode 100644 index e479d7031..000000000 --- a/src/ui/widget/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd ../.. && $(MAKE) ui/widget/all - -clean %.a %.$(OBJEXT): - cd ../.. && $(MAKE) ui/widget/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index eb0e45f14..7427ad4e2 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -355,13 +355,12 @@ PageSizer::PageSizer(Registry & _wr) _fitPageMarginExpander.set_vexpand(); _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1); - _dimTabOrderGList = NULL; - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj()); - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionHeight.gobj()); - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionUnits.gobj()); - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _fitPageMarginExpander.gobj()); - Glib::ListHandle<Widget *> dimFocusChain(_dimTabOrderGList, Glib::OWNERSHIP_NONE); - _customDimTable.set_focus_chain(dimFocusChain); + _dimTabOrderList.clear(); + _dimTabOrderList.push_back(&_dimensionWidth); + _dimTabOrderList.push_back(&_dimensionHeight); + _dimTabOrderList.push_back(&_dimensionUnits); + _dimTabOrderList.push_back(&_fitPageMarginExpander); + _customDimTable.set_focus_chain(_dimTabOrderList); //## Set up fit page expander _fitPageMarginExpander.set_use_underline(); @@ -454,7 +453,6 @@ PageSizer::PageSizer(Registry & _wr) */ PageSizer::~PageSizer() { - g_list_free(_dimTabOrderGList); } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index f84f96782..329ecfc6d 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -220,7 +220,7 @@ protected: RegisteredUnitMenu _dimensionUnits; RegisteredScalarUnit _dimensionWidth; RegisteredScalarUnit _dimensionHeight; - GList * _dimTabOrderGList; + std::vector<Widget*> _dimTabOrderList; //### Fit Page options Gtk::Expander _fitPageMarginExpander; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 9332fe0f9..aea9b7e8e 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -24,7 +24,6 @@ #include <glibmm/i18n.h> #include "panel.h" -#include "icon-size.h" #include "preferences.h" #include "desktop.h" diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 2981316c0..8b8e663a5 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -34,6 +34,7 @@ #include <glibmm/i18n.h> #include <glibmm/convert.h> +#include <glibmm/regex.h> #ifdef WIN32 #include <windows.h> @@ -78,6 +79,7 @@ void DialogPage::add_line(bool indent, auto hb = Gtk::manage(new Gtk::Box()); hb->set_spacing(12); + hb->set_hexpand(true); hb->pack_start(widget, expand_widget, expand_widget); // Pack an additional widget into a box with the widget if desired @@ -859,6 +861,35 @@ void PrefEntry::on_changed() } } +void PrefMultiEntry::init(Glib::ustring const &prefs_path, int height) +{ + // TODO: Figure out if there's a way to specify height in lines instead of px + // and how to obtain a reasonable default width if 'expand_widget' is not used + set_size_request(100, height); + set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + set_shadow_type(Gtk::SHADOW_IN); + + add(_text); + + _prefs_path = prefs_path; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring value = prefs->getString(_prefs_path); + value = Glib::Regex::create("\\|")->replace_literal(value, 0, "\n", (Glib::RegexMatchFlags)0); + _text.get_buffer()->set_text(value); + _text.get_buffer()->signal_changed().connect(sigc::mem_fun(*this, &PrefMultiEntry::on_changed)); +} + +void PrefMultiEntry::on_changed() +{ + if (get_visible()) //only take action if user changed value + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring value = _text.get_buffer()->get_text(); + value = Glib::Regex::create("\\n")->replace_literal(value, 0, "|", (Glib::RegexMatchFlags)0); + prefs->setString(_prefs_path, value); + } +} + void PrefColorPicker::init(Glib::ustring const &label, Glib::ustring const &prefs_path, guint32 default_rgba) { diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 142793509..2578be533 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -28,6 +28,8 @@ #include <sigc++/sigc++.h> #include <gtkmm/checkbutton.h> #include <gtkmm/radiobutton.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/textview.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/drawingarea.h> #include <gtkmm/grid.h> @@ -195,6 +197,16 @@ protected: void on_changed(); }; +class PrefMultiEntry : public Gtk::ScrolledWindow +{ +public: + void init(Glib::ustring const &prefs_path, int height); +protected: + Glib::ustring _prefs_path; + Gtk::TextView _text; + void on_changed(); +}; + class PrefEntryButtonHBox : public Gtk::HBox { public: diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 639bd4161..a88413347 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -412,9 +412,12 @@ RegisteredColorPicker::on_changed (guint32 rgba) local_repr = dt->getNamedView()->getRepr(); local_doc = dt->getDocument(); } - gchar c[32]; - sp_svg_write_color(c, sizeof(c), rgba); + if (_akey == _ckey + "_opacity_LPE") { //For LPE parameter we want stored with alpha + sprintf(c, "#%08x", rgba); + } else { + sp_svg_write_color(c, sizeof(c), rgba); + } bool saved = DocumentUndo::getUndoSensitive(local_doc); DocumentUndo::setUndoSensitive(local_doc, false); local_repr->setAttribute(_ckey.c_str(), c); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 68acddfcc..d9b93f6db 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -107,8 +107,7 @@ static const GtkTargetEntry ui_drop_target_entries [] = { {"application/x-color", 0, APP_X_COLOR} }; -#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0]) -static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries); +static guint nui_drop_target_entries = G_N_ELEMENTS(ui_drop_target_entries); /* convenience function */ static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop); @@ -139,7 +138,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_blocked (false), - _unit_mis(NULL), _sw_unit(NULL) { set_name("SelectedStyle"); @@ -336,7 +334,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) while(iter != m.end()) { Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); mi->add(*(new Gtk::Label(iter->first, Gtk::ALIGN_START))); - _unit_mis = g_slist_append(_unit_mis, mi); + _unit_mis.push_back(mi); Inkscape::Util::Unit const *u = unit_table.getUnit(iter->first); mi->signal_activate().connect(sigc::bind<Inkscape::Util::Unit const *>(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u)); _popup_sw.attach(*mi, 0,1, row, row+1); @@ -449,6 +447,7 @@ SelectedStyle::~SelectedStyle() delete selection_modified_connection; subselection_changed_connection->disconnect(); delete subselection_changed_connection; + _unit_mis.clear(); for (int i = SS_FILL; i <= SS_STROKE; i++) { delete _color_preview[i]; @@ -488,9 +487,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) _sw_unit = desktop->getNamedView()->display_units; // Set the doc default unit active in the units list - gint length = g_slist_length(_unit_mis); - for (int i = 0; i < length; i++) { - Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i); + for ( auto mi:_unit_mis ) { if (mi && mi->get_label() == _sw_unit->abbr) { mi->set_active(); break; diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 065d745f0..b7f3d5dda 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -267,7 +267,7 @@ protected: Gtk::Menu _popup_sw; Gtk::RadioButtonGroup _sw_group; - GSList *_unit_mis; + std::vector<Gtk::RadioMenuItem*> _unit_mis; void on_popup_units(Inkscape::Util::Unit const *u); void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index d1776e630..0c082d3ce 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -71,7 +71,7 @@ bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) bool SpinButton::on_my_key_press_event(GdkEventKey* event) { - switch (Inkscape::UI::Tools::get_group0_keyval (event)) { + switch (Inkscape::UI::Tools::get_latin_keyval (event)) { case GDK_KEY_Escape: undo(); return true; // I consumed the event diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index a1501c229..d36220b74 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -14,7 +14,7 @@ #include "style-internal.h" #include "unit-tracker.h" -#include "widgets/ege-select-one-action.h" +//#include "widgets/ege-select-one-action.h" #define COLUMN_STRING 0 @@ -31,9 +31,6 @@ UnitTracker::UnitTracker(UnitType unit_type) : _activeUnit(NULL), _activeUnitInitialized(false), _store(0), - _unitList(0), - _actionList(0), - _adjList(0), _priorValues() { _store = gtk_list_store_new(1, G_TYPE_STRING); @@ -58,17 +55,17 @@ UnitTracker::UnitTracker(UnitType unit_type) : UnitTracker::~UnitTracker() { // Unhook weak references to GtkActions - while (_actionList) { - g_signal_handlers_disconnect_by_func(G_OBJECT(_actionList->data), (gpointer) _unitChangedCB, this); - g_object_weak_unref(G_OBJECT(_actionList->data), _actionFinalizedCB, this); - _actionList = g_slist_delete_link(_actionList, _actionList); + for (auto i : _actionList) { + g_signal_handlers_disconnect_by_func(G_OBJECT(i), (gpointer) _unitChangedCB, this); + g_object_weak_unref(G_OBJECT(i), _actionFinalizedCB, this); } + _actionList.clear(); // Unhook weak references to GtkAdjustments - while (_adjList) { - g_object_weak_unref(G_OBJECT(_adjList->data), _adjustmentFinalizedCB, this); - _adjList = g_slist_delete_link(_adjList, _adjList); + for (auto i : _adjList) { + g_object_weak_unref(G_OBJECT(i), _adjustmentFinalizedCB, this); } + _adjList.clear(); } bool UnitTracker::isUpdating() const @@ -109,9 +106,9 @@ void UnitTracker::setActiveUnitByAbbr(gchar const *abbr) void UnitTracker::addAdjustment(GtkAdjustment *adj) { - if (!g_slist_find(_adjList, adj)) { + if (std::find(_adjList.begin(),_adjList.end(),adj)!=_adjList.end()) { g_object_weak_ref(G_OBJECT(adj), _adjustmentFinalizedCB, this); - _adjList = g_slist_append(_adjList, adj); + _adjList.push_back(adj); } } @@ -147,7 +144,7 @@ GtkAction *UnitTracker::createAction(gchar const *name, gchar const *label, gcha ege_select_one_action_set_appearance(act1, "minimal"); g_object_weak_ref(G_OBJECT(act1), _actionFinalizedCB, this); g_signal_connect(G_OBJECT(act1), "changed", G_CALLBACK(_unitChangedCB), this); - _actionList = g_slist_append(_actionList, act1); + _actionList.push_back(act1); return GTK_ACTION(act1); } @@ -180,9 +177,10 @@ void UnitTracker::_adjustmentFinalizedCB(gpointer data, GObject *where_the_objec void UnitTracker::_actionFinalized(GObject *where_the_object_was) { - GSList *target = g_slist_find(_actionList, where_the_object_was); - if (target) { - _actionList = g_slist_remove(_actionList, where_the_object_was); + EgeSelectOneAction* act = (EgeSelectOneAction*)(where_the_object_was); + auto it = std::find(_actionList.begin(),_actionList.end(), act); + if (it != _actionList.end()) { + _actionList.erase(it); } else { g_warning("Received a finalization callback for unknown object %p", where_the_object_was); } @@ -190,9 +188,10 @@ void UnitTracker::_actionFinalized(GObject *where_the_object_was) void UnitTracker::_adjustmentFinalized(GObject *where_the_object_was) { - GSList *target = g_slist_find(_adjList, where_the_object_was); - if (target) { - _adjList = g_slist_remove(_adjList, where_the_object_was); + GtkAdjustment* adj = (GtkAdjustment*)(where_the_object_was); + auto it = std::find(_adjList.begin(),_adjList.end(), adj); + if (it != _adjList.end()) { + _adjList.erase(it); } else { g_warning("Received a finalization callback for unknown object %p", where_the_object_was); } @@ -217,7 +216,7 @@ void UnitTracker::_setActive(gint active) Inkscape::Util::Unit const *newUnit = unit_table.getUnit(newAbbr); _activeUnit = newUnit; - if (_adjList) { + if (!_adjList.empty()) { _fixupAdjustments(unit, newUnit); } @@ -230,11 +229,8 @@ void UnitTracker::_setActive(gint active) _active = active; - for ( GSList *cur = _actionList ; cur ; cur = g_slist_next(cur) ) { - if (IS_EGE_SELECT_ONE_ACTION(cur->data)) { - EgeSelectOneAction *act = EGE_SELECT_ONE_ACTION(cur->data); - ege_select_one_action_set_active(act, active); - } + for (auto act:_actionList) { + ege_select_one_action_set_active(act, active); } _activeUnitInitialized = true; @@ -244,8 +240,7 @@ void UnitTracker::_setActive(gint active) void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit) { _isUpdating = true; - for ( GSList *cur = _adjList ; cur ; cur = g_slist_next(cur) ) { - GtkAdjustment *adj = GTK_ADJUSTMENT(cur->data); + for ( auto adj : _adjList ) { gdouble oldVal = gtk_adjustment_get_value(adj); gdouble val = oldVal; diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index 8fa9ff304..643ac4e51 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -17,6 +17,7 @@ #include <map> #include "util/units.h" +#include "widgets/ege-select-one-action.h" using Inkscape::Util::Unit; using Inkscape::Util::UnitType; @@ -65,9 +66,8 @@ private: Inkscape::Util::Unit const *_activeUnit; bool _activeUnitInitialized; GtkListStore *_store; - GSList *_unitList; - GSList *_actionList; - GSList *_adjList; + std::vector<EgeSelectOneAction*> _actionList; + std::vector<GtkAdjustment*> _adjList; std::map <GtkAdjustment *, gdouble> _priorValues; }; |
