[gtkmm] Added Gtk::Switch, wrapping GtkSwitch.



commit 11dd616fa0691092d38df73c831652390eb94be4
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Nov 30 09:41:04 2010 +0100

    Added Gtk::Switch, wrapping GtkSwitch.
    
    * configure.ac: Depend on the latest GTK+.
    * tools/extra_defs_gen/generate_defs_gtk.cc: Mention GTK_TYPE_SWITCH.
    * gtk/src/filelist.am:
    * gtk/src/switch.[hg|ccg]: Added Gtk::Switch, wrapping GtkSwitch.
    * gtk/gtkmm.h: Include it.

 ChangeLog                                 |   10 ++++++
 configure.ac                              |    2 +-
 gtk/gtkmm.h                               |    1 +
 gtk/src/activatable.hg                    |    1 -
 gtk/src/filelist.am                       |    1 +
 gtk/src/switch.ccg                        |   26 +++++++++++++++
 gtk/src/switch.hg                         |   51 +++++++++++++++++++++++++++++
 tools/extra_defs_gen/generate_defs_gtk.cc |    1 +
 8 files changed, 91 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 01d171f..a01f0c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-11-30  Murray Cumming  <murrayc murrayc com>
 
+	Added Gtk::Switch, wrapping GtkSwitch. 
+
+	* configure.ac: Depend on the latest GTK+.
+	* tools/extra_defs_gen/generate_defs_gtk.cc: Mention GTK_TYPE_SWITCH.
+	* gtk/src/filelist.am:
+	* gtk/src/switch.[hg|ccg]: Added Gtk::Switch, wrapping GtkSwitch.
+	* gtk/gtkmm.h: Include it.
+
+2010-11-30  Murray Cumming  <murrayc murrayc com>
+
 	ComboBox: Add methods.
 
 	* gtk/src/gtk_methods.defs: Regenerated with h2defs.py.
diff --git a/configure.ac b/configure.ac
index 865a287..45f2bff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,7 @@ AS_IF([test "x$enable_static" = xyes],
 
 # gdkmm really does need GTK+, because part of Gdk::DragContext is in GTK+.
 # The extra cairomm check is because gdkmm requires a newer cairomm than pangomm requires.
-AC_SUBST([GDKMM_MODULES], ['giomm-2.4 >= 2.27.0 pangomm-1.4 >= 2.26 gtk+-3.0 >= 2.91.4 cairomm-1.0 >= 1.9.2'])
+AC_SUBST([GDKMM_MODULES], ['giomm-2.4 >= 2.27.0 pangomm-1.4 >= 2.26 gtk+-3.0 >= 2.91.5 cairomm-1.0 >= 1.9.2'])
 
 AS_IF([test "x$gtkmm_host_windows" = xyes],
       [GTKMM_MODULES=$GDKMM_MODULES],
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index f11eed6..615737e 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -217,6 +217,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/stockid.h>
 #include <gtkmm/stockitem.h>
 #include <gtkmm/style.h>
+#include <gtkmm/switch.h>
 #include <gtkmm/table.h>
 #include <gtkmm/tearoffmenuitem.h>
 #include <gtkmm/textbuffer.h>
diff --git a/gtk/src/activatable.hg b/gtk/src/activatable.hg
index 8151546..c359856 100644
--- a/gtk/src/activatable.hg
+++ b/gtk/src/activatable.hg
@@ -32,7 +32,6 @@ typedef struct _GtkActivatableIface GtkActivatableIface;
 namespace Gtk
 {
 
-//TODO: Use this when we can add new base classes to existing classes.
 /** Activatable widgets can be connected to a Gtk::Action and reflect the state 
  * of the action. An Activatable can also provide feedback through its action, 
  * as it is responsible for activating the related action.
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 5d8f0a3..9c4dc98 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -141,6 +141,7 @@ gtkmm_files_any_hg =		\
 	statusicon.hg		\
 	stockitem.hg		\
 	style.hg		\
+	switch.hg \
 	table.hg		\
 	targetlist.hg		\
 	tearoffmenuitem.hg	\
diff --git a/gtk/src/switch.ccg b/gtk/src/switch.ccg
new file mode 100644
index 0000000..9517e8b
--- /dev/null
+++ b/gtk/src/switch.ccg
@@ -0,0 +1,26 @@
+/* 
+ *
+ * Copyright 1998-2002 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gtk/gtk.h>
+
+namespace Gtk
+{
+
+} // namespace Gtk
+
diff --git a/gtk/src/switch.hg b/gtk/src/switch.hg
new file mode 100644
index 0000000..96c43f9
--- /dev/null
+++ b/gtk/src/switch.hg
@@ -0,0 +1,51 @@
+/* Copyright (C) 2010 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gtkmm/widget.h>
+#include <gtkmm/activatable.h>
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/widget_p.h)
+
+namespace Gtk
+{
+
+/** A "light switch"-style toggle.
+ *
+ * The Switch widget has two states: on or off. The user can control
+ * which state should be active by clicking the empty area, or by dragging the
+ * handle.
+ *
+ * @ingroup Widgets
+ * @newin{3,0}
+ */
+class Switch
+  : public Widget,
+    public Activatable
+{
+  _CLASS_GTKOBJECT(Switch, GtkSwitch, GTK_WIDGET, Gtk::Widget, GtkWidget)
+  _IMPLEMENTS_INTERFACE(Activatable)
+public:
+
+  _CTOR_DEFAULT
+
+  _WRAP_METHOD(void set_active(bool is_active = true), gtk_switch_set_active)
+  _WRAP_METHOD(bool get_active() const, gtk_switch_get_active)
+
+  _WRAP_PROPERTY("active", bool)
+};
+
+} // namespace Gtk
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index 54246a2..2c08cbc 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -170,6 +170,7 @@ int main(int argc, char** argv)
             << get_defs( GTK_TYPE_STATUSBAR )
             << get_defs( GTK_TYPE_STATUS_ICON )
             << get_defs( GTK_TYPE_STYLE )
+            << get_defs( GTK_TYPE_SWITCH )
             << get_defs( GTK_TYPE_TABLE )
             << get_defs( GTK_TYPE_TEAROFF_MENU_ITEM )
             << get_defs( GTK_TYPE_TOGGLE_BUTTON )



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]