[gtksourceviewmm/devel] Fixed constructors.



commit a0ae81e2f44bec8427c799acc3f72d04f1fb3f54
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Wed Jan 13 00:24:17 2010 +0100

    Fixed constructors.
    
    * gtksourceview/src/sourcebuffer.ccg:
    * gtksourceview/src/sourcebuffer.hg:
    * gtksourceview/src/sourcecompletioninfo.ccg:
    * gtksourceview/src/sourcecompletioninfo.hg:
    * gtksourceview/src/sourcecompletionitem.ccg:
    * gtksourceview/src/sourcecompletionitem.hg
    * gtksourceview/src/sourceprintcompositor.ccg:
    * gtksourceview/src/sourceprintcompositor.hg: Constructors needed
    to be wrapped by hand, because C _new() functions were doing
    something more than call to g_object_new() or were calling
    g_object_new() with properties not given as a parameter.

 gtksourceview/src/sourcebuffer.ccg          |   12 +++++-
 gtksourceview/src/sourcebuffer.hg           |    4 +--
 gtksourceview/src/sourcecompletioninfo.ccg  |    4 ++
 gtksourceview/src/sourcecompletioninfo.hg   |    2 +-
 gtksourceview/src/sourcecompletionitem.ccg  |   50 +++++++++++++++++++++++++++
 gtksourceview/src/sourcecompletionitem.hg   |   10 ++---
 gtksourceview/src/sourceprintcompositor.ccg |    6 +++
 gtksourceview/src/sourceprintcompositor.hg  |    3 +-
 8 files changed, 77 insertions(+), 14 deletions(-)
