scorninpc / php-gtk3

GTK3 extension for PHP
https://andor.com.br/
GNU Lesser General Public License v3.0
118 stars 13 forks source link

change cursor #71

Closed subabrain closed 11 months ago

subabrain commented 1 year ago

Hello,

i have a simple question :P

i tried to make a new cursor with the following code:

    $this->window = $this->builder->get_object("window");

    ...

    $ctype = new GdkCursorType("GDK_X_CURSOR");
    $cursor = new GdkCursor($ctype);
    $this->window->set_cursor($cursor);

but it crashes - maybe someone could help here - thx a lot!

Edit: but i cant find this class in the phpgtk3 sourcecode ...

Greets Robert

scorninpc commented 1 year ago

Hey Robert, how is going?

gtk_widget_set_cursor is a Gtk4 method. For Gtk3 we use gdk_window_set_cursor. BTW is not implemented.

I'll implement it for you tomorow ok?

scorninpc commented 1 year ago

Hello Robert,

I've implemented the cursor change, look:

image

<?php

Gtk::init();

// create the window
$window = new GtkWindow();
$window->set_size_request(300, 200);
$window->set_name("mywindow");

// create a box
$vbox = new \GtkBox(GtkOrientation::VERTICAL);
$vbox->pack_start($a = new GtkLabel("My Window"), TRUE, TRUE);
$a->set_name("button1");

// connect to destroy
$window->connect("destroy", function($window) {
    Gtk::main_quit();
});

// add widget
$window->add($vbox);

// run
$window->show_all();

// change cursor (the window exists only after show)
$cursor = new GdkCursor(GdkCursorType::X_CURSOR);
$window->get_window()->set_cursor($cursor);

// loop
Gtk::main();

If you can, pull the repository and compile. If no, i'll create a new release in the next week

Thanks

subabrain commented 1 year ago

Hello Bruno,

im fine - thx! I hope your doing well?

Thanks a lot for your Implementation and Help!

I will give a try :)

Thx and Greets! Robert

subabrain commented 1 year ago

Ah by the way (off topic) but i will try to modify my RPGET for also encrypt .ui / glade files - i will inform you if its ready :)

Greets Robert