From 9d5ee2dde34854c6a5deccd9ac59e75aed83da59 Mon Sep 17 00:00:00 2001 From: Sven Pohl Date: Tue, 28 Feb 2023 15:58:07 +0100 Subject: [PATCH 1/6] fix: new depedency added --- docs/compile-windows.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/compile-windows.md b/docs/compile-windows.md index 8d68fa6..f6f2397 100644 --- a/docs/compile-windows.md +++ b/docs/compile-windows.md @@ -249,6 +249,7 @@ libglib-2.0.dll.a libgladeui-2.dll.a libgtksourceview-3.0.dll.a + libpango-1.0.dll.a ``` 4. Build everything From 299af9148953410d16ca01a45974f28b3b6e8f4f Mon Sep 17 00:00:00 2001 From: Sven Pohl Date: Fri, 17 Mar 2023 20:34:12 +0100 Subject: [PATCH 2/6] feat: get and set data draft --- main.cpp | 61 +++++++++++++++++++++++++++-------------------- src/G/GObject.cpp | 24 +++++++++++++++++++ src/G/GObject.h | 2 ++ 3 files changed, 61 insertions(+), 26 deletions(-) diff --git a/main.cpp b/main.cpp index f1c5075..e388023 100644 --- a/main.cpp +++ b/main.cpp @@ -41,6 +41,8 @@ extern "C" gobject.method<&GObject_::is_connected>("is_connected"); gobject.method<&GObject_::get_property>("get_property"); gobject.method<&GObject_::set_property>("set_property"); + gobject.method<&GObject_::get_data>("get_data"); + gobject.method<&GObject_::set_data>("set_data"); gobject.method<&GObject_::signal_handler_block>("signal_handler_block"); gobject.method<&GObject_::signal_handler_unblock>("signal_handler_unblock"); gobject.constant("TYPE_INVALID", (int)G_TYPE_INVALID); @@ -511,7 +513,7 @@ extern "C" // gdkevent.property("type", 0); // GdkEventMask - Php::Class gdkeventmask("GdkEventMask"); + Php::Class gdkeventmask("GdkEventMask"); gdkeventmask.constant("EXPOSURE_MASK", (int)GDK_EXPOSURE_MASK); gdkeventmask.constant("POINTER_MOTION_MASK", (int)GDK_POINTER_MOTION_MASK); gdkeventmask.constant("POINTER_MOTION_HINT_MASK", (int)GDK_POINTER_MOTION_HINT_MASK); @@ -538,7 +540,11 @@ extern "C" gdkeventmask.constant("TOUCHPAD_GESTURE_MASK", (int)GDK_TOUCHPAD_GESTURE_MASK); gdkeventmask.constant("TABLET_PAD_MASK", (int)GDK_TABLET_PAD_MASK); gdkeventmask.constant("ALL_EVENTS_MASK", (int)GDK_ALL_EVENTS_MASK); - + + // GdkThreads + // Php::Class gdkthreads("GdkThreads"); + // gdkthreads.method<&GdkThreads_::add_idle>("add_idle"); + // GdkScreen Php::Class gdkscreen("GdkScreen"); // gdkevent.method<&GdkEvent_::__construct>("__construct"); @@ -563,7 +569,7 @@ extern "C" // GdkEventKey Php::Class gdkeventkey("GdkEventKey"); - // GdkEventKey + // GdkEventType Php::Class gdkeventtype("GdkEventType"); gdkeventtype.constant("NOTHING", (int)GDK_NOTHING); gdkeventtype.constant("DELETE", (int)GDK_DELETE); @@ -637,7 +643,7 @@ extern "C" gdkpixbuf.method<&GdkPixbuf_::get_from_drawable>("get_from_drawable"); gdkpixbuf.method<&GdkPixbuf_::scale_simple>("scale_simple"); - // GdkEventKey + // GdkInterpType Php::Class gdkinterptype("GdkInterpType"); gdkinterptype.constant("NEAREST", (int)GDK_INTERP_NEAREST); gdkinterptype.constant("TILES", (int)GDK_INTERP_TILES); @@ -1054,22 +1060,22 @@ extern "C" gtkcontainer.method<&GtkContainer_::class_handle_border_width>("class_handle_border_width"); Php::Class gtktable("GtkTable"); - gtktable.extends(gtkcontainer); - gtktable.method<&GtkTable_::resize>("resize"); - gtktable.method<&GtkTable_::attach>("attach"); - gtktable.method<&GtkTable_::attach_defaults>("attach_defaults"); - gtktable.method<&GtkTable_::set_row_spacing>("set_row_spacing"); - gtktable.method<&GtkTable_::get_row_spacing>("get_row_spacing"); - gtktable.method<&GtkTable_::set_col_spacing>("set_col_spacing"); - gtktable.method<&GtkTable_::get_col_spacing>("get_col_spacing"); - gtktable.method<&GtkTable_::set_row_spacings>("set_row_spacings"); - gtktable.method<&GtkTable_::get_default_row_spacing>("get_default_row_spacing"); - gtktable.method<&GtkTable_::set_col_spacings>("set_col_spacings"); - gtktable.method<&GtkTable_::get_default_col_spacing>("get_default_col_spacing"); - gtktable.method<&GtkTable_::set_homogeneous>("set_homogeneous"); - gtktable.method<&GtkTable_::get_homogeneous>("get_homogeneous"); - gtktable.method<&GtkTable_::get_size>("get_size"); - gtktable.method<&GtkTable_::__construct>("__construct"); + gtktable.extends(gtkcontainer); + gtktable.method<&GtkTable_::resize>("resize"); + gtktable.method<&GtkTable_::attach>("attach"); + gtktable.method<&GtkTable_::attach_defaults>("attach_defaults"); + gtktable.method<&GtkTable_::set_row_spacing>("set_row_spacing"); + gtktable.method<&GtkTable_::get_row_spacing>("get_row_spacing"); + gtktable.method<&GtkTable_::set_col_spacing>("set_col_spacing"); + gtktable.method<&GtkTable_::get_col_spacing>("get_col_spacing"); + gtktable.method<&GtkTable_::set_row_spacings>("set_row_spacings"); + gtktable.method<&GtkTable_::get_default_row_spacing>("get_default_row_spacing"); + gtktable.method<&GtkTable_::set_col_spacings>("set_col_spacings"); + gtktable.method<&GtkTable_::get_default_col_spacing>("get_default_col_spacing"); + gtktable.method<&GtkTable_::set_homogeneous>("set_homogeneous"); + gtktable.method<&GtkTable_::get_homogeneous>("get_homogeneous"); + gtktable.method<&GtkTable_::get_size>("get_size"); + gtktable.method<&GtkTable_::__construct>("__construct"); // GtkBox Php::Class gtkbox("GtkBox"); @@ -1134,7 +1140,6 @@ extern "C" // GtkBin Php::Class gtkbin("GtkBin"); gtkbin.extends(gtkcontainer); - gtkbin.method<&GtkBin_::test3>("test3"); gtkbin.method<&GtkBin_::get_child>("get_child"); Php::Class gtkviewport("GtkViewport"); @@ -1486,7 +1491,6 @@ extern "C" gtkbutton.method<&GtkButton_::set_always_show_image>("set_always_show_image"); gtkbutton.method<&GtkButton_::get_always_show_image>("get_always_show_image"); gtkbutton.method<&GtkButton_::get_event_window>("get_event_window"); - // GtkColorButton Php::Class gtkcolorbutton("GtkColorButton"); @@ -1569,10 +1573,13 @@ extern "C" // GtkScrolledWindow Php::Class gtkscrolledwindow("GtkScrolledWindow"); - gtkscrolledwindow.extends(gtkcontainer); + gtkscrolledwindow.extends(gtkbin); gtkscrolledwindow.method<&GtkScrolledWindow_::__construct>("__construct"); gtkscrolledwindow.method<&GtkScrolledWindow_::set_policy>("set_policy"); gtkscrolledwindow.method<&GtkScrolledWindow_::set_shadow_type>("set_shadow_type"); + gtkscrolledwindow.method<&GtkScrolledWindow_::set_propagate_natural_height>("set_propagate_natural_height"); + gtkscrolledwindow.method<&GtkScrolledWindow_::set_max_content_height>("set_max_content_height"); + gtkscrolledwindow.method<&GtkScrolledWindow_::set_min_content_height>("set_min_content_height"); // GtkRequisition // Php::Class gtkrequisition("GtkRequisition"); @@ -1750,8 +1757,8 @@ extern "C" // GtkCellRendererCombo Php::Class gtkcellrenderercombo("GtkCellRendererCombo"); - gtkcellrenderercombo.extends(gtkcellrenderertext); - gtkcellrenderercombo.method<&GtkCellRendererCombo_::__construct>("__construct"); + gtkcellrenderercombo.extends(gtkcellrenderertext); + gtkcellrenderercombo.method<&GtkCellRendererCombo_::__construct>("__construct"); // GtkCellRendererToggle Php::Class gtkcellrenderertoggle("GtkCellRendererToggle"); @@ -1836,6 +1843,7 @@ extern "C" gtknotebook.extends(gtkcontainer); gtknotebook.method<&GtkNotebook_::__construct>("__construct"); gtknotebook.method<&GtkNotebook_::append_page>("append_page"); + gtknotebook.method<&GtkNotebook_::prepend_page>("prepend_page"); gtknotebook.method<&GtkNotebook_::insert_page>("insert_page"); gtknotebook.method<&GtkNotebook_::remove_page>("remove_page"); gtknotebook.method<&GtkNotebook_::detach_tab>("detach_tab"); @@ -3774,6 +3782,7 @@ extern "C" extension.add(std::move(gdkeventkey)); extension.add(std::move(gdkeventtype)); extension.add(std::move(gdkeventmask)); + // extension.add(std::move(gdkthreads)); extension.add(std::move(gdkpixbuf)); extension.add(std::move(gdkdrawable)); extension.add(std::move(gdkinterptype)); @@ -4219,7 +4228,7 @@ GValue phpgtk_get_gvalue(Php::Value phpgtk_value, GType type_column) { // Cast int64_t b = (int64_t)phpgtk_value; - //Php::call("var_dump", b); + // Php::call("var_dump", b); g_value_init(>k_value, G_TYPE_LONG); g_value_set_long(>k_value, b); break; diff --git a/src/G/GObject.cpp b/src/G/GObject.cpp index ec3a867..78a9dd8 100644 --- a/src/G/GObject.cpp +++ b/src/G/GObject.cpp @@ -369,4 +369,28 @@ void GObject_::signal_handler_unblock(Php::Parameters ¶meters) gulong handler_id = (gulong) p_handler_id; g_signal_handler_unblock(G_OBJECT(instance), handler_id); +} + +Php::Value GObject_::get_data(Php::Parameters& parameters) +{ + std::string s_key = parameters[0]; + gchar* key = (gchar*)s_key.c_str(); + + gpointer value = g_object_get_data(G_OBJECT(instance), key); + + return (gchar)value; +} + + +void GObject_::set_data(Php::Parameters& parameters) +{ + std::string s_key = parameters[0]; + gchar* key = (gchar*)s_key.c_str(); + + std::string s_value = parameters[1]; + gpointer* value = (gpointer*)s_value.c_str(); + + printf("%p", value); + + g_object_set_data(G_OBJECT(instance), key, value); } \ No newline at end of file diff --git a/src/G/GObject.h b/src/G/GObject.h index adcc0b0..784fe6e 100644 --- a/src/G/GObject.h +++ b/src/G/GObject.h @@ -64,6 +64,8 @@ void signal_handler_block(Php::Parameters ¶meters); void signal_handler_unblock(Php::Parameters ¶meters); + Php::Value get_data(Php::Parameters& parameters); + void set_data(Php::Parameters& parameters); void __clone(); }; From 5afaad5900a3354e28e1443b5610e304ea71e019 Mon Sep 17 00:00:00 2001 From: Sven Pohl Date: Fri, 17 Mar 2023 20:34:34 +0100 Subject: [PATCH 3/6] feat: threads draft --- src/Gdk/GdkThreads.cpp | 8 ++++++++ src/Gdk/GdkThreads.h | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/Gdk/GdkThreads.cpp create mode 100644 src/Gdk/GdkThreads.h diff --git a/src/Gdk/GdkThreads.cpp b/src/Gdk/GdkThreads.cpp new file mode 100644 index 0000000..6fb4613 --- /dev/null +++ b/src/Gdk/GdkThreads.cpp @@ -0,0 +1,8 @@ + +#include "GdkThreads.h" + + +void GdkThreads_::add_idle(Php::Parameters ¶meters) +{ + throw Php::Exception("gdk_threads_add_idle not implemented yet"); +} \ No newline at end of file diff --git a/src/Gdk/GdkThreads.h b/src/Gdk/GdkThreads.h new file mode 100644 index 0000000..4acf12e --- /dev/null +++ b/src/Gdk/GdkThreads.h @@ -0,0 +1,27 @@ + +#ifndef _PHPGTK_GdkTHREADS_H_ +#define _PHPGTK_GdkTHREADS_H_ + +#include +#include +#include + +/** + * + */ +class GdkThreads_ : public Php::Base +{ + /** + * Publics + */ +public: + + /** + * C++ constructor and destructor + */ + GdkThreads_() = default; + + void add_idle(Php::Parameters ¶meters); +}; + +#endif \ No newline at end of file From 71b7746f328816823f10b50144e4946cc0d9e8d8 Mon Sep 17 00:00:00 2001 From: Sven Pohl Date: Fri, 17 Mar 2023 20:34:57 +0100 Subject: [PATCH 4/6] chore: cleanup --- src/Gtk/GtkBin.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Gtk/GtkBin.cpp b/src/Gtk/GtkBin.cpp index 7b1c207..9312244 100644 --- a/src/Gtk/GtkBin.cpp +++ b/src/Gtk/GtkBin.cpp @@ -4,14 +4,9 @@ GtkBin_::GtkBin_() = default; GtkBin_::~GtkBin_() = default; -void GtkBin_::test3() -{ - Php::out << "-- GtkBin_::test 1" << std::endl; -} - Php::Value GtkBin_::get_child() { - gpointer* ret = (gpointer*)gtk_bin_get_child(GTK_BIN(instance)); + gpointer *ret = (gpointer *)gtk_bin_get_child(GTK_BIN(instance)); return cobject_to_phpobject(ret); } \ No newline at end of file From 23f4e2974d81bf110021900dd4f25d566ef8a7ce Mon Sep 17 00:00:00 2001 From: Sven Pohl Date: Fri, 17 Mar 2023 20:35:38 +0100 Subject: [PATCH 5/6] feat: more notebook functions --- src/Gtk/GtkNotebook.cpp | 21 +++++++++++++++++++++ src/Gtk/GtkNotebook.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/Gtk/GtkNotebook.cpp b/src/Gtk/GtkNotebook.cpp index 9b0f790..1530af5 100644 --- a/src/Gtk/GtkNotebook.cpp +++ b/src/Gtk/GtkNotebook.cpp @@ -38,6 +38,27 @@ Php::Value GtkNotebook_::append_page(Php::Parameters ¶meters) return ret; } +Php::Value GtkNotebook_::prepend_page(Php::Parameters& parameters) +{ + GtkWidget* child; + if (parameters.size() > 0) { + Php::Value object_child = parameters[0]; + GtkWidget_* phpgtk_child = (GtkWidget_*)object_child.implementation(); + child = GTK_WIDGET(phpgtk_child->get_instance()); + } + + GtkWidget* tab_label; + if (parameters.size() > 1) { + Php::Value object_tab_label = parameters[1]; + GtkWidget_* phpgtk_tab_label = (GtkWidget_*)object_tab_label.implementation(); + tab_label = GTK_WIDGET(phpgtk_tab_label->get_instance()); + } + + gint ret = gtk_notebook_prepend_page(GTK_NOTEBOOK(instance), child, tab_label); + + return ret; +} + Php::Value GtkNotebook_::insert_page(Php::Parameters ¶meters) { GtkWidget *child; diff --git a/src/Gtk/GtkNotebook.h b/src/Gtk/GtkNotebook.h index 51eefa3..befc6b4 100644 --- a/src/Gtk/GtkNotebook.h +++ b/src/Gtk/GtkNotebook.h @@ -31,6 +31,8 @@ Php::Value append_page(Php::Parameters ¶meters); + Php::Value prepend_page(Php::Parameters& parameters); + Php::Value insert_page(Php::Parameters ¶meters); void remove_page(Php::Parameters ¶meters); From 485b96e8916707b2b56d845945205f189ef166ca Mon Sep 17 00:00:00 2001 From: Sven Pohl Date: Fri, 17 Mar 2023 20:35:55 +0100 Subject: [PATCH 6/6] feat: more scrolled window functions --- src/Gtk/GtkScrolledWindow.cpp | 24 ++++++++++++++++++++++++ src/Gtk/GtkScrolledWindow.h | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/src/Gtk/GtkScrolledWindow.cpp b/src/Gtk/GtkScrolledWindow.cpp index 87bf463..aad90a1 100644 --- a/src/Gtk/GtkScrolledWindow.cpp +++ b/src/Gtk/GtkScrolledWindow.cpp @@ -42,4 +42,28 @@ void GtkScrolledWindow_::set_shadow_type(Php::Parameters ¶meters) gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(instance), type); +} + +void GtkScrolledWindow_::set_propagate_natural_height(Php::Parameters& parameters) +{ + gboolean natural_height = (gboolean)parameters[0]; + + gtk_scrolled_window_set_propagate_natural_height(GTK_SCROLLED_WINDOW(instance), natural_height); + +} + + +void GtkScrolledWindow_::set_max_content_height(Php::Parameters& parameters) +{ + int height = (int)parameters[0]; + + gtk_scrolled_window_set_max_content_height(GTK_SCROLLED_WINDOW(instance), height); +} + + +void GtkScrolledWindow_::set_min_content_height(Php::Parameters& parameters) +{ + int height = (int)parameters[0]; + + gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(instance), height); } \ No newline at end of file diff --git a/src/Gtk/GtkScrolledWindow.h b/src/Gtk/GtkScrolledWindow.h index 88532d9..1f25c26 100644 --- a/src/Gtk/GtkScrolledWindow.h +++ b/src/Gtk/GtkScrolledWindow.h @@ -38,6 +38,12 @@ void set_policy(Php::Parameters ¶meters); void set_shadow_type(Php::Parameters ¶meters); + + void set_propagate_natural_height(Php::Parameters& parameters); + + void set_max_content_height(Php::Parameters& parameters); + + void set_min_content_height(Php::Parameters& parameters); }; #endif \ No newline at end of file