Skip to content

Commit af070bc

Browse files
committed
[rpiclient-gtk] Preparing rpi dialogs support for gtk+-4.0
1 parent 52310f2 commit af070bc

File tree

5 files changed

+73
-27
lines changed

5 files changed

+73
-27
lines changed

rpiclient/rc/images/icon.png

6.43 KB
Loading

rpiclient/rc/images/logo.png

11.2 KB
Loading

rpiclient/src/misc/rpi_dialog_misc.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2+
/*
3+
* rpi_dialog_misc.c
4+
* Copyright (C) 2016 - 2025 Vladimir Roncevic <elektron.ronca@gmail.com>
5+
*
6+
* rpiclient-gtk is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License as published by the
8+
* Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* rpiclient-gtk is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
* See the GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#include "rpi_dialog_misc.h"
20+

rpiclient/src/misc/rpi_dialog_misc.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2+
/*
3+
* rpi_dialog_misc.h
4+
* Copyright (C) 2016 - 2025 Vladimir Roncevic <elektron.ronca@gmail.com>
5+
*
6+
* rpiclient-gtk is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License as published by the
8+
* Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* rpiclient-gtk is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14+
* See the GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
#pragma once
20+
21+
#include <gtk/gtk.h>
22+

rpiclient/src/misc/rpi_misc.c

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,48 +38,52 @@ gboolean rpi_is_widget_visible_misc(const GtkWidget* widget)
3838

3939
void rpi_set_visible_widget_misc(GtkWidget* widget, gboolean visible)
4040
{
41-
if (widget)
41+
if (!widget)
4242
{
43+
return;
44+
}
45+
4346
#if GTK_MAJOR_VERSION == 4
44-
if (GTK_IS_WINDOW(widget))
45-
{
46-
gtk_window_present(GTK_WINDOW(widget));
47-
}
48-
else
49-
{
50-
gtk_widget_set_visible(GTK_WIDGET(widget), visible);
51-
}
47+
if (GTK_IS_WINDOW(widget))
48+
{
49+
gtk_window_present(GTK_WINDOW(widget));
50+
}
51+
else
52+
{
53+
gtk_widget_set_visible(GTK_WIDGET(widget), visible);
54+
}
5255
#elif GTK_MAJOR_VERSION == 3
53-
if (visible)
54-
{
55-
gtk_widget_show(GTK_WIDGET(widget));
56-
}
57-
else
58-
{
59-
gtk_widget_hide(GTK_WIDGET(widget));
60-
}
56+
if (visible)
57+
{
58+
gtk_widget_show(GTK_WIDGET(widget));
59+
}
60+
else
61+
{
62+
gtk_widget_hide(GTK_WIDGET(widget));
63+
}
6164
#else
6265
#error "Supported GTK+ version: gtk+-3.0 gtk+-4.0!"
6366
#endif
64-
}
6567
}
6668

6769
void rpi_destroy_widget_misc(GtkWidget* widget)
6870
{
69-
if (widget)
71+
if (!widget)
7072
{
73+
return;
74+
}
75+
7176
#if GTK_MAJOR_VERSION == 4
72-
if (GTK_IS_WINDOW(widget))
73-
{
74-
gtk_window_close(GTK_WINDOW(widget));
75-
}
77+
if (GTK_IS_WINDOW(widget))
78+
{
79+
gtk_window_close(GTK_WINDOW(widget));
80+
}
7681

77-
gtk_widget_unparent(GTK_WIDGET(widget));
78-
g_object_unref(widget);
82+
gtk_widget_unparent(GTK_WIDGET(widget));
83+
g_object_unref(widget);
7984
#elif GTK_MAJOR_VERSION == 3
80-
gtk_widget_destroy(GTK_WIDGET(widget));
85+
gtk_widget_destroy(GTK_WIDGET(widget));
8186
#else
8287
#error "Supported GTK+ version: gtk+-3.0 gtk+-4.0!"
8388
#endif
84-
}
8589
}

0 commit comments

Comments
 (0)