Compare commits
3 Commits
master
...
khorben/gt
Author | SHA1 | Date | |
---|---|---|---|
8eacf3a717 | |||
491342e186 | |||
171f2d4645 |
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2011-2019 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2011-2021 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Accessories */
|
/* This file is part of DeforaOS Desktop Accessories */
|
||||||
/* All rights reserved.
|
/* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -75,7 +75,7 @@ static int _usage(void);
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
static void _compare_on_changed(gpointer data);
|
static void _compare_on_changed(gpointer data);
|
||||||
static void _compare_on_close(gpointer data);
|
static void _compare_on_close(gpointer data);
|
||||||
static gboolean _compare_on_closex(gpointer data);
|
static gboolean _compare_on_closex(GtkWidget * widget);
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
@ -91,8 +91,8 @@ static int _compare(char const * string1, char const * string2)
|
||||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(window), 4);
|
gtk_container_set_border_width(GTK_CONTAINER(window), 4);
|
||||||
gtk_window_set_title(GTK_WINDOW(window), _("Compare strings"));
|
gtk_window_set_title(GTK_WINDOW(window), _("Compare strings"));
|
||||||
g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(
|
g_signal_connect(window, "delete-event", G_CALLBACK(_compare_on_closex),
|
||||||
_compare_on_closex), window);
|
NULL);
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||||
#else
|
#else
|
||||||
|
@ -135,7 +135,7 @@ static int _compare(char const * string1, char const * string2)
|
||||||
#if GTK_CHECK_VERSION(3, 10, 0)
|
#if GTK_CHECK_VERSION(3, 10, 0)
|
||||||
widget = gtk_button_new_with_label(_("Close"));
|
widget = gtk_button_new_with_label(_("Close"));
|
||||||
gtk_button_set_image(GTK_BUTTON(widget),
|
gtk_button_set_image(GTK_BUTTON(widget),
|
||||||
gtk_image_new_from_icon_name(GTK_STOCK_CLOSE,
|
gtk_image_new_from_icon_name("gtk-close",
|
||||||
GTK_ICON_SIZE_BUTTON));
|
GTK_ICON_SIZE_BUTTON));
|
||||||
#else
|
#else
|
||||||
widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
||||||
|
@ -145,8 +145,13 @@ static int _compare(char const * string1, char const * string2)
|
||||||
gtk_container_add(GTK_CONTAINER(bbox), widget);
|
gtk_container_add(GTK_CONTAINER(bbox), widget);
|
||||||
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
|
||||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
while(g_list_model_get_n_items(gtk_window_get_toplevels()) > 0)
|
||||||
|
g_main_context_iteration(NULL, TRUE);
|
||||||
|
#else
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all(window);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,18 +208,20 @@ static void _compare_on_close(gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget * widget = data;
|
GtkWidget * widget = data;
|
||||||
|
|
||||||
gtk_widget_hide(widget);
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_window_destroy(GTK_WINDOW(widget));
|
||||||
|
#else
|
||||||
|
gtk_widget_destroy(widget);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* compare_on_closex */
|
/* compare_on_closex */
|
||||||
static gboolean _compare_on_closex(gpointer data)
|
static gboolean _compare_on_closex(GtkWidget * widget)
|
||||||
{
|
{
|
||||||
GtkWidget * widget = data;
|
|
||||||
|
|
||||||
_compare_on_close(widget);
|
_compare_on_close(widget);
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,7 +236,11 @@ int main(int argc, char * argv[])
|
||||||
_error("setlocale", 1);
|
_error("setlocale", 1);
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_init();
|
||||||
|
#else
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
#endif
|
||||||
while((o = getopt(argc, argv, "")) != -1)
|
while((o = getopt(argc, argv, "")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2006-2019 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2006-2021 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Accessories */
|
/* This file is part of DeforaOS Desktop Accessories */
|
||||||
/* All rights reserved.
|
/* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -63,7 +63,7 @@ static int _usage(void);
|
||||||
/* functions */
|
/* functions */
|
||||||
/* fontsel */
|
/* fontsel */
|
||||||
static void _fontsel_on_close(gpointer data);
|
static void _fontsel_on_close(gpointer data);
|
||||||
static gboolean _fontsel_on_closex(gpointer data);
|
static gboolean _fontsel_on_closex(GtkWidget * widget);
|
||||||
|
|
||||||
static int _fontsel(void)
|
static int _fontsel(void)
|
||||||
{
|
{
|
||||||
|
@ -72,43 +72,70 @@ static int _fontsel(void)
|
||||||
GtkWidget * bbox;
|
GtkWidget * bbox;
|
||||||
GtkWidget * widget;
|
GtkWidget * widget;
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
window = gtk_window_new();
|
||||||
|
#else
|
||||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
#endif
|
||||||
gtk_window_set_title(GTK_WINDOW(window), _("Font browser"));
|
gtk_window_set_title(GTK_WINDOW(window), _("Font browser"));
|
||||||
g_signal_connect_swapped(G_OBJECT(window), "delete-event", G_CALLBACK(
|
g_signal_connect(window, "delete-event", G_CALLBACK(_fontsel_on_closex),
|
||||||
_fontsel_on_closex), window);
|
NULL);
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||||
#else
|
#else
|
||||||
vbox = gtk_vbox_new(FALSE, 4);
|
vbox = gtk_vbox_new(FALSE, 4);
|
||||||
#endif
|
#endif
|
||||||
|
#if !GTK_CHECK_VERSION(4, 0, 0)
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
|
||||||
|
#endif
|
||||||
#if GTK_CHECK_VERSION(3, 2, 0)
|
#if GTK_CHECK_VERSION(3, 2, 0)
|
||||||
widget = gtk_font_chooser_widget_new();
|
widget = gtk_font_chooser_widget_new();
|
||||||
#else
|
#else
|
||||||
widget = gtk_font_selection_new();
|
widget = gtk_font_selection_new();
|
||||||
#endif
|
#endif
|
||||||
gtk_container_add(GTK_CONTAINER(vbox), widget);
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
gtk_box_append(GTK_BOX(vbox), widget);
|
||||||
bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
|
|
||||||
#else
|
#else
|
||||||
bbox = gtk_hbutton_box_new();
|
gtk_container_add(GTK_CONTAINER(vbox), widget);
|
||||||
#endif
|
#endif
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
|
||||||
|
#else
|
||||||
|
# if GTK_CHECK_VERSION(3, 0, 0)
|
||||||
|
bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
# else
|
||||||
|
bbox = gtk_hbutton_box_new();
|
||||||
|
# endif
|
||||||
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
||||||
#if GTK_CHECK_VERSION(3, 10, 0)
|
#endif
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
widget = gtk_button_new_with_label(_("Close"));
|
||||||
|
#elif GTK_CHECK_VERSION(3, 10, 0)
|
||||||
widget = gtk_button_new_with_label(_("Close"));
|
widget = gtk_button_new_with_label(_("Close"));
|
||||||
gtk_button_set_image(GTK_BUTTON(widget),
|
gtk_button_set_image(GTK_BUTTON(widget),
|
||||||
gtk_image_new_from_icon_name(GTK_STOCK_CLOSE,
|
gtk_image_new_from_icon_name("gtk-close",
|
||||||
GTK_ICON_SIZE_BUTTON));
|
GTK_ICON_SIZE_BUTTON));
|
||||||
#else
|
#else
|
||||||
widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
||||||
#endif
|
#endif
|
||||||
g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
|
g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
|
||||||
_fontsel_on_close), window);
|
_fontsel_on_close), window);
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_box_append(GTK_BOX(bbox), widget);
|
||||||
|
gtk_box_append(GTK_BOX(vbox), bbox);
|
||||||
|
gtk_box_append(GTK_BOX(window), vbox);
|
||||||
|
#else
|
||||||
gtk_container_add(GTK_CONTAINER(bbox), widget);
|
gtk_container_add(GTK_CONTAINER(bbox), widget);
|
||||||
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
|
||||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||||
|
#endif
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
while(g_list_model_get_n_items(gtk_window_get_toplevels()) > 0)
|
||||||
|
g_main_context_iteration(NULL, TRUE);
|
||||||
|
#else
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all(window);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,16 +143,18 @@ static void _fontsel_on_close(gpointer data)
|
||||||
{
|
{
|
||||||
GtkWidget * widget = data;
|
GtkWidget * widget = data;
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_window_destroy(GTK_WINDOW(widget));
|
||||||
|
#else
|
||||||
gtk_widget_hide(widget);
|
gtk_widget_hide(widget);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean _fontsel_on_closex(gpointer data)
|
static gboolean _fontsel_on_closex(GtkWidget * widget)
|
||||||
{
|
{
|
||||||
GtkWidget * widget = data;
|
|
||||||
|
|
||||||
_fontsel_on_close(widget);
|
_fontsel_on_close(widget);
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +184,11 @@ int main(int argc, char * argv[])
|
||||||
_error("setlocale", 1);
|
_error("setlocale", 1);
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_init();
|
||||||
|
#else
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
#endif
|
||||||
while((o = getopt(argc, argv, "")) != -1)
|
while((o = getopt(argc, argv, "")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2007-2019 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2007-2021 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Accessories */
|
/* This file is part of DeforaOS Desktop Accessories */
|
||||||
/* All rights reserved.
|
/* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -42,7 +42,9 @@
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <libintl.h>
|
#include <libintl.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>
|
||||||
#endif
|
#endif
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
@ -184,7 +186,11 @@ static int _progress(Prefs * prefs, char * argv[])
|
||||||
/* graphical interface */
|
/* graphical interface */
|
||||||
if((prefs->flags & PREFS_x) == 0)
|
if((prefs->flags & PREFS_x) == 0)
|
||||||
{
|
{
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
p.window = gtk_window_new();
|
||||||
|
#else
|
||||||
p.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
p.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
#endif
|
||||||
#if GTK_CHECK_VERSION(3, 0, 0) && !GTK_CHECK_VERSION(3, 14, 0)
|
#if GTK_CHECK_VERSION(3, 0, 0) && !GTK_CHECK_VERSION(3, 14, 0)
|
||||||
gtk_window_set_has_resize_grip(GTK_WINDOW(p.window), FALSE);
|
gtk_window_set_has_resize_grip(GTK_WINDOW(p.window), FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
@ -315,7 +321,11 @@ static int _progress(Prefs * prefs, char * argv[])
|
||||||
#else
|
#else
|
||||||
hbox = gtk_hbox_new(FALSE, 0);
|
hbox = gtk_hbox_new(FALSE, 0);
|
||||||
#endif
|
#endif
|
||||||
#if GTK_CHECK_VERSION(3, 10, 0)
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
widget = gtk_button_new_with_label(_("Cancel"));
|
||||||
|
gtk_button_set_image(GTK_BUTTON(widget),
|
||||||
|
gtk_image_new_from_icon_name("gtk-cancel"));
|
||||||
|
#elif GTK_CHECK_VERSION(3, 10, 0)
|
||||||
widget = gtk_button_new_with_label(_("Cancel"));
|
widget = gtk_button_new_with_label(_("Cancel"));
|
||||||
gtk_button_set_image(GTK_BUTTON(widget),
|
gtk_button_set_image(GTK_BUTTON(widget),
|
||||||
gtk_image_new_from_icon_name(GTK_STOCK_CANCEL,
|
gtk_image_new_from_icon_name(GTK_STOCK_CANCEL,
|
||||||
|
@ -340,7 +350,12 @@ static int _progress(Prefs * prefs, char * argv[])
|
||||||
printf("%lu\n", id);
|
printf("%lu\n", id);
|
||||||
fclose(stdout);
|
fclose(stdout);
|
||||||
}
|
}
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
while(g_list_model_get_n_items(gtk_window_get_toplevels()) > 0)
|
||||||
|
g_main_context_iteration(NULL, TRUE);
|
||||||
|
#else
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
#endif
|
||||||
close(p.fd);
|
close(p.fd);
|
||||||
close(p.fds[1]);
|
close(p.fds[1]);
|
||||||
return p.ret;
|
return p.ret;
|
||||||
|
@ -387,7 +402,11 @@ static int _error_do(Progress * progress, char const * message,
|
||||||
"%s: %s", message, error);
|
"%s: %s", message, error);
|
||||||
gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
|
gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
|
||||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_window_destroy(GTK_WINDOW(dialog));
|
||||||
|
#else
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,7 +753,11 @@ int main(int argc, char * argv[])
|
||||||
_error("setlocale", 1);
|
_error("setlocale", 1);
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
|
#if GTK_CHECK_VERSION(4, 0, 0)
|
||||||
|
gtk_init();
|
||||||
|
#else
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
#endif
|
||||||
while((o = getopt(argc, argv, "b:ef:l:p:t:xz")) != -1)
|
while((o = getopt(argc, argv, "b:ef:l:p:t:xz")) != -1)
|
||||||
switch(o)
|
switch(o)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,16 @@ cflags_force=`pkg-config --cflags libSystem gtk+-3.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+-3.0`
|
ldflags_force=`pkg-config --libs libSystem gtk+-3.0`
|
||||||
|
|
||||||
|
[mode::gtk4-debug]
|
||||||
|
cflags_force=`pkg-config --cflags libSystem gtk4` -fPIC
|
||||||
|
ldflags_force=`pkg-config --libs libSystem gtk4`
|
||||||
|
|
||||||
|
[mode::gtk4-release]
|
||||||
|
cppflags_force=-I ../include -DNDEBUG
|
||||||
|
cflags_force=`pkg-config --cflags libSystem gtk4` -fPIC
|
||||||
|
cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
|
||||||
|
ldflags_force=`pkg-config --libs libSystem gtk4`
|
||||||
|
|
||||||
#targets
|
#targets
|
||||||
[compare]
|
[compare]
|
||||||
type=binary
|
type=binary
|
||||||
|
@ -48,6 +58,9 @@ sources=progress.c
|
||||||
#for Gtk+ 3
|
#for Gtk+ 3
|
||||||
cflags=`pkg-config --cflags gtk+-x11-3.0`
|
cflags=`pkg-config --cflags gtk+-x11-3.0`
|
||||||
ldflags=`pkg-config --cflags gtk+-x11-3.0`
|
ldflags=`pkg-config --cflags gtk+-x11-3.0`
|
||||||
|
#for Gtk+ 4
|
||||||
|
#cflags=`pkg-config --cflags gtk4-x11`
|
||||||
|
#ldflags=`pkg-config --cflags gtk4-x11`
|
||||||
install=$(BINDIR)
|
install=$(BINDIR)
|
||||||
|
|
||||||
[progress.c]
|
[progress.c]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user