mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
Merge branch 'deprecation-cleanups' into 'main'
gtk-demo: Remove deprecations from dnd See merge request GNOME/gtk!5160
This commit is contained in:
commit
93f9b2d519
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
|
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
|
||||||
|
|
||||||
@ -26,6 +25,9 @@ struct _CanvasItem {
|
|||||||
double delta;
|
double delta;
|
||||||
|
|
||||||
GtkWidget *editor;
|
GtkWidget *editor;
|
||||||
|
|
||||||
|
GtkStyleProvider *provider;
|
||||||
|
char *css_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CanvasItemClass {
|
struct _CanvasItemClass {
|
||||||
@ -36,32 +38,41 @@ G_DEFINE_TYPE (CanvasItem, canvas_item, GTK_TYPE_WIDGET)
|
|||||||
|
|
||||||
static int n_items = 0;
|
static int n_items = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
unstyle_item (CanvasItem *item)
|
||||||
|
{
|
||||||
|
if (item->provider)
|
||||||
|
{
|
||||||
|
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (item->label), item->provider);
|
||||||
|
g_clear_object (&item->provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->css_class)
|
||||||
|
{
|
||||||
|
gtk_widget_remove_css_class (item->label, item->css_class);
|
||||||
|
g_clear_pointer (&item->css_class, g_free);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_color (CanvasItem *item,
|
set_color (CanvasItem *item,
|
||||||
GdkRGBA *color)
|
GdkRGBA *color)
|
||||||
{
|
{
|
||||||
char *css;
|
char *css;
|
||||||
char *str;
|
char *str;
|
||||||
GtkStyleContext *context;
|
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
const char *old_class;
|
const char *name;
|
||||||
|
|
||||||
|
unstyle_item (item);
|
||||||
|
|
||||||
str = gdk_rgba_to_string (color);
|
str = gdk_rgba_to_string (color);
|
||||||
css = g_strdup_printf ("* { background: %s; }", str);
|
name = gtk_widget_get_name (item->label);
|
||||||
|
css = g_strdup_printf ("#%s { background: %s; }", name, str);
|
||||||
context = gtk_widget_get_style_context (item->label);
|
|
||||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
|
||||||
if (provider)
|
|
||||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
|
||||||
|
|
||||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
|
||||||
if (old_class)
|
|
||||||
gtk_widget_remove_css_class (item->label, old_class);
|
|
||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
provider = gtk_css_provider_new ();
|
||||||
gtk_css_provider_load_from_data (provider, css, -1);
|
gtk_css_provider_load_from_data (provider, css, -1);
|
||||||
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
|
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
|
||||||
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
|
item->provider = GTK_STYLE_PROVIDER (provider);
|
||||||
|
|
||||||
g_free (str);
|
g_free (str);
|
||||||
g_free (css);
|
g_free (css);
|
||||||
@ -71,21 +82,10 @@ static void
|
|||||||
set_css (CanvasItem *item,
|
set_css (CanvasItem *item,
|
||||||
const char *class)
|
const char *class)
|
||||||
{
|
{
|
||||||
GtkStyleContext *context;
|
unstyle_item (item);
|
||||||
GtkCssProvider *provider;
|
|
||||||
const char *old_class;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (item->label);
|
|
||||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
|
||||||
if (provider)
|
|
||||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
|
||||||
|
|
||||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
|
||||||
if (old_class)
|
|
||||||
gtk_widget_remove_css_class (item->label, old_class);
|
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
|
|
||||||
gtk_widget_add_css_class (item->label, class);
|
gtk_widget_add_css_class (item->label, class);
|
||||||
|
item->css_class = g_strdup (class);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -724,6 +724,7 @@ do_dnd (GtkWidget *do_widget)
|
|||||||
int i;
|
int i;
|
||||||
int x, y;
|
int x, y;
|
||||||
GtkCssProvider *provider;
|
GtkCssProvider *provider;
|
||||||
|
GString *css;
|
||||||
|
|
||||||
button = gtk_color_button_new ();
|
button = gtk_color_button_new ();
|
||||||
g_object_unref (g_object_ref_sink (button));
|
g_object_unref (g_object_ref_sink (button));
|
||||||
@ -735,6 +736,18 @@ do_dnd (GtkWidget *do_widget)
|
|||||||
800);
|
800);
|
||||||
g_object_unref (provider);
|
g_object_unref (provider);
|
||||||
|
|
||||||
|
css = g_string_new ("");
|
||||||
|
for (i = 0; colors[i]; i++)
|
||||||
|
g_string_append_printf (css, ".canvasitem.%s { background: %s; }\n", colors[i], colors[i]);
|
||||||
|
|
||||||
|
provider = gtk_css_provider_new ();
|
||||||
|
gtk_css_provider_load_from_data (provider, css->str, css->len);
|
||||||
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||||
|
GTK_STYLE_PROVIDER (provider),
|
||||||
|
800);
|
||||||
|
g_object_unref (provider);
|
||||||
|
g_string_free (css, TRUE);
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_display (GTK_WINDOW (window),
|
gtk_window_set_display (GTK_WINDOW (window),
|
||||||
gtk_widget_get_display (do_widget));
|
gtk_widget_get_display (do_widget));
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static GtkWidget *window = NULL;
|
static GtkWidget *window = NULL;
|
||||||
static GtkWidget *font_button = NULL;
|
static GtkWidget *font_button = NULL;
|
||||||
static GtkWidget *entry = NULL;
|
static GtkWidget *entry = NULL;
|
||||||
@ -45,7 +43,6 @@ update_image (void)
|
|||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GdkPixbuf *pixbuf2;
|
GdkPixbuf *pixbuf2;
|
||||||
const char *hint;
|
|
||||||
cairo_font_options_t *fopt;
|
cairo_font_options_t *fopt;
|
||||||
cairo_hint_style_t hintstyle;
|
cairo_hint_style_t hintstyle;
|
||||||
cairo_hint_metrics_t hintmetrics;
|
cairo_hint_metrics_t hintmetrics;
|
||||||
@ -60,18 +57,23 @@ update_image (void)
|
|||||||
|
|
||||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||||
|
|
||||||
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
|
switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting)))
|
||||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
|
||||||
if (hint)
|
|
||||||
{
|
{
|
||||||
if (strcmp (hint, "none") == 0)
|
case 0:
|
||||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||||
else if (strcmp (hint, "slight") == 0)
|
break;
|
||||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
case 1:
|
||||||
else if (strcmp (hint, "medium") == 0)
|
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
break;
|
||||||
else if (strcmp (hint, "full") == 0)
|
case 2:
|
||||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
cairo_font_options_set_hint_style (fopt, hintstyle);
|
cairo_font_options_set_hint_style (fopt, hintstyle);
|
||||||
|
|
||||||
@ -420,7 +422,7 @@ do_fontrendering (GtkWidget *do_widget)
|
|||||||
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
|
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
|
||||||
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
|
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
|
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (hinting, "notify::selected", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
|
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
|
||||||
|
@ -116,15 +116,18 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBoxText" id="hinting">
|
<object class="GtkDropDown" id="hinting">
|
||||||
<property name="active">0</property>
|
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<items>
|
<property name="model">
|
||||||
<item translatable="yes" id="none">None</item>
|
<object class="GtkStringList">
|
||||||
<item translatable="yes" id="slight">Slight</item>
|
<items>
|
||||||
<item translatable="yes" id="medium">Medium</item>
|
<item translatable="yes">None</item>
|
||||||
<item translatable="yes" id="full">Full</item>
|
<item translatable="yes">Slight</item>
|
||||||
</items>
|
<item translatable="yes">Medium</item>
|
||||||
|
<item translatable="yes">Full</item>
|
||||||
|
</items>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<layout>
|
<layout>
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#include "gtkshadertoy.h"
|
#include "gtkshadertoy.h"
|
||||||
#include "gskshaderpaintable.h"
|
#include "gskshaderpaintable.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static GtkWidget *demo_window = NULL;
|
static GtkWidget *demo_window = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -146,7 +144,6 @@ make_shader_stack (const char *name,
|
|||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GtkEventController *controller;
|
GtkEventController *controller;
|
||||||
GtkCssProvider *provider;
|
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
|
||||||
stack = gtk_shader_stack_new ();
|
stack = gtk_shader_stack_new ();
|
||||||
@ -237,12 +234,6 @@ make_shader_stack (const char *name,
|
|||||||
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
|
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
|
||||||
g_object_set_data (G_OBJECT (button), "the-stack", stack);
|
g_object_set_data (G_OBJECT (button), "the-stack", stack);
|
||||||
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
|
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
|
||||||
provider = gtk_css_provider_new ();
|
|
||||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
|
||||||
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
|
|
||||||
GTK_STYLE_PROVIDER (provider),
|
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
||||||
g_object_unref (provider);
|
|
||||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||||
gtk_widget_add_css_class (button, "small");
|
gtk_widget_add_css_class (button, "small");
|
||||||
@ -276,11 +267,21 @@ make_shader_stack (const char *name,
|
|||||||
return vbox;
|
return vbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_provider (gpointer data)
|
||||||
|
{
|
||||||
|
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||||
|
|
||||||
|
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||||
|
g_object_unref (provider);
|
||||||
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
create_gltransition_window (GtkWidget *do_widget)
|
create_gltransition_window (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
|
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
GtkCssProvider *provider;
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||||
@ -335,6 +336,14 @@ create_gltransition_window (GtkWidget *do_widget)
|
|||||||
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
|
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
|
||||||
1, 1, 1, 1);
|
1, 1, 1, 1);
|
||||||
|
|
||||||
|
provider = gtk_css_provider_new ();
|
||||||
|
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||||
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||||
|
GTK_STYLE_PROVIDER (provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
#include "script-names.h"
|
#include "script-names.h"
|
||||||
#include "unicode-names.h"
|
#include "unicode-names.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
#define UCD_TYPE_ITEM (ucd_item_get_type ())
|
#define UCD_TYPE_ITEM (ucd_item_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
|
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
|
||||||
|
|
||||||
@ -339,6 +337,15 @@ create_ucd_view (GtkWidget *label)
|
|||||||
|
|
||||||
static GtkWidget *window;
|
static GtkWidget *window;
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_provider (gpointer data)
|
||||||
|
{
|
||||||
|
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||||
|
|
||||||
|
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||||
|
g_object_unref (provider);
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
do_listview_ucd (GtkWidget *do_widget)
|
do_listview_ucd (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
@ -361,7 +368,7 @@ do_listview_ucd (GtkWidget *do_widget)
|
|||||||
gtk_widget_add_css_class (label, "enormous");
|
gtk_widget_add_css_class (label, "enormous");
|
||||||
provider = gtk_css_provider_new ();
|
provider = gtk_css_provider_new ();
|
||||||
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
|
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
|
||||||
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||||
gtk_widget_set_hexpand (label, TRUE);
|
gtk_widget_set_hexpand (label, TRUE);
|
||||||
gtk_box_append (GTK_BOX (box), label);
|
gtk_box_append (GTK_BOX (box), label);
|
||||||
|
|
||||||
@ -371,6 +378,8 @@ do_listview_ucd (GtkWidget *do_widget)
|
|||||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||||
gtk_box_prepend (GTK_BOX (box), sw);
|
gtk_box_prepend (GTK_BOX (box), sw);
|
||||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (window))
|
if (!gtk_widget_get_visible (window))
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/* Create an object for the pegs that get moved around in the game.
|
/* Create an object for the pegs that get moved around in the game.
|
||||||
*
|
*
|
||||||
@ -361,6 +360,15 @@ drop_drop (GtkDropTarget *target,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_provider (gpointer data)
|
||||||
|
{
|
||||||
|
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||||
|
|
||||||
|
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||||
|
g_object_unref (provider);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_board (GtkWidget *window)
|
create_board (GtkWidget *window)
|
||||||
{
|
{
|
||||||
@ -377,6 +385,9 @@ create_board (GtkWidget *window)
|
|||||||
|
|
||||||
provider = gtk_css_provider_new ();
|
provider = gtk_css_provider_new ();
|
||||||
gtk_css_provider_load_from_data (provider, css, -1);
|
gtk_css_provider_load_from_data (provider, css, -1);
|
||||||
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||||
|
GTK_STYLE_PROVIDER (provider),
|
||||||
|
800);
|
||||||
|
|
||||||
grid = gtk_grid_new ();
|
grid = gtk_grid_new ();
|
||||||
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
|
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
|
||||||
@ -395,9 +406,6 @@ create_board (GtkWidget *window)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
image = gtk_image_new ();
|
image = gtk_image_new ();
|
||||||
gtk_style_context_add_provider (gtk_widget_get_style_context (image),
|
|
||||||
GTK_STYLE_PROVIDER (provider),
|
|
||||||
800);
|
|
||||||
gtk_widget_add_css_class (image, "solitaire-field");
|
gtk_widget_add_css_class (image, "solitaire-field");
|
||||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||||
if (x != 3 || y != 3)
|
if (x != 3 || y != 3)
|
||||||
@ -441,7 +449,7 @@ create_board (GtkWidget *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (provider);
|
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -16,7 +16,6 @@ enum {
|
|||||||
NUM_PROPERTIES
|
NUM_PROPERTIES
|
||||||
};
|
};
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
|
||||||
static void
|
static void
|
||||||
pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||||
GdkSnapshot *snapshot,
|
GdkSnapshot *snapshot,
|
||||||
@ -37,7 +36,6 @@ pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
|||||||
|
|
||||||
g_object_unref (texture);
|
g_object_unref (texture);
|
||||||
}
|
}
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||||
|
@ -16,26 +16,6 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/* Convenience function to create a combo box holding a number of strings
|
|
||||||
*/
|
|
||||||
GtkWidget *
|
|
||||||
create_combo_box (const char **strings)
|
|
||||||
{
|
|
||||||
GtkWidget *combo_box;
|
|
||||||
const char **str;
|
|
||||||
|
|
||||||
combo_box = gtk_combo_box_text_new ();
|
|
||||||
|
|
||||||
for (str = strings; *str; str++)
|
|
||||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), *str);
|
|
||||||
|
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
|
|
||||||
|
|
||||||
return combo_box;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_row (GtkGrid *table,
|
add_row (GtkGrid *table,
|
||||||
int row,
|
int row,
|
||||||
@ -43,7 +23,7 @@ add_row (GtkGrid *table,
|
|||||||
const char *label_text,
|
const char *label_text,
|
||||||
const char **options)
|
const char **options)
|
||||||
{
|
{
|
||||||
GtkWidget *combo_box;
|
GtkWidget *dropdown;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
|
||||||
label = gtk_label_new_with_mnemonic (label_text);
|
label = gtk_label_new_with_mnemonic (label_text);
|
||||||
@ -52,12 +32,12 @@ add_row (GtkGrid *table,
|
|||||||
gtk_widget_set_hexpand (label, TRUE);
|
gtk_widget_set_hexpand (label, TRUE);
|
||||||
gtk_grid_attach (table, label, 0, row, 1, 1);
|
gtk_grid_attach (table, label, 0, row, 1, 1);
|
||||||
|
|
||||||
combo_box = create_combo_box (options);
|
dropdown = gtk_drop_down_new_from_strings (options);
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dropdown);
|
||||||
gtk_widget_set_halign (combo_box, GTK_ALIGN_END);
|
gtk_widget_set_halign (dropdown, GTK_ALIGN_END);
|
||||||
gtk_widget_set_valign (combo_box, GTK_ALIGN_BASELINE);
|
gtk_widget_set_valign (dropdown, GTK_ALIGN_BASELINE);
|
||||||
gtk_size_group_add_widget (size_group, combo_box);
|
gtk_size_group_add_widget (size_group, dropdown);
|
||||||
gtk_grid_attach (table, combo_box, 1, row, 1, 1);
|
gtk_grid_attach (table, dropdown, 1, row, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include <stdlib.h> /* for exit() */
|
#include <stdlib.h> /* for exit() */
|
||||||
#include "paintable.h"
|
#include "paintable.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static void easter_egg_callback (GtkWidget *button, gpointer data);
|
static void easter_egg_callback (GtkWidget *button, gpointer data);
|
||||||
|
|
||||||
@ -431,11 +430,11 @@ attach_widgets (GtkTextView *text_view)
|
|||||||
}
|
}
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
{
|
{
|
||||||
widget = gtk_combo_box_text_new ();
|
const char *options[] = {
|
||||||
|
"Option 1", "Option 2", "Option 3", NULL
|
||||||
|
};
|
||||||
|
|
||||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 1");
|
widget = gtk_drop_down_new_from_strings (options);
|
||||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 2");
|
|
||||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 3");
|
|
||||||
}
|
}
|
||||||
else if (i == 2)
|
else if (i == 2)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GtkApplication parent_instance;
|
GtkApplication parent_instance;
|
||||||
@ -352,7 +350,8 @@ quit_activated (GSimpleAction *action,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
combo_changed (GtkComboBox *combo,
|
combo_changed (GtkDropDown *combo,
|
||||||
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkDialog *dialog = user_data;
|
GtkDialog *dialog = user_data;
|
||||||
@ -361,7 +360,7 @@ combo_changed (GtkComboBox *combo,
|
|||||||
char **accels;
|
char **accels;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
action = gtk_combo_box_get_active_id (combo);
|
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
|
||||||
|
|
||||||
if (!action)
|
if (!action)
|
||||||
return;
|
return;
|
||||||
@ -390,7 +389,7 @@ response (GtkDialog *dialog,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
||||||
GtkComboBox *combo = g_object_get_data (user_data, "combo");
|
GtkDropDown *combo = g_object_get_data (user_data, "combo");
|
||||||
const char *action;
|
const char *action;
|
||||||
const char *str;
|
const char *str;
|
||||||
char **accels;
|
char **accels;
|
||||||
@ -401,7 +400,7 @@ response (GtkDialog *dialog,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
action = gtk_combo_box_get_active_id (combo);
|
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
|
||||||
|
|
||||||
if (!action)
|
if (!action)
|
||||||
return;
|
return;
|
||||||
@ -426,6 +425,7 @@ edit_accels (GSimpleAction *action,
|
|||||||
char **actions;
|
char **actions;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
int i;
|
int i;
|
||||||
|
GtkStringList *strings;
|
||||||
|
|
||||||
dialog = gtk_dialog_new_with_buttons ("Accelerators",
|
dialog = gtk_dialog_new_with_buttons ("Accelerators",
|
||||||
NULL,
|
NULL,
|
||||||
@ -437,7 +437,8 @@ edit_accels (GSimpleAction *action,
|
|||||||
gtk_window_set_application (GTK_WINDOW (dialog), app);
|
gtk_window_set_application (GTK_WINDOW (dialog), app);
|
||||||
actions = gtk_application_list_action_descriptions (app);
|
actions = gtk_application_list_action_descriptions (app);
|
||||||
|
|
||||||
combo = gtk_combo_box_text_new ();
|
strings = gtk_string_list_new (NULL);
|
||||||
|
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||||
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
|
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
|
||||||
"margin-top", 10,
|
"margin-top", 10,
|
||||||
"margin-bottom", 10,
|
"margin-bottom", 10,
|
||||||
@ -448,8 +449,8 @@ edit_accels (GSimpleAction *action,
|
|||||||
|
|
||||||
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), combo);
|
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), combo);
|
||||||
for (i = 0; actions[i]; i++)
|
for (i = 0; actions[i]; i++)
|
||||||
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), actions[i], actions[i]);
|
gtk_string_list_append (strings, actions[i]);
|
||||||
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed), dialog);
|
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
|
||||||
|
|
||||||
entry = gtk_entry_new ();
|
entry = gtk_entry_new ();
|
||||||
gtk_widget_set_hexpand (entry, TRUE);
|
gtk_widget_set_hexpand (entry, TRUE);
|
||||||
@ -460,7 +461,7 @@ edit_accels (GSimpleAction *action,
|
|||||||
g_object_set_data (G_OBJECT (dialog), "combo", combo);
|
g_object_set_data (G_OBJECT (dialog), "combo", combo);
|
||||||
g_object_set_data (G_OBJECT (dialog), "entry", entry);
|
g_object_set_data (G_OBJECT (dialog), "entry", entry);
|
||||||
|
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,6 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkFileChooserWidget:
|
* GtkFileChooserWidget:
|
||||||
*
|
*
|
||||||
|
@ -25,94 +25,13 @@
|
|||||||
|
|
||||||
#include "gtkfilechooserutils.h"
|
#include "gtkfilechooserutils.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "deprecated/gtktreedatalistprivate.h"
|
|
||||||
#include "deprecated/gtktreednd.h"
|
|
||||||
#include "gtkfilter.h"
|
#include "gtkfilter.h"
|
||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
/*** Structure: how GtkFileSystemModel works
|
|
||||||
*
|
|
||||||
* This is a custom GtkTreeModel used to hold a collection of files for GtkFileChooser. There are two use cases:
|
|
||||||
*
|
|
||||||
* 1. The model populates itself from a folder, using the GIO file enumerator API. This happens if you use
|
|
||||||
* _gtk_file_system_model_new_for_directory(). This is the normal usage for showing the contents of a folder.
|
|
||||||
*
|
|
||||||
* 2. The caller populates the model by hand, with files not necessarily in the same folder. This happens
|
|
||||||
* if you use _gtk_file_system_model_new() and then _gtk_file_system_model_add_and_query_file(). This is
|
|
||||||
* the special kind of usage for “search” and “recent-files”, where the file chooser gives the model the
|
|
||||||
* files to be displayed.
|
|
||||||
*
|
|
||||||
* Internal data structure
|
|
||||||
* -----------------------
|
|
||||||
*
|
|
||||||
* Each file is kept in a FileModelNode structure. Each FileModelNode holds a GFile* and other data. All the
|
|
||||||
* node structures have the same size, determined at runtime, depending on the number of columns that were passed
|
|
||||||
* to _gtk_file_system_model_new() or _gtk_file_system_model_new_for_directory() (that is, the size of a node is
|
|
||||||
* not sizeof (FileModelNode), but rather model->node_size). The last field in the FileModelNode structure,
|
|
||||||
* node->values[], is an array of GValue, used to hold the data for those columns.
|
|
||||||
*
|
|
||||||
* The model stores an array of FileModelNode structures in model->files. This is a GArray where each element is
|
|
||||||
* model->node_size bytes in size (the model computes that node size when initializing itself). There are
|
|
||||||
* convenience macros, get_node() and node_index(), to access that array based on an array index or a pointer to
|
|
||||||
* a node inside the array.
|
|
||||||
*
|
|
||||||
* The model accesses files through two of its fields:
|
|
||||||
*
|
|
||||||
* model->files - GArray of FileModelNode structures.
|
|
||||||
*
|
|
||||||
* model->file_lookup - hash table that maps a GFile* to an index inside the model->files array.
|
|
||||||
*
|
|
||||||
* The model->file_lookup hash table is populated lazily. It is both accessed and populated with the
|
|
||||||
* node_get_for_file() function. The invariant is that the files in model->files[n] for n < g_hash_table_size
|
|
||||||
* (model->file_lookup) are already added to the hash table.
|
|
||||||
*
|
|
||||||
* Each FileModelNode has a node->visible field, which indicates whether the node is visible in the GtkTreeView.
|
|
||||||
* A node may be invisible if, for example, it corresponds to a hidden file and the file chooser is not showing
|
|
||||||
* hidden files. Also, a file filter may be explicitly set onto the model, for example, to only show files that
|
|
||||||
* match “*.jpg”. In this case, node->filtered_out says whether the node failed the filter. The ultimate
|
|
||||||
* decision on whether a node is visible or not in the treeview is distilled into the node->visible field.
|
|
||||||
* The reason for having a separate node->filtered_out field is so that the file chooser can query whether
|
|
||||||
* a (filtered-out) folder should be made sensitive in the GUI.
|
|
||||||
*
|
|
||||||
* Visible rows vs. possibly-invisible nodes
|
|
||||||
* -----------------------------------------
|
|
||||||
*
|
|
||||||
* Since not all nodes in the model->files array may be visible, we need a way to map visible row indexes from
|
|
||||||
* the treeview to array indexes in our array of files. And thus we introduce a bit of terminology:
|
|
||||||
*
|
|
||||||
* index - An index in the model->files array. All variables/fields that represent indexes are either called
|
|
||||||
* “index” or “i_*”, or simply “i” for things like loop counters.
|
|
||||||
*
|
|
||||||
* row - An index in the GtkTreeView, i.e. the index of a row within the outward-facing API of the
|
|
||||||
* GtkFileSystemModel. However, note that our rows are 1-based, not 0-based, for the reason explained in the
|
|
||||||
* following paragraph. Variables/fields that represent visible rows are called “row”, or “r_*”, or simply
|
|
||||||
* “r”.
|
|
||||||
*
|
|
||||||
* Each FileModelNode has a node->row field which is the number of visible rows in the treeview, *before and
|
|
||||||
* including* that node. This means that node->row is 1-based, instead of 0-based --- this makes some code
|
|
||||||
* simpler, believe it or not :) This also means that when the calling GtkTreeView gives us a GtkTreePath, we
|
|
||||||
* turn the 0-based treepath into a 1-based row for our purposes. If a node is not visible, it will have the
|
|
||||||
* same row number as its closest preceding visible node.
|
|
||||||
*
|
|
||||||
* We try to compute the node->row fields lazily. A node is said to be “valid” if its node->row is accurate.
|
|
||||||
* For this, the model keeps a model->n_nodes_valid field which is the count of valid nodes starting from the
|
|
||||||
* beginning of the model->files array. When a node changes its information, or when a node gets deleted, that
|
|
||||||
* node and the following ones get invalidated by simply setting model->n_nodes_valid to the array index of the
|
|
||||||
* node. If the model happens to need a node’s row number and that node is in the model->files array after
|
|
||||||
* model->n_nodes_valid, then the nodes get re-validated up to the sought node. See node_validate_rows() for
|
|
||||||
* this logic.
|
|
||||||
*
|
|
||||||
* You never access a node->row directly. Instead, call node_get_tree_row(). That function will validate the nodes
|
|
||||||
* up to the sought one if the node is not valid yet, and it will return a proper 0-based row.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*** DEFINES ***/
|
|
||||||
|
|
||||||
/* priority used for all async callbacks in the main loop
|
/* priority used for all async callbacks in the main loop
|
||||||
* This should be higher than redraw priorities so multiple callbacks
|
* This should be higher than redraw priorities so multiple callbacks
|
||||||
* firing can be handled without intermediate redraws */
|
* firing can be handled without intermediate redraws
|
||||||
|
*/
|
||||||
#define IO_PRIORITY G_PRIORITY_DEFAULT
|
#define IO_PRIORITY G_PRIORITY_DEFAULT
|
||||||
|
|
||||||
/* random number that everyone else seems to use, too */
|
/* random number that everyone else seems to use, too */
|
||||||
|
@ -1870,9 +1870,7 @@ find_affected_text (GtkFontChooserWidget *fontchooser,
|
|||||||
|
|
||||||
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
|
||||||
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
if (hb_ot_layout_language_find_feature (hb_face,
|
if (hb_ot_layout_language_find_feature (hb_face,
|
||||||
HB_OT_TAG_GSUB,
|
HB_OT_TAG_GSUB,
|
||||||
@ -2013,9 +2011,7 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
|
|||||||
|
|
||||||
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
|
||||||
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
|
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
|
||||||
{
|
{
|
||||||
@ -2565,9 +2561,7 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
|
|||||||
{
|
{
|
||||||
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
|
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
hb_ot_layout_script_select_language (hb_face, table[i], script_index, 1, &lang_tag, &lang_index);
|
||||||
hb_ot_layout_script_find_language (hb_face, table[i], script_index, lang_tag, &lang_index);
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
feat = features + n_features;
|
feat = features + n_features;
|
||||||
count = G_N_ELEMENTS (features) - n_features;
|
count = G_N_ELEMENTS (features) - n_features;
|
||||||
|
@ -520,8 +520,6 @@ on_remove_server_button_clicked (RemoveServerData *data)
|
|||||||
populate_servers (data->view);
|
populate_servers (data->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
populate_servers (GtkPlacesView *view)
|
populate_servers (GtkPlacesView *view)
|
||||||
{
|
{
|
||||||
@ -617,8 +615,6 @@ populate_servers (GtkPlacesView *view)
|
|||||||
g_bookmark_file_free (server_list);
|
g_bookmark_file_free (server_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_view_mode (GtkPlacesView *view)
|
update_view_mode (GtkPlacesView *view)
|
||||||
{
|
{
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
|
||||||
|
|
||||||
struct _GtkSearchEngineModel
|
struct _GtkSearchEngineModel
|
||||||
{
|
{
|
||||||
GtkSearchEngine parent;
|
GtkSearchEngine parent;
|
||||||
|
Loading…
Reference in New Issue
Block a user