Commit b83498f8 authored by Murray Cumming's avatar Murray Cumming Committed by Murray Cumming

Wrap the get and set methods that deal with char** arrays, using

2004-10-22  Murray Cumming  <murrayc@murrayc.com>

        * gtk/src/aboutdialog.hg: Wrap the get and set methods that deal with
        char** arrays, using Glib::SArrayHandle. Wrap the callback set
        methods with a SignalProxy.
        * gtk/src/gtk_signals.defs: Add signals and properties for
        AboutDialog and MenuToolButton.
        * tools/extra_defs_gen/generate_defs_gtk.cc: Get defs for
        GtkAboutDialog and GtkMenuToolButton.
        * gtk/src/action_group.hg: Add translate_string(). We probably need to
        use iit in the .ccg file.
        * gtk/src/icontheme.hg: Added get_icon_sizes().
        * gtk/src/iconview.hg: Added get_selected_items().
        * tools/m4/convert_gtk.m4: Added conversion for SArrayHandle to char**,
        and GList* to SListHandle<TreePath>
parent db358509
2004-10-22 Murray Cumming <murrayc@murrayc.com>
* gtk/src/aboutdialog.hg: Wrap the get and set methods that deal with
char** arrays, using Glib::SArrayHandle. Wrap the callback set
methods with a SignalProxy.
* gtk/src/gtk_signals.defs: Add signals and properties for
AboutDialog and MenuToolButton.
* tools/extra_defs_gen/generate_defs_gtk.cc: Get defs for
GtkAboutDialog and GtkMenuToolButton.
* gtk/src/action_group.hg: Add translate_string(). We probably need to
use iit in the .ccg file.
* gtk/src/icontheme.hg: Added get_icon_sizes().
* gtk/src/iconview.hg: Added get_selected_items().
* tools/m4/convert_gtk.m4: Added conversion for SArrayHandle to char**,
and GList* to SListHandle<TreePath>
2004-10-17 Gene Ruebsamen <gene@erachampion.com>
* docs/tutorial/gtkmm-tut.xml: Updated the Windows installation
......
* AboutDialog:
- Added more get and set methods and properties.
- Wrapped signals.
* ActionGroup: Added translate_string().
* IconTheme: Added get_icon_sizes().
* IconView: Added get_selected_items().
2.5.0:
gtkmm 2.5 wraps new API in GTK+ 2.5, and is API/ABI-compatibile with gtkmm 2.4.
......
......@@ -24,9 +24,84 @@
#include <gtk/gtklabel.h>
namespace //anonymous
{
// This Signal Proxy allows the C++ coder to specify
// a sigc::slot instead of a static function.
class SignalProxy_ActivateLink
{
public:
typedef Gtk::AboutDialog::SlotActivateLink SlotType;
SignalProxy_ActivateLink(const SlotType& slot)
: slot_(slot) {}
~SignalProxy_ActivateLink();
static void gtk_callback(GtkAboutDialog* about, const gchar* link, gpointer data);
static void gtk_callback_destroy(void* data);
private:
SlotType slot_;
};
SignalProxy_ActivateLink::~SignalProxy_ActivateLink()
{}
void SignalProxy_ActivateLink::gtk_callback(GtkAboutDialog* about, const gchar* link, gpointer data)
{
SignalProxy_ActivateLink *const self = static_cast<SignalProxy_ActivateLink*>(data);
try
{
Gtk::AboutDialog* pCppAbout = Glib::wrap(about);
(self->slot_)( *pCppAbout, Glib::convert_const_gchar_ptr_to_ustring(link) );
}
catch(...)
{
Glib::exception_handlers_invoke();
}
}
void SignalProxy_ActivateLink::gtk_callback_destroy(void* data)
{
delete static_cast<SignalProxy_ActivateLink*>(data);
}
} // anonymous namespace
namespace Gtk
{
//static:
void AboutDialog::set_email_hook(const SlotActivateLink& slot)
{
// Create a signal proxy. A pointer to this will be passed
// through the callback's data parameter. It will be deleted
// when SignalProxy_ActivateLink::gtk_callback_destroy() is called.
SignalProxy_ActivateLink *const pSignalProxy = new SignalProxy_ActivateLink(slot);
gtk_about_dialog_set_email_hook(
&SignalProxy_ActivateLink::gtk_callback, pSignalProxy,
&SignalProxy_ActivateLink::gtk_callback_destroy);
}
//static:
void AboutDialog::set_url_hook(const SlotActivateLink& slot)
{
// Create a signal proxy. A pointer to this will be passed
// through the callback's data parameter. It will be deleted
// when SignalProxy_ActivateLink::gtk_callback_destroy() is called.
SignalProxy_ActivateLink *const pSignalProxy = new SignalProxy_ActivateLink(slot);
gtk_about_dialog_set_url_hook(
&SignalProxy_ActivateLink::gtk_callback, pSignalProxy,
&SignalProxy_ActivateLink::gtk_callback_destroy);
}
} // namespace Gtk
......@@ -20,6 +20,7 @@
*/
#include <gtkmm/dialog.h>
//#include <glibmm/listhandle.h>
_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/dialog_p.h)
......@@ -52,12 +53,13 @@ public:
_WRAP_METHOD(void set_website(const Glib::ustring& website), gtk_about_dialog_set_website)
_WRAP_METHOD(Glib::ustring get_website_label() const, gtk_about_dialog_get_website_label)
_WRAP_METHOD(void set_website_label(const Glib::ustring& website_label), gtk_about_dialog_set_website_label)
//TODO: _WRAP_METHOD(gchar** get_authors(), gtk_about_dialog_get_authors)
//TODO: _WRAP_METHOD(void set_authors(gchar** authors), gtk_about_dialog_set_authors)
//TODO: _WRAP_METHOD(gchar** get_documenters() const, gtk_about_dialog_get_documenters)
//TODO: _WRAP_METHOD(void gtk_about_dialog_set_documenters(gchar** documenters), gtk_about_dialog_set_documenters)
//TODO: _WRAP_METHOD(gchar** get_artists() const, gtk_about_dialog_get_artists)
//TODO: _WRAP_METHOD(void set_artists(gchar ** artists), gtk_about_dialog_set_artists)
_WRAP_METHOD(Glib::StringArrayHandle get_authors() const, gtk_about_dialog_get_authors)
_WRAP_METHOD(void set_authors(const Glib::StringArrayHandle& authors) const, gtk_about_dialog_set_authors)
_WRAP_METHOD(Glib::StringArrayHandle get_documenters() const, gtk_about_dialog_get_documenters)
_WRAP_METHOD(void set_documenters(const Glib::StringArrayHandle& documenters), gtk_about_dialog_set_documenters)
_WRAP_METHOD(Glib::StringArrayHandle get_artists() const, gtk_about_dialog_get_artists)
_WRAP_METHOD(void set_artists(const Glib::StringArrayHandle& artists), gtk_about_dialog_set_artists)
_WRAP_METHOD(Glib::ustring get_translator_credits() const, gtk_about_dialog_get_translator_credits)
_WRAP_METHOD(void set_translator_credits(const Glib::ustring& translator_credits), gtk_about_dialog_set_translator_credits)
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_logo(), gtk_about_dialog_get_logo)
......@@ -65,18 +67,32 @@ public:
_WRAP_METHOD(void set_logo(const Glib::RefPtr<Gdk::Pixbuf>& logo), gtk_about_dialog_set_logo)
/* TODO:
typedef void (* GtkAboutDialogActivateLinkFunc) (GtkAboutDialog *about,
const gchar *link,
gpointer data);
/** For instance,
* void on_activate_link_url(AboutDialog& about_dialog, const Glib::ustring& link);
*/
typedef sigc::slot<void, AboutDialog& /* about_dialog */, const Glib::ustring& /* link */> SlotActivateLink;
//TODO: Document these methods.
static void set_email_hook(const SlotActivateLink& slot);
_IGNORE(gtk_about_dialog_set_email_hook)
static void set_url_hook(const SlotActivateLink& slot);
_IGNORE(gtk_about_dialog_set_url_hook)
_WRAP_PROPERTY("name", Glib::ustring)
_WRAP_PROPERTY("version", Glib::ustring)
_WRAP_PROPERTY("copyright", Glib::ustring)
_WRAP_PROPERTY("comments", Glib::ustring)
_WRAP_PROPERTY("website", Glib::ustring)
_WRAP_PROPERTY("website-label", Glib::ustring)
_WRAP_PROPERTY("license", Glib::ustring)
_WRAP_PROPERTY("authors", Glib::StringArrayHandle)
_WRAP_PROPERTY("documenters", Glib::StringArrayHandle)
_WRAP_PROPERTY("translator-credits", Glib::StringArrayHandle)
_WRAP_PROPERTY("artists", Glib::StringArrayHandle)
_WRAP_PROPERTY("logo", Glib::RefPtr<Gdk::Pixbuf>)
GtkAboutDialogActivateLinkFunc gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
gpointer data,
GDestroyNotify destroy);
GtkAboutDialogActivateLinkFunc gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
gpointer data,
GDestroyNotify destroy);
*/
};
......
......@@ -68,7 +68,12 @@ void ActionGroup::add(const Glib::RefPtr<Action>& action, const Action::SlotActi
//because the extra stuff there is already done when the Action (or a derived type, such as ToggleAction) is create()ed.
action->signal_activate().connect(slot);
//TODO: Use the translation_func?
//We probably don't need to use translate_string(), because the label and tooltip will be regular translated strings in our C++ application code.
//But C needs it because gtk_action_group_add_actions() takes a static array of GtkActionEntrys whose fields
//can not be translated with gettext macros.
//But we should soon know if menus and toolbars are not translated in non-english locales. murrayc.
add(action);
}
......
......@@ -66,6 +66,10 @@ public:
void add(const Glib::RefPtr<Action>& action, const Action::SlotActivate& slot);
void add(const Glib::RefPtr<Action>& action, const AccelKey& accel_key, const Action::SlotActivate& slot);
_WRAP_METHOD(void remove(const Glib::RefPtr<Action>& action), gtk_action_group_remove_action)
//TODO: We probably need to use this in our add_actions() implementation:
_WRAP_METHOD(Glib::ustring translate_string(const Glib::ustring& str) const, gtk_action_group_translate_string)
//These are just C convenience methods:
_IGNORE(gtk_action_group_add_actions, gtk_action_group_add_toggle_actions, gtk_action_group_add_radio_actions,
......
This diff is collapsed.
......@@ -28,11 +28,20 @@ void IconTheme::set_search_path(const Glib::ArrayHandle<Glib::ustring>& path)
Glib::ArrayHandle<Glib::ustring> IconTheme::get_search_path() const
{
int *temp_int = 0;
gchar ***temp_path = 0;
int* temp_int = 0;
gchar*** temp_path = 0;
gtk_icon_theme_get_search_path(const_cast<GtkIconTheme*>(gobj()), temp_path, temp_int);
return Glib::ArrayHandle<Glib::ustring>((const char**)(*temp_path), *temp_int, Glib::OWNERSHIP_SHALLOW);
}
Glib::ArrayHandle<int> IconTheme::get_icon_sizes(const Glib::ustring& icon_name) const
{
int* pArrayInts = gtk_icon_theme_get_icon_sizes(const_cast<GtkIconTheme*>(gobj()), icon_name.c_str());
//pArrayInts is null-terminated.
return Glib::ArrayHandle<int>(pArrayInts, Glib::OWNERSHIP_SHALLOW); //TODO: I'm not sure about the ownership. murrayc.
}
} // namespace Gtk
......@@ -49,8 +49,9 @@ public:
_WRAP_METHOD(void set_custom_theme(const Glib::ustring& theme_name), gtk_icon_theme_set_custom_theme)
_WRAP_METHOD(bool has_icon(const Glib::ustring& icon_name) const, gtk_icon_theme_has_icon)
//TODO: _WRAP_METHOD(gint* get_icon_sizes(const Glib::ustring& icon_name) const, gtk_icon_theme_get_icon_sizes)
Glib::ArrayHandle<int> get_icon_sizes(const Glib::ustring& icon_name) const;
_IGNORE(gtk_icon_theme_get_icon_sizes)
_WRAP_METHOD(IconInfo lookup_icon(const Glib::ustring& icon_name, int size, IconLookupFlags flags) const, gtk_icon_theme_lookup_icon)
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_icon(const Glib::ustring& icon_name, int size, IconLookupFlags flags) const, gtk_icon_theme_load_icon, errthrow)
......
......@@ -41,9 +41,13 @@ void proxy_foreach_callback(GtkIconView* /* icon_view */, GtkTreePath* path, voi
} //anonymous namespace
namespace Gtk
{
//Allow the generated code to work without the prefix:
typedef IconView::ArrayHandle_TreePaths ArrayHandle_TreePaths;
void IconView::selected_foreach(const SlotForeach& slot)
{
SlotForeach slot_copy(slot);
......
......@@ -85,7 +85,28 @@ public:
_WRAP_METHOD(void select_path(const TreeModel::Path& path), gtk_icon_view_select_path)
_WRAP_METHOD(void unselect_path(const TreeModel::Path& path), gtk_icon_view_unselect_path)
_WRAP_METHOD(bool path_is_selected(const TreeModel::Path& path) const, gtk_icon_view_path_is_selected)
//TODO: _WRAP_METHOD(GList *gtk_icon_view_get_selected_items (GtkIconView *icon_view);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
//TODO: I'm not sure about these to_*() functions. murrayc.
struct TreePathTraits
{
typedef TreePath CppType;
typedef const GtkTreePath* CType;
typedef GtkTreePath* CTypeNonConst;
static CType to_c_type (const CppType& obj) { return obj.gobj(); }
static CType to_c_type (const CType& obj) { return obj; }
static CppType to_cpp_type (const CType& obj) { return CppType(const_cast<CTypeNonConst>(obj), true); }
static void release_c_type (const CType&) {}
};
#endif //DOXYGEN_SHOULD_SKIP_THIS
typedef Glib::ListHandle<TreePath, TreePathTraits> ArrayHandle_TreePaths;
_CONVERSION(`GList*',`ArrayHandle_TreePaths',__FL2H_SHALLOW)
_WRAP_METHOD(ArrayHandle_TreePaths get_selected_items() const, gtk_icon_view_get_selected_items)
_WRAP_METHOD(void select_all(), gtk_icon_view_select_all)
_WRAP_METHOD(void unselect_all(), gtk_icon_view_unselect_all)
_WRAP_METHOD(void item_activated(const TreeModel::Path& path), gtk_icon_view_item_activated)
......
......@@ -63,7 +63,8 @@ int main (int argc, char *argv[])
<< get_defs( GDK_TYPE_SCREEN )
<< get_defs( GDK_TYPE_VISUAL )
<< get_defs( GDK_TYPE_WINDOW )
<< get_defs( GTK_TYPE_ABOUT_DIALOG )
<< get_defs( GTK_TYPE_ACCEL_GROUP )
<< get_defs( GTK_TYPE_ACCEL_LABEL )
<< get_defs( GTK_TYPE_ACTION )
......@@ -123,7 +124,8 @@ int main (int argc, char *argv[])
<< get_defs( GTK_TYPE_MENU_BAR )
<< get_defs( GTK_TYPE_MENU_ITEM )
<< get_defs( GTK_TYPE_MENU_SHELL )
<< get_defs( GTK_TYPE_MESSAGE_DIALOG )
<< get_defs( GTK_TYPE_MENU_TOOL_BUTTON )
<< get_defs( GTK_TYPE_MESSAGE_DIALOG )
<< get_defs( GTK_TYPE_MISC )
<< get_defs( GTK_TYPE_NOTEBOOK )
<< get_defs( GTK_TYPE_OBJECT )
......
......@@ -505,3 +505,5 @@ _CONVERSION(`GtkAction*',`const Glib::RefPtr<Action>&',`Glib::wrap($3, true)')
_CONVERSION(`AlignmentEnum',`float',`_gtkmm_align_float_from_enum($3)')
# Used by AboutDialog:
_CONVERSION(`const Glib::StringArrayHandle&',`gchar**',`const_cast<char**>(($3).data())')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment