Compare commits

...

4 Commits

16 changed files with 148 additions and 23 deletions

1
data/gtk4/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/libDesktop.pc

View File

@ -0,0 +1,11 @@
prefix=@PREFIX@
includedir=${prefix}/include
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
Name: @PACKAGE@
Description: DeforaOS Desktop helper library
Version: @VERSION@
Requires: libSystem gtk4-x11
Cflags: -I${includedir}
Libs: @RPATH@ -L${libdir} -lDesktop

9
data/gtk4/project.conf Normal file
View File

@ -0,0 +1,9 @@
targets=libDesktop.pc
dist=Makefile,libDesktop.pc.in
#targets
[libDesktop.pc]
type=script
script=../pkgconfig.sh
depends=libDesktop.pc.in,../../config.sh
install=

View File

@ -1,6 +1,6 @@
subdirs=gtk3 subdirs=gtk3
dist=Makefile,pkgconfig.sh dist=Makefile,pkgconfig.sh
mode=gtk3-debug mode=gtk4-debug
#modes #modes
[mode::gtk2-debug] [mode::gtk2-debug]
@ -8,3 +8,9 @@ subdirs=gtk2
[mode::gtk2-release] [mode::gtk2-release]
subdirs=gtk2 subdirs=gtk2
[mode::gtk4-debug]
subdirs=gtk4
[mode::gtk4-release]
subdirs=gtk4

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2009-2012 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2009-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *
@ -41,6 +41,10 @@ typedef struct _DesktopAccel
unsigned int accel; unsigned int accel;
} DesktopAccel; } DesktopAccel;
# if GTK_CHECK_VERSION(4, 0, 0)
typedef void GtkAccelGroup;
# endif
/* functions */ /* functions */
void desktop_accel_create(DesktopAccel const * accel, gpointer data, void desktop_accel_create(DesktopAccel const * accel, gpointer data,

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *
@ -107,8 +107,29 @@
# define GDK_KEY_uparrow GDK_uparrow # define GDK_KEY_uparrow GDK_uparrow
# endif # endif
/* Gtk+ 4.0 */
# if GTK_CHECK_VERSION(4, 0, 0)
void gtk_box_pack_end(GtkBox * box, GtkWidget * child,
gboolean fill, gboolean expand, gint padding);
void gtk_box_pack_start(GtkBox * box, GtkWidget * child,
gboolean fill, gboolean expand, gint padding);
# define GTK_CONTAINER(a) GTK_WIDGET(a)
void gtk_container_add(GtkWidget * container, GtkWidget * child);
# define GTK_ICON_LOOKUP_USE_BUILTIN 0
# define GTK_ICON_LOOKUP_GENERIC_FALLBACK 0
GdkPixbuf * gtk_icon_theme_load_icon(GtkIconTheme * theme, char const * name,
GtkIconSize size, guint flags, gpointer data);
void gtk_main(void);
# define GTK_STOCK_DIRECTORY "gtk-directory"
# define GTK_STOCK_FILE "gtk-file"
# define GTK_STOCK_MISSING_IMAGE "gtk-missing-image"
# elif !GTK_CHECK_VERSION(3, 0, 0)
/* Gtk+ 3.0 */ /* Gtk+ 3.0 */
# if !GTK_CHECK_VERSION(3, 0, 0)
/* types */ /* types */
typedef struct _GdkRGBA typedef struct _GdkRGBA
{ {

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2009-2012 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2009-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *
@ -31,6 +31,8 @@
#ifndef LIBDESKTOP_DESKTOP_TOOLBAR_H #ifndef LIBDESKTOP_DESKTOP_TOOLBAR_H
# define LIBDESKTOP_DESKTOP_TOOLBAR_H # define LIBDESKTOP_DESKTOP_TOOLBAR_H
# include "accel.h"
/* Toolbar */ /* Toolbar */
/* types */ /* types */
@ -41,7 +43,11 @@ typedef struct _DesktopToolbar
const char * stock; const char * stock;
GdkModifierType modifier; GdkModifierType modifier;
unsigned int accel; unsigned int accel;
# if GTK_CHECK_VERSION(4, 0, 0)
GtkWidget * widget;
# else
GtkToolItem * widget; GtkToolItem * widget;
# endif
} DesktopToolbar; } DesktopToolbar;

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2009-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2012-2018 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *
@ -28,13 +28,41 @@
#include <gdk/gdkx.h> #include <gtk/gtk.h>
#if GTK_CHECK_VERSION(4, 0, 0)
# include <gdk/x11/gdkx.h>
#else
# include <gdk/gdkx.h>
#endif
#include "Desktop.h" #include "Desktop.h"
/* Compat */ /* Compat */
#if GTK_CHECK_VERSION(4, 0, 0)
/* Gtk+ 4 */
/* gtk_icon_theme_load_icon */
GdkPixbuf * gtk_icon_theme_load_icon(GtkIconTheme * theme, char const * name,
GtkIconSize size, guint flags, gpointer data)
{
GtkWidget * image;
(void) theme;
image = gtk_image_new_from_icon_name(name);
gtk_image_set_icon_size(GTK_IMAGE(image), size);
return image;
}
/* gtk_main */
void gtk_main(void)
{
while(g_list_model_get_n_items(gtk_window_get_toplevels()) > 0)
g_main_context_iteration(NULL, TRUE);
}
#elif GTK_CHECK_VERSION(3, 0, 0)
/* Gtk+ 3 */ /* Gtk+ 3 */
#if GTK_CHECK_VERSION(3, 0, 0)
/* gdk_window_clear */ /* gdk_window_clear */
void gdk_window_clear(GdkWindow * window) void gdk_window_clear(GdkWindow * window)
{ {
@ -47,10 +75,10 @@ void gdk_window_clear(GdkWindow * window)
XClearWindow(display, wid); XClearWindow(display, wid);
gdk_error_trap_pop(); gdk_error_trap_pop();
} }
#endif
#if !GTK_CHECK_VERSION(3, 0, 0) #elif GTK_CHECK_VERSION(2, 0, 0)
/* Gtk+ 2.0 */
/* gtk_box_new */ /* gtk_box_new */
GtkWidget * gtk_box_new(GtkOrientation orientation, gint spacing) GtkWidget * gtk_box_new(GtkOrientation orientation, gint spacing)
{ {

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2009-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop libDesktop */ /* This file is part of DeforaOS Desktop libDesktop */
/* All rights reserved. /* All rights reserved.
* *
@ -37,7 +37,9 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(4, 0, 0)
# include <gdk/x11/gdkx.h>
#elif GTK_CHECK_VERSION(3, 0, 0)
# include <gtk/gtkx.h> # include <gtk/gtkx.h>
#else #else
# include <gdk/gdkx.h> # include <gdk/gdkx.h>

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2021 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS libDesktop */ /* This file is part of DeforaOS libDesktop */
/* All rights reserved. /* All rights reserved.
* *
@ -110,7 +110,12 @@ Mime * mime_new(GtkIconTheme * theme)
if((mime = object_new(sizeof(*mime))) == NULL) if((mime = object_new(sizeof(*mime))) == NULL)
return NULL; return NULL;
if(theme == NULL) if(theme == NULL)
#if GTK_CHECK_VERSION(4, 0, 0)
theme = gtk_icon_theme_get_for_display(
gdk_display_get_default());
#else
theme = gtk_icon_theme_get_default(); theme = gtk_icon_theme_get_default();
#endif
mime->theme = theme; mime->theme = theme;
for(g = globs2; *g != NULL; g++) for(g = globs2; *g != NULL; g++)
if((fp = fopen(*g, "r")) != NULL) if((fp = fopen(*g, "r")) != NULL)

View File

@ -1,11 +1,11 @@
targets=libDesktop targets=libDesktop
cppflags_force=-I ../include cppflags_force=-I ../include
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11` -fPIC cflags_force=`pkg-config --cflags libSystem gtk4-x11` -fPIC
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11` ldflags_force=`pkg-config --libs libSystem gtk4-x11`
ldflags=-Wl,-z,relro -Wl,-z,now ldflags=-Wl,-z,relro -Wl,-z,now
dist=Makefile,mimehandler.h dist=Makefile,mimehandler.h
mode=gtk3-debug mode=gtk4-debug
#modes #modes
[mode::gtk2-debug] [mode::gtk2-debug]
@ -18,9 +18,21 @@ cflags_force=`pkg-config --cflags libSystem gtk+-2.0` -fPIC
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk+-2.0` ldflags_force=`pkg-config --libs libSystem gtk+-2.0`
[mode::gtk3-debug]
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11` -fPIC
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11`
[mode::gtk3-release] [mode::gtk3-release]
cppflags_force=-I ../include -DNDEBUG cppflags_force=-I ../include -DNDEBUG
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11` -fPIC
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11`
[mode::gtk4-release]
cppflags_force=-I ../include -DNDEBUG
cflags_force=`pkg-config --cflags libSystem gtk4-x11` -fPIC
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk4-x11`
#targets #targets
[libDesktop] [libDesktop]

View File

@ -5,7 +5,7 @@ ldflags=-pie -Wl,-z,relro -Wl,-z,now
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11` cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11`
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11` $(OBJDIR)../src/libDesktop.a ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11` $(OBJDIR)../src/libDesktop.a
dist=Makefile,applications/Root.desktop,applications/Widget.desktop,clint.sh,fixme.sh,htmllint.sh,pkgconfig.sh,tests.sh,xmllint.sh dist=Makefile,applications/Root.desktop,applications/Widget.desktop,clint.sh,fixme.sh,htmllint.sh,pkgconfig.sh,tests.sh,xmllint.sh
mode=gtk3-debug mode=gtk4-debug
#modes #modes
[mode::gtk2-debug] [mode::gtk2-debug]
@ -22,6 +22,16 @@ ldflags_force=`pkg-config --libs libSystem gtk+-2.0` $(OBJDIR)../src/libDesktop.
cppflags_force=-I ../include -DNDEBUG cppflags_force=-I ../include -DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
[mode::gtk4-debug]
cflags_force=`pkg-config --cflags libSystem gtk4`
ldflags_force=`pkg-config --libs libSystem gtk4` $(OBJDIR)../src/libDesktop.a
[mode::gtk4-release]
cppflags_force=-I ../include -DNDEBUG
cflags_force=`pkg-config --cflags libSystem gtk4`
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk4` $(OBJDIR)../src/libDesktop.a
#targets #targets
[clint.log] [clint.log]
type=script type=script

View File

@ -1,11 +1,11 @@
targets=widget targets=widget
cppflags_force=-I ../include cppflags_force=-I ../include
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11` cflags_force=`pkg-config --cflags libSystem gtk4-x11`
cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11` -L $(OBJDIR)../src -lDesktop ldflags_force=`pkg-config --libs libSystem gtk4-x11` -L $(OBJDIR)../src -lDesktop
ldflags=-pie -Wl,-z,relro -Wl,-z,now ldflags=-pie -Wl,-z,relro -Wl,-z,now
dist=Makefile,subst.sh dist=Makefile,subst.sh
mode=gtk3-debug mode=gtk4-debug
#modes #modes
[mode::gtk2-debug] [mode::gtk2-debug]
@ -18,9 +18,19 @@ cflags_force=`pkg-config --cflags libSystem gtk+-2.0`
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk+-2.0` -L $(OBJDIR)../src -lDesktop ldflags_force=`pkg-config --libs libSystem gtk+-2.0` -L $(OBJDIR)../src -lDesktop
[mode::gtk3-debug]
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11`
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11` -L $(OBJDIR)../src -lDesktop
[mode::gtk3-release] [mode::gtk3-release]
cppflags_force=-I ../include -DNDEBUG cppflags_force=-I ../include -DNDEBUG
cflags_force=`pkg-config --cflags libSystem gtk+-3.0 x11`
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
ldflags_force=`pkg-config --libs libSystem gtk+-3.0 x11` -L $(OBJDIR)../src -lDesktop
[mode::gtk4-release]
cppflags_force=-I ../include -DNDEBUG
cflags=-W -Wall -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
#targets #targets
[widget] [widget]

View File

@ -142,7 +142,7 @@ int main(int argc, char * argv[])
memset(&prefs, 0, sizeof(prefs)); memset(&prefs, 0, sizeof(prefs));
#if GTK_CHECK_VERSION(4, 0, 0) #if GTK_CHECK_VERSION(4, 0, 0)
gtk_init(&argc, &argv); gtk_init();
#else #else
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
#endif #endif