diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2012-10-04 08:06:18 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2012-10-04 08:06:18 +0000 |
| commit | fec1be463b3950772422da45fe4655de40c864e7 (patch) | |
| tree | 2eeef78cb15a7fba9453cfc9c12067c0331818d5 /src/ui | |
| parent | update based on patch 'changes_2012_09_27b.patch' (diff) | |
| parent | extensions. Extrude. allow selection of multiple objects (Bug 1055155) (diff) | |
| download | inkscape-fec1be463b3950772422da45fe4655de40c864e7.tar.gz inkscape-fec1be463b3950772422da45fe4655de40c864e7.zip | |
merge from trunk (r11734)
(bzr r11668.1.22)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/ui/dialog/object-properties.cpp | 48 | ||||
| -rw-r--r-- | src/ui/dialog/tracedialog.cpp | 167 | ||||
| -rw-r--r-- | src/ui/widget/gimpspinscale.c | 9 | ||||
| -rw-r--r-- | src/ui/widget/panel.cpp | 14 | ||||
| -rw-r--r-- | src/ui/widget/panel.h | 6 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 70 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.h | 9 |
8 files changed, 244 insertions, 86 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index b3bcb3fdd..ec7782302 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -42,6 +42,7 @@ set(ui_SRC dialog/filter-effects-dialog.cpp dialog/find.cpp dialog/floating-behavior.cpp + dialog/font-substitution.cpp dialog/glyphs.cpp dialog/guides.cpp dialog/icon-preview.cpp @@ -82,6 +83,7 @@ set(ui_SRC widget/entry.cpp widget/filter-effect-chooser.cpp widget/frame.cpp + widget/gimpspinscale.c widget/imageicon.cpp widget/imagetoggler.cpp widget/labelled.cpp @@ -101,6 +103,7 @@ set(ui_SRC widget/scalar-unit.cpp widget/scalar.cpp widget/selected-style.cpp + widget/spin-scale.cpp widget/spin-slider.cpp widget/spinbutton.cpp widget/style-subject.cpp @@ -117,6 +120,7 @@ set(ui_SRC # Headers clipboard.h control-manager.h + control-types.h icon-names.h previewable.h previewfillable.h @@ -148,6 +152,7 @@ set(ui_SRC dialog/filter-effects-dialog.h dialog/find.h dialog/floating-behavior.h + dialog/font-substitution.h dialog/glyphs.h dialog/guides.h dialog/icon-preview.h @@ -204,6 +209,7 @@ set(ui_SRC widget/entry.h widget/filter-effect-chooser.h widget/frame.h + widget/gimpspinscale.h widget/imageicon.h widget/imagetoggler.h widget/labelled.h @@ -224,6 +230,7 @@ set(ui_SRC widget/scalar-unit.h widget/scalar.h widget/selected-style.h + widget/spin-scale.h widget/spin-slider.h widget/spinbutton.h widget/style-subject.h diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 0aeb3816f..12ee2f762 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -54,7 +54,7 @@ ObjectProperties::ObjectProperties (void) : LabelID(_("_ID:"), 1), LabelLabel(_("_Label:"), 1), LabelTitle(_("_Title:"),1), - LabelDescription(_("_Description"),1), + LabelDescription(_("_Description:"),1), FrameDescription("", FALSE), HBoxCheck(FALSE, 0), CheckTable(1, 2, TRUE), @@ -69,16 +69,15 @@ ObjectProperties::ObjectProperties (void) : subselChangedConn() { //initialize labels for the table at the bottom of the dialog - int_labels.push_back("onclick"); - int_labels.push_back("onmouseover"); - int_labels.push_back("onmouseout"); - int_labels.push_back("onmousedown"); - int_labels.push_back("onmouseup"); - int_labels.push_back("onmousemove"); - int_labels.push_back("onfocusin"); - int_labels.push_back("onfocusout"); - int_labels.push_back("onfocusout"); - int_labels.push_back("onload"); + int_labels.push_back("onclick:"); + int_labels.push_back("onmouseover:"); + int_labels.push_back("onmouseout:"); + int_labels.push_back("onmousedown:"); + int_labels.push_back("onmouseup:"); + int_labels.push_back("onmousemove:"); + int_labels.push_back("onfocusin:"); + int_labels.push_back("onfocusout:"); + int_labels.push_back("onload:"); desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectProperties::setTargetDesktop) ); deskTrack.connect(GTK_WIDGET(gobj())); @@ -101,10 +100,11 @@ void ObjectProperties::MakeWidget(void) TopTable.set_border_width(4); TopTable.set_row_spacings(4); - TopTable.set_col_spacings(4); - contents->pack_start (TopTable, true, true, 0); + TopTable.set_col_spacings(0); + contents->pack_start (TopTable, false, false, 0); /* Create the label for the object id */ + LabelID.set_label (LabelID.get_label() + " "); LabelID.set_alignment (1, 0.5); TopTable.attach (LabelID, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, @@ -124,6 +124,7 @@ void ObjectProperties::MakeWidget(void) EntryID.grab_focus(); /* Create the label for the object label */ + LabelLabel.set_label (LabelLabel.get_label() + " "); LabelLabel.set_alignment (1, 0.5); TopTable.attach (LabelLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, @@ -141,6 +142,7 @@ void ObjectProperties::MakeWidget(void) EntryLabel.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the label for the object title */ + LabelTitle.set_label (LabelTitle.get_label() + " "); LabelTitle.set_alignment (1, 0.5); TopTable.attach (LabelTitle, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, @@ -149,18 +151,17 @@ void ObjectProperties::MakeWidget(void) /* Create the entry box for the object title */ EntryTitle.set_sensitive (FALSE); EntryTitle.set_max_length (256); - TopTable.attach (EntryTitle, 1, 3, 2, 3, + TopTable.attach (EntryTitle, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::AttachOptions(), 0, 0 ); LabelTitle.set_mnemonic_widget (EntryTitle); + // pressing enter in the label field is the same as clicking Set: + EntryTitle.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the frame for the object description */ FrameDescription.set_label_widget (LabelDescription); - FrameDescription.set_padding (4,0,0,0); - - TopTable.attach (FrameDescription, 0, 3, 3, 4, - Gtk::EXPAND | Gtk::FILL, - Gtk::EXPAND | Gtk::FILL, 0, 0 ); + FrameDescription.set_padding (0,0,0,0); + contents->pack_start (FrameDescription, true, true, 0); /* Create the text view box for the object description */ FrameTextDescription.set_border_width(4); @@ -175,8 +176,8 @@ void ObjectProperties::MakeWidget(void) /* Check boxes */ contents->pack_start (HBoxCheck, FALSE, FALSE, 0); - CheckTable.set_border_width(0); - HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 10); + CheckTable.set_border_width(4); + HBoxCheck.pack_start (CheckTable, TRUE, TRUE, 0); /* Hide */ CBHide.set_tooltip_text (_("Check to make the object invisible")); @@ -195,7 +196,9 @@ void ObjectProperties::MakeWidget(void) /* Button for setting the object's id, label, title and description. */ - HBoxCheck.pack_start (BSet, TRUE, TRUE, 10); + CheckTable.attach (BSet, 2, 3, 0, 1, + Gtk::EXPAND | Gtk::FILL, + Gtk::AttachOptions(), 0, 0 ); BSet.signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::label_changed)); /* Create the frame for interactivity options */ @@ -332,7 +335,6 @@ void ObjectProperties::label_changed(void) /* Retrieve the label widget for the object's label */ Glib::ustring label = EntryLabel.get_text(); - g_assert(!label.empty()); /* Give feedback on success of setting the drawing object's label * using the widget's label text diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index a6495c205..1ad827a56 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -26,6 +26,8 @@ #include <glibmm/i18n.h> #include "desktop.h" +#include "desktop-tracker.h" +#include "selection.h" #include "trace/potrace/inkscape-potrace.h" #include "inkscape.h" @@ -83,6 +85,13 @@ class TraceDialogImpl : public TraceDialog void abort(); void previewCallback(); + void previewLiveCallback(); + void onSettingsChange(); + void onSelectionModified( guint flags ); + void onSetDefaults(); + + void setDesktop(SPDesktop *desktop); + void setTargetDesktop(SPDesktop *desktop); //############ General items @@ -90,6 +99,7 @@ class TraceDialogImpl : public TraceDialog Gtk::Button *mainOkButton; Gtk::Button *mainCancelButton; + Gtk::Button *mainResetButton; //######## Left pannel @@ -194,11 +204,40 @@ class TraceDialogImpl : public TraceDialog UI::Widget::Frame previewFrame; Gtk::VBox previewVBox; Gtk::Button previewButton; + Gtk::CheckButton previewLiveButton; + gboolean previewLive; Gtk::Image previewImage; + SPDesktop *desktop; + DesktopTracker deskTrack; + sigc::connection desktopChangeConn; + sigc::connection selectChangedConn; + sigc::connection selectModifiedConn; + }; +void TraceDialogImpl::setDesktop(SPDesktop *desktop) +{ + Panel::setDesktop(desktop); + deskTrack.setBase(desktop); +} +void TraceDialogImpl::setTargetDesktop(SPDesktop *desktop) +{ + if (this->desktop != desktop) { + if (this->desktop) { + selectChangedConn.disconnect(); + selectModifiedConn.disconnect(); + } + this->desktop = desktop; + if (desktop && desktop->selection) { + selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange))); + selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &TraceDialogImpl::onSelectionModified))); + + } + onSettingsChange(); + } +} //######################################################################### //## E V E N T S @@ -294,8 +333,9 @@ void TraceDialogImpl::potraceProcess(bool do_i_trace) { int width = preview->get_width(); int height = preview->get_height(); - double scaleFX = 200.0 / (double)width; - double scaleFY = 200.0 / (double)height; + const Gtk::Allocation& vboxAlloc = previewImage.get_allocation(); + double scaleFX = vboxAlloc.get_width() / (double)width; + double scaleFY = vboxAlloc.get_height() / (double)height; double scaleFactor = scaleFX > scaleFY ? scaleFY : scaleFX; int newWidth = (int) (((double)width) * scaleFactor); int newHeight = (int) (((double)height) * scaleFactor); @@ -351,6 +391,58 @@ void TraceDialogImpl::abort() //######################################################################### /** + * Callback for when any setting changes + */ +void TraceDialogImpl::onSettingsChange() +{ + if (previewLive) { + previewCallback(); + } +} + +void TraceDialogImpl::onSelectionModified( guint flags ) +{ + if (flags & ( SP_OBJECT_MODIFIED_FLAG | + SP_OBJECT_PARENT_MODIFIED_FLAG | + SP_OBJECT_STYLE_MODIFIED_FLAG) ) { + onSettingsChange(); + } +} + +/** + * Callback for when users resets defaults + */ +void TraceDialogImpl::onSetDefaults() +{ + + // temporarily disable live update + gboolean wasLive = previewLive; + previewLive = false; + + modeBrightnessRadioButton.set_active(true); + modeBrightnessSpinner.set_value(0.45); + modeCannyHiSpinner.set_value(0.65); + modeMultiScanNrColorSpinner.set_value(8.0); + modeMultiScanNrColorSpinner.set_value(8.0); + optionsSpecklesSizeSpinner.set_value(2); + optionsCornersThresholdSpinner.set_value(1.0); + optionsOptimToleranceSpinner.set_value(0.2); + + modeInvertButton.set_active(false); + modeMultiScanSmoothButton.set_active(true); + modeMultiScanStackButton.set_active(true); + modeMultiScanBackgroundButton.set_active(false); + optionsSpecklesButton.set_active(true); + optionsCornersButton.set_active(true); + optionsOptimButton.set_active(true); + sioxButton.set_active(false); + + previewLive = wasLive; + onSettingsChange(); + +} + +/** * Callback from the Preview button. Can be called from elsewhere. */ void TraceDialogImpl::previewCallback() @@ -359,24 +451,31 @@ void TraceDialogImpl::previewCallback() } /** + * Callback from the Preview Live button. + */ +void TraceDialogImpl::previewLiveCallback() +{ + previewLive = previewLiveButton.get_active(); + previewButton.set_sensitive(!previewLive); + onSettingsChange(); +} + +/** * Default response from the dialog. Let's intercept it */ void TraceDialogImpl::responseCallback(int response_id) { - if (response_id == GTK_RESPONSE_OK) - { - // for now, we assume potrace, as it's the only one we have - potraceProcess(true); - } - else if (response_id == GTK_RESPONSE_CANCEL) - { + if (response_id == GTK_RESPONSE_OK) { + // for now, we assume potrace, as it's the only one we have + potraceProcess(true); + } else if (response_id == GTK_RESPONSE_CANCEL) { abort(); - } - else - { + } else if (response_id == GTK_RESPONSE_HELP) { + onSetDefaults(); + } else { hide(); return; - } + } } @@ -417,6 +516,7 @@ TraceDialogImpl::TraceDialogImpl() : modeBrightnessSpinner.set_value(0.45); modeBrightnessBox.pack_end(modeBrightnessSpinner, false, false, MARGIN); modeBrightnessSpinner.set_tooltip_text(_("Brightness cutoff for black/white")); + modeBrightnessSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeBrightnessSpinnerLabel.set_label(_("_Threshold:")); modeBrightnessSpinnerLabel.set_use_underline(true); @@ -435,6 +535,8 @@ TraceDialogImpl::TraceDialogImpl() : modeCannyRadioButton.set_use_underline(true); modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN); modeCannyRadioButton.set_tooltip_text(_("Trace with optimal edge detection by J. Canny's algorithm")); + modeCannyRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); + /* modeCannyBox.pack_start(modeCannySeparator); modeCannyLoSpinnerLabel.set_label(_("Low")); @@ -451,6 +553,7 @@ TraceDialogImpl::TraceDialogImpl() : modeCannyHiSpinner.set_value(0.65); modeCannyBox.pack_end(modeCannyHiSpinner, false, false, MARGIN); modeCannyHiSpinner.set_tooltip_text(_("Brightness cutoff for adjacent pixels (determines edge thickness)")); + modeCannyHiSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeCannyHiSpinnerLabel.set_label(_("T_hreshold:")); modeCannyHiSpinnerLabel.set_use_underline(true); @@ -469,6 +572,7 @@ TraceDialogImpl::TraceDialogImpl() : modeQuantRadioButton.set_use_underline(true); modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN); modeQuantRadioButton.set_tooltip_text(_("Trace along the boundaries of reduced colors")); + modeQuantRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeQuantNrColorSpinner.set_digits(0); modeQuantNrColorSpinner.set_increments(1.0, 0); @@ -476,6 +580,7 @@ TraceDialogImpl::TraceDialogImpl() : modeQuantNrColorSpinner.set_value(8.0); modeQuantBox.pack_end(modeQuantNrColorSpinner, false, false, MARGIN); modeQuantNrColorSpinner.set_tooltip_text(_("The number of reduced colors")); + modeQuantNrColorSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeQuantNrColorLabel.set_label(_("_Colors:")); modeQuantNrColorLabel.set_mnemonic_widget(modeQuantNrColorSpinner); @@ -491,6 +596,7 @@ TraceDialogImpl::TraceDialogImpl() : modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN); modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN); modeInvertButton.set_tooltip_text(_("Invert black and white regions")); + modeInvertButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeBrightnessFrame.add(modeBrightnessVBox); modePageBox.pack_start(modeBrightnessFrame, false, false, 0); @@ -504,6 +610,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanBrightnessRadioButton.set_use_underline(true); modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN); modeMultiScanBrightnessRadioButton.set_tooltip_text(_("Trace the given number of brightness levels")); + modeMultiScanBrightnessRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanNrColorSpinner.set_digits(0); modeMultiScanNrColorSpinner.set_increments(1.0, 0); @@ -515,6 +622,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanNrColorLabel.set_mnemonic_widget(modeMultiScanNrColorSpinner); modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN); modeMultiScanNrColorSpinner.set_tooltip_text(_("The desired number of scans")); + modeMultiScanNrColorSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN); @@ -523,6 +631,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanColorRadioButton.set_use_underline(true); modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN); modeMultiScanColorRadioButton.set_tooltip_text(_("Trace the given number of reduced colors")); + modeMultiScanColorRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN); @@ -531,6 +640,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanMonoRadioButton.set_use_underline(true); modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN); modeMultiScanMonoRadioButton.set_tooltip_text(_("Same as Colors, but the result is converted to grayscale")); + modeMultiScanMonoRadioButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN); @@ -540,6 +650,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanSmoothButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN); modeMultiScanSmoothButton.set_tooltip_text(_("Apply Gaussian blur to the bitmap before tracing")); + modeMultiScanSmoothButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); // TRANSLATORS: "Stack" is a verb here modeMultiScanStackButton.set_label(_("Stac_k scans")); @@ -547,6 +658,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanStackButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN); modeMultiScanStackButton.set_tooltip_text(_("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)")); + modeMultiScanStackButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanBackgroundButton.set_label(_("Remo_ve background")); @@ -555,6 +667,7 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN); // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan modeMultiScanBackgroundButton.set_tooltip_text(_("Remove bottom (background) layer when done")); + modeMultiScanBackgroundButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); modeMultiScanVBox.pack_start(modeMultiScanHBox4, false, false, MARGIN); @@ -577,12 +690,14 @@ TraceDialogImpl::TraceDialogImpl() : optionsSpecklesButton.set_use_underline(true); optionsSpecklesButton.set_tooltip_text(_("Ignore small spots (speckles) in the bitmap")); optionsSpecklesButton.set_active(true); + optionsSpecklesButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsSpecklesBox.pack_start(optionsSpecklesButton, false, false, MARGIN); optionsSpecklesSizeSpinner.set_digits(0); optionsSpecklesSizeSpinner.set_increments(1, 0); optionsSpecklesSizeSpinner.set_range(0, 1000); optionsSpecklesSizeSpinner.set_value(2); optionsSpecklesSizeSpinner.set_tooltip_text(_("Speckles of up to this many pixels will be suppressed")); + optionsSpecklesSizeSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN); optionsSpecklesSizeLabel.set_label(_("S_ize:")); optionsSpecklesSizeLabel.set_use_underline(true); @@ -593,6 +708,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsCornersButton.set_use_underline(true); optionsCornersButton.set_tooltip_text(_("Smooth out sharp corners of the trace")); optionsCornersButton.set_active(true); + optionsCornersButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsCornersBox.pack_start(optionsCornersButton, false, false, MARGIN); optionsCornersThresholdSpinner.set_digits(2); optionsCornersThresholdSpinner.set_increments(0.01, 0); @@ -600,6 +716,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsCornersThresholdSpinner.set_value(1.0); optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN); optionsCornersThresholdSpinner.set_tooltip_text(_("Increase this to smooth corners more")); + optionsCornersThresholdSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsCornersThresholdLabel.set_label(_("_Threshold:")); optionsCornersThresholdLabel.set_use_underline(true); optionsCornersThresholdLabel.set_mnemonic_widget(optionsCornersThresholdSpinner); @@ -609,6 +726,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsOptimButton.set_use_underline(true); optionsOptimButton.set_active(true); optionsOptimButton.set_tooltip_text(_("Try to optimize paths by joining adjacent Bezier curve segments")); + optionsOptimButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsOptimBox.pack_start(optionsOptimButton, false, false, MARGIN); optionsOptimToleranceSpinner.set_digits(2); optionsOptimToleranceSpinner.set_increments(0.05, 0); @@ -616,6 +734,7 @@ TraceDialogImpl::TraceDialogImpl() : optionsOptimToleranceSpinner.set_value(0.2); optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN); optionsOptimToleranceSpinner.set_tooltip_text(_("Increase this to reduce the number of nodes in the trace by more aggressive optimization")); + optionsOptimToleranceSpinner.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &TraceDialogImpl::onSettingsChange) ); optionsOptimToleranceLabel.set_label(_("To_lerance:")); optionsOptimToleranceLabel.set_use_underline(true); optionsOptimToleranceLabel.set_mnemonic_widget(optionsOptimToleranceSpinner); @@ -645,7 +764,7 @@ TraceDialogImpl::TraceDialogImpl() : //#### end left panel - mainHBox.pack_start(leftVBox); + mainHBox.pack_start(leftVBox, false, false, 0); //#### begin right panel @@ -658,12 +777,20 @@ TraceDialogImpl::TraceDialogImpl() : rightVBox.pack_start(sioxBox, false, false, 0); //## preview + Gtk::HBox *previewButtonHBox = manage(new Gtk::HBox(false, MARGIN )); + previewLiveButton.set_label(_("Live Preview")); + previewLiveButton.set_use_underline(true); + previewLiveCallback(); + previewLiveButton.signal_clicked().connect( + sigc::mem_fun(*this, &TraceDialogImpl::previewLiveCallback) ); previewButton.set_label(_("_Update")); previewButton.set_use_underline(true); previewButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) ); - previewVBox.pack_end(previewButton, false, false, 0); + previewButtonHBox->pack_start(previewLiveButton, false, false, 0); + previewButtonHBox->pack_end(previewButton, true, true, 0); + previewVBox.pack_end(*previewButtonHBox, false, false, 0); // I guess it's correct to call the "intermediate bitmap" a preview of the trace previewButton.set_tooltip_text(_("Preview the intermediate bitmap with the current settings, without actual tracing")); previewImage.set_size_request(200,200); @@ -677,11 +804,13 @@ TraceDialogImpl::TraceDialogImpl() : //#### end right panel - mainHBox.pack_start(rightVBox); + mainHBox.pack_start(rightVBox, true, true, 0); //#### Global stuff contents->pack_start(mainHBox); + mainResetButton = addResponseButton(_("Reset"), GTK_RESPONSE_HELP, true); + mainResetButton ->set_tooltip_text(_("Reset all settings to defaults")); //## The OK button mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL); @@ -694,6 +823,9 @@ TraceDialogImpl::TraceDialogImpl() : show_all_children(); + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &TraceDialogImpl::setTargetDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); + //## Connect the signal signalResponse().connect( sigc::mem_fun(*this, &TraceDialogImpl::responseCallback)); @@ -714,6 +846,9 @@ TraceDialog &TraceDialog::getInstance() */ TraceDialogImpl::~TraceDialogImpl() { + selectChangedConn.disconnect(); + selectModifiedConn.disconnect(); + desktopChangeConn.disconnect(); } diff --git a/src/ui/widget/gimpspinscale.c b/src/ui/widget/gimpspinscale.c index 1b7ac7bfe..df39b9644 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/ui/widget/gimpspinscale.c @@ -432,7 +432,11 @@ static gboolean gdk_cairo_region (cr, event->region); cairo_clip (cr); +#if GTK_CHECK_VERSION(2, 24,0) w = gdk_window_get_width (event->window); +#else + gdk_drawable_get_size (event->window, &w, NULL); +#endif #endif @@ -682,7 +686,12 @@ gimp_spin_scale_change_value (GtkWidget *widget, gint width; gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper); + +#if GTK_CHECK_VERSION(2, 24,0) width = gdk_window_get_width (text_window); +#else + gdk_drawable_get_size (text_window, &width, NULL); +#endif #endif diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 1f945ada6..42435f298 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -572,21 +572,21 @@ void Panel::_apply() g_warning("Apply button clicked for panel [Panel::_apply()]"); } -Gtk::Button *Panel::addResponseButton(const Glib::ustring &button_text, int response_id) +Gtk::Button *Panel::addResponseButton(const Glib::ustring &button_text, int response_id, bool pack_start) { Gtk::Button *button = new Gtk::Button(button_text); - _addResponseButton(button, response_id); + _addResponseButton(button, response_id, pack_start); return button; } -Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id) +Gtk::Button *Panel::addResponseButton(const Gtk::StockID &stock_id, int response_id, bool pack_start) { Gtk::Button *button = new Gtk::Button(stock_id); - _addResponseButton(button, response_id); + _addResponseButton(button, response_id, pack_start); return button; } -void Panel::_addResponseButton(Gtk::Button *button, int response_id) +void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_start) { // Create a button box for the response buttons if it's the first button to be added if (!_action_area) { @@ -597,6 +597,10 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id) _action_area->pack_end(*button); + if (pack_start) { + _action_area->set_child_secondary( *button , true); + } + if (response_id != 0) { // Re-emit clicked signals as response signals button->signal_clicked().connect(sigc::bind(_signal_response.make_slot(), response_id)); diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 2d92d65c9..b4cc04809 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -96,8 +96,8 @@ public: /* Methods providing a Gtk::Dialog like interface for adding buttons that emit Gtk::RESPONSE * signals on click. */ - Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id); - Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id); + Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id, bool pack_start=false); + Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id, bool pack_start=false); void setDefaultResponse(int response_id); void setResponseSensitive(int response_id, bool setting); @@ -119,7 +119,7 @@ protected: virtual void _handleResponse(int response_id); /* Helper methods */ - void _addResponseButton(Gtk::Button *button, int response_id); + void _addResponseButton(Gtk::Button *button, int response_id, bool pack_start=false); Inkscape::Selection *_getSelection(); /** diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a4313f677..e5992958b 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -23,6 +23,7 @@ #include "desktop-handles.h" #include "style.h" #include "desktop-style.h" +#include "sp-namedview.h" #include "sp-linear-gradient-fns.h" #include "sp-radial-gradient-fns.h" #include "sp-pattern.h" @@ -38,7 +39,6 @@ #include "sp-gradient.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" -#include "helper/units.h" #include "event-context.h" #include "message-context.h" #include "verbs.h" @@ -144,10 +144,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_blocked (false), - _popup_px(_sw_group), - _popup_pt(_sw_group), - _popup_mm(_sw_group), - + _unit_mis(NULL), _sw_unit(NULL) { _drop[0] = _drop[1] = 0; @@ -298,34 +295,39 @@ SelectedStyle::SelectedStyle(bool /*layout*/) } { - _popup_px.add(*(new Gtk::Label(_("px"), 0.0, 0.5))); - _popup_px.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_px)); - _popup_sw.attach(_popup_px, 0,1, 0,1); - - _popup_pt.add(*(new Gtk::Label(_("pt"), 0.0, 0.5))); - _popup_pt.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_pt)); - _popup_sw.attach(_popup_pt, 0,1, 1,2); - - _popup_mm.add(*(new Gtk::Label(_("mm"), 0.0, 0.5))); - _popup_mm.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_mm)); - _popup_sw.attach(_popup_mm, 0,1, 2,3); + int row = 0; + + // List of units should match with Fill/Stroke dialog stroke style width list + for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) { + SPUnit const *u = (SPUnit*)l->data; + Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); + mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5))); + _unit_mis = g_slist_append(_unit_mis, mi); + mi->signal_activate().connect(sigc::bind<SPUnitId>(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id)); + _popup_sw.attach(*mi, 0,1, row, row+1); + row++; + } - _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, 3,4); + _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); + row++; for (guint i = 0; i < G_N_ELEMENTS(_sw_presets_str); ++i) { Gtk::MenuItem *mi = Gtk::manage(new Gtk::MenuItem()); mi->add(*(new Gtk::Label(_sw_presets_str[i], 0.0, 0.5))); mi->signal_activate().connect(sigc::bind<int>(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i)); - _popup_sw.attach(*mi, 0,1, 4+i, 5+i); + _popup_sw.attach(*mi, 0,1, row, row+1); + row++; } - guint i = G_N_ELEMENTS(_sw_presets_str) + 5; - - _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, i,i+1); + _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); + row++; _popup_sw_remove.add(*(new Gtk::Label(_("Remove"), 0.0, 0.5))); _popup_sw_remove.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_remove)); - _popup_sw.attach(_popup_sw_remove, 0,1, i+1,i+2); + _popup_sw.attach(_popup_sw_remove, 0,1, row, row+1); + row++; + + sp_set_font_size_smaller (GTK_WIDGET(_popup_sw.gobj())); _popup_sw.show_all(); } @@ -447,7 +449,17 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - //_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + _sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_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); + if (mi && mi->get_label() == Glib::ustring(_sw_unit->abbr)) { + mi->set_active(); + break; + } + } } void SelectedStyle::dragDataReceived( GtkWidget */*widget*/, @@ -887,16 +899,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_px() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PX)); - update(); -} -void SelectedStyle::on_popup_pt() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PT)); - update(); -} -void SelectedStyle::on_popup_mm() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_MM)); +void SelectedStyle::on_popup_units(SPUnitId id) { + _sw_unit = (SPUnit *) &(sp_unit_get_by_id(id)); update(); } diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 542983b53..a9e9d7274 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -27,6 +27,7 @@ #include <sigc++/sigc++.h> #include "rotateable.h" +#include "helper/units.h" class SPDesktop; class SPUnit; @@ -250,12 +251,8 @@ protected: Gtk::Menu _popup_sw; Gtk::RadioButtonGroup _sw_group; - Gtk::RadioMenuItem _popup_px; - void on_popup_px(); - Gtk::RadioMenuItem _popup_pt; - void on_popup_pt(); - Gtk::RadioMenuItem _popup_mm; - void on_popup_mm(); + GSList *_unit_mis; + void on_popup_units(SPUnitId id); void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; |
