[gtkmm] Gtk::AccelLabel, Scrollbar, SpinButton: Inherit from Widget, add new API
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::AccelLabel, Scrollbar, SpinButton: Inherit from Widget, add new API
- Date: Fri, 21 Jul 2017 15:15:02 +0000 (UTC)
commit ec25bfd4d5ae105d4752342f0823656510b5aa1b
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Fri Jul 21 17:12:10 2017 +0200
Gtk::AccelLabel, Scrollbar, SpinButton: Inherit from Widget, add new API
* gtk/src/accellabel.[ccg|hg]: Add set/get/property_label() and
set/get/property_use_underline(). Make get_accel() const.
* gtk/src/scrollbar.[ccg|hg]: Implement the Orientable interface.
Add set/unset/get/property_adjustment() and get_wheel_delta().
* gtk/src/spinbutton.hg: Implement the Orientable and Editable interfaces.
Add set/get/property_text(), set/get/property_width_chars() and
set/get/property_max_width_chars().
gtk/src/accellabel.ccg | 10 ++--------
gtk/src/accellabel.hg | 21 +++++++++++++++------
gtk/src/scrollbar.ccg | 8 +++++++-
gtk/src/scrollbar.hg | 34 ++++++++++++++++++++++++++--------
gtk/src/spinbutton.hg | 23 +++++++++++++++++++----
5 files changed, 69 insertions(+), 27 deletions(-)
---
diff --git a/gtk/src/accellabel.ccg b/gtk/src/accellabel.ccg
index 8aff201..e3c43e3 100644
--- a/gtk/src/accellabel.ccg
+++ b/gtk/src/accellabel.ccg
@@ -24,13 +24,8 @@ namespace Gtk
AccelLabel::AccelLabel(const Glib::ustring& label, bool mnemonic)
:
- _CONSTRUCT()
-{
- if(mnemonic)
- set_text_with_mnemonic(label);
- else
- set_text(label);
-}
+ _CONSTRUCT("label", label.c_str(), "use_underline", gboolean(mnemonic))
+{}
void AccelLabel::unset_accel_widget()
{
@@ -39,4 +34,3 @@ void AccelLabel::unset_accel_widget()
}
} // namespace Gtk
-
diff --git a/gtk/src/accellabel.hg b/gtk/src/accellabel.hg
index 0341020..e1dab01 100644
--- a/gtk/src/accellabel.hg
+++ b/gtk/src/accellabel.hg
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <gtkmm/label.h>
+#include <gtkmm/widget.h>
_DEFS(gtkmm,gtk)
-_PINCLUDE(gtkmm/private/label_p.h)
+_PINCLUDE(gtkmm/private/widget_p.h)
namespace Gtk
@@ -30,13 +30,13 @@ namespace Gtk
*
* @ingroup Widgets
*/
-class AccelLabel : public Label
+class AccelLabel : public Widget
{
- _CLASS_GTKOBJECT(AccelLabel,GtkAccelLabel,GTK_ACCEL_LABEL,Gtk::Label,GtkLabel)
+ _CLASS_GTKOBJECT(AccelLabel, GtkAccelLabel, GTK_ACCEL_LABEL, Gtk::Widget, GtkWidget)
_IGNORE(gtk_accel_label_set_accel_closure)
public:
- //The default ctor doesn't correspond to any _new function, but gtkmenuitem.cc does a simple
g_object_new() with no properties.
+ //The default ctor doesn't correspond to any _new function, but gtkmenuitem.c does a simple g_object_new()
with no properties.
/** Default constructor to create an AccelLabel object
*/
_CTOR_DEFAULT
@@ -59,10 +59,19 @@ public:
_WRAP_METHOD(void set_accel(guint accelerator_key, Gdk::ModifierType accelerator_mods),
gtk_accel_label_set_accel)
#m4 _INITIALIZATION(`Gdk::ModifierType&', `GdkModifierType', `$3 = ($1)$4')
- _WRAP_METHOD(void get_accel(guint& accelerator_key, Gdk::ModifierType& accelerator_mods{>>}),
gtk_accel_label_get_accel)
+ _WRAP_METHOD(void get_accel(guint& accelerator_key, Gdk::ModifierType& accelerator_mods{>>}) const,
gtk_accel_label_get_accel)
+
+ _WRAP_METHOD(void set_label(const Glib::ustring& text), gtk_accel_label_set_label)
+ _WRAP_METHOD(Glib::ustring get_label() const, gtk_accel_label_get_label)
+
+ _WRAP_METHOD(void set_use_underline(bool setting = true), gtk_accel_label_set_use_underline)
+ _WRAP_METHOD(bool get_use_underline() const, gtk_accel_label_get_use_underline)
//_WRAP_PROPERTY("accel-closure", Glib::Object) //GClosure
+ _IGNORE_PROPERTY(accel-closure)
_WRAP_PROPERTY("accel-widget", Gtk::Widget*)
+ _WRAP_PROPERTY("label", Glib::ustring)
+ _WRAP_PROPERTY("use-underline", bool)
};
} // namespace Gtk
diff --git a/gtk/src/scrollbar.ccg b/gtk/src/scrollbar.ccg
index 884f687..dc9c072 100644
--- a/gtk/src/scrollbar.ccg
+++ b/gtk/src/scrollbar.ccg
@@ -17,6 +17,7 @@
*/
#include <gtkmm/adjustment.h>
+#include <gdkmm/events.h>
#include <gtk/gtk.h>
@@ -25,8 +26,13 @@ namespace Gtk
Scrollbar::Scrollbar(const Glib::RefPtr<Adjustment>& adjustment, Orientation orientation)
:
-_CONSTRUCT_SPECIFIC(Range, Scrollbar, "adjustment", Glib::unwrap(adjustment), "orientation",
(GtkOrientation)(orientation))
+_CONSTRUCT("adjustment", Glib::unwrap(adjustment), "orientation", (GtkOrientation)orientation)
{
}
+void Scrollbar::unset_adjustment()
+{
+ gtk_scrollbar_set_adjustment(gobj(), nullptr);
+}
+
} // namespace Gtk
diff --git a/gtk/src/scrollbar.hg b/gtk/src/scrollbar.hg
index 3c32b18..b7557d5 100644
--- a/gtk/src/scrollbar.hg
+++ b/gtk/src/scrollbar.hg
@@ -16,17 +16,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <gtkmm/range.h>
+#include <gtkmm/widget.h>
+#include <gtkmm/orientable.h>
_DEFS(gtkmm,gtk)
-_PINCLUDE(gtkmm/private/range_p.h)
+_PINCLUDE(gtkmm/private/widget_p.h)
+
+namespace Gdk
+{
+class EventScroll;
+}
namespace Gtk
{
+class Adjustment;
-/** A Scrollbar.
+/** A %Scrollbar.
*
- * The #Scrollbar widget is a horizontal or vertical scrollbar,
+ * The %Scrollbar widget is a horizontal or vertical scrollbar,
* depending on the value of the orientation property.
*
* The position of the thumb in a scrollbar is controlled by the scroll
@@ -40,17 +47,28 @@ namespace Gtk
*
* @ingroup Widgets
*/
-class Scrollbar
- : public Range{
- _CLASS_GTKOBJECT(Scrollbar,GtkScrollbar,GTK_SCROLLBAR,Gtk::Range,GtkRange)
+class Scrollbar : public Widget, public Orientable
+{
+ _CLASS_GTKOBJECT(Scrollbar, GtkScrollbar, GTK_SCROLLBAR,Gtk::Widget, GtkWidget)
+ _IMPLEMENTS_INTERFACE(Orientable)
public:
_CTOR_DEFAULT()
- //Note that we try to use the same defaul parameter value as the default property value.
+ //Note that we try to use the same default parameter value as the default property value.
explicit Scrollbar(const Glib::RefPtr<Adjustment>& adjustment, Orientation orientation =
Orientation::HORIZONTAL);
_IGNORE(gtk_scrollbar_new)
+ _WRAP_METHOD(void set_adjustment(const Glib::RefPtr<Adjustment>& adjustment), gtk_scrollbar_set_adjustment)
+ void unset_adjustment();
+
+ _WRAP_METHOD(Glib::RefPtr<Adjustment> get_adjustment(), gtk_scrollbar_get_adjustment, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const Adjustment> get_adjustment() const, gtk_scrollbar_get_adjustment,
refreturn, constversion)
+
+#m4 _CONVERSION(`const Gdk::EventScroll&',`const GdkEventScroll*',`($3).gobj()')
+ _WRAP_METHOD(double get_wheel_delta(const Gdk::EventScroll& event) const, gtk_scrollbar_get_wheel_delta)
+
+ _WRAP_PROPERTY("adjustment", Glib::RefPtr<Adjustment>)
};
} //namespace Gtk
diff --git a/gtk/src/spinbutton.hg b/gtk/src/spinbutton.hg
index 2cc75cf..97959c7 100644
--- a/gtk/src/spinbutton.hg
+++ b/gtk/src/spinbutton.hg
@@ -15,11 +15,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <gtkmm/entry.h>
+#include <gtkmm/widget.h>
+#include <gtkmm/orientable.h>
#include <gtkmm/editable.h>
_DEFS(gtkmm,gtk)
-_PINCLUDE(gtkmm/private/entry_p.h)
+_PINCLUDE(gtkmm/private/widget_p.h)
namespace Gtk
@@ -38,9 +39,11 @@ class Adjustment;
*
* @ingroup Widgets
*/
-class SpinButton : public Entry
+class SpinButton : public Widget, public Orientable, public Editable
{
- _CLASS_GTKOBJECT(SpinButton,GtkSpinButton,GTK_SPIN_BUTTON,Gtk::Entry,GtkEntry)
+ _CLASS_GTKOBJECT(SpinButton, GtkSpinButton, GTK_SPIN_BUTTON, Gtk::Widget, GtkWidget)
+ _IMPLEMENTS_INTERFACE(Orientable)
+ _IMPLEMENTS_INTERFACE(Editable)
public:
_WRAP_ENUM(UpdatePolicy, GtkSpinButtonUpdatePolicy)
@@ -94,6 +97,15 @@ public:
_WRAP_METHOD(void update(), gtk_spin_button_update)
+ _WRAP_METHOD(void set_text(const Glib::ustring& text), gtk_spin_button_set_text)
+ _WRAP_METHOD(Glib::ustring get_text() const, gtk_spin_button_get_text)
+
+ _WRAP_METHOD(void set_max_width_chars(int max_width_chars), gtk_spin_button_set_max_width_chars)
+ _WRAP_METHOD(int get_max_width_chars() const, gtk_spin_button_get_max_width_chars)
+
+ _WRAP_METHOD(void set_width_chars(int width_chars), gtk_spin_button_set_width_chars)
+ _WRAP_METHOD(int get_width_chars() const, gtk_spin_button_get_width_chars)
+
/** Constant to return from a signal handler for the input
* signal in case of conversion failure.
*
@@ -117,6 +129,9 @@ public:
_WRAP_PROPERTY("wrap", bool)
_WRAP_PROPERTY("update-policy", UpdatePolicy)
_WRAP_PROPERTY("value", double)
+ _WRAP_PROPERTY("width-chars", int)
+ _WRAP_PROPERTY("max-width-chars", int)
+ _WRAP_PROPERTY("text", Glib::ustring)
};
} // namespace Gtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]