From 75e3a2dfaf5602cc5507614d2fe379f885b4838c Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 12 Apr 2020 07:20:09 +0200 Subject: [PATCH] Add more stubs to the GWindow widget --- include/GToolkit/GWindow.h | 4 ++++ src/gwindow.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/GToolkit/GWindow.h b/include/GToolkit/GWindow.h index 1210455..09f26db 100644 --- a/include/GToolkit/GWindow.h +++ b/include/GToolkit/GWindow.h @@ -45,12 +45,16 @@ void gwindow_delete(GWindow * gwindow); /* accessors */ +bool gwindow_get_decorated(GWindow * gwindow); +bool gwindow_get_modal(GWindow * gwindow); bool gwindow_get_resizable(GWindow * gwindow); +void gwindow_get_size(GWindow * gwindow, int * width, int * height); char const * gwindow_get_title(GWindow * gwindow); void gwindow_set_resizable(GWindow * gwindow, bool resizable); void gwindow_set_title(GWindow * gwindow, char const * title); /* useful */ +void gwindow_resize(GWindow * gwindow, int width, int height); void gwindow_show(GWindow * gwindow); #endif /* !GTOOLKIT_GWINDOW_H */ diff --git a/src/gwindow.c b/src/gwindow.c index b5b686d..0f98dd7 100644 --- a/src/gwindow.c +++ b/src/gwindow.c @@ -44,6 +44,7 @@ struct _GWindow /* GWindow */ char * title; + bool decorated; bool fullscreen; bool resizable; int width; @@ -69,6 +70,7 @@ GWindow * gwindow_new(void) if((gwindow = malloc(sizeof(*gwindow))) == NULL) return NULL; /* FIXME report */ gwindow->title = NULL; + gwindow->decorated = true; gwindow->fullscreen = false; gwindow->resizable = true; gwindow->width = -1; @@ -104,6 +106,20 @@ void gwindow_delete(GWindow * gwindow) /* accessors */ +/* gwindow_get_decorated */ +bool gwindow_get_decorated(GWindow * gwindow) +{ + return gwindow->decorated; +} + + +/* gwindow_get_modal */ +bool gwindow_get_modal(GWindow * gwindow) +{ + return false; +} + + /* gwindow_get_resizable */ bool gwindow_get_resizable(GWindow * gwindow) { @@ -111,6 +127,16 @@ bool gwindow_get_resizable(GWindow * gwindow) } +/* gwindow_get_size */ +void gwindow_get_size(GWindow * gwindow, int * width, int * height) +{ + if(width != NULL) + *width = gwindow->width; + if(height != NULL) + *height = gwindow->height; +} + + /* gwindow_get_title */ char const * gwindow_get_title(GWindow * gwindow) { @@ -181,6 +207,15 @@ void gwindow_event_expose(GWindow * gwindow, XExposeEvent * event) } +/* gwindow_resize */ +void gwindow_resize(GWindow * gwindow, int width, int height) +{ + gwindow->width = (width == -1 || width > 0) ? width : -1; + gwindow->height = (height == -1 || height > 0) ? height : -1; + /* FIXME actually resize the window */ +} + + /* gwindow_show */ void gwindow_show(GWindow * gwindow) /* FIXME accept flags (focus...) */