├── out
└── .gitignore
├── .gitignore
├── resources
├── functions
│ ├── gdk
│ │ └── screen.h
│ ├── gtk
│ │ ├── button.h
│ │ ├── text_view.h
│ │ ├── container.h
│ │ ├── text_buffer.h
│ │ ├── main.h
│ │ ├── application.h
│ │ ├── grid.h
│ │ ├── box.h
│ │ ├── style.h
│ │ ├── widget.h
│ │ ├── label.h
│ │ ├── builder.h
│ │ ├── entry.h
│ │ ├── css_provider.h
│ │ └── window.h
│ └── g
│ │ ├── main.h
│ │ ├── application.h
│ │ ├── signal.h
│ │ └── object.h
├── type
│ └── base.h
├── gtk.h
├── GApplication.h
├── GObjectSignals.h
└── GtkWidget.h
├── .phplint.yml
├── src
├── Enum
│ ├── BoxEnum.php
│ └── WindowEnum.php
├── Gtk
│ ├── Button.php
│ ├── Container.php
│ ├── CssProvider.php
│ ├── Widget.php
│ ├── Signal.php
│ ├── Label.php
│ ├── Grid.php
│ ├── Box.php
│ ├── Window.php
│ └── Entry.php
├── Library.php
├── Gtk.php
└── Support
│ └── ProxyTrait.php
├── example
├── c
│ ├── custom-widget
│ │ ├── res
│ │ │ ├── resources.xml
│ │ │ ├── main.glade
│ │ │ └── GtkListBoxItem.glade
│ │ ├── Makefile
│ │ ├── GtkListBoxItem.h
│ │ ├── GtkListBoxItem.c
│ │ ├── custom_widget.c
│ │ └── resources.c
│ ├── cairo
│ │ ├── Makefile
│ │ ├── main.glade
│ │ └── main.c
│ ├── style
│ │ ├── Makefile
│ │ ├── style.css
│ │ ├── main.c
│ │ └── main.glade
│ ├── timer
│ │ ├── Makefile
│ │ └── main.c
│ ├── image-viewer
│ │ ├── Makefile
│ │ └── image_viewer.c
│ └── hello-world
│ │ ├── Makefile
│ │ ├── hello_world_old.c
│ │ └── hello_world.c
└── php
│ ├── main
│ └── main.php
│ ├── callback_function
│ └── main.php
│ ├── container_widget_layout
│ └── main.php
│ ├── style
│ ├── style.css
│ ├── main.php
│ └── main.glade
│ └── authorization
│ └── main.php
├── phpcs.xml
├── composer.json
├── README.md
└── psalm.xml
/out/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | composer.lock
2 | vendor
3 | .idea
4 | var
--------------------------------------------------------------------------------
/resources/functions/gdk/screen.h:
--------------------------------------------------------------------------------
1 | extern GdkScreen* gdk_screen_get_default(void);
--------------------------------------------------------------------------------
/resources/functions/gtk/button.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget* gtk_button_new_with_label(const gchar *label);
2 |
--------------------------------------------------------------------------------
/resources/functions/g/main.h:
--------------------------------------------------------------------------------
1 | extern guint g_timeout_add (guint interval, GSourceFunc function, gpointer data);
--------------------------------------------------------------------------------
/resources/functions/gtk/text_view.h:
--------------------------------------------------------------------------------
1 | extern GtkTextBuffer* gtk_text_view_get_buffer(GtkTextView *text_view);
2 |
--------------------------------------------------------------------------------
/resources/functions/gtk/container.h:
--------------------------------------------------------------------------------
1 | extern void gtk_container_add (GtkContainer *container, GtkWidget *widget);
2 |
--------------------------------------------------------------------------------
/resources/functions/g/application.h:
--------------------------------------------------------------------------------
1 | extern int g_application_run (GApplication *application, int argc, char **argv);
2 |
--------------------------------------------------------------------------------
/resources/functions/gtk/text_buffer.h:
--------------------------------------------------------------------------------
1 | extern void gtk_text_buffer_set_text(GtkTextBuffer *buffer,const gchar *text,gint len);
2 |
--------------------------------------------------------------------------------
/.phplint.yml:
--------------------------------------------------------------------------------
1 | path: ./
2 | jobs: 10
3 | cache: var/cache/.phplint.json
4 | extensions:
5 | - php
6 | exclude:
7 | - vendor
8 | - var
--------------------------------------------------------------------------------
/resources/functions/gtk/main.h:
--------------------------------------------------------------------------------
1 | extern void gtk_init(int *, char **[]);
2 | extern void gtk_main();
3 | extern void gtk_main_quit();
4 |
--------------------------------------------------------------------------------
/resources/functions/gtk/application.h:
--------------------------------------------------------------------------------
1 | extern GtkApplication* gtk_application_new(const gchar *application_id, GApplicationFlags flags);
2 |
--------------------------------------------------------------------------------
/resources/functions/gtk/grid.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget *gtk_grid_new (void);
2 | extern void gtk_grid_attach(GtkGrid *grid, GtkWidget *child, gint left, gint top, gint width, gint height);
3 |
--------------------------------------------------------------------------------
/resources/functions/g/signal.h:
--------------------------------------------------------------------------------
1 | extern gulong g_signal_connect_data(gpointer instance, const gchar *detailed_signal, GCallback c_handler, void* data, GCallback destroy_data, int connect_flags);
--------------------------------------------------------------------------------
/src/Enum/BoxEnum.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | GtkListBoxItem.glade
4 |
5 |
6 |
--------------------------------------------------------------------------------
/resources/functions/gtk/box.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget* gtk_box_new(GtkOrientation orientation, gint spacing);
2 | extern void gtk_box_pack_start(GtkBox *box, GtkWidget *child, gboolean expand, gboolean fill, guint padding);
--------------------------------------------------------------------------------
/resources/functions/g/object.h:
--------------------------------------------------------------------------------
1 | extern void g_object_set(gpointer object, const gchar *first_property_name, ...);
2 | extern gpointer g_object_ref_sink(gpointer object);
3 | extern void g_object_unref (gpointer object);
4 |
--------------------------------------------------------------------------------
/resources/functions/gtk/style.h:
--------------------------------------------------------------------------------
1 | extern void gtk_style_context_add_provider_for_screen(GdkScreen *screen,GtkStyleProvider *provider,guint priority);
2 | extern void gtk_style_context_add_class(GtkStyleContext *context,const gchar *class_name);
3 |
--------------------------------------------------------------------------------
/resources/functions/gtk/widget.h:
--------------------------------------------------------------------------------
1 | extern void gtk_widget_show_all(GtkWidget *);
2 | extern void gtk_widget_set_size_request(GtkWidget *widget, gint width, gint height);
3 | extern GtkStyleContext* gtk_widget_get_style_context(GtkWidget *widget);
4 |
--------------------------------------------------------------------------------
/resources/functions/gtk/label.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget * gtk_label_new (const gchar *str);
2 | extern void gtk_label_set_text (GtkLabel *label,const gchar *str);
3 | extern void gtk_label_set_width_chars(GtkLabel *label, gint n_chars);
4 | extern void gtk_label_set_markup(GtkLabel *label, const gchar *str);
5 |
--------------------------------------------------------------------------------
/example/php/main/main.php:
--------------------------------------------------------------------------------
1 | init();
11 |
12 | $window = new Window(\Gtk3\Enum\WindowEnum::popUp());
13 | $window->show();
14 |
15 | $gtk->main();
16 |
17 | return 0;
--------------------------------------------------------------------------------
/example/c/cairo/Makefile:
--------------------------------------------------------------------------------
1 | CC := clang
2 |
3 | CFLAGS = `pkg-config --cflags gtk+-3.0`
4 | LIBS = `pkg-config --libs gtk+-3.0`
5 |
6 | src = main.c
7 | obj = cairo_paint
8 | targets = cairo_paint
9 |
10 | all: $(targets)
11 |
12 | cairo_paint: $(src)
13 | $(CC) -o $(obj) $(src) $(CFLAGS) $(LIBS)
14 |
15 | clean:
16 | rm -f $(targets) *.o *.*~
17 |
--------------------------------------------------------------------------------
/example/c/style/Makefile:
--------------------------------------------------------------------------------
1 | CC := clang
2 |
3 | CFLAGS = `pkg-config --cflags gtk+-3.0` -Wall
4 | LIBS = `pkg-config --libs gtk+-3.0`
5 |
6 | src = main.c
7 | obj = style_sample
8 | targets = style_sample
9 |
10 | all: $(targets)
11 |
12 | style_sample: $(src)
13 | $(CC) -o $(obj) $(src) $(CFLAGS) $(LIBS)
14 |
15 | clean:
16 | rm -f $(targets) *.o *.*~
17 |
--------------------------------------------------------------------------------
/example/c/timer/Makefile:
--------------------------------------------------------------------------------
1 | CC := clang
2 |
3 | CFLAGS = `pkg-config --cflags gtk+-3.0` -Wall
4 | LIBS = `pkg-config --libs gtk+-3.0`
5 |
6 | src = main.c
7 | obj = timer_sample
8 | targets = timer_sample
9 |
10 | all: $(targets)
11 |
12 | timer_sample: $(src)
13 | $(CC) -o $(obj) $(src) $(CFLAGS) $(LIBS)
14 |
15 | clean:
16 | rm -f $(targets) *.o *.*~
17 |
--------------------------------------------------------------------------------
/resources/functions/gtk/builder.h:
--------------------------------------------------------------------------------
1 | extern GtkBuilder* gtk_builder_new(void);
2 | extern guint gtk_builder_add_from_file(GtkBuilder *builder, const gchar *filename, GError **error);
3 | extern guint gtk_builder_add_from_file (GtkBuilder *builder,const gchar *filename,GError **error);
4 | extern GObject* gtk_builder_get_object(GtkBuilder *builder, const gchar *name);
5 |
--------------------------------------------------------------------------------
/example/c/image-viewer/Makefile:
--------------------------------------------------------------------------------
1 | CC := clang
2 |
3 | CFLAGS = `pkg-config --cflags gtk+-3.0`
4 | LIBS = `pkg-config --libs gtk+-3.0`
5 |
6 | targets = image_viewer
7 | obj =image_viewer
8 | src = image_viewer.c
9 |
10 | all: $(targets)
11 |
12 | image_viewer: $(src)
13 | $(CC) -o $(obj) $(src) $(CFLAGS) $(LIBS)
14 |
15 | clean:
16 | rm -f $(targets) *.o *.*~
17 |
--------------------------------------------------------------------------------
/example/c/custom-widget/Makefile:
--------------------------------------------------------------------------------
1 | CC := clang
2 |
3 | CFLAGS = `pkg-config --cflags gtk+-3.0`
4 | LIBS = `pkg-config --libs gtk+-3.0`
5 |
6 | targets = custom_widget
7 | obj = custom_widget
8 | src = custom_widget.c GtkListBoxItem.c resources.c
9 |
10 | all: $(targets)
11 |
12 | custom_widget: $(src)
13 | $(CC) -o $(obj) $(src) $(CFLAGS) $(LIBS)
14 |
15 | clean:
16 | rm -f $(targets) *.o *.*~
17 |
--------------------------------------------------------------------------------
/resources/functions/gtk/entry.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget* gtk_entry_new(void);
2 | extern void gtk_entry_set_max_length(GtkEntry *entry, gint max);
3 | extern const gchar* gtk_entry_get_text(GtkEntry *entry);
4 | extern void gtk_entry_set_text(GtkEntry *entry, const gchar *text);
5 | extern void gtk_entry_set_visibility(GtkEntry *entry, gboolean visible);
6 | extern void gtk_entry_set_invisible_char(GtkEntry *entry, gunichar ch);
--------------------------------------------------------------------------------
/src/Gtk/Button.php:
--------------------------------------------------------------------------------
1 | widget = Gtk::getInstance()->gtk_button_new_with_label($text);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/c/hello-world/Makefile:
--------------------------------------------------------------------------------
1 | CC := clang
2 |
3 | CFLAGS = `pkg-config --cflags gtk+-3.0`
4 | LIBS = `pkg-config --libs gtk+-3.0`
5 |
6 | targets = hello_world_old hello_world
7 |
8 | all: $(targets)
9 |
10 | hello_world_old: hello_world_old.c
11 | $(CC) -o hello_world_old hello_world_old.c $(CFLAGS) $(LIBS)
12 |
13 | hello_world: hello_world.c
14 | $(CC) -o hello_world hello_world.c $(CFLAGS) $(LIBS)
15 |
16 | clean:
17 | rm -f $(targets) *.o
18 |
--------------------------------------------------------------------------------
/phpcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | src
16 |
--------------------------------------------------------------------------------
/resources/type/base.h:
--------------------------------------------------------------------------------
1 | typedef char gchar;
2 | typedef int gint;
3 | typedef int guint;
4 | typedef bool gboolean;
5 | typedef unsigned char guchar;
6 | typedef long glong;
7 | typedef unsigned long gulong;
8 | typedef float gfloat;
9 | typedef double gdouble;
10 | typedef int8_t gint8;
11 | typedef uint8_t guint8;
12 | typedef int16_t gint16;
13 | typedef uint16_t guint16;
14 | typedef int32_t gint32;
15 | typedef uint32_t guint32;
16 | typedef void* gpointer;
17 | typedef guint32 gunichar;
18 | typedef signed long gssize;
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "kmaestro/gtk",
3 | "license": "MIT",
4 | "authors": [
5 | {
6 | "name": "Dima",
7 | "email": "polishuk1003@gmail.com"
8 | }
9 | ],
10 | "require": {
11 | "php": "^8.1",
12 | "ext-FFI": "^8.1",
13 | "serafim/ffi-loader": "^1.0"
14 | },
15 | "autoload": {
16 | "psr-4": {
17 | "Gtk3\\": "src"
18 | }
19 | },
20 | "require-dev": {
21 | },
22 | "scripts": {
23 | "lint": "phplint",
24 | "cs-check": "phpcs",
25 | "cs-fix": "phpcbf",
26 | "psalm": "psalm"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | The project is moved to https://github.com/PHP-GTK/gtk
2 |
3 | ### Requirement
4 |
5 | - php (8.1)
6 | - ext-FFI
7 | - gtk-3
8 |
9 | **Installation**
10 |
11 | ```bash
12 | composer require kmaestro/gtk
13 | ```
14 |
15 | **Linux**
16 | ```bash
17 | sudo apt-get install libgtk-3-dev
18 | ```
19 |
20 | **Example:**
21 |
22 | ```php
23 | require __DIR__ . '/vendor/autoload.php';
24 |
25 | use Gtk3\Gtk;
26 | use Gtk3\Gtk\Window;
27 | use Gtk3\Enum\WindowEnum;
28 |
29 | $gtk = Gtk::getInstance();
30 |
31 | $gtk->init();
32 |
33 | $window = new Window(WindowEnum::topLevel);
34 | $window->widget()->show();
35 |
36 | $gtk->main();
37 |
38 | return 0;
39 | ```
40 |
--------------------------------------------------------------------------------
/src/Gtk/Container.php:
--------------------------------------------------------------------------------
1 | info->ffi->gtk_container_add(
24 | Gtk::getInstance()->cast("GtkContainer *", $window->window),
25 | Gtk::getInstance()->cast("GtkWidget *", $widget->widget)
26 | );
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/resources/functions/gtk/css_provider.h:
--------------------------------------------------------------------------------
1 | extern gboolean gtk_css_provider_load_from_path(GtkCssProvider *css_provider, const gchar *path, GError **error);
2 | extern GtkCssProvider* gtk_css_provider_new(void);
3 | extern GtkCssProvider* gtk_css_provider_get_named(const gchar *name,const gchar *variant);
4 | extern gboolean gtk_css_provider_load_from_data(GtkCssProvider *css_provider, const gchar *data, gssize length, GError **error);
5 | extern gboolean gtk_css_provider_load_from_file(GtkCssProvider *css_provider, GFile *file, GError **error);
6 | extern void gtk_css_provider_load_from_resource(GtkCssProvider *css_provider, const gchar *resource_path);
7 | extern char* gtk_css_provider_to_string(GtkCssProvider *provider);
--------------------------------------------------------------------------------
/example/c/hello-world/hello_world_old.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main (int argc, char** argv)
4 | {
5 | GtkWidget *window;
6 | GtkWidget *label;
7 |
8 | gtk_init (&argc, &argv);
9 |
10 | window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
11 |
12 | gtk_window_set_title (GTK_WINDOW (window), "Hello world");
13 |
14 | g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
15 |
16 | gtk_widget_set_size_request (window, 640, 480);
17 |
18 | gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
19 |
20 | label = gtk_label_new ("Hello world");
21 | gtk_container_add (GTK_CONTAINER (window), label);
22 |
23 | gtk_widget_show_all (window);
24 |
25 | gtk_main ();
26 |
27 | return 0;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/src/Gtk/CssProvider.php:
--------------------------------------------------------------------------------
1 | provider = Gtk::getInstance()->gtk_css_provider_new();
15 | }
16 |
17 | /**
18 | * @param string $path
19 | *
20 | * @return mixed
21 | * @throws \Exception
22 | */
23 | public function loadFromPath(string $path)
24 | {
25 | $error = Gtk::getInstance()->new('GError*');
26 | return Gtk::getInstance()->gtk_css_provider_load_from_path(
27 | Gtk::getInstance()->cast('GtkCssProvider*', $this->provider),
28 | $path,
29 | Gtk::addr($error)
30 | );
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Gtk/Widget.php:
--------------------------------------------------------------------------------
1 | $functionName(Gtk::getInstance()->cast($cast, $this->widget), ...$arguments);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Gtk/Signal.php:
--------------------------------------------------------------------------------
1 | g_signal_connect_data(
29 | $instance->widget,
30 | $detailed_signal,
31 | $c_handler,
32 | $data,
33 | null,
34 | null
35 | );
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/example/php/callback_function/main.php:
--------------------------------------------------------------------------------
1 | cast('char *',$data)), ++$count);
19 | }
20 |
21 | $gtk->init();
22 | $window = new Window();
23 | $button = new Button("Hello World!");
24 | $signal = new Signal();
25 |
26 | $container = new Container();
27 | $container->add($window, $button);
28 |
29 | $signal->connect($button, 'clicked', 'button_clicked', 'button 1');
30 |
31 | $button->show();
32 | $window->show();
33 |
34 | $gtk->main();
--------------------------------------------------------------------------------
/resources/functions/gtk/window.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget * gtk_window_new (GtkWindowType type);
2 | extern void gtk_window_set_default_size (GtkWindow *window,gint width,gint height);
3 | extern void gtk_widget_show (GtkWidget *);
4 | extern void gtk_window_set_title (GtkWindow *window, gchar *title);
5 | extern void gtk_window_get_size (GtkWindow *window, gint *width, gint *height);
6 | extern void gtk_window_fullscreen(GtkWindow *window);
7 | extern void gtk_window_unfullscreen (GtkWindow *window);
8 | extern void gtk_window_set_position (GtkWindow *window, GtkWindowPosition position);
9 | extern void gtk_window_resize(GtkWindow *window, gint width, gint height);
10 | extern void gtk_window_set_resizable(GtkWindow *window, gboolean resizable);
11 | extern void gtk_window_present(GtkWindow *window);
12 | extern void gtk_window_maximize(GtkWindow *window);
13 | extern void gtk_window_unmaximize(GtkWindow *window);
--------------------------------------------------------------------------------
/psalm.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/c/custom-widget/GtkListBoxItem.h:
--------------------------------------------------------------------------------
1 | #ifndef __GTK_LISTBOX_ITEM_H__
2 | #define __GTK_LISTBOX_ITEM_H__
3 |
4 | #include
5 |
6 | #define GTK_TYPE_LISTBOX_ITEM\
7 | (gtk_listbox_item_get_type())
8 | #define GTK_LISTBOX_ITEM(listbox_row)\
9 | (G_TYPE_CHECK_INSTANCE_CAST((listbox_row), GTK_TYPE_LISTBOX_ITEM, GtkListBoxItem))
10 | #define GTK_LISTBOX_ITEM_CLASS(klass)\
11 | (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_LISTBOX_ITEM, GtkListBoxItemClass))
12 |
13 | GType gtk_listbox_item_get_type (void) G_GNUC_CONST;
14 |
15 | typedef struct {
16 | GtkListBoxRowClass parent_class;
17 | } GtkListBoxItemClass;
18 |
19 | typedef struct {
20 | GtkLabel *label_no;
21 | GtkLabel *label_body;
22 | } GtkListBoxItemPrivate;
23 |
24 | typedef struct {
25 | GtkListBoxRow parent;
26 | GtkListBoxItemPrivate *priv;
27 | } GtkListBoxItem;
28 |
29 | extern GtkListBoxItem *gtk_listbox_item_new (gint index, const gchar *str);
30 |
31 | #endif // __GTK_LISTBOX_ITEM_H__
32 |
--------------------------------------------------------------------------------
/src/Gtk/Label.php:
--------------------------------------------------------------------------------
1 | widget = Gtk::getInstance()->gtk_label_new($text);
25 | }
26 |
27 | public function __call(string $name, array $arguments)
28 | {
29 | $functionName = 'gtk_label_' . strtolower(preg_replace('~([A-Z])~', '_$1', $name));
30 | $cast = "GtkLabel *";
31 |
32 | try {
33 | return Gtk::getInstance()->$functionName(Gtk::getInstance()->cast($cast, $this->widget), ...$arguments);
34 | } catch (\Throwable) {
35 | return parent::__call($name, $arguments);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Gtk/Grid.php:
--------------------------------------------------------------------------------
1 | widget = Gtk::getInstance()->gtk_grid_new();
22 | }
23 |
24 | /**
25 | * @param Widget $widget
26 | * @param int $left
27 | * @param int $top
28 | * @param int $width
29 | * @param int $height
30 | *
31 | * @throws \Exception
32 | */
33 | public function attach(Widget $widget, int $left, int $top, int $width, int $height): void
34 | {
35 | Gtk::getInstance()->gtk_grid_attach(
36 | Gtk::getInstance()->cast('GtkGrid *', $this->widget),
37 | Gtk::getInstance()->cast('GtkWidget *', $widget->widget),
38 | $left,
39 | $top,
40 | $width,
41 | $height
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/example/c/hello-world/hello_world.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | static void cb_application_activate (GtkApplication* app, gpointer user_data)
4 | {
5 | GtkWidget *window;
6 | GtkWidget *label;
7 |
8 | window = gtk_application_window_new (app);
9 |
10 | gtk_window_set_title (GTK_WINDOW (window), "Hello world");
11 |
12 | gtk_widget_set_size_request (window, 640, 480);
13 |
14 | gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
15 |
16 | label = gtk_label_new ("Hello world");
17 | gtk_container_add (GTK_CONTAINER (window), label);
18 |
19 | gtk_widget_show_all (window);
20 | }
21 |
22 | int main (int argc, char **argv)
23 | {
24 | GtkApplication *app;
25 | int status;
26 |
27 | app = gtk_application_new ("org.gtk3.helloworld", G_APPLICATION_FLAGS_NONE);
28 |
29 | g_signal_connect (app, "activate", G_CALLBACK (cb_application_activate), NULL);
30 |
31 | status = g_application_run (G_APPLICATION (app), argc, argv);
32 |
33 | g_object_unref (app);
34 |
35 | return status;
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/src/Gtk/Box.php:
--------------------------------------------------------------------------------
1 | widget = Gtk::getInstance()->gtk_box_new($orientation->value, $spacing);
26 | }
27 |
28 | /**
29 | * @param Widget $child
30 | * @param bool $expand
31 | * @param bool $fill
32 | * @param int $padding
33 | *
34 | * @throws \Exception
35 | */
36 | public function packStart(Widget $child, bool $expand, bool $fill, int $padding): void
37 | {
38 | Gtk::getInstance()->gtk_box_pack_start(
39 | Gtk::getInstance()->cast('GtkBox*', $this->widget),
40 | $child->widget,
41 | $expand,
42 | $fill,
43 | $padding
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/example/c/cairo/main.glade:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Library.php:
--------------------------------------------------------------------------------
1 | isLinux():
52 | return self::LIBRARY_LINUX;
53 | default:
54 | return null;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/example/php/container_widget_layout/main.php:
--------------------------------------------------------------------------------
1 | init();
13 |
14 | function my_close_app()
15 | {
16 | Gtk::getInstance()->mainQuit();
17 | }
18 |
19 | function my_delete_event()
20 | {
21 | print_r("In delete_event\n");
22 | return true;
23 | }
24 |
25 | $window = new Window();
26 | $window->setTitle('The Window Title');
27 | $window->setPosition(1);
28 | $window->setDefaultSize( 300, 200);
29 |
30 | $window->connect('destroy', 'my_close_app', null);
31 | $window->connect( 'delete_event', 'my_delete_event', null);
32 |
33 | $label1 = new Label('Label 1');
34 | $label1->setText('sdf');
35 | $label1->setWidthChars(1);
36 | $label2 = new Label('Label 2');
37 | $label3 = new Label('Label 3');
38 |
39 | $hbox = new Box(\Gtk3\Enum\BoxEnum::horizontal, 5);
40 | $vbox = new Box(\Gtk3\Enum\BoxEnum::vertical, 10);
41 |
42 | $vbox->packStart($label1, true, false, 5);
43 | $vbox->packStart($label2, true, false, 5);
44 |
45 | $hbox->packStart($vbox, true, false, 5);
46 | $hbox->packStart($label3, true, false, 5);
47 |
48 | $container = new Container();
49 | $container->add($window, $hbox);
50 |
51 | $window->widget()->showAll();
52 |
53 |
54 | $gtk->main();
--------------------------------------------------------------------------------
/example/c/custom-widget/res/main.glade:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 480
6 | 240
7 | False
8 | GTKListBoxサンプル
9 | center
10 |
11 |
12 |
13 |
14 |
15 | True
16 | True
17 | never
18 | in
19 |
20 |
21 | True
22 | False
23 |
24 |
25 | True
26 | False
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/example/c/style/style.css:
--------------------------------------------------------------------------------
1 | /* GtkLabel */
2 | label {
3 | color: red;
4 | background-color: transparent;
5 | font: 20px Sans;
6 | }
7 |
8 | /* GtkSpinner - spinner */
9 | spinner {
10 | color: blue;
11 | background-color: gray;
12 | }
13 |
14 | /* GtkButton */
15 | .text-button {
16 | border-image: none;
17 | border-style: solid;
18 | border-width: 1px;
19 | border-radius: 10px;
20 | border-color: grey;
21 | background-image: none;
22 | background-color: rgb(211, 211, 211);
23 | }
24 |
25 | /* GtkButton GtkLabe */
26 | .text-button label {
27 | color: green;
28 | }
29 |
30 | /* GtkButton */
31 | .button-ligt-gray {
32 | border-image: none;
33 | border-style: solid;
34 | border-width: 4px;
35 | border-radius: 20px;
36 | border-color: black;
37 | background-image: none;
38 | background-color: aqua;
39 | }
40 |
41 | button:hover:active {
42 | border-image: none;
43 | border-style: solid;
44 | border-width: 1px;
45 | border-radius: 10px;
46 | border-color: grey;
47 | background-image: none;
48 | background-color: orange;
49 | color: cyan;
50 | }
51 |
52 | /* GtkToggleButton */
53 | .toggle:checked {
54 | background-color:red;
55 | }
56 |
57 | /* GtkSwitch */
58 | switch:checked {
59 | background-color:burlywood;
60 | }
61 |
62 | /* GtkTextView */
63 | textview.view text {
64 | color: royalblue;
65 | }
66 |
--------------------------------------------------------------------------------
/example/php/style/style.css:
--------------------------------------------------------------------------------
1 | /* GtkLabel */
2 | label {
3 | color: red;
4 | background-color: transparent;
5 | font: 20px Sans;
6 | }
7 |
8 | /* GtkSpinner - spinner */
9 | spinner {
10 | color: blue;
11 | background-color: gray;
12 | }
13 |
14 | /* GtkButton */
15 | .text-button {
16 | border-image: none;
17 | border-style: solid;
18 | border-width: 1px;
19 | border-radius: 10px;
20 | border-color: grey;
21 | background-image: none;
22 | background-color: rgb(211, 211, 211);
23 | }
24 |
25 | /* GtkButton GtkLabe */
26 | .text-button label {
27 | color: green;
28 | }
29 |
30 | /* GtkButton */
31 | .button-ligt-gray {
32 | border-image: none;
33 | border-style: solid;
34 | border-width: 4px;
35 | border-radius: 20px;
36 | border-color: black;
37 | background-image: none;
38 | background-color: aqua;
39 | }
40 |
41 | button:hover:active {
42 | border-image: none;
43 | border-style: solid;
44 | border-width: 1px;
45 | border-radius: 10px;
46 | border-color: grey;
47 | background-image: none;
48 | background-color: orange;
49 | color: cyan;
50 | }
51 |
52 | /* GtkToggleButton */
53 | .toggle:checked {
54 | background-color:red;
55 | }
56 |
57 | /* GtkSwitch */
58 | switch:checked {
59 | background-color:burlywood;
60 | }
61 |
62 | /* GtkTextView */
63 | textview.view text {
64 | color: royalblue;
65 | }
66 |
--------------------------------------------------------------------------------
/example/c/custom-widget/GtkListBoxItem.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "GtkListBoxItem.h"
3 |
4 | /**
5 | *[refs]: https://developer.gnome.org/gtk3/stable/GtkWidget.html
6 | * Building composite widgets from template XML
7 | */
8 | G_DEFINE_TYPE_WITH_PRIVATE (GtkListBoxItem, gtk_listbox_item, GTK_TYPE_LIST_BOX_ROW);
9 |
10 | static void gtk_listbox_item_class_init (GtkListBoxItemClass *klass)
11 | {
12 | gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS(klass),
13 | "/gtk/examples/custom-widget/GtkListBoxItem.glade");
14 |
15 | gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS(klass),
16 | GtkListBoxItem, label_no);
17 | gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS(klass),
18 | GtkListBoxItem, label_body);
19 | }
20 |
21 | static void gtk_listbox_item_init (GtkListBoxItem *self)
22 | {
23 | self->priv = (GtkListBoxItemPrivate *) gtk_listbox_item_get_instance_private (GTK_LISTBOX_ITEM (self));
24 | gtk_widget_init_template (GTK_WIDGET (self));
25 | }
26 |
27 | GtkListBoxItem *gtk_listbox_item_new (gint index, const gchar *str)
28 | {
29 | GtkListBoxItem *row =
30 | GTK_LISTBOX_ITEM (g_object_new (gtk_listbox_item_get_type (), NULL));
31 |
32 | g_warn_if_fail (row != NULL);
33 | g_warn_if_fail (row->priv != NULL);
34 | g_warn_if_fail (row->priv->label_body != NULL);
35 |
36 | {
37 | gchar idx[16];
38 | memset (idx, 0x0, 16);
39 | sprintf (idx, "%d", index);
40 | gtk_label_set_text (row->priv->label_no, idx);
41 | }
42 |
43 | gtk_label_set_text (row->priv->label_body, str);
44 |
45 | return row;
46 | }
47 |
--------------------------------------------------------------------------------
/example/php/style/main.php:
--------------------------------------------------------------------------------
1 | gtk_application_new('org.gtk3.style', null);
8 |
9 | $gtk->g_signal_connect_data($app, 'activate', 'cb_application_activate', null, null, null);
10 | $status = $gtk::getInstance()->info->ffi->g_application_run($gtk->cast('GApplication*',$app), 0, null);
11 | $gtk->g_object_ref_sink($app);
12 |
13 | function cb_application_activate(): void
14 | {
15 | global $app;
16 | $gtk = \Gtk3\Gtk::getInstance();
17 | $builder = $gtk->gtk_builder_new();
18 | $error = $gtk->new('GError*');
19 | $gtk->gtk_builder_add_from_file($builder, './main.glade', \Gtk3\Gtk::addr($error));
20 | $window = $gtk->gtk_builder_get_object($builder, 'application_window');
21 | $gtk->g_object_set($window, "application", $app, NULL);
22 | $gtk->gtk_widget_set_size_request($gtk->cast('GtkWidget*',$window), 320, 240);
23 | // $gtk->gtk_window_set_position($gtk->cast('GtkWidget*',$window), 1);
24 |
25 | $provider = $gtk->gtk_css_provider_new();
26 | $gtk->gtk_css_provider_load_from_path ($provider, "./style.css", \Gtk3\Gtk::addr($error));
27 |
28 | $gtk->gtk_style_context_add_provider_for_screen(
29 | $gtk->gdk_screen_get_default(),
30 | $gtk->cast('GtkStyleProvider*',$provider),
31 | 1
32 | );
33 |
34 | $button = $gtk->gtk_builder_get_object($builder, "button0");
35 |
36 | $context = $gtk->gtk_widget_get_style_context($gtk->cast('GtkWidget*', $button));
37 | $gtk->gtk_style_context_add_class($context, "button-ligt-gray");
38 |
39 | $textview = $gtk->gtk_builder_get_object($builder, "textview");
40 | $buffer = $gtk->gtk_text_view_get_buffer($gtk->cast('GtkTextView*',$textview));
41 | $gtk->gtk_text_buffer_set_text($buffer, "Просмотр текста", -1);
42 |
43 | $gtk->gtk_widget_show_all($gtk->cast('GtkWidget*', $window));
44 | $gtk->g_object_unref($builder);
45 | }
--------------------------------------------------------------------------------
/example/php/authorization/main.php:
--------------------------------------------------------------------------------
1 | mainQuit();
13 | }
14 |
15 | $gtk = Gtk::getInstance();
16 |
17 | $gtk->init();
18 |
19 | $window = new Window();
20 | $window->setTitle('GtkEntryBox');
21 | $window->setPosition(0);
22 | $window->setDefaultSize(200, 200);
23 |
24 | $signal = new Gtk\Signal();
25 | $window->connect('destroy', 'closeApp', null);
26 |
27 |
28 | $usernameLabel = new Gtk\Label('Login: ');
29 | $usernameLabel->setWidthChars(12);
30 |
31 | $passwordLabel = new Gtk\Label('Password: ');
32 | $passwordLabel->setWidthChars(12);
33 |
34 | $usernameEntry = new Gtk\Entry();
35 | $passwordEntry = new Gtk\Entry();
36 | $passwordEntry->setVisibility(false);
37 |
38 | $okButton = new Gtk\Button('OK');
39 |
40 | $signal->connect($okButton, 'clicked', function () use ($passwordEntry){
41 | global $password;
42 | $passwordText = $passwordEntry->getText(100);
43 |
44 | if ($passwordText === $password) {
45 | echo 'Access granted!' . PHP_EOL;
46 | } else {
47 | echo 'Access denied' . PHP_EOL;
48 | }
49 |
50 | }, $passwordEntry->widget);
51 |
52 | $hbox1 = new Gtk\Box(\Gtk3\Enum\BoxEnum::horizontal, 5);
53 | $hbox2 = new Gtk\Box(\Gtk3\Enum\BoxEnum::horizontal, 5);
54 |
55 | $vbox = new Gtk\Box(\Gtk3\Enum\BoxEnum::vertical, 10);
56 |
57 | $hbox1->packStart($usernameLabel, true, false, 5);
58 | $hbox1->packStart($usernameEntry, true, false, 5);
59 |
60 | $hbox2->packStart($passwordLabel, true, true, 5);
61 | $hbox2->packStart($passwordEntry, true, false, 5);
62 |
63 | $vbox->packStart($hbox1, false, false, 5);
64 | $vbox->packStart($hbox2, false, false, 5);
65 | $vbox->packStart($okButton, false, false, 5);
66 |
67 | $container = new Gtk\Container();
68 | $container->add($window, $vbox);
69 | $window->showAll();
70 |
71 | $gtk->main();
72 |
73 | return 0;
--------------------------------------------------------------------------------
/example/c/timer/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | static GtkWidget *s_label = NULL;
6 |
7 | static guint timer_id;
8 | static volatile gboolean s_timer_request_quit = FALSE;
9 |
10 | static gboolean label_countup (gpointer user_data)
11 | {
12 | static gint s_label_count = 0;
13 |
14 | if (s_label != NULL && !s_timer_request_quit) {
15 | gchar label[256];
16 | memset (label, 0x0, 256);
17 | sprintf (label, "count = %d", s_label_count);
18 | gtk_label_set_text ( GTK_LABEL (s_label), label);
19 | s_label_count++;
20 | }
21 | return !s_timer_request_quit;
22 | }
23 |
24 | static gboolean cb_window_delete_event (GtkWidget *widget, GdkEventAny *event, gpointer user_data)
25 | {
26 | s_timer_request_quit = TRUE;
27 | g_source_remove (timer_id);
28 |
29 | return FALSE;
30 | }
31 |
32 | static void cb_application_activate (GtkApplication* app, gpointer user_data)
33 | {
34 | GtkWidget *window;
35 |
36 | window = gtk_application_window_new (app);
37 | gtk_window_set_title (GTK_WINDOW (window), "Таймер образец");
38 | gtk_widget_set_size_request (window, 320, 240);
39 | gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
40 | g_signal_connect (window, "delete_event", G_CALLBACK (cb_window_delete_event), NULL);
41 |
42 | s_label = gtk_label_new ("count = 0");
43 | gtk_container_add (GTK_CONTAINER (window), s_label);
44 |
45 | gtk_widget_show_all (window);
46 |
47 | timer_id = g_timeout_add (1000, (GSourceFunc)label_countup, NULL);
48 | }
49 |
50 | int main (int argc, char **argv)
51 | {
52 | GtkApplication *app;
53 | int status;
54 |
55 | app = gtk_application_new ("org.gtk3.timer", G_APPLICATION_FLAGS_NONE);
56 | g_signal_connect (app, "activate", G_CALLBACK (cb_application_activate), NULL);
57 | status = g_application_run (G_APPLICATION (app), argc, argv);
58 | g_object_unref (app);
59 |
60 | return status;
61 | }
62 |
--------------------------------------------------------------------------------
/src/Gtk/Window.php:
--------------------------------------------------------------------------------
1 | window = Gtk::getInstance()->gtk_window_new($type->value);
40 | $this->widget = new Widget($this->window);
41 | }
42 |
43 | public function widget(): Widget
44 | {
45 | return $this->widget;
46 | }
47 |
48 | public function __call(string $name, array $arguments)
49 | {
50 | $functionName = 'gtk_window_' . strtolower(preg_replace('~([A-Z])~', '_$1', $name));
51 | $cast = "GtkWindow *";
52 |
53 | return Gtk::getInstance()->$functionName(Gtk::getInstance()->cast($cast, $this->window), ...$arguments);
54 | }
55 |
56 | /**
57 | * @param string $detailed_signal
58 | * @param callable $c_handler
59 | * @param null $data
60 | *
61 | * @return int
62 | */
63 | public function connect(
64 | string $detailed_signal,
65 | callable $c_handler,
66 | $data = null
67 | ): int {
68 | return (int) Gtk::getInstance()->g_signal_connect_data(
69 | $this->window,
70 | $detailed_signal,
71 | $c_handler,
72 | $data,
73 | null,
74 | null
75 | );
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Gtk/Entry.php:
--------------------------------------------------------------------------------
1 | widget = Gtk::getInstance()->gtk_entry_new();
20 | }
21 |
22 | /**
23 | * sdfsd
24 | *
25 | * @param int $max
26 | *
27 | * @throws \Exception
28 | */
29 | public function setMaxLength(int $max): void
30 | {
31 | Gtk::getInstance()->gtk_entry_set_max_length(
32 | Gtk::getInstance()->cast('GtkEntry *', $this->widget),
33 | $max
34 | );
35 | }
36 |
37 | /**
38 | * @param int $max
39 | *
40 | * @return string
41 | * @throws \Exception
42 | */
43 | public function getText(int $max): string
44 | {
45 | return (string) Gtk::getInstance()->gtk_entry_get_text(
46 | Gtk::getInstance()->cast('GtkEntry *', $this->widget),
47 | );
48 | }
49 |
50 | /**
51 | * @param string $text
52 | *
53 | * @throws \Exception
54 | */
55 | public function setText(string $text): void
56 | {
57 | Gtk::getInstance()->gtk_entry_set_text(
58 | Gtk::getInstance()->cast('GtkEntry *', $this->widget),
59 | $text
60 | );
61 | }
62 |
63 | /**
64 | * @param bool $visible
65 | *
66 | * @throws \Exception
67 | */
68 | public function setVisibility(bool $visible): void
69 | {
70 | Gtk::getInstance()->gtk_entry_set_visibility(
71 | Gtk::getInstance()->cast('GtkEntry *', $this->widget),
72 | $visible
73 | );
74 | }
75 |
76 | /**
77 | * @param string $ch
78 | *
79 | * @throws \Exception
80 | */
81 | public function setInvisibleChar(string $ch): void
82 | {
83 | Gtk::getInstance()->gtk_entry_set_invisible_char(
84 | Gtk::getInstance()->cast('GtkEntry *', $this->widget),
85 | $ch
86 | );
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/example/c/custom-widget/custom_widget.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "GtkListBoxItem.h"
3 |
4 | static gboolean cb_item_selected (GtkListBox *listbox, GtkListBoxItem *row, gpointer user_data)
5 | {
6 | if (row != NULL) {
7 | const gint index = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (row));
8 | g_print ("item selected -> No.%d %s\n", index, gtk_label_get_text (row->priv->label_body));
9 | }
10 |
11 | return TRUE;
12 | }
13 |
14 | static void cb_app_activate (GtkApplication* app, gpointer user_data)
15 | {
16 | GtkBuilder* builder = gtk_builder_new ();
17 | g_return_if_fail (builder != NULL);
18 |
19 | GError* error = NULL;
20 | if (!gtk_builder_add_from_file (builder, "./res/main.glade", &error)) {
21 | if (error) {
22 | g_error ("Failed to load: %s", error->message);
23 | g_error_free (error);
24 | return ;
25 | }
26 | }
27 |
28 | GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (gtk_builder_get_object (builder, "application_window"));
29 | g_warn_if_fail (window != NULL);
30 | g_object_set (window, "application", app, NULL);
31 |
32 | GtkWidget *listbox = GTK_WIDGET (gtk_builder_get_object (builder, "listbox"));
33 | g_warn_if_fail (listbox != NULL);
34 |
35 | g_signal_connect (listbox, "row-selected", G_CALLBACK (cb_item_selected), NULL);
36 |
37 | for (int i = 0; i < 10; i++) {
38 | static const gchar items[][256] = {
39 | "суши",
40 | "стейк",
41 | "Карри и рис",
42 | "гамбургер",
43 | "Удон",
44 | "Жареная курица",
45 | "гречиха",
46 | "Жареный рис",
47 | "Жареный рис",
48 | "Миска с морепродуктами",
49 | };
50 | GtkListBoxItem *item = gtk_listbox_item_new (i, items[i]);
51 | gtk_container_add (GTK_CONTAINER (listbox), GTK_WIDGET (item));
52 | }
53 |
54 | gtk_widget_show_all (GTK_WIDGET (window));
55 | g_object_unref (builder);
56 | }
57 |
58 | int main (int argc, char **argv)
59 | {
60 | GtkApplication *app;
61 | int status;
62 |
63 | app = gtk_application_new ("org.gtk3.custom-widget", G_APPLICATION_FLAGS_NONE);
64 | g_signal_connect (app, "activate", G_CALLBACK (cb_app_activate), NULL);
65 | status = g_application_run (G_APPLICATION (app), argc, argv);
66 | g_object_unref (app);
67 |
68 | return status;
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/example/c/style/main.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | static void cb_application_activate (GtkApplication* app, gpointer user_data)
4 | {
5 | GtkBuilder* builder = gtk_builder_new ();
6 | g_return_if_fail (builder != NULL);
7 |
8 | GError* error = NULL;
9 | if (!gtk_builder_add_from_file (builder, "./main.glade", &error)) {
10 | if (error) {
11 | g_error ("Failed to load: %s", error->message);
12 | g_error_free (error);
13 | return ;
14 | }
15 | }
16 |
17 | GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (gtk_builder_get_object (builder, "application_window"));
18 | g_warn_if_fail (window != NULL);
19 | g_object_set (window, "application", app, NULL);
20 |
21 | gtk_widget_set_size_request (GTK_WIDGET (window), 320, 240);
22 | gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
23 |
24 | GtkCssProvider* provider = gtk_css_provider_new ();
25 | gtk_css_provider_load_from_path (provider, "./style.css", &error);
26 | if (error != NULL) {
27 | g_print ("Error:\t%s\n", error->message);
28 | g_error_free (error);
29 | return ;
30 | }
31 |
32 | gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
33 | GTK_STYLE_PROVIDER (provider),
34 | GTK_STYLE_PROVIDER_PRIORITY_USER);
35 |
36 | GtkWidget *button = GTK_WIDGET (gtk_builder_get_object (builder, "button0"));
37 | GtkStyleContext *context = gtk_widget_get_style_context (button);
38 | gtk_style_context_add_class (context, "button-ligt-gray");
39 |
40 | {
41 | GtkWidget *textview = GTK_WIDGET (gtk_builder_get_object (builder, "textview"));
42 | GtkTextBuffer *buffer;
43 | buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
44 | gtk_text_buffer_set_text (buffer, "Просмотр текста", -1);
45 | }
46 |
47 | gtk_widget_show_all (GTK_WIDGET (window));
48 | g_object_unref (builder);
49 | }
50 |
51 | int main (int argc, char **argv)
52 | {
53 | GtkApplication *app;
54 | int status;
55 |
56 | app = gtk_application_new ("org.gtk3.style", G_APPLICATION_FLAGS_NONE);
57 | g_signal_connect (app, "activate", G_CALLBACK (cb_application_activate), NULL);
58 | status = g_application_run (G_APPLICATION (app), argc, argv);
59 | g_object_unref (app);
60 |
61 | return status;
62 | }
63 |
--------------------------------------------------------------------------------
/example/c/custom-widget/res/GtkListBoxItem.glade:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | False
7 | 16
8 |
9 |
10 | True
11 | False
12 | 4
13 | 4
14 | True
15 |
16 |
17 | 32
18 | True
19 | False
20 | 8
21 | 8
22 | 8
23 | 8
24 |
25 |
26 | 0
27 | 0
28 |
29 |
30 |
31 |
32 | True
33 | False
34 | True
35 |
36 |
37 | True
38 | False
39 | 8
40 | 8
41 | True
42 |
43 |
44 | False
45 | True
46 | 0
47 |
48 |
49 |
50 |
51 | 1
52 | 0
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/Gtk.php:
--------------------------------------------------------------------------------
1 | loader = $this->loader();
35 |
36 | $this->info = $this->loadLibrary(new Library());
37 |
38 | self::setInstance($this);
39 | }
40 |
41 | /**
42 | * @return self $this
43 | */
44 | public static function getInstance(): self
45 | {
46 | return self::$instance ??= new static();
47 | }
48 |
49 | /**
50 | * @param self|null $instance
51 | * @return void
52 | */
53 | public static function setInstance(?self $instance): void
54 | {
55 | self::$instance = $instance;
56 | }
57 |
58 | /**
59 | * @return Loader
60 | */
61 | private function loader(): Loader
62 | {
63 | $loader = new Loader();
64 |
65 | $pre = $loader->preprocessor();
66 | $pre->keepComments = false;
67 | $pre->minify = false;
68 | $pre->tolerant = false;
69 |
70 | return $loader;
71 | }
72 |
73 |
74 | /**
75 | * @param LibraryInterface $library
76 | * @return LibraryInformation
77 | */
78 | public function loadLibrary(LibraryInterface $library): LibraryInformation
79 | {
80 | return $this->loader->load($library);
81 | }
82 |
83 | /**
84 | * @param int $argc
85 | * @param array $argv
86 | * @throws \Exception
87 | */
88 | public function init(int $argc = 0, array $argv = [])
89 | {
90 | $argcPtr = $this->new('int');
91 | $argcPtr->cdata = $argc;
92 | $argvPtr = FFI::new('char**');
93 | $argcPtr->cdata = $argc;
94 |
95 | $this->gtk_init(FFI::addr($argcPtr), FFI::addr($argvPtr));
96 | }
97 |
98 | /**
99 | *
100 | */
101 | public function main(): void
102 | {
103 | $this->gtk_main();
104 | }
105 |
106 | /**
107 | *
108 | */
109 | public function mainQuit(): void
110 | {
111 | $this->gtk_main_quit();
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/resources/gtk.h:
--------------------------------------------------------------------------------
1 | #include "type/base.h"
2 |
3 | typedef void* (*GCallback) (void*, void*);
4 | typedef struct _GClosureNotify GClosureNotify;
5 | typedef struct _GConnectFlags GConnectFlags;
6 | typedef struct _GError GError;
7 | typedef struct _GClosureNotifyData GClosureNotifyData;
8 | typedef gboolean (*GSourceFunc) (gpointer user_data);
9 | typedef struct _GtkWidget GtkWidget;
10 | typedef struct _GtkGrid GtkGrid;
11 | typedef struct _GtkBuilder GtkBuilder;
12 | typedef struct _GtkWindow GtkWindow;
13 | typedef struct _GtkContainer GtkContainer;
14 | typedef struct _GtkLabel GtkLabel;
15 | typedef struct _GtkApplication GtkApplication;
16 | typedef struct _GApplication GApplication;
17 | typedef struct _GtkCssProvider GtkCssProvider;
18 | typedef struct _GdkScreen GdkScreen;
19 | typedef struct _GtkStyleProvider GtkStyleProvider;
20 | typedef struct _GObject GObject;
21 | typedef struct _GtkStyleContext GtkStyleContext;
22 | typedef struct _GtkTextBuffer GtkTextBuffer;
23 | typedef struct _GtkTextView GtkTextView;
24 | typedef struct _GtkBox GtkBox;
25 | typedef struct _GtkEntry GtkEntry;
26 | typedef struct _GFile GFile;
27 |
28 | typedef enum
29 | {
30 | GTK_WINDOW_TOPLEVEL,
31 | GTK_WINDOW_POPUP
32 | } GtkWindowType;
33 |
34 | typedef enum
35 | {
36 | GTK_ORIENTATION_HORIZONTAL,
37 | GTK_ORIENTATION_VERTICAL
38 | } GtkOrientation;
39 |
40 | typedef enum
41 | {
42 | G_APPLICATION_FLAGS_NONE,
43 | G_APPLICATION_IS_SERVICE = (1 << 0),
44 | G_APPLICATION_IS_LAUNCHER = (1 << 1),
45 |
46 | G_APPLICATION_HANDLES_OPEN = (1 << 2),
47 | G_APPLICATION_HANDLES_COMMAND_LINE = (1 << 3),
48 | G_APPLICATION_SEND_ENVIRONMENT = (1 << 4),
49 |
50 | G_APPLICATION_NON_UNIQUE = (1 << 5),
51 |
52 | G_APPLICATION_CAN_OVERRIDE_APP_ID = (1 << 6),
53 | G_APPLICATION_ALLOW_REPLACEMENT = (1 << 7),
54 | G_APPLICATION_REPLACE = (1 << 8)
55 | } GApplicationFlags;
56 |
57 | typedef enum
58 | {
59 | GTK_WIN_POS_NONE,
60 | GTK_WIN_POS_CENTER,
61 | GTK_WIN_POS_MOUSE,
62 | GTK_WIN_POS_CENTER_ALWAYS,
63 | GTK_WIN_POS_CENTER_ON_PARENT
64 | } GtkWindowPosition;
65 |
66 |
67 |
68 |
69 | #include "functions/gtk/main.h"
70 | #include "functions/gtk/widget.h"
71 | #include "functions/gtk/window.h"
72 | #include "functions/gtk/button.h"
73 | #include "functions/gtk/label.h"
74 | #include "functions/gtk/container.h"
75 | #include "functions/gtk/style.h"
76 | #include "functions/gtk/css_provider.h"
77 | #include "functions/gtk/grid.h"
78 | #include "functions/gtk/application.h"
79 | #include "functions/gtk/builder.h"
80 | #include "functions/gtk/text_view.h"
81 | #include "functions/gtk/text_buffer.h"
82 | #include "functions/gtk/box.h"
83 | #include "functions/gtk/entry.h"
84 | #include "functions/g/main.h"
85 | #include "functions/g/application.h"
86 | #include "functions/g/object.h"
87 | #include "functions/g/signal.h"
88 | #include "functions/gdk/screen.h"
89 |
--------------------------------------------------------------------------------
/example/c/image-viewer/image_viewer.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | static void cb_button_quit_clicked (GtkWidget *button, gpointer user_data)
4 | {
5 | GApplication *app = G_APPLICATION (user_data);
6 | g_application_quit (app);
7 | }
8 |
9 | static void cb_button_chooser_clicked (GtkWidget *button, gpointer user_data)
10 | {
11 | GtkApplication* app = GTK_APPLICATION (user_data);
12 | GtkWindow *window = gtk_application_get_active_window (app);
13 |
14 | GtkWidget *dialog = gtk_file_chooser_dialog_new (
15 | "Выберите файл изображения",
16 | GTK_WINDOW (window),
17 | GTK_FILE_CHOOSER_ACTION_OPEN,
18 | "Отменеть",
19 | GTK_RESPONSE_CANCEL,
20 | "Выбор",
21 | GTK_RESPONSE_ACCEPT,
22 | NULL);
23 |
24 | gtk_widget_show_all (dialog);
25 |
26 | if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
27 | gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
28 |
29 | GtkWidget *image = GTK_WIDGET (g_object_get_data (G_OBJECT (window), "image"));
30 | g_return_if_fail (image != NULL);
31 |
32 | gtk_image_set_from_file (GTK_IMAGE (image), filename);
33 | g_free (filename);
34 | }
35 |
36 | gtk_widget_destroy (dialog);
37 | }
38 |
39 | static void cb_app_activate (GtkApplication* app, gpointer user_data)
40 | {
41 | GtkWidget *window = gtk_application_window_new (GTK_APPLICATION (app));
42 |
43 | gtk_widget_set_size_request (GTK_WIDGET (window), 640, 480);
44 | gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
45 |
46 | GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL , 2);
47 | gtk_container_add (GTK_CONTAINER (window), vbox);
48 | {
49 | GtkWidget *image = gtk_image_new ();
50 | g_object_set_data (G_OBJECT (window), "image", (gpointer)image);
51 | gtk_box_pack_start (GTK_BOX (vbox), image, TRUE, TRUE, 0);
52 | }
53 | {
54 | GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
55 | gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
56 |
57 | GtkWidget *button_quit = gtk_button_new_with_label("Закрыть");
58 | g_signal_connect (button_quit, "clicked", G_CALLBACK (cb_button_quit_clicked), app);
59 | gtk_box_pack_start (GTK_BOX (hbox), button_quit, TRUE, TRUE, 0);
60 |
61 | GtkWidget *button_chooser = gtk_button_new_with_label("Выбор файла изображения");
62 | g_signal_connect (button_chooser, "clicked", G_CALLBACK (cb_button_chooser_clicked), app);
63 | gtk_box_pack_start (GTK_BOX (hbox), button_chooser, TRUE, TRUE, 0);
64 | }
65 |
66 | gtk_widget_show_all (GTK_WIDGET (window));
67 | }
68 |
69 | int main (int argc, char **argv)
70 | {
71 | GtkApplication *app;
72 | int status;
73 |
74 | app = gtk_application_new ("org.gtk3.image-viewer", G_APPLICATION_FLAGS_NONE);
75 | g_signal_connect (app, "activate", G_CALLBACK (cb_app_activate), NULL);
76 | status = g_application_run (G_APPLICATION (app), argc, argv);
77 | g_object_unref (app);
78 |
79 | return status;
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/resources/GApplication.h:
--------------------------------------------------------------------------------
1 | extern gboolean g_application_id_is_valid(const gchar *application_id);
2 | extern GApplication* g_application_new(const gchar *application_id, GApplicationFlags flags);
3 | extern const gchar* g_application_get_application_id(GApplication *application);
4 | extern void g_application_set_application_id(GApplication *application, const gchar *application_id);
5 | extern guint g_application_get_inactivity_timeout(GApplication *application);
6 | extern void g_application_set_inactivity_timeout(GApplication *application, guint inactivity_timeout);
7 | extern GApplicationFlags g_application_get_flags(GApplication *application);
8 | extern void g_application_set_flags(GApplication *application, GApplicationFlags flags);
9 | extern const gchar* g_application_get_resource_base_path(GApplication *application);
10 | extern void g_application_set_resource_base_path (GApplication *application, const gchar *resource_path);
11 | extern GDBusConnection* g_application_get_dbus_connection(GApplication *application);
12 | extern const gchar* g_application_get_dbus_object_path(GApplication *application);
13 | extern void g_application_set_action_group(GApplication *application, GActionGroup *action_group);
14 | extern gboolean g_application_get_is_registered(GApplication *application);
15 | extern gboolean g_application_get_is_remote(GApplication *application);
16 | extern gboolean g_application_register(GApplication *application, GCancellable *cancellable, GError **error);
17 | extern void g_application_hold(GApplication *application);
18 | extern void g_application_release(GApplication *application);
19 | extern void g_application_quit(GApplication *application);
20 | extern void g_application_activate(GApplication *application);
21 | extern void g_application_open(GApplication *application, GFile **files, gint n_files, const gchar *hint);
22 | extern void g_application_send_notification(GApplication *application, const gchar *id, GNotification *notification);
23 | extern void g_application_withdraw_notification(GApplication *application, const gchar *id);
24 | extern int g_application_run(GApplication *application, int argc, char **argv);
25 | extern void g_application_add_main_option_entries(GApplication *application, const GOptionEntry *entries);
26 | extern void g_application_add_main_option (GApplication *application, const char *long_name, char short_name, GOptionFlags flags, GOptionArg arg, const char *description,const char *arg_description);
27 | extern void g_application_add_option_group(GApplication *application, GOptionGroup *group);
28 | extern void g_application_set_option_context_parameter_string(GApplication *application, const gchar *parameter_string);
29 | extern void g_application_set_option_context_summary(GApplication *application, const gchar *summary);
30 | extern void g_application_set_option_context_description(GApplication *application, const gchar *description);
31 | extern void g_application_set_default(GApplication *application);
32 | extern GApplication * g_application_get_default(void);
33 | extern void g_application_mark_busy (GApplication *application);
34 | extern void g_application_unmark_busy(GApplication *application);
35 | extern gboolean g_application_get_is_busy (GApplication *application);
36 | extern void g_application_bind_busy_property (GApplication *application, gpointer object, const gchar *property);
37 | extern void g_application_unbind_busy_property(GApplication *application, gpointer object, const gchar *property);
--------------------------------------------------------------------------------
/src/Support/ProxyTrait.php:
--------------------------------------------------------------------------------
1 | 'Gtk'
17 | ];
18 |
19 | /**
20 | * {@inheritDoc}
21 | */
22 | public function __call(string $name, array $arguments)
23 | {
24 | return $this->info->ffi->$name(...$arguments);
25 | }
26 |
27 | /**
28 | * @param CData $type
29 | * @return CData
30 | * @psalm-suppress MixedInferredReturnType
31 | */
32 | public static function addr(CData $type): CData
33 | {
34 | return \FFI::addr($type);
35 | }
36 |
37 | /**
38 | * @param string $type
39 | * @param bool $owned
40 | * @param bool $persistent
41 | * @return CData
42 | * @psalm-suppress MixedInferredReturnType
43 | */
44 | public function new(string $type, bool $owned = true, bool $persistent = false): CData
45 | {
46 | try {
47 | return $this->info->ffi->new($this->nameToInternal($type), $owned, $persistent);
48 | } catch (ParserException $e) {
49 | $error = \sprintf('Structure "%s" not found. %s', $type, \ucfirst($e->getMessage()));
50 |
51 | throw new \Exception($error);
52 | }
53 | }
54 |
55 | /**
56 | * @param string $type
57 | * @return string
58 | * @psalm-suppress MixedAssignment
59 | * @psalm-suppress MixedArgumentTypeCoercion
60 | * @psalm-suppress MixedOperand
61 | */
62 | protected function namespaceToPrefix(string $type): string
63 | {
64 | $type = \trim($type, '\\');
65 |
66 | foreach ($this->casts as $from => $to) {
67 | if (\strpos($type, $from) !== 0) {
68 | continue;
69 | }
70 |
71 | $type = $to . \substr($type, \strlen($from));
72 | }
73 |
74 | return $type;
75 | }
76 |
77 | /**
78 | * @param string $type
79 | * @return string
80 | */
81 | protected function nameToInternal(string $type): string
82 | {
83 | $ptr = 0;
84 |
85 | $type = $this->namespaceToPrefix($type);
86 |
87 | while (\substr($type, -3) === 'Ptr') {
88 | $type = \substr($type, 0, -3);
89 | $ptr++;
90 | }
91 |
92 | return \str_replace('\\', '_', $type) . \str_repeat('*', $ptr);
93 | }
94 |
95 | /**
96 | * @param string|CType $type
97 | * @param CData $ptr
98 | * @return CData
99 | * @psalm-suppress PossiblyInvalidArgument
100 | * @psalm-suppress MixedInferredReturnType
101 | */
102 | public function cast($type, CData $ptr): CData
103 | {
104 | if (\is_string($type)) {
105 | $type = $this->nameToInternal($type);
106 | }
107 |
108 | try {
109 | return $this->info->ffi->cast($type, $ptr);
110 | } catch (ParserException $e) {
111 | $error = \sprintf('Structure "%s" not found. %s', $type, \ucfirst($e->getMessage()));
112 |
113 | throw new \Exception($error);
114 | }
115 | }
116 |
117 | /**
118 | * @param string|CType $type
119 | * @return CType
120 | * @psalm-suppress PossiblyInvalidArgument
121 | * @psalm-suppress MixedInferredReturnType
122 | */
123 | public function type($type): CType
124 | {
125 | if (\is_string($type)) {
126 | $type = $this->nameToInternal($type);
127 | }
128 |
129 | try {
130 | return $this->info->ffi->type($type);
131 | } catch (ParserException $e) {
132 | $error = \sprintf('Structure "%s" not found. %s', $type, \ucfirst($e->getMessage()));
133 |
134 | throw new \Exception($error);
135 | }
136 | }
137 |
138 | /**
139 | * {@inheritDoc}
140 | */
141 | public static function __callStatic(string $name, array $arguments)
142 | {
143 | return \FFI::$name(...$arguments);
144 | }
145 |
146 | /**
147 | * @param string $name
148 | * @return mixed
149 | */
150 | public function __get(string $name)
151 | {
152 | return $this->info->ffi->$name;
153 | }
154 |
155 | /**
156 | * @param string $name
157 | * @param mixed $value
158 | * @noinspection MagicMethodsValidityInspection
159 | */
160 | public function __set(string $name, $value): void
161 | {
162 | $this->info->ffi->$name = $value;
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/example/c/cairo/main.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | static cairo_surface_t *s_cairo_surface = NULL;
4 |
5 | static void clear_surface ()
6 | {
7 | cairo_t *cr = cairo_create (s_cairo_surface);
8 |
9 | cairo_set_source_rgb (cr, 1, 1, 1);
10 | cairo_paint (cr);
11 |
12 | cairo_destroy (cr);
13 | }
14 |
15 | static void draw_brush (GtkWidget *widget, gdouble x, gdouble y)
16 | {
17 | #define BRUSH_SIZE 10
18 |
19 | cairo_t *cr = cairo_create (s_cairo_surface);
20 |
21 | cairo_rectangle (cr, x - BRUSH_SIZE / 2, y - BRUSH_SIZE / 2, BRUSH_SIZE, BRUSH_SIZE);
22 | cairo_fill (cr);
23 | cairo_destroy (cr);
24 |
25 | gtk_widget_queue_draw_area (widget, x - BRUSH_SIZE / 2, y - BRUSH_SIZE / 2, BRUSH_SIZE, BRUSH_SIZE);
26 | }
27 |
28 | static gboolean configure_event_cb (GtkWidget *widget, GdkEventConfigure *event, gpointer data)
29 | {
30 | if (s_cairo_surface != NULL)
31 | cairo_surface_destroy (s_cairo_surface);
32 |
33 | s_cairo_surface = gdk_window_create_similar_surface (
34 | gtk_widget_get_window (widget),
35 | CAIRO_CONTENT_COLOR,
36 | gtk_widget_get_allocated_width (widget),
37 | gtk_widget_get_allocated_height (widget));
38 |
39 | clear_surface ();
40 |
41 | return TRUE;
42 | }
43 |
44 | static gboolean cb_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
45 | {
46 | cairo_set_source_surface (cr, s_cairo_surface, 0, 0);
47 | cairo_paint (cr);
48 |
49 | return TRUE;
50 | }
51 |
52 | static gboolean cb_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
53 | {
54 | if (s_cairo_surface == NULL)
55 | return FALSE;
56 |
57 | if (event->button == GDK_BUTTON_PRIMARY)
58 | draw_brush (widget, event->x, event->y);
59 | else if (event->button == GDK_BUTTON_SECONDARY) {
60 | clear_surface ();
61 | gtk_widget_queue_draw (widget);
62 | }
63 |
64 | return TRUE;
65 | }
66 |
67 | static gboolean cb_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer data)
68 | {
69 | if (s_cairo_surface == NULL)
70 | return FALSE;
71 |
72 | if (event->state & GDK_BUTTON1_MASK)
73 | draw_brush (widget, event->x, event->y);
74 |
75 | return TRUE;
76 | }
77 |
78 | static void cb_window_destory ()
79 | {
80 | if (s_cairo_surface != NULL)
81 | cairo_surface_destroy (s_cairo_surface);
82 | }
83 |
84 | static void cb_application_activate (GtkApplication* app, gpointer user_data)
85 | {
86 | GtkBuilder* builder = gtk_builder_new ();
87 | g_return_if_fail (builder != NULL);
88 |
89 | GError* error = NULL;
90 | if (!gtk_builder_add_from_file (builder, "./main.glade", &error)) {
91 | if (error) {
92 | g_error ("Failed to load: %s", error->message);
93 | g_error_free (error);
94 | return ;
95 | }
96 | }
97 |
98 | GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (gtk_builder_get_object (builder, "application_window"));
99 | g_warn_if_fail (window != NULL);
100 | g_object_set (window, "application", app, NULL);
101 | gtk_window_set_title (GTK_WINDOW (window), "2D графика Краска с Каиром");
102 | g_signal_connect (window, "destroy", G_CALLBACK (cb_window_destory), NULL);
103 |
104 | {
105 | GtkWidget *drawing_area = GTK_WIDGET (gtk_builder_get_object (builder, "drawing_area"));
106 | g_warn_if_fail (drawing_area != NULL);
107 |
108 | g_signal_connect (drawing_area, "draw", G_CALLBACK (cb_draw), NULL);
109 | g_signal_connect (drawing_area, "configure-event", G_CALLBACK (configure_event_cb), NULL);
110 | g_signal_connect (drawing_area, "motion-notify-event", G_CALLBACK (cb_motion_notify_event), NULL);
111 | g_signal_connect (drawing_area, "button-press-event", G_CALLBACK (cb_button_press_event), NULL);
112 |
113 | gtk_widget_set_events (drawing_area, gtk_widget_get_events (drawing_area)
114 | | GDK_BUTTON_PRESS_MASK
115 | | GDK_POINTER_MOTION_MASK);
116 | }
117 |
118 | gtk_widget_show_all (GTK_WIDGET (window));
119 | g_object_unref (builder);
120 | }
121 |
122 | int main (int argc, char **argv)
123 | {
124 | GtkApplication *app;
125 | int status;
126 |
127 | app = gtk_application_new ("org.gtk3.cairo", G_APPLICATION_FLAGS_NONE);
128 | g_signal_connect (app, "activate", G_CALLBACK (cb_application_activate), NULL);
129 | status = g_application_run (G_APPLICATION (app), argc, argv);
130 | g_object_unref (app);
131 |
132 | return status;
133 | }
134 |
--------------------------------------------------------------------------------
/resources/GObjectSignals.h:
--------------------------------------------------------------------------------
1 | extern guint g_signal_new (const gchar *signal_name, GType itype, GSignalFlags signal_flags, guint class_offset, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, ...);
2 | extern guint g_signal_newv(const gchar *signal_name, GType itype, GSignalFlags signal_flags, GClosure *class_closure, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, GType *param_types);
3 | extern guint g_signal_new_valist(const gchar *signal_name, GType itype, GSignalFlags signal_flags, GClosure *class_closure, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, va_list args);
4 | extern void g_signal_set_va_marshaller(guint signal_id, GType instance_type, GSignalCVaMarshaller va_marshaller);
5 | extern void g_signal_query(guint signal_id, GSignalQuery *query);
6 | extern guint g_signal_lookup(const gchar *name, GType itype);
7 | extern const gchar* g_signal_name(guint signal_id);
8 | extern guint* g_signal_list_ids(GType itype, guint *n_ids);
9 | extern void g_signal_emit(gpointer instance, guint signal_id, GQuark detail, ...);
10 | extern void g_signal_emit_by_name (gpointer instance, const gchar *detailed_signal, ...);
11 | extern void g_signal_emitv(const GValue *instance_and_params, guint signal_id, GQuark detail, GValue *return_value);
12 | extern void g_signal_emit_valist(gpointer instance,guint signal_id, GQuark detail, va_list var_args);
13 | extern gulong g_signal_connect_object(gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer gobject, GConnectFlags connect_flags);
14 | extern gulong g_signal_connect_data(gpointer instance, const gchar *detailed_signal, GCallback c_handler, gpointer data, GClosureNotify destroy_data, GConnectFlags connect_flags);
15 | extern gulong g_signal_connect_closure(gpointer instance, const gchar *detailed_signal, GClosure *closure, gboolean after);
16 | extern gulong g_signal_connect_closure_by_id(gpointer instance, guint signal_id, GQuark detail, GClosure *closure, gboolean after);
17 | extern void g_signal_handler_block(gpointer instance, gulong handler_id);
18 | extern void g_signal_handler_unblock(gpointer instance, gulong handler_id);
19 | extern void g_signal_handler_disconnect(gpointer instance, gulong handler_id);
20 | extern gulong g_signal_handler_find(gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
21 | extern guint g_signal_handlers_block_matched(gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
22 | extern guint g_signal_handlers_unblock_matched(gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
23 | extern guint g_signal_handlers_disconnect_matched(gpointer instance, GSignalMatchType mask, guint signal_id, GQuark detail, GClosure *closure, gpointer func, gpointer data);
24 | extern gboolean g_signal_handler_is_connected(gpointer instance, gulong handler_id);
25 | extern gboolean g_signal_has_handler_pending(gpointer instance, guint signal_id, GQuark detail, gboolean may_be_blocked);
26 | extern void g_signal_stop_emission(gpointer instance, guint signal_id, GQuark detail);
27 | extern void g_signal_stop_emission_by_name(gpointer instance, const gchar *detailed_signal);
28 | extern void g_signal_override_class_closure(guint signal_id, GType instance_type, GClosure *class_closure);
29 | extern void g_signal_chain_from_overridden(const GValue *instance_and_params, GValue *return_value);
30 | extern guint g_signal_new_class_handler(const gchar *signal_name, GType itype, GSignalFlags signal_flags, GCallback class_handler, GSignalAccumulator accumulator, gpointer accu_data, GSignalCMarshaller c_marshaller, GType return_type, guint n_params, ...);
31 | extern void g_signal_override_class_handler (const gchar *signal_name, GType instance_type, GCallback class_handler);
32 | extern void g_signal_chain_from_overridden_handler (gpointer instance, ...);
33 | extern gulong g_signal_add_emission_hook (guint signal_id, GQuark detail, GSignalEmissionHook hook_func, gpointer hook_data, GDestroyNotify data_destroy);
34 | extern void g_signal_remove_emission_hook(guint signal_id, gulong hook_id);
35 | extern gboolean g_signal_parse_name(const gchar *detailed_signal, GType itype, guint *signal_id_p, GQuark *detail_p, gboolean force_detail_quark);
36 | extern GSignalInvocationHint* g_signal_get_invocation_hint(gpointer instance);
37 | extern GClosure* g_signal_type_cclosure_new(GType itype, guint struct_offset);
38 | extern gboolean g_signal_accumulator_first_wins (GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy);
39 | extern gboolean g_signal_accumulator_true_handled(GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy);
40 | extern void g_clear_signal_handler (gulong *handler_id_ptr, gpointer instance);
--------------------------------------------------------------------------------
/example/c/style/main.glade:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | False
7 |
8 |
9 |
10 |
11 |
12 | True
13 | False
14 | True
15 | True
16 |
17 |
18 | True
19 | False
20 | True
21 |
22 |
23 | 0
24 | 0
25 |
26 |
27 |
28 |
29 | True
30 | False
31 | label
32 |
33 |
34 | 1
35 | 0
36 |
37 |
38 |
39 |
40 | button
41 | True
42 | True
43 | True
44 |
45 |
46 | 2
47 | 0
48 |
49 |
50 |
51 |
52 | togglebutton
53 | True
54 | True
55 | True
56 |
57 |
58 | 1
59 | 1
60 |
61 |
62 |
63 |
64 | True
65 | True
66 |
67 |
68 | 2
69 | 1
70 |
71 |
72 |
73 |
74 | button
75 | True
76 | True
77 | True
78 |
79 |
80 | 0
81 | 1
82 |
83 |
84 |
85 |
86 | True
87 | False
88 | label
89 |
90 |
91 | 1
92 | 2
93 |
94 |
95 |
96 |
97 | True
98 | True
99 |
100 |
101 | 2
102 | 2
103 |
104 |
105 |
106 |
107 | button
108 | True
109 | True
110 | True
111 |
112 |
113 | 0
114 | 2
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/example/php/style/main.glade:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | False
7 |
8 |
9 |
10 |
11 |
12 | True
13 | False
14 | True
15 | True
16 |
17 |
18 | True
19 | False
20 | True
21 |
22 |
23 | 0
24 | 0
25 |
26 |
27 |
28 |
29 | True
30 | False
31 | label
32 |
33 |
34 | 1
35 | 0
36 |
37 |
38 |
39 |
40 | button
41 | True
42 | True
43 | True
44 |
45 |
46 | 2
47 | 0
48 |
49 |
50 |
51 |
52 | togglebutton
53 | True
54 | True
55 | True
56 |
57 |
58 | 1
59 | 1
60 |
61 |
62 |
63 |
64 | True
65 | True
66 |
67 |
68 | 2
69 | 1
70 |
71 |
72 |
73 |
74 | button
75 | True
76 | True
77 | True
78 |
79 |
80 | 0
81 | 1
82 |
83 |
84 |
85 |
86 | True
87 | False
88 | label
89 |
90 |
91 | 1
92 | 2
93 |
94 |
95 |
96 |
97 | True
98 | True
99 |
100 |
101 | 2
102 | 2
103 |
104 |
105 |
106 |
107 | button
108 | True
109 | True
110 | True
111 |
112 |
113 | 0
114 | 2
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/example/c/custom-widget/resources.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #if defined (__ELF__) && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6))
4 | # define SECTION __attribute__ ((section (".gresource.resources"), aligned (8)))
5 | #else
6 | # define SECTION
7 | #endif
8 |
9 | #ifdef _MSC_VER
10 | static const SECTION union { const guint8 data[713]; const double alignment; void * const ptr;} resources_resource_data = { {
11 | 0107, 0126, 0141, 0162, 0151, 0141, 0156, 0164, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
12 | 0030, 0000, 0000, 0000, 0254, 0000, 0000, 0000, 0000, 0000, 0000, 0050, 0005, 0000, 0000, 0000,
13 | 0000, 0000, 0000, 0000, 0001, 0000, 0000, 0000, 0002, 0000, 0000, 0000, 0002, 0000, 0000, 0000,
14 | 0002, 0000, 0000, 0000, 0324, 0265, 0002, 0000, 0377, 0377, 0377, 0377, 0254, 0000, 0000, 0000,
15 | 0001, 0000, 0114, 0000, 0260, 0000, 0000, 0000, 0264, 0000, 0000, 0000, 0127, 0314, 0251, 0126,
16 | 0004, 0000, 0000, 0000, 0264, 0000, 0000, 0000, 0024, 0000, 0166, 0000, 0310, 0000, 0000, 0000,
17 | 0236, 0002, 0000, 0000, 0367, 0166, 0223, 0153, 0003, 0000, 0000, 0000, 0236, 0002, 0000, 0000,
18 | 0011, 0000, 0114, 0000, 0250, 0002, 0000, 0000, 0254, 0002, 0000, 0000, 0111, 0366, 0213, 0013,
19 | 0000, 0000, 0000, 0000, 0254, 0002, 0000, 0000, 0004, 0000, 0114, 0000, 0260, 0002, 0000, 0000,
20 | 0264, 0002, 0000, 0000, 0262, 0270, 0236, 0150, 0002, 0000, 0000, 0000, 0264, 0002, 0000, 0000,
21 | 0016, 0000, 0114, 0000, 0304, 0002, 0000, 0000, 0310, 0002, 0000, 0000, 0057, 0000, 0000, 0000,
22 | 0003, 0000, 0000, 0000, 0107, 0164, 0153, 0114, 0151, 0163, 0164, 0102, 0157, 0170, 0111, 0164,
23 | 0145, 0155, 0056, 0147, 0154, 0141, 0144, 0145, 0361, 0010, 0000, 0000, 0001, 0000, 0000, 0000,
24 | 0170, 0332, 0315, 0126, 0115, 0157, 0333, 0060, 0014, 0275, 0347, 0127, 0010, 0274, 0016, 0253,
25 | 0223, 0145, 0030, 0172, 0160, 0134, 0140, 0207, 0026, 0003, 0172, 0032, 0272, 0263, 0041, 0113,
26 | 0114, 0302, 0105, 0226, 0074, 0211, 0151, 0323, 0177, 0077, 0305, 0201, 0267, 0174, 0250, 0151,
27 | 0354, 0026, 0303, 0156, 0264, 0304, 0047, 0362, 0221, 0174, 0262, 0362, 0233, 0115, 0155, 0304,
28 | 0043, 0372, 0100, 0316, 0316, 0140, 0162, 0065, 0006, 0201, 0126, 0071, 0115, 0166, 0061, 0203,
29 | 0037, 0017, 0267, 0037, 0257, 0341, 0246, 0030, 0345, 0144, 0031, 0375, 0134, 0052, 0024, 0332,
30 | 0325, 0222, 0242, 0353, 0202, 0127, 0323, 0061, 0024, 0043, 0041, 0162, 0217, 0277, 0326, 0344,
31 | 0061, 0010, 0103, 0125, 0273, 0361, 0001, 0376, 0036, 0071, 0275, 0232, 0214, 0041, 0153, 0375,
32 | 0030, 0353, 0306, 0110, 0106, 0241, 0214, 0014, 0141, 0006, 0167, 0274, 0272, 0247, 0300, 0137,
33 | 0335, 0346, 0133, 0334, 0002, 0321, 0110, 0217, 0226, 0367, 0327, 0277, 0273, 0247, 0066, 0104,
34 | 0004, 0067, 0336, 0065, 0350, 0371, 0131, 0130, 0131, 0343, 0014, 0224, 0264, 0345, 0334, 0251,
35 | 0165, 0200, 0342, 0126, 0232, 0200, 0171, 0326, 0071, 0244, 0375, 0053, 0347, 0065, 0372, 0362,
36 | 0211, 0064, 0057, 0241, 0230, 0174, 0071, 0361, 0127, 0113, 0062, 0172, 0147, 0307, 0057, 0127,
37 | 0375, 0104, 0305, 0173, 0211, 0336, 0171, 0322, 0040, 0110, 0107, 0176, 0133, 0253, 0163, 0074,
38 | 0015, 0364, 0110, 0201, 0052, 0203, 0120, 0074, 0370, 0365, 0111, 0126, 0103, 0230, 0244, 0060,
39 | 0265, 0364, 0013, 0262, 0045, 0273, 0006, 0212, 0317, 0075, 0000, 0225, 0143, 0166, 0365, 0205,
40 | 0230, 0045, 0156, 0032, 0151, 0365, 0031, 0046, 0007, 0065, 0113, 0327, 0355, 0136, 0126, 0150,
41 | 0166, 0205, 0063, 0133, 0263, 0264, 0016, 0366, 0021, 0247, 0141, 0333, 0026, 0225, 0333, 0231,
42 | 0302, 0300, 0120, 0114, 0077, 0245, 0102, 0017, 0252, 0374, 0320, 0352, 0237, 0051, 0250, 0301,
43 | 0171, 0314, 0361, 0272, 0047, 0312, 0323, 0142, 0071, 0000, 0326, 0266, 0273, 0057, 0250, 0153,
44 | 0371, 0013, 0270, 0074, 0333, 0265, 0354, 0140, 0255, 0221, 0152, 0025, 0057, 0200, 0363, 0347,
45 | 0157, 0251, 0227, 0222, 0131, 0252, 0050, 0250, 0361, 0245, 0131, 0105, 0016, 0257, 0201, 0342,
46 | 0352, 0161, 0374, 0074, 0073, 0032, 0265, 0113, 0106, 0057, 0336, 0037, 0273, 0301, 0253, 0242,
47 | 0361, 0037, 0215, 0316, 0253, 0272, 0112, 0023, 0274, 0120, 0137, 0225, 0323, 0317, 0160, 0214,
48 | 0033, 0310, 0370, 0055, 0254, 0207, 0213, 0346, 0015, 0302, 0031, 0134, 0356, 0264, 0020, 0136,
49 | 0026, 0103, 0052, 0120, 0027, 0247, 0167, 0131, 0346, 0144, 0114, 0377, 0106, 0064, 0056, 0020,
50 | 0307, 0137, 0354, 0031, 0361, 0045, 0265, 0224, 0324, 0323, 0273, 0135, 0004, 0223, 0177, 0172,
51 | 0021, 0034, 0046, 0275, 0267, 0231, 0147, 0335, 0143, 0043, 0076, 0136, 0262, 0077, 0257, 0227,
52 | 0142, 0364, 0033, 0334, 0313, 0250, 0100, 0000, 0050, 0165, 0165, 0141, 0171, 0051, 0145, 0170,
53 | 0141, 0155, 0160, 0154, 0145, 0163, 0057, 0000, 0004, 0000, 0000, 0000, 0147, 0164, 0153, 0057,
54 | 0002, 0000, 0000, 0000, 0143, 0165, 0163, 0164, 0157, 0155, 0055, 0167, 0151, 0144, 0147, 0145,
55 | 0164, 0057, 0000, 0000, 0001, 0000, 0000, 0000
56 | } };
57 | #else /* _MSC_VER */
58 | static const SECTION union { const guint8 data[713]; const double alignment; void * const ptr;} resources_resource_data = {
59 | "\107\126\141\162\151\141\156\164\000\000\000\000\000\000\000\000"
60 | "\030\000\000\000\254\000\000\000\000\000\000\050\005\000\000\000"
61 | "\000\000\000\000\001\000\000\000\002\000\000\000\002\000\000\000"
62 | "\002\000\000\000\324\265\002\000\377\377\377\377\254\000\000\000"
63 | "\001\000\114\000\260\000\000\000\264\000\000\000\127\314\251\126"
64 | "\004\000\000\000\264\000\000\000\024\000\166\000\310\000\000\000"
65 | "\236\002\000\000\367\166\223\153\003\000\000\000\236\002\000\000"
66 | "\011\000\114\000\250\002\000\000\254\002\000\000\111\366\213\013"
67 | "\000\000\000\000\254\002\000\000\004\000\114\000\260\002\000\000"
68 | "\264\002\000\000\262\270\236\150\002\000\000\000\264\002\000\000"
69 | "\016\000\114\000\304\002\000\000\310\002\000\000\057\000\000\000"
70 | "\003\000\000\000\107\164\153\114\151\163\164\102\157\170\111\164"
71 | "\145\155\056\147\154\141\144\145\361\010\000\000\001\000\000\000"
72 | "\170\332\315\126\115\157\333\060\014\275\347\127\010\274\016\253"
73 | "\223\145\030\172\160\134\140\207\026\003\172\032\272\263\041\113"
74 | "\114\302\105\226\074\211\151\323\177\077\305\201\267\174\250\151"
75 | "\354\026\303\156\264\304\047\362\221\174\262\362\233\115\155\304"
76 | "\043\372\100\316\316\140\162\065\006\201\126\071\115\166\061\203"
77 | "\037\017\267\037\257\341\246\030\345\144\031\375\134\052\024\332"
78 | "\325\222\242\353\202\127\323\061\024\043\041\162\217\277\326\344"
79 | "\061\010\103\125\273\361\001\376\036\071\275\232\214\041\153\375"
80 | "\030\353\306\110\106\241\214\014\141\006\167\274\272\247\300\137"
81 | "\335\346\133\334\002\321\110\217\226\367\327\277\273\247\066\104"
82 | "\004\067\336\065\350\371\131\130\131\343\014\224\264\345\334\251"
83 | "\165\200\342\126\232\200\171\326\071\244\375\053\347\065\372\362"
84 | "\211\064\057\241\230\174\071\361\127\113\062\172\147\307\057\127"
85 | "\375\104\305\173\211\336\171\322\040\110\107\176\133\253\163\074"
86 | "\015\364\110\201\052\203\120\074\370\365\111\126\103\230\244\060"
87 | "\265\364\013\262\045\273\006\212\317\075\000\225\143\166\365\205"
88 | "\230\045\156\032\151\365\031\046\007\065\113\327\355\136\126\150"
89 | "\166\205\063\133\263\264\016\366\021\247\141\333\026\225\333\231"
90 | "\302\300\120\114\077\245\102\017\252\374\320\352\237\051\250\301"
91 | "\171\314\361\272\047\312\323\142\071\000\326\266\273\057\250\153"
92 | "\371\013\270\074\333\265\354\140\255\221\152\025\057\200\363\347"
93 | "\157\251\227\222\131\252\050\250\361\245\131\105\016\257\201\342"
94 | "\352\161\374\074\073\032\265\113\106\057\336\037\273\301\253\242"
95 | "\361\037\215\316\253\272\112\023\274\120\137\225\323\317\160\214"
96 | "\033\310\370\055\254\207\213\346\015\302\031\134\356\264\020\136"
97 | "\026\103\052\120\027\247\167\131\346\144\114\377\106\064\056\020"
98 | "\307\137\354\031\361\045\265\224\324\323\273\135\004\223\177\172"
99 | "\021\034\046\275\267\231\147\335\143\043\076\136\262\077\257\227"
100 | "\142\364\033\334\313\250\100\000\050\165\165\141\171\051\145\170"
101 | "\141\155\160\154\145\163\057\000\004\000\000\000\147\164\153\057"
102 | "\002\000\000\000\143\165\163\164\157\155\055\167\151\144\147\145"
103 | "\164\057\000\000\001\000\000\000" };
104 | #endif /* !_MSC_VER */
105 |
106 | static GStaticResource static_resource = { resources_resource_data.data, sizeof (resources_resource_data.data) - 1 /* nul terminator */, NULL, NULL, NULL };
107 | extern GResource *resources_get_resource (void);
108 | GResource *resources_get_resource (void)
109 | {
110 | return g_static_resource_get_resource (&static_resource);
111 | }
112 | /*
113 | If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and
114 | destructors, in a sane way, including e.g. on library unload. If not you're on
115 | your own.
116 |
117 | Some compilers need #pragma to handle this, which does not work with macros,
118 | so the way you need to use this is (for constructors):
119 |
120 | #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
121 | #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(my_constructor)
122 | #endif
123 | G_DEFINE_CONSTRUCTOR(my_constructor)
124 | static void my_constructor(void) {
125 | ...
126 | }
127 |
128 | */
129 |
130 | #ifndef __GTK_DOC_IGNORE__
131 |
132 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
133 |
134 | #define G_HAS_CONSTRUCTORS 1
135 |
136 | #define G_DEFINE_CONSTRUCTOR(_func) static void __attribute__((constructor)) _func (void);
137 | #define G_DEFINE_DESTRUCTOR(_func) static void __attribute__((destructor)) _func (void);
138 |
139 | #elif defined (_MSC_VER) && (_MSC_VER >= 1500)
140 | /* Visual studio 2008 and later has _Pragma */
141 |
142 | #include
143 |
144 | #define G_HAS_CONSTRUCTORS 1
145 |
146 | /* We do some weird things to avoid the constructors being optimized
147 | * away on VS2015 if WholeProgramOptimization is enabled. First we
148 | * make a reference to the array from the wrapper to make sure its
149 | * references. Then we use a pragma to make sure the wrapper function
150 | * symbol is always included at the link stage. Also, the symbols
151 | * need to be extern (but not dllexport), even though they are not
152 | * really used from another object file.
153 | */
154 |
155 | /* We need to account for differences between the mangling of symbols
156 | * for Win32 (x86) and x64 programs, as symbols on Win32 are prefixed
157 | * with an underscore but symbols on x64 are not.
158 | */
159 | #ifdef _WIN64
160 | #define G_MSVC_SYMBOL_PREFIX ""
161 | #else
162 | #define G_MSVC_SYMBOL_PREFIX "_"
163 | #endif
164 |
165 | #define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
166 | #define G_DEFINE_DESTRUCTOR(_func) G_MSVC_DTOR (_func, G_MSVC_SYMBOL_PREFIX)
167 |
168 | #define G_MSVC_CTOR(_func,_sym_prefix) \
169 | static void _func(void); \
170 | extern int (* _array ## _func)(void); \
171 | int _func ## _wrapper(void) { _func(); g_slist_find (NULL, _array ## _func); return 0; } \
172 | __pragma(comment(linker,"/include:" _sym_prefix # _func "_wrapper")) \
173 | __pragma(section(".CRT$XCU",read)) \
174 | __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _wrapper;
175 |
176 | #define G_MSVC_DTOR(_func,_sym_prefix) \
177 | static void _func(void); \
178 | extern int (* _array ## _func)(void); \
179 | int _func ## _constructor(void) { atexit (_func); g_slist_find (NULL, _array ## _func); return 0; } \
180 | __pragma(comment(linker,"/include:" _sym_prefix # _func "_constructor")) \
181 | __pragma(section(".CRT$XCU",read)) \
182 | __declspec(allocate(".CRT$XCU")) int (* _array ## _func)(void) = _func ## _constructor;
183 |
184 | #elif defined (_MSC_VER)
185 |
186 | #define G_HAS_CONSTRUCTORS 1
187 |
188 | /* Pre Visual studio 2008 must use #pragma section */
189 | #define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
190 | #define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
191 |
192 | #define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
193 | section(".CRT$XCU",read)
194 | #define G_DEFINE_CONSTRUCTOR(_func) \
195 | static void _func(void); \
196 | static int _func ## _wrapper(void) { _func(); return 0; } \
197 | __declspec(allocate(".CRT$XCU")) static int (*p)(void) = _func ## _wrapper;
198 |
199 | #define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
200 | section(".CRT$XCU",read)
201 | #define G_DEFINE_DESTRUCTOR(_func) \
202 | static void _func(void); \
203 | static int _func ## _constructor(void) { atexit (_func); return 0; } \
204 | __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
205 |
206 | #elif defined(__SUNPRO_C)
207 |
208 | /* This is not tested, but i believe it should work, based on:
209 | * http://opensource.apple.com/source/OpenSSL098/OpenSSL098-35/src/fips/fips_premain.c
210 | */
211 |
212 | #define G_HAS_CONSTRUCTORS 1
213 |
214 | #define G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA 1
215 | #define G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA 1
216 |
217 | #define G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(_func) \
218 | init(_func)
219 | #define G_DEFINE_CONSTRUCTOR(_func) \
220 | static void _func(void);
221 |
222 | #define G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(_func) \
223 | fini(_func)
224 | #define G_DEFINE_DESTRUCTOR(_func) \
225 | static void _func(void);
226 |
227 | #else
228 |
229 | /* constructors not supported for this compiler */
230 |
231 | #endif
232 |
233 | #endif /* __GTK_DOC_IGNORE__ */
234 |
235 | #ifdef G_HAS_CONSTRUCTORS
236 |
237 | #ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
238 | #pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(resource_constructor)
239 | #endif
240 | G_DEFINE_CONSTRUCTOR(resource_constructor)
241 | #ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
242 | #pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(resource_destructor)
243 | #endif
244 | G_DEFINE_DESTRUCTOR(resource_destructor)
245 |
246 | #else
247 | #warning "Constructor not supported on this compiler, linking in resources will not work"
248 | #endif
249 |
250 | static void resource_constructor (void)
251 | {
252 | g_static_resource_init (&static_resource);
253 | }
254 |
255 | static void resource_destructor (void)
256 | {
257 | g_static_resource_fini (&static_resource);
258 | }
259 |
--------------------------------------------------------------------------------
/resources/GtkWidget.h:
--------------------------------------------------------------------------------
1 | extern GtkWidget* gtk_widget_new(GType type, const gchar *first_property_name, ...);
2 | extern void gtk_widget_destroy(GtkWidget *widget);
3 | extern gboolean gtk_widget_in_destruction(GtkWidget *widget);
4 | extern void gtk_widget_destroyed(GtkWidget *widget, GtkWidget **widget_pointer);
5 | extern void gtk_widget_unparent(GtkWidget *widget);
6 | extern void gtk_widget_show(GtkWidget *widget);
7 | extern void gtk_widget_show_now(GtkWidget *widget);
8 | extern void gtk_widget_hide(GtkWidget *widget);
9 | extern void gtk_widget_show_all(GtkWidget *widget);
10 | extern void gtk_widget_map(GtkWidget *widget);
11 | extern void gtk_widget_unmap(GtkWidget *widget);
12 | extern void gtk_widget_realize(GtkWidget *widget);
13 | extern void gtk_widget_unrealize(GtkWidget *widget);
14 | extern void gtk_widget_draw(GtkWidget *widget, cairo_t *cr);
15 | extern void gtk_widget_queue_draw(GtkWidget *widget);
16 | extern void gtk_widget_queue_resize(GtkWidget *widget);
17 | extern void gtk_widget_queue_resize_no_redraw(GtkWidget *widget);
18 | extern void gtk_widget_queue_allocate(GtkWidget *widget);
19 | extern GdkFrameClock* gtk_widget_get_frame_clock(GtkWidget *widget);
20 | extern gint gtk_widget_get_scale_factor(GtkWidget *widget);
21 | extern gboolean (*GtkTickCallback)(GtkWidget *widget, GdkFrameClock *frame_clock, gpointer user_data);
22 | extern guint gtk_widget_add_tick_callback(GtkWidget *widget, GtkTickCallback callback, gpointer user_data, GDestroyNotify notify);
23 | extern void gtk_widget_remove_tick_callback(GtkWidget *widget, guint id);
24 | extern void gtk_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
25 | extern void gtk_widget_size_allocate_with_baseline (GtkWidget *widget, GtkAllocation *allocation, gint baseline);
26 | extern void gtk_widget_add_accelerator(GtkWidget *widget, const gchar *accel_signal, GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods, GtkAccelFlags accel_flags);
27 | extern gboolean gtk_widget_remove_accelerator(GtkWidget *widget, GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods);
28 | extern void gtk_widget_set_accel_path(GtkWidget *widget, const gchar *accel_path, GtkAccelGroup *accel_group);
29 | extern GList* gtk_widget_list_accel_closures(GtkWidget *widget);
30 | extern gboolean gtk_widget_can_activate_accel(GtkWidget *widget, guint signal_id);
31 | extern gboolean gtk_widget_event(GtkWidget *widget, GdkEvent *event);
32 | extern gboolean gtk_widget_activate(GtkWidget *widget);
33 | extern void gtk_widget_reparent(GtkWidget *widget, GtkWidget *new_parent);
34 | extern gboolean gtk_widget_intersect(GtkWidget *widget, const GdkRectangle *area, GdkRectangle *intersection);
35 | extern gboolean gtk_widget_is_focus(GtkWidget *widget);
36 | extern void gtk_widget_grab_focus(GtkWidget *widget);
37 | extern void gtk_widget_grab_default(GtkWidget *widget);
38 | extern void gtk_widget_set_name(GtkWidget *widget, const gchar *name);
39 | extern const gchar* gtk_widget_get_name(GtkWidget *widget);
40 | extern void gtk_widget_set_sensitive(GtkWidget *widget, gboolean sensitive);
41 | extern void gtk_widget_set_parent(GtkWidget *widget, GtkWidget *parent);
42 | extern void gtk_widget_set_parent_window(GtkWidget *widget, GdkWindow *parent_window);
43 | extern GdkWindow* gtk_widget_get_parent_window(GtkWidget *widget);
44 | extern void gtk_widget_set_events(GtkWidget *widget, gint events);
45 | extern gint gtk_widget_get_events(GtkWidget *widget);
46 | extern void gtk_widget_add_events(GtkWidget *widget, gint events);
47 | extern void gtk_widget_set_device_events (GtkWidget *widget, GdkDevice *device, GdkEventMask events);
48 | extern GdkEventMask gtk_widget_get_device_events(GtkWidget *widget, GdkDevice *device);
49 | extern void gtk_widget_add_device_events(GtkWidget *widget, GdkDevice *device, GdkEventMask events);
50 | extern void gtk_widget_set_device_enabled (GtkWidget *widget, GdkDevice *device, gboolean enabled);
51 | extern gboolean gtk_widget_get_device_enabled(GtkWidget *widget, GdkDevice *device);
52 | extern GtkWidget* gtk_widget_get_toplevel(GtkWidget *widget);
53 | extern GtkWidget* gtk_widget_get_ancestor(GtkWidget *widget, GType widget_type);
54 | extern GdkVisual* gtk_widget_get_visual(GtkWidget *widget);
55 | extern void gtk_widget_set_visual(GtkWidget *widget, GdkVisual *visual);
56 | extern gboolean gtk_widget_is_ancestor(GtkWidget *widget, GtkWidget *ancestor);
57 | extern gboolean gtk_widget_translate_coordinates(GtkWidget *src_widget, GtkWidget *dest_widget, gint src_x, gint src_y, gint *dest_x, gint *dest_y);
58 | extern gboolean gtk_widget_hide_on_delete(GtkWidget *widget);
59 | extern void gtk_widget_set_direction(GtkWidget *widget, GtkTextDirection dir);
60 | extern GtkTextDirection gtk_widget_get_direction(GtkWidget *widget);
61 | extern void gtk_widget_set_default_direction(GtkTextDirection dir);
62 | extern GtkTextDirection gtk_widget_get_default_direction(void);
63 | extern void gtk_widget_shape_combine_region(GtkWidget *widget, cairo_region_t *region);
64 | extern void gtk_widget_input_shape_combine_region(GtkWidget *widget, cairo_region_t *region);
65 | extern PangoContext* gtk_widget_create_pango_context(GtkWidget *widget);
66 | extern PangoContext* gtk_widget_get_pango_context(GtkWidget *widget);
67 | extern void gtk_widget_set_font_options(GtkWidget *widget, const cairo_font_options_t *options);
68 | extern const cairo_font_options_t* gtk_widget_get_font_options(GtkWidget *widget);
69 | extern void gtk_widget_set_font_map(GtkWidget *widget, PangoFontMap *font_map);
70 | extern PangoFontMap* gtk_widget_get_font_map(GtkWidget *widget);
71 | extern PangoLayout* gtk_widget_create_pango_layout(GtkWidget *widget, const gchar *text);
72 | extern void gtk_widget_queue_draw_area(GtkWidget *widget, gint x, gint y, gint width, gint height);
73 | extern void gtk_widget_queue_draw_region(GtkWidget *widget, const cairo_region_t *region);
74 | extern void gtk_widget_set_app_paintable(GtkWidget *widget, gboolean app_paintable);
75 | extern void gtk_widget_set_redraw_on_allocate(GtkWidget *widget, gboolean redraw_on_allocate);
76 | extern gboolean gtk_widget_mnemonic_activate(GtkWidget *widget, gboolean group_cycling);
77 | extern void gtk_widget_class_install_style_property(GtkWidgetClass *klass, GParamSpec *pspec);
78 | extern void gtk_widget_class_install_style_property_parser(GtkWidgetClass *klass, GParamSpec *pspec, GtkRcPropertyParser parser);
79 | extern GParamSpec* gtk_widget_class_find_style_property(GtkWidgetClass *klass, const gchar *property_name);
80 | extern GParamSpec** gtk_widget_class_list_style_properties(GtkWidgetClass *klass, guint *n_properties);
81 | extern gboolean gtk_widget_send_focus_change(GtkWidget *widget, GdkEvent *event);
82 | extern void gtk_widget_style_get (GtkWidget *widget, const gchar *first_property_name, ...);
83 | extern void gtk_widget_style_get_property(GtkWidget *widget, const gchar *property_name, GValue *value);
84 | extern void gtk_widget_style_get_valist(GtkWidget *widget, const gchar *first_property_name, va_list var_args);
85 | extern void gtk_widget_class_set_accessible_type(GtkWidgetClass *widget_class, GType type);
86 | extern void gtk_widget_class_set_accessible_role(GtkWidgetClass *widget_class, AtkRole role);
87 | extern AtkObject * gtk_widget_get_accessible(GtkWidget *widget);
88 | extern gboolean gtk_widget_child_focus(GtkWidget *widget, GtkDirectionType direction);
89 | extern void gtk_widget_child_notify (GtkWidget *widget, const gchar *child_property);
90 | extern void gtk_widget_freeze_child_notify(GtkWidget *widget);
91 | extern gboolean gtk_widget_get_child_visible(GtkWidget *widget);
92 | extern GtkWidget* gtk_widget_get_parent(GtkWidget *widget);
93 | extern GtkSettings* gtk_widget_get_settings(GtkWidget *widget);
94 | extern GtkClipboard * gtk_widget_get_clipboard(GtkWidget *widget, GdkAtom selection);
95 | extern GdkDisplay* gtk_widget_get_display(GtkWidget *widget);
96 | extern GdkScreen* gtk_widget_get_screen(GtkWidget *widget);
97 | extern gboolean gtk_widget_has_screen(GtkWidget *widget);
98 | extern void gtk_widget_get_size_request(GtkWidget *widget, gint *width, gint *height);
99 | extern void gtk_widget_set_child_visible(GtkWidget *widget, gboolean is_visible);
100 | extern void gtk_widget_set_size_request(GtkWidget *widget, gint width, gint height);
101 | extern void gtk_widget_thaw_child_notify (GtkWidget *widget);
102 | extern void gtk_widget_set_no_show_all (GtkWidget *widget, gboolean no_show_all);
103 | extern gboolean gtk_widget_get_no_show_all(GtkWidget *widget);
104 | extern GList * gtk_widget_list_mnemonic_labels(GtkWidget *widget);
105 | extern void gtk_widget_add_mnemonic_label(GtkWidget *widget, GtkWidget *label);
106 | extern void gtk_widget_remove_mnemonic_label(GtkWidget *widget, GtkWidget *label);
107 | extern void gtk_widget_error_bell(GtkWidget *widget);
108 | extern gboolean gtk_widget_keynav_failed(GtkWidget *widget, GtkDirectionType direction);
109 | extern gchar * gtk_widget_get_tooltip_markup(GtkWidget *widget);
110 | extern void gtk_widget_set_tooltip_markup(GtkWidget *widget, const gchar *markup);
111 | extern gchar * gtk_widget_get_tooltip_text(GtkWidget *widget);
112 | extern void gtk_widget_set_tooltip_text(GtkWidget *widget, const gchar *text);
113 | extern GtkWindow* gtk_widget_get_tooltip_window(GtkWidget *widget);
114 | extern void gtk_widget_set_tooltip_window(GtkWidget *widget, GtkWindow *custom_window);
115 | extern gboolean gtk_widget_get_has_tooltip(GtkWidget *widget);
116 | extern void gtk_widget_set_has_tooltip(GtkWidget *widget, gboolean has_tooltip);
117 | extern void gtk_widget_trigger_tooltip_query(GtkWidget *widget);
118 | extern GdkWindow* gtk_widget_get_window(GtkWidget *widget);
119 | extern void gtk_widget_register_window(GtkWidget *widget, GdkWindow *window);
120 | extern void gtk_widget_unregister_window(GtkWidget *widget, GdkWindow *window);
121 | extern gboolean gtk_cairo_should_draw_window(cairo_t *cr, GdkWindow *window);
122 | extern void gtk_cairo_transform_to_window(cairo_t *cr, GtkWidget *widget, GdkWindow *window);
123 | extern int gtk_widget_get_allocated_width(GtkWidget *widget);
124 | extern int gtk_widget_get_allocated_height(GtkWidget *widget);
125 | extern void gtk_widget_get_allocation(GtkWidget *widget, GtkAllocation *allocation);
126 | extern void gtk_widget_set_allocation(GtkWidget *widget, const GtkAllocation *allocation);
127 | extern int gtk_widget_get_allocated_baseline(GtkWidget *widget);
128 | extern void gtk_widget_get_allocated_size(GtkWidget *widget, GtkAllocation *allocation, int *baseline);
129 | extern void gtk_widget_get_clip(GtkWidget *widget, GtkAllocation *clip);
130 | extern void gtk_widget_set_clip(GtkWidget *widget, const GtkAllocation *clip);
131 | extern gboolean gtk_widget_get_app_paintable(GtkWidget *widget);
132 | extern gboolean gtk_widget_get_can_default(GtkWidget *widget);
133 | extern void gtk_widget_set_can_default(GtkWidget *widget, gboolean can_default);
134 | extern gboolean gtk_widget_get_can_focus(GtkWidget *widget);
135 | extern void gtk_widget_set_can_focus(GtkWidget *widget, gboolean can_focus);
136 | extern gboolean gtk_widget_get_focus_on_click(GtkWidget *widget);
137 | extern void gtk_widget_set_focus_on_click(GtkWidget *widget, gboolean focus_on_click);
138 | extern gboolean gtk_widget_get_has_window(GtkWidget *widget);
139 | extern void gtk_widget_set_has_window(GtkWidget *widget, gboolean has_window);
140 | extern gboolean gtk_widget_get_sensitive(GtkWidget *widget);
141 | extern gboolean gtk_widget_get_sensitive(GtkWidget *widget);
142 | extern gboolean gtk_widget_is_sensitive(GtkWidget *widget);
143 | extern gboolean gtk_widget_get_visible(GtkWidget *widget);
144 | extern gboolean gtk_widget_is_visible(GtkWidget *widget);
145 | extern void gtk_widget_set_visible(GtkWidget *widget, gboolean visible);
146 | extern void gtk_widget_set_state_flags(GtkWidget *widget, GtkStateFlags flags, gboolean clear);
147 | extern void gtk_widget_unset_state_flags(GtkWidget *widget, GtkStateFlags flags);
148 | extern GtkStateFlags gtk_widget_get_state_flags(GtkWidget *widget);
149 | extern gboolean gtk_widget_has_default(GtkWidget *widget);
150 | extern gboolean gtk_widget_has_focus(GtkWidget *widget);
151 | extern gboolean gtk_widget_has_visible_focus (GtkWidget *widget);
152 | extern gboolean gtk_widget_has_grab(GtkWidget *widget);
153 | extern gboolean gtk_widget_is_drawable(GtkWidget *widget);
154 | extern gboolean gtk_widget_is_toplevel(GtkWidget *widget);
155 | extern void gtk_widget_set_window(GtkWidget *widget, GdkWindow *window);
156 | extern void gtk_widget_set_receives_default(GtkWidget *widget, gboolean receives_default);
157 | extern gboolean gtk_widget_get_receives_default(GtkWidget *widget);
158 | extern void gtk_widget_set_support_multidevice(GtkWidget *widget, gboolean support_multidevice);
159 | extern void gtk_widget_set_realized(GtkWidget *widget, gboolean realized);
160 | extern gboolean gtk_widget_get_realized(GtkWidget *widget);
161 | extern void gtk_widget_set_mapped(GtkWidget *widget, gboolean mapped);
162 | extern gboolean gtk_widget_get_mapped(GtkWidget *widget);
163 | extern gboolean gtk_widget_device_is_shadowed(GtkWidget *widget, GdkDevice *device);
164 | extern GdkModifierType gtk_widget_get_modifier_mask(GtkWidget *widget, GdkModifierIntent intent);
165 | extern void gtk_widget_insert_action_group (GtkWidget *widget, const gchar *name, GActionGroup *group);
166 | extern double gtk_widget_get_opacity(GtkWidget *widget);
167 | extern void gtk_widget_set_opacity(GtkWidget *widget, double opacity);
168 | extern const gchar** gtk_widget_list_action_prefixes(GtkWidget *widget);
169 | extern GActionGroup* gtk_widget_get_action_group(GtkWidget *widget, const gchar *prefix);
170 | extern GtkWidgetPath* gtk_widget_get_path(GtkWidget *widget);
171 | extern GtkStyleContext* gtk_widget_get_style_context(GtkWidget *widget);
172 | extern void gtk_widget_reset_style(GtkWidget *widget);
173 | extern const char* gtk_widget_class_get_css_name(GtkWidgetClass *widget_class);
174 | extern void gtk_widget_class_set_css_name(GtkWidgetClass *widget_class, const char *name);
175 | extern GtkRequisition* gtk_requisition_new(void);
176 | extern GtkRequisition* gtk_requisition_copy(const GtkRequisition *requisition);
177 | extern void gtk_requisition_free(GtkRequisition *requisition);
178 | extern void gtk_widget_get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height);
179 | extern void gtk_widget_get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_width);
180 | extern void gtk_widget_get_preferred_height_for_width(GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height);
181 | extern void gtk_widget_get_preferred_width_for_height(GtkWidget *widget, gint height, gint *minimum_width, gint *natural_width);
182 | extern void gtk_widget_get_preferred_height_and_baseline_for_width(GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height, gint *minimum_baseline, gint *natural_baseline);
183 | extern GtkSizeRequestMode gtk_widget_get_request_mode(GtkWidget *widget);
184 | extern void gtk_widget_get_preferred_size(GtkWidget *widget, GtkRequisition *minimum_size, GtkRequisition *natural_size);
185 | extern gint gtk_distribute_natural_allocation(gint extra_space, guint n_requested_sizes, GtkRequestedSize *sizes);
186 | extern GtkAlign gtk_widget_get_halign(GtkWidget *widget);
187 | extern void gtk_widget_set_halign(GtkWidget *widget, GtkAlign align);
188 | extern GtkAlign gtk_widget_get_valign(GtkWidget *widget);
189 | extern GtkAlign gtk_widget_get_valign_with_baseline(GtkWidget *widget);
190 | extern void gtk_widget_set_valign(GtkWidget *widget, GtkAlign align);
191 | extern gint gtk_widget_get_margin_start(GtkWidget *widget);
192 | extern void gtk_widget_set_margin_start(GtkWidget *widget, gint margin);
193 | extern gint gtk_widget_get_margin_end(GtkWidget *widget);
194 | extern void gtk_widget_set_margin_end(GtkWidget *widget, gint margin);
195 | extern gint gtk_widget_get_margin_top(GtkWidget *widget);
196 | extern void gtk_widget_set_margin_top(GtkWidget *widget, gint margin);
197 | extern gint gtk_widget_get_margin_bottom(GtkWidget *widget);
198 | extern void gtk_widget_set_margin_bottom(GtkWidget *widget, gint margin);
199 | extern gboolean gtk_widget_get_hexpand(GtkWidget *widget);
200 | extern void gtk_widget_set_hexpand(GtkWidget *widget, gboolean expand);
201 | extern gboolean gtk_widget_get_hexpand_set(GtkWidget *widget);
202 | extern void gtk_widget_set_hexpand_set(GtkWidget *widget, gboolean set);
203 | extern gboolean gtk_widget_get_vexpand(GtkWidget *widget);
204 | extern void gtk_widget_set_vexpand(GtkWidget *widget, gboolean expand);
205 | extern gboolean gtk_widget_get_vexpand_set(GtkWidget *widget);
206 | extern void gtk_widget_set_vexpand_set(GtkWidget *widget, gboolean set);
207 | extern void gtk_widget_queue_compute_expand(GtkWidget *widget);
208 | extern gboolean gtk_widget_compute_expand(GtkWidget *widget, GtkOrientation orientation);
209 | extern void gtk_widget_init_template(GtkWidget *widget);
210 | extern void gtk_widget_class_set_template(GtkWidgetClass *widget_class, GBytes *template_bytes);
211 | extern void gtk_widget_class_set_template_from_resource (GtkWidgetClass *widget_class, const gchar *resource_name);
212 | extern GObject* gtk_widget_get_template_child(GtkWidget *widget, GType widget_type, const gchar *name);
--------------------------------------------------------------------------------