summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/panel.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
committerMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
commita168040d5a452544328a1e6ad35aaac351f94d44 (patch)
treefae1ba829f543a473da281bd5fa6e4deabbf6912 /src/ui/widget/panel.cpp
parentRemoved function pointers from SPObject and subclasses. (diff)
parentDutch translation update (diff)
downloadinkscape-a168040d5a452544328a1e6ad35aaac351f94d44.tar.gz
inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.zip
merged from trunk
(bzr r11608.1.56)
Diffstat (limited to 'src/ui/widget/panel.cpp')
-rw-r--r--src/ui/widget/panel.cpp124
1 files changed, 106 insertions, 18 deletions
diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp
index a1ae6a36d..7eb114d0a 100644
--- a/src/ui/widget/panel.cpp
+++ b/src/ui/widget/panel.cpp
@@ -15,8 +15,6 @@
# include <config.h>
#endif
-#include <glibmm/i18n.h>
-
#include <gtkmm/dialog.h> // for Gtk::RESPONSE_*
#include <gtkmm/menu.h>
#include <gtkmm/stock.h>
@@ -24,6 +22,8 @@
#include <gtkmm/radiomenuitem.h>
#include <gtkmm/separatormenuitem.h>
+#include <glibmm/i18n.h>
+
#include <gtk/gtk.h>
#include "panel.h"
@@ -42,7 +42,8 @@ static const int PANEL_SETTING_SIZE = 0;
static const int PANEL_SETTING_MODE = 1;
static const int PANEL_SETTING_SHAPE = 2;
static const int PANEL_SETTING_WRAP = 3;
-static const int PANEL_SETTING_NEXTFREE = 4;
+static const int PANEL_SETTING_BORDER = 4;
+static const int PANEL_SETTING_NEXTFREE = 5;
void Panel::prep() {
@@ -93,7 +94,7 @@ void Panel::_init()
Glib::ustring tmp("<");
_anchor = SP_ANCHOR_CENTER;
- guint panel_size = 0, panel_mode = 0, panel_ratio = 100;
+ guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0;
bool panel_wrap = 0;
if (!_prefs_path.empty()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -101,6 +102,7 @@ void Panel::_init()
panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE);
panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10);
panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 100, 0, 500 );
+ panel_border = prefs->getIntLimited(_prefs_path + "/panel_border", BORDER_NONE, 0, 2 );
}
_menu = new Gtk::Menu();
@@ -198,6 +200,42 @@ void Panel::_init()
}
{
+ Glib::ustring widthItemLabel(C_("Swatches", "Border"));
+
+ //TRANSLATORS: Indicates border of colour swatches
+ const gchar *widthLabels[] = {
+ NC_("Swatches border", "None"),
+ NC_("Swatches border", "Solid"),
+ NC_("Swatches border", "Wide"),
+ };
+
+ Gtk::MenuItem *item = manage( new Gtk::MenuItem(widthItemLabel));
+ Gtk::Menu *type_menu = manage(new Gtk::Menu());
+ item->set_submenu(*type_menu);
+ _menu->append(*item);
+
+ Gtk::RadioMenuItem::Group widthGroup;
+
+ guint values[] = {0, 1, 2};
+ guint hot_index = 0;
+ for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) {
+ // Assume all values are in increasing order
+ if ( values[i] <= panel_border ) {
+ hot_index = i;
+ }
+ }
+ for ( guint i = 0; i < G_N_ELEMENTS(widthLabels); ++i ) {
+ Glib::ustring _label(g_dpgettext2(NULL, "Swatches border", widthLabels[i]));
+ Gtk::RadioMenuItem *_item = manage(new Gtk::RadioMenuItem(widthGroup, _label));
+ type_menu->append(*_item);
+ if ( i <= hot_index ) {
+ _item->set_active(true);
+ }
+ _item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_BORDER, values[i]));
+ }
+ }
+
+ {
//TRANSLATORS: "Wrap" indicates how colour swatches are displayed
Glib::ustring wrap_label(C_("Swatches","Wrap"));
Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrap_label));
@@ -259,6 +297,7 @@ void Panel::_init()
_bounceCall(PANEL_SETTING_MODE, panel_mode);
_bounceCall(PANEL_SETTING_SHAPE, panel_ratio);
_bounceCall(PANEL_SETTING_WRAP, panel_wrap);
+ _bounceCall(PANEL_SETTING_BORDER, panel_border);
}
void Panel::setLabel(Glib::ustring const &label)
@@ -323,7 +362,7 @@ void Panel::present()
void Panel::restorePanelPrefs()
{
- guint panel_size = 0, panel_mode = 0, panel_ratio = 100;
+ guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0;
bool panel_wrap = 0;
if (!_prefs_path.empty()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -331,11 +370,13 @@ void Panel::restorePanelPrefs()
panel_size = prefs->getIntLimited(_prefs_path + "/panel_size", 1, 0, PREVIEW_SIZE_HUGE);
panel_mode = prefs->getIntLimited(_prefs_path + "/panel_mode", 1, 0, 10);
panel_ratio = prefs->getIntLimited(_prefs_path + "/panel_ratio", 000, 0, 500 );
+ panel_border = prefs->getIntLimited(_prefs_path + "/panel_border", BORDER_NONE, 0, 2 );
}
_bounceCall(PANEL_SETTING_SIZE, panel_size);
_bounceCall(PANEL_SETTING_MODE, panel_mode);
_bounceCall(PANEL_SETTING_SHAPE, panel_ratio);
_bounceCall(PANEL_SETTING_WRAP, panel_wrap);
+ _bounceCall(PANEL_SETTING_BORDER, panel_border);
}
sigc::signal<void, int> &Panel::signalResponse()
@@ -360,30 +401,32 @@ void Panel::_bounceCall(int i, int j)
if (_fillable) {
ViewType curr_type = _fillable->getPreviewType();
guint curr_ratio = _fillable->getPreviewRatio();
+ ::BorderStyle curr_border = _fillable->getPreviewBorder();
+
switch (j) {
case 0:
{
- _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio, curr_border);
}
break;
case 1:
{
- _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio, curr_border);
}
break;
case 2:
{
- _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio, curr_border);
}
break;
case 3:
{
- _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio, curr_border);
}
break;
case 4:
{
- _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio);
+ _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio, curr_border);
}
break;
default:
@@ -399,15 +442,16 @@ void Panel::_bounceCall(int i, int j)
if (_fillable) {
::PreviewSize curr_size = _fillable->getPreviewSize();
guint curr_ratio = _fillable->getPreviewRatio();
+ ::BorderStyle curr_border = _fillable->getPreviewBorder();
switch (j) {
case 0:
{
- _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio);
+ _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio, curr_border);
}
break;
case 1:
{
- _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio);
+ _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio, curr_border);
}
break;
default:
@@ -423,7 +467,40 @@ void Panel::_bounceCall(int i, int j)
if ( _fillable ) {
ViewType curr_type = _fillable->getPreviewType();
::PreviewSize curr_size = _fillable->getPreviewSize();
- _fillable->setStyle(curr_size, curr_type, j);
+ ::BorderStyle curr_border = _fillable->getPreviewBorder();
+
+ _fillable->setStyle(curr_size, curr_type, j, curr_border);
+ }
+ break;
+ case PANEL_SETTING_BORDER:
+ if (!_prefs_path.empty()) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt(_prefs_path + "/panel_border", j);
+ }
+ if ( _fillable ) {
+ ::PreviewSize curr_size = _fillable->getPreviewSize();
+ ViewType curr_type = _fillable->getPreviewType();
+ guint curr_ratio = _fillable->getPreviewRatio();
+
+ switch (j) {
+ case 0:
+ {
+ _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_NONE);
+ }
+ break;
+ case 1:
+ {
+ _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_SOLID);
+ }
+ break;
+ case 2:
+ {
+ _fillable->setStyle(curr_size, curr_type, curr_ratio, BORDER_WIDE);
+ }
+ break;
+ default:
+ break;
+ }
}
break;
case PANEL_SETTING_WRAP:
@@ -483,6 +560,7 @@ void Panel::_regItem(Gtk::MenuItem* item, int group, int id)
_menu->append(*item);
item->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), group + PANEL_SETTING_NEXTFREE, id));
item->show();
+
}
void Panel::_handleAction(int /*set_id*/, int /*item_id*/)
@@ -495,31 +573,41 @@ 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) {
+#if WITH_GTKMM_3_0
+ _action_area = new Gtk::ButtonBox();
+ _action_area->set_layout(Gtk::BUTTONBOX_END);
+ _action_area->set_spacing(6);
+#else
_action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6);
+#endif
_action_area->set_border_width(4);
pack_end(*_action_area, Gtk::PACK_SHRINK, 0);
}
_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));