From 11f1e38e26e948d3c675c4d780eecee1073c0f99 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 6 Jul 2013 16:35:40 +0000 Subject: [PATCH] avoid GTK+ prefixes for our tree entry code, it is not part of GTK+ git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/private/treeentry_gtk.h | 32 ++++++------- src/gtk/listbox.cpp | 48 +++++++++---------- src/gtk/treeentry_gtk.c | 66 +++++++++++++------------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/include/wx/gtk/private/treeentry_gtk.h b/include/wx/gtk/private/treeentry_gtk.h index 7665577a9b..cf723aeda3 100644 --- a/include/wx/gtk/private/treeentry_gtk.h +++ b/include/wx/gtk/private/treeentry_gtk.h @@ -16,40 +16,40 @@ extern "C" { #include /* for gpointer and gchar* etc. */ -#define GTK_TYPE_TREE_ENTRY (gtk_tree_entry_get_type()) -#define GTK_TREE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_tree_entry_get_type (), GtkTreeEntry)) -#define GTK_IS_TREE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_tree_entry_get_type ())) +#define WX_TYPE_TREE_ENTRY wx_tree_entry_get_type() +#define WX_TREE_ENTRY(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, wx_tree_entry_get_type(), wxTreeEntry) +#define WX_IS_TREE_ENTRY(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, wx_tree_entry_get_type()) -typedef struct _GtkTreeEntry GtkTreeEntry; +typedef struct _wxTreeEntry wxTreeEntry; -typedef void (*GtkTreeEntryDestroy) (GtkTreeEntry* entry, gpointer context); +typedef void (*wxTreeEntryDestroy)(wxTreeEntry* entry, void* context); -struct _GtkTreeEntry +struct _wxTreeEntry { GObject parent; /* object instance */ gchar* label; /* label - always copied by this object except on get */ gchar* collate_key; /* collate key used for string comparisons/sorting */ gpointer userdata; /* untouched userdata */ - GtkTreeEntryDestroy destroy_func; /* called upon destruction - use for freeing userdata etc. */ + wxTreeEntryDestroy destroy_func; /* called upon destruction - use for freeing userdata etc. */ gpointer destroy_func_data; /* context passed to destroy_func */ }; -GtkTreeEntry* gtk_tree_entry_new (void); +wxTreeEntry* wx_tree_entry_new(void); -GType gtk_tree_entry_get_type (void); +GType wx_tree_entry_get_type(void); -gchar* gtk_tree_entry_get_collate_key (GtkTreeEntry* entry); +char* wx_tree_entry_get_collate_key(wxTreeEntry* entry); -gchar* gtk_tree_entry_get_label (GtkTreeEntry* entry); +char* wx_tree_entry_get_label(wxTreeEntry* entry); -gpointer gtk_tree_entry_get_userdata (GtkTreeEntry* entry); +void* wx_tree_entry_get_userdata(wxTreeEntry* entry); -void gtk_tree_entry_set_label (GtkTreeEntry* entry, const gchar* label); +void wx_tree_entry_set_label(wxTreeEntry* entry, const char* label); -void gtk_tree_entry_set_userdata (GtkTreeEntry* entry, gpointer userdata); +void wx_tree_entry_set_userdata(wxTreeEntry* entry, void* userdata); -void gtk_tree_entry_set_destroy_func (GtkTreeEntry* entry, - GtkTreeEntryDestroy destroy_func, +void wx_tree_entry_set_destroy_func(wxTreeEntry* entry, + wxTreeEntryDestroy destroy_func, gpointer destroy_func_data); #ifdef __cplusplus diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 07155104e7..cbfad9693d 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -69,10 +69,10 @@ namespace { // Return the entry for the given listbox item. -GtkTreeEntry * +wxTreeEntry * GetEntry(GtkListStore *store, GtkTreeIter *iter, const wxListBox *listbox) { - GtkTreeEntry* entry; + wxTreeEntry* entry; gtk_tree_model_get(GTK_TREE_MODEL(store), iter, WXLISTBOX_DATACOLUMN_ARG(listbox), @@ -179,12 +179,12 @@ gtk_listbox_key_press_callback( GtkWidget *WXUNUSED(widget), //----------------------------------------------------------------------------- extern "C" { -static void gtk_tree_entry_destroy_cb(GtkTreeEntry* entry, +static void tree_entry_destroy_cb(wxTreeEntry* entry, wxListBox* listbox) { if (listbox->HasClientObjectData()) { - gpointer userdata = gtk_tree_entry_get_userdata(entry); + void* userdata = wx_tree_entry_get_userdata(entry); if (userdata) delete (wxClientData *)userdata; } @@ -201,16 +201,16 @@ static gint gtk_listbox_sort_callback(GtkTreeModel * WXUNUSED(model), GtkTreeIter *b, wxListBox *listbox) { - GtkTreeEntry* entry1 = GetEntry(listbox->m_liststore, a, listbox); + wxTreeEntry* entry1 = GetEntry(listbox->m_liststore, a, listbox); wxCHECK_MSG(entry1, 0, wxT("Could not get first entry")); - GtkTreeEntry* entry2 = GetEntry(listbox->m_liststore, b, listbox); + wxTreeEntry* entry2 = GetEntry(listbox->m_liststore, b, listbox); wxCHECK_MSG(entry2, 0, wxT("Could not get second entry")); //We compare collate keys here instead of calling g_utf8_collate //as it is rather slow (and even the docs recommend this) - return strcmp(gtk_tree_entry_get_collate_key(entry1), - gtk_tree_entry_get_collate_key(entry2)) >= 0; + return strcmp(wx_tree_entry_get_collate_key(entry1), + wx_tree_entry_get_collate_key(entry2)) >= 0; } } @@ -225,12 +225,12 @@ static gboolean gtk_listbox_searchequal_callback(GtkTreeModel * WXUNUSED(model), GtkTreeIter* iter, wxListBox* listbox) { - GtkTreeEntry* entry = GetEntry(listbox->m_liststore, iter, listbox); + wxTreeEntry* entry = GetEntry(listbox->m_liststore, iter, listbox); wxCHECK_MSG(entry, 0, wxT("Could not get entry")); wxGtkString keycollatekey(g_utf8_collate_key(key, -1)); - return strcmp(keycollatekey, gtk_tree_entry_get_collate_key(entry)) != 0; + return strcmp(keycollatekey, wx_tree_entry_get_collate_key(entry)) != 0; } } @@ -312,10 +312,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, #if wxUSE_CHECKLISTBOX if(m_hasCheckBoxes) m_liststore = gtk_list_store_new(2, G_TYPE_BOOLEAN, - GTK_TYPE_TREE_ENTRY); + WX_TYPE_TREE_ENTRY); else #endif - m_liststore = gtk_list_store_new(1, GTK_TYPE_TREE_ENTRY); + m_liststore = gtk_list_store_new(1, WX_TYPE_TREE_ENTRY); gtk_tree_view_set_model(m_treeview, GTK_TREE_MODEL(m_liststore)); @@ -458,9 +458,9 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, int wxListBox::DoInsertOneItem(const wxString& item, unsigned int pos) { - GtkTreeEntry* entry = gtk_tree_entry_new(); - gtk_tree_entry_set_label(entry, wxGTK_CONV(item)); - gtk_tree_entry_set_destroy_func(entry, (GtkTreeEntryDestroy)gtk_tree_entry_destroy_cb, this); + wxTreeEntry* entry = wx_tree_entry_new(); + wx_tree_entry_set_label(entry, wxGTK_CONV(item)); + wx_tree_entry_set_destroy_func(entry, (wxTreeEntryDestroy)tree_entry_destroy_cb, this); #if wxUSE_CHECKLISTBOX int entryCol = int(m_hasCheckBoxes); @@ -543,7 +543,7 @@ int wxListBox::GTKGetIndexFor(GtkTreeIter& iter) const } // get GtkTreeEntry from position (note: you need to g_unref it if valid) -GtkTreeEntry *wxListBox::GTKGetEntry(unsigned n) const +wxTreeEntry* wxListBox::GTKGetEntry(unsigned n) const { GtkTreeIter iter; if ( !GTKGetIteratorFor(n, &iter) ) @@ -558,18 +558,18 @@ GtkTreeEntry *wxListBox::GTKGetEntry(unsigned n) const void* wxListBox::DoGetItemClientData(unsigned int n) const { - GtkTreeEntry* entry = GTKGetEntry(n); + wxTreeEntry* entry = GTKGetEntry(n); wxCHECK_MSG(entry, NULL, wxT("could not get entry")); - return gtk_tree_entry_get_userdata( entry ); + return wx_tree_entry_get_userdata(entry); } void wxListBox::DoSetItemClientData(unsigned int n, void* clientData) { - GtkTreeEntry* entry = GTKGetEntry(n); + wxTreeEntry* entry = GTKGetEntry(n); wxCHECK_RET(entry, wxT("could not get entry")); - gtk_tree_entry_set_userdata( entry, clientData ); + wx_tree_entry_set_userdata(entry, clientData); } // ---------------------------------------------------------------------------- @@ -582,10 +582,10 @@ void wxListBox::SetString(unsigned int n, const wxString& label) GtkTreeIter iter; wxCHECK_RET(GTKGetIteratorFor(n, &iter), "invalid index"); - GtkTreeEntry* entry = GetEntry(m_liststore, &iter, this); + wxTreeEntry* entry = GetEntry(m_liststore, &iter, this); // update the item itself - gtk_tree_entry_set_label(entry, wxGTK_CONV(label)); + wx_tree_entry_set_label(entry, wxGTK_CONV(label)); // signal row changed GtkTreeModel* tree_model = GTK_TREE_MODEL(m_liststore); @@ -598,10 +598,10 @@ wxString wxListBox::GetString(unsigned int n) const { wxCHECK_MSG( m_treeview != NULL, wxEmptyString, wxT("invalid listbox") ); - GtkTreeEntry* entry = GTKGetEntry(n); + wxTreeEntry* entry = GTKGetEntry(n); wxCHECK_MSG( entry, wxEmptyString, wxT("wrong listbox index") ); - return wxGTK_CONV_BACK( gtk_tree_entry_get_label(entry) ); + return wxGTK_CONV_BACK(wx_tree_entry_get_label(entry)); } unsigned int wxListBox::GetCount() const diff --git a/src/gtk/treeentry_gtk.c b/src/gtk/treeentry_gtk.c index 5bdae1daa6..f1a211b7e3 100644 --- a/src/gtk/treeentry_gtk.c +++ b/src/gtk/treeentry_gtk.c @@ -32,22 +32,22 @@ typedef pid_t GPid; */ /* forwards */ -static void gtk_tree_entry_class_init(void* g_class, void* class_data); -static void gtk_tree_entry_string_transform_func(const GValue *src_value, +static void wx_tree_entry_class_init(void* g_class, void* class_data); +static void wx_tree_entry_string_transform_func(const GValue *src_value, GValue *dest_value); -static void gtk_tree_entry_dispose(GObject* obj); +static void wx_tree_entry_dispose(GObject* obj); static GObjectClass* parent_class; /* public */ -GtkTreeEntry* -gtk_tree_entry_new() +wxTreeEntry* +wx_tree_entry_new() { - return GTK_TREE_ENTRY(g_object_new(GTK_TYPE_TREE_ENTRY, NULL)); + return WX_TREE_ENTRY(g_object_new(WX_TYPE_TREE_ENTRY, NULL)); } GType -gtk_tree_entry_get_type () +wx_tree_entry_get_type() { static GType tree_entry_type = 0; @@ -58,25 +58,25 @@ gtk_tree_entry_get_type () sizeof(GObjectClass), NULL, /* base_init */ NULL, /* base_finalize */ - gtk_tree_entry_class_init, + wx_tree_entry_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (GtkTreeEntry), + sizeof(wxTreeEntry), 16, /* n_preallocs */ NULL, /* instance_init */ NULL /* value_table */ }; - tree_entry_type = g_type_register_static (G_TYPE_OBJECT, "GtkTreeEntry", + tree_entry_type = g_type_register_static (G_TYPE_OBJECT, "wxTreeEntry", &tree_entry_info, (GTypeFlags)0); g_value_register_transform_func(tree_entry_type, G_TYPE_STRING, - gtk_tree_entry_string_transform_func); + wx_tree_entry_string_transform_func); } return tree_entry_type; } -gchar* gtk_tree_entry_get_collate_key (GtkTreeEntry* entry) +char* wx_tree_entry_get_collate_key(wxTreeEntry* entry) { if (entry->collate_key == NULL) { @@ -87,21 +87,21 @@ gchar* gtk_tree_entry_get_collate_key (GtkTreeEntry* entry) return entry->collate_key; } -gchar* gtk_tree_entry_get_label (GtkTreeEntry* entry) +char* wx_tree_entry_get_label(wxTreeEntry* entry) { - g_assert(GTK_IS_TREE_ENTRY(entry)); + g_assert(WX_IS_TREE_ENTRY(entry)); return entry->label; } -gpointer gtk_tree_entry_get_userdata (GtkTreeEntry* entry) +void* wx_tree_entry_get_userdata(wxTreeEntry* entry) { - g_assert(GTK_IS_TREE_ENTRY(entry)); + g_assert(WX_IS_TREE_ENTRY(entry)); return entry->userdata; } -void gtk_tree_entry_set_label (GtkTreeEntry* entry, const gchar* label) +void wx_tree_entry_set_label(wxTreeEntry* entry, const char* label) { - g_assert(GTK_IS_TREE_ENTRY(entry)); + g_assert(WX_IS_TREE_ENTRY(entry)); /* free previous if it exists */ if(entry->label) @@ -114,50 +114,50 @@ void gtk_tree_entry_set_label (GtkTreeEntry* entry, const gchar* label entry->collate_key = NULL; } -void gtk_tree_entry_set_userdata (GtkTreeEntry* entry, gpointer userdata) +void wx_tree_entry_set_userdata(wxTreeEntry* entry, void* userdata) { - g_assert(GTK_IS_TREE_ENTRY(entry)); + g_assert(WX_IS_TREE_ENTRY(entry)); entry->userdata = userdata; } -void gtk_tree_entry_set_destroy_func (GtkTreeEntry* entry, - GtkTreeEntryDestroy destroy_func, +void wx_tree_entry_set_destroy_func(wxTreeEntry* entry, + wxTreeEntryDestroy destroy_func, gpointer destroy_func_data) { - g_assert(GTK_IS_TREE_ENTRY(entry)); + g_assert(WX_IS_TREE_ENTRY(entry)); entry->destroy_func = destroy_func; entry->destroy_func_data = destroy_func_data; } /* private */ -static void gtk_tree_entry_class_init(void* g_class, void* class_data) +static void wx_tree_entry_class_init(void* g_class, void* class_data) { GObjectClass* gobject_class = G_OBJECT_CLASS(g_class); - gobject_class->dispose = gtk_tree_entry_dispose; + gobject_class->dispose = wx_tree_entry_dispose; parent_class = G_OBJECT_CLASS(g_type_class_peek_parent(g_class)); } -static void gtk_tree_entry_string_transform_func(const GValue *src_value, +static void wx_tree_entry_string_transform_func(const GValue *src_value, GValue *dest_value) { - GtkTreeEntry *entry; + wxTreeEntry* entry; void* src_ptr = g_value_peek_pointer(src_value); /* Make sure src is a treeentry and dest can hold a string */ - g_assert(GTK_IS_TREE_ENTRY(src_ptr)); + g_assert(WX_IS_TREE_ENTRY(src_ptr)); g_assert(G_VALUE_HOLDS(dest_value, G_TYPE_STRING)); - entry = GTK_TREE_ENTRY(src_ptr); + entry = WX_TREE_ENTRY(src_ptr); g_value_set_string(dest_value, entry->label); } -static void gtk_tree_entry_dispose(GObject* obj) +static void wx_tree_entry_dispose(GObject* obj) { - GtkTreeEntry *entry; + wxTreeEntry* entry; - g_assert(GTK_IS_TREE_ENTRY(obj)); + g_assert(WX_IS_TREE_ENTRY(obj)); - entry = GTK_TREE_ENTRY(obj); + entry = WX_TREE_ENTRY(obj); /* free label if it exists */ if(entry->label)