[gtksourceviewmm] Quick and dirty SourceGutterRenderer{Pixbuf, Text} wrapper. * gtksourceview/src/sourcegutterrendererp



commit 8ee03bdcb77ea814e4d9599e17fead6da02812d2
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Wed Dec 1 20:48:06 2010 +0100

    Quick and dirty SourceGutterRenderer{Pixbuf,Text} wrapper.
    * gtksourceview/src/sourcegutterrendererpixbuf.ccg:
    * gtksourceview/src/sourcegutterrendererpixbuf.hg:
    * gtksourceview/src/sourcegutterrenderertext.ccg:
    * gtksourceview/src/sourcegutterrenderertext.hg: New wrappers.
    * gtksourceview/src/filelist.am: Added new files to build.
    * gtksourceview/gtksourceviewmm/.gitignore: Updated.

 gtksourceview/gtksourceviewmm/.gitignore         |    2 +
 gtksourceview/src/filelist.am                    |    2 +
 gtksourceview/src/sourcegutterrendererpixbuf.ccg |   21 +++
 gtksourceview/src/sourcegutterrendererpixbuf.hg  |  168 ++++++++++++++++++++++
 gtksourceview/src/sourcegutterrenderertext.ccg   |   37 +++++
 gtksourceview/src/sourcegutterrenderertext.hg    |   53 +++++++
 6 files changed, 283 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourceviewmm/.gitignore b/gtksourceview/gtksourceviewmm/.gitignore
index e399485..9106f3b 100644
--- a/gtksourceview/gtksourceviewmm/.gitignore
+++ b/gtksourceview/gtksourceviewmm/.gitignore
@@ -9,6 +9,8 @@
 /sourcecompletionwords.*
 /sourcegutter.*
 /sourcegutterrenderer.*
+/sourcegutterrendererpixbuf.*
+/sourcegutterrenderertext.*
 /sourcelanguage.*
 /sourcelanguagemanager.*
 /sourcemark.*
diff --git a/gtksourceview/src/filelist.am b/gtksourceview/src/filelist.am
index c507359..1dab839 100644
--- a/gtksourceview/src/filelist.am
+++ b/gtksourceview/src/filelist.am
@@ -20,6 +20,8 @@ files_hg =				\
 	sourcecompletionwords.hg        \
 	sourcegutter.hg			\
 	sourcegutterrenderer.hg		\
+	sourcegutterrendererpixbuf.hg	\
+	sourcegutterrenderertext.hg	\
 	sourcelanguage.hg		\
 	sourcelanguagemanager.hg	\
 	sourcemark.hg			\
