[gtkmm] Added EntryBuffer and used it in the Entry API.



commit 87ffabf1b7e1355c9e3a04684e7622b442599c7f
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jan 25 09:56:34 2010 +0100

    Added EntryBuffer and used it in the Entry API.
    
    * gtk/src/entrybuffer.[hg|cc]: Added EntryBuffer. GtkEntryBuffer was
    actually added to GTK+ 2.18, but we didn't wrap it until now.
    * gtk/src/entry.hg: Aded get/set_buffer(), propery, and new constructor.

 ChangeLog                                 |    8 ++
 gtk/src/entry.hg                          |    9 ++-
 gtk/src/entrybuffer.ccg                   |   48 +++++++++++
 gtk/src/entrybuffer.hg                    |  128 +++++++++++++++++++++++++++++
 gtk/src/filelist.am                       |    1 +
 tools/extra_defs_gen/generate_defs_gtk.cc |    1 +
 tools/m4/convert_gtk.m4                   |    4 +
 7 files changed, 198 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4f67e3a..b9b2a06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-01-25  Murray Cumming  <murrayc murrayc com>
 
+	Added EntryBuffer and used it in the Entry API.
+
+	* gtk/src/entrybuffer.[hg|cc]: Added EntryBuffer. GtkEntryBuffer was 
+	actually added to GTK+ 2.18, but we didn't wrap it until now.
+	* gtk/src/entry.hg: Aded get/set_buffer(), propery, and new constructor.
+
+2010-01-25  Murray Cumming  <murrayc murrayc com>
+
 	Entry: Added get_text_window() and get_icon_window().
 
 	* gtk/src/entry.hg: Added get_text_window() and get_icon_window().
diff --git a/gtk/src/entry.hg b/gtk/src/entry.hg
index e180d8b..7bac6a9 100644
--- a/gtk/src/entry.hg
+++ b/gtk/src/entry.hg
@@ -27,6 +27,7 @@
 #include <gtkmm/adjustment.h>
 #include <gtkmm/image.h> //For ImageType.
 #include <gtkmm/border.h>
+#include <gtkmm/entrybuffer.h>
 
 _DEFS(gtkmm,gtk)
 _PINCLUDE(gtkmm/private/widget_p.h)
@@ -61,7 +62,12 @@ class Entry
 public:
 
   _CTOR_DEFAULT
-  
+  _WRAP_CTOR(Entry(const Glib::RefPtr<EntryBuffer>& buffer), gtk_entry_new_with_buffer)
+
+  _WRAP_METHOD(Glib::RefPtr<EntryBuffer> get_buffer(), gtk_entry_get_buffer, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const EntryBuffer> get_buffer() const, gtk_entry_get_buffer, refreturn, constversion)
+
+  _WRAP_METHOD(void set_buffer(const Glib::RefPtr<EntryBuffer>& buffer), gtk_entry_set_buffer)
 
   _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_text_window(), gtk_entry_get_text_window, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_text_window() const, gtk_entry_get_text_window, refreturn, constversion)
@@ -190,6 +196,7 @@ public:
   _IGNORE_SIGNAL("toggle_overwrite")
   _IGNORE_SIGNAL("backspace")
 
+  _WRAP_PROPERTY("buffer", Glib::RefPtr<EntryBuffer>)
   _WRAP_PROPERTY("cursor-position", int)
   _WRAP_PROPERTY("selection-bound", int)
   _WRAP_PROPERTY("editable", bool)