---
diff --git a/gtksourceview/src/sourcebuffer.ccg b/gtksourceview/src/sourcebuffer.ccg
index 11a4290..18d1701 100644
--- a/gtksourceview/src/sourcebuffer.ccg
+++ b/gtksourceview/src/sourcebuffer.ccg
@@ -25,19 +25,27 @@
 namespace gtksourceview
 {
 
+SourceBuffer::SourceBuffer (const Glib::RefPtr<Gtk::TextTagTable>& tag_table) :
+  _CONSTRUCT("tag-table", Glib::unwrap(tag_table))
+{}
+
+// TODO: check later how bug 606732 goes.
 SourceBuffer::SourceBuffer (const Glib::RefPtr<SourceLanguage> &language) :
-    _CONSTRUCT
+//    _CONSTRUCT("tag-table, NULL")
+    _CONSTRUCT("tag-table", NULL, "language", Glib::unwrap(language))
 {
+    /*
     if (language)
     {
         gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (gobject_),
-                                        language->gobj ()) ;
+                                        Glib::unwrap(language)) ;
     }
     else
     {
         gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (gobject_),
                                         0) ;
     }
+    */
 }
 
 bool SourceBuffer::backward_iter_to_source_mark(Gtk::TextIter& iter)
diff --git a/gtksourceview/src/sourcebuffer.hg b/gtksourceview/src/sourcebuffer.hg
index 4d0615b..46e9332 100644
--- a/gtksourceview/src/sourcebuffer.hg
+++ b/gtksourceview/src/sourcebuffer.hg
@@ -54,9 +54,7 @@ class SourceBuffer : public Gtk::TextBuffer
 protected:
   _CTOR_DEFAULT
 
-#m4 _CONVERSION(`const Glib::RefPtr<Gtk::TextTagTable>&',`GtkTextTagTable*',__CONVERT_REFPTR_TO_P)
-
-  _WRAP_CTOR(SourceBuffer(const Glib::RefPtr<Gtk::TextTagTable>& tag_table), gtk_source_buffer_new)
+  explicit SourceBuffer (const Glib::RefPtr<Gtk::TextTagTable>& tag_table) ;
   explicit SourceBuffer (const Glib::RefPtr<SourceLanguage> &language) ;
 
 public:
diff --git a/gtksourceview/src/sourcecompletioninfo.ccg b/gtksourceview/src/sourcecompletioninfo.ccg
index 5375587..2f29e7d 100644
--- a/gtksourceview/src/sourcecompletioninfo.ccg
+++ b/gtksourceview/src/sourcecompletioninfo.ccg
@@ -22,6 +22,10 @@
 namespace gtksourceview
 {
 
+SourceCompletionInfo::SourceCompletionInfo() :
+  _CONSTRUCT("type", GTK_WINDOW_POPUP)
+{}
+
 void
 SourceCompletionInfo::move_to_iter(const Gtk::TextView& view)
 {
diff --git a/gtksourceview/src/sourcecompletioninfo.hg b/gtksourceview/src/sourcecompletioninfo.hg
index 358a849..ec44daa 100644
--- a/gtksourceview/src/sourcecompletioninfo.hg
+++ b/gtksourceview/src/sourcecompletioninfo.hg
@@ -33,7 +33,7 @@ class SourceCompletionInfo : public Gtk::Window
   _CLASS_GTKOBJECT(SourceCompletionInfo, GtkSourceCompletionInfo, GTK_SOURCE_COMPLETION_INFO, Gtk::Window, GtkWindow)
 
 public:
-  _CTOR_DEFAULT()
+  SourceCompletionInfo();
 
 #m4 _CONVERSION(`const Gtk::TextView&',`GtkTextView*',`const_cast<GtkTextView*>(($3).gobj())')
 #m4 _CONVERSION(`const Gtk::TextIter&',`GtkTextIter*',`const_cast<GtkTextIter*>(($3).gobj())')
diff --git a/gtksourceview/src/sourcecompletionitem.ccg b/gtksourceview/src/sourcecompletionitem.ccg
index 7df38b2..d719382 100644
--- a/gtksourceview/src/sourcecompletionitem.ccg
+++ b/gtksourceview/src/sourcecompletionitem.ccg
@@ -18,3 +18,53 @@
  */
 
 #include <gtksourceview/gtksourcecompletionitem.h>
+
+namespace gtksourceview
+{
+
+SourceCompletionItem::SourceCompletionItem(const Glib::ustring& label, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info) :
+  _CONSTRUCT("label", label.c_str(), "text", text.c_str(), "icon", Glib::unwrap(icon), "info", (info.empty() ? 0 : info.c_str()))
+{}
+
+SourceCompletionItem::SourceCompletionItem(const SourceMarkup& markup, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info) :
+  _CONSTRUCT("markup", markup.get_c_str(), "text", text.c_str(), "icon", Glib::unwrap(icon), "info", (info.empty() ? 0 : info.c_str()))
+{}
+
+SourceCompletionItem::SourceCompletionItem(const Glib::ustring& label, const Glib::ustring& text, const Gtk::StockID& stock, const Glib::ustring& info) :
+  _CONSTRUCT("text", text.c_str(), "info", (info.empty() ? 0 : info.c_str()))
+{
+  GdkPixbuf* icon;
+  Glib::ustring temp_label(label);
+
+  if (stock)
+  {
+    GtkIconTheme* theme = gtk_icon_theme_get_default();
+
+    int width, height;
+    gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
+    icon = gtk_icon_theme_load_icon (theme,
+                                     stock.get_c_str(),
+                                     width,
+                                     GTK_ICON_LOOKUP_USE_BUILTIN,
+                                     NULL);
+
+    GtkStockItem stock_item;
+    if (temp_label.empty() && gtk_stock_lookup (stock.get_c_str(), &stock_item))
+    {
+      temp_label = stock_item.label;
+    }
+  }
+  else
+  {
+    icon = NULL;
+  }
+
+  g_object_set(gobj(), "label", temp_label.c_str(), "icon", icon, NULL);
+
+  if (icon)
+  {
+    g_object_unref(icon);
+  }
+}
+
+} // namespace gtksourceview
diff --git a/gtksourceview/src/sourcecompletionitem.hg b/gtksourceview/src/sourcecompletionitem.hg
index 96fbaea..6ffe5dd 100644
--- a/gtksourceview/src/sourcecompletionitem.hg
+++ b/gtksourceview/src/sourcecompletionitem.hg
@@ -34,15 +34,13 @@ class SourceCompletionItem : public Glib::Object
   _CLASS_GOBJECT(SourceCompletionItem, GtkSourceCompletionItem, GTK_SOURCE_COMPLETION_ITEM, Glib::Object, GObject)
   _IMPLEMENTS_INTERFACE(SourceCompletionProposal)
 protected:
-#m4 _CONVERSION(`const Glib::RefPtr<const Gdk::Pixbuf>&',`GdkPixbuf*',`const_cast<GdkPixbuf*>(($3)->gobj())')
-#m4 _CONVERSION(`const SourceMarkup&',`const gchar*',`($3).get_c_str()')
-  _WRAP_CTOR(SourceCompletionItem(const Glib::ustring& label, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info), gtk_source_completion_item_new)
-  _WRAP_CTOR(SourceCompletionItem(const SourceMarkup& markup, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info), gtk_source_completion_item_new_with_markup)
-  _WRAP_CTOR(SourceCompletionItem(const SourceMarkup& markup, const Glib::ustring& text, const Gtk::StockID& stock, const Glib::ustring& info), gtk_source_completion_item_new_from_stock)
+  explicit SourceCompletionItem(const Glib::ustring& label, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info);
+  explicit SourceCompletionItem(const SourceMarkup& markup, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info);
+  explicit SourceCompletionItem(const Glib::ustring& label, const Glib::ustring& text, const Gtk::StockID& stock, const Glib::ustring& info);
 public:
   _WRAP_CREATE(const Glib::ustring& label, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info)
   _WRAP_CREATE(const SourceMarkup& markup, const Glib::ustring& text, const Glib::RefPtr<const Gdk::Pixbuf>& icon, const Glib::ustring& info)
-  _WRAP_CREATE(const SourceMarkup& markup, const Glib::ustring& text, const Gtk::StockID& stock, const Glib::ustring& info)
+  _WRAP_CREATE(const Glib::ustring& label, const Glib::ustring& text, const Gtk::StockID& stock, const Glib::ustring& info)
 
   _WRAP_PROPERTY("icon", Glib::RefPtr<Gdk::Pixbuf>)
   _WRAP_PROPERTY("info", Glib::ustring)
diff --git a/gtksourceview/src/sourceprintcompositor.ccg b/gtksourceview/src/sourceprintcompositor.ccg
index eb3a084..5427d46 100644
--- a/gtksourceview/src/sourceprintcompositor.ccg
+++ b/gtksourceview/src/sourceprintcompositor.ccg
@@ -22,6 +22,12 @@
 namespace gtksourceview
 {
 
+SourcePrintCompositor::SourcePrintCompositor(const SourceView& view) :
+  _CONSTRUCT("buffer", Glib::unwrap(view.get_source_buffer()), "tab-width", view.get_tab_width(), "highlight-syntax", view.get_source_buffer()->get_highlight_syntax(), "wrap-mode", static_cast<GtkWrapMode>(view.get_wrap_mode()), "print-line-numbers", (view.get_show_line_numbers() ? 0 : 1))
+{
+  set_body_font_name(const_cast<SourceView&>(view).get_pango_context()->get_font_description().to_string());
+}
+
 void
 SourcePrintCompositor::set_header_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right)
 {
diff --git a/gtksourceview/src/sourceprintcompositor.hg b/gtksourceview/src/sourceprintcompositor.hg
index 8d295d1..cebcccc 100644
--- a/gtksourceview/src/sourceprintcompositor.hg
+++ b/gtksourceview/src/sourceprintcompositor.hg
@@ -34,8 +34,7 @@ class SourcePrintCompositor : public Glib::Object
 
 protected:
   _WRAP_CTOR(SourcePrintCompositor(const Glib::RefPtr<SourceBuffer>& buffer), gtk_source_print_compositor_new)
-#m4 _CONVERSION(`const SourceView&',`GtkSourceView*',`($3).gobj()')
-  _WRAP_CTOR(SourcePrintCompositor(const SourceView& view), gtk_source_print_compositor_new_from_view)
+  explicit SourcePrintCompositor(const SourceView& view);
 public:
   _WRAP_CREATE(const Glib::RefPtr<SourceBuffer>& buffer)
   _WRAP_CREATE(const SourceView& view)



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