diff --git a/gtksourceview/src/sourcegutterrendererpixbuf.ccg b/gtksourceview/src/sourcegutterrendererpixbuf.ccg
new file mode 100644
index 0000000..8779000
--- /dev/null
+++ b/gtksourceview/src/sourcegutterrendererpixbuf.ccg
@@ -0,0 +1,21 @@
+/* sourcegutterrendererpixbuf.cc
+ *
+ * Copyright (C) 2009, 2010 Krzesimir Nowak
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gtksourceview/gtksourcegutterrendererpixbuf.h>
+
diff --git a/gtksourceview/src/sourcegutterrendererpixbuf.hg b/gtksourceview/src/sourcegutterrendererpixbuf.hg
new file mode 100644
index 0000000..90ff298
--- /dev/null
+++ b/gtksourceview/src/sourcegutterrendererpixbuf.hg
@@ -0,0 +1,168 @@
+/* sourcegutterrendererpixbuf.h
+ *
+ * Copyright (C) 2010 Krzesimir Nowak
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/// \file
+/// \brief SourceGutterRendererPixbuf class
+
+#include <glibmm/refptr.h>
+#include <gdkmm/pixbuf.h>
+#include <gtksourceviewmm/sourcegutterrenderer.h>
+
+_DEFS(gtksourceviewmm,gtksourceview)
+_PINCLUDE(gtksourceviewmm/private/sourcegutterrenderer_p.h)
+
+namespace Gsv
+{
+
+// TODO: write docs.
+class SourceGutterRendererPixbuf : public SourceGutterRenderer
+{
+  _CLASS_GTKOBJECT(SourceGutterRendererPixbuf, GtkSourceGutterRendererPixbuf, GTK_SOURCE_GUTTER_RENDERER_PIXBUF, SourceGutterRenderer, GtkSourceGutterRenderer)
+public:
+  _CTOR_DEFAULT()
+
+  _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_pixbuf(), gtk_source_gutter_renderer_pixbuf_get_pixbuf, refreturn)
+
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_pixbuf() const, gtk_source_gutter_renderer_pixbuf_get_pixbuf, constversion)
+
+#m4 _CONVERSION(`const Glib::RefPtr<const Gdk::Pixbuf>&', `GdkPixbuf*', `const_cast<GdkPixbuf*>(Glib::unwrap($3))')
+  _WRAP_METHOD(void set_pixbuf(const Glib::RefPtr<const Gdk::Pixbuf>& pixbuf), gtk_source_gutter_renderer_pixbuf_set_pixbuf)
+
+  _WRAP_METHOD(std::string get_stock_id() const, gtk_source_gutter_renderer_pixbuf_get_stock_id)
+
+  _WRAP_METHOD(void set_stock_id(const std::string& stock_id), gtk_source_gutter_renderer_pixbuf_set_stock_id)
+
+  _WRAP_METHOD(Gtk::IconSize get_icon_size() const, gtk_source_gutter_renderer_pixbuf_get_icon_size)
+
+  _WRAP_METHOD(void set_icon_size(Gtk::IconSize size), gtk_source_gutter_renderer_pixbuf_set_icon_size)
+
+  _WRAP_METHOD(std::string get_stock_detail() const, gtk_source_gutter_renderer_pixbuf_get_stock_detail)
+
+  _WRAP_METHOD(void set_stock_detail(const std::string& stock_detail), gtk_source_gutter_renderer_pixbuf_set_stock_detail)
+
+#m4 _CONVERSION(`GIcon*', `Glib::RefPtr<Gio::Icon>', `Glib::wrap($3)')
+  _WRAP_METHOD(Glib::RefPtr<Gio::Icon> get_icon(), gtk_source_gutter_renderer_pixbuf_get_gicon, refreturn)
+
+  _WRAP_METHOD(Glib::RefPtr<const Gio::Icon> get_icon() const, gtk_source_gutter_renderer_pixbuf_get_gicon, constversion)
+
+#m4 _CONVERSION(`const Glib::RefPtr<Gio::Icon>&', `GIcon*', `Glib::unwrap($3)')
+  _WRAP_METHOD(void set_icon(const Glib::RefPtr<Gio::Icon>& icon), gtk_source_gutter_renderer_pixbuf_set_gicon)
+
+  _WRAP_METHOD(std::string get_icon_name() const, gtk_source_gutter_renderer_pixbuf_get_icon_name)
+
+  _WRAP_METHOD(void set_icon_name(const std::string& icon_name), gtk_source_gutter_renderer_pixbuf_set_icon_name)
+
+/*
+
+
+#m4 _CONVERSION(`const Cairo::RefPtr<Cairo::Context>&', `cairo_t*', `(($3) ? ($3)->cobj() : 0)')
+#m4 _CONVERSION(`const Gdk::Rectangle&',`const GdkRectangle*',($3).gobj())
+#m4 _CONVERSION(`Gtk::TextIter&',`GtkTextIter*',($3).gobj())
+  _WRAP_METHOD(void begin(
+                  const Cairo::RefPtr<Cairo::Context>& cr,
+                  const Gdk::Rectangle& background_area,
+                  const Gdk::Rectangle& cell_area,
+                  Gtk::TextIter& start,
+                  Gtk::TextIter& end), gtk_source_gutter_renderer_begin)
+
+  _WRAP_METHOD(void draw(
+                  const Cairo::RefPtr<Cairo::Context>& cr,
+                  const Gdk::Rectangle& background_area,
+                  const Gdk::Rectangle& cell_area,
+                  Gtk::TextIter& start,
+                  Gtk::TextIter& end,
+                  SourceGutterRendererState), gtk_source_gutter_renderer_draw)
+
+  _WRAP_METHOD(void end(), gtk_source_gutter_renderer_end)
+
+  _WRAP_METHOD(int get_size() const, gtk_source_gutter_renderer_get_size)
+
+  _WRAP_METHOD(void set_size(int size), gtk_source_gutter_renderer_set_size)
+
+  _WRAP_METHOD(bool get_visible() const, gtk_source_gutter_renderer_get_visible)
+
+  _WRAP_METHOD(void set_visible(bool visible), gtk_source_gutter_renderer_set_visible)
+
+// TODO: write padding class. krnowak
+
+  _WRAP_METHOD(void get_padding(int& xpad, int& ypad) const, gtk_source_gutter_renderer_get_padding)
+
+  _WRAP_METHOD(void set_padding(int xpad, int ypad), gtk_source_gutter_renderer_set_padding)
+
+// TODO: write alignment class. krnowak
+
+  _WRAP_METHOD(void get_alignment(float& xalign, float& yalign) const, gtk_source_gutter_renderer_get_alignment)
+
+  _WRAP_METHOD(void set_alignment(float xalign, float yalign), gtk_source_gutter_renderer_set_alignment)
+
+  _WRAP_METHOD(SourceGutterRendererAlignmentMode get_alignment_mode() const, gtk_source_gutter_renderer_get_alignment_mode)
+
+  _WRAP_METHOD(void set_alignment_mode(SourceGutterRendererAlignmentMode mode), gtk_source_gutter_renderer_set_alignment_mode)
+
+  _WRAP_METHOD(Gtk::TextWindowType get_window_type() const, gtk_source_gutter_renderer_get_window_type)
+
+#m4 _CONVERSION(GtkTextView*, Gtk::TextView*, Glib::wrap($3))
+  _WRAP_METHOD(Gtk::TextView* get_view(), gtk_source_gutter_renderer_get_view)
+
+  _WRAP_METHOD(const Gtk::TextView* get_view() const, gtk_source_gutter_renderer_get_view, constversion)
+
+// TODO: use std::pair? krnowak
+
+#m4 _CONVERSION(`Gdk::Color&',`GdkColor*',`($3).gobj()')
+  _WRAP_METHOD(bool get_background(Gdk::Color& color) const, gtk_source_gutter_renderer_get_background)
+
+  bool is_background_set() const;
+
+#m4 _CONVERSION(`const Gdk::Color&',`const GdkColor*',`($3).gobj()')
+  _WRAP_METHOD(void set_background(const Gdk::Color& color), gtk_source_gutter_renderer_set_background)
+
+  _IGNORE(gtk_source_gutter_renderer_activate, gtk_source_gutter_renderer_query_activatable, gtk_source_gutter_renderer_query_tooltip, gtk_source_gutter_renderer_query_data)
+
+  _WRAP_METHOD(void queue_draw(), gtk_source_gutter_renderer_queue_draw)
+
+protected:
+
+
+#m4 _CONVERSION(`const GdkRectangle*',`const Gdk::Rectangle&',`Glib::wrap($3)')
+#m4 _CONVERSION(`GdkRectangle*',`const Gdk::Rectangle&',`Glib::wrap($3)')
+#m4 _CONVERSION(`GtkTextIter*',`Gtk::TextIter&',`Glib::wrap($3)')
+
+  _WRAP_VFUNC(void begin(
+                  const Cairo::RefPtr<Cairo::Context>& cr,
+                  const Gdk::Rectangle& background_area,
+                  const Gdk::Rectangle& cell_area,
+                  Gtk::TextIter& start,
+                  Gtk::TextIter& end), begin)
+
+  _WRAP_VFUNC(void draw(
+                  const Cairo::RefPtr<Cairo::Context>& cr,
+                  const Gdk::Rectangle& background_area,
+                  const Gdk::Rectangle& cell_area,
+                  Gtk::TextIter& start,
+                  Gtk::TextIter& end,
+                  SourceGutterRendererState), draw)
+
+  _WRAP_VFUNC(void end(), end)
+
+public: */
+};
+
+} // namespace Gsv
+
+
diff --git a/gtksourceview/src/sourcegutterrenderertext.ccg b/gtksourceview/src/sourcegutterrenderertext.ccg
new file mode 100644
index 0000000..3681427
--- /dev/null
+++ b/gtksourceview/src/sourcegutterrenderertext.ccg
@@ -0,0 +1,37 @@
+/* sourcegutterrenderertext.cc
+ *
+ * Copyright (C) 2009, 2010 Krzesimir Nowak
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gtksourceview/gtksourcegutterrenderertext.h>
+
+namespace Gsv
+{
+
+void SourceGutterRendererText::set_text(const SourceMarkup& markup)
+{
+  const Glib::ustring str(markup.get_string());
+
+  gtk_source_gutter_renderer_text_set_markup(gobj(), str.c_str(), str.bytes());
+}
+
+void SourceGutterRendererText::set_text(const Glib::ustring& text)
+{
+  gtk_source_gutter_renderer_text_set_text(gobj(), text.c_str(), text.bytes());
+}
+
+} // namespace Gsv
diff --git a/gtksourceview/src/sourcegutterrenderertext.hg b/gtksourceview/src/sourcegutterrenderertext.hg
new file mode 100644
index 0000000..6bb9f4b
--- /dev/null
+++ b/gtksourceview/src/sourcegutterrenderertext.hg
@@ -0,0 +1,53 @@
+/* sourcegutterrenderertext.h
+ *
+ * Copyright (C) 2010 Krzesimir Nowak
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/// \file
+/// \brief SourceGutterRendererText class
+
+#include <gtksourceviewmm/sourcegutterrenderer.h>
+#include <gtksourceviewmm/sourcemarkup.h>
+
+_DEFS(gtksourceviewmm,gtksourceview)
+_PINCLUDE(gtksourceviewmm/private/sourcegutterrenderer_p.h)
+
+namespace Gsv
+{
+
+// TODO: write docs.
+class SourceGutterRendererText : public SourceGutterRenderer
+{
+  _CLASS_GTKOBJECT(SourceGutterRendererText, GtkSourceGutterRendererText, GTK_SOURCE_GUTTER_RENDERER_TEXT, SourceGutterRenderer, GtkSourceGutterRenderer)
+public:
+  _CTOR_DEFAULT()
+
+  _IGNORE(gtk_source_gutter_renderer_text_set_markup)
+  void set_text(const SourceMarkup& markup);
+
+  _IGNORE(gtk_source_gutter_renderer_text_set_text)
+  void set_text(const Glib::ustring& text);
+
+#m4 _CONVERSION(`const SourceMarkup&', `const gchar*', `($3).get_c_str()')
+  _WRAP_METHOD(void measure(const SourceMarkup& markup, int& width, int& height), gtk_source_gutter_renderer_text_measure_markup)
+
+  _WRAP_METHOD(void measure(const Glib::ustring& text, int& width, int& height), gtk_source_gutter_renderer_text_measure)
+};
+
+} // namespace Gsv
+
+



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