diff --git a/gtk/src/entrybuffer.ccg b/gtk/src/entrybuffer.ccg
new file mode 100644
index 0000000..8f0e2d4
--- /dev/null
+++ b/gtk/src/entrybuffer.ccg
@@ -0,0 +1,48 @@
+// -*- c++ -*-
+/* $Id: entrybuffer.ccg,v 1.8 2006/11/20 09:19:49 murrayc Exp $ */
+
+/* Copyright(C) 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>
+#include <glib.h>
+
+
+namespace Gtk
+{
+
+EntryBuffer::EntryBuffer(const Glib::ustring& text)
+{
+  set_text(text);
+}
+
+void EntryBuffer::set_text(const Glib::ustring& text)
+{
+  gtk_entry_buffer_set_text(gobj(), text.c_str(), -1 /* see docs */); 
+}
+
+guint EntryBuffer::insert_text(guint position, const Glib::ustring& text)
+{
+  return gtk_entry_buffer_insert_text(gobj(), position, text.c_str(), -1 /* see docs */);
+}
+
+void EntryBuffer::emit_inserted_text(guint position, const Glib::ustring& text)
+{
+  gtk_entry_buffer_emit_inserted_text(gobj(), position, text.c_str(), -1 /* see docs */); 
+}
+
+} // namespace Gtk
diff --git a/gtk/src/entrybuffer.hg b/gtk/src/entrybuffer.hg
new file mode 100644
index 0000000..9bd3177
--- /dev/null
+++ b/gtk/src/entrybuffer.hg
@@ -0,0 +1,128 @@
+/* $Id: entrybuffer.hg,v 1.20 2006/11/20 09:19:49 murrayc Exp $ */
+
+/* Copyright(C) 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.
+ */
+
+// This is for including the config header before any code (such as
+// the #ifndef GTKMM_DISABLE_DEPRECATED in deprecated classes) is generated:
+_CONFIGINCLUDE(gtkmmconfig.h)
+
+#include <gtkmm/object.h>
+#include <gtkmm/texttagtable.h>
+#include <gtkmm/textchildanchor.h>
+#include <gtkmm/textmark.h>
+#include <gtkmm/textiter.h>
+#include <gtkmm/clipboard.h>
+#include <gdkmm/pixbuf.h>
+#include <gtkmmconfig.h>
+#include <utility>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+
+class TextMark;
+class TextIter;
+
+/** A Text buffer for the Entry widget.
+ *
+ * The EntryBuffer class contains the actual text displayed in an Entry widget.
+ *
+ * A single EntryBuffer object can be shared by multiple Entry
+ * widgets which will then share the same text content, but not the cursor
+ * position, visibility attributes, icon etc.
+ *
+ * EntryBuffer may be derived from. Such a derived class might allow
+ * text to be stored in an alternate location, such as non-pageable memory,
+ * useful in the case of important passwords. Or a derived class could 
+ * integrate with an application's concept of undo/redo.
+ *
+ * @newin2p20
+ */
+class EntryBuffer : public Glib::Object
+{
+   _CLASS_GOBJECT(EntryBuffer, GtkEntryBuffer, GTK_TEXT_BUFFER, Glib::Object, GObject)
+protected:
+
+  /** Create a new EntryBuffer object with no text.
+   */
+  _CTOR_DEFAULT()
+
+  /** Create a new EntryBuffer object.
+   *
+   * @param text Initial buffer text.
+   */
+  explicit EntryBuffer(const Glib::ustring& text);
+
+public:
+  /** Create a new EntryBuffer object with no text.
+   */
+  _WRAP_CREATE()
+
+  /** Create a new EntryBuffer object.
+   *
+   * @param text Initial buffer text.
+   */
+  _WRAP_CREATE(const Glib::ustring& text)
+
+  _WRAP_METHOD(gsize get_bytes() const, gtk_entry_buffer_get_bytes)
+  _WRAP_METHOD(guint get_length() const, gtk_entry_buffer_get_length)
+  _WRAP_METHOD(Glib::ustring get_text() const, gtk_entry_buffer_get_text)
+
+  /** Sets the text in the buffer.
+   * This is roughly equivalent to calling delete_text() and insert_text().
+   *
+   * @param text The text to set in the buffer.
+   */
+  void set_text(const Glib::ustring& text);
+  _IGNORE(gtk_entry_buffer_set_text)
+
+  _WRAP_METHOD(void set_max_length(int max_length), gtk_entry_buffer_set_max_length)
+  _WRAP_METHOD(int get_max_length() const, gtk_entry_buffer_get_max_length)
+
+  /** Inserts @a text into the contents of the buffer, at position @a position.
+   *
+   * @param position The position at which to insert text.
+   * @param text The text to insert into the buffer.
+   * @result The number of characters actually inserted.
+   */
+  guint insert_text(guint position, const Glib::ustring& text);
+  _IGNORE(gtk_entry_buffer_insert_text)
+
+  _WRAP_METHOD(guint delete_text(guint position, int n_chars), gtk_entry_buffer_delete_text)
+
+  /** Used when deriving from EntryBuffer.
+   * @param position Position at which text was inserted.
+   * @param text Text that was inserted.
+   */
+  void emit_inserted_text(guint position, const Glib::ustring& text);
+  _IGNORE(gtk_entry_buffer_emit_inserted_text)
+
+  _WRAP_METHOD(void emit_deleted_text(guint position, guint n_chars),  gtk_entry_buffer_emit_deleted_text)
+
+  _WRAP_SIGNAL(void inserted_text(guint position, const gchar* chars, guint n_chars), "inserted-text")
+  _WRAP_SIGNAL(void deleted_text(guint position, guint n_chars), "deleted-text")
+
+  _WRAP_PROPERTY("text", Glib::ustring)
+  _WRAP_PROPERTY("length", guint)
+  _WRAP_PROPERTY("max-length", int)
+};
+
+} // namespace Gtk
+
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index e7c4c5f..37cb32e 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -55,6 +55,7 @@ gtkmm_files_any_hg =		\
 	editable.hg		\
 	entry.hg		\
 	entrycompletion.hg	\
+	entrybuffer.hg		\
 	enums.hg		\
 	eventbox.hg		\
 	expander.hg		\
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index f73a281..6ee9149 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -119,6 +119,7 @@ int main(int argc, char** argv)
             << get_defs( GTK_TYPE_EDITABLE )
             << get_defs( GTK_TYPE_ENTRY )
             << get_defs( GTK_TYPE_ENTRY_COMPLETION )
+            << get_defs( GTK_TYPE_ENTRY_BUFFER )
             << get_defs( GTK_TYPE_EVENT_BOX )
             << get_defs( GTK_TYPE_EXPANDER )
             << get_defs( GTK_TYPE_FILE_FILTER )
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index ef722d8..e8217c2 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -412,6 +412,10 @@ _CONVERSION(`GtkTextChildAnchor*',`Glib::RefPtr<ChildAnchor>',`Glib::wrap($3)')
 _CONVERSION(`GtkTextChildAnchor*',`Glib::RefPtr<TextChildAnchor>',`Glib::wrap($3)')
 _CONVERSION(`GtkTextChildAnchor*',`Glib::RefPtr<const TextChildAnchor>',`Glib::wrap($3)')
 
+_CONVERSION(`GtkEntryBuffer*',`Glib::RefPtr<EntryBuffer>',`Glib::wrap($3)')
+_CONVERSION(`GtkEntryBuffer*',`Glib::RefPtr<const EntryBuffer>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<EntryBuffer>&',`GtkEntryBuffer*',__CONVERT_REFPTR_TO_P)
+
 # Tree:
 #_CONVERSION(`const TreeIter&',`const GtkTreeIter*',__FR2P)
 _CONVERSION(`const iterator&',`const GtkTreeIter*',__FR2P)



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