[gtksourceviewmm/devel] Handle some NULL cases.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceviewmm/devel] Handle some NULL cases.
- Date: Mon, 11 Jan 2010 12:10:57 +0000 (UTC)
commit c76fb162c6e018da204320a310225bfdcab34b92
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Mon Jan 11 12:56:06 2010 +0100
Handle some NULL cases.
* gtksourceview/src/sourcegutter.ccg:
* gtksourceview/src/sourcegutter.hg: Added method resetting
cell|data func. Also fixed dereferencing possible NULL pointer.
* gtksourceview/src/sourceiter.ccg: Added methods doing
forward|backward search without limits.
* gtksourceview/src/sourceprintcompositor.ccg: Format setters now
interpret empty strings as NULL.
* gtksourceview/src/sourceview.ccg:
* gtksourceview/src/sourceview.hg: Two set_mark_category_icon()
overloads now interpret empty stock or icon name as NULL. Also
fixed dereferencing possible NULL pointer. Added method mark
category tooltip func.
gtksourceview/src/sourcegutter.ccg | 16 +++++++-
gtksourceview/src/sourcegutter.hg | 2 +
gtksourceview/src/sourceiter.ccg | 54 +++++++++++++++++++++++++--
gtksourceview/src/sourceiter.hg | 32 ++++++++++++++++
gtksourceview/src/sourceprintcompositor.ccg | 17 ++++++++
gtksourceview/src/sourceprintcompositor.hg | 10 ++++-
gtksourceview/src/sourceview.ccg | 26 +++++++++++-
gtksourceview/src/sourceview.hg | 12 ++++-
8 files changed, 155 insertions(+), 14 deletions(-)
---
diff --git a/gtksourceview/src/sourcegutter.ccg b/gtksourceview/src/sourcegutter.ccg
index d6795df..3273920 100644
--- a/gtksourceview/src/sourcegutter.ccg
+++ b/gtksourceview/src/sourcegutter.ccg
@@ -78,7 +78,7 @@ void SourceGutter::set_cell_data_func(Gtk::CellRenderer* renderer, const SlotDat
{
SlotData* slot_copy = new SlotData(slot);
- gtk_source_gutter_set_cell_data_func(gobj(), renderer->gobj(),
+ gtk_source_gutter_set_cell_data_func(gobj(), Glib::unwrap(renderer),
&SignalProxy_CellData_gtk_callback, slot_copy,
&SignalProxy_CellData_gtk_callback_destroy);
}
@@ -87,10 +87,22 @@ void SourceGutter::set_cell_size_func(Gtk::CellRenderer* renderer, const SlotSiz
{
SlotSize* slot_copy = new SlotSize(slot);
- gtk_source_gutter_set_cell_size_func(gobj(), renderer->gobj(),
+ gtk_source_gutter_set_cell_size_func(gobj(), Glib::unwrap(renderer),
&SignalProxy_CellSize_gtk_callback, slot_copy,
&SignalProxy_CellSize_gtk_callback_destroy);
}
+void
+SourceGutter::reset_cell_data_func(Gtk::CellRenderer* renderer)
+{
+ gtk_source_gutter_set_cell_data_func(gobj(), Glib::unwrap(renderer), 0, 0, 0);
+}
+
+void
+SourceGutter::reset_cell_size_func(Gtk::CellRenderer* renderer)
+{
+ gtk_source_gutter_set_cell_size_func(gobj(), Glib::unwrap(renderer), 0, 0, 0);
+}
+
}//end namespace gtksourceview
diff --git a/gtksourceview/src/sourcegutter.hg b/gtksourceview/src/sourcegutter.hg
index 6ff94cf..17369c0 100644
--- a/gtksourceview/src/sourcegutter.hg
+++ b/gtksourceview/src/sourcegutter.hg
@@ -64,6 +64,8 @@ public:
_IGNORE(gtk_source_gutter_set_cell_data_func, gtk_source_gutter_set_cell_size_func)
void set_cell_data_func(Gtk::CellRenderer* renderer, const SlotData& slot);
void set_cell_size_func(Gtk::CellRenderer* renderer, const SlotSize& slot);
+ void reset_cell_data_func(Gtk::CellRenderer* renderer);
+ void reset_cell_size_func(Gtk::CellRenderer* renderer);
_WRAP_PROPERTY("view", SourceView*)
_WRAP_PROPERTY("window-type", Gtk::TextWindowType)
diff --git a/gtksourceview/src/sourceiter.ccg b/gtksourceview/src/sourceiter.ccg
index 1f26ac4..83d0a58 100644
--- a/gtksourceview/src/sourceiter.ccg
+++ b/gtksourceview/src/sourceiter.ccg
@@ -80,9 +80,11 @@ SourceIter::forward_search (const Glib::ustring &a_str,
Gtk::TextIter &a_match_end,
const Gtk::TextIter &a_limit) const
{
+// what is the use of these things? krnowak
+ /*
const GtkTextIter *gobject (gobj ()) ;
- g_return_val_if_fail (gobject, FALSE) ;
- g_return_val_if_fail (a_str.c_str (), FALSE) ;
+ g_return_val_if_fail (gobject, FALSE) ; // that will never fail, since gobject is always not null.
+ g_return_val_if_fail (a_str.c_str (), FALSE) ; // ditto.
GtkTextIter match_start, match_end ;
gboolean res = gtk_source_iter_forward_search (gobject,
@@ -96,6 +98,13 @@ SourceIter::forward_search (const Glib::ustring &a_str,
a_match_start = res_match_start ;
a_match_end = res_match_end ;
return res ;
+ */
+ return gtk_source_iter_forward_search(const_cast<GtkTextIter*>(gobj()),
+ a_str.c_str(),
+ static_cast<GtkSourceSearchFlags>(a_flags),
+ a_match_start.gobj(),
+ a_match_end.gobj(),
+ a_limit.gobj());
}
bool
@@ -105,9 +114,11 @@ SourceIter::backward_search (const Glib::ustring &a_str,
Gtk::TextIter &a_match_end,
const Gtk::TextIter &a_limit) const
{
+// what is the use of these things? krnowak
+ /*
const GtkTextIter *gobject (gobj ()) ;
- g_return_val_if_fail (gobject, FALSE) ;
- g_return_val_if_fail (a_str.c_str (), FALSE) ;
+ g_return_val_if_fail (gobject, FALSE) ; // that will never fail, since gobject is always not null.
+ g_return_val_if_fail (a_str.c_str (), FALSE) ; // ditto.
GtkTextIter match_start, match_end ;
gboolean res = gtk_source_iter_backward_search (gobject,
@@ -121,6 +132,41 @@ SourceIter::backward_search (const Glib::ustring &a_str,
a_match_start = res_match_start ;
a_match_end = res_match_end ;
return res ;
+ */
+ return gtk_source_iter_backward_search(const_cast<GtkTextIter*>(gobj()),
+ a_str.c_str(),
+ static_cast<GtkSourceSearchFlags>(a_flags),
+ a_match_start.gobj(),
+ a_match_end.gobj(),
+ a_limit.gobj());
+}
+
+bool
+SourceIter::forward_search (const Glib::ustring &a_str,
+ SourceSearchFlags a_flags,
+ Gtk::TextIter &a_match_start,
+ Gtk::TextIter &a_match_end) const
+{
+ return gtk_source_iter_forward_search(const_cast<GtkTextIter*>(gobj()),
+ a_str.c_str(),
+ static_cast<GtkSourceSearchFlags>(a_flags),
+ a_match_start.gobj(),
+ a_match_end.gobj(),
+ 0);
+}
+
+bool
+SourceIter::backward_search (const Glib::ustring &a_str,
+ SourceSearchFlags a_flags,
+ Gtk::TextIter &a_match_start,
+ Gtk::TextIter &a_match_end) const
+{
+ return gtk_source_iter_backward_search(const_cast<GtkTextIter*>(gobj()),
+ a_str.c_str(),
+ static_cast<GtkSourceSearchFlags>(a_flags),
+ a_match_start.gobj(),
+ a_match_end.gobj(),
+ 0);
}
}//end namespace gtksourceview
diff --git a/gtksourceview/src/sourceiter.hg b/gtksourceview/src/sourceiter.hg
index 2d1d8d8..5a55cd6 100644
--- a/gtksourceview/src/sourceiter.hg
+++ b/gtksourceview/src/sourceiter.hg
@@ -105,6 +105,22 @@ class SourceIter : public Gtk::TextIter
Gtk::TextIter &a_match_end,
const Gtk::TextIter &a_limit) const ;
+ /// \brief same as forward_search(), but searchs to the end.
+ ///
+ /// \param a_str the string to search for
+ /// \param a_flags search flags, to be combined with the '|' operator
+ /// \param a_match_start out parameter. Points the the beginning
+ /// of the region that matches the search. This is applicable
+ /// if and only if the function returns true.
+ /// \param a_match_end out parameter. Points the the end
+ /// of the region that matches the search. This is applicable
+ /// if and only if the function returns true.
+ /// \return true if the search was successful, false otherwise.
+ bool forward_search (const Glib::ustring &a_str,
+ SourceSearchFlags a_flags,
+ Gtk::TextIter &a_match_start,
+ Gtk::TextIter &a_match_end) const ;
+
/// \brief search backward in the buffer
///
/// \param a_str the string to search for
@@ -122,6 +138,22 @@ class SourceIter : public Gtk::TextIter
Gtk::TextIter &a_match_end,
const Gtk::TextIter &a_limit) const ;
+ /// \brief same as backward_search(), but searchs to the start.
+ ///
+ /// \param a_str the string to search for
+ /// \param a_flags search flags, to be combined with the '|' operator
+ /// \param a_match_start out parameter. Points the the beginning
+ /// of the region that matches the search. This is applicable
+ /// if and only if the function returns true.
+ /// \param a_match_end out parameter. Points the the end
+ /// of the region that matches the search. This is applicable
+ /// if and only if the function returns true.
+ /// \return true if the search was successful, false otherwise.
+ bool backward_search (const Glib::ustring &a_str,
+ SourceSearchFlags a_flags,
+ Gtk::TextIter &a_match_start,
+ Gtk::TextIter &a_match_end) const ;
+
};//end class SourceIter
diff --git a/gtksourceview/src/sourceprintcompositor.ccg b/gtksourceview/src/sourceprintcompositor.ccg
index ba71a47..eb3a084 100644
--- a/gtksourceview/src/sourceprintcompositor.ccg
+++ b/gtksourceview/src/sourceprintcompositor.ccg
@@ -18,3 +18,20 @@
*/
#include <gtksourceview/gtksourceprintcompositor.h>
+
+namespace gtksourceview
+{
+
+void
+SourcePrintCompositor::set_header_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right)
+{
+ gtk_source_print_compositor_set_header_format(gobj(), static_cast<gboolean>(separator), (left.empty() ? 0 : left.c_str()), (center.empty() ? 0 : center.c_str()), (right.empty() ? 0 : right.c_str()));
+}
+
+void
+SourcePrintCompositor::set_footer_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right)
+{
+ gtk_source_print_compositor_set_footer_format(gobj(), static_cast<gboolean>(separator), (left.empty() ? 0 : left.c_str()), (center.empty() ? 0 : center.c_str()), (right.empty() ? 0 : right.c_str()));
+}
+
+} // namespace gtksourceview
diff --git a/gtksourceview/src/sourceprintcompositor.hg b/gtksourceview/src/sourceprintcompositor.hg
index 5ab46ab..8d295d1 100644
--- a/gtksourceview/src/sourceprintcompositor.hg
+++ b/gtksourceview/src/sourceprintcompositor.hg
@@ -87,8 +87,14 @@ public:
_WRAP_METHOD(void set_print_footer(bool print), gtk_source_print_compositor_set_print_footer)
_WRAP_METHOD(bool get_print_footer() const, gtk_source_print_compositor_get_print_footer)
- _WRAP_METHOD(void set_header_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right), gtk_source_print_compositor_set_header_format)
- _WRAP_METHOD(void set_footer_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right), gtk_source_print_compositor_set_footer_format)
+// XXX: wrapped by hand, because here NULL could be passed.
+// _WRAP_METHOD(void set_header_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right), gtk_source_print_compositor_set_header_format)
+// _WRAP_METHOD(void set_footer_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right), gtk_source_print_compositor_set_footer_format)
+
+ _WRAP_METHOD_DOCS_ONLY(gtk_source_print_compositor_set_header_format)
+ void set_header_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right);
+ _WRAP_METHOD_DOCS_ONLY(gtk_source_print_compositor_set_footer_format)
+ void set_footer_format(bool separator, const Glib::ustring& left, const Glib::ustring& center, const Glib::ustring& right);
_WRAP_METHOD(int get_n_pages() const, gtk_source_print_compositor_get_n_pages)
#m4 _CONVERSION(`const Glib::RefPtr<Gtk::PrintContext>&',`GtkPrintContext*',__CONVERT_REFPTR_TO_P($3))
diff --git a/gtksourceview/src/sourceview.ccg b/gtksourceview/src/sourceview.ccg
index e97cf6d..635912b 100644
--- a/gtksourceview/src/sourceview.ccg
+++ b/gtksourceview/src/sourceview.ccg
@@ -98,7 +98,7 @@ SourceView::set_source_buffer (const Glib::RefPtr<SourceBuffer> &source_buffer)
void
SourceView::set_mark_category_pixbuf(const Glib::ustring& category, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
{
- gtk_source_view_set_mark_category_icon_from_pixbuf(gobj(), category.c_str(), pixbuf->gobj());
+ gtk_source_view_set_mark_category_icon_from_pixbuf(gobj(), category.c_str(), Glib::unwrap(pixbuf));
}
Glib::RefPtr<Gdk::Pixbuf>
@@ -114,7 +114,20 @@ SourceView::get_mark_category_pixbuf(const Glib::ustring&) const
}
#endif
-void SourceView::set_mark_category_tooltip_func(const Glib::ustring& category, const SlotMarkTooltip& slot)
+void
+SourceView::set_mark_category_icon(const Glib::ustring& category, const Gtk::StockID& stock_id)
+{
+ gtk_source_view_set_mark_category_icon_from_stock(gobj(), category.c_str(), ((stock_id) ? stock_id.get_c_str() : 0));
+}
+
+void
+SourceView::set_mark_category_icon(const Glib::ustring& category, const Glib::ustring& icon_name)
+{
+ gtk_source_view_set_mark_category_icon_from_icon_name(gobj(), category.c_str(), (icon_name.empty() ? 0 : icon_name.c_str()));
+}
+
+void
+SourceView::set_mark_category_tooltip_func(const Glib::ustring& category, const SlotMarkTooltip& slot)
{
SlotMarkTooltip* slot_copy = new SlotMarkTooltip(slot);
@@ -123,7 +136,8 @@ void SourceView::set_mark_category_tooltip_func(const Glib::ustring& category, c
&SignalProxy_MarkTooltip_gtk_callback_destroy);
}
-void SourceView::set_mark_category_tooltip_markup_func(const Glib::ustring& category, const SlotMarkTooltip& slot)
+void
+SourceView::set_mark_category_tooltip_markup_func(const Glib::ustring& category, const SlotMarkTooltip& slot)
{
SlotMarkTooltip* slot_copy = new SlotMarkTooltip(slot);
@@ -132,5 +146,11 @@ void SourceView::set_mark_category_tooltip_markup_func(const Glib::ustring& cate
&SignalProxy_MarkTooltip_gtk_callback_destroy);
}
+void
+SourceView::unset_mark_category_tooltip_func(const Glib::ustring& category)
+{
+ gtk_source_view_set_mark_category_tooltip_func(gobj(), category.c_str(), 0, 0, 0);
+}
+
}//end namespace gtksourceview
diff --git a/gtksourceview/src/sourceview.hg b/gtksourceview/src/sourceview.hg
index b09994f..a04fe7c 100644
--- a/gtksourceview/src/sourceview.hg
+++ b/gtksourceview/src/sourceview.hg
@@ -60,7 +60,7 @@ public:
/// \param buffer the buffer to display in the SourceView
explicit SourceView (const Glib::RefPtr<SourceBuffer> &buffer) ;
-
+// TODO: remove these when breaking API/ABI?
_WRAP_CREATE()
_WRAP_CREATE(const Glib::RefPtr<SourceBuffer> &buffer)
@@ -242,8 +242,13 @@ public:
#endif // GTKSOURCEVIEWMM_DISABLE_DEPRECATED
_WRAP_METHOD(void set_mark_category_icon(const Glib::ustring& category, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_source_view_set_mark_category_icon_from_pixbuf)
- _WRAP_METHOD(void set_mark_category_icon(const Glib::ustring& category, const Gtk::StockID& stock_id), gtk_source_view_set_mark_category_icon_from_stock)
- _WRAP_METHOD(void set_mark_category_icon(const Glib::ustring& category, const Glib::ustring& icon_name), gtk_source_view_set_mark_category_icon_from_icon_name)
+// XXX: wrapped by hand, because stock_id or icon_name could be empty, which means NULL.
+// _WRAP_METHOD(void set_mark_category_icon(const Glib::ustring& category, const Gtk::StockID& stock_id), gtk_source_view_set_mark_category_icon_from_stock)
+// _WRAP_METHOD(void set_mark_category_icon(const Glib::ustring& category, const Glib::ustring& icon_name), gtk_source_view_set_mark_category_icon_from_icon_name)
+ _WRAP_METHOD_DOCS_ONLY(gtk_source_view_set_mark_category_icon_from_stock)
+ void set_mark_category_icon(const Glib::ustring& category, const Gtk::StockID& stock_id);
+ _WRAP_METHOD_DOCS_ONLY(gtk_source_view_set_mark_category_icon_from_icon_name)
+ void set_mark_category_icon(const Glib::ustring& category, const Glib::ustring& icon_name);
#m4 _CONVERSION(`const Gdk::Color&',`const GdkColor*',`($3).gobj()')
_WRAP_METHOD(void set_mark_category_background(const Glib::ustring& category, const Gdk::Color& color), gtk_source_view_set_mark_category_background)
@@ -267,6 +272,7 @@ public:
_IGNORE(gtk_source_view_set_mark_category_tooltip_func, gtk_source_view_set_mark_category_tooltip_markup_func)
void set_mark_category_tooltip_func(const Glib::ustring& category, const SlotMarkTooltip& slot);
void set_mark_category_tooltip_markup_func(const Glib::ustring& category, const SlotMarkTooltip& slot);
+ void unset_mark_category_tooltip_func(const Glib::ustring& category);
#m4 _CONVERSION(`GtkSourceGutter*',`Glib::RefPtr<SourceGutter>',`Glib::wrap($3)')
#m4 _CONVERSION(`GtkSourceGutter*',`Glib::RefPtr<const SourceGutter>',`Glib::wrap($3)')
_WRAP_METHOD(Glib::RefPtr<SourceGutter> get_gutter(Gtk::TextWindowType window_type), gtk_source_view_get_gutter, refreturn)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]