Skip to content

Commit

Permalink
Merge pull request #65 from APS-Services/feat/threads
Browse files Browse the repository at this point in the history
Added method GObject_::get_data
Added method GObject_::set_data
Added class GdkThreads
Added method GtkNotebook_::prepend_page
Added method GtkScrolledWindow_::set_propagate_natural_height
Added method GtkScrolledWindow_::set_max_content_height
Added method GtkScrolledWindow_::set_min_content_height
  • Loading branch information
scorninpc authored Mar 24, 2023
2 parents a0dc2ec + 485b96e commit 8aad727
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 32 deletions.
61 changes: 35 additions & 26 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -511,7 +513,7 @@ extern "C"
// gdkevent.property("type", 0);

// GdkEventMask
Php::Class<Php::Base> gdkeventmask("GdkEventMask");
Php::Class<Php::Base> 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);
Expand All @@ -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<Php::GdkThreads_> gdkthreads("GdkThreads");
// gdkthreads.method<&GdkThreads_::add_idle>("add_idle");

// GdkScreen
Php::Class<GdkScreen_> gdkscreen("GdkScreen");
// gdkevent.method<&GdkEvent_::__construct>("__construct");
Expand All @@ -563,7 +569,7 @@ extern "C"
// GdkEventKey
Php::Class<GdkEventKey_> gdkeventkey("GdkEventKey");

// GdkEventKey
// GdkEventType
Php::Class<Php::Base> gdkeventtype("GdkEventType");
gdkeventtype.constant("NOTHING", (int)GDK_NOTHING);
gdkeventtype.constant("DELETE", (int)GDK_DELETE);
Expand Down Expand Up @@ -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<Php::Base> gdkinterptype("GdkInterpType");
gdkinterptype.constant("NEAREST", (int)GDK_INTERP_NEAREST);
gdkinterptype.constant("TILES", (int)GDK_INTERP_TILES);
Expand Down Expand Up @@ -1054,22 +1060,22 @@ extern "C"
gtkcontainer.method<&GtkContainer_::class_handle_border_width>("class_handle_border_width");

Php::Class<GtkTable_> 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("GtkBox");
Expand Down Expand Up @@ -1134,7 +1140,6 @@ extern "C"
// GtkBin
Php::Class<GtkBin_> gtkbin("GtkBin");
gtkbin.extends(gtkcontainer);
gtkbin.method<&GtkBin_::test3>("test3");
gtkbin.method<&GtkBin_::get_child>("get_child");

Php::Class<GtkViewport_> gtkviewport("GtkViewport");
Expand Down Expand Up @@ -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("GtkColorButton");
Expand Down Expand Up @@ -1569,10 +1573,13 @@ extern "C"

// GtkScrolledWindow
Php::Class<GtkScrolledWindow_> 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("GtkRequisition");
Expand Down Expand Up @@ -1750,8 +1757,8 @@ extern "C"

// GtkCellRendererCombo
Php::Class<GtkCellRendererCombo_> gtkcellrenderercombo("GtkCellRendererCombo");
gtkcellrenderercombo.extends(gtkcellrenderertext);
gtkcellrenderercombo.method<&GtkCellRendererCombo_::__construct>("__construct");
gtkcellrenderercombo.extends(gtkcellrenderertext);
gtkcellrenderercombo.method<&GtkCellRendererCombo_::__construct>("__construct");

// GtkCellRendererToggle
Php::Class<GtkCellRendererToggle_> gtkcellrenderertoggle("GtkCellRendererToggle");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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(&gtk_value, G_TYPE_LONG);
g_value_set_long(&gtk_value, b);
break;
Expand Down
24 changes: 24 additions & 0 deletions src/G/GObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,28 @@ void GObject_::signal_handler_unblock(Php::Parameters &parameters)
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);
}
2 changes: 2 additions & 0 deletions src/G/GObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
void signal_handler_block(Php::Parameters &parameters);
void signal_handler_unblock(Php::Parameters &parameters);

Php::Value get_data(Php::Parameters& parameters);
void set_data(Php::Parameters& parameters);

void __clone();
};
Expand Down
8 changes: 8 additions & 0 deletions src/Gdk/GdkThreads.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include "GdkThreads.h"


void GdkThreads_::add_idle(Php::Parameters &parameters)
{
throw Php::Exception("gdk_threads_add_idle not implemented yet");
}
27 changes: 27 additions & 0 deletions src/Gdk/GdkThreads.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#ifndef _PHPGTK_GdkTHREADS_H_
#define _PHPGTK_GdkTHREADS_H_

#include <phpcpp.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

/**
*
*/
class GdkThreads_ : public Php::Base
{
/**
* Publics
*/
public:

/**
* C++ constructor and destructor
*/
GdkThreads_() = default;

void add_idle(Php::Parameters &parameters);
};

#endif
7 changes: 1 addition & 6 deletions src/Gtk/GtkBin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
21 changes: 21 additions & 0 deletions src/Gtk/GtkNotebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ Php::Value GtkNotebook_::append_page(Php::Parameters &parameters)
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 &parameters)
{
GtkWidget *child;
Expand Down
2 changes: 2 additions & 0 deletions src/Gtk/GtkNotebook.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

Php::Value append_page(Php::Parameters &parameters);

Php::Value prepend_page(Php::Parameters& parameters);

Php::Value insert_page(Php::Parameters &parameters);

void remove_page(Php::Parameters &parameters);
Expand Down
24 changes: 24 additions & 0 deletions src/Gtk/GtkScrolledWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,28 @@ void GtkScrolledWindow_::set_shadow_type(Php::Parameters &parameters)

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);
}
6 changes: 6 additions & 0 deletions src/Gtk/GtkScrolledWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
void set_policy(Php::Parameters &parameters);

void set_shadow_type(Php::Parameters &parameters);

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

0 comments on commit 8aad727

Please sign in to comment.