[gtkmm] ColorChooser: Add add_palette.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] ColorChooser: Add add_palette.
- Date: Mon, 26 Mar 2012 08:14:12 +0000 (UTC)
commit 68e4671f348e37793c06827e45fd7492107e226d
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Mar 26 10:12:07 2012 +0200
ColorChooser: Add add_palette.
* gtk/src/colorchooser.[hg|ccg]: Wrap gtk_color_chooser_add_palette().
ChangeLog | 13 -------------
gtk/src/colorchooser.ccg | 6 ++++++
gtk/src/colorchooser.hg | 31 ++++++++++++++++++++++++-------
3 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 486d4ef..93ac140 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,19 +19,6 @@
2012-03-25 Murray Cumming <murrayc murrayc com>
- Gtk::CellArea: Add foreach().
-
- * gtk/src/cellarea.[hg|ccg]: Wrap gtk_cell_area_foreach() and
- gtk_cell_area_foreach_alloc().
-
-2012-03-25 Murray Cumming <murrayc murrayc com>
-
- Gdk::Device: Add list_axes().
-
- * gdk/src/device.[hg|ccg]: Wrap gdk_device_list_axes().
-
-2012-03-25 Murray Cumming <murrayc murrayc com>
-
Gdk: Add AppLaunchContext.
* tools/extra_defs_gen/generate_defs_gtk.cc: Mention
diff --git a/gtk/src/colorchooser.ccg b/gtk/src/colorchooser.ccg
index ca30855..78e945a 100644
--- a/gtk/src/colorchooser.ccg
+++ b/gtk/src/colorchooser.ccg
@@ -27,4 +27,10 @@ Gdk::RGBA ColorChooser::get_rgba() const
return Glib::wrap(&crgba, true);
}
+void ColorChooser::add_palette(Orientation orientation, int colors_per_line, const std::vector<Gdk::RGBA>& colors)
+{
+ gtk_color_chooser_add_palette(gobj(), (GtkOrientation)orientation, colors_per_line, colors.size(),
+ Glib::ArrayHandler<Gdk::RGBA, Gdk::RGBATraits>::vector_to_array(colors).data() );
+}
+
} //namespace Gtk
diff --git a/gtk/src/colorchooser.hg b/gtk/src/colorchooser.hg
index 410d490..2b400e9 100644
--- a/gtk/src/colorchooser.hg
+++ b/gtk/src/colorchooser.hg
@@ -16,6 +16,7 @@
*/
#include <glibmm/interface.h>
+#include <gtkmm/enums.h> //For Orientation.
#include <gdkmm/rgba.h>
_DEFS(gtkmm,gtk)
@@ -52,13 +53,29 @@ public:
_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)
-*/
+ /** Adds a palette to the color chooser. If @a orientation is horizontal,
+ * the colors are grouped in rows, with @colors_per_line colors
+ * in each row. If @horizontal is %FALSE, the colors are grouped
+ * in columns instead.
+ *
+ * The default color palette of ColorChooserWidget has
+ * 27 colors, organized in columns of 3 colors. The default gray
+ * palette has 9 grays in a single row.
+ *
+ * The layout of the color chooser widget works best when the
+ * palettes have 9-10 columns.
+ *
+ * Calling this function for the first time has the
+ * side effect of removing the default color and gray palettes
+ * from the color chooser.
+ *
+ * @param orientation ORIENTATION_HORIZONTAL if the palette should be displayed in rows, or ORIENTATION_VERTICAL for columns
+ * @param colors_per_line The number of colors to show in each row/column.
+ * @param colors The colors of the palette.
+ *
+ * @newin{3,4}
+ */
+ void add_palette(Orientation orientation, int colors_per_line, const std::vector<Gdk::RGBA>& 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())')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]