[gtkmm] Gtk: Update for the latest gtk4 (remove Gtk::ModelButton, etc.)
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk: Update for the latest gtk4 (remove Gtk::ModelButton, etc.)
- Date: Wed, 27 Nov 2019 15:16:09 +0000 (UTC)
commit 70ba2acddbf3a6be979b030a19fce95714611b97
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed Nov 27 16:01:36 2019 +0100
Gtk: Update for the latest gtk4 (remove Gtk::ModelButton, etc.)
* gtk/src/buildable.[ccg|hg]:
* gtk/src/builder.[ccg|hg]: Remove all code requiring the get_type_from_name()
vfunc, which has been removed from GtkBuilder. The gtkmm__ prefix must now
sometimes (but rarely) be used in the .ui file. See the description of
Builder::get_widget_derived().
gdk/src/surface.hg | 4 +--
gtk/gtkmm.h | 1 -
gtk/src/buildable.ccg | 70 ---------------------------------------
gtk/src/buildable.hg | 27 ---------------
gtk/src/builder.ccg | 47 --------------------------
gtk/src/builder.hg | 33 +++++++------------
gtk/src/editable.hg | 4 +++
gtk/src/filelist.am | 1 -
gtk/src/modelbutton.ccg | 17 ----------
gtk/src/modelbutton.hg | 87 -------------------------------------------------
gtk/src/popovermenu.hg | 12 +++----
gtk/src/stack.hg | 11 +++++--
gtk/src/textbuffer.hg | 16 ++++++++-
gtk/src/window.hg | 4 +--
14 files changed, 48 insertions(+), 286 deletions(-)
---
diff --git a/gdk/src/surface.hg b/gdk/src/surface.hg
index 22087cae..413ea2c1 100644
--- a/gdk/src/surface.hg
+++ b/gdk/src/surface.hg
@@ -168,8 +168,8 @@ public:
_WRAP_METHOD(void beep(), gdk_surface_beep)
- _WRAP_METHOD(void iconify(), gdk_surface_iconify)
- _WRAP_METHOD(void deiconify(), gdk_surface_deiconify)
+ _WRAP_METHOD(void minimize(), gdk_surface_minimize)
+ _WRAP_METHOD(void unminimize(), gdk_surface_unminimize)
_WRAP_METHOD(void stick(), gdk_surface_stick)
_WRAP_METHOD(void unstick(), gdk_surface_unstick)
_WRAP_METHOD(void maximize(), gdk_surface_maximize)
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 114c525b..dfbb84e6 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -200,7 +200,6 @@ extern const int gtkmm_micro_version;
#include <gtkmm/menuitem.h>
#include <gtkmm/menushell.h>
#include <gtkmm/messagedialog.h>
-#include <gtkmm/modelbutton.h>
#include <gtkmm/noselection.h>
#include <gtkmm/notebook.h>
#include <gtkmm/object.h>
diff --git a/gtk/src/buildable.ccg b/gtk/src/buildable.ccg
index 2eaf52a3..f10e0efc 100644
--- a/gtk/src/buildable.ccg
+++ b/gtk/src/buildable.ccg
@@ -16,74 +16,4 @@
*/
#include <gtk/gtk.h>
-#include <gtkmm/builder.h>
-#include <cstring>
-namespace Gtk
-{
-
-//static
-gboolean Buildable_Class::custom_tag_start_vfunc_callback(
- GtkBuildable* buildable,
- GtkBuilder* builder,
- GObject* child,
- const gchar* tagname,
- GtkBuildableParser* parser,
- gpointer* data)
-{
- // If it's a TreeModel (such as ListStore or TreeStore) and it's the start
- // of a <columns> element, inform the Builder that the get_type_from_name()
- // vfunc shall not search for gtkmm-derived types.
- // See https://bugzilla.gnome.org/show_bug.cgi?id=742637
- if (GTK_IS_TREE_MODEL(buildable) && std::strcmp(tagname, "columns") == 0)
- {
- const auto cpp_builder = dynamic_cast<Builder*>(
- Glib::ObjectBase::_get_current_wrapper((GObject*)builder));
- if (cpp_builder)
- cpp_builder->set_no_gtkmm_derived_types(true);
- }
-
- const auto base = static_cast<BaseClassType*>(
- g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C
interface).
- g_type_interface_peek(G_OBJECT_GET_CLASS(buildable), CppObjectType::get_type()) // Get the interface.
- )
- );
-
- // Call the original underlying C function:
- if (base && base->custom_tag_start)
- return (*base->custom_tag_start)(buildable, builder, child, tagname, parser, data);
- return false;
-}
-
-//static
-void Buildable_Class::custom_tag_end_vfunc_callback(
- GtkBuildable* buildable,
- GtkBuilder* builder,
- GObject* child,
- const gchar* tagname,
- gpointer data)
-{
- const auto base = static_cast<BaseClassType*>(
- g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C
interface).
- g_type_interface_peek(G_OBJECT_GET_CLASS(buildable), CppObjectType::get_type()) // Get the interface.
- )
- );
-
- // Call the original underlying C function:
- if (base && base->custom_tag_end)
- (*base->custom_tag_end)(buildable, builder, child, tagname, data);
-
- // If it's a TreeModel (such as ListStore or TreeStore) and it's the end
- // of a </columns> element, inform the Builder that the get_type_from_name()
- // vfunc shall resume search for gtkmm-derived types.
- // See https://bugzilla.gnome.org/show_bug.cgi?id=742637
- if (GTK_IS_TREE_MODEL(buildable) && std::strcmp(tagname, "columns") == 0)
- {
- const auto cpp_builder = dynamic_cast<Builder*>(
- Glib::ObjectBase::_get_current_wrapper((GObject*)builder));
- if (cpp_builder)
- cpp_builder->set_no_gtkmm_derived_types(false);
- }
-}
-
-} // namespace Gtk
diff --git a/gtk/src/buildable.hg b/gtk/src/buildable.hg
index ba6ce5c4..81f1d2f1 100644
--- a/gtk/src/buildable.hg
+++ b/gtk/src/buildable.hg
@@ -83,33 +83,6 @@ public:
*/
//TODO: Properties, signals, vfuncs.
-
-#m4begin
-dnl //Custom-coded vfuncs:
-dnl
- _PUSH(SECTION_CC_PRE_INCLUDES)
- // Needed before gtkmm/private/buildable_p.h is included.
- typedef struct _GtkBuilder GtkBuilder;
- typedef struct _GtkBuildableParser GtkBuildableParser;
- _SECTION(SECTION_PCC_CLASS_INIT_VFUNCS)
- klass->custom_tag_start = &custom_tag_start_vfunc_callback;
- klass->custom_tag_end = &custom_tag_end_vfunc_callback;
- _SECTION(SECTION_PH_VFUNCS)
- static gboolean custom_tag_start_vfunc_callback(
- GtkBuildable* buildable,
- GtkBuilder* builder,
- GObject* child,
- const gchar* tagname,
- GtkBuildableParser* parser,
- gpointer* data);
- static void custom_tag_end_vfunc_callback(
- GtkBuildable* buildable,
- GtkBuilder* builder,
- GObject* child,
- const gchar* tagname,
- gpointer data);
- _POP()
-#m4end
};
} // namespace Gtk
diff --git a/gtk/src/builder.ccg b/gtk/src/builder.ccg
index 2570a9f1..2cb3a2c1 100644
--- a/gtk/src/builder.ccg
+++ b/gtk/src/builder.ccg
@@ -22,53 +22,6 @@
namespace Gtk
{
-
-// Allow GtkBuilder to instantiate a gtkmm derived GType instead of the regular
-// GTK+ GType, so we can, for instance, use our vfuncs and default signal handlers.
-// static
-GType Builder_Class::get_type_from_name_vfunc_callback(GtkBuilder* self, const char* type_name)
-{
- if (!type_name)
- return G_TYPE_INVALID;
-
- GType gtype = G_TYPE_INVALID;
-
- // If a TreeModel (such as ListStore or TreeStore) is being built,
- // Buildable_Class may have requested no search for gtkmm-derived types.
- // See https://bugzilla.gnome.org/show_bug.cgi?id=742637
- const auto obj = dynamic_cast<Builder*>(
- Glib::ObjectBase::_get_current_wrapper((GObject*)self));
- if (!(obj && obj->no_gtkmm_derived_types))
- {
- // See if there is a gtkmm version of the gclass:
- Glib::ustring classname_prefixed ("gtkmm__"); // gtkmm uses a prefix
- classname_prefixed += type_name;
-
- gtype = g_type_from_name(classname_prefixed.c_str());
- }
-
- if (gtype == G_TYPE_INVALID) // If it's not a registered typename
- {
- // Get the parent class of the object class (the original underlying C class).
- const auto base = static_cast<BaseClassType*>(
- g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)));
-
- // Call the original underlying C function.
- if (base && base->get_type_from_name)
- gtype = (*base->get_type_from_name)(self, type_name);
- else // If that's not possible, just use the normal GType.
- gtype = g_type_from_name(type_name);
- }
-
- return gtype;
-}
-
-// Called from Buildable
-void Builder::set_no_gtkmm_derived_types(bool status)
-{
- no_gtkmm_derived_types = status;
-}
-
// static
Glib::RefPtr<Builder> Builder::create_from_file(const std::string& filename)
{
diff --git a/gtk/src/builder.hg b/gtk/src/builder.hg
index 8fd75783..10cdafbc 100644
--- a/gtk/src/builder.hg
+++ b/gtk/src/builder.hg
@@ -548,6 +548,18 @@ public:
* auto pDialog2 = Gtk::Builder::get_widget_derived<MyDerivedDialog>(refBuilder, "mydialog2", "A storm is
imminent!", true);
* @endcode
*
+ * If your derived class overrides vfuncs (virtual functions) or default signal
+ * handlers which are part of the wrapped C API, its class name in the XML UI file
+ * must have a @a gtkmm__ prefix, for instance
+ * @code
+ * <object class="gtkmm__GtkDialog" id="mydialog3">
+ * @endcode
+ * gtkmm__GtkDialog is a subclass of GtkDialog in the GType system. In most
+ * respects a GtkSomeClass instance acts identically to a gtkmm__GtkSomeClass
+ * instance, but C++ vfuncs and default signal handlers are not called for
+ * GtkSomeClass instances. (Signal handlers, connected with signal_some_signal().connect(),
+ * are called for both gtkmm__GtkSomeClass and GtkSomeClass instances.)
+ *
* @note
* If get_widget_derived() is called more than once for the same widget (the
* same @a name), only the first call will call the widget's constructor.
@@ -627,15 +639,9 @@ public:
#m4 _CONVERSION(`GSList*',`std::vector<Glib::RefPtr<const Glib::Object>
',`Glib::SListHandler<Glib::RefPtr<const Glib::Object> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
_WRAP_METHOD(std::vector<Glib::RefPtr<const Glib::Object> > get_objects() const, gtk_builder_get_objects)
- //_WRAP_METHOD(void connect_signals(gpointer user_data), gtk_builder_connect_signals)
- //_WRAP_METHOD(void connect_signals_full(GtkBuilderConnectFunc func, gpointer user_data),
gtk_builder_connect_signals_full)
_WRAP_METHOD(void set_translation_domain(const Glib::ustring& domain), gtk_builder_set_translation_domain)
_WRAP_METHOD(Glib::ustring get_translation_domain() const, gtk_builder_get_translation_domain)
- _WRAP_METHOD(void set_application(const Glib::RefPtr<Application>& application),
gtk_builder_set_application)
- _WRAP_METHOD(Glib::RefPtr<Application> get_application(), gtk_builder_get_application, refreturn)
- _WRAP_METHOD(Glib::RefPtr<const Application> get_application() const, gtk_builder_get_application,
refreturn, constversion)
-
//We ignore gtk_builder_get_type_from_name() because it only seems useful when implementing GtkBuildable
for widgets.
_IGNORE(gtk_builder_get_type_from_name)
@@ -644,21 +650,6 @@ public:
protected:
Gtk::Widget* get_widget_checked(const Glib::ustring& name, GType type);
GtkWidget* get_cwidget(const Glib::ustring& name);
-
-private:
- void set_no_gtkmm_derived_types(bool status);
- bool no_gtkmm_derived_types {false};
- friend class Buildable_Class;
-
-#m4begin
-dnl Custom-coded vfunc:
-dnl
- _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
- klass->get_type_from_name = &get_type_from_name_vfunc_callback;
- _SECTION(SECTION_PH_VFUNCS)
- static GType get_type_from_name_vfunc_callback(GtkBuilder* self, const char* type_name);
- _POP()
-#m4end
};
} // namespace Gtk
diff --git a/gtk/src/editable.hg b/gtk/src/editable.hg
index 2e15f3c6..b84051ce 100644
--- a/gtk/src/editable.hg
+++ b/gtk/src/editable.hg
@@ -70,6 +70,9 @@ public:
_WRAP_METHOD(int get_max_width_chars() const, gtk_editable_get_max_width_chars)
_WRAP_METHOD(void set_max_width_chars(int n_chars), gtk_editable_set_max_width_chars)
+ _WRAP_METHOD(bool get_enable_undo() const, gtk_editable_get_enable_undo)
+ _WRAP_METHOD(void set_enable_undo(bool enable_undo = true), gtk_editable_set_enable_undo)
+
// Don't wrap API for implementations. Should it be wrapped?
_IGNORE(gtk_editable_install_properties, gtk_editable_init_delegate, gtk_editable_finish_delegate,
gtk_editable_delegate_set_property, gtk_editable_delegate_get_property)
@@ -112,6 +115,7 @@ dnl // C prototype: void insert_text(const gchar* text, int length, int* positio
_WRAP_PROPERTY("text", Glib::ustring)
_WRAP_PROPERTY("cursor-position", int)
+ _WRAP_PROPERTY("enable-undo", bool)
_WRAP_PROPERTY("selection-bound", int)
_WRAP_PROPERTY("editable", bool)
_WRAP_PROPERTY("width-chars", int)
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 3ca2e22b..972e7dff 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -133,7 +133,6 @@ gtkmm_files_any_hg = \
menushell.hg \
menutoolbutton.hg \
messagedialog.hg \
- modelbutton.hg \
native.hg \
nativedialog.hg \
noselection.hg \
diff --git a/gtk/src/popovermenu.hg b/gtk/src/popovermenu.hg
index cc38ff91..9adc98ec 100644
--- a/gtk/src/popovermenu.hg
+++ b/gtk/src/popovermenu.hg
@@ -59,12 +59,6 @@ class PopoverMenu : public Popover
public:
_WRAP_ENUM(Flags, GtkPopoverMenuFlags)
- /** Creates a new popover menu to point to @a relative_to.
- *
- * @param relative_to The Gtk::Widget the popover menu is related to.
- */
- _WRAP_CTOR(PopoverMenu(const Widget& relative_to{?}), gtk_popover_menu_new)
-
//This is custom-implemented because the gtk_popover_menu_new_from_model() does more
//than just call g_object_new. MenuBar and Menu have both the same issue.
//See https://bugzilla.gnome.org/show_bug.cgi?id=704671
@@ -111,10 +105,12 @@ public:
Flags flags = static_cast<Flags>(0));
_IGNORE(gtk_popover_menu_new_from_model, gtk_popover_menu_new_from_model_full)
- _WRAP_METHOD(void add_submenu(Widget& submenu, const Glib::ustring& name), gtk_popover_menu_add_submenu)
- _WRAP_METHOD(void open_submenu(const Glib::ustring& name), gtk_popover_menu_open_submenu)
+ _WRAP_METHOD(void set_menu_model(const Glib::RefPtr<Gio::MenuModel>& model),
gtk_popover_menu_set_menu_model)
+ _WRAP_METHOD(Glib::RefPtr<Gio::MenuModel> get_menu_model(), gtk_popover_menu_get_menu_model, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const Gio::MenuModel> get_menu_model() const, gtk_popover_menu_get_menu_model,
refreturn, constversion)
_WRAP_PROPERTY("visible-submenu", Glib::ustring)
+ _WRAP_PROPERTY("menu-model", Glib::RefPtr<Gio::MenuModel>)
// PopoverMenu has no signals nor vfuncs.
};
diff --git a/gtk/src/stack.hg b/gtk/src/stack.hg
index b65f47b1..6ea268cd 100644
--- a/gtk/src/stack.hg
+++ b/gtk/src/stack.hg
@@ -49,8 +49,15 @@ class Stack
public:
_CTOR_DEFAULT
- _WRAP_METHOD(void add(Widget& child, const Glib::ustring& name), gtk_stack_add_named)
- _WRAP_METHOD(void add(Widget& child, const Glib::ustring& name, const Glib::ustring& title),
gtk_stack_add_titled)
+ _WRAP_METHOD(Glib::RefPtr<StackPage> add(Widget& child, const Glib::ustring& name),
+ gtk_stack_add_named, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const StackPage> add(Widget& child, const Glib::ustring& name) const,
+ gtk_stack_add_named, refreturn, constversion)
+
+ _WRAP_METHOD(Glib::RefPtr<StackPage> add(Widget& child, const Glib::ustring& name,
+ const Glib::ustring& title), gtk_stack_add_titled, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const StackPage> add(Widget& child, const Glib::ustring& name,
+ const Glib::ustring& title) const, gtk_stack_add_titled, refreturn, constversion)
_WRAP_METHOD(Glib::RefPtr<StackPage> get_page(Widget& child), gtk_stack_get_page, refreturn)
_WRAP_METHOD(Glib::RefPtr<const StackPage> get_page(const Widget& child) const, gtk_stack_get_page,
refreturn, constversion)
diff --git a/gtk/src/textbuffer.hg b/gtk/src/textbuffer.hg
index 1a76a161..0cd5cfe6 100644
--- a/gtk/src/textbuffer.hg
+++ b/gtk/src/textbuffer.hg
@@ -494,7 +494,16 @@ public:
_WRAP_METHOD(void select_range(const iterator& ins, const iterator& bound), gtk_text_buffer_select_range)
-/* Called to specify atomic user actions, used to implement undo */
+ _WRAP_METHOD(bool get_can_undo() const, gtk_text_buffer_get_can_undo)
+ _WRAP_METHOD(bool get_can_redo() const, gtk_text_buffer_get_can_redo)
+ _WRAP_METHOD(bool get_enable_undo() const, gtk_text_buffer_get_enable_undo)
+ _WRAP_METHOD(void set_enable_undo(bool enable_undo = true), gtk_text_buffer_set_enable_undo)
+ _WRAP_METHOD(guint get_max_undo_levels() const, gtk_text_buffer_get_max_undo_levels)
+ _WRAP_METHOD(void set_max_undo_levels(guint max_undo_levels), gtk_text_buffer_set_max_undo_levels)
+ _WRAP_METHOD(void undo(), gtk_text_buffer_undo)
+ _WRAP_METHOD(void redo(), gtk_text_buffer_redo)
+ _WRAP_METHOD(void begin_irreversible_action(), gtk_text_buffer_begin_irreversible_action)
+ _WRAP_METHOD(void end_irreversible_action(), gtk_text_buffer_end_irreversible_action)
_WRAP_METHOD(void begin_user_action(), gtk_text_buffer_begin_user_action)
_WRAP_METHOD(void end_user_action(), gtk_text_buffer_end_user_action)
@@ -530,6 +539,8 @@ _CONVERSION(`GtkTextIter*',`TextBuffer::iterator&',Glib::wrap_iter($3))
#m4 _CONVERSION(`GdkClipboard*',`const Glib::RefPtr<Gdk::Clipboard>&', Glib::wrap($3, true))
#m4 _CONVERSION(`const Glib::RefPtr<Gdk::Clipboard>&', `GdkClipboard*', Glib::unwrap($3))
_WRAP_SIGNAL(void paste_done(const Glib::RefPtr<Gdk::Clipboard>& clipboard), "paste_done")
+ _WRAP_SIGNAL(void redo(), "redo")
+ _WRAP_SIGNAL(void undo(), "undo")
_WRAP_PROPERTY("tag-table", Glib::RefPtr<TextBuffer::TagTable>)
_WRAP_PROPERTY("text", Glib::ustring)
@@ -537,6 +548,9 @@ _CONVERSION(`GtkTextIter*',`TextBuffer::iterator&',Glib::wrap_iter($3))
_WRAP_PROPERTY("cursor-position", int)
_WRAP_PROPERTY("copy-target-list", Glib::RefPtr<Gdk::ContentFormats>)
_WRAP_PROPERTY("paste-target-list", Glib::RefPtr<Gdk::ContentFormats>)
+ _WRAP_PROPERTY("can-undo", bool)
+ _WRAP_PROPERTY("can-redo", bool)
+ _WRAP_PROPERTY("enable-undo", bool)
private:
friend TextMark;
diff --git a/gtk/src/window.hg b/gtk/src/window.hg
index d946fa78..9752e115 100644
--- a/gtk/src/window.hg
+++ b/gtk/src/window.hg
@@ -233,8 +233,8 @@ dnl
_WRAP_METHOD(void present(), gtk_window_present)
_WRAP_METHOD(void present(guint32 timestamp), gtk_window_present_with_time)
- _WRAP_METHOD(void iconify(), gtk_window_iconify)
- _WRAP_METHOD(void deiconify(), gtk_window_deiconify)
+ _WRAP_METHOD(void minimize(), gtk_window_minimize)
+ _WRAP_METHOD(void unminimize(), gtk_window_unminimize)
_WRAP_METHOD(void stick(), gtk_window_stick)
_WRAP_METHOD(void unstick(), gtk_window_unstick)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]