summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/widget/button.cpp (renamed from src/widgets/button.cpp)52
-rw-r--r--src/ui/widget/button.h (renamed from src/widgets/button.h)41
-rw-r--r--src/widgets/CMakeLists.txt2
-rw-r--r--src/widgets/desktop-widget.cpp34
-rw-r--r--src/widgets/desktop-widget.h11
-rw-r--r--src/widgets/toolbox.cpp18
7 files changed, 85 insertions, 75 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index a076a58c7..a0a540970 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -147,6 +147,7 @@ set(ui_SRC
widget/iconrenderer.cpp
widget/alignment-selector.cpp
widget/anchor-selector.cpp
+ widget/button.cpp
widget/clipmaskicon.cpp
widget/color-entry.cpp
widget/color-icc-selector.cpp
@@ -370,6 +371,7 @@ set(ui_SRC
widget/alignment-selector.h
widget/anchor-selector.h
widget/attr-widget.h
+ widget/button.h
widget/clipmaskicon.h
widget/color-entry.h
widget/color-icc-selector.h
diff --git a/src/widgets/button.cpp b/src/ui/widget/button.cpp
index 199a69b34..ac6705577 100644
--- a/src/widgets/button.cpp
+++ b/src/ui/widget/button.cpp
@@ -22,7 +22,11 @@
#include "ui/icon-loader.h"
#include "ui/interface.h"
-SPButton::~SPButton()
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+Button::~Button()
{
if (_action) {
_c_set_active.disconnect();
@@ -39,7 +43,7 @@ SPButton::~SPButton()
}
void
-SPButton::get_preferred_width_vfunc(int &minimal_width, int &natural_width) const
+Button::get_preferred_width_vfunc(int &minimal_width, int &natural_width) const
{
auto child = get_child();
@@ -60,7 +64,7 @@ SPButton::get_preferred_width_vfunc(int &minimal_width, int &natural_width) cons
}
void
-SPButton::get_preferred_height_vfunc(int &minimal_height, int &natural_height) const
+Button::get_preferred_height_vfunc(int &minimal_height, int &natural_height) const
{
auto child = get_child();
@@ -81,15 +85,15 @@ SPButton::get_preferred_height_vfunc(int &minimal_height, int &natural_height) c
}
void
-SPButton::on_clicked()
+Button::on_clicked()
{
- if (_type == SP_BUTTON_TYPE_TOGGLE) {
+ if (_type == BUTTON_TYPE_TOGGLE) {
Gtk::Button::on_clicked();
}
}
bool
-SPButton::process_event(GdkEvent *event)
+Button::process_event(GdkEvent *event)
{
switch (event->type) {
case GDK_2BUTTON_PRESS:
@@ -106,15 +110,15 @@ SPButton::process_event(GdkEvent *event)
}
void
-SPButton::perform_action()
+Button::perform_action()
{
if (_action) {
sp_action_perform(_action, nullptr);
}
}
-SPButton::SPButton(GtkIconSize size,
- SPButtonType type,
+Button::Button(GtkIconSize size,
+ ButtonType type,
SPAction *action,
SPAction *doubleclick_action)
:
@@ -131,9 +135,9 @@ SPButton::SPButton(GtkIconSize size,
set_can_focus(false);
set_can_default(false);
- _on_clicked = signal_clicked().connect(sigc::mem_fun(*this, &SPButton::perform_action));
+ _on_clicked = signal_clicked().connect(sigc::mem_fun(*this, &Button::perform_action));
- signal_event().connect(sigc::mem_fun(*this, &SPButton::process_event));
+ signal_event().connect(sigc::mem_fun(*this, &Button::process_event));
set_action(action);
@@ -146,7 +150,7 @@ SPButton::SPButton(GtkIconSize size,
}
void
-SPButton::toggle_set_down(bool down)
+Button::toggle_set_down(bool down)
{
_on_clicked.block();
set_active(down);
@@ -154,7 +158,7 @@ SPButton::toggle_set_down(bool down)
}
void
-SPButton::set_doubleclick_action(SPAction *action)
+Button::set_doubleclick_action(SPAction *action)
{
if (_doubleclick_action) {
g_object_unref(_doubleclick_action);
@@ -166,7 +170,7 @@ SPButton::set_doubleclick_action(SPAction *action)
}
void
-SPButton::set_action(SPAction *action)
+Button::set_action(SPAction *action)
{
Gtk::Widget *child;
@@ -184,7 +188,7 @@ SPButton::set_action(SPAction *action)
if (action) {
g_object_ref(action);
_c_set_active = action->signal_set_active.connect(
- sigc::mem_fun(*this, &SPButton::action_set_active));
+ sigc::mem_fun(*this, &Button::action_set_active));
_c_set_sensitive = action->signal_set_sensitive.connect(
sigc::mem_fun(*this, &Gtk::Widget::set_sensitive));
@@ -200,9 +204,9 @@ SPButton::set_action(SPAction *action)
}
void
-SPButton::action_set_active(bool active)
+Button::action_set_active(bool active)
{
- if (_type != SP_BUTTON_TYPE_TOGGLE) {
+ if (_type != BUTTON_TYPE_TOGGLE) {
return;
}
@@ -213,7 +217,7 @@ SPButton::action_set_active(bool active)
}
void
-SPButton::set_composed_tooltip(SPAction *action)
+Button::set_composed_tooltip(SPAction *action)
{
if (action) {
unsigned int shortcut = sp_shortcut_get_primary(action->verb);
@@ -236,8 +240,8 @@ SPButton::set_composed_tooltip(SPAction *action)
}
}
-SPButton::SPButton(GtkIconSize size,
- SPButtonType type,
+Button::Button(GtkIconSize size,
+ ButtonType type,
Inkscape::UI::View::View *view,
const gchar *name,
const gchar *tip)
@@ -254,14 +258,18 @@ SPButton::SPButton(GtkIconSize size,
set_can_focus(false);
set_can_default(false);
- _on_clicked = signal_clicked().connect(sigc::mem_fun(*this, &SPButton::perform_action));
- signal_event().connect(sigc::mem_fun(*this, &SPButton::process_event));
+ _on_clicked = signal_clicked().connect(sigc::mem_fun(*this, &Button::perform_action));
+ signal_event().connect(sigc::mem_fun(*this, &Button::process_event));
auto action = sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, nullptr);
set_action(action);
g_object_unref(action);
}
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
/*
Local Variables:
mode:c++
diff --git a/src/widgets/button.h b/src/ui/widget/button.h
index 736eed273..ab559e4e6 100644
--- a/src/widgets/button.h
+++ b/src/ui/widget/button.h
@@ -22,21 +22,17 @@ namespace UI {
namespace View {
class View;
}
-}
-}
-enum SPButtonType {
- SP_BUTTON_TYPE_NORMAL,
- SP_BUTTON_TYPE_TOGGLE
-};
+namespace Widget {
-struct SPBChoiceData {
- guchar *px;
+enum ButtonType {
+ BUTTON_TYPE_NORMAL,
+ BUTTON_TYPE_TOGGLE
};
-class SPButton : public Gtk::ToggleButton{
+class Button : public Gtk::ToggleButton{
private:
- SPButtonType _type;
+ ButtonType _type;
GtkIconSize _lsize;
unsigned int _psize;
SPAction *_action;
@@ -60,24 +56,25 @@ protected:
void on_clicked() override;
public:
- SPButton(GtkIconSize size,
- SPButtonType type,
- SPAction *action,
- SPAction *doubleclick_action);
+ Button(GtkIconSize size,
+ ButtonType type,
+ SPAction *action,
+ SPAction *doubleclick_action);
- SPButton(GtkIconSize size,
- SPButtonType type,
- Inkscape::UI::View::View *view,
- const gchar *name,
- const gchar *tip);
+ Button(GtkIconSize size,
+ ButtonType type,
+ Inkscape::UI::View::View *view,
+ const gchar *name,
+ const gchar *tip);
- ~SPButton();
+ ~Button();
void toggle_set_down(bool down);
};
-#define SP_BUTTON_IS_DOWN(b) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (b))
-
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
#endif // !SEEN_SP_BUTTON_H
/*
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 4bd1504f7..1180ed736 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -2,7 +2,6 @@
add_subdirectory(gimp)
set(widgets_SRC
- button.cpp
desktop-widget.cpp
eek-preview.cpp
ege-adjustment-action.cpp
@@ -31,7 +30,6 @@ set(widgets_SRC
# -------
# Headers
- button.h
desktop-widget.h
eek-preview.h
ege-adjustment-action.h
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index cc92f0f78..dab0e5fdf 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -33,8 +33,6 @@
#include <gtkmm/separator.h>
#include <gtkmm/separatormenuitem.h>
-
-
#include <gdkmm/types.h>
#if GTK_CHECK_VERSION(3,20,0)
#include <gdkmm/seat.h>
@@ -76,6 +74,7 @@
#include "ui/interface.h"
#include "ui/tools/box3d-tool.h"
#include "ui/uxmanager.h"
+#include "ui/widget/button.h"
#include "ui/widget/dock.h"
#include "ui/widget/ink-select-one-action.h"
#include "ui/widget/layer-selector.h"
@@ -86,7 +85,6 @@
#include "util/units.h"
// We're in the "widgets" directory, so no need to explicitly prefix these:
-#include "button.h"
#include "gimp/ruler.h"
#include "spinbutton-events.h"
#include "spw-utilities.h"
@@ -382,11 +380,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
// Lock guides button
- dtw->_guides_lock = Gtk::manage(new SPButton( GTK_ICON_SIZE_MENU,
- SP_BUTTON_TYPE_TOGGLE,
- nullptr,
- INKSCAPE_ICON("object-locked"),
- _("Toggle lock of all guides in the document")));
+ dtw->_guides_lock = Gtk::manage(new Inkscape::UI::Widget::Button(GTK_ICON_SIZE_MENU,
+ Inkscape::UI::Widget::BUTTON_TYPE_TOGGLE,
+ nullptr,
+ INKSCAPE_ICON("object-locked"),
+ _("Toggle lock of all guides in the document")));
auto guides_lock_style_provider = Gtk::CssProvider::create();
guides_lock_style_provider->load_from_data("GtkWidget { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; }");
@@ -440,11 +438,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->_canvas_tbl->attach(*dtw->_vscrollbar_box, 2, 0, 1, 2);
// Sticky zoom button
- dtw->_sticky_zoom = Gtk::manage(new SPButton( GTK_ICON_SIZE_MENU,
- SP_BUTTON_TYPE_TOGGLE,
- nullptr,
- INKSCAPE_ICON("zoom-original"),
- _("Zoom drawing if window size changes")));
+ dtw->_sticky_zoom = Gtk::manage(new Inkscape::UI::Widget::Button(GTK_ICON_SIZE_MENU,
+ Inkscape::UI::Widget::BUTTON_TYPE_TOGGLE,
+ nullptr,
+ INKSCAPE_ICON("zoom-original"),
+ _("Zoom drawing if window size changes")));
dtw->_sticky_zoom->set_name("StickyZoom");
dtw->_sticky_zoom->set_active(prefs->getBool("/options/stickyzoom/value"));
dtw->_sticky_zoom->signal_toggled().connect(sigc::mem_fun(dtw, &SPDesktopWidget::sticky_zoom_toggled));
@@ -464,11 +462,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
tip = act->tip;
}
}
- dtw->_cms_adjust = Gtk::manage(new SPButton( GTK_ICON_SIZE_MENU,
- SP_BUTTON_TYPE_TOGGLE,
- nullptr,
- INKSCAPE_ICON("color-management"),
- tip ));
+ dtw->_cms_adjust = Gtk::manage(new Inkscape::UI::Widget::Button(GTK_ICON_SIZE_MENU,
+ Inkscape::UI::Widget::BUTTON_TYPE_TOGGLE,
+ nullptr,
+ INKSCAPE_ICON("color-management"),
+ tip ));
dtw->_cms_adjust->set_name("CMS_Adjust");
#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h
index a16dbd2c7..078508fa5 100644
--- a/src/widgets/desktop-widget.h
+++ b/src/widgets/desktop-widget.h
@@ -26,7 +26,6 @@
// forward declaration
typedef struct _EgeColorProfTracker EgeColorProfTracker;
-class SPButton;
struct SPCanvas;
struct SPCanvasItem;
class SPDesktop;
@@ -43,6 +42,14 @@ class SpinButton;
class ToggleButton;
}
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+class Button;
+}
+}
+}
+
#define SP_TYPE_DESKTOP_WIDGET SPDesktopWidget::getType()
#define SP_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget))
#define SP_DESKTOP_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass))
@@ -109,7 +116,7 @@ private:
Gtk::ToggleButton *_guides_lock;
- SPButton *_cms_adjust;
+ Inkscape::UI::Widget::Button *_cms_adjust;
Gtk::ToggleButton *_sticky_zoom;
Gtk::Grid *_coord_status;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 924e49140..fe105aea6 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -55,11 +55,11 @@
#include "ui/interface.h"
#include "ui/tools-switch.h"
#include "ui/uxmanager.h"
+#include "ui/widget/button.h"
#include "ui/widget/spinbutton.h"
#include "ui/widget/style-swatch.h"
#include "ui/widget/unit-tracker.h"
-#include "widgets/button.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/spinbutton-events.h"
#include "widgets/spw-utilities.h"
@@ -258,7 +258,7 @@ static void update_aux_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWi
static void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
static void update_commands_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
-static GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick( GtkWidget *t, GtkIconSize size, SPButtonType type,
+static GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick( GtkWidget *t, GtkIconSize size, Inkscape::UI::Widget::ButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view);
@@ -325,12 +325,12 @@ Gtk::Widget* VerbAction::create_tool_item_vfunc()
GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/tools/small");
GtkWidget* toolbox = nullptr;
auto holder = Glib::wrap(sp_toolbox_button_item_new_from_verb_with_doubleclick( toolbox, toolboxSize,
- SP_BUTTON_TYPE_TOGGLE,
+ Inkscape::UI::Widget::BUTTON_TYPE_TOGGLE,
verb,
verb2,
view ));
- auto button_widget = static_cast<SPButton *>(holder->get_child());
+ auto button_widget = static_cast<Inkscape::UI::Widget::Button *>(holder->get_child());
if ( active ) {
button_widget->toggle_set_down(active);
@@ -360,8 +360,8 @@ void VerbAction::set_active(bool active)
for ( Glib::SListHandle<Gtk::Widget*>::iterator it = proxies.begin(); it != proxies.end(); ++it ) {
Gtk::ToolItem* ti = dynamic_cast<Gtk::ToolItem*>(*it);
if (ti) {
- // *should* have one child that is the SPButton
- auto child = dynamic_cast<SPButton *>(ti->get_child());
+ // *should* have one child that is the Inkscape::UI::Widget::Button
+ auto child = dynamic_cast<Inkscape::UI::Widget::Button *>(ti->get_child());
if (child) {
child->toggle_set_down(active);
}
@@ -458,7 +458,7 @@ void delete_prefspusher(GObject * /*obj*/, PrefPusher *watcher )
// ------------------------------------------------------
-GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t, GtkIconSize size, SPButtonType type,
+GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t, GtkIconSize size, Inkscape::UI::Widget::ButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view)
{
@@ -475,8 +475,8 @@ GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t
}
/* fixme: Handle sensitive/unsensitive */
- /* fixme: Implement SPButton construction from action */
- auto b = Gtk::manage(new SPButton(size, type, action, doubleclick_action));
+ /* fixme: Implement Inkscape::UI::Widget::Button construction from action */
+ auto b = Gtk::manage(new Inkscape::UI::Widget::Button(size, type, action, doubleclick_action));
b->show();
auto b_toolitem = Gtk::manage(new Gtk::ToolItem());
b_toolitem->add(*b);