use G_VALUE_INIT

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75163 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett 2013-11-10 18:13:27 +00:00
parent ea566e2ed0
commit 54e89f14bb
5 changed files with 43 additions and 37 deletions

View File

@ -16,6 +16,11 @@
#include "wx/gtk/private/string.h"
#include "wx/gtk/private/gtk2-compat.h"
#ifndef G_VALUE_INIT
// introduced in GLib 2.30
#define G_VALUE_INIT { 0, { { 0 } } }
#endif
// pango_version_check symbol is quite recent ATM (4/2007)... so we
// use our own wrapper which implements a smart trick.
// Use this function as you'd use pango_version_check:

View File

@ -202,7 +202,7 @@ void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap)
if ( gtk_tree_model_iter_nth_child( model, &iter, NULL, n ) )
{
GValue value0 = { 0, };
GValue value0 = G_VALUE_INIT;
g_value_init( &value0, G_TYPE_OBJECT );
g_value_set_object( &value0, bitmap.GetPixbuf() );
gtk_list_store_set_value( GTK_LIST_STORE(model), &iter,
@ -222,7 +222,7 @@ wxBitmap wxBitmapComboBox::GetItemBitmap(unsigned int n) const
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
{
GValue value = { 0, };
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value( model, &iter,
m_bitmapCellIndex, &value );
GdkPixbuf* pixbuf = (GdkPixbuf*) g_value_get_object( &value );
@ -300,7 +300,7 @@ void wxBitmapComboBox::GTKInsertComboBoxTextItem( unsigned int n, const wxString
gtk_list_store_insert( store, &iter, n );
GValue value = { 0, };
GValue value = G_VALUE_INIT;
g_value_init( &value, G_TYPE_STRING );
g_value_set_string( &value, wxGTK_CONV( text ) );
gtk_list_store_set_value( store, &iter, m_stringCellIndex, &value );

View File

@ -15,6 +15,7 @@
#include "wx/checklst.h"
#include <gtk/gtk.h>
#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// "toggled"
@ -111,7 +112,7 @@ bool wxCheckListBox::IsChecked(unsigned int index) const
if(!res)
return false;
GValue value = {0, };
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value(GTK_TREE_MODEL(m_liststore),
&iter,
0, //column

View File

@ -208,7 +208,7 @@ int wxChoice::FindString( const wxString &item, bool bCase ) const
int count = 0;
do
{
GValue value = { 0, };
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value( model, &iter, m_stringCellIndex, &value );
wxString str = wxGTK_CONV_BACK( g_value_get_string( &value ) );
g_value_unset( &value );
@ -239,7 +239,7 @@ void wxChoice::SetString(unsigned int n, const wxString &text)
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
{
GValue value = { 0, };
GValue value = G_VALUE_INIT;
g_value_init( &value, G_TYPE_STRING );
g_value_set_string( &value, wxGTK_CONV( text ) );
gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, m_stringCellIndex, &value );
@ -260,7 +260,7 @@ wxString wxChoice::GetString(unsigned int n) const
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
{
GValue value = { 0, };
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value( model, &iter, m_stringCellIndex, &value );
wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) );
g_value_unset( &value );

View File

@ -1875,7 +1875,7 @@ void wxDataViewRenderer::SetMode( wxDataViewCellMode mode )
m_mode = mode;
// This value is most often ignored in GtkTreeView
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, gtk_cell_renderer_mode_get_type() );
g_value_set_enum( &gvalue, gtkMode );
g_object_set_property( G_OBJECT(m_renderer), "mode", &gvalue );
@ -1936,7 +1936,7 @@ void wxDataViewRenderer::GtkApplyAlignment(GtkCellRenderer *renderer)
else if (align & wxALIGN_CENTER_HORIZONTAL)
xalign = 0.5;
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_FLOAT );
g_value_set_float( &gvalue, xalign );
g_object_set_property( G_OBJECT(renderer), "xalign", &gvalue );
@ -1950,7 +1950,7 @@ void wxDataViewRenderer::GtkApplyAlignment(GtkCellRenderer *renderer)
else if (align & wxALIGN_CENTER_VERTICAL)
yalign = 0.5;
GValue gvalue2 = { 0, };
GValue gvalue2 = G_VALUE_INIT;
g_value_init( &gvalue2, G_TYPE_FLOAT );
g_value_set_float( &gvalue2, yalign );
g_object_set_property( G_OBJECT(renderer), "yalign", &gvalue2 );
@ -1976,7 +1976,7 @@ void wxDataViewRenderer::EnableEllipsize(wxEllipsizeMode mode)
// we use the same values in wxEllipsizeMode as PangoEllipsizeMode so we
// can just cast between them
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, PANGO_TYPE_ELLIPSIZE_MODE );
g_value_set_enum( &gvalue, static_cast<PangoEllipsizeMode>(mode) );
g_object_set_property( G_OBJECT(rend), "ellipsize", &gvalue );
@ -1989,7 +1989,7 @@ wxEllipsizeMode wxDataViewRenderer::GetEllipsizeMode() const
if ( !rend )
return wxELLIPSIZE_NONE;
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, PANGO_TYPE_ELLIPSIZE_MODE );
g_object_get_property( G_OBJECT(rend), "ellipsize", &gvalue );
wxEllipsizeMode
@ -2052,7 +2052,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
{
const GdkColor * const gcol = attr.GetColour().GetColor();
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, GDK_TYPE_COLOR );
g_value_set_boxed( &gvalue, gcol );
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
@ -2062,7 +2062,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
}
else
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, FALSE );
g_object_set_property( G_OBJECT(renderer), "foreground-set", &gvalue );
@ -2071,7 +2071,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
if (attr.GetItalic())
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, PANGO_TYPE_STYLE );
g_value_set_enum( &gvalue, PANGO_STYLE_ITALIC );
g_object_set_property( G_OBJECT(renderer), "style", &gvalue );
@ -2081,7 +2081,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
}
else
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, FALSE );
g_object_set_property( G_OBJECT(renderer), "style-set", &gvalue );
@ -2091,7 +2091,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
if (attr.GetBold())
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, PANGO_TYPE_WEIGHT );
g_value_set_enum( &gvalue, PANGO_WEIGHT_BOLD );
g_object_set_property( G_OBJECT(renderer), "weight", &gvalue );
@ -2101,7 +2101,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
}
else
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, FALSE );
g_object_set_property( G_OBJECT(renderer), "weight-set", &gvalue );
@ -2114,7 +2114,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
wxColour colour = attr.GetBackgroundColour();
const GdkColor * const gcol = colour.GetColor();
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, GDK_TYPE_COLOR );
g_value_set_boxed( &gvalue, gcol );
g_object_set_property( G_OBJECT(renderer), "cell-background_gdk", &gvalue );
@ -2122,7 +2122,7 @@ bool GtkApplyAttr(GtkCellRendererText *renderer, const wxDataViewItemAttr& attr)
}
else
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, FALSE );
g_object_set_property( G_OBJECT(renderer), "cell-background-set", &gvalue );
@ -2147,7 +2147,7 @@ wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype, wxD
if (mode & wxDATAVIEW_CELL_EDITABLE)
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, true );
g_object_set_property( G_OBJECT(m_renderer), "editable", &gvalue );
@ -2164,7 +2164,7 @@ wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString &varianttype, wxD
bool wxDataViewTextRenderer::SetTextValue(const wxString& str)
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_STRING );
g_value_set_string( &gvalue, wxGTK_CONV_FONT( str, GetOwner()->GetOwner()->GetFont() ) );
g_object_set_property( G_OBJECT(m_renderer), "text", &gvalue );
@ -2175,7 +2175,7 @@ bool wxDataViewTextRenderer::SetTextValue(const wxString& str)
bool wxDataViewTextRenderer::GetTextValue(wxString& str) const
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_STRING );
g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue );
str = wxGTK_CONV_BACK_FONT( g_value_get_string( &gvalue ), const_cast<wxDataViewTextRenderer*>(this)->GetOwner()->GetOwner()->GetFont() );
@ -2200,7 +2200,7 @@ void wxDataViewTextRenderer::SetAlignment( int align )
else if (align & wxALIGN_CENTER_HORIZONTAL)
pangoAlign = PANGO_ALIGN_CENTER;
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, gtk_cell_renderer_mode_get_type() );
g_value_set_enum( &gvalue, pangoAlign );
g_object_set_property( G_OBJECT(m_renderer), "alignment", &gvalue );
@ -2227,7 +2227,7 @@ namespace
// set "pixbuf" property on the given renderer
void SetPixbufProp(GtkCellRenderer *renderer, GdkPixbuf *pixbuf)
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_OBJECT );
g_value_set_object( &gvalue, pixbuf );
g_object_set_property( G_OBJECT(renderer), "pixbuf", &gvalue );
@ -2294,7 +2294,7 @@ static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle *renderer,
wxDataViewToggleRenderer *cell = (wxDataViewToggleRenderer*) user_data;
// get old value
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_object_get_property( G_OBJECT(renderer), "active", &gvalue );
// invert it
@ -2329,7 +2329,7 @@ wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString &varianttype,
}
else
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, false );
g_object_set_property( G_OBJECT(m_renderer), "activatable", &gvalue );
@ -2344,7 +2344,7 @@ bool wxDataViewToggleRenderer::SetValue( const wxVariant &value )
{
bool tmp = value;
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, tmp );
g_object_set_property( G_OBJECT(m_renderer), "active", &gvalue );
@ -2355,7 +2355,7 @@ bool wxDataViewToggleRenderer::SetValue( const wxVariant &value )
bool wxDataViewToggleRenderer::GetValue( wxVariant &value ) const
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_object_get_property( G_OBJECT(m_renderer), "active", &gvalue );
value = g_value_get_boolean( &gvalue ) != 0;
@ -2451,7 +2451,7 @@ void wxDataViewCustomRenderer::RenderText( const wxString &text,
GtkCellRendererText * const textRenderer = GtkGetTextRenderer();
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_STRING );
g_value_set_string( &gvalue, wxGTK_CONV_FONT( text, GetOwner()->GetOwner()->GetFont() ) );
g_object_set_property( G_OBJECT(textRenderer), "text", &gvalue );
@ -2562,7 +2562,7 @@ wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
void wxDataViewProgressRenderer::GTKSetLabel()
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_STRING );
// Take care to not use GetOwner() here if the label is empty, we can be
@ -2590,7 +2590,7 @@ bool wxDataViewProgressRenderer::SetValue( const wxVariant &value )
#endif // !wxUSE_UNICODE
gint tmp = (long) value;
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_INT );
g_value_set_int( &gvalue, tmp );
g_object_set_property( G_OBJECT(m_renderer), "value", &gvalue );
@ -2672,7 +2672,7 @@ wxSize wxDataViewChoiceRenderer::GetSize() const
bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_STRING );
g_value_set_string(&gvalue,
wxGTK_CONV_FONT(value.GetString(),
@ -2685,7 +2685,7 @@ bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const
{
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_STRING );
g_object_get_property( G_OBJECT(m_renderer), "text", &gvalue );
wxString temp = wxGTK_CONV_BACK_FONT(g_value_get_string(&gvalue),
@ -2712,7 +2712,7 @@ void wxDataViewChoiceRenderer::SetAlignment( int align )
else if (align & wxALIGN_CENTER_HORIZONTAL)
pangoAlign = PANGO_ALIGN_CENTER;
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, gtk_cell_renderer_mode_get_type() );
g_value_set_enum( &gvalue, pangoAlign );
g_object_set_property( G_OBJECT(m_renderer), "alignment", &gvalue );
@ -2894,7 +2894,7 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
visible = true;
}
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, visible );
g_object_set_property( G_OBJECT(renderer), "visible", &gvalue );
@ -2920,7 +2920,7 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
bool enabled = wx_model->IsEnabled( item, cell->GetOwner()->GetModelColumn() );
// a) this sets the appearance to disabled grey
GValue gvalue = { 0, };
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_BOOLEAN );
g_value_set_boolean( &gvalue, enabled );
g_object_set_property( G_OBJECT(renderer), "sensitive", &gvalue );