mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-24 12:41:16 +00:00
gtk-demo: Deprecation cleanup
Remove many uses of deprecated api in gtk4-demo. Remaining uses are demos of wholly deprecated objects that will just be dropped in GTK5.
This commit is contained in:
parent
23222a97fc
commit
3e066a0a15
@ -2,8 +2,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef GtkApplication DemoApplication;
|
||||
typedef GtkApplicationClass DemoApplicationClass;
|
||||
|
||||
@ -216,6 +214,41 @@ activate_quit (GSimpleAction *action,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
delete_messages (gpointer data)
|
||||
{
|
||||
g_list_free_full ((GList *)data, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
pop_message (GtkWidget *status)
|
||||
{
|
||||
GList *messages = (GList *) g_object_get_data (G_OBJECT (status), "messages");
|
||||
|
||||
if (messages)
|
||||
{
|
||||
char *message = messages->data;
|
||||
messages = g_list_remove (messages, message);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (status), "messages",
|
||||
messages, delete_messages);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (status), message);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
push_message (GtkWidget *status,
|
||||
const char *message)
|
||||
{
|
||||
GList *messages = (GList *) g_object_get_data (G_OBJECT (status), "messages");
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (status), message);
|
||||
messages = g_list_prepend (messages, g_strdup (message));
|
||||
g_object_set_data_full (G_OBJECT (status), "messages",
|
||||
messages, delete_messages);
|
||||
}
|
||||
|
||||
static void
|
||||
update_statusbar (GtkTextBuffer *buffer,
|
||||
DemoApplicationWindow *window)
|
||||
@ -226,7 +259,7 @@ update_statusbar (GtkTextBuffer *buffer,
|
||||
GtkTextIter iter;
|
||||
|
||||
/* clear any previous message, underflow is allowed */
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (window->status), 0);
|
||||
pop_message (window->status);
|
||||
|
||||
count = gtk_text_buffer_get_char_count (buffer);
|
||||
|
||||
@ -240,7 +273,7 @@ update_statusbar (GtkTextBuffer *buffer,
|
||||
msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document",
|
||||
row, col, count);
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, msg);
|
||||
push_message (window->status, msg);
|
||||
|
||||
g_free (msg);
|
||||
}
|
||||
|
@ -76,8 +76,13 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStatusbar" id="status">
|
||||
<object class="GtkLabel" id="status">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-start">2</property>
|
||||
<property name="margin-end">2</property>
|
||||
<property name="margin-top">2</property>
|
||||
<property name="margin-bottom">2</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">3</property>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Builder
|
||||
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkStatusBar, GtkShortcutController, toolbar
|
||||
* #Keywords: GMenu, GtkPopoverMenuBar, GtkBuilder, GtkShortcutController, toolbar
|
||||
*
|
||||
* Demonstrates a traditional interface, loaded from a XML description,
|
||||
* and shows how to connect actions to the menu items and toolbar buttons.
|
||||
@ -37,30 +37,34 @@ remove_timeout (gpointer data)
|
||||
g_source_remove (id);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static gboolean
|
||||
pop_status (gpointer data)
|
||||
static int
|
||||
pop_message (gpointer data)
|
||||
{
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (data), 0);
|
||||
g_object_set_data (G_OBJECT (data), "timeout", NULL);
|
||||
GtkWidget *status = data;
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (status), "");
|
||||
g_object_set_data (G_OBJECT (status), "timeout", GUINT_TO_POINTER (0));
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void
|
||||
status_message (GtkStatusbar *status,
|
||||
const char *text)
|
||||
status_message (GtkWidget *status,
|
||||
const char *text)
|
||||
{
|
||||
guint id;
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (status), 0, text);
|
||||
id = g_timeout_add (5000, pop_status, status);
|
||||
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (status), "timeout"));
|
||||
if (id)
|
||||
g_source_remove (id);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (status), text);
|
||||
|
||||
id = g_timeout_add (5000, pop_message, status);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (status), "timeout", GUINT_TO_POINTER (id), remove_timeout);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
help_activate (GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
@ -69,7 +73,7 @@ help_activate (GSimpleAction *action,
|
||||
GtkWidget *status;
|
||||
|
||||
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
||||
status_message (GTK_STATUSBAR (status), "Help not available");
|
||||
status_message (status, "Help not available");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -82,7 +86,7 @@ not_implemented (GSimpleAction *action,
|
||||
|
||||
text = g_strdup_printf ("Action “%s” not implemented", g_action_get_name (G_ACTION (action)));
|
||||
status = GTK_WIDGET (g_object_get_data (G_OBJECT (user_data), "status"));
|
||||
status_message (GTK_STATUSBAR (status), text);
|
||||
status_message (status, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
show_parsing_error (GtkCssProvider *provider,
|
||||
GtkCssSection *section,
|
||||
@ -49,20 +47,23 @@ css_text_changed (GtkTextBuffer *buffer,
|
||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
gtk_css_provider_load_from_data (provider, text, -1);
|
||||
gtk_css_provider_load_from_string (provider, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = data;
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
apply_css (child, provider);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -81,6 +82,7 @@ do_css_basics (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "CSS Basics");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
gtk_widget_add_css_class (window, "demo");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
text = gtk_text_buffer_new (NULL);
|
||||
|
@ -4,23 +4,24 @@
|
||||
* anymore. :)
|
||||
*/
|
||||
|
||||
/* This CSS resets all properties to their defaults values
|
||||
* and overrides all user settings and the theme in use */
|
||||
@import url("resource://css_basics/reset.css");
|
||||
/* This resets all properties to their defaults values
|
||||
* and overrides all user settings and the theme in use
|
||||
*/
|
||||
@import url("resource://css_shadows/reset.css");
|
||||
|
||||
/* Set a very futuristic style by default */
|
||||
* {
|
||||
.demo * {
|
||||
color: green;
|
||||
font-family: Monospace;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
window {
|
||||
window.demo {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* Make sure selections are visible */
|
||||
selection {
|
||||
.demo selection {
|
||||
background-color: darkGreen;
|
||||
color: black;
|
||||
}
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
show_parsing_error (GtkCssProvider *provider,
|
||||
GtkCssSection *section,
|
||||
@ -50,33 +48,23 @@ css_text_changed (GtkTextBuffer *buffer,
|
||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
gtk_css_provider_load_from_data (provider, text, -1);
|
||||
gtk_css_provider_load_from_string (provider, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
drawing_area_draw (GtkDrawingArea *da,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
clear_provider (gpointer data)
|
||||
{
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (da));
|
||||
GtkStyleProvider *provider = data;
|
||||
|
||||
gtk_render_background (context, cr, 0, 0, width, height);
|
||||
gtk_render_frame (context, cr, 0, 0, width, height);
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
apply_css (child, provider);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -95,16 +83,17 @@ do_css_multiplebgs (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Multiple Backgrounds");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
gtk_widget_add_css_class (window, "demo");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), overlay);
|
||||
|
||||
child = gtk_drawing_area_new ();
|
||||
/* Don't set a draw_func, since we are only interested in CSS drawing,
|
||||
* which happens automatically.
|
||||
*/
|
||||
gtk_widget_set_name (child, "canvas");
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (child),
|
||||
drawing_area_draw,
|
||||
NULL, NULL);
|
||||
gtk_overlay_set_child (GTK_OVERLAY (overlay), child);
|
||||
|
||||
child = gtk_button_new ();
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
show_parsing_error (GtkCssProvider *provider,
|
||||
GtkCssSection *section,
|
||||
@ -51,20 +49,23 @@ css_text_changed (GtkTextBuffer *buffer,
|
||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
gtk_css_provider_load_from_data (provider, text, -1);
|
||||
gtk_css_provider_load_from_string (provider, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = data;
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
apply_css (child, provider);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -83,6 +84,7 @@ do_css_pixbufs (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Animated Backgrounds");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
gtk_widget_add_css_class (window, "demo");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
||||
|
@ -50,7 +50,7 @@
|
||||
100% { background-size: 12px, 96px, 12px, 96px, 12px, 96px, 12px, 96px, auto; }
|
||||
}
|
||||
|
||||
window {
|
||||
window.demo {
|
||||
background-image: url("resource://css_pixbufs/images/apple-red.png"),
|
||||
url("resource://css_pixbufs/images/gnome-applets.png"),
|
||||
url("resource://css_pixbufs/images/gnome-calendar.png"),
|
||||
@ -66,11 +66,11 @@ window {
|
||||
}
|
||||
|
||||
/* Make the text editor has a nice style */
|
||||
.view, scrollbar, separator {
|
||||
window.demo .view, scrollbar, separator {
|
||||
color: black;
|
||||
background-color: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
.view:selected {
|
||||
window.demo .view:selected {
|
||||
background-color: rgba(127,127,255,0.5);
|
||||
}
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
show_parsing_error (GtkCssProvider *provider,
|
||||
GtkCssSection *section,
|
||||
@ -48,20 +46,23 @@ css_text_changed (GtkTextBuffer *buffer,
|
||||
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
|
||||
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
gtk_css_provider_load_from_data (provider, text, -1);
|
||||
gtk_css_provider_load_from_string (provider, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = data;
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
|
||||
for (child = gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = gtk_widget_get_next_sibling (child))
|
||||
apply_css (child, provider);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), provider, G_MAXUINT);
|
||||
g_object_set_data_full (G_OBJECT (widget), "provider", provider, clear_provider);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@ -101,6 +102,7 @@ do_css_shadows (GtkWidget *do_widget)
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Shadows");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
|
||||
gtk_widget_add_css_class (window, "demo");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
|
||||
@ -142,7 +144,7 @@ do_css_shadows (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@ -5,12 +5,13 @@
|
||||
*/
|
||||
|
||||
/* This CSS resets all properties to their defaults values
|
||||
* and overrides all user settings and the theme in use */
|
||||
* and overrides all user settings and the theme in use
|
||||
*/
|
||||
@import url("resource://css_shadows/reset.css");
|
||||
@import url("resource://css_shadows/cssview.css");
|
||||
|
||||
/* Get a nice background for the window */
|
||||
.background {
|
||||
window.demo.background {
|
||||
background-color: #4870bc;
|
||||
background-image: linear-gradient(to left, transparent, rgba(255,255,255,.07) 50%, transparent 50%),
|
||||
linear-gradient(to left, transparent, rgba(255,255,255,.13) 50%, transparent 50%),
|
||||
@ -19,7 +20,7 @@
|
||||
background-size: 29px, 59px, 73px, 109px;
|
||||
}
|
||||
|
||||
button {
|
||||
window.demo button {
|
||||
color: black;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
@ -27,18 +28,15 @@ button {
|
||||
border: 1px transparent solid;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
window.demo button:hover {
|
||||
text-shadow: 3px 3px 5px alpha(black, 0.75);
|
||||
-gtk-icon-shadow: 3px 3px 5px alpha(black, 0.75);
|
||||
box-shadow: 3px 3px 5px alpha(black, 0.5) inset;
|
||||
border: solid 1px alpha(black, 0.75);
|
||||
}
|
||||
|
||||
button:active {
|
||||
window.demo button:active {
|
||||
padding: 11px 9px 9px 11px;
|
||||
text-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
||||
-gtk-icon-shadow: 1px 1px 2.5px alpha(black, 0.6);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,21 +1,21 @@
|
||||
/* Make the text editor has a nice style */
|
||||
.view {
|
||||
window.demo .view {
|
||||
color: #2e3436;
|
||||
font-family: Monospace;
|
||||
background-color: alpha(white, 0.30);
|
||||
}
|
||||
|
||||
.view:selected {
|
||||
window.demo .view:selected {
|
||||
color: white;
|
||||
background-color: #4a90d9;
|
||||
}
|
||||
|
||||
scrollbar trough,
|
||||
window.demo scrollbar trough,
|
||||
.scrollbars-junction {
|
||||
background-color: alpha(white, 0.80);
|
||||
}
|
||||
|
||||
scrollbar slider {
|
||||
window.demo scrollbar slider {
|
||||
border-width: 3px;
|
||||
border-style: solid;
|
||||
border-radius: 10px;
|
||||
@ -24,11 +24,11 @@ scrollbar slider {
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
scrollbar slider:hover {
|
||||
window.demo scrollbar slider:hover {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
paned separator {
|
||||
window.demo paned separator {
|
||||
background-color: alpha(white, 0.80);
|
||||
background-image: linear-gradient(transparent, transparent 1px, #999 1px, #999 4px, transparent 4px);
|
||||
background-size: 40px auto;
|
||||
@ -36,6 +36,6 @@ paned separator {
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
paned separator:hover {
|
||||
window.demo paned separator:hover {
|
||||
background-image: linear-gradient(transparent, transparent 1px, #555 1px, #555 4px, transparent 4px);
|
||||
}
|
||||
|
@ -208,7 +208,13 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStatusbar" id="statusbar1"/>
|
||||
<object class="GtkLabel" id="statusbar1">
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-start">2</property>
|
||||
<property name="margin-end">2</property>
|
||||
<property name="margin-top">2</property>
|
||||
<property name="margin-bottom">2</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -760,9 +760,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
GtkCssProvider *provider;
|
||||
GString *css;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
button = gtk_color_button_new ();
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
button = gtk_color_dialog_button_new (gtk_color_dialog_new ());
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
static void
|
||||
@ -45,21 +43,22 @@ do_expander (GtkWidget *do_widget)
|
||||
if (!window)
|
||||
{
|
||||
toplevel = GTK_WIDGET (gtk_widget_get_root (do_widget));
|
||||
window = gtk_message_dialog_new_with_markup (GTK_WINDOW (toplevel),
|
||||
0,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"<big><b>%s</b></big>",
|
||||
"Something went wrong");
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (window),
|
||||
"Here are some more details "
|
||||
"but not the full story.");
|
||||
|
||||
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (window));
|
||||
|
||||
label = gtk_widget_get_last_child (area);
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Expander");
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
|
||||
area = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_widget_set_margin_start (area, 10);
|
||||
gtk_widget_set_margin_end (area, 10);
|
||||
gtk_widget_set_margin_top (area, 10);
|
||||
gtk_widget_set_margin_bottom (area, 10);
|
||||
gtk_window_set_child (GTK_WINDOW (window), area);
|
||||
label = gtk_label_new ("<big><b>Something went wrong</b></big>");
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
gtk_box_append (GTK_BOX (area), label);
|
||||
label = gtk_label_new ("Here are some more details but not the full story");
|
||||
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
|
||||
gtk_widget_set_vexpand (label, FALSE);
|
||||
gtk_box_append (GTK_BOX (area), label);
|
||||
|
||||
expander = gtk_expander_new ("Details:");
|
||||
gtk_widget_set_vexpand (expander, TRUE);
|
||||
@ -122,7 +121,7 @@ do_expander (GtkWidget *do_widget)
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_set_visible (window, TRUE);
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
else
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
|
||||
|
@ -68,13 +68,18 @@ create_blurred_button (void)
|
||||
return w;
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
static GtkWidget *
|
||||
create_font_button (void)
|
||||
{
|
||||
return gtk_font_button_new ();
|
||||
GtkFontDialog *dialog;
|
||||
GtkWidget *button;
|
||||
|
||||
dialog = gtk_font_dialog_new ();
|
||||
button = gtk_font_dialog_button_new (dialog);
|
||||
g_object_unref (dialog);
|
||||
|
||||
return button;
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *
|
||||
create_level_bar (void)
|
||||
|
@ -150,8 +150,6 @@ if librsvg_dep.found()
|
||||
gtkdemo_deps += [ librsvg_dep ]
|
||||
endif
|
||||
|
||||
gtkdemo_args = [ '-DGDK_DISABLE_DEPRECATED', '-DGTK_DISABLE_DEPRECATED', ]
|
||||
|
||||
demos_h = custom_target('gtk4 demo header',
|
||||
output: 'demos.h',
|
||||
input: demos,
|
||||
@ -235,7 +233,7 @@ gtkdemo_deps += [ demo_conf_h ]
|
||||
|
||||
executable('gtk4-demo',
|
||||
sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
|
||||
c_args: gtkdemo_args + demo_cflags,
|
||||
c_args: demo_cflags,
|
||||
dependencies: gtkdemo_deps,
|
||||
include_directories: confinc,
|
||||
win_subsystem: 'windows',
|
||||
@ -245,7 +243,7 @@ executable('gtk4-demo',
|
||||
|
||||
executable('gtk4-demo-application',
|
||||
sources: ['application.c', gtkdemo_resources],
|
||||
c_args: gtkdemo_args + common_cflags,
|
||||
c_args: common_cflags,
|
||||
dependencies: gtkdemo_deps,
|
||||
include_directories: confinc,
|
||||
win_subsystem: 'windows',
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
enum {
|
||||
COLOR_SET,
|
||||
N_SIGNALS
|
||||
@ -124,19 +122,16 @@ drawing_area_unmap (GtkWidget *widget)
|
||||
|
||||
static void
|
||||
drawing_area_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
DrawingArea *area = (DrawingArea *) widget;
|
||||
GtkAllocation allocation;
|
||||
int width, height;
|
||||
cairo_t *cr;
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
cr = gtk_snapshot_append_cairo (snapshot,
|
||||
&GRAPHENE_RECT_INIT (
|
||||
0, 0,
|
||||
allocation.width,
|
||||
allocation.height
|
||||
));
|
||||
width = gtk_widget_get_width (widget);
|
||||
height = gtk_widget_get_height (widget);
|
||||
|
||||
cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
@ -145,7 +140,7 @@ drawing_area_snapshot (GtkWidget *widget,
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 0.6, 0.6, 0.6);
|
||||
cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
@ -6,6 +6,6 @@
|
||||
* Also, when adding new style properties, please add them here.
|
||||
*/
|
||||
|
||||
* {
|
||||
window.demo * {
|
||||
all: unset;
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ GtkWidget *
|
||||
do_spinner (GtkWidget *do_widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button;
|
||||
@ -35,28 +34,19 @@ do_spinner (GtkWidget *do_widget)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
window = gtk_dialog_new_with_buttons ("Spinner",
|
||||
GTK_WINDOW (do_widget),
|
||||
0,
|
||||
_("_Close"),
|
||||
GTK_RESPONSE_NONE,
|
||||
NULL);
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Spinner");
|
||||
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
|
||||
|
||||
g_signal_connect (window, "response",
|
||||
G_CALLBACK (gtk_window_destroy), NULL);
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
|
||||
gtk_widget_set_margin_top (vbox, 5);
|
||||
gtk_widget_set_margin_bottom (vbox, 5);
|
||||
gtk_box_append (GTK_BOX (content_area), vbox);
|
||||
gtk_widget_set_margin_start (vbox, 5);
|
||||
gtk_widget_set_margin_end (vbox, 5);
|
||||
|
||||
gtk_window_set_child (GTK_WINDOW (window), vbox);
|
||||
|
||||
/* Sensitive */
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
|
Loading…
Reference in New Issue
Block a user