[gtkmm] Added and used ToolItemGroup.



commit 449e5887b8bd768e65db73b9aa4ffb94f4b74db5
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Dec 22 16:07:15 2009 +0100

    Added and used ToolItemGroup.
    
    * gtk/src/toolitemgroup.[hg|ccg]: Added this GtkToolItemGroup wrapper.
    * gtk/src/toolitem.hg: Use ToolItemGroup instead of Widget.
    See https://bugzilla.gnome.org/show_bug.cgi?id=567729#c37

 ChangeLog                 |    8 +++++
 gtk/src/filelist.am       |    1 +
 gtk/src/toolitemgroup.ccg |   30 ++++++++++++++++++
 gtk/src/toolitemgroup.hg  |   74 +++++++++++++++++++++++++++++++++++++++++++++
 gtk/src/toolpalette.hg    |   39 ++++++++++++++++++-----
 5 files changed, 143 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 61c76f7..1eede47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-22  Murray Cumming  <murrayc murrayc com>>
+
+	Added and used ToolItemGroup.
+
+	* gtk/src/toolitemgroup.[hg|ccg]: Added this GtkToolItemGroup wrapper.
+	* gtk/src/toolitem.hg: Use ToolItemGroup instead of Widget. 
+	See https://bugzilla.gnome.org/show_bug.cgi?id=567729#c37
+
 2009-12-21  Murray Cumming  <murrayc murrayc com>
 
 	ToolPalette: Added drag methods.
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index c4125b3..6d7b8f6 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -156,6 +156,7 @@ gtkmm_files_any_hg =		\
 	toolbar.hg		\
 	toolbutton.hg		\
 	toolitem.hg		\
+	toolitemgroup.hg	\
 	toolpalette.hg		\
 	toolshell.hg		\
 	tooltip.hg		\
diff --git a/gtk/src/toolitemgroup.ccg b/gtk/src/toolitemgroup.ccg
new file mode 100644
index 0000000..a87190c
--- /dev/null
+++ b/gtk/src/toolitemgroup.ccg
@@ -0,0 +1,30 @@
+// -*- c++ -*-
+/* $Id: toolitemgroup.ccg,v 1.1 2003/10/22 15:40:19 murrayc Exp $ */
+
+/* 
+ *
+ * Copyright 2009 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/toolitemgroup.hg b/gtk/src/toolitemgroup.hg
new file mode 100644
index 0000000..fe4e5f1
--- /dev/null
+++ b/gtk/src/toolitemgroup.hg
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 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/container.h>
+#include <gtkmm/toolitem.h>
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/container_p.h)
+
+namespace Gtk
+{
+
+/** A ToolItemGroup is used together with ToolPalette to add ToolItems to a 
+ * palette-like container with different categories and drag and drop support.
+ *
+ * @ingroup Widgets
+ * @ingroup Containers
+ */
+class ToolItemGroup : public Container
+{
+  _CLASS_GTKOBJECT(ToolItemGroup, GtkToolItemGroup, GTK_TOOL_ITEM_GROUP, Gtk::Container, GtkContainer)
+public:
+  _WRAP_CTOR(ToolItemGroup(const Glib::ustring& label = Glib::ustring()), gtk_tool_item_group_new)
+
+  _WRAP_METHOD(void set_label(const Glib::ustring& label), gtk_tool_item_group_set_label)
+  _WRAP_METHOD(void set_label_widget(Widget& label_widget), gtk_tool_item_group_set_label_widget)
+  _WRAP_METHOD(void set_collapsed(bool collapsed = true), gtk_tool_item_group_set_collapsed)
+  _WRAP_METHOD(void set_ellipsize(Pango::EllipsizeMode ellipsize), gtk_tool_item_group_set_ellipsize)
+  _WRAP_METHOD(void set_header_relief(ReliefStyle style), gtk_tool_item_group_set_header_relief)
+
+  _WRAP_METHOD(Glib::ustring get_label() const, gtk_tool_item_group_get_label)
+
+  _WRAP_METHOD(Widget* get_label_widget(), get_label_widget)
+  _WRAP_METHOD(const Widget* get_label_widget() const, get_label_widget, constversion)
+
+  _WRAP_METHOD(bool get_collapsed() const, gtk_tool_item_group_get_collapsed)
+  _WRAP_METHOD(Pango::EllipsizeMode get_ellipsize() const, gtk_tool_item_group_get_ellipsize)
+  _WRAP_METHOD(ReliefStyle get_header_relief() const, gtk_tool_item_group_get_header_relief)
+
+  _WRAP_METHOD(void insert(ToolItem& item, int position), gtk_tool_item_group_insert)
+  _WRAP_METHOD(void set_item_position(ToolItem& item, int position), gtk_tool_item_group_set_item_position)
+  _WRAP_METHOD(int get_item_position(const ToolItem& item), gtk_tool_item_group_get_item_position)
+
+  _WRAP_METHOD(guint get_n_items() const, gtk_tool_item_group_get_n_items)
+
+  _WRAP_METHOD(ToolItem* get_nth_item(guint index), gtk_tool_item_group_get_nth_item)
+  _WRAP_METHOD(const ToolItem* get_nth_item(guint index) const, gtk_tool_item_group_get_nth_item, constversion)
+
+  _WRAP_METHOD(ToolItem* get_drop_item(int x, int y), gtk_tool_item_group_get_drop_item)
+  _WRAP_METHOD(ToolItem* get_drop_item(int x, int y) const, gtk_tool_item_group_get_drop_item, constversion)
+
+  _WRAP_PROPERTY("label", Glib::ustring)
+  _WRAP_PROPERTY("label-widget", Gtk::Widget*)
+  _WRAP_PROPERTY("collapsed", bool)
+  _WRAP_PROPERTY("ellipsize", Pango::EllipsizeMode)
+  _WRAP_PROPERTY("header-relief", ReliefStyle)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/toolpalette.hg b/gtk/src/toolpalette.hg
index a0adc8e..e1d0af7 100644
--- a/gtk/src/toolpalette.hg
+++ b/gtk/src/toolpalette.hg
@@ -19,6 +19,7 @@
 #include <gtkmm/toolitem.h>
 #include <gtkmm/orientable.h>
 #include <gtkmm/adjustment.h>
+#include <gtkmm/toolitemgroup.h>
 
 _DEFS(gtkmm,gtk)
 _PINCLUDE(gtkmm/private/container_p.h)
@@ -28,7 +29,18 @@ namespace Gtk
 
 _WRAP_ENUM(ToolPaletteDragTargets, GtkToolPaletteDragTargets)
 
-/** TODO
+/** A ToolPalette allows you to add ToolItems to a palette-like container with 
+ * various categories and drag and drop support.
+ *
+ * ToolItems cannot be added directly to a ToolPalette - instead they are added 
+ * to a ToolItemGroup which can than be added to a ToolPalette. To add a 
+ * ToolItemGroup to a ToolPalette, use Gtk::Container::add(). 
+ *
+ * The easiest way to use drag and drop with ToolPalette is to call 
+ * add_drag_dest() with the desired drag source palette and the desired drag 
+ * target widget. Then get_drag_item() can be used to get the dragged item in 
+ * the "drag-data-received" signal handler of the drag target.
+ *
  * @ingroup Widgets
  * @ingroup Containers
  */
@@ -41,13 +53,15 @@ class ToolPalette
 public:
   _CTOR_DEFAULT()
 
-  _WRAP_METHOD(void set_group_position(Widget& group, int position), gtk_tool_palette_set_group_position)
-  _WRAP_METHOD(void set_exclusive(Widget& group, bool exclusive), gtk_tool_palette_set_exclusive)
-  _WRAP_METHOD(void set_expand(Widget& group, bool expand = true), gtk_tool_palette_set_expand)
+//This conversion is needed because of https://bugzilla.gnome.org/show_bug.cgi?id=567729#c37
+#m4 _CONVERSION(`ToolItemGroup&',`GtkWidget*',`GTK_WIDGET(($3).gobj())')
+  _WRAP_METHOD(void set_group_position(ToolItemGroup& group, int position), gtk_tool_palette_set_group_position)
+  _WRAP_METHOD(void set_exclusive(ToolItemGroup& group, bool exclusive), gtk_tool_palette_set_exclusive)
+  _WRAP_METHOD(void set_expand(ToolItemGroup& group, bool expand = true), gtk_tool_palette_set_expand)
 
-  _WRAP_METHOD(int get_group_position(Widget& group) const, gtk_tool_palette_get_group_position)
-  _WRAP_METHOD(bool get_exclusive(Widget& group) const, gtk_tool_palette_get_exclusive)
-  _WRAP_METHOD(bool get_expand(Widget& group), gtk_tool_palette_get_expand)
+  _WRAP_METHOD(int get_group_position(ToolItemGroup& group) const, gtk_tool_palette_get_group_position)
+  _WRAP_METHOD(bool get_exclusive(ToolItemGroup& group) const, gtk_tool_palette_get_exclusive)
+  _WRAP_METHOD(bool get_expand(ToolItemGroup& group), gtk_tool_palette_get_expand)
 
   _WRAP_METHOD(void set_icon_size(IconSize icon_size), gtk_tool_palette_set_icon_size)
   _WRAP_METHOD(void unset_icon_size(), gtk_tool_palette_unset_icon_size)
@@ -58,8 +72,15 @@ public:
   _WRAP_METHOD(ToolbarStyle get_style() const, gtk_tool_palette_get_style)
 
   _WRAP_METHOD(ToolItem* get_drop_item(int x, int y), gtk_tool_palette_get_drop_item)
-  _WRAP_METHOD(Widget* get_drop_group(int x, int y), gtk_tool_palette_get_drop_group)
-  _WRAP_METHOD(Widget* get_drag_item(const SelectionData& selection), gtk_tool_palette_get_drag_item )
+
+//This conversion is needed because of https://bugzilla.gnome.org/show_bug.cgi?id=567729#c37
+#m4 _CONVERSION(`GtkWidget*',`ToolItemGroup*',`Glib::wrap(GTK_TOOL_ITEM_GROUP($3))')
+#m4 _CONVERSION(`GtkWidget*',`const ToolItemGroup*',`Glib::wrap(GTK_TOOL_ITEM_GROUP($3))')
+  _WRAP_METHOD(ToolItemGroup* get_drop_group(int x, int y), gtk_tool_palette_get_drop_group)
+  _WRAP_METHOD(const ToolItemGroup* get_drop_group(int x, int y) const, gtk_tool_palette_get_drop_group, constversion)
+
+  _WRAP_METHOD(ToolItem* get_drag_item(const SelectionData& selection), gtk_tool_palette_get_drag_item)
+  _WRAP_METHOD(const ToolItem* get_drag_item(const SelectionData& selection) const, gtk_tool_palette_get_drag_item, constversion)
 
   _WRAP_METHOD(void set_drag_source(ToolPaletteDragTargets targets), gtk_tool_palette_set_drag_source)
   _WRAP_METHOD(void add_drag_dest(Gtk::Widget& widget, DestDefaults flags, ToolPaletteDragTargets targets, Gdk::DragAction actions), gtk_tool_palette_add_drag_dest)



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