diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-03-08 08:59:37 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-03-08 08:59:37 +0000 |
| commit | d8a3b36b43e0700126a7a25a1d38858d1a1d4836 (patch) | |
| tree | eaf5a86ac5542fc33ed8bb697a615e08ddd2ae01 /src/ui | |
| parent | changes_2013_02_25a.patch (diff) | |
| parent | Drop deprecated get_vbox method in Gtk::Dialog (diff) | |
| download | inkscape-d8a3b36b43e0700126a7a25a1d38858d1a1d4836.tar.gz inkscape-d8a3b36b43e0700126a7a25a1d38858d1a1d4836.zip | |
merge from trunk (r12181)
(bzr r11668.1.53)
Diffstat (limited to 'src/ui')
30 files changed, 424 insertions, 171 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 8fd8eb4e3..f3c3b8473 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -84,6 +84,7 @@ set(ui_SRC widget/entry.cpp widget/filter-effect-chooser.cpp widget/frame.cpp + widget/gimpcolorwheel.c widget/gimpspinscale.c widget/imageicon.cpp widget/imagetoggler.cpp @@ -212,6 +213,7 @@ set(ui_SRC widget/filter-effect-chooser.h widget/frame.h widget/gimpspinscale.h + widget/gimpcolorwheel.h widget/imageicon.h widget/imagetoggler.h widget/labelled.h diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 0c0027c15..d4928d25d 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -97,7 +97,12 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { tabs->append_page(*manage( make_scrolled_text(license_text)), _("_License"), true); +#if WITH_GTKMM_3_0 + get_content_area()->pack_end(*manage(tabs), true, true); +#else get_vbox()->pack_end(*manage(tabs), true, true); +#endif + tabs->show_all(); add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); @@ -114,7 +119,11 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { label->set_selectable(true); label->show(); +#if WITH_GTKMM_3_0 + get_content_area()->pack_start(*manage(label), false, false); +#else get_vbox()->pack_start(*manage(label), false, false); +#endif Gtk::Requisition requisition; #if GTK_CHECK_VERSION(3,0,0) diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index 77a4f4f03..da43763c8 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -32,7 +32,12 @@ CalligraphicProfileRename::CalligraphicProfileRename() : { set_title(_("Edit profile")); +#if WITH_GTKMM_3_0 + Gtk::Box *mainVBox = get_content_area(); +#else Gtk::Box *mainVBox = get_vbox(); +#endif + _layout_table.set_spacings(4); _layout_table.resize (1, 2); diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index 429ed57bf..e61f8e389 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -69,7 +69,11 @@ DebugDialogImpl::DebugDialogImpl() set_title(_("Messages")); set_size_request(300, 400); +#if WITH_GTKMM_3_0 + Gtk::Box *mainVBox = get_content_area(); +#else Gtk::Box *mainVBox = get_vbox(); +#endif //## Add a menu for clear() Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("_File"), true)); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 50f30e8f4..fd368ed9f 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -20,6 +20,11 @@ #include "dialog-manager.h" #include <gtkmm/imagemenuitem.h> + +#if GTK_CHECK_VERSION(3,0,0) +# include <gdkmm/devicemanager.h> +#endif + #include "ui/widget/spinbutton.h" #include <glibmm/i18n.h> @@ -1201,7 +1206,6 @@ void FilterEffectsDialog::FilterModifier::on_change_selection() { Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP); update_selection(selection); - update_filters(); } void FilterEffectsDialog::FilterModifier::on_modified_selection( guint flags ) @@ -1785,7 +1789,15 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair // Check mouse state int mx, my; Gdk::ModifierType mask; + +#if GTK_CHECK_VERSION(3,0,0) + Glib::RefPtr<Gdk::Display> display = get_bin_window()->get_display(); + Glib::RefPtr<Gdk::DeviceManager> dm = display->get_device_manager(); + Glib::RefPtr<const Gdk::Device> device = dm->get_client_pointer(); + get_bin_window()->get_device_position(device, mx, my, mask); +#else get_bin_window()->get_pointer(mx, my, mask); +#endif // Outline the bottom of the connection area const int outline_x = x + fheight * (row_count - row_index); @@ -2668,7 +2680,7 @@ void FilterEffectsDialog::update_primitive_infobox() break; case(NR_FILTER_SPECULARLIGHTING): _infobox_icon.set_from_icon_name("feSpecularLighting-icon", Gtk::ICON_SIZE_DIALOG); - _infobox_desc.set_markup(_("The feDiffuseLighting and <b>feSpecularLighting</b> filter primitives create \"embossed\" shadings. The input's alpha channel is used to provide depth information: higher opacity areas are raised toward the viewer and lower opacity areas recede away from the viewer.")); + _infobox_desc.set_markup(_("The <b>feDiffuseLighting</b> and <b>feSpecularLighting</b> filter primitives create \"embossed\" shadings. The input's alpha channel is used to provide depth information: higher opacity areas are raised toward the viewer and lower opacity areas recede away from the viewer.")); break; case(NR_FILTER_TILE): _infobox_icon.set_from_icon_name("feTile-icon", Gtk::ICON_SIZE_DIALOG); diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index ba81c6d47..d70c5f187 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -12,6 +12,7 @@ #include <gtkmm/dialog.h> #include <gtkmm/stock.h> +#include <glibmm/main.h> #include <gtk/gtk.h> #include "floating-behavior.h" @@ -134,7 +135,13 @@ FloatingBehavior::create(Dialog &dialog) inline FloatingBehavior::operator Gtk::Widget &() { return *_d; } inline GtkWidget *FloatingBehavior::gobj() { return GTK_WIDGET(_d->gobj()); } -inline Gtk::Box* FloatingBehavior::get_vbox() { return _d->get_vbox(); } +inline Gtk::Box* FloatingBehavior::get_vbox() { +#if WITH_GTKMM_3_0 + return _d->get_content_area(); +#else + return _d->get_vbox(); +#endif +} inline void FloatingBehavior::present() { _d->present(); } inline void FloatingBehavior::hide() { _d->hide(); } inline void FloatingBehavior::show() { _d->show(); } diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 07e73cec8..f0112f1d8 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -37,6 +37,8 @@ #include "libnrtype/FontFactory.h" #include "libnrtype/font-instance.h" +#include <glibmm/regex.h> + namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index eec904ee4..be44794d0 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -1,6 +1,7 @@ /* Authors: * Jon A. Cruz * Abhishek Sharma + * Tavmjong Bah * * Copyright (C) 2010 Jon A. Cruz * Released under GNU GPL, read the file 'COPYING' for more information @@ -343,7 +344,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : GtkWidget *fontsel = sp_font_selector_new(); fsel = SP_FONT_SELECTOR(fontsel); - sp_font_selector_set_font(fsel, sp_font_selector_get_font(fsel), 12.0); + sp_font_selector_set_fontspec( fsel, sp_font_selector_get_fontspec(fsel), 12.0 ); + gtk_widget_set_size_request (fontsel, 0, 150); g_signal_connect( G_OBJECT(fontsel), "font_set", G_CALLBACK(fontChangeCB), this ); @@ -520,6 +522,7 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) } } +// Append selected glyphs to selected text void GlyphsPanel::insertText() { SPItem *textItem = 0; @@ -611,7 +614,7 @@ void GlyphsPanel::glyphSelectionChanged() calcCanInsert(); } -void GlyphsPanel::fontChangeCB(SPFontSelector * /*fontsel*/, font_instance * /*font*/, GlyphsPanel *self) +void GlyphsPanel::fontChangeCB(SPFontSelector * /*fontsel*/, Glib::ustring /*fontspec*/, GlyphsPanel *self) { if (self) { self->rebuild(); @@ -667,7 +670,13 @@ void GlyphsPanel::readSelection( bool updateStyle, bool /*updateContent*/ ) void GlyphsPanel::rebuild() { - font_instance *font = fsel ? sp_font_selector_get_font(fsel) : 0; + Glib::ustring fontspec = fsel ? sp_font_selector_get_fontspec(fsel) : ""; + + font_instance* font = 0; + if( !fontspec.empty() ) { + font = font_factory::Default()->FaceFromFontSpecification( fontspec.c_str() ); + } + if (font) { //double sp_font_selector_get_size (SPFontSelector *fsel); diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 162c7b296..6571af0a4 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -54,7 +54,7 @@ private: static GlyphColumns *getColumns(); - static void fontChangeCB(SPFontSelector *fontsel, font_instance *font, GlyphsPanel *self); + static void fontChangeCB(SPFontSelector *fontsel, Glib::ustring fontspec, GlyphsPanel *self); void rebuild(); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index d8bbb5539..06671393d 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -166,12 +166,12 @@ void GuidelinePropertiesDialog::_setup() { add_button(Gtk::Stock::DELETE, -12); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - Gtk::Box *mainVBox = get_vbox(); - #if WITH_GTKMM_3_0 + Gtk::Box *mainVBox = get_content_area(); _layout_table.set_row_spacing(4); _layout_table.set_column_spacing(4); #else + Gtk::Box *mainVBox = get_vbox(); _layout_table.set_spacings(4); _layout_table.resize (3, 4); #endif diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 57f815730..c63b78c70 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -18,6 +18,7 @@ #endif #include <glibmm/i18n.h> +#include <glibmm/miscutils.h> #include "inkscape-preferences.h" #include <gtkmm/main.h> @@ -1288,7 +1289,7 @@ void InkscapePreferences::initPageBehavior() _page_mask.add_group_header( _("Before applying")); _mask_grouping_none.init( _("Do not group clipped/masked objects"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_NONE, true, 0); - _mask_grouping_separate.init( _("Enclose every clipped/masked object in its own group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_SEPARATE, false, &_mask_grouping_none); + _mask_grouping_separate.init( _("Put every clipped/masked object in its own group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_SEPARATE, false, &_mask_grouping_none); _mask_grouping_all.init( _("Put all clipped/masked objects into one group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_ALL, false, &_mask_grouping_none); _page_mask.add_line(true, "", _mask_grouping_none, "", @@ -1476,7 +1477,15 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui scroller->add(_kb_tree); int row = 3; + +#if WITH_GTKMM_3_0 + scroller->set_hexpand(); + scroller->set_vexpand(); + _page_keyshortcuts.attach(*scroller, 0, row, 2, 1); +#else _page_keyshortcuts.attach(*scroller, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL); +#endif + row++; #if WITH_GTKMM_3_0 @@ -1487,7 +1496,13 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui box_buttons->set_layout(Gtk::BUTTONBOX_END); box_buttons->set_spacing(4); + +#if WITH_GTKMM_3_0 + box_buttons->set_hexpand(); + _page_keyshortcuts.attach(*box_buttons, 0, row, 3, 1); +#else _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); +#endif UI::Widget::Button *kb_reset = manage(new UI::Widget::Button(_("Reset"), _("Remove all your customized keyboard shortcuts, and revert to the shortcuts in the shortcut file listed above"))); box_buttons->pack_start(*kb_reset, true, true, 6); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index b21ab0128..eaf1ffc3d 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -87,6 +87,14 @@ enum { }; +namespace Gtk { +#if WITH_GTKMM_3_0 +class Scale; +#else +class HScale; +#endif +} + namespace Inkscape { namespace UI { namespace Dialog { @@ -188,7 +196,12 @@ protected: UI::Widget::PrefCheckButton _scroll_space; UI::Widget::PrefCheckButton _wheel_zoom; +#if WITH_GTKMM_3_0 + Gtk::Scale *_slider_snapping_delay; +#else Gtk::HScale *_slider_snapping_delay; +#endif + UI::Widget::PrefCheckButton _snap_indicator; UI::Widget::PrefCheckButton _snap_closest_only; UI::Widget::PrefCheckButton _snap_mouse_pointer; diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 6a1bc829e..3feed2afe 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -40,12 +40,12 @@ namespace Dialogs { LayerPropertiesDialog::LayerPropertiesDialog() : _strategy(NULL), _desktop(NULL), _layer(NULL), _position_visible(false) { - Gtk::Box *mainVBox = get_vbox(); - #if WITH_GTKMM_3_0 + Gtk::Box *mainVBox = get_content_area(); _layout_table.set_row_spacing(4); _layout_table.set_column_spacing(4); #else + Gtk::Box *mainVBox = get_vbox(); _layout_table.set_spacings(4); _layout_table.resize (1, 2); #endif diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index fdc33b2a6..dd147d00f 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -20,6 +20,7 @@ #include <gtkmm/separatormenuitem.h> #include <glibmm/i18n.h> +#include <glibmm/main.h> #include "desktop.h" #include "desktop-style.h" diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index e899dbcfc..b5f51d81d 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -73,7 +73,12 @@ LivePathEffectAdd::LivePathEffectAdd() : add_button.set_use_underline(true); add_button.set_can_default(); +#if WITH_GTKMM_3_0 + Gtk::Box *mainVBox = get_content_area(); +#else Gtk::Box *mainVBox = get_vbox(); +#endif + mainVBox->pack_start(scrolled_window, true, true); add_action_widget(close_button, Gtk::RESPONSE_CLOSE); add_action_widget(add_button, Gtk::RESPONSE_APPLY); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index be69635e8..0da39dd73 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -22,6 +22,7 @@ #include "document-undo.h" #include <gtkmm/notebook.h> #include <gtkmm/imagemenuitem.h> +#include <gtkmm/scale.h> #include <gtkmm/stock.h> #include <glibmm/i18n.h> #include <message-stack.h> @@ -191,7 +192,7 @@ void SvgFontsDialog::on_kerning_value_changed(){ //slider values increase from right to left so that they match the kerning pair preview //XML Tree being directly used here while it shouldn't be. - this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str()); + this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider->get_value()).c_str()); DocumentUndo::maybeDone(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); //populate_kerning_pairs_box(); @@ -299,7 +300,7 @@ void SvgFontsDialog::on_kerning_pair_selection_changed(){ this->kerning_pair = kern; //slider values increase from right to left so that they match the kerning pair preview - kerning_slider.set_value(get_selected_spfont()->horiz_adv_x - kern->k); + kerning_slider->set_value(get_selected_spfont()->horiz_adv_x - kern->k); } void SvgFontsDialog::update_global_settings_tab(){ @@ -328,9 +329,9 @@ void SvgFontsDialog::on_font_selection_changed(){ double set_width = spfont->horiz_adv_x; setwidth_spin.set_value(set_width); - kerning_slider.set_range(0, set_width); - kerning_slider.set_draw_value(false); - kerning_slider.set_value(0); + kerning_slider->set_range(0, set_width); + kerning_slider->set_draw_value(false); + kerning_slider->set_value(0); update_global_settings_tab(); populate_glyphs_box(); @@ -779,7 +780,7 @@ Gtk::VBox* SvgFontsDialog::kerning_tab(){ add_kernpair_button.set_label(_("Add pair")); add_kernpair_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_kerning_pair)); _KerningPairsList.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_pair_selection_changed)); - kerning_slider.signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_value_changed)); + kerning_slider->signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_kerning_value_changed)); kerning_vbox.pack_start(*kerning_selector, false,false); @@ -797,7 +798,7 @@ Gtk::VBox* SvgFontsDialog::kerning_tab(){ Gtk::HBox* kerning_amount_hbox = Gtk::manage(new Gtk::HBox()); kerning_vbox.pack_start(*kerning_amount_hbox, false,false); kerning_amount_hbox->add(*Gtk::manage(new Gtk::Label(_("Kerning value:")))); - kerning_amount_hbox->add(kerning_slider); + kerning_amount_hbox->add(*kerning_slider); kerning_preview.set_size(300 + 20, 150 + 20); _font_da.set_size(150 + 20, 50 + 20); @@ -884,6 +885,12 @@ void SvgFontsDialog::add_font(){ SvgFontsDialog::SvgFontsDialog() : UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS), _add(Gtk::Stock::NEW) { +#if WITH_GTKMM_3_0 + kerning_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); +#else + kerning_slider = Gtk::manage(new Gtk::HScale); +#endif + _add.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_font)); Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 910f79d4c..9be984820 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -20,13 +20,20 @@ #include <gtkmm/drawingarea.h> #include <gtkmm/entry.h> #include <gtkmm/liststore.h> -#include <gtkmm/scale.h> #include <gtkmm/scrolledwindow.h> #include <gtkmm/treeview.h> #include "attributes.h" #include "xml/helper-observer.h" +namespace Gtk { +#if WITH_GTKMM_3_0 +class Scale; +#else +class HScale; +#endif +} + class SPGlyph; class SPGlyphKerning; class SvgFont; @@ -210,7 +217,12 @@ private: GlyphComboBox first_glyph, second_glyph; SPGlyphKerning* kerning_pair; Inkscape::UI::Widget::SpinButton setwidth_spin; - Gtk::HScale kerning_slider; + +#if WITH_GTKMM_3_0 + Gtk::Scale* kerning_slider; +#else + Gtk::HScale* kerning_slider; +#endif class EntryWidget : public Gtk::HBox { diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 43b88e5c6..71fee342a 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -23,6 +23,7 @@ #include <glibmm/i18n.h> #include <glibmm/main.h> +#include <glibmm/timer.h> #include <gdkmm/pixbuf.h> #include "color-item.h" diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 97cd28cdd..a71227861 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -8,8 +8,9 @@ * Johan Engelen <goejendaagh@zonnet.nl> * Abhishek Sharma * John Smith + * Tavmjong Bah * - * Copyright (C) 1999-2012 Authors + * Copyright (C) 1999-2013 Authors * Copyright (C) 2000-2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -32,6 +33,7 @@ extern "C" { #include <gtkmm/stock.h> #include <libnrtype/font-instance.h> #include <libnrtype/font-style-to-pos.h> +#include <libnrtype/font-lister.h> #include <xml/repr.h> #include "macros.h" @@ -305,18 +307,20 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) // FIXME: process result_family/style == QUERY_STYLE_MULTIPLE_DIFFERENT by showing "Many" in the lists - // Get a font_instance using the font-specification attribute stored in SPStyle if available - font_instance *font = font_factory::Default()->FaceFromStyle(query); + Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); - if (font) { + // This is done for us by text-toolbar. No need to do it twice. + // fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); + // fontlister->selection_update(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); - sp_font_selector_set_font (fsel, font, sp_style_css_size_px_to_units(query->font_size.computed, unit) ); - setPreviewText(font, phrase); - font->Unref(); - font=NULL; - } + Glib::ustring fontspec = fontlister->get_fontspec(); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); + double size = sp_style_css_size_px_to_units(query->font_size.computed, unit); + sp_font_selector_set_fontspec(fsel, fontspec, size ); + + setPreviewText (fontspec, phrase); if (query->text_anchor.computed == SP_CSS_TEXT_ANCHOR_START) { if (query->text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY) { @@ -351,30 +355,31 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) blocked = false; } -void TextEdit::setPreviewText (font_instance *font, Glib::ustring phrase) + +void TextEdit::setPreviewText (Glib::ustring font_spec, Glib::ustring phrase) { - if (!font) { + if (font_spec.empty()) { return; } - char *desc = pango_font_description_to_string(font->descr); + Glib::ustring phrase_escaped = Glib::Markup::escape_text( phrase ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * PT_PER_PX; - gchar *const phrase_escaped = g_markup_escape_text(phrase.c_str(), -1); - // Pango font size is in 1024ths of a point - gchar *markup = g_strdup_printf("<span font=\"%s\" size=\"%d\">%s</span>", - desc, (int) (pt_size * PANGO_SCALE ), phrase_escaped); + // C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE ); + std::ostringstream size_st; + size_st << pt_size * PANGO_SCALE; - preview_label.set_markup(markup); + Glib::ustring markup = "<span font=\"" + font_spec + + "\" size=\"" + size_st.str() + "\">" + phrase_escaped + "</span>"; - g_free(desc); - g_free(phrase_escaped); - g_free(markup); + preview_label.set_markup(markup.c_str()); } + SPItem *TextEdit::getSelectedTextItem (void) { if (!SP_ACTIVE_DESKTOP) @@ -430,34 +435,18 @@ void TextEdit::updateObjectText ( SPItem *text ) } } -SPCSSAttr *TextEdit::getTextStyle () +SPCSSAttr *TextEdit::fillTextStyle () { SPCSSAttr *css = sp_repr_css_attr_new (); - // font - font_instance *font = sp_font_selector_get_font (fsel); - - if ( font ) { - Glib::ustring fontName = font_factory::Default()->ConstructFontSpecification(font); - sp_repr_css_set_property (css, "-inkscape-font-specification", fontName.c_str()); - - gchar c[256]; - - font->Family(c, 256); - sp_repr_css_set_property (css, "font-family", c); - - font->Attribute( "weight", c, 256); - sp_repr_css_set_property (css, "font-weight", c); + Glib::ustring fontspec = sp_font_selector_get_fontspec (fsel); - font->Attribute("style", c, 256); - sp_repr_css_set_property (css, "font-style", c); + if( !fontspec.empty() ) { - font->Attribute("stretch", c, 256); - sp_repr_css_set_property (css, "font-stretch", c); - - font->Attribute("variant", c, 256); - sp_repr_css_set_property (css, "font-variant", c); + Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance(); + fontlister->fill_css( css, fontspec ); + // TODO, possibly move this to FontLister::set_css to be shared. Inkscape::CSSOStringStream os; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); @@ -467,9 +456,6 @@ SPCSSAttr *TextEdit::getTextStyle () os << sp_font_selector_get_size (fsel) << sp_style_get_css_unit_string(unit); } sp_repr_css_set_property (css, "font-size", os.str().c_str()); - - font->Unref(); - font=NULL; } // Layout @@ -505,7 +491,7 @@ SPCSSAttr *TextEdit::getTextStyle () void TextEdit::onSetDefault() { - SPCSSAttr *css = getTextStyle (); + SPCSSAttr *css = fillTextStyle (); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); blocked = true; @@ -525,7 +511,7 @@ void TextEdit::onApply() unsigned items = 0; const GSList *item_list = sp_desktop_selection(desktop)->itemList(); - SPCSSAttr *css = getTextStyle (); + SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); for (; item_list != NULL; item_list = item_list->next) { @@ -556,6 +542,13 @@ void TextEdit::onApply() } } + // Update FontLister + Glib::ustring fontspec = sp_font_selector_get_fontspec (fsel); + if( !fontspec.empty() ) { + Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance(); + fontlister->set_fontspec( fontspec, false ); + } + // complete the transaction DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Set text style")); @@ -577,11 +570,11 @@ void TextEdit::onTextChange (GtkTextBuffer *text_buffer, TextEdit *self) GtkTextIter end; gtk_text_buffer_get_bounds (text_buffer, &start, &end); gchar *str = gtk_text_buffer_get_text(text_buffer, &start, &end, TRUE); - font_instance *font = sp_font_selector_get_font(self->fsel); + Glib::ustring fontspec = sp_font_selector_get_fontspec(self->fsel); - if (font) { + if( !fontspec.empty() ) { const gchar *phrase = str && *str ? str : self->samplephrase.c_str(); - self->setPreviewText(font, phrase); + self->setPreviewText(fontspec, phrase); } else { self->preview_label.set_markup(""); } @@ -594,7 +587,7 @@ void TextEdit::onTextChange (GtkTextBuffer *text_buffer, TextEdit *self) self->setasdefault_button.set_sensitive ( true); } -void TextEdit::onFontChange(SPFontSelector * /*fontsel*/, font_instance * font, TextEdit *self) +void TextEdit::onFontChange(SPFontSelector * /*fontsel*/, gchar* fontspec, TextEdit *self) { GtkTextIter start, end; gchar *str; @@ -607,9 +600,9 @@ void TextEdit::onFontChange(SPFontSelector * /*fontsel*/, font_instance * font, gtk_text_buffer_get_bounds (self->text_buffer, &start, &end); str = gtk_text_buffer_get_text (self->text_buffer, &start, &end, TRUE); - if (font) { + if (fontspec) { const gchar *phrase = str && *str ? str : self->samplephrase.c_str(); - self->setPreviewText(font, phrase); + self->setPreviewText(fontspec, phrase); } else { self->preview_label.set_markup(""); } diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index bca6cee90..3fdeea05d 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -7,8 +7,9 @@ * Johan Engelen <goejendaagh@zonnet.nl> * John Smith * Kris De Gussem <Kris.DeGussem@gmail.com> + * Tavmjong Bah * - * Copyright (C) 1999-2012 Authors + * Copyright (C) 1999-2013 Authors * Copyright (C) 2000-2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -100,10 +101,10 @@ protected: * onFontChange updates the dialog UI. The subfunction setPreviewText updates the preview label. * * @param fontsel pointer to SPFontSelector (currently not used). - * @param font pointer to the font instance for the text to be previewed + * @param fontspec for the text to be previewed. * @param self pointer to the current instance of the dialog. */ - static void onFontChange (SPFontSelector *fontsel, font_instance *font, TextEdit *self); + static void onFontChange (SPFontSelector *fontsel, gchar* fontspec, TextEdit *self); /** * Get the selected text off the main canvas. @@ -118,15 +119,15 @@ protected: unsigned getSelectedTextCount (void); /** - * Helper function to create markup from a font definition and display in the preview label. + * Helper function to create markup from a fontspec and display in the preview label. * - * @param font pointer to the font instance for the text to be previewed + * @param fontspec for the text to be previewed * @param phrase text to be shown */ - void setPreviewText (font_instance *font, Glib::ustring phrase); + void setPreviewText (Glib::ustring font_spec, Glib::ustring phrase); void updateObjectText ( SPItem *text ); - SPCSSAttr *getTextStyle (); + SPCSSAttr *fillTextStyle (); /** * Helper function to style radio buttons with icons, tooltips. diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index 31fb3096c..5585f2db4 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -56,8 +56,14 @@ void ColorPicker::setupDialog(const Glib::ustring &title) _colorSelectorDialog.set_title (title); _colorSelectorDialog.set_border_width (4); _colorSelector = SP_COLOR_SELECTOR(sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK)); + +#if WITH_GTKMM_3_0 + _colorSelectorDialog.get_content_area()->pack_start ( + *Glib::wrap(&_colorSelector->vbox), true, true, 0); +#else _colorSelectorDialog.get_vbox()->pack_start ( *Glib::wrap(&_colorSelector->vbox), true, true, 0); +#endif g_signal_connect(G_OBJECT(_colorSelector), "dragged", G_CALLBACK(sp_color_picker_color_mod), (void *)this); diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index b9cc50845..8d960ddc3 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -18,6 +18,7 @@ #include <gtkmm/icontheme.h> #include <gtkmm/stockitem.h> +#include <glibmm/exceptionhandler.h> namespace Inkscape { namespace UI { diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index a38a93fb1..2bfc7e0df 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -54,6 +54,17 @@ Dock::Dock(Gtk::Orientation orientation) { gdl_dock_bar_set_orientation(_gdl_dock_bar, static_cast<GtkOrientation>(orientation)); +#if WITH_GTKMM_3_0 + switch(orientation) { + case Gtk::ORIENTATION_VERTICAL: + _dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); + break; + case Gtk::ORIENTATION_HORIZONTAL: + _dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); + } + + _paned = Gtk::manage(new Gtk::Paned(orientation)); +#else switch (orientation) { case Gtk::ORIENTATION_VERTICAL: _dock_box = Gtk::manage(new Gtk::HBox()); @@ -63,6 +74,7 @@ Dock::Dock(Gtk::Orientation orientation) _dock_box = Gtk::manage(new Gtk::VBox()); _paned = Gtk::manage(new Gtk::HPaned()); } +#endif _scrolled_window->add(*_dock_box); _scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index e5b062ec9..314bf75bf 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -21,7 +21,9 @@ #include <gtkmm/box.h> #include <gtkmm/frame.h> #include <gtkmm/alignment.h> +#include <gtkmm/scale.h> #include <gtkmm/stock.h> +#include <gtkmm/table.h> #include "preferences.h" #include "ui/widget/preferences-widget.h" @@ -49,90 +51,139 @@ namespace Widget { DialogPage::DialogPage() { - this->set_border_width(12); - this->set_col_spacings(12); - this->set_row_spacings(6); + set_border_width(12); + +#if WITH_GTKMM_3_0 + set_orientation(Gtk::ORIENTATION_VERTICAL); + set_column_spacing(12); + set_row_spacing(6); +#else + set_col_spacings(12); + set_row_spacings(6); +#endif } -void DialogPage::add_line(bool indent, Glib::ustring const &label, Gtk::Widget &widget, Glib::ustring const &suffix, const Glib::ustring &tip, bool expand_widget, Gtk::Widget *other_widget) +/** + * Add a widget to the bottom row of the dialog page + * + * \param[in] indent Whether the widget should be indented by one column + * \param[in] label The label text for the widget + * \param[in] widget The widget to add to the page + * \param[in] suffix Text for an optional label at the right of the widget + * \param[in] tip Tooltip text for the widget + * \param[in] expand_widget Whether to expand the widget horizontally + * \param[in] other_widget An optional additional widget to display at the right of the first one + */ +void DialogPage::add_line(bool indent, + Glib::ustring const &label, + Gtk::Widget &widget, + Glib::ustring const &suffix, + const Glib::ustring &tip, + bool expand_widget, + Gtk::Widget *other_widget) { - int start_col; - int row = this->property_n_rows(); - Gtk::Widget* w; - if (expand_widget) - { - w = &widget; - } - else - { - Gtk::HBox* hb = Gtk::manage(new Gtk::HBox()); - hb->set_spacing(12); - hb->pack_start(widget,false,false); - if (other_widget) { - hb->pack_start(*other_widget,false,false); - } - - w = (Gtk::Widget*) hb; - } + if (tip != "") + widget.set_tooltip_text (tip); + + Gtk::Alignment* label_alignment = Gtk::manage(new Gtk::Alignment()); + + Gtk::HBox* hb = Gtk::manage(new Gtk::HBox()); + hb->set_spacing(12); + hb->pack_start(widget, expand_widget, expand_widget); + + // Pack an additional widget into a box with the widget if desired + if (other_widget) + hb->pack_start(*other_widget, expand_widget, expand_widget); + + // Pack the widget into an alignment container so that it can + // be indented if desired + Gtk::Alignment* w_alignment = Gtk::manage(new Gtk::Alignment()); + w_alignment->add(*hb); + +#if WITH_GTKMM_3_0 + w_alignment->set_valign(Gtk::ALIGN_CENTER); +#else + guint row = property_n_rows(); +#endif + + // Add a label in the first column if provided if (label != "") { - Gtk::Label* label_widget; - label_widget = Gtk::manage(new Gtk::Label(label , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true)); + Gtk::Label* label_widget = Gtk::manage(new Gtk::Label(label, Gtk::ALIGN_START, + Gtk::ALIGN_CENTER, true)); label_widget->set_mnemonic_widget(widget); + + // Pack the label into an alignment container so that we can indent it + // if necessary + label_alignment->add(*label_widget); + if (indent) - { - Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment()); - alignment->set_padding(0, 0, 12, 0); - alignment->add(*label_widget); - this->attach(*alignment , 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); - } - else - this->attach(*label_widget , 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); - start_col = 1; + label_alignment->set_padding(0, 0, 12, 0); + +#if WITH_GTKMM_3_0 + label_alignment->set_valign(Gtk::ALIGN_CENTER); + add(*label_alignment); + attach_next_to(*w_alignment, *label_alignment, Gtk::POS_RIGHT, 1, 1); +#else + attach(*label_alignment, 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); +#endif } - else - start_col = 0; - if (start_col == 0 && indent) //indent this widget + // Now add the widget to the bottom of the dialog +#if WITH_GTKMM_3_0 + if (label == "") { - Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment()); - alignment->set_padding(0, 0, 12, 0); - alignment->add(*w); - this->attach(*alignment, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(), 0, 0); - } - else - { - this->attach(*w, start_col, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(), 0, 0); - } + if (indent) + w_alignment->set_padding(0, 0, 12, 0); + + add(*w_alignment); + + GValue width = G_VALUE_INIT; + g_value_init(&width, G_TYPE_INT); + g_value_set_int(&width, 2); + gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(w_alignment->gobj()), "width", &width); + } +#else + // The widget should span two columns if there is no label + int w_col_span = 1; + if (label == "") + w_col_span = 2; + + attach(*w_alignment, 2 - w_col_span, 2, row, row + 1, + Gtk::FILL | Gtk::EXPAND, + Gtk::AttachOptions(), + 0, 0); +#endif + // Add a label on the right of the widget if desired if (suffix != "") { Gtk::Label* suffix_widget = Gtk::manage(new Gtk::Label(suffix , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true)); - if (expand_widget) - this->attach(*suffix_widget, 2, 3, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); - else - ((Gtk::HBox*)w)->pack_start(*suffix_widget,false,false); - } - - if (tip != "") - { - widget.set_tooltip_text (tip); + hb->pack_start(*suffix_widget,false,false); } } void DialogPage::add_group_header(Glib::ustring name) { - int row = this->property_n_rows(); if (name != "") { Gtk::Label* label_widget = Gtk::manage(new Gtk::Label(Glib::ustring(/*"<span size='large'>*/"<b>") + name + Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true)); label_widget->set_use_markup(true); - this->attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); + +#if WITH_GTKMM_3_0 + label_widget->set_valign(Gtk::ALIGN_CENTER); + add(*label_widget); +// if (row != 1) + // set_row_spacing(row - 1, 18); +#else + int row = property_n_rows(); + attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); if (row != 1) - this->set_row_spacing(row - 1, 18); + set_row_spacing(row - 1, 18); +#endif } } @@ -444,8 +495,8 @@ ZoomCorrRulerSlider::on_slider_value_changed() { freeze = true; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/options/zoomcorrection/value", _slider.get_value() / 100.0); - _sb.set_value(_slider.get_value()); + prefs->setDouble("/options/zoomcorrection/value", _slider->get_value() / 100.0); + _sb.set_value(_slider->get_value()); _ruler.queue_draw(); freeze = false; } @@ -459,7 +510,7 @@ ZoomCorrRulerSlider::on_spinbutton_value_changed() freeze = true; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/options/zoomcorrection/value", _sb.get_value() / 100.0); - _slider.set_value(_sb.get_value()); + _slider->set_value(_sb.get_value()); _ruler.queue_draw(); freeze = false; } @@ -498,13 +549,19 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl _ruler.set_size(ruler_width, ruler_height); - _slider.set_size_request(_ruler.width(), -1); - _slider.set_range (lower, upper); - _slider.set_increments (step_increment, page_increment); - _slider.set_value (value); - _slider.set_digits(2); +#if WITH_GTKMM_3_0 + _slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); +#else + _slider = Gtk::manage(new Gtk::HScale()); +#endif + + _slider->set_size_request(_ruler.width(), -1); + _slider->set_range (lower, upper); + _slider->set_increments (step_increment, page_increment); + _slider->set_value (value); + _slider->set_digits(2); - _slider.signal_value_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_slider_value_changed)); + _slider->signal_value_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_slider_value_changed)); _sb.signal_value_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_spinbutton_value_changed)); _unit.signal_changed().connect(sigc::mem_fun(*this, &ZoomCorrRulerSlider::on_unit_changed)); @@ -518,18 +575,28 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl _unit.set_data("sensitive", GINT_TO_POINTER(1)); _unit.setUnit(prefs->getString("/options/zoomcorrection/unit")); - Gtk::Table *table = Gtk::manage(new Gtk::Table()); Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); Gtk::Alignment *alignment2 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); alignment1->add(_sb); alignment2->add(_unit); - table->attach(_slider, 0, 1, 0, 1); +#if WITH_GTKMM_3_0 + Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + table->attach(*_slider, 0, 0, 1, 1); + alignment1->set_halign(Gtk::ALIGN_CENTER); + table->attach(*alignment1, 1, 0, 1, 1); + table->attach(_ruler, 0, 1, 1, 1); + alignment2->set_halign(Gtk::ALIGN_CENTER); + table->attach(*alignment2, 1, 1, 1, 1); +#else + Gtk::Table *table = Gtk::manage(new Gtk::Table()); + table->attach(*_slider, 0, 1, 0, 1); table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0)); table->attach(_ruler, 0, 1, 1, 2); table->attach(*alignment2, 1, 2, 1, 2, static_cast<Gtk::AttachOptions>(0)); +#endif - this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET); + pack_start(*table, Gtk::PACK_SHRINK); } void @@ -539,8 +606,8 @@ PrefSlider::on_slider_value_changed() { freeze = true; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble(_prefs_path, _slider.get_value()); - _sb.set_value(_slider.get_value()); + prefs->setDouble(_prefs_path, _slider->get_value()); + _sb.set_value(_slider->get_value()); freeze = false; } } @@ -553,7 +620,7 @@ PrefSlider::on_spinbutton_value_changed() freeze = true; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(_prefs_path, _sb.get_value()); - _slider.set_value(_sb.get_value()); + _slider->set_value(_sb.get_value()); freeze = false; } } @@ -574,11 +641,17 @@ PrefSlider::init(Glib::ustring const &prefs_path, freeze = false; - _slider.set_range (lower, upper); - _slider.set_increments (step_increment, page_increment); - _slider.set_value (value); - _slider.set_digits(digits); - _slider.signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_slider_value_changed)); +#if WITH_GTKMM_3_0 + _slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); +#else + _slider = Gtk::manage(new Gtk::HScale()); +#endif + + _slider->set_range (lower, upper); + _slider->set_increments (step_increment, page_increment); + _slider->set_value (value); + _slider->set_digits(digits); + _slider->signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_slider_value_changed)); _sb.signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_spinbutton_value_changed)); _sb.set_range (lower, upper); @@ -586,12 +659,20 @@ PrefSlider::init(Glib::ustring const &prefs_path, _sb.set_value (value); _sb.set_digits(digits); - Gtk::Table *table = Gtk::manage(new Gtk::Table()); Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); alignment1->add(_sb); - table->attach(_slider, 0, 1, 0, 1); +#if WITH_GTKMM_3_0 + Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + _slider->set_hexpand(); + table->attach(*_slider, 0, 0, 1, 1); + alignment1->set_halign(Gtk::ALIGN_CENTER); + table->attach(*alignment1, 1, 0, 1, 1); +#else + Gtk::Table *table = Gtk::manage(new Gtk::Table()); + table->attach(*_slider, 0, 1, 0, 1); table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0)); +#endif this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET); } diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 646a8b2fa..e3968045d 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -25,14 +25,26 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/drawingarea.h> -#include <gtkmm/scale.h> + +#if WITH_GTKMM_3_0 +#include <gtkmm/grid.h> +#else #include <gtkmm/table.h> +#endif #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" #include "ui/widget/spinbutton.h" #include "ui/widget/scalar-unit.h" +namespace Gtk { +#if WITH_GTKMM_3_0 +class Scale; +#else +class HScale; +#endif +} + namespace Inkscape { namespace UI { namespace Widget { @@ -137,7 +149,11 @@ private: Inkscape::UI::Widget::SpinButton _sb; UnitMenu _unit; - Gtk::HScale _slider; +#if WITH_GTKMM_3_0 + Gtk::Scale* _slider; +#else + Gtk::HScale* _slider; +#endif ZoomCorrRuler _ruler; bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -155,7 +171,13 @@ private: Glib::ustring _prefs_path; Inkscape::UI::Widget::SpinButton _sb; - Gtk::HScale _slider; + +#if WITH_GTKMM_3_0 + Gtk::Scale* _slider; +#else + Gtk::HScale* _slider; +#endif + bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -251,7 +273,11 @@ protected: void on_changed(); }; +#if WITH_GTKMM_3_0 +class DialogPage : public Gtk::Grid +#else class DialogPage : public Gtk::Table +#endif { public: DialogPage(); diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 9bbcc80f9..fca8a7974 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -142,7 +142,7 @@ void Scalar::update() void Scalar::addSlider() { #if WITH_GTKMM_3_0 - Gtk::HScale *scale = new Gtk::HScale(static_cast<SpinButton*>(_widget)->get_adjustment()); + Gtk::Scale *scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment()); #else Gtk::HScale *scale = new Gtk::HScale( * static_cast<SpinButton*>(_widget)->get_adjustment() ); #endif diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 323b1209c..facbf704c 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -116,11 +116,20 @@ Gtk::Adjustment& SpinSlider::get_adjustment() return _adjustment; } +#if WITH_GTKMM_3_0 +const Gtk::Scale& SpinSlider::get_scale() const +#else const Gtk::HScale& SpinSlider::get_scale() const +#endif { return _scale; } + +#if WITH_GTKMM_3_0 +Gtk::Scale& SpinSlider::get_scale() +#else Gtk::HScale& SpinSlider::get_scale() +#endif { return _scale; } diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index f4a62107b..8a45299e5 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -41,13 +41,14 @@ public: #if WITH_GTKMM_3_0 const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const; Glib::RefPtr<Gtk::Adjustment> get_adjustment(); + const Gtk::Scale& get_scale() const; + Gtk::Scale& get_scale(); #else const Gtk::Adjustment& get_adjustment() const; Gtk::Adjustment& get_adjustment(); -#endif - const Gtk::HScale& get_scale() const; Gtk::HScale& get_scale(); +#endif const Inkscape::UI::Widget::SpinButton& get_spin_button() const; Inkscape::UI::Widget::SpinButton& get_spin_button(); @@ -57,10 +58,11 @@ public: private: #if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> _adjustment; + Gtk::Scale _scale; #else Gtk::Adjustment _adjustment; -#endif Gtk::HScale _scale; +#endif Inkscape::UI::Widget::SpinButton _spin; }; diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 16558f0ee..f92a08d0a 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -73,8 +73,15 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la theLabel1->set_use_underline(); theLabel1->set_alignment(0, 0.5); // align the label with the checkbox text above by indenting 22 px. - _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); + _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); + +#if WITH_GTKMM_3_0 + _hscale = manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); + _hscale->set_range(1.0, 51.0); +#else _hscale = manage (new Gtk::HScale (1.0, 51, 1.0)); +#endif + theLabel1->set_mnemonic_widget (*_hscale); _hscale->set_draw_value (true); _hscale->set_value_pos (Gtk::POS_RIGHT); diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index d0b78e3c1..2184cd52b 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -13,7 +13,12 @@ #include <gtkmm/radiobuttongroup.h> namespace Gtk { - class RadioButton; +class RadioButton; +#if WITH_GTKMM_3_0 +class Scale; +#else +class HScale; +#endif } namespace Inkscape { @@ -55,7 +60,13 @@ protected: void on_toggled(); void update (double val); Gtk::HBox *_hbox; + +#if WITH_GTKMM_3_0 + Gtk::Scale *_hscale; +#else Gtk::HScale *_hscale; +#endif + Gtk::RadioButtonGroup _radio_button_group; Gtk::RadioButton *_button1; Gtk::RadioButton *_button2; |
