[gtkmm] Add ColorChooser and ColorChooserDialog, deprecating ColorSelection*.



commit 3fdc8c26f0de8cd053578e50b94cbde13f077468
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 2 20:39:08 2012 +0100

    Add ColorChooser and ColorChooserDialog, deprecating ColorSelection*.
    
    * tools/extra_defs_gen/generate_defs_gtk.cc: Mention the new Color*
    types.
    * gtk/src/gtk_signals.def
    * gtk/src/gtk_methods.defs: Update.
    
    * gtk/src/filelist.am:
    * gtk/src/colorchooser.[hg|ccg]: Add the ColorChooser interface.
    * gtk/src/colorchooserdialog.[hg|ccg]: Add ColorChooserDialog.
    * gtk/src/colorbutton.hg: Add a comment that we cannot derive this from
    the new interface, though the C API does that, because we cannot break
    ABI.
    * gtk/src/colorselection.hg: Deprecate ColorSelection and
    ColorSelectionDialog, as in the C API.
    * gtk/gtkmm.h: Mention the new headers.
    * demos/gtk-demo/example_colorsel.cc: Use GtkChooserDialog instead of
    ColorSelectionDialog.

 ChangeLog                                 |   21 +++++++++
 demos/gtk-demo/example_colorsel.cc        |   16 ++-----
 gtk/gtkmm.h                               |    2 +
 gtk/src/colorbutton.hg                    |    2 +
 gtk/src/colorchooser.ccg                  |   30 ++++++++++++
 gtk/src/colorchooser.hg                   |   71 +++++++++++++++++++++++++++++
 gtk/src/colorchooserdialog.ccg            |   28 +++++++++++
 gtk/src/colorchooserdialog.hg             |   52 +++++++++++++++++++++
 gtk/src/colorselection.hg                 |    2 +
 gtk/src/filelist.am                       |    2 +
 gtk/src/gtk_methods.defs                  |   71 +++++++++++++++++++++++++----
 gtk/src/gtk_signals.defs                  |   58 +++++++++++++++++++++++
 tools/extra_defs_gen/generate_defs_gtk.cc |    2 +
 13 files changed, 336 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index de7d9e0..b70f541 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2012-03-02  Murray Cumming  <murrayc murrayc com>
+
+	Add ColorChooser and ColorChooserDialog, deprecating ColorSelection*.
+
+	* tools/extra_defs_gen/generate_defs_gtk.cc: Mention the new Color* 
+	types.
+	* gtk/src/gtk_signals.def
+	* gtk/src/gtk_methods.defs: Update.
+
+	* gtk/src/filelist.am:
+	* gtk/src/colorchooser.[hg|ccg]: Add the ColorChooser interface.
+	* gtk/src/colorchooserdialog.[hg|ccg]: Add ColorChooserDialog.
+	* gtk/src/colorbutton.hg: Add a comment that we cannot derive this from
+	the new interface, though the C API does that, because we cannot break
+	ABI.
+	* gtk/src/colorselection.hg: Deprecate ColorSelection and 
+	ColorSelectionDialog, as in the C API.
+	* gtk/gtkmm.h: Mention the new headers.
+	* demos/gtk-demo/example_colorsel.cc: Use GtkChooserDialog instead of
+	ColorSelectionDialog.
+
 2012-03-01  Josà Alburquerque  <jaalburquerque gmail com>
 
 	gmmproc: _CLASS_GTKOBJECT: Include destructor documentation.
diff --git a/demos/gtk-demo/example_colorsel.cc b/demos/gtk-demo/example_colorsel.cc
index cdba328..90647e6 100644
--- a/demos/gtk-demo/example_colorsel.cc
+++ b/demos/gtk-demo/example_colorsel.cc
@@ -1,7 +1,6 @@
- /* Color Selector
+ /* Color Chooser
  *
- * GtkColorSelection lets the user choose a color. GtkColorSelectionDialog is
- * a prebuilt dialog containing a GtkColorSelection.
+ * GtkColorChooserDialog lets the user choose a color.
  *
  */
 
@@ -80,20 +79,15 @@ Example_ColorSel::~Example_ColorSel()
 
 void Example_ColorSel::on_button_clicked()
 {
-  Gtk::ColorSelectionDialog dialog ("Changing color");
+  Gtk::ColorChooserDialog dialog("Changing color");
   dialog.set_transient_for(*this);
-
-  Gtk::ColorSelection *const pColorSel = dialog.get_color_selection();
-
-  pColorSel->set_previous_rgba(m_Color);
-  pColorSel->set_current_rgba(m_Color);
-  pColorSel->set_has_palette();
+  dialog.set_rgba(m_Color);
 
   const int response = dialog.run();
 
   if(response == Gtk::RESPONSE_OK)
   {
-    m_Color = pColorSel->get_current_rgba();
+    m_Color = dialog.get_rgba();
 
     m_DrawingArea.override_background_color(m_Color);
   }
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 294421b..f25f400 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -129,6 +129,8 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/cellrenderertext.h>
 #include <gtkmm/cellrenderertoggle.h>
 #include <gtkmm/colorbutton.h>
+#include <gtkmm/colorchooser.h>
+#include <gtkmm/colorchooserdialog.h>
 #include <gtkmm/colorselection.h>
 #include <gtkmm/combobox.h>
 #include <gtkmm/comboboxtext.h>
diff --git a/gtk/src/colorbutton.hg b/gtk/src/colorbutton.hg
index 842d5f2..892874c 100644
--- a/gtk/src/colorbutton.hg
+++ b/gtk/src/colorbutton.hg
@@ -33,6 +33,8 @@ _PINCLUDE(gtkmm/private/button_p.h)
 namespace Gtk
 {
 
+//TODO: Derive from (and implement) ColorChooser when we can break ABI.
+
 /** A button to launch a color selection dialog.
  *
  * The GtkColorButton is a button which displays the currently selected color an allows to
diff --git a/gtk/src/colorchooser.ccg b/gtk/src/colorchooser.ccg
new file mode 100644
index 0000000..ca30855
--- /dev/null
+++ b/gtk/src/colorchooser.ccg
@@ -0,0 +1,30 @@
+/* Copyright 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+namespace Gtk
+{
+
+Gdk::RGBA ColorChooser::get_rgba() const
+{
+  GdkRGBA crgba;
+  gtk_color_chooser_get_rgba(const_cast<GtkColorChooser*>(gobj()), &crgba);
+  return Glib::wrap(&crgba, true);
+}
+
+} //namespace Gtk
diff --git a/gtk/src/colorchooser.hg b/gtk/src/colorchooser.hg
new file mode 100644
index 0000000..410d490
--- /dev/null
+++ b/gtk/src/colorchooser.hg
@@ -0,0 +1,71 @@
+/* Copyright (C) 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <glibmm/interface.h>
+#include <gdkmm/rgba.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/interface_p.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+extern "C"
+{
+typedef struct _GtkColorChooserInterface GtkColorChooserInterface;
+}
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+namespace Gtk
+{
+
+/** This interface can be implemented by widgets which allow the user to choose
+ * a color. Depending on the situation, colors may be
+ * allowed to have alpha (translucency).
+ * The main widgets that implement this interface are ColorChooserWidget, ColorChooserDialog
+ * and ColorChooserButton.
+ *
+ * @newin{3,4}
+ */
+class ColorChooser : public Glib::Interface
+{
+  _CLASS_INTERFACE(ColorChooser, GtkColorChooser, GTK_COLOR_CHOOSER, GtkColorChooserInterface)
+
+public:
+  //TODO: Documentation.
+  Gdk::RGBA get_rgba() const;
+  _IGNORE(gtk_color_chooser_get_rgba)
+
+  _WRAP_METHOD(void set_rgba(const Gdk::RGBA& color), gtk_color_chooser_set_rgba)
+  _WRAP_METHOD(bool get_use_alpha() const, gtk_color_chooser_get_use_alpha)
+  _WRAP_METHOD(void set_use_alpha(bool use_alpha = true), gtk_color_chooser_set_use_alpha)
+
+/* TODO:
+void     gtk_color_chooser_add_palette    (GtkColorChooser *chooser,
+                                           gboolean         horizontal,
+                                           gint             colors_per_line,
+                                           gint             n_colors,
+                                           GdkRGBA         *colors)
+*/
+
+#m4 _CONVERSION(`const GdkRGBA*',`const Gdk::RGBA&',`Glib::wrap(const_cast<GdkRGBA*>($3), true)')
+//#m4 _CONVERSION(`const Gdk::RGBA&',`const GdkRGBA*',`const_cast<GdkRGBA*>(($3).gobj())')
+  _WRAP_SIGNAL(void color_activated(const Gdk::RGBA& color), "color-activated")
+
+  _WRAP_PROPERTY("rgba", Gdk::RGBA)
+  _WRAP_PROPERTY("use-alpha", bool)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/colorchooserdialog.ccg b/gtk/src/colorchooserdialog.ccg
new file mode 100644
index 0000000..7c58bc0
--- /dev/null
+++ b/gtk/src/colorchooserdialog.ccg
@@ -0,0 +1,28 @@
+/* Copyright 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+
+namespace Gtk
+{
+
+ColorChooserDialog::ColorChooserDialog(const Glib::ustring& title)
+: _CONSTRUCT("title", title.c_str())
+{
+}
+
+} // namespace Gtk
diff --git a/gtk/src/colorchooserdialog.hg b/gtk/src/colorchooserdialog.hg
new file mode 100644
index 0000000..58949d0
--- /dev/null
+++ b/gtk/src/colorchooserdialog.hg
@@ -0,0 +1,52 @@
+/* Copyright (C) 2012 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/colorchooser.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/dialog_p.h)
+
+namespace Gtk
+{
+
+//TODO: Create the screenshot.
+/** This dialog is for choosing a color. It implements the ColorChooser interface.
+ *
+ * A ColorChooserDialog looks like this:
+ * @image html colorchooserdialog.png
+ *
+ * @ingroup Dialogs
+ */
+class ColorChooserDialog
+: public Dialog,
+  public ColorChooser
+{
+  _CLASS_GTKOBJECT(ColorChooserDialog, GtkColorChooserDialog, GTK_COLOR_CHOOSER_DIALOG, Gtk::Dialog, GtkDialog)
+  _UNMANAGEABLE()
+public:
+
+  _CTOR_DEFAULT()
+
+  explicit ColorChooserDialog(const Glib::ustring& title);
+
+  _WRAP_CTOR(ColorChooserDialog(const Glib::ustring& title, Window& parent), gtk_color_chooser_dialog_new)
+
+  _WRAP_PROPERTY("show-editor", bool)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/colorselection.hg b/gtk/src/colorselection.hg
index 138480d..28aa34a 100644
--- a/gtk/src/colorselection.hg
+++ b/gtk/src/colorselection.hg
@@ -49,6 +49,7 @@ namespace Gtk
 class ColorSelection : public VBox
 {
   _CLASS_GTKOBJECT(ColorSelection,GtkColorSelection,GTK_COLOR_SELECTION,Gtk::VBox,GtkVBox)
+  _IS_DEPRECATED
   _IGNORE(gtk_color_selection_get_current_color, gtk_color_selection_get_previous_color,
           gtk_color_selection_set_color, gtk_color_selection_get_color, gtk_color_selection_set_update_policy)
 public:
@@ -103,6 +104,7 @@ class ColorSelectionDialog : public Dialog
 {
   _CLASS_GTKOBJECT(ColorSelectionDialog,GtkColorSelectionDialog,GTK_COLOR_SELECTION_DIALOG,Gtk::Dialog,GtkDialog)
   _UNMANAGEABLE()
+  _IS_DEPRECATED
 public:
 
   _CTOR_DEFAULT()
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 929c06e..c29fbdb 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -59,6 +59,8 @@ gtkmm_files_any_hg =		\
 	checkmenuitem.hg	\
 	clipboard.hg		\
 	colorbutton.hg		\
+	colorchooser.hg		\
+	colorchooserdialog.hg	\
 	colorselection.hg	\
 	combobox.hg		\
 	comboboxtext.hg		\
diff --git a/gtk/src/gtk_methods.defs b/gtk/src/gtk_methods.defs
index baa5a77..3eb8489 100644
--- a/gtk/src/gtk_methods.defs
+++ b/gtk/src/gtk_methods.defs
@@ -1706,16 +1706,6 @@
   )
 )
 
-(define-enum CssCombinator
-  (in-module "Gtk")
-  (c-name "GtkCssCombinator")
-  (gtype-id "GTK_TYPE_CSS_COMBINATOR")
-  (values
-    '("descandant" "GTK_CSS_COMBINE_DESCANDANT")
-    '("child" "GTK_CSS_COMBINE_CHILD")
-  )
-)
-
 (define-enum CssSpecialValue
   (in-module "Gtk")
   (c-name "GtkCssSpecialValue")
@@ -4831,6 +4821,10 @@
 
 
 
+;; From gtkallocatedbitmaskprivate.h
+
+
+
 ;; From gtkanimationdescription.h
 
 
@@ -5794,6 +5788,33 @@
 
 
 
+;; From gtkbitmaskprivateimpl.h
+
+(define-function return
+  (c-name "return")
+  (return-type "else")
+  (parameters
+    '("GtkBitmask" "*")
+  )
+)
+
+(define-function g_string_free
+  (c-name "g_string_free")
+  (return-type "return")
+  (parameters
+  )
+)
+
+(define-function if
+  (c-name "if")
+  (return-type "else")
+  (parameters
+    '("index_-<" "GTK_BITMASK_N_DIRECT_BITS")
+  )
+)
+
+
+
 ;; From gtkborder.h
 
 (define-function gtk_border_get_type
@@ -21321,6 +21342,36 @@
   )
 )
 
+(define-method set_kinetic_scrolling
+  (of-object "GtkScrolledWindow")
+  (c-name "gtk_scrolled_window_set_kinetic_scrolling")
+  (return-type "none")
+  (parameters
+    '("gboolean" "kinetic_scrolling")
+  )
+)
+
+(define-method get_kinetic_scrolling
+  (of-object "GtkScrolledWindow")
+  (c-name "gtk_scrolled_window_get_kinetic_scrolling")
+  (return-type "gboolean")
+)
+
+(define-method set_capture_button_press
+  (of-object "GtkScrolledWindow")
+  (c-name "gtk_scrolled_window_set_capture_button_press")
+  (return-type "none")
+  (parameters
+    '("gboolean" "capture_button_press")
+  )
+)
+
+(define-method get_capture_button_press
+  (of-object "GtkScrolledWindow")
+  (c-name "gtk_scrolled_window_get_capture_button_press")
+  (return-type "gboolean")
+)
+
 
 
 ;; From gtksearchengine.h
diff --git a/gtk/src/gtk_signals.defs b/gtk/src/gtk_signals.defs
index 598eaa4..e721973 100644
--- a/gtk/src/gtk_signals.defs
+++ b/gtk/src/gtk_signals.defs
@@ -2719,6 +2719,46 @@
   (construct-only #f)
 )
 
+;; From GtkColorChooser
+
+(define-signal color-activated
+  (of-object "GtkColorChooser")
+  (return-type "void")
+  (when "first")
+  (parameters
+    '("const-GdkRGBA*" "p0")
+  )
+)
+
+(define-property rgba
+  (of-object "GtkColorChooser")
+  (prop-type "GParamBoxed")
+  (docs "Current color, as a GdkRGBA")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property use-alpha
+  (of-object "GtkColorChooser")
+  (prop-type "GParamBoolean")
+  (docs "Whether alpha should be shown")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+;; From GtkColorChooserDialog
+
+(define-property show-editor
+  (of-object "GtkColorChooserDialog")
+  (prop-type "GParamBoolean")
+  (docs "Show editor")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From GtkColorSelection
 
 (define-signal color-changed
@@ -6864,6 +6904,15 @@
   )
 )
 
+(define-property kinetic-scrolling
+  (of-object "GtkScrolledWindow")
+  (prop-type "GParamBoolean")
+  (docs "Kinetic scrolling mode.")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 (define-property hadjustment
   (of-object "GtkScrolledWindow")
   (prop-type "GParamObject")
@@ -11093,6 +11142,15 @@
   (when "first")
 )
 
+(define-signal touch-event
+  (of-object "GtkWidget")
+  (return-type "gboolean")
+  (when "last")
+  (parameters
+    '("GdkEvent*" "p0")
+  )
+)
+
 (define-property type
   (of-object "GtkWindow")
   (prop-type "GParamEnum")
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index da8174d..b118bd6 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -98,6 +98,8 @@ int main(int argc, char** argv)
             << get_defs( GTK_TYPE_CELL_RENDERER_SPINNER )
             << get_defs( GTK_TYPE_CLIPBOARD )
             << get_defs( GTK_TYPE_COLOR_BUTTON )
+            << get_defs( GTK_TYPE_COLOR_CHOOSER )
+            << get_defs( GTK_TYPE_COLOR_CHOOSER_DIALOG )
             << get_defs( GTK_TYPE_COLOR_SELECTION )
             << get_defs( GTK_TYPE_COLOR_SELECTION_DIALOG )
             << get_defs( GTK_TYPE_COMBO_BOX )



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