From 0c63499f4369d78f9f7186438dfc2051d4f677bb Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 17 Apr 2012 17:31:13 +0900 Subject: Fix for 169888 : HIG Style frame (bzr r11260) --- src/ui/widget/Makefile_insert | 2 ++ src/ui/widget/frame.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++ src/ui/widget/frame.h | 79 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 src/ui/widget/frame.cpp create mode 100644 src/ui/widget/frame.h (limited to 'src/ui/widget') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index 4dc83a81d..cea869300 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -19,6 +19,8 @@ ink_common_sources += \ ui/widget/entry.h \ ui/widget/filter-effect-chooser.h \ ui/widget/filter-effect-chooser.cpp \ + ui/widget/frame.cpp \ + ui/widget/frame.h \ ui/widget/handlebox.cpp \ ui/widget/handlebox.h \ ui/widget/icon-widget.cpp \ diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp new file mode 100644 index 000000000..b2968f806 --- /dev/null +++ b/src/ui/widget/frame.cpp @@ -0,0 +1,83 @@ +/* + * Authors: + * Murray C + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "frame.h" + + +// Inkscape::UI::Widget::Frame + +namespace Inkscape { +namespace UI { +namespace Widget { + +Frame::Frame(Glib::ustring const &label_text /*= ""*/, gboolean label_bold /*= TRUE*/ ) + : _label(label_text, 1.0, 0.5, TRUE), + _alignment() +{ + set_shadow_type(Gtk::SHADOW_NONE); + + //Put an indented GtkAlignment inside the frame. + //Further children should be children of this GtkAlignment: + Gtk::Frame::add(_alignment); + set_padding(4, 0, 8, 0); + + set_label_widget(_label); + set_label(label_text, label_bold); + + show_all_children(); +} + +void +Frame::add(Widget& widget) +{ + _alignment.add(widget); +} + +void +Frame::set_label(const Glib::ustring &label_text, gboolean label_bold /*= TRUE*/) +{ + if (label_bold) { + _label.set_markup(Glib::ustring("") + label_text + ""); + } else { + _label.set_text(label_text); + } +} + +void +Frame::set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right) +{ +#if WITH_GTKMM_2_24 + _alignment.set_padding(padding_top, padding_bottom, padding_left, padding_right); +#endif +} + +Gtk::Label const * +Frame::get_label_widget() const +{ + return &_label; +} + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/frame.h b/src/ui/widget/frame.h new file mode 100644 index 000000000..cf736d8a1 --- /dev/null +++ b/src/ui/widget/frame.h @@ -0,0 +1,79 @@ +/* + * Authors: + * Murray C + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_FRAME_H +#define INKSCAPE_UI_WIDGET_FRAME_H + +#include + +namespace Gtk { +class Frame; +} + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * Creates a Gnome HIG style indented frame with bold label + * See http://developer.gnome.org/hig-book/stable/controls-frames.html.en + */ +class Frame : public Gtk::Frame +{ +public: + + /** + * Construct a Frame Widget. + * + * @param label The frame text. + */ + Frame(Glib::ustring const &label = "", gboolean label_bold = TRUE); + + /** + * Return the label widget + */ + Gtk::Label const *get_label_widget() const; + + /** + * Add a widget to this frame + */ + virtual void add(Widget& widget); + + /** + * Set the frame label text and if bold or not + */ + void set_label(const Glib::ustring &label, gboolean label_bold = TRUE); + + /** + * Set the frame padding + */ + void set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right); + +protected: + Gtk::Label _label; + Gtk::Alignment _alignment; + +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_FRAME_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 6963da8960dab2e5e26204512cd4bb8924364821 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 21 Apr 2012 14:52:34 +0100 Subject: Replace deprecated toolbar orientation API. Unfortunately there is no replacement in Gtkmm 3 so we need to use underlying GTK+ object (bzr r11275) --- src/ui/widget/toolbox.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp index 99891fc44..a11bd2d74 100644 --- a/src/ui/widget/toolbox.cpp +++ b/src/ui/widget/toolbox.cpp @@ -12,6 +12,7 @@ #endif #include +#include #include #include "ui/widget/toolbox.h" #include "path-prefix.h" @@ -97,7 +98,9 @@ Toolbox::init_actions() void Toolbox::init_orientation(Gtk::Orientation const &orientation) { - static_cast(_widget)->set_orientation(orientation); + gtk_orientable_set_orientation(GTK_ORIENTABLE(static_cast(_widget)->gobj()), + GtkOrientation(orientation)); + if (orientation == Gtk::ORIENTATION_VERTICAL) { set_handle_position(Gtk::POS_TOP); } @@ -226,7 +229,8 @@ Toolbox::on_change_orient_horiz() { Glib::RefPtr action = Glib::RefPtr::cast_static(_detach_grp->get_action("OrientHoriz")); if (action->get_active()) { - static_cast(_widget)->set_orientation(Gtk::ORIENTATION_HORIZONTAL); + gtk_orientable_set_orientation(GTK_ORIENTABLE(static_cast(_widget)->gobj()), + GTK_ORIENTATION_HORIZONTAL); } } @@ -235,7 +239,8 @@ Toolbox::on_change_orient_vert() { Glib::RefPtr action = Glib::RefPtr::cast_static(_detach_grp->get_action("OrientVert")); if (action->get_active()) { - static_cast(_widget)->set_orientation(Gtk::ORIENTATION_VERTICAL); + gtk_orientable_set_orientation(GTK_ORIENTABLE(static_cast(_widget)->gobj()), + GTK_ORIENTATION_VERTICAL); } } -- cgit v1.2.3 From 55e1e3451e22a636ba0a87017eef2d5fe2ca05bb Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 23 Apr 2012 16:19:09 +0100 Subject: Get rid of GtkObject in toolbox (bzr r11286) --- src/ui/widget/selected-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index c81385dd7..d26005317 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1157,7 +1157,7 @@ void SelectedStyle::on_opacity_changed () { _("Change opacity")); // resume interruptibility sp_desktop_canvas(_desktop)->endForcedFullRedraws(); - spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj())); + spinbutton_defocus(GTK_WIDGET(_opacity_sb.gobj())); _opacity_blocked = false; } -- cgit v1.2.3