Compare commits

..

9 Commits

Author SHA1 Message Date
Matthias Clasen c85905dfcd Add an experiment
This is a suggestion entry that does infix
matching, highlights the match, and sorts
the matches by relevance.
2020-07-10 15:40:12 -04:00
Matthias Clasen e2eba253cb suggestionentry: Update action enabledness
Update the action enabledness when appropriate so
that an explicit button does not appear insensitive
when it shouldn't.
2020-07-10 14:47:54 -04:00
Matthias Clasen 09d1129f4f suggestionentry: Work better without a filter
Make it possible to use the suggestion entry
by doing filtering in the model yourself, and
set use-filter to FALSE. We are still getting
the popup behavior, but inserting prefixes
can't be guaranteed to work well if the
filtering isn't doing prefix matching.
2020-07-10 13:58:42 -04:00
Matthias Clasen affa829ac2 suggestionentry: Handle no-model situations
We shouldn't throw criticals when there is no
model. Just act like a plain entry.
2020-07-10 13:56:16 -04:00
Matthias Clasen da397664b4 docs: Mention GtkSuggestionEntry in list widget overview 2020-07-10 13:56:16 -04:00
Matthias Clasen d3b32e9f42 gtk-demo: Add suggestion entry demos
Move the Dropdowns demo to Lists/Selections,
and make it show both GtkDropDown and
GtkSuggestionEntry, with some variations.
2020-07-10 13:56:16 -04:00
Matthias Clasen e2d92863b2 suggestionentry: Add minimum-length
A direct copy of GtkEntryCompletion:minimmum-key-length.
2020-07-10 13:56:16 -04:00
Matthias Clasen f9e1e7bd1a suggestionentry: Add an optional button
This is useful for comboboxtext-like use cases.
To simulate comboboxtext behavior, set
use-filter = FALSE
show-button = TRUE
insert-selection = TRUE
2020-07-10 13:56:16 -04:00
Matthias Clasen 641c068744 Add GtkSuggestionEntry
GtkSuggestionEntry is a replacement for GtkComboBoxText
and GtkEntryCompletion, very similar to GtkDropDown, but
using an entry as widget.
2020-07-10 13:56:16 -04:00
170 changed files with 10328 additions and 9363 deletions
+1 -7
View File
@@ -30,9 +30,6 @@ Overview of Changes in GTK 3.99.0
- Improve scrolling behavior
- Autoscroll and autoexpand during DND
* GtkScrolledWindow:
- Make autoscrolling work again
* GtkFilterListModel:
- Add incremental filtering
@@ -51,15 +48,12 @@ Overview of Changes in GTK 3.99.0
- Improve frame clock accuracy
* GSK:
- Use GL_ARB_framebuffer_object
- Use gL_ARB_framebuffer_object
* gtk-demo:
- Add incremental refill to the color grid
- Improve performance of the color grid
- Add an incrementally filtering word list
- Improve the sidebar
* Install print-editor as another demo
* Translation updates
Basque
+31 -45
View File
@@ -1,38 +1,29 @@
{
"app-id" : "org.gtk.WidgetFactory4",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
"command" : "gtk4-widget-factory",
"tags" : [
"devel",
"development",
"nightly"
],
"desktop-file-name-prefix" : "(Development) ",
"finish-args" : [
"app-id": "org.gtk.WidgetFactory4",
"runtime": "org.gnome.Platform",
"runtime-version": "master",
"sdk": "org.gnome.Sdk",
"command": "gtk4-widget-factory",
"tags": ["devel", "development", "nightly"],
"desktop-file-name-prefix": "(Development) ",
"finish-args": [
"--device=dri",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--talk-name=org.gtk.vfs",
"--talk-name=org.gtk.vfs.*"
"--talk-name=org.gtk.vfs", "--talk-name=org.gtk.vfs.*"
],
"cleanup" : [
"cleanup": [
"/include",
"/lib/pkgconfig",
"/share/pkgconfig",
"/lib/pkgconfig", "/share/pkgconfig",
"/share/aclocal",
"/man",
"/share/man",
"/share/gtk-doc",
"*.la",
".a",
"/man", "/share/man", "/share/gtk-doc",
"*.la", ".a",
"/lib/girepository-1.0",
"/share/gir-1.0",
"/share/doc"
],
"modules" : [
"modules": [
{
"name" : "wayland",
"buildsystem" : "autotools",
@@ -48,18 +39,18 @@
]
},
{
"name" : "graphene",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"name": "graphene",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"--libdir=/app/lib",
"-Dtests=false",
"-Dbenchmarks=false"
],
"sources" : [
"sources": [
{
"type" : "git",
"url" : "https://github.com/ebassi/graphene.git"
"type": "git",
"url": "https://github.com/ebassi/graphene.git"
}
]
},
@@ -67,7 +58,7 @@
"name" : "libsass",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
@@ -82,7 +73,7 @@
"name" : "sassc",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
@@ -94,23 +85,18 @@
]
},
{
"name" : "gtk",
"buildsystem" : "meson",
"builddir" : true,
"config-opts" : [
"name": "gtk",
"buildsystem": "meson",
"builddir": true,
"config-opts": [
"--libdir=/app/lib"
],
"sources" : [
"sources": [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/gtk.git"
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/gtk.git"
}
]
}
],
"build-options" : {
"env" : {
"DBUS_SESSION_BUS_ADDRESS" : "''"
}
}
]
}
+12 -78
View File
@@ -597,83 +597,6 @@ css_button_new (const char *class)
return button;
}
typedef struct
{
GtkWidget parent_instance;
GdkRGBA color;
} ColorSwatch;
typedef struct
{
GtkWidgetClass parent_class;
} ColorSwatchClass;
G_DEFINE_TYPE (ColorSwatch, color_swatch, GTK_TYPE_WIDGET)
static GdkContentProvider *
color_swatch_drag_prepare (GtkDragSource *source,
double x,
double y,
ColorSwatch *swatch)
{
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &swatch->color);
}
static void
color_swatch_init (ColorSwatch *swatch)
{
GtkDragSource *source = gtk_drag_source_new ();
g_signal_connect (source, "prepare", G_CALLBACK (color_swatch_drag_prepare), swatch);
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (source));
}
static void
color_swatch_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
ColorSwatch *swatch = (ColorSwatch *)widget;
float w = gtk_widget_get_width (widget);
float h = gtk_widget_get_height (widget);
gtk_snapshot_append_color (snapshot, &swatch->color,
&GRAPHENE_RECT_INIT(0, 0, w, h));
}
void
color_swatch_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum_size,
int *natural_size,
int *minimum_baseline,
int *natural_baseline)
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
*minimum_size = *natural_size = 48;
else
*minimum_size = *natural_size = 32;
}
static void
color_swatch_class_init (ColorSwatchClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->snapshot = color_swatch_snapshot;
widget_class->measure = color_swatch_measure;
gtk_widget_class_set_css_name (widget_class, "colorswatch");
}
static GtkWidget *
color_swatch_new (const char *color)
{
ColorSwatch *swatch = g_object_new (color_swatch_get_type (), NULL);
gdk_rgba_parse (&swatch->color, color);
return GTK_WIDGET (swatch);
}
static GtkWidget *window = NULL;
GtkWidget *
@@ -747,7 +670,18 @@ do_dnd (GtkWidget *do_widget)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), box3);
for (i = 0; colors[i]; i++)
gtk_box_append (GTK_BOX (box3), color_swatch_new (colors[i]));
{
GdkRGBA rgba;
GtkWidget *swatch;
gdk_rgba_parse (&rgba, colors[i]);
swatch = g_object_new (g_type_from_name ("GtkColorSwatch"),
"rgba", &rgba,
"selectable", FALSE,
NULL);
gtk_box_append (GTK_BOX (box3), swatch);
}
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow1"));
gtk_box_append (GTK_BOX (box3), css_button_new ("rainbow2"));
+178 -28
View File
@@ -1,13 +1,15 @@
/* Drop Downs
/* Lists/Selections
*
* The GtkDropDown widget is a modern alternative to GtkComboBox.
* It uses list models instead of tree models, and the content is
* displayed using widgets instead of cell renderers.
* The GtkDropDown and GtkSuggestionEntry widgets are modern
* alternatives to GtkComboBox and GtkEntryCompletion.
*
* They use list models instead of tree models, and the content
* is displayed using widgets instead of cell renderers.
*
* The examples here demonstrate how to use different kinds of
* list models with GtkDropDown, how to use search and how to
* display the selected item differently from the presentation
* in the popup.
* list models with GtkDropDown and GtkSuggestionEntry, how to
* use search and how to display the selected item differently
* from the presentation in the popup.
*/
#include <gtk/gtk.h>
@@ -218,13 +220,50 @@ get_title (gpointer item)
return g_strdup (STRING_HOLDER (item)->title);
}
static char *
get_file_name (gpointer item)
{
return g_strdup (g_file_info_get_display_name (G_FILE_INFO (item)));
}
static void
setup_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GtkWidget *box;
GtkWidget *icon;
GtkWidget *label;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
icon = gtk_image_new ();
label = gtk_label_new ("");
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_box_append (GTK_BOX (box), icon);
gtk_box_append (GTK_BOX (box), label);
gtk_list_item_set_child (item, box);
}
static void
bind_item (GtkSignalListItemFactory *factory,
GtkListItem *item)
{
GFileInfo *info = G_FILE_INFO (gtk_list_item_get_item (item));
GtkWidget *box = gtk_list_item_get_child (item);
GtkWidget *icon = gtk_widget_get_first_child (box);
GtkWidget *label = gtk_widget_get_last_child (box);
gtk_image_set_from_gicon (GTK_IMAGE (icon), g_file_info_get_icon (info));
gtk_label_set_label (GTK_LABEL (label), g_file_info_get_display_name (info));
}
GtkWidget *
do_dropdown (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
GtkWidget *button, *box, *spin, *check;
GtkWidget *button, *box, *spin, *check, *hbox, *label, *entry;
GListModel *model;
GtkExpression *expression;
GtkListItemFactory *factory;
const char * const times[] = { "1 minute", "2 minutes", "5 minutes", "20 minutes", NULL };
const char * const many_times[] = {
"1 minute", "2 minutes", "5 minutes", "10 minutes", "15 minutes", "20 minutes",
@@ -237,23 +276,78 @@ do_dropdown (GtkWidget *do_widget)
const char * const device_descriptions[] = {
"Built-in Audio", "Built-in audio", "Thinkpad Tunderbolt 3 Dock USB Audio", "Thinkpad Tunderbolt 3 Dock USB Audio", NULL
};
const char *words[] = {
"GNOME",
"gnominious",
"Gnomonic projection",
"total",
"totally",
"toto",
"tottery",
"totterer",
"Totten trust",
"totipotent",
"totipotency",
"totemism",
"totem pole",
"Totara",
"totalizer",
"totalizator",
"totalitarianism",
"total parenteral nutrition",
"total hysterectomy",
"total eclipse",
"Totipresence",
"Totipalmi",
"Tomboy",
"zombie",
NULL
};
char *cwd;
GFile *file;
GListModel *dir;
if (!window)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drop Downs");
gtk_window_set_title (GTK_WINDOW (window), "Selections");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_widget_set_margin_start (box, 10);
gtk_widget_set_margin_end (box, 10);
gtk_widget_set_margin_top (box, 10);
gtk_widget_set_margin_bottom (box, 10);
gtk_window_set_child (GTK_WINDOW (window), box);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
gtk_widget_set_margin_start (hbox, 20);
gtk_widget_set_margin_end (hbox, 20);
gtk_widget_set_margin_top (hbox, 20);
gtk_widget_set_margin_bottom (hbox, 20);
gtk_window_set_child (GTK_WINDOW (window), hbox);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_box_append (GTK_BOX (hbox), box);
label = gtk_label_new ("Dropdowns");
gtk_widget_add_css_class (label, "title-4");
gtk_box_append (GTK_BOX (box), label);
/* A basic dropdown */
button = drop_down_new_from_strings (times, NULL, NULL);
gtk_box_append (GTK_BOX (box), button);
/* A dropdown using an expression to obtain strings */
button = drop_down_new_from_strings (many_times, NULL, NULL);
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_title,
NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
gtk_expression_unref (expression);
gtk_box_append (GTK_BOX (box), button);
/* A dropdown using a non-trivial model, and search */
button = gtk_drop_down_new ();
model = G_LIST_MODEL (pango_cairo_font_map_get_default ());
@@ -270,30 +364,86 @@ do_dropdown (GtkWidget *do_widget)
spin = gtk_spin_button_new_with_range (-1, g_list_model_get_n_items (G_LIST_MODEL (model)), 1);
gtk_widget_set_halign (spin, GTK_ALIGN_START);
gtk_widget_set_margin_start (spin, 20);
g_object_bind_property (button, "selected", spin, "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), spin);
check = gtk_check_button_new_with_label ("Enable search");
gtk_widget_set_margin_start (check, 20);
g_object_bind_property (button, "enable-search", check, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), check);
g_object_unref (model);
button = drop_down_new_from_strings (times, NULL, NULL);
gtk_box_append (GTK_BOX (box), button);
button = drop_down_new_from_strings (many_times, NULL, NULL);
gtk_drop_down_set_enable_search (GTK_DROP_DOWN (button), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_title,
NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (button), expression);
gtk_expression_unref (expression);
gtk_box_append (GTK_BOX (box), button);
/* A dropdown with a separate list factory */
button = drop_down_new_from_strings (device_titles, device_icons, device_descriptions);
gtk_box_append (GTK_BOX (box), button);
gtk_box_append (GTK_BOX (hbox), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_box_append (GTK_BOX (hbox), box);
label = gtk_label_new ("Suggestions");
gtk_widget_add_css_class (label, "title-4");
gtk_box_append (GTK_BOX (box), label);
/* A basic suggestion entry */
entry = gtk_suggestion_entry_new ();
g_object_set (entry, "placeholder-text", "Words with T or G…", NULL);
gtk_suggestion_entry_set_from_strings (GTK_SUGGESTION_ENTRY (entry), words);
gtk_box_append (GTK_BOX (box), entry);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_widget_set_halign (hbox, GTK_ALIGN_START);
gtk_widget_set_margin_start (hbox, 20);
spin = gtk_spin_button_new_with_range (0, 10, 1);
g_object_bind_property (entry, "minimum-length", spin, "value", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (hbox), gtk_label_new ("Min. length"));
gtk_box_append (GTK_BOX (hbox), spin);
gtk_box_append (GTK_BOX (box), hbox);
check = gtk_check_button_new_with_label ("Auto-Insert");
gtk_widget_set_margin_start (check, 20);
g_object_bind_property (entry, "insert-prefix", check, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), check);
check = gtk_check_button_new_with_label ("Auto-Select");
gtk_widget_set_margin_start (check, 20);
g_object_bind_property (entry, "insert-selection", check, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
gtk_box_append (GTK_BOX (box), check);
/* A suggestion entry using a custom model, and no filtering */
entry = gtk_suggestion_entry_new ();
cwd = g_get_current_dir ();
file = g_file_new_for_path (cwd);
dir = G_LIST_MODEL (gtk_directory_list_new ("standard::display-name,standard::content-type,standard::icon,standard::size", file));
gtk_suggestion_entry_set_model (GTK_SUGGESTION_ENTRY (entry), dir);
g_object_unref (dir);
g_object_unref (file);
g_free (cwd);
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL,
0, NULL,
(GCallback)get_file_name,
NULL, NULL);
gtk_suggestion_entry_set_expression (GTK_SUGGESTION_ENTRY (entry), expression);
gtk_expression_unref (expression);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_item), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_item), NULL);
gtk_suggestion_entry_set_factory (GTK_SUGGESTION_ENTRY (entry), factory);
g_object_unref (factory);
gtk_suggestion_entry_set_use_filter (GTK_SUGGESTION_ENTRY (entry), FALSE);
gtk_suggestion_entry_set_show_button (GTK_SUGGESTION_ENTRY (entry), TRUE);
gtk_suggestion_entry_set_insert_selection (GTK_SUGGESTION_ENTRY (entry), TRUE);
gtk_box_append (GTK_BOX (box), entry);
}
if (!gtk_widget_get_visible (window))
+1 -2
View File
@@ -950,8 +950,7 @@ do_listview_colors (GtkWidget *do_widget)
g_object_unref (selection_filter);
g_object_unref (no_selection);
model = gtk_multi_selection_get_model (GTK_MULTI_SELECTION (model));
g_object_ref (model);
g_object_get (model, "model", &model, NULL);
selection_info_toggle = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (selection_info_toggle), "emblem-important-symbolic");
+3 -3
View File
@@ -1,11 +1,11 @@
listview.viewswitcher {
list.viewswitcher {
border: 1px solid gray;
}
listview.viewswitcher > row {
list.viewswitcher > row {
padding: 5px;
}
listview.viewswitcher row:selected {
list.viewswitcher row:selected {
background: gray;
}
+5 -1
View File
@@ -215,6 +215,7 @@ transform_settings_to_keys (GBinding *binding,
GtkFilterListModel *filter_model;
GtkFilter *filter;
GtkNoSelection *selection_model;
GtkExpression *expression;
char **keys;
guint i;
@@ -245,8 +246,11 @@ transform_settings_to_keys (GBinding *binding,
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data)));
g_object_unref (store);
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
expression = gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name");
filter = gtk_string_filter_new ();
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expression);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
gtk_expression_unref (expression);
g_object_unref (sort_model);
g_set_object (&current_filter, filter);
+5 -2
View File
@@ -160,6 +160,7 @@ do_listview_words (GtkWidget *do_widget)
GtkNoSelection *selection;
GtkStringList *stringlist;
GtkFilter *filter;
GtkExpression *expression;
GFile *file;
file = g_file_new_for_path ("/usr/share/dict/words");
@@ -176,7 +177,10 @@ do_listview_words (GtkWidget *do_widget)
g_strfreev (words);
}
filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
filter = gtk_string_filter_new ();
expression = gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string");
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), expression);
gtk_expression_unref (expression);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (stringlist), filter);
gtk_filter_list_model_set_incremental (filter_model, TRUE);
@@ -211,7 +215,6 @@ do_listview_words (GtkWidget *do_widget)
gtk_overlay_add_overlay (GTK_OVERLAY (overlay), progress);
sw = gtk_scrolled_window_new ();
gtk_widget_set_vexpand (sw, TRUE);
gtk_overlay_set_child (GTK_OVERLAY (overlay), sw);
listview = gtk_list_view_new_with_factory (
+4 -113
View File
@@ -18,7 +18,6 @@ static gchar *current_file = NULL;
static GtkWidget *notebook;
static GtkSingleSelection *selection;
static GtkWidget *toplevel;
static char **search_needle;
typedef struct _GtkDemo GtkDemo;
struct _GtkDemo
@@ -946,18 +945,7 @@ selection_cb (GtkSingleSelection *sel,
gpointer user_data)
{
GtkTreeListRow *row = gtk_single_selection_get_selected_item (sel);
GtkDemo *demo;
gtk_widget_set_sensitive (GTK_WIDGET (notebook), !!row);
if (!row)
{
gtk_window_set_title (GTK_WINDOW (toplevel), "No match");
return;
}
demo = gtk_tree_list_row_get_item (row);
GtkDemo *demo = gtk_tree_list_row_get_item (row);
if (demo->filename)
load_file (demo->name, demo->filename);
@@ -965,84 +953,6 @@ selection_cb (GtkSingleSelection *sel,
gtk_window_set_title (GTK_WINDOW (toplevel), demo->title);
}
static gboolean
filter_demo (GtkDemo *demo)
{
int i;
/* Show only if the name maches every needle */
for (i = 0; search_needle[i]; i++)
{
if (!demo->title)
return FALSE;
if (g_str_match_string (search_needle[i], demo->title, TRUE))
continue;
return FALSE;
}
return TRUE;
}
static gboolean
demo_filter_by_name (GtkTreeListRow *row,
GtkFilterListModel *model)
{
GListModel *children;
GtkDemo *demo;
guint i, n;
/* Show all items if search is empty */
if (!search_needle || !search_needle[0] || !*search_needle[0])
return TRUE;
g_assert (GTK_IS_TREE_LIST_ROW (row));
g_assert (GTK_IS_FILTER_LIST_MODEL (model));
children = gtk_tree_list_row_get_children (row);
if (children)
{
n = g_list_model_get_n_items (children);
for (i = 0; i < n; i++)
{
demo = g_list_model_get_item (children, i);
g_assert (GTK_IS_DEMO (demo));
if (filter_demo (demo))
{
g_object_unref (demo);
return TRUE;
}
g_object_unref (demo);
}
}
demo = gtk_tree_list_row_get_item (row);
g_assert (GTK_IS_DEMO (demo));
return filter_demo (demo);
}
static void
demo_search_changed_cb (GtkSearchEntry *entry,
GtkFilter *filter)
{
const char *text;
g_assert (GTK_IS_SEARCH_ENTRY (entry));
g_assert (GTK_IS_FILTER (filter));
text = gtk_editable_get_text (GTK_EDITABLE (entry));
g_clear_pointer (&search_needle, g_strfreev);
if (text && *text)
search_needle = g_strsplit (text, " ", 0);
gtk_filter_changed (filter, GTK_FILTER_CHANGE_DIFFERENT);
}
static GListModel *
create_demo_model (void)
{
@@ -1097,25 +1007,13 @@ get_child_model (gpointer item,
return NULL;
}
static void
clear_search (GtkSearchBar *bar)
{
if (!gtk_search_bar_get_search_mode (bar))
{
GtkWidget *entry = gtk_search_bar_get_child (GTK_SEARCH_BAR (bar));
gtk_editable_set_text (GTK_EDITABLE (entry), "");
}
}
static void
activate (GApplication *app)
{
GtkBuilder *builder;
GListModel *listmodel;
GtkTreeListModel *treemodel;
GtkWidget *window, *listview, *search_entry, *search_bar;
GtkFilterListModel *filter_model;
GtkFilter *filter;
GtkWidget *window, *listview;
static GActionEntry win_entries[] = {
{ "run", activate_run, NULL, NULL, NULL }
@@ -1136,8 +1034,6 @@ activate (GApplication *app)
toplevel = GTK_WIDGET (window);
listview = GTK_WIDGET (gtk_builder_get_object (builder, "listview"));
g_signal_connect (listview, "activate", G_CALLBACK (activate_cb), window);
search_bar = GTK_WIDGET (gtk_builder_get_object (builder, "searchbar"));
g_signal_connect (search_bar, "notify::search-mode-enabled", G_CALLBACK (clear_search), NULL);
listmodel = create_demo_model ();
treemodel = gtk_tree_list_model_new (FALSE,
@@ -1146,13 +1042,7 @@ activate (GApplication *app)
get_child_model,
NULL,
NULL);
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
gtk_filter_list_model_set_filter (filter_model, filter);
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
selection = gtk_single_selection_new (G_LIST_MODEL (filter_model));
selection = gtk_single_selection_new (G_LIST_MODEL (treemodel));
g_signal_connect (selection, "notify::selected-item", G_CALLBACK (selection_cb), NULL);
gtk_list_view_set_model (GTK_LIST_VIEW (listview), G_LIST_MODEL (selection));
@@ -1249,6 +1139,7 @@ out:
demo = (func) (window);
gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
}
+5 -22
View File
@@ -55,29 +55,12 @@
<property name="hscrollbar-policy">never</property>
<property name="min-content-width">150</property>
<child>
<object class="GtkBox">
<property name="width-request">220</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar" id="searchbar">
<property name="key-capture-widget">window</property>
<child>
<object class="GtkSearchEntry" id="search-entry"/>
</child>
<object class="GtkListView" id="listview">
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/ui/main-listitem.ui</property>
</object>
</child>
<child>
<object class="GtkListView" id="listview">
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/ui/main-listitem.ui</property>
</object>
</property>
</object>
</child>
</property>
</object>
</child>
</object>
+1 -1
View File
@@ -18,7 +18,6 @@ demos = files([
'cursors.c',
'dialog.c',
'drawingarea.c',
'dropdown.c',
'dnd.c',
'editable_cells.c',
'entry_completion.c',
@@ -47,6 +46,7 @@ demos = files([
'listview_colors.c',
'listview_filebrowser.c',
'listview_minesweeper.c',
'dropdown.c',
'listview_settings.c',
'listview_weather.c',
'listview_words.c',
@@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="43.000351" x2="85.000351" y1="39.000164" y2="39.000164">
<stop offset="0" stop-color="#26a269"/>
<stop offset="0.0934161" stop-color="#84e3b7"/>
<stop offset="0.330831" stop-color="#26a269"/>
<stop offset="0.686952" stop-color="#26a269"/>
<stop offset="0.89736" stop-color="#175e3c"/>
<stop offset="1" stop-color="#26a269"/>
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#c0bfbc"/>
<stop offset="0.154754" stop-color="#ffffff"/>
<stop offset="0.433722" stop-color="#bdbbb5"/>
<stop offset="0.650505" stop-color="#c1c0ba"/>
<stop offset="0.825253" stop-color="#ffffff"/>
<stop offset="1" stop-color="#c0bfbc"/>
</linearGradient>
<linearGradient id="c" gradientTransform="matrix(0.0811899 -0.046875 0.069079 0.119648 307.03142 127.069456)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="d" gradientTransform="matrix(-0.0811899 -0.046875 -0.069079 0.119648 -177.242852 127.069447)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="e" gradientUnits="userSpaceOnUse" x1="14" x2="56" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#813d9c"/>
<stop offset="0.109119" stop-color="#b378ca"/>
<stop offset="0.241583" stop-color="#813d9c"/>
<stop offset="0.731841" stop-color="#813d9c"/>
<stop offset="0.872163" stop-color="#4d255d"/>
<stop offset="1" stop-color="#813d9c"/>
</linearGradient>
<linearGradient id="f" gradientUnits="userSpaceOnUse" x1="72" x2="114" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#e66100"/>
<stop offset="0.0678478" stop-color="#ff903e"/>
<stop offset="0.168852" stop-color="#e66100"/>
<stop offset="0.886626" stop-color="#e66100"/>
<stop offset="1" stop-color="#9d4200"/>
</linearGradient>
<clipPath id="g">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="h">
<rect height="128" width="128"/>
</clipPath>
<filter id="i" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="j">
<g clip-path="url(#h)" filter="url(#i)">
<g clip-path="url(#g)">
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
</g>
</g>
</mask>
<mask id="k">
<g filter="url(#i)">
<rect fill-opacity="0.8" height="128" width="128"/>
</g>
</mask>
<linearGradient id="l" gradientTransform="matrix(0 0.37 -0.98462 0 295.38501 -30.360001)" gradientUnits="userSpaceOnUse" x1="300" x2="428" y1="235" y2="235">
<stop offset="0" stop-color="#f9f06b"/>
<stop offset="1" stop-color="#f5c211"/>
</linearGradient>
<clipPath id="m">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="n">
<rect height="128" width="128"/>
</clipPath>
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
<g clip-path="url(#n)" mask="url(#j)">
<g clip-path="url(#m)" mask="url(#k)">
<path d="m 128 80.640625 v 47.359375 h -128 v -47.359375 z m 0 0" fill="url(#l)"/>
<path d="m 13.308594 80.640625 l 47.355468 47.359375 h 21.214844 l -47.359375 -47.359375 z m 42.421875 0 l 47.363281 47.359375 h 21.214844 l -47.363282 -47.359375 z m 42.429687 0 l 29.839844 29.839844 v -21.210938 l -8.628906 -8.628906 z m -98.160156 7.90625 v 21.214844 l 18.238281 18.238281 h 21.214844 z m 0 0"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.4 KiB

@@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="43.000351" x2="85.000351" y1="39.000164" y2="39.000164">
<stop offset="0" stop-color="#26a269"/>
<stop offset="0.0934161" stop-color="#84e3b7"/>
<stop offset="0.330831" stop-color="#26a269"/>
<stop offset="0.686952" stop-color="#26a269"/>
<stop offset="0.89736" stop-color="#175e3c"/>
<stop offset="1" stop-color="#26a269"/>
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#c0bfbc"/>
<stop offset="0.154754" stop-color="#ffffff"/>
<stop offset="0.433722" stop-color="#bdbbb5"/>
<stop offset="0.650505" stop-color="#c1c0ba"/>
<stop offset="0.825253" stop-color="#ffffff"/>
<stop offset="1" stop-color="#c0bfbc"/>
</linearGradient>
<linearGradient id="c" gradientTransform="matrix(0.0811899 -0.046875 0.069079 0.119648 307.03142 127.069456)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="d" gradientTransform="matrix(-0.0811899 -0.046875 -0.069079 0.119648 -177.242852 127.069447)" x1="-1710.210571" x2="-1774.45166" xlink:href="#b" y1="-1202.376709" y2="-1202.376709"/>
<linearGradient id="e" gradientUnits="userSpaceOnUse" x1="14" x2="56" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#813d9c"/>
<stop offset="0.109119" stop-color="#b378ca"/>
<stop offset="0.241583" stop-color="#813d9c"/>
<stop offset="0.731841" stop-color="#813d9c"/>
<stop offset="0.872163" stop-color="#4d255d"/>
<stop offset="1" stop-color="#813d9c"/>
</linearGradient>
<linearGradient id="f" gradientUnits="userSpaceOnUse" x1="72" x2="114" y1="94.999964" y2="94.999964">
<stop offset="0" stop-color="#e66100"/>
<stop offset="0.0678478" stop-color="#ff903e"/>
<stop offset="0.168852" stop-color="#e66100"/>
<stop offset="0.886626" stop-color="#e66100"/>
<stop offset="1" stop-color="#9d4200"/>
</linearGradient>
<path d="m 51 18 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 51 12 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#57e389"/>
<path d="m 76.976562 55.453125 c 1.480469 -0.855469 3.371094 -0.347656 4.226563 1.132813 l 6.742187 11.679687 c 0.855469 1.480469 0.347657 3.371094 -1.132812 4.226563 c -1.480469 0.851562 -3.371094 0.347656 -4.226562 -1.132813 l -6.742188 -11.679687 c -0.855469 -1.480469 -0.347656 -3.371094 1.132812 -4.226563 z m 0 0" fill="url(#c)"/>
<path d="m 52.8125 55.453125 c -1.480469 -0.855469 -3.371094 -0.347656 -4.226562 1.132813 l -6.742188 11.679687 c -0.855469 1.480469 -0.347656 3.371094 1.132812 4.226563 c 1.480469 0.851562 3.371094 0.347656 4.226563 -1.132813 l 6.742187 -11.679687 c 0.855469 -1.480469 0.347657 -3.371094 -1.132812 -4.226563 z m 0 0" fill="url(#d)"/>
<path d="m 22 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#e)"/>
<path d="m 22 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#dc8add"/>
<path d="m 80 74 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="url(#f)"/>
<path d="m 80 68 h 26 c 4.417969 0 8 3.582031 8 8 v 26 c 0 4.417969 -3.582031 8 -8 8 h -26 c -4.417969 0 -8 -3.582031 -8 -8 v -26 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#ffa348"/>
</svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
<path d="m 5.75 1 c -0.414062 0 -0.75 0.335938 -0.75 0.75 v 4.5 c 0 0.414062 0.335938 0.75 0.75 0.75 h 0.191406 l -1 2 h -3.191406 c -0.414062 0 -0.75 0.335938 -0.75 0.75 v 4.5 c 0 0.414062 0.335938 0.75 0.75 0.75 h 4.5 c 0.414062 0 0.75 -0.335938 0.75 -0.75 v -4.5 c 0 -0.414062 -0.335938 -0.75 -0.75 -0.75 h -0.191406 l 1 -2 h 1.882812 l 1 2 h -0.191406 c -0.414062 0 -0.75 0.335938 -0.75 0.75 v 4.5 c 0 0.414062 0.335938 0.75 0.75 0.75 h 4.5 c 0.414062 0 0.75 -0.335938 0.75 -0.75 v -4.5 c 0 -0.414062 -0.335938 -0.75 -0.75 -0.75 h -3.191406 l -1 -2 h 0.191406 c 0.414062 0 0.75 -0.335938 0.75 -0.75 v -4.5 c 0 -0.414062 -0.335938 -0.75 -0.75 -0.75 z m 0 0"/>
</svg>

Before

Width:  |  Height:  |  Size: 801 B

-9
View File
@@ -19,12 +19,3 @@ executable('gtk4-node-editor',
gui_app: true,
link_args: extra_demo_ldflags,
install: false)
# icons
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')
foreach size: ['scalable', 'symbolic']
install_subdir('data/' + size,
install_dir: icontheme_dir
)
endforeach
+1 -1
View File
@@ -101,7 +101,7 @@ activate_about (GSimpleAction *action,
"website", "http://www.gtk.org",
"comments", "Program to test GTK rendering",
"authors", (const char *[]){ "Benjamin Otte", "Timm Bäder", NULL},
"logo-icon-name", "org.gtk.gtk4.NodeEditor.Devel",
"logo-icon-name", "text-editor-symbolic",
"title", "About GTK Node Editor",
"system-information", s->str,
NULL);
@@ -1,179 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="a" gradientTransform="matrix(0.232143 0 0 0.328947 -7.567033 263.82666)" gradientUnits="userSpaceOnUse" x1="88.595886" x2="536.595886" y1="-449.394012" y2="-449.394012">
<stop offset="0" stop-color="#acabae"/>
<stop offset="0.0384615" stop-color="#deddda"/>
<stop offset="0.0768555" stop-color="#c0bfbc"/>
<stop offset="0.923077" stop-color="#c0bfbc"/>
<stop offset="0.961538" stop-color="#deddda"/>
<stop offset="1" stop-color="#9a9996"/>
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse" x1="26.999876" x2="100.999876" y1="32.999688" y2="32.999688">
<stop offset="0" stop-color="#7e7c77"/>
<stop offset="0.3" stop-color="#9a9996"/>
<stop offset="1" stop-color="#9a9996"/>
</linearGradient>
<linearGradient id="c" gradientUnits="userSpaceOnUse" x1="67.467916" x2="67.467916" y1="83.999688" y2="36.782906">
<stop offset="0" stop-color="#deddda"/>
<stop offset="1" stop-color="#c0bfbc"/>
</linearGradient>
<clipPath id="d">
<path d="m 79 72 h 15 v 16 h -15 z m 0 0"/>
</clipPath>
<clipPath id="e">
<path d="m 93.21875 72.921875 l -14.21875 14.21875 h -4.0625 v -18.28125 h 18.28125 z m 0 0"/>
</clipPath>
<linearGradient id="f" gradientTransform="matrix(0 0.126951 0.126951 0 76.460862 36.359884)" gradientUnits="userSpaceOnUse" x1="344" x2="340" y1="76" y2="72">
<stop offset="0" stop-color="#d5d3cf"/>
<stop offset="1" stop-color="#ffffff"/>
</linearGradient>
<filter id="g" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="h">
<g filter="url(#g)">
<rect fill-opacity="0.396" height="128" width="128"/>
</g>
</mask>
<linearGradient id="i" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#1c71d8"/>
<stop offset="0.323117" stop-color="#62a0ea"/>
<stop offset="0.59387" stop-color="#1b5aa6"/>
<stop offset="1" stop-color="#1c71d8"/>
</linearGradient>
<linearGradient id="j" gradientTransform="matrix(1.597748 1.597748 -1.06066 1.06066 -56.853041 -543.720139)" x1="224.504562" x2="231.453873" xlink:href="#i" y1="282.5" y2="282.5"/>
<radialGradient id="k" cx="227.599915" cy="201.029724" gradientTransform="matrix(4.072817 4.073078 -5.940048 5.939073 373.883117 -2098.049112)" gradientUnits="userSpaceOnUse" r="2.5">
<stop offset="0" stop-color="#93bdf1"/>
<stop offset="1" stop-color="#1a5fb4"/>
</radialGradient>
<linearGradient id="l" gradientTransform="matrix(2.121328 2.121328 -2.174353 2.174353 181.766074 -1021.145947)" gradientUnits="userSpaceOnUse" x1="226.90625" x2="228.86203" y1="288.75" y2="288.767151">
<stop offset="0" stop-color="#77767b"/>
<stop offset="0.443872" stop-color="#f6f5f4"/>
<stop offset="1" stop-color="#5e5c64"/>
</linearGradient>
<linearGradient id="m" gradientTransform="matrix(1.258421 1.258421 -1.06066 1.06066 57.381892 -503.024312)" gradientUnits="userSpaceOnUse" x1="223.1875" x2="233.0625" y1="278" y2="278">
<stop offset="0" stop-color="#ffa348"/>
<stop offset="0.265823" stop-color="#ffd7af"/>
<stop offset="0.734177" stop-color="#ff8d1c"/>
<stop offset="1" stop-color="#ffa348"/>
</linearGradient>
<linearGradient id="n" gradientTransform="matrix(1.573027 1.573027 -1.06066 1.06066 -14.348129 -574.754333)" x1="224.504562" x2="231.453873" xlink:href="#i" y1="282.5" y2="282.5"/>
<clipPath id="o">
<path d="m 79 72 h 15 v 16 h -15 z m 0 0"/>
</clipPath>
<clipPath id="p">
<path d="m 93.21875 72.921875 l -14.21875 14.21875 h -4.0625 v -18.28125 h 18.28125 z m 0 0"/>
</clipPath>
<mask id="q">
<g filter="url(#g)">
<rect fill-opacity="0.396" height="128" width="128"/>
</g>
</mask>
<clipPath id="r">
<rect height="152" width="192"/>
</clipPath>
<g id="s" clip-path="url(#r)">
<path d="m 29 112 c -4.433594 0 -8 -3.566406 -8 -8 v -2 c 0 4.433594 3.566406 8 8 8 h 88 c 4.433594 0 8 -3.566406 8 -8 v 2 c 0 4.433594 -3.566406 8 -8 8 z m 0 0" fill="#f6f5f4"/>
</g>
<clipPath id="t">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="u">
<rect height="128" width="128"/>
</clipPath>
<mask id="v">
<g clip-path="url(#u)" filter="url(#g)">
<g clip-path="url(#t)">
<path d="m 21 16 c -4.433594 0 -8 3.566406 -8 8 v 84 c 0 4.433594 3.566406 8 8 8 h 4 v -4 h 80 v 4 h 4 c 4.433594 0 8 -3.566406 8 -8 v -84 c 0 -4.433594 -3.566406 -8 -8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 21 12 h 88 c 4.417969 0 8 3.582031 8 8 v 68 c 0 4.417969 -3.582031 8 -8 8 h -88 c -4.417969 0 -8 -3.582031 -8 -8 v -68 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#deddda"/>
<path d="m 27 28 h 74 v 10 h -74 z m 0 0" fill="url(#b)"/>
<path d="m 27 38 h 74 v 46 h -74 z m 0 0" fill="url(#c)"/>
<path d="m 24 33 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#bf5f00" fill-opacity="0.964567"/>
<path d="m 18 40 h 6 v 12 h -6 z m 0 0" fill="#acacac" fill-opacity="0.984252"/>
<path d="m 18 40 h 6 v 10 h -6 z m 0 0" fill="#d1d1d1" fill-opacity="0.984252"/>
<path d="m 37 36 h 56 v 44 h -56 z m 0 0" fill="#deddda" fill-opacity="0.984252"/>
<path d="m 37 34 h 56 c 1.105469 0 2 0.894531 2 2 s -0.894531 2 -2 2 h -56 c -1.105469 0 -2 -0.894531 -2 -2 s 0.894531 -2 2 -2 z m 0 0" fill-opacity="0.940945"/>
<path d="m 37 36.859375 h 56 v 36.925781 l -14.125 14.214844 h -41.875 z m 0 0" fill="#9a9996" fill-opacity="0.984252"/>
<path d="m 37 36 h 56 v 36.925781 l -14.125 14.214844 h -41.875 z m 0 0" fill="#f6f5f4" fill-opacity="0.984252"/>
<g clip-path="url(#o)">
<g clip-path="url(#p)">
<path d="m 79 77.386719 v 9.351562 c 0 2.464844 2 4.464844 4.464844 4.464844 h 9.351562 c 2.464844 0 4.464844 -2 4.464844 -4.464844 v -9.351562 c 0 -2.464844 -2 -4.464844 -4.464844 -4.464844 h -9.351562 c -2.464844 0 -4.464844 2 -4.464844 4.464844 z m 0 0" fill="url(#f)"/>
</g>
</g>
<path d="m 27 100 h 76 c 1.109375 0 2 0.890625 2 2 v 10 h -80 v -10 c 0 -1.109375 0.890625 -2 2 -2 z m 0 0" fill="#5e5c64" fill-opacity="0.940945"/>
<path d="m 27 102 h 76 c 1.109375 0 2 0.890625 2 2 v 10 h -80 v -10 c 0 -1.109375 0.890625 -2 2 -2 z m 0 0" fill="#9a9996"/>
<path d="m 13 106 v 2 c 0 4.433594 3.566406 8 8 8 h 4 v -2 h -4 c -4.433594 0 -8 -3.566406 -8 -8 z m 104 0 c 0 4.433594 -3.566406 8 -8 8 h -4 v 2 h 4 c 4.433594 0 8 -3.566406 8 -8 z m -92 6 v 2 h 80 v -2 z m 0 0" fill="#9e9c99" fill-opacity="0.366142"/>
<path d="m 27 38 v 46 l 6 -46 z m 0 0" fill="#7e7c77" fill-opacity="0.11811"/>
<path d="m 24 32 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#ffa348" fill-opacity="0.964567"/>
<use mask="url(#q)" transform="matrix(1 0 0 1 -8 -16)" xlink:href="#s"/>
<path d="m 89.503906 31.144531 l 10.066406 10.066407 l -41.71875 41.71875 l -10.066406 -10.066407 z m 0 0" fill="#ffa348"/>
<path d="m 88.246094 29.886719 l 7.550781 7.550781 l -41.71875 41.71875 l -7.550781 -7.550781 z m 0 0" fill="#ff7800"/>
<path d="m 86.789062 28.429688 l 2.515626 2.515624 l -41.71875 41.71875 l -2.515626 -2.515624 z m 0 0" fill="#ffbe6f"/>
<path d="m 121.898438 -0.101562 c -4.855469 0.921874 -11.730469 5.152343 -18.140626 11.558593 l -16.96875 16.972657 l 12.78125 12.78125 l 16.972657 -16.972657 c 6.40625 -6.40625 10.636719 -13.28125 11.558593 -18.136719 z m 0 0" fill="url(#j)"/>
<path d="m 110.011719 13.882812 c -2.1875 -0.398437 -5.421875 0.988282 -8.167969 3.730469 l -11.871094 11.875 l -6.6875 6.6875 c -4.800781 4.800781 -9.234375 12.007813 -9.648437 13.042969 c -0.484375 1.207031 -0.449219 2.730469 0.953125 4.136719 c 1.40625 1.40625 2.917968 1.441406 4.136718 0.953125 c 1.035157 -0.414063 8.292969 -4.984375 13.042969 -9.648438 l 2.402344 -2.398437 l 16.160156 -16.160157 c 2.742188 -2.746093 4.128907 -5.976562 3.730469 -8.167968 c -0.742188 1.390625 -1.859375 2.902344 -3.308594 4.347656 l -13.996094 13.996094 l -5.089843 -5.089844 l 13.996093 -13.996094 c 1.445313 -1.445312 2.960938 -2.566406 4.347657 -3.308594 z m 0 0" fill="url(#k)"/>
<path d="m 95.273438 36.914062 l -2.960938 2.960938 l -2.398438 2.402344 c -4.90625 5.101562 -11.855468 10.828125 -11.855468 10.828125 c 1.011718 -0.433594 8.167968 -5.101563 12.914062 -9.769531 l 2.402344 -2.402344 l 2.960938 -2.957032 z m 0 0" fill="#62a0ea"/>
<path d="m 87.320312 26.835938 l 13.789063 13.789062 c 0.292969 0.292969 0.292969 0.769531 0 1.0625 s -0.769531 0.292969 -1.0625 0 l -13.789063 -13.789062 c -0.292968 -0.292969 -0.292968 -0.769532 0 -1.0625 c 0.292969 -0.289063 0.769532 -0.289063 1.0625 0 z m 0 0" fill="#3584e4"/>
<path d="m 42.421875 89.765625 c -3 3 -6.382813 4.484375 -7.554687 3.3125 c -1.171876 -1.171875 0.3125 -4.554687 3.3125 -7.554687 c 3.003906 -3.003907 6.386718 -4.488282 7.558593 -3.316407 s -0.3125 4.554688 -3.316406 7.558594 z m 0 0" fill="url(#l)"/>
<path d="m 45.269531 70.347656 l -7.851562 12.511719 l 7.835937 7.925781 l 12.597656 -7.855468 z m -6.039062 13.171875 l 5.449219 5.449219 c 0.347656 0.347656 0.449218 0.933594 0.097656 1.160156 c -0.886719 0.570313 -2.9375 1.539063 -2.9375 1.539063 c -0.25 0.128906 -0.539063 0.164062 -0.773438 -0.066407 l -4.546875 -4.550781 c -0.234375 -0.230469 -0.207031 -0.527343 -0.066406 -0.773437 l 1.617187 -2.859375 c 0.207032 -0.363281 0.8125 -0.25 1.160157 0.101562 z m 0 0" fill="url(#m)"/>
<path d="m 43.332031 74.777344 l 9.867188 9.867187 c 0.394531 0.390625 0.476562 0.871094 0.128906 1.066407 l -7.710937 5.253906 c -0.308594 0.210937 -0.785157 0.160156 -1.171876 -0.226563 l -6.984374 -6.988281 c -0.386719 -0.386719 -0.4375 -0.859375 -0.230469 -1.167969 l 5.234375 -7.8125 c 0.125 -0.285156 0.558594 -0.304687 0.867187 0.007813 z m 0 0" fill="url(#n)"/>
</g>
</g>
</mask>
<mask id="w">
<g filter="url(#g)">
<rect fill-opacity="0.8" height="128" width="128"/>
</g>
</mask>
<linearGradient id="x" gradientTransform="matrix(0 0.37 -0.98462 0 295.38501 -30.360001)" gradientUnits="userSpaceOnUse" x1="300" x2="428" y1="235" y2="235">
<stop offset="0" stop-color="#f9f06b"/>
<stop offset="1" stop-color="#f5c211"/>
</linearGradient>
<clipPath id="y">
<rect height="128" width="128"/>
</clipPath>
<clipPath id="z">
<rect height="128" width="128"/>
</clipPath>
</defs>
<path d="m 21 16 c -4.433594 0 -8 3.566406 -8 8 v 84 c 0 4.433594 3.566406 8 8 8 h 4 v -4 h 80 v 4 h 4 c 4.433594 0 8 -3.566406 8 -8 v -84 c 0 -4.433594 -3.566406 -8 -8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 21 12 h 88 c 4.417969 0 8 3.582031 8 8 v 68 c 0 4.417969 -3.582031 8 -8 8 h -88 c -4.417969 0 -8 -3.582031 -8 -8 v -68 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#deddda"/>
<path d="m 27 28 h 74 v 10 h -74 z m 0 0" fill="url(#b)"/>
<path d="m 27 38 h 74 v 46 h -74 z m 0 0" fill="url(#c)"/>
<path d="m 24 33 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#bf5f00" fill-opacity="0.964567"/>
<g fill-opacity="0.984252">
<path d="m 18 40 h 6 v 12 h -6 z m 0 0" fill="#acacac"/>
<path d="m 18 40 h 6 v 10 h -6 z m 0 0" fill="#d1d1d1"/>
<path d="m 37 36 h 56 v 44 h -56 z m 0 0" fill="#deddda"/>
</g>
<path d="m 37 34 h 56 c 1.105469 0 2 0.894531 2 2 s -0.894531 2 -2 2 h -56 c -1.105469 0 -2 -0.894531 -2 -2 s 0.894531 -2 2 -2 z m 0 0" fill-opacity="0.940945"/>
<path d="m 37 36.859375 h 56 v 36.925781 l -14.125 14.214844 h -41.875 z m 0 0" fill="#9a9996" fill-opacity="0.984252"/>
<path d="m 37 36 h 56 v 36.925781 l -14.125 14.214844 h -41.875 z m 0 0" fill="#f6f5f4" fill-opacity="0.984252"/>
<g clip-path="url(#d)">
<g clip-path="url(#e)">
<path d="m 79 77.386719 v 9.351562 c 0 2.464844 2 4.464844 4.464844 4.464844 h 9.351562 c 2.464844 0 4.464844 -2 4.464844 -4.464844 v -9.351562 c 0 -2.464844 -2 -4.464844 -4.464844 -4.464844 h -9.351562 c -2.464844 0 -4.464844 2 -4.464844 4.464844 z m 0 0" fill="url(#f)"/>
</g>
</g>
<path d="m 27 100 h 76 c 1.109375 0 2 0.890625 2 2 v 10 h -80 v -10 c 0 -1.109375 0.890625 -2 2 -2 z m 0 0" fill="#5e5c64" fill-opacity="0.940945"/>
<path d="m 27 102 h 76 c 1.109375 0 2 0.890625 2 2 v 10 h -80 v -10 c 0 -1.109375 0.890625 -2 2 -2 z m 0 0" fill="#9a9996"/>
<path d="m 13 106 v 2 c 0 4.433594 3.566406 8 8 8 h 4 v -2 h -4 c -4.433594 0 -8 -3.566406 -8 -8 z m 104 0 c 0 4.433594 -3.566406 8 -8 8 h -4 v 2 h 4 c 4.433594 0 8 -3.566406 8 -8 z m -92 6 v 2 h 80 v -2 z m 0 0" fill="#9e9c99" fill-opacity="0.366142"/>
<path d="m 27 38 v 46 l 6 -46 z m 0 0" fill="#7e7c77" fill-opacity="0.11811"/>
<path d="m 24 32 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#ffa348" fill-opacity="0.964567"/>
<use mask="url(#h)" transform="matrix(1 0 0 1 -8 -16)" xlink:href="#s"/>
<path d="m 89.503906 31.144531 l 10.066406 10.066407 l -41.71875 41.71875 l -10.066406 -10.066407 z m 0 0" fill="#ffa348"/>
<path d="m 88.246094 29.886719 l 7.550781 7.550781 l -41.71875 41.71875 l -7.550781 -7.550781 z m 0 0" fill="#ff7800"/>
<path d="m 86.789062 28.429688 l 2.515626 2.515624 l -41.71875 41.71875 l -2.515626 -2.515624 z m 0 0" fill="#ffbe6f"/>
<path d="m 121.898438 -0.101562 c -4.855469 0.921874 -11.730469 5.152343 -18.140626 11.558593 l -16.96875 16.972657 l 12.78125 12.78125 l 16.972657 -16.972657 c 6.40625 -6.40625 10.636719 -13.28125 11.558593 -18.136719 z m 0 0" fill="url(#j)"/>
<path d="m 110.011719 13.882812 c -2.1875 -0.398437 -5.421875 0.988282 -8.167969 3.730469 l -11.871094 11.875 l -6.6875 6.6875 c -4.800781 4.800781 -9.234375 12.007813 -9.648437 13.042969 c -0.484375 1.207031 -0.449219 2.730469 0.953125 4.136719 c 1.40625 1.40625 2.917968 1.441406 4.136718 0.953125 c 1.035157 -0.414063 8.292969 -4.984375 13.042969 -9.648438 l 2.402344 -2.398437 l 16.160156 -16.160157 c 2.742188 -2.746093 4.128907 -5.976562 3.730469 -8.167968 c -0.742188 1.390625 -1.859375 2.902344 -3.308594 4.347656 l -13.996094 13.996094 l -5.089843 -5.089844 l 13.996093 -13.996094 c 1.445313 -1.445312 2.960938 -2.566406 4.347657 -3.308594 z m 0 0" fill="url(#k)"/>
<path d="m 95.273438 36.914062 l -2.960938 2.960938 l -2.398438 2.402344 c -4.90625 5.101562 -11.855468 10.828125 -11.855468 10.828125 c 1.011718 -0.433594 8.167968 -5.101563 12.914062 -9.769531 l 2.402344 -2.402344 l 2.960938 -2.957032 z m 0 0" fill="#62a0ea"/>
<path d="m 87.320312 26.835938 l 13.789063 13.789062 c 0.292969 0.292969 0.292969 0.769531 0 1.0625 s -0.769531 0.292969 -1.0625 0 l -13.789063 -13.789062 c -0.292968 -0.292969 -0.292968 -0.769532 0 -1.0625 c 0.292969 -0.289063 0.769532 -0.289063 1.0625 0 z m 0 0" fill="#3584e4"/>
<path d="m 42.421875 89.765625 c -3 3 -6.382813 4.484375 -7.554687 3.3125 c -1.171876 -1.171875 0.3125 -4.554687 3.3125 -7.554687 c 3.003906 -3.003907 6.386718 -4.488282 7.558593 -3.316407 s -0.3125 4.554688 -3.316406 7.558594 z m 0 0" fill="url(#l)"/>
<path d="m 45.269531 70.347656 l -7.851562 12.511719 l 7.835937 7.925781 l 12.597656 -7.855468 z m -6.039062 13.171875 l 5.449219 5.449219 c 0.347656 0.347656 0.449218 0.933594 0.097656 1.160156 c -0.886719 0.570313 -2.9375 1.539063 -2.9375 1.539063 c -0.25 0.128906 -0.539063 0.164062 -0.773438 -0.066407 l -4.546875 -4.550781 c -0.234375 -0.230469 -0.207031 -0.527343 -0.066406 -0.773437 l 1.617187 -2.859375 c 0.207032 -0.363281 0.8125 -0.25 1.160157 0.101562 z m 0 0" fill="url(#m)"/>
<path d="m 43.332031 74.777344 l 9.867188 9.867187 c 0.394531 0.390625 0.476562 0.871094 0.128906 1.066407 l -7.710937 5.253906 c -0.308594 0.210937 -0.785157 0.160156 -1.171876 -0.226563 l -6.984374 -6.988281 c -0.386719 -0.386719 -0.4375 -0.859375 -0.230469 -1.167969 l 5.234375 -7.8125 c 0.125 -0.285156 0.558594 -0.304687 0.867187 0.007813 z m 0 0" fill="url(#n)"/>
<g clip-path="url(#z)" mask="url(#v)">
<g clip-path="url(#y)" mask="url(#w)">
<path d="m 128 80.640625 v 47.359375 h -128 v -47.359375 z m 0 0" fill="url(#x)"/>
<path d="m 13.308594 80.640625 l 47.355468 47.359375 h 21.214844 l -47.359375 -47.359375 z m 42.421875 0 l 47.363281 47.359375 h 21.214844 l -47.363282 -47.359375 z m 42.429687 0 l 29.839844 29.839844 v -21.210938 l -8.628906 -8.628906 z m -98.160156 7.90625 v 21.214844 l 18.238281 18.238281 h 21.214844 z m 0 0"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 18 KiB

@@ -1,100 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="128px" viewBox="0 0 128 128" width="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient id="a" gradientTransform="matrix(0.232143 0 0 0.328947 -7.567033 263.82666)" gradientUnits="userSpaceOnUse" x1="88.595886" x2="536.595886" y1="-449.394012" y2="-449.394012">
<stop offset="0" stop-color="#acabae"/>
<stop offset="0.0384615" stop-color="#deddda"/>
<stop offset="0.0768555" stop-color="#c0bfbc"/>
<stop offset="0.923077" stop-color="#c0bfbc"/>
<stop offset="0.961538" stop-color="#deddda"/>
<stop offset="1" stop-color="#9a9996"/>
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse" x1="26.999876" x2="100.999876" y1="32.999688" y2="32.999688">
<stop offset="0" stop-color="#7e7c77"/>
<stop offset="0.3" stop-color="#9a9996"/>
<stop offset="1" stop-color="#9a9996"/>
</linearGradient>
<linearGradient id="c" gradientUnits="userSpaceOnUse" x1="67.467916" x2="67.467916" y1="83.999688" y2="36.782906">
<stop offset="0" stop-color="#deddda"/>
<stop offset="1" stop-color="#c0bfbc"/>
</linearGradient>
<clipPath id="d">
<path d="m 79 72 h 15 v 16 h -15 z m 0 0"/>
</clipPath>
<clipPath id="e">
<path d="m 93.21875 72.921875 l -14.21875 14.21875 h -4.0625 v -18.28125 h 18.28125 z m 0 0"/>
</clipPath>
<linearGradient id="f" gradientTransform="matrix(0 0.126951 0.126951 0 76.460862 36.359884)" gradientUnits="userSpaceOnUse" x1="344" x2="340" y1="76" y2="72">
<stop offset="0" stop-color="#d5d3cf"/>
<stop offset="1" stop-color="#ffffff"/>
</linearGradient>
<filter id="g" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="h">
<g filter="url(#g)">
<rect fill-opacity="0.396" height="128" width="128"/>
</g>
</mask>
<clipPath id="i">
<rect height="152" width="192"/>
</clipPath>
<linearGradient id="j" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#1c71d8"/>
<stop offset="0.323117" stop-color="#62a0ea"/>
<stop offset="0.59387" stop-color="#1b5aa6"/>
<stop offset="1" stop-color="#1c71d8"/>
</linearGradient>
<linearGradient id="k" gradientTransform="matrix(1.597748 1.597748 -1.06066 1.06066 -56.853041 -543.720139)" x1="224.504562" x2="231.453873" xlink:href="#j" y1="282.5" y2="282.5"/>
<radialGradient id="l" cx="227.599915" cy="201.029724" gradientTransform="matrix(4.072817 4.073078 -5.940048 5.939073 373.883117 -2098.049112)" gradientUnits="userSpaceOnUse" r="2.5">
<stop offset="0" stop-color="#93bdf1"/>
<stop offset="1" stop-color="#1a5fb4"/>
</radialGradient>
<linearGradient id="m" gradientTransform="matrix(2.121328 2.121328 -2.174353 2.174353 181.766074 -1021.145947)" gradientUnits="userSpaceOnUse" x1="226.90625" x2="228.86203" y1="288.75" y2="288.767151">
<stop offset="0" stop-color="#77767b"/>
<stop offset="0.443872" stop-color="#f6f5f4"/>
<stop offset="1" stop-color="#5e5c64"/>
</linearGradient>
<linearGradient id="n" gradientTransform="matrix(1.258421 1.258421 -1.06066 1.06066 57.381892 -503.024312)" gradientUnits="userSpaceOnUse" x1="223.1875" x2="233.0625" y1="278" y2="278">
<stop offset="0" stop-color="#ffa348"/>
<stop offset="0.265823" stop-color="#ffd7af"/>
<stop offset="0.734177" stop-color="#ff8d1c"/>
<stop offset="1" stop-color="#ffa348"/>
</linearGradient>
<linearGradient id="o" gradientTransform="matrix(1.573027 1.573027 -1.06066 1.06066 -14.348129 -574.754333)" x1="224.504562" x2="231.453873" xlink:href="#j" y1="282.5" y2="282.5"/>
<path d="m 21 16 c -4.433594 0 -8 3.566406 -8 8 v 84 c 0 4.433594 3.566406 8 8 8 h 4 v -4 h 80 v 4 h 4 c 4.433594 0 8 -3.566406 8 -8 v -84 c 0 -4.433594 -3.566406 -8 -8 -8 z m 0 0" fill="url(#a)"/>
<path d="m 21 12 h 88 c 4.417969 0 8 3.582031 8 8 v 68 c 0 4.417969 -3.582031 8 -8 8 h -88 c -4.417969 0 -8 -3.582031 -8 -8 v -68 c 0 -4.417969 3.582031 -8 8 -8 z m 0 0" fill="#deddda"/>
<path d="m 27 28 h 74 v 10 h -74 z m 0 0" fill="url(#b)"/>
<path d="m 27 38 h 74 v 46 h -74 z m 0 0" fill="url(#c)"/>
<path d="m 24 33 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#bf5f00" fill-opacity="0.964567"/>
<g fill-opacity="0.984252">
<path d="m 18 40 h 6 v 12 h -6 z m 0 0" fill="#acacac"/>
<path d="m 18 40 h 6 v 10 h -6 z m 0 0" fill="#d1d1d1"/>
<path d="m 37 36 h 56 v 44 h -56 z m 0 0" fill="#deddda"/>
</g>
<path d="m 37 34 h 56 c 1.105469 0 2 0.894531 2 2 s -0.894531 2 -2 2 h -56 c -1.105469 0 -2 -0.894531 -2 -2 s 0.894531 -2 2 -2 z m 0 0" fill-opacity="0.940945"/>
<path d="m 37 36.859375 h 56 v 36.925781 l -14.125 14.214844 h -41.875 z m 0 0" fill="#9a9996" fill-opacity="0.984252"/>
<path d="m 37 36 h 56 v 36.925781 l -14.125 14.214844 h -41.875 z m 0 0" fill="#f6f5f4" fill-opacity="0.984252"/>
<g clip-path="url(#d)">
<g clip-path="url(#e)">
<path d="m 79 77.386719 v 9.351562 c 0 2.464844 2 4.464844 4.464844 4.464844 h 9.351562 c 2.464844 0 4.464844 -2 4.464844 -4.464844 v -9.351562 c 0 -2.464844 -2 -4.464844 -4.464844 -4.464844 h -9.351562 c -2.464844 0 -4.464844 2 -4.464844 4.464844 z m 0 0" fill="url(#f)"/>
</g>
</g>
<path d="m 27 100 h 76 c 1.109375 0 2 0.890625 2 2 v 10 h -80 v -10 c 0 -1.109375 0.890625 -2 2 -2 z m 0 0" fill="#5e5c64" fill-opacity="0.940945"/>
<path d="m 27 102 h 76 c 1.109375 0 2 0.890625 2 2 v 10 h -80 v -10 c 0 -1.109375 0.890625 -2 2 -2 z m 0 0" fill="#9a9996"/>
<path d="m 13 106 v 2 c 0 4.433594 3.566406 8 8 8 h 4 v -2 h -4 c -4.433594 0 -8 -3.566406 -8 -8 z m 104 0 c 0 4.433594 -3.566406 8 -8 8 h -4 v 2 h 4 c 4.433594 0 8 -3.566406 8 -8 z m -92 6 v 2 h 80 v -2 z m 0 0" fill="#9e9c99" fill-opacity="0.366142"/>
<path d="m 27 38 v 46 l 6 -46 z m 0 0" fill="#7e7c77" fill-opacity="0.11811"/>
<path d="m 24 32 c 0 1.65625 -1.34375 3 -3 3 s -3 -1.34375 -3 -3 s 1.34375 -3 3 -3 s 3 1.34375 3 3 z m 0 0" fill="#ffa348" fill-opacity="0.964567"/>
<g clip-path="url(#i)" mask="url(#h)" transform="matrix(1 0 0 1 -8 -16)">
<path d="m 29 112 c -4.433594 0 -8 -3.566406 -8 -8 v -2 c 0 4.433594 3.566406 8 8 8 h 88 c 4.433594 0 8 -3.566406 8 -8 v 2 c 0 4.433594 -3.566406 8 -8 8 z m 0 0" fill="#f6f5f4"/>
</g>
<path d="m 89.503906 31.144531 l 10.066406 10.066407 l -41.71875 41.71875 l -10.066406 -10.066407 z m 0 0" fill="#ffa348"/>
<path d="m 88.246094 29.886719 l 7.550781 7.550781 l -41.71875 41.71875 l -7.550781 -7.550781 z m 0 0" fill="#ff7800"/>
<path d="m 86.789062 28.429688 l 2.515626 2.515624 l -41.71875 41.71875 l -2.515626 -2.515624 z m 0 0" fill="#ffbe6f"/>
<path d="m 121.898438 -0.101562 c -4.855469 0.921874 -11.730469 5.152343 -18.140626 11.558593 l -16.96875 16.972657 l 12.78125 12.78125 l 16.972657 -16.972657 c 6.40625 -6.40625 10.636719 -13.28125 11.558593 -18.136719 z m 0 0" fill="url(#k)"/>
<path d="m 110.011719 13.882812 c -2.1875 -0.398437 -5.421875 0.988282 -8.167969 3.730469 l -11.871094 11.875 l -6.6875 6.6875 c -4.800781 4.800781 -9.234375 12.007813 -9.648437 13.042969 c -0.484375 1.207031 -0.449219 2.730469 0.953125 4.136719 c 1.40625 1.40625 2.917968 1.441406 4.136718 0.953125 c 1.035157 -0.414063 8.292969 -4.984375 13.042969 -9.648438 l 2.402344 -2.398437 l 16.160156 -16.160157 c 2.742188 -2.746093 4.128907 -5.976562 3.730469 -8.167968 c -0.742188 1.390625 -1.859375 2.902344 -3.308594 4.347656 l -13.996094 13.996094 l -5.089843 -5.089844 l 13.996093 -13.996094 c 1.445313 -1.445312 2.960938 -2.566406 4.347657 -3.308594 z m 0 0" fill="url(#l)"/>
<path d="m 95.273438 36.914062 l -2.960938 2.960938 l -2.398438 2.402344 c -4.90625 5.101562 -11.855468 10.828125 -11.855468 10.828125 c 1.011718 -0.433594 8.167968 -5.101563 12.914062 -9.769531 l 2.402344 -2.402344 l 2.960938 -2.957032 z m 0 0" fill="#62a0ea"/>
<path d="m 87.320312 26.835938 l 13.789063 13.789062 c 0.292969 0.292969 0.292969 0.769531 0 1.0625 s -0.769531 0.292969 -1.0625 0 l -13.789063 -13.789062 c -0.292968 -0.292969 -0.292968 -0.769532 0 -1.0625 c 0.292969 -0.289063 0.769532 -0.289063 1.0625 0 z m 0 0" fill="#3584e4"/>
<path d="m 42.421875 89.765625 c -3 3 -6.382813 4.484375 -7.554687 3.3125 c -1.171876 -1.171875 0.3125 -4.554687 3.3125 -7.554687 c 3.003906 -3.003907 6.386718 -4.488282 7.558593 -3.316407 s -0.3125 4.554688 -3.316406 7.558594 z m 0 0" fill="url(#m)"/>
<path d="m 45.269531 70.347656 l -7.851562 12.511719 l 7.835937 7.925781 l 12.597656 -7.855468 z m -6.039062 13.171875 l 5.449219 5.449219 c 0.347656 0.347656 0.449218 0.933594 0.097656 1.160156 c -0.886719 0.570313 -2.9375 1.539063 -2.9375 1.539063 c -0.25 0.128906 -0.539063 0.164062 -0.773438 -0.066407 l -4.546875 -4.550781 c -0.234375 -0.230469 -0.207031 -0.527343 -0.066406 -0.773437 l 1.617187 -2.859375 c 0.207032 -0.363281 0.8125 -0.25 1.160157 0.101562 z m 0 0" fill="url(#n)"/>
<path d="m 43.332031 74.777344 l 9.867188 9.867187 c 0.394531 0.390625 0.476562 0.871094 0.128906 1.066407 l -7.710937 5.253906 c -0.308594 0.210937 -0.785157 0.160156 -1.171876 -0.226563 l -6.984374 -6.988281 c -0.386719 -0.386719 -0.4375 -0.859375 -0.230469 -1.167969 l 5.234375 -7.8125 c 0.125 -0.285156 0.558594 -0.304687 0.867187 0.007813 z m 0 0" fill="url(#o)"/>
</svg>

Before

Width:  |  Height:  |  Size: 9.4 KiB

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<filter id="a" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="b">
<g filter="url(#a)">
<rect fill-opacity="0.396" height="16" width="16"/>
</g>
</mask>
<clipPath id="c">
<rect height="152" width="192"/>
</clipPath>
<g clip-path="url(#c)" mask="url(#b)" transform="matrix(1 0 0 1 -168 -16)">
<path d="m 29 112 c -4.433594 0 -8 -3.566406 -8 -8 v -2 c 0 4.433594 3.566406 8 8 8 h 88 c 4.433594 0 8 -3.566406 8 -8 v 2 c 0 4.433594 -3.566406 8 -8 8 z m 0 0" fill="#f6f5f4"/>
</g>
<g fill="#2e3436">
<path d="m 4 2 v 2 h 5.585938 l 2 -2 z m -2 3 c -0.5 0 -1 0.5 -1 1 v 4 c 0 0.5 0.5 1 1 1 h 1 v -2 h 2 c 0 -0.265625 0.105469 -0.519531 0.292969 -0.707031 l 3.292969 -3.292969 z m 11.414062 0 l -4 4 h 3.585938 v 2 h 1 c 0.5 0 1 -0.5 1 -1 v -4 c 0 -0.5 -0.5 -1 -1 -1 z m -9.414062 5 v 5 h 8 v -5 h -3.585938 l -0.707031 0.707031 c -0.1875 0.1875 -0.441406 0.292969 -0.707031 0.292969 h -1 c -0.550781 0 -1 -0.449219 -1 -1 z m 0 0"/>
<path d="m 6 10 h 1 l 9 -9 l -1 -1 l -9 9 z m 0 0"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

-9
View File
@@ -12,12 +12,3 @@ install_data('org.gtk.PrintEditor4.desktop', install_dir: gtk_applicationsdir)
# appdata
install_data('org.gtk.PrintEditor4.appdata.xml', install_dir: gtk_appdatadir)
# icons
icontheme_dir = join_paths(gtk_datadir, 'icons/hicolor')
foreach size: ['scalable', 'symbolic']
install_subdir('data/' + size,
install_dir: icontheme_dir
)
endforeach
@@ -2,7 +2,7 @@
Name=Print Editor
Comment=A simple editor demonstrating GTK printing
Exec=gtk4-print-editor %f
Icon=org.gtk.PrintEditor4.Devel
Icon=text-editor-symbolic
Terminal=false
Type=Application
StartupNotify=true
+1 -3
View File
@@ -633,7 +633,7 @@ activate_about (GSimpleAction *action,
"website", "http://www.gtk.org",
"comments", "Program to demonstrate GTK printing",
"authors", (const char *[]){ "Alexander Larsson", NULL },
"logo-icon-name", "org.gtk.PrintEditor4.Devel",
"logo-icon-name", "text-editor-symbolic",
"title", "About GTK Print Editor",
"system-information", sysinfo->str,
NULL);
@@ -781,8 +781,6 @@ activate (GApplication *app)
gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);
update_title (GTK_WINDOW (main_window));
gtk_widget_add_css_class (main_window, "devel");
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child (GTK_WINDOW (main_window), box);
+3 -4
View File
@@ -65,9 +65,9 @@
<section>
<xi:include href="xml/gtksorter.xml" />
<xi:include href="xml/gtkcustomsorter.xml" />
<xi:include href="xml/gtkmultisorter.xml" />
<xi:include href="xml/gtkstringsorter.xml" />
<xi:include href="xml/gtknumericsorter.xml" />
<xi:include href="xml/gtkmultisorter.xml" />
</section>
<xi:include href="xml/gtkselectionmodel.xml" />
<section>
@@ -93,9 +93,7 @@
<xi:include href="xml/gtklistview.xml" />
<xi:include href="xml/gtkgridview.xml" />
<xi:include href="xml/gtkcolumnview.xml" />
<section>
<xi:include href="xml/gtkcolumnviewcolumn.xml" />
</section>
<xi:include href="xml/gtkcolumnviewcolumn.xml" />
<xi:include href="xml/gtkdropdown.xml" />
</chapter>
@@ -223,6 +221,7 @@
<xi:include href="xml/gtksearchentry.xml" />
<xi:include href="xml/gtksearchbar.xml" />
<xi:include href="xml/gtkeditablelabel.xml" />
<xi:include href="xml/gtksuggestionentry.xml" />
</chapter>
<chapter id="TextWidgetObjects">
+24 -16
View File
@@ -3420,7 +3420,6 @@ gtk_tree_list_row_get_type
<SECTION>
<FILE>gtktreeexpander</FILE>
<TITLE>GtkTreeExpander</TITLE>
GtkTreeExpander
gtk_tree_expander_new
gtk_tree_expander_get_child
gtk_tree_expander_set_child
@@ -7542,27 +7541,12 @@ gtk_expression_watch_unwatch
<SUBSECTION>
gtk_property_expression_new
gtk_property_expression_new_for_pspec
gtk_property_expression_get_expression
gtk_property_expression_get_pspec
gtk_constant_expression_new
gtk_constant_expression_new_for_value
gtk_constant_expression_get_value
gtk_object_expression_new
gtk_object_expression_get_object
gtk_closure_expression_new
gtk_cclosure_expression_new
<SUBSECTION>
GTK_VALUE_HOLDS_EXPRESSION
gtk_value_set_expression
gtk_value_take_expression
gtk_value_get_expression
gtk_value_dup_expression
<SUBSECTION>
GtkParamSpecExpression
gtk_param_spec_expression
<SUBSECTION Standard>
GTK_IS_EXPRESSION
GTK_TYPE_EXPRESSION
@@ -7638,3 +7622,27 @@ gtk_selection_filter_model_new_for_type
gtk_selection_filter_model_set_model
gtk_selection_filter_model_get_model
</SECTION>
<SECTION>
<FILE>gtksuggestionentry</FILE>
<TITLE>GtkSuggestionEntry</TITLE>
GtkSuggestionEntry
gtk_suggestion_entry_new
gtk_suggestion_entry_set_model
gtk_suggestion_entry_get_model
gtk_suggestion_entry_set_from_strings
gtk_suggestion_entry_set_factory
gtk_suggestion_entry_get_factory
gtk_suggestion_entry_set_expression
gtk_suggestion_entry_get_expression
gtk_suggestion_entry_set_use_filter
gtk_suggestion_entry_get_use_filter
gtk_suggestion_entry_set_insert_selection
gtk_suggestion_entry_get_insert_selection
gtk_suggestion_entry_set_insert_prefix
gtk_suggestion_entry_get_insert_prefix
gtk_suggestion_entry_set_show_button
gtk_suggestion_entry_get_show_button
gtk_suggestion_entry_set_minimum_length
gtk_suggestion_entry_get_minimum_length
</SECTION>
+1 -7
View File
@@ -19,7 +19,6 @@ gtk_assistant_get_type
gtk_assistant_page_get_type
gtk_bin_layout_get_type
gtk_bitset_get_type
gtk_expression_get_type
gtk_bookmark_list_get_type
gtk_box_get_type
gtk_box_layout_get_type
@@ -30,7 +29,6 @@ gtk_builder_list_item_factory_get_type
gtk_builder_scope_get_type
gtk_button_get_type
gtk_calendar_get_type
gtk_cclosure_expression_get_type
gtk_cell_area_get_type
gtk_cell_area_box_get_type
gtk_cell_area_context_get_type
@@ -48,7 +46,6 @@ gtk_cell_renderer_toggle_get_type
gtk_cell_view_get_type
gtk_center_layout_get_type
gtk_check_button_get_type
gtk_closure_expression_get_type
gtk_color_button_get_type
gtk_color_chooser_get_type
gtk_color_chooser_dialog_get_type
@@ -57,7 +54,6 @@ gtk_column_view_get_type
gtk_column_view_column_get_type
gtk_combo_box_get_type
gtk_combo_box_text_get_type
gtk_constant_expression_get_type
gtk_constraint_get_type
gtk_constraint_guide_get_type
gtk_constraint_layout_get_type
@@ -154,7 +150,6 @@ gtk_no_selection_get_type
gtk_notebook_get_type
gtk_notebook_page_get_type
gtk_numeric_sorter_get_type
gtk_object_expression_get_type
gtk_orientable_get_type
gtk_overlay_get_type
gtk_overlay_layout_get_type
@@ -177,7 +172,6 @@ gtk_print_operation_preview_get_type
gtk_print_settings_get_type
@DISABLE_ON_W32@gtk_print_unix_dialog_get_type
gtk_progress_bar_get_type
gtk_property_expression_get_type
gtk_radio_button_get_type
gtk_range_get_type
gtk_recent_manager_get_type
@@ -220,6 +214,7 @@ gtk_string_filter_get_type
gtk_string_list_get_type
gtk_string_object_get_type
gtk_string_sorter_get_type
gtk_suggestion_entry_get_type
gtk_switch_get_type
gtk_level_bar_get_type
gtk_style_context_get_type
@@ -235,7 +230,6 @@ gtk_text_view_get_type
gtk_toggle_button_get_type
gtk_tree_drag_dest_get_type
gtk_tree_drag_source_get_type
gtk_tree_expander_get_type
gtk_tree_list_model_get_type
gtk_tree_list_row_get_type
gtk_tree_list_row_sorter_get_type
+1 -1
View File
@@ -170,7 +170,7 @@ in GTK 3, you can prepare for the switch by using gtk_widget_destroy()
only on toplevel windows, and replace all other uses with
gtk_container_remove() or g_object_unref().
### Reduce the use of generic container APIs
### Reduce the use of generic container APIs</title>
GTK 4 removes gtk_container_add() and gtk_container_remove(). While there
is not always a replacement for gtk_container_remove() in GTK 3, you can
+3 -1
View File
@@ -183,7 +183,7 @@ transitioning code for easy lookup:
| #GtkTreeModel | #GListModel |
| #GtkTreePath | #guint position, #GtkTreeListRow |
| #GtkTreeIter | #guint position |
| #GtkTreeRowReference | #GObject item |
| GtkTreeRowReference | #GObject item |
| #GtkListStore | #GListStore |
| #GtkTreeStore | #GtkTreeListModel, #GtkTreeExpander |
| #GtkTreeSelection | #GtkSelectionModel |
@@ -198,4 +198,6 @@ transitioning code for easy lookup:
| #GtkCellLayout | #GtkListItemFactory |
| #GtkCellArea | #GtkWidget |
| #GtkCellRenderer | #GtkWidget |
| #GtkComboBoxText | #GtkSuggestionEntry |
| #GtkEntryCompletion | #GtkSuggestionEntry |
-283
View File
@@ -1,283 +0,0 @@
/*
* Copyright © 2020 Benjamin Otte
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#include <glib.h>
G_BEGIN_DECLS
#ifndef GDK_ARRAY_TYPE_NAME
#define GDK_ARRAY_TYPE_NAME GdkArray
#endif
#ifndef GDK_ARRAY_NAME
#define GDK_ARRAY_NAME gdk_array
#endif
#ifndef GDK_ARRAY_ELEMENT_TYPE
#define GDK_ARRAY_ELEMENT_TYPE gpointer
#endif
#ifdef GDK_ARRAY_PREALLOC
#if GDK_ARRAY_PREALLOC == 0
#undef GDK_ARRAY_PREALLOC
#endif
#endif
#ifdef GDK_ARRAY_NULL_TERMINATED
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
#else
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
#endif
/* make this readable */
#define _T_ GDK_ARRAY_ELEMENT_TYPE
#define GdkArray GDK_ARRAY_TYPE_NAME
#define gdk_array_paste_more(GDK_ARRAY_NAME, func_name) GDK_ARRAY_NAME ## _ ## func_name
#define gdk_array_paste(GDK_ARRAY_NAME, func_name) gdk_array_paste_more (GDK_ARRAY_NAME, func_name)
#define gdk_array(func_name) gdk_array_paste (GDK_ARRAY_NAME, func_name)
typedef struct GdkArray GdkArray;
struct GdkArray
{
_T_ *start;
_T_ *end;
_T_ *end_allocation;
#ifdef GDK_ARRAY_PREALLOC
_T_ preallocated[GDK_ARRAY_REAL_SIZE(GDK_ARRAY_PREALLOC)];
#endif
};
/* no G_GNUC_UNUSED here, if you don't use an array type, remove it. */
static inline void
gdk_array(init) (GdkArray *self)
{
#ifdef GDK_ARRAY_PREALLOC
self->start = self->preallocated;
self->end = self->start;
self->end_allocation = self->start + GDK_ARRAY_PREALLOC;
#ifdef GDK_ARRAY_NULL_TERMINATED
*self->start = *(_T_[1]) {};
#endif
#else
self->start = NULL;
self->end = NULL;
self->end_allocation = NULL;
#endif
}
static inline void
gdk_array(free_elements) (_T_ *start,
_T_ *end)
{
#ifdef GDK_ARRAY_FREE_FUNC
_T_ *e;
for (e = start; e < end; e++)
#ifdef GDK_ARRAY_BY_VALUE
GDK_ARRAY_FREE_FUNC (e);
#else
GDK_ARRAY_FREE_FUNC (*e);
#endif
#endif
}
/* no G_GNUC_UNUSED here */
static inline void
gdk_array(clear) (GdkArray *self)
{
gdk_array(free_elements) (self->start, self->end);
#ifdef GDK_ARRAY_PREALLOC
if (self->start != self->preallocated)
#endif
g_free (self->start);
gdk_array(init) (self);
}
G_GNUC_UNUSED static inline _T_ *
gdk_array(get_data) (const GdkArray *self)
{
return self->start;
}
G_GNUC_UNUSED static inline _T_ *
gdk_array(index) (const GdkArray *self,
gsize pos)
{
return self->start + pos;
}
G_GNUC_UNUSED static inline gsize
gdk_array(get_capacity) (const GdkArray *self)
{
return self->end_allocation - self->start;
}
G_GNUC_UNUSED static inline gsize
gdk_array(get_size) (const GdkArray *self)
{
return self->end - self->start;
}
G_GNUC_UNUSED static inline gboolean
gdk_array(is_empty) (const GdkArray *self)
{
return self->end == self->start;
}
G_GNUC_UNUSED static void
gdk_array(reserve) (GdkArray *self,
gsize n)
{
gsize new_size, size;
if (n <= gdk_array(get_capacity) (self))
return;
size = gdk_array(get_size) (self);
new_size = 1 << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
#ifdef GDK_ARRAY_PREALLOC
if (self->start == self->preallocated)
{
self->start = g_new (_T_, new_size);
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
}
else
#endif
#ifdef GDK_ARRAY_NULL_TERMINATED
if (self->start == NULL)
{
self->start = g_new (_T_, new_size);
*self->start = *(_T_[1]) {};
}
else
#endif
self->start = g_renew (_T_, self->start, new_size);
self->end = self->start + size;
self->end_allocation = self->start + new_size;
#ifdef GDK_ARRAY_NULL_TERMINATED
self->end_allocation--;
#endif
}
G_GNUC_UNUSED static void
gdk_array(splice) (GdkArray *self,
gsize pos,
gsize removed,
_T_ *additions,
gsize added)
{
gsize size;
gsize remaining;
size = gdk_array(get_size) (self);
g_assert (pos + removed <= size);
remaining = size - pos - removed;
gdk_array(free_elements) (gdk_array(index) (self, pos),
gdk_array(index) (self, pos + removed));
gdk_array(reserve) (self, size - removed + added);
if (GDK_ARRAY_REAL_SIZE (remaining) && removed != added)
memmove (gdk_array(index) (self, pos + added),
gdk_array(index) (self, pos + removed),
GDK_ARRAY_REAL_SIZE (remaining) * sizeof (_T_));
if (added)
{
if (additions)
memcpy (gdk_array(index) (self, pos),
additions,
added * sizeof (_T_));
else
memset (gdk_array(index) (self, pos), 0, added * sizeof (_T_));
}
/* might overflow, but does the right thing */
self->end += added - removed;
}
G_GNUC_UNUSED static void
gdk_array(set_size) (GdkArray *self,
gsize new_size)
{
gsize old_size = gdk_array(get_size) (self);
if (new_size > old_size)
gdk_array(splice) (self, old_size, 0, NULL, new_size - old_size);
else
gdk_array(splice) (self, new_size, old_size - new_size, NULL, 0);
}
G_GNUC_UNUSED static void
gdk_array(append) (GdkArray *self,
#ifdef GDK_ARRAY_BY_VALUE
_T_ *value)
#else
_T_ value)
#endif
{
gdk_array(splice) (self,
gdk_array(get_size) (self),
0,
#ifdef GDK_ARRAY_BY_VALUE
value,
#else
&value,
#endif
1);
}
#ifdef GDK_ARRAY_BY_VALUE
G_GNUC_UNUSED static _T_ *
gdk_array(get) (const GdkArray *self,
gsize pos)
{
return gdk_array(index) (self, pos);
}
#else
G_GNUC_UNUSED static _T_
gdk_array(get) (const GdkArray *self,
gsize pos)
{
return *gdk_array(index) (self, pos);
}
#endif
#ifndef GDK_ARRAY_NO_UNDEF
#undef _T_
#undef GdkArray
#undef gdk_array_paste_more
#undef gdk_array_paste
#undef gdk_array
#undef GDK_ARRAY_REAL_SIZE
#undef GDK_ARRAY_BY_VALUE
#undef GDK_ARRAY_ELEMENT_TYPE
#undef GDK_ARRAY_FREE_FUNC
#undef GDK_ARRAY_NAME
#undef GDK_ARRAY_NULL_TERMINATED
#undef GDK_ARRAY_PREALLOC
#undef GDK_ARRAY_TYPE_NAME
#endif
+1 -1
View File
@@ -354,7 +354,7 @@ gdk_rgba_equal (gconstpointer p1,
*
* Returns a textual specification of @rgba in the form
* `rgb(r,g,b)` or
* `rgba(r,g,b,a)`,
* `rgba(r g,b,a)`,
* where “r”, “g”, “b” and “a” represent the red, green,
* blue and alpha values respectively. “r”, “g”, and “b” are
* represented as integers in the range 0 to 255, and “a”
-6
View File
@@ -544,12 +544,6 @@ gdk_registry_handle_global (void *data,
gdk_wayland_display_init_xdg_output (display_wayland);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
{
display_wayland->idle_inhibit_manager =
wl_registry_bind (display_wayland->wl_registry, id,
&zwp_idle_inhibit_manager_v1_interface, 1);
}
g_hash_table_insert (display_wayland->known_globals,
GUINT_TO_POINTER (id), g_strdup (interface));
-2
View File
@@ -35,7 +35,6 @@
#include <gdk/wayland/keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h>
#include <gdk/wayland/server-decoration-client-protocol.h>
#include <gdk/wayland/xdg-output-unstable-v1-client-protocol.h>
#include <gdk/wayland/idle-inhibit-unstable-v1-client-protocol.h>
#include <glib.h>
#include <gdk/gdkkeys.h>
@@ -110,7 +109,6 @@ struct _GdkWaylandDisplay
struct zwp_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit;
struct org_kde_kwin_server_decoration_manager *server_decoration_manager;
struct zxdg_output_manager_v1 *xdg_output_manager;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
GList *async_roundtrips;
-36
View File
@@ -191,9 +191,6 @@ struct _GdkWaylandSurface
struct zxdg_imported_v1 *imported_transient_for;
GHashTable *shortcuts_inhibitors;
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
size_t idle_inhibitor_refcount;
};
struct _GdkWaylandSurfaceClass
@@ -1987,39 +1984,6 @@ gdk_wayland_surface_announce_csd (GdkSurface *surface)
ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT);
}
gboolean
gdk_wayland_surface_inhibit_idle (GdkSurface *surface)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
if (!display_wayland->idle_inhibit_manager)
return false;
if (!impl->idle_inhibitor)
{
g_assert (impl->idle_inhibitor_refcount == 0);
impl->idle_inhibitor =
zwp_idle_inhibit_manager_v1_create_inhibitor (display_wayland->idle_inhibit_manager,
impl->display_server.wl_surface);
}
++impl->idle_inhibitor_refcount;
return true;
}
void
gdk_wayland_surface_uninhibit_idle (GdkSurface *surface)
{
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
g_assert (impl->idle_inhibitor && impl->idle_inhibitor_refcount > 0);
if (--impl->idle_inhibitor_refcount == 0)
{
zwp_idle_inhibitor_v1_destroy (impl->idle_inhibitor);
impl->idle_inhibitor = NULL;
}
}
static void
calculate_popup_rect (GdkSurface *surface,
GdkPopupLayout *layout,
-3
View File
@@ -80,9 +80,6 @@ void gdk_wayland_surface_set_application_id (GdkSurface *sur
void gdk_wayland_surface_announce_csd (GdkSurface *surface);
gboolean gdk_wayland_surface_inhibit_idle (GdkSurface *surface);
void gdk_wayland_surface_uninhibit_idle (GdkSurface *surface);
G_END_DECLS
#endif /* __GDK_WAYLAND_SURFACE_H__ */
-1
View File
@@ -54,7 +54,6 @@ proto_sources = [
['keyboard-shortcuts-inhibit', 'unstable', 'v1', ],
['server-decoration', 'private' ],
['xdg-output', 'unstable', 'v1', ],
['idle-inhibit', 'unstable', 'v1', ],
]
gdk_wayland_gen_headers = []
+1 -1
View File
@@ -184,7 +184,7 @@ gdk_x11_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_x11_surface_pre_damage (surface);
#ifdef HAVE_XDAMAGE
if (context_x11->xdamage != 0 && _gdk_x11_surface_syncs_frames (surface))
if (context_x11->xdamage != 0)
{
g_assert (context_x11->frame_fence == 0);
+4 -4
View File
@@ -360,8 +360,8 @@ gdk_x11_surface_begin_frame (GdkSurface *surface,
}
}
gboolean
_gdk_x11_surface_syncs_frames (GdkSurface *surface)
static gboolean
should_sync_frame_drawing (GdkSurface *surface)
{
GdkX11Surface *impl = GDK_X11_SURFACE (surface);
@@ -395,7 +395,7 @@ static void
maybe_sync_counter_for_end_frame (GdkSurface *surface)
{
GdkX11Surface *impl = GDK_X11_SURFACE (surface);
gboolean frame_sync_negotiated = _gdk_x11_surface_syncs_frames (surface);
gboolean frame_sync_negotiated = should_sync_frame_drawing (surface);
gboolean frame_done_painting = !impl->toplevel->frame_pending;
#ifdef HAVE_XDAMAGE
@@ -478,7 +478,7 @@ gdk_x11_surface_end_frame (GdkSurface *surface)
maybe_sync_counter_for_end_frame (surface);
if (_gdk_x11_surface_syncs_frames (surface))
if (should_sync_frame_drawing (surface))
{
impl->toplevel->frame_pending = TRUE;
gdk_surface_freeze_updates (surface);
-2
View File
@@ -179,7 +179,6 @@ GdkCursor *_gdk_x11_surface_get_cursor (GdkSurface *window);
void _gdk_x11_surface_update_size (GdkX11Surface *impl);
void _gdk_x11_surface_set_surface_scale (GdkSurface *window,
int scale);
gboolean _gdk_x11_surface_syncs_frames (GdkSurface *surface);
void gdk_x11_surface_pre_damage (GdkSurface *surface);
@@ -189,7 +188,6 @@ void gdk_x11_surface_move (GdkSurface *surface,
void gdk_x11_surface_check_monitor (GdkSurface *surface,
GdkMonitor *monitor);
G_END_DECLS
#endif /* __GDK_X11_SURFACE__ */
+121 -181
View File
@@ -70,6 +70,7 @@ typedef enum
RESET_CLIP = 1 << 1,
RESET_OPACITY = 1 << 2,
DUMP_FRAMEBUFFER = 1 << 3,
CENTER_CHILD = 1 << 4,
NO_CACHE_PLZ = 1 << 5,
} OffscreenFlags;
@@ -905,7 +906,6 @@ upload_texture (GskGLRenderer *self,
}
else
{
out_region->texture_id =
gsk_gl_driver_get_texture_for_texture (self->gl_driver,
texture,
@@ -1152,59 +1152,6 @@ rounded_inner_rect_contains_rect (const GskRoundedRect *rounded,
return graphene_rect_contains_rect (&inner, rect);
}
/* Current clip is NOT rounded but new one is definitely! */
static inline bool
intersect_rounded_rectilinear (const graphene_rect_t *non_rounded,
const GskRoundedRect *rounded,
GskRoundedRect *result)
{
int n_corners = 0;
bool corners[4];
/* Intersects with top left corner? */
n_corners += corners[0] = rounded_rect_has_corner (rounded, 0) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 0), NULL);
/* top right? */
n_corners += corners[1] = rounded_rect_has_corner (rounded, 1) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 1), NULL);
/* bottom right? */
n_corners += corners[2] = rounded_rect_has_corner (rounded, 2) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 2), NULL);
/* bottom left */
n_corners += corners[3] = rounded_rect_has_corner (rounded, 3) &&
graphene_rect_intersection (non_rounded,
&rounded_rect_corner (rounded, 3), NULL);
if (corners[0] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 0)))
return false;
if (corners[1] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 1)))
return false;
if (corners[2] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 2)))
return false;
if (corners[3] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 3)))
return false;
/* We do intersect with at least one of the corners, but in such a way that the
* intersection between the two clips can still be represented by a single rounded
* rect in a trivial way. do that. */
graphene_rect_intersection (non_rounded, &rounded->bounds, &result->bounds);
for (int i = 0; i < 4; i++)
{
if (corners[i])
result->corner[i] = rounded->corner[i];
else
result->corner[i].width = result->corner[i].height = 0;
}
return true;
}
/* This code intersects the current (maybe rounded) clip with the new
* non-rounded clip */
static inline void
render_clipped_child (GskGLRenderer *self,
RenderOpBuilder *builder,
@@ -1212,57 +1159,112 @@ render_clipped_child (GskGLRenderer *self,
GskRenderNode *child)
{
graphene_rect_t transformed_clip;
GskRoundedRect intersection;
GskRoundedRect child_clip;
ops_transform_bounds_modelview (builder, clip, &transformed_clip);
if (builder->clip_is_rectilinear)
{
memset (&intersection, 0, sizeof (GskRoundedRect));
graphene_rect_intersection (&transformed_clip,
&builder->current_clip->bounds,
&intersection.bounds);
goto trivial;
ops_push_clip (builder, &intersection);
{
const GskRoundedRect *cur_clip = builder->current_clip;
int n_corners = 0;
bool corners[4];
/* Intersects with top left corner? */
n_corners += corners[0] = rounded_rect_has_corner (cur_clip, 0) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 0), NULL);
/* top right? */
n_corners += corners[1] = rounded_rect_has_corner (cur_clip, 1) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 1), NULL);
/* bottom right? */
n_corners += corners[2] = rounded_rect_has_corner (cur_clip, 2) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 2), NULL);
/* bottom left */
n_corners += corners[3] = rounded_rect_has_corner (cur_clip, 3) &&
graphene_rect_intersection (&transformed_clip,
&rounded_rect_corner (cur_clip, 3), NULL);
if (n_corners == 0)
goto trivial;
if (corners[0] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 0)))
goto rtt;
if (corners[1] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 1)))
goto rtt;
if (corners[2] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 2)))
goto rtt;
if (corners[3] && !graphene_rect_contains_rect (&transformed_clip, &rounded_rect_corner (cur_clip, 3)))
goto rtt;
/* We do intersect with at least one of the corners, but in such a way that the
* intersection between the two clips can still be represented by a single rounded
* rect in a trivial way. do that. */
{
GskRoundedRect real_intersection;
graphene_rect_intersection (&transformed_clip, &cur_clip->bounds, &real_intersection.bounds);
for (int i = 0; i < 4; i++)
{
if (corners[i])
real_intersection.corner[i] = cur_clip->corner[i];
else
real_intersection.corner[i].width = real_intersection.corner[i].height = 0;
}
/* Draw with that new clip */
ops_push_clip (builder, &real_intersection);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
}
else if (intersect_rounded_rectilinear (&transformed_clip,
builder->current_clip,
&intersection))
{
ops_push_clip (builder, &intersection);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
}
else
{
/* well fuck */
const float scale = ops_get_scale (builder);
gboolean is_offscreen;
TextureRegion region;
GskRoundedRect scaled_clip;
return;
}
memset (&scaled_clip, 0, sizeof (GskRoundedRect));
rtt:
{
/* well fuck */
const float scale = ops_get_scale (builder);
gboolean is_offscreen;
TextureRegion region;
GskRoundedRect scaled_clip;
scaled_clip.bounds.origin.x = clip->origin.x * scale;
scaled_clip.bounds.origin.y = clip->origin.y * scale;
scaled_clip.bounds.size.width = clip->size.width * scale;
scaled_clip.bounds.size.height = clip->size.height * scale;
memset (&scaled_clip, 0, sizeof (GskRoundedRect));
ops_push_clip (builder, &scaled_clip);
if (!add_offscreen_ops (self, builder, &child->bounds,
child,
&region, &is_offscreen,
RESET_OPACITY | FORCE_OFFSCREEN))
g_assert_not_reached ();
ops_pop_clip (builder);
scaled_clip.bounds.origin.x = clip->origin.x * scale;
scaled_clip.bounds.origin.y = clip->origin.y * scale;
scaled_clip.bounds.size.width = clip->size.width * scale;
scaled_clip.bounds.size.height = clip->size.height * scale;
ops_set_program (builder, &self->programs->blit_program);
ops_set_texture (builder, region.texture_id);
ops_push_clip (builder, &scaled_clip);
if (!add_offscreen_ops (self, builder, &child->bounds,
child,
&region, &is_offscreen,
RESET_OPACITY | FORCE_OFFSCREEN))
g_assert_not_reached ();
ops_pop_clip (builder);
load_offscreen_vertex_data (ops_draw (builder, NULL), child, builder);
}
ops_set_program (builder, &self->programs->blit_program);
ops_set_texture (builder, region.texture_id);
load_offscreen_vertex_data (ops_draw (builder, NULL), child, builder);
return;
}
trivial:
memset (&child_clip, 0, sizeof (GskRoundedRect));
graphene_rect_intersection (&transformed_clip,
&builder->current_clip->bounds,
&child_clip.bounds);
ops_push_clip (builder, &child_clip);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
return;
}
static inline void
@@ -1292,29 +1294,6 @@ render_rounded_clip_node (GskGLRenderer *self,
return;
ops_transform_bounds_modelview (builder, &clip->bounds, &transformed_clip.bounds);
for (i = 0; i < 4; i ++)
{
transformed_clip.corner[i].width = clip->corner[i].width * scale;
transformed_clip.corner[i].height = clip->corner[i].height * scale;
}
if (builder->clip_is_rectilinear)
{
GskRoundedRect intersected_clip;
if (intersect_rounded_rectilinear (&builder->current_clip->bounds,
&transformed_clip,
&intersected_clip))
{
ops_push_clip (builder, &intersected_clip);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
return;
}
}
/* After this point we are really working with a new and a current clip
* which both have rounded corners. */
if (!ops_has_clip (builder))
need_offscreen = FALSE;
@@ -1328,16 +1307,12 @@ render_rounded_clip_node (GskGLRenderer *self,
{
/* If they don't intersect at all, we can simply set
* the new clip and add the render ops */
/* If the new clip entirely contains the current clip, the intersection is simply
* the current clip, so we can ignore the new one */
if (rounded_inner_rect_contains_rect (&transformed_clip, &builder->current_clip->bounds))
for (i = 0; i < 4; i ++)
{
gsk_gl_renderer_add_render_ops (self, child, builder);
return;
transformed_clip.corner[i].width = clip->corner[i].width * scale;
transformed_clip.corner[i].height = clip->corner[i].height * scale;
}
/* TODO: Intersect current and new clip */
ops_push_clip (builder, &transformed_clip);
gsk_gl_renderer_add_render_ops (self, child, builder);
ops_pop_clip (builder);
@@ -1379,6 +1354,7 @@ render_rounded_clip_node (GskGLRenderer *self,
load_offscreen_vertex_data (ops_draw (builder, NULL), node, builder);
}
/* Else this node is entirely out of the current clip node and we don't draw it anyway. */
}
static inline void
@@ -1786,6 +1762,7 @@ render_unblurred_outset_shadow_node (GskGLRenderer *self,
}
static GdkRGBA COLOR_WHITE = { 1, 1, 1, 1 };
static inline void
render_outset_shadow_node (GskGLRenderer *self,
@@ -1806,32 +1783,19 @@ render_outset_shadow_node (GskGLRenderer *self,
OpShadow *shadow;
int blurred_texture_id;
int cached_tid;
bool do_slicing;
/* scaled_outline is the minimal outline we need to draw the given drop shadow,
* enlarged by the spread and offset by the blur radius. */
scaled_outline = *outline;
if (outline->bounds.size.width < blur_extra ||
outline->bounds.size.height < blur_extra)
{
do_slicing = false;
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
}
else
{
/* Shrink our outline to the minimum size that can still hold all the border radii */
gsk_rounded_rect_shrink_to_minimum (&scaled_outline);
/* Increase by the spread */
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
/* Grow bounds but don't grow corners */
graphene_rect_inset (&scaled_outline.bounds, - blur_extra / 2.0, - blur_extra / 2.0);
/* For the center part, we add a few pixels */
scaled_outline.bounds.size.width += SHADOW_EXTRA_SIZE;
scaled_outline.bounds.size.height += SHADOW_EXTRA_SIZE;
do_slicing = true;
}
/* Shrink our outline to the minimum size that can still hold all the border radii */
gsk_rounded_rect_shrink_to_minimum (&scaled_outline);
/* Increase by the spread */
gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
/* Grow bounds but don't grow corners */
graphene_rect_inset (&scaled_outline.bounds, - extra_blur_pixels, - extra_blur_pixels);
/* For the center part, we add a few pixels */
scaled_outline.bounds.size.width += SHADOW_EXTRA_SIZE;
scaled_outline.bounds.size.height += SHADOW_EXTRA_SIZE;
texture_width = (int)ceil ((scaled_outline.bounds.size.width + blur_extra) * scale);
texture_height = (int)ceil ((scaled_outline.bounds.size.height + blur_extra) * scale);
@@ -1916,41 +1880,6 @@ render_outset_shadow_node (GskGLRenderer *self,
blurred_texture_id = cached_tid;
}
if (!do_slicing)
{
const float min_x = floorf (builder->dx + outline->bounds.origin.x - spread - (blur_extra / 2.0) + dx);
const float min_y = floorf (builder->dy + outline->bounds.origin.y - spread - (blur_extra / 2.0) + dy);
float x1, x2, y1, y2, tx1, tx2, ty1, ty2;
ops_set_program (builder, &self->programs->outset_shadow_program);
ops_set_color (builder, color);
ops_set_texture (builder, blurred_texture_id);
shadow = ops_begin (builder, OP_CHANGE_OUTSET_SHADOW);
shadow->outline = transform_rect (self, builder, outline);
tx1 = 0; tx2 = 1;
ty1 = 0; ty2 = 1;
x1 = min_x;
x2 = min_x + texture_width / scale;
y1 = min_y;
y2 = min_y + texture_height / scale;
ops_draw (builder, (GskQuadVertex[GL_N_VERTICES]) {
{ { x1, y1 }, { tx1, ty2 }, },
{ { x1, y2 }, { tx1, ty1 }, },
{ { x2, y1 }, { tx2, ty2 }, },
{ { x2, y2 }, { tx2, ty1 }, },
{ { x1, y2 }, { tx1, ty1 }, },
{ { x2, y1 }, { tx2, ty2 }, },
});
return;
}
ops_set_program (builder, &self->programs->outset_shadow_program);
ops_set_color (builder, color);
ops_set_texture (builder, blurred_texture_id);
@@ -3388,8 +3317,19 @@ add_offscreen_ops (GskGLRenderer *self,
bounds->origin.y * scale,
width, height));
builder->dx = 0;
builder->dy = 0;
if (flags & CENTER_CHILD)
{
ops_offset (builder,
(bounds->size.width - child_node->bounds.size.width) / 2.0 -
child_node->bounds.origin.x,
(bounds->size.height - child_node->bounds.size.height) / 2.0 -
child_node->bounds.origin.y);
}
else
{
builder->dx = 0;
builder->dy = 0;
}
if (flags & RESET_OPACITY)
prev_opacity = ops_set_opacity (builder, 1.0);
+1
View File
@@ -247,6 +247,7 @@
#include <gtk/gtkstringsorter.h>
#include <gtk/gtkstylecontext.h>
#include <gtk/gtkstyleprovider.h>
#include <gtk/gtksuggestionentry.h>
#include <gtk/gtkswitch.h>
#include <gtk/gtktext.h>
#include <gtk/gtktextbuffer.h>
+1 -103
View File
@@ -1,7 +1,6 @@
/*
* Copyright © 2010 Codethink Limited
* Copyright © 2013 Canonical Limited
* Copyright © 2020 Emmanuel Gil Peyrot
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,42 +24,12 @@
#include "gtknative.h"
#include <gdk/wayland/gdkwayland.h>
#include <gdk/wayland/gdkdisplay-wayland.h>
#include <gdk/wayland/idle-inhibit-unstable-v1-client-protocol.h>
typedef struct
{
GtkApplicationImplDBusClass parent_class;
/* stores the dbus version of the overriden methods */
guint (*dbus_inhibit) (GtkApplicationImpl *impl,
GtkWindow *window,
GtkApplicationInhibitFlags flags,
const gchar *reason);
void (*dbus_uninhibit) (GtkApplicationImpl *impl,
guint cookie);
} GtkApplicationImplWaylandClass;
typedef struct
{
guint cookie;
guint dbus_cookie;
GtkApplicationInhibitFlags flags;
GdkSurface *surface;
} GtkApplicationWaylandInhibitor;
static void
gtk_application_wayland_inhibitor_free (GtkApplicationWaylandInhibitor *inhibitor)
{
g_slice_free (GtkApplicationWaylandInhibitor, inhibitor);
}
typedef GtkApplicationImplDBusClass GtkApplicationImplWaylandClass;
typedef struct
{
GtkApplicationImplDBus dbus;
GSList *inhibitors;
guint next_cookie;
} GtkApplicationImplWayland;
@@ -103,70 +72,6 @@ gtk_application_impl_wayland_before_emit (GtkApplicationImpl *impl,
gdk_wayland_display_set_startup_notification_id (gdk_display_get_default (), startup_notification_id);
}
static guint
gtk_application_impl_wayland_inhibit (GtkApplicationImpl *impl,
GtkWindow *window,
GtkApplicationInhibitFlags flags,
const gchar *reason)
{
GtkApplicationImplWayland *wayland = (GtkApplicationImplWayland *) impl;
GdkSurface *surface;
GtkApplicationWaylandInhibitor *inhibitor;
gboolean success;
if (!flags)
return 0;
inhibitor = g_slice_new (GtkApplicationWaylandInhibitor);
inhibitor->cookie = ++wayland->next_cookie;
inhibitor->flags = flags;
wayland->inhibitors = g_slist_prepend (wayland->inhibitors, inhibitor);
if (flags & GTK_APPLICATION_INHIBIT_IDLE)
{
surface = gtk_native_get_surface (GTK_NATIVE (window));
if (GDK_IS_WAYLAND_SURFACE (surface))
{
success = gdk_wayland_surface_inhibit_idle (surface);
if (success)
{
flags &= ~GTK_APPLICATION_INHIBIT_IDLE;
inhibitor->surface = surface;
}
}
}
inhibitor->dbus_cookie = ((GtkApplicationImplWaylandClass *) G_OBJECT_GET_CLASS (wayland))->dbus_inhibit (impl, window, flags, reason);
return inhibitor->cookie;
}
static void
gtk_application_impl_wayland_uninhibit (GtkApplicationImpl *impl,
guint cookie)
{
GtkApplicationImplWayland *wayland = (GtkApplicationImplWayland *) impl;
GSList *iter;
for (iter = wayland->inhibitors; iter; iter = iter->next)
{
GtkApplicationWaylandInhibitor *inhibitor = iter->data;
if (inhibitor->cookie == cookie)
{
if (inhibitor->dbus_cookie)
((GtkApplicationImplWaylandClass *) G_OBJECT_GET_CLASS (wayland))->dbus_uninhibit (impl, inhibitor->dbus_cookie);
if (inhibitor->surface)
gdk_wayland_surface_uninhibit_idle (inhibitor->surface);
gtk_application_wayland_inhibitor_free (inhibitor);
wayland->inhibitors = g_slist_delete_link (wayland->inhibitors, iter);
return;
}
}
g_warning ("Invalid inhibitor cookie");
}
static void
gtk_application_impl_wayland_init (GtkApplicationImplWayland *wayland)
{
@@ -177,15 +82,8 @@ gtk_application_impl_wayland_class_init (GtkApplicationImplWaylandClass *class)
{
GtkApplicationImplClass *impl_class = GTK_APPLICATION_IMPL_CLASS (class);
class->dbus_inhibit = impl_class->inhibit;
class->dbus_uninhibit = impl_class->uninhibit;
impl_class->handle_window_realize =
gtk_application_impl_wayland_handle_window_realize;
impl_class->before_emit =
gtk_application_impl_wayland_before_emit;
impl_class->inhibit =
gtk_application_impl_wayland_inhibit;
impl_class->uninhibit =
gtk_application_impl_wayland_uninhibit;
}
-1
View File
@@ -109,7 +109,6 @@ gtk_application_accels_set_accels_for_action (GtkApplicationAccels *accels,
}
g_list_store_remove (G_LIST_STORE (accels->shortcuts), i);
g_object_unref (shortcut_i);
break;
}
+137
View File
@@ -0,0 +1,137 @@
#ifndef __GTK_ARRAY_IMPL_PRIVATE_H__
#define __GTK_ARRAY_IMPL_PRIVATE_H__
/* This is a dumbed-down GPtrArray, which takes some stack
* space to use. When using this, the general case should always
* be that the number of elements is lower than reserved_size.
* The GPtrArray should only be used in extreme cases.
*/
typedef struct
{
guint reserved_size;
guint len;
void **stack_space;
GPtrArray *ptr_array;
} GtkArray;
static inline void
gtk_array_init (GtkArray *self,
void **stack_space,
guint reserved_size)
{
self->reserved_size = reserved_size;
self->len = 0;
self->stack_space = stack_space;
self->ptr_array = NULL;
}
static inline void *
gtk_array_index (const GtkArray *self,
guint index)
{
g_assert (index < self->len);
if (G_LIKELY (!self->ptr_array))
return self->stack_space[index];
return g_ptr_array_index (self->ptr_array, index);
}
static inline void
gtk_array_add (GtkArray *self,
void *element)
{
if (G_LIKELY (self->len < self->reserved_size))
{
self->stack_space[self->len] = element;
self->len++;
return;
}
/* Need to fall back to the GPtrArray */
if (G_UNLIKELY (!self->ptr_array))
{
self->ptr_array = g_ptr_array_new_full (self->len + 1, NULL);
memcpy (self->ptr_array->pdata, self->stack_space, sizeof (void *) * self->len);
self->ptr_array->len = self->len;
}
g_ptr_array_add (self->ptr_array, element);
self->len++; /* We still count self->len */
}
static inline void
gtk_array_insert (GtkArray *self,
guint index,
void *element)
{
if (index >= self->len)
{
gtk_array_add (self, element);
return;
}
if (G_LIKELY (self->len < self->reserved_size))
{
memmove (self->stack_space + index + 1, self->stack_space + index,
sizeof (void *) * (self->len - index));
self->stack_space[index] = element;
self->len++;
return;
}
if (G_UNLIKELY (!self->ptr_array))
{
self->ptr_array = g_ptr_array_new_full (self->len + 1, NULL);
memcpy (self->ptr_array->pdata, self->stack_space, sizeof (void *) * self->len);
self->ptr_array->len = self->len;
}
g_assert (self->ptr_array);
g_ptr_array_insert (self->ptr_array, index, element);
self->len++;
}
static inline void
gtk_array_free (GtkArray *self,
GDestroyNotify element_free_func)
{
guint i;
if (G_LIKELY (!self->ptr_array))
{
if (element_free_func)
{
for (i = 0; i < self->len; i++)
element_free_func (self->stack_space[i]);
}
return;
}
g_assert (self->ptr_array);
if (element_free_func)
{
for (i = 0; i < self->ptr_array->len; i++)
element_free_func (g_ptr_array_index (self->ptr_array, i));
}
g_ptr_array_free (self->ptr_array, TRUE);
}
static inline void **
gtk_array_get_data (GtkArray *self)
{
if (G_LIKELY (!self->ptr_array))
return self->stack_space;
return self->ptr_array->pdata;
}
#endif
+4 -3
View File
@@ -27,19 +27,20 @@
* SECTION:gtkbitset
* @title: GtkBitset
* @short_description: Sets of integers
* @see_also: #GtkSelectionModel
* @see_also: GtkSelectionModel
*
* #GtkBitset is a data structure for representing a set of unsigned integers.
* Another name for this data structure is "bitmap".
*
* The current implemenation is based on [roaring bitmaps](https://roaringbitmap.org/).
* This version is based on [roaring bitmaps](https://roaringbitmap.org/).
*
* A bitset allows adding a set of integers and provides support for set operations
* like unions, intersections and checks for equality or if a value is contained
* in the set. #GtkBitset also contains various functions to query metadata about
* the bitset, such as the minimum or maximum values or its size.
*
* The fastest way to iterate values in a bitset is #GtkBitsetIter.
* The fastest way to iterate values in a bitset is #GtkBitsetIter which allows
* quick iteration of all the values in a bitset.
*
* The main use case for #GtkBitset is implementing complex selections for
* #GtkSelectionModel.
+1 -15
View File
@@ -130,21 +130,7 @@ void gtk_bitset_splice (GtkBitset
guint removed,
guint added);
/**
* GtkBitsetIter:
*
* An opaque, stack-allocated struct for iterating
* over the elements of a #GtkBitset. Before a GtkBitsetIter
* can be used, it needs to be initialized with
* gtk_bitset_iter_init_first(), gtk_bitset_iter_init_last()
* or gtk_bitset_iter_init_at().
*/
typedef struct _GtkBitsetIter GtkBitsetIter;
struct _GtkBitsetIter
{
gpointer private_data[10];
};
typedef struct {gpointer private_data[10]; } GtkBitsetIter;
GDK_AVAILABLE_IN_ALL
gboolean gtk_bitset_iter_init_first (GtkBitsetIter *iter,
+14 -6
View File
@@ -28,6 +28,7 @@
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtknative.h"
/**
* SECTION:gtkboxlayout
@@ -249,8 +250,10 @@ gtk_box_layout_compute_size (GtkBoxLayout *self,
required_nat += (n_visible_children - 1) * spacing;
}
*minimum = required_min;
*natural = required_nat;
if (minimum != NULL)
*minimum = required_min;
if (natural != NULL)
*natural = required_nat;
}
static void
@@ -417,10 +420,15 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
}
}
*minimum = computed_minimum;
*natural = MAX (computed_natural, computed_natural_below + computed_natural_above);
*min_baseline = computed_minimum_baseline;
*nat_baseline = computed_natural_baseline;
if (minimum != NULL)
*minimum = computed_minimum;
if (natural != NULL)
*natural = MAX (computed_natural, computed_natural_below + computed_natural_above);
if (min_baseline != NULL)
*min_baseline = computed_minimum_baseline;
if (nat_baseline != NULL)
*nat_baseline = computed_natural_baseline;
}
static void
-11
View File
@@ -294,17 +294,6 @@ gtk_button_class_init (GtkButtonClass *klass)
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_BUTTON_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, I_("button"));
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_Return, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_ISO_Enter, 0,
"activate", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Enter, 0,
"activate", NULL);
}
static void
+1 -3
View File
@@ -62,12 +62,10 @@ gtk_column_list_item_factory_setup (GtkListItemFactory *factory,
{
GtkColumnViewColumn *column = g_list_model_get_item (columns, i);
gtk_column_list_item_factory_add_column (self,
gtk_column_list_item_factory_add_column (self,
list_item->owner,
column,
FALSE);
g_object_unref (column);
}
}
+10 -19
View File
@@ -60,7 +60,7 @@
* GtkColumnView allows the user to select items according to the selection
* characteristics of the model. If the provided model is not a #GtkSelectionModel,
* GtkColumnView will wrap it in a #GtkSingleSelection. For models that allow
* multiple selected items, it is possible to turn on *rubberband selection*,
* multiple selected items, it is possible to turn on _rubberband selection_,
* using #GtkColumnView:enable-rubberband.
*
* The column view supports sorting that can be customized by the user by
@@ -1241,7 +1241,7 @@ gtk_column_view_set_model (GtkColumnView *self,
*
* Gets the list of columns in this column view. This list is constant over
* the lifetime of @self and can be used to monitor changes to the columns
* of @self by connecting to the #GListModel:items-changed signal.
* of @self by connecting to the GListModel:items-changed signal.
*
* Returns: (transfer none): The list managing the columns
**/
@@ -1263,7 +1263,7 @@ gtk_column_view_get_columns (GtkColumnView *self)
*/
void
gtk_column_view_set_show_row_separators (GtkColumnView *self,
gboolean show_row_separators)
gboolean show_row_separators)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
@@ -1302,7 +1302,7 @@ gtk_column_view_get_show_row_separators (GtkColumnView *self)
*/
void
gtk_column_view_set_show_column_separators (GtkColumnView *self,
gboolean show_column_separators)
gboolean show_column_separators)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
@@ -1486,26 +1486,17 @@ gtk_column_view_get_list_view (GtkColumnView *self)
* gtk_column_view_get_sorter:
* @self: a #GtkColumnView
*
* Returns a special sorter that reflects the users sorting
* choices in the column view.
* Returns the sorter associated with users sorting choices in
* the column view.
*
* To allow users to customizable sorting by clicking on column
* headers, this sorter needs to be set on the sort model underneath
* the model that is displayed by the view.
* headers, this sorter needs to be set on the sort
* model(s) underneath the model that is displayed
* by the view.
*
* See gtk_column_view_column_set_sorter() for setting up
* See gtk_column_view_column_get_sorter() for setting up
* per-column sorting.
*
* Here is an example:
* |[
* gtk_column_view_column_set_sorter (column, sorter);
* gtk_column_view_append_column (view, column);
* model = gtk_sort_list_model_new (store,
* gtk_column_view_get_sorter (view));
* selection = gtk_no_selection_new (model);
* gtk_column_view_set_model (view, selection);
* ]|
*
* Returns: (transfer none): the #GtkSorter of @self
*/
GtkSorter *
-1
View File
@@ -105,7 +105,6 @@ void gtk_column_view_set_reorderable (GtkColumnView
GDK_AVAILABLE_IN_ALL
gboolean gtk_column_view_get_reorderable (GtkColumnView *self);
GDK_AVAILABLE_IN_ALL
void gtk_column_view_set_enable_rubberband (GtkColumnView *self,
gboolean enable_rubberband);
GDK_AVAILABLE_IN_ALL
-1
View File
@@ -85,7 +85,6 @@ void gtk_column_view_column_set_header_menu (GtkColu
GDK_AVAILABLE_IN_ALL
GMenuModel * gtk_column_view_column_get_header_menu (GtkColumnViewColumn *self);
GDK_AVAILABLE_IN_ALL
void gtk_column_view_column_set_fixed_width (GtkColumnViewColumn *self,
int fixed_width);
GDK_AVAILABLE_IN_ALL
-8
View File
@@ -115,14 +115,6 @@ gtk_column_view_sorter_dispose (GObject *object)
{
GtkColumnViewSorter *self = GTK_COLUMN_VIEW_SORTER (object);
/* The sorter is owned by the columview and is unreffed
* after the columns, so the sequence must be empty at
* this point.
* The sorter can outlive the columview it comes from
* (the model might still have a ref), but that does
* not change the fact that all columns will be gone.
*/
g_assert (g_sequence_is_empty (self->sorters));
g_clear_pointer (&self->sorters, g_sequence_free);
G_OBJECT_CLASS (gtk_column_view_sorter_parent_class)->dispose (object);
+15 -13
View File
@@ -391,9 +391,9 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
}
static void
verify_tree_match_results (GtkCssProvider *provider,
GtkCssNode *node,
GtkCssSelectorMatches *tree_rules)
verify_tree_match_results (GtkCssProvider *provider,
GtkCssNode *node,
GtkArray *tree_rules)
{
#ifdef VERIFY_TREE
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (provider);
@@ -407,9 +407,9 @@ verify_tree_match_results (GtkCssProvider *provider,
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
for (j = 0; j < gtk_css_selector_matches_get_size (tree_rules); j++)
for (j = 0; j < tree_rules->len; j++)
{
if (ruleset == gtk_css_selector_matches_get (tree_rules, j))
if (ruleset == gtk_array_index (tree_rules, j))
{
found = TRUE;
break;
@@ -459,21 +459,22 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
GtkCssRuleset *ruleset;
guint j;
int i;
GtkCssSelectorMatches tree_rules;
GtkArray tree_rules_array;
GtkCssRuleset *rules_stack[32];
if (_gtk_css_selector_tree_is_empty (priv->tree))
return;
gtk_css_selector_matches_init (&tree_rules);
_gtk_css_selector_tree_match_all (priv->tree, filter, node, &tree_rules);
gtk_array_init (&tree_rules_array, (void**)rules_stack, 32);
_gtk_css_selector_tree_match_all (priv->tree, filter, node, &tree_rules_array);
if (!gtk_css_selector_matches_is_empty (&tree_rules))
if (tree_rules_array.len > 0)
{
verify_tree_match_results (css_provider, node, &tree_rules);
verify_tree_match_results (css_provider, node, &tree_rules_array);
for (i = gtk_css_selector_matches_get_size (&tree_rules) - 1; i >= 0; i--)
for (i = tree_rules_array.len - 1; i >= 0; i--)
{
ruleset = gtk_css_selector_matches_get (&tree_rules, i);
ruleset = gtk_array_index (&tree_rules_array, i);
if (ruleset->styles == NULL)
continue;
@@ -492,8 +493,9 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
ruleset->styles[j].value);
}
}
gtk_array_free (&tree_rules_array, NULL);
}
gtk_css_selector_matches_clear (&tree_rules);
if (change)
*change = gtk_css_selector_tree_get_change_all (priv->tree, filter, node);
+20 -17
View File
@@ -24,6 +24,7 @@
#include "gtkcssprovider.h"
#include "gtkstylecontextprivate.h"
#include "gtkarrayimplprivate.h"
#include <errno.h>
#if defined(_MSC_VER) && _MSC_VER >= 1500
@@ -151,14 +152,14 @@ gtk_css_selector_tree_get_matches (const GtkCssSelectorTree *tree)
}
static void
gtk_css_selector_matches_insert_sorted (GtkCssSelectorMatches *matches,
gpointer data)
gtk_array_insert_sorted (GtkArray *array,
gpointer data)
{
guint i;
for (i = 0; i < gtk_css_selector_matches_get_size (matches); i++)
for (i = 0; i < array->len; i++)
{
gpointer elem = gtk_css_selector_matches_get (matches, i);
gpointer elem = gtk_array_index (array, i);
if (data == elem)
return;
@@ -167,7 +168,7 @@ gtk_css_selector_matches_insert_sorted (GtkCssSelectorMatches *matches,
break;
}
gtk_css_selector_matches_splice (matches, i, 0, (gpointer[1]) { data }, 1);
gtk_array_insert (array, i, data);
}
static inline gboolean
@@ -1876,7 +1877,7 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
static void
gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
GtkCssSelectorMatches *results)
GtkArray *results)
{
int i;
gpointer *matches;
@@ -1886,7 +1887,7 @@ gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree,
return;
for (i = 0; matches[i] != NULL; i++)
gtk_css_selector_matches_insert_sorted (results, matches[i]);
gtk_array_insert_sorted (results, matches[i]);
}
static gboolean
@@ -1894,7 +1895,7 @@ gtk_css_selector_tree_match (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
gboolean match_filter,
GtkCssNode *node,
GtkCssSelectorMatches *results)
GtkArray *results)
{
const GtkCssSelectorTree *prev;
GtkCssNode *child;
@@ -1931,7 +1932,7 @@ void
_gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
GtkCssSelectorMatches *out_tree_rules)
GtkArray *out_tree_rules)
{
const GtkCssSelectorTree *iter;
@@ -2116,7 +2117,8 @@ subdivide_infos (GByteArray *array,
GHashTableIter iter;
guint max_count;
gpointer key, value;
GtkCssSelectorMatches exact_matches;
void *exact_matches_stack[8];
GtkArray exact_matches_array;
gint32 res;
guint i;
@@ -2158,7 +2160,7 @@ subdivide_infos (GByteArray *array,
matched_infos = g_alloca (sizeof (GtkCssSelectorRuleSetInfo *) * n_infos);
remaining_infos = g_alloca (sizeof (GtkCssSelectorRuleSetInfo *) * n_infos);
gtk_css_selector_matches_init (&exact_matches);
gtk_array_init (&exact_matches_array, (void**)exact_matches_stack, 8);
for (i = 0; i < n_infos; i++)
{
GtkCssSelectorRuleSetInfo *info = infos[i];
@@ -2169,7 +2171,7 @@ subdivide_infos (GByteArray *array,
if (info->current_selector == NULL)
{
/* Matches current node */
gtk_css_selector_matches_append (&exact_matches, info->match);
gtk_array_add (&exact_matches_array, info->match);
if (info->selector_match != NULL)
*info->selector_match = GUINT_TO_POINTER (tree_offset);
}
@@ -2186,16 +2188,17 @@ subdivide_infos (GByteArray *array,
}
}
if (!gtk_css_selector_matches_is_empty (&exact_matches))
if (exact_matches_array.len > 0)
{
gtk_css_selector_matches_append (&exact_matches, NULL); /* Null terminate */
gtk_array_add (&exact_matches_array, NULL); /* Null terminate */
res = array->len;
g_byte_array_append (array, (guint8 *) gtk_css_selector_matches_get_data (&exact_matches),
gtk_css_selector_matches_get_size (&exact_matches) * sizeof (gpointer));
g_byte_array_append (array, (guint8 *)gtk_array_get_data (&exact_matches_array),
exact_matches_array.len * sizeof (gpointer));
gtk_array_free (&exact_matches_array, NULL);
}
else
res = GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET;
gtk_css_selector_matches_clear (&exact_matches);
get_tree (array, tree_offset)->matches_offset = res;
res = subdivide_infos (array, matched_infos, n_matched, tree_offset);
+3 -8
View File
@@ -21,12 +21,7 @@
#include "gtk/gtkcountingbloomfilterprivate.h"
#include "gtk/gtkcsstypesprivate.h"
#include "gtk/gtkcssparserprivate.h"
#define GDK_ARRAY_ELEMENT_TYPE gpointer
#define GDK_ARRAY_TYPE_NAME GtkCssSelectorMatches
#define GDK_ARRAY_NAME gtk_css_selector_matches
#define GDK_ARRAY_PREALLOC 32
#include "gdk/gdkarrayimpl.c"
#include "gtk/gtkarrayimplprivate.h"
G_BEGIN_DECLS
@@ -50,8 +45,8 @@ int _gtk_css_selector_compare (const GtkCssSelector *a,
void _gtk_css_selector_tree_free (GtkCssSelectorTree *tree);
void _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
GtkCssSelectorMatches *out_tree_rules);
GtkCssNode *node,
GtkArray *out_tree_rules);
GtkCssChange gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCountingBloomFilter *filter,
GtkCssNode *node);
+5 -9
View File
@@ -29,8 +29,8 @@
* @Title: GtkCustomFilter
* @Short_description: Filtering with callbacks
*
* #GtkCustomFilter is a #GtkFilter that uses a callback to determine
* whether to include an item or not.
* #GtkCustomFilter is a #GtkFilter that uses a callback to determine whether
* to include an item or not.
*/
struct _GtkCustomFilter
{
@@ -98,13 +98,11 @@ gtk_custom_filter_init (GtkCustomFilter *self)
* gtk_custom_filter_new:
* @match_func: (nullable): function to filter items
* @user_data: (nullable): user data to pass to @match_func
* @user_destroy: destroy notify for @user_data
* @user_destroy: destory notify
*
* Creates a new filter using the given @match_func to filter
* items.
*
* If @match_func is %NULL, the filter matches all items.
*
* If the filter func changes its filtering behavior,
* gtk_filter_changed() needs to be called.
*
@@ -129,12 +127,10 @@ gtk_custom_filter_new (GtkCustomFilterFunc match_func,
* @self: a #GtkCustomFilter
* @match_func: (nullable): function to filter items
* @user_data: (nullable): user data to pass to @match_func
* @user_destroy: destroy notify for @user_data
* @user_destroy: destory notify
*
* Sets (or unsets) the function used for filtering items.
*
* If @match_func is %NULL, the filter matches all items.
*
*
* If the filter func changes its filtering behavior,
* gtk_filter_changed() needs to be called.
*
+5 -9
View File
@@ -27,7 +27,7 @@
/**
* SECTION:gtkcustomsorter
* @Title: GtkCustomSorter
* @Short_description: Sorting with a callbacks
* @Short_description: Sorting with a callback
*
* GtkCustomSorter is a #GtkSorter implementation that sorts
* via a traditional #GCompareDataFunc callback.
@@ -108,10 +108,8 @@ gtk_custom_sorter_init (GtkCustomSorter *self)
* Creates a new #GtkSorter that works by calling
* @sort_func to compare items.
*
* If @sort_func is %NULL, all items are considered equal.
*
* Returns: a new #GtkSorter
*/
* Returns: a new #GTkSorter
*/
GtkSorter *
gtk_custom_sorter_new (GCompareDataFunc sort_func,
gpointer user_data,
@@ -131,12 +129,10 @@ gtk_custom_sorter_new (GCompareDataFunc sort_func,
* @self: a #GtkCustomSorter
* @sort_func: (nullable): function to sort items
* @user_data: (nullable): user data to pass to @match_func
* @user_destroy: destroy notify for @user_data
* @user_destroy: destory notify
*
* Sets (or unsets) the function used for sorting items.
*
* If @sort_func is %NULL, all items are considered equal.
*
*
* If the sort func changes its sorting behavior,
* gtk_sorter_changed() needs to be called.
*
+5 -4
View File
@@ -48,10 +48,11 @@ typedef enum {
GTK_DEBUG_INTERACTIVE = 1 << 10,
GTK_DEBUG_TOUCHSCREEN = 1 << 11,
GTK_DEBUG_ACTIONS = 1 << 12,
GTK_DEBUG_LAYOUT = 1 << 13,
GTK_DEBUG_SNAPSHOT = 1 << 14,
GTK_DEBUG_CONSTRAINTS = 1 << 15,
GTK_DEBUG_BUILDER_OBJECTS = 1 << 16,
GTK_DEBUG_RESIZE = 1 << 13,
GTK_DEBUG_LAYOUT = 1 << 14,
GTK_DEBUG_SNAPSHOT = 1 << 15,
GTK_DEBUG_CONSTRAINTS = 1 << 16,
GTK_DEBUG_BUILDER_OBJECTS = 1 << 17,
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
+3 -2
View File
@@ -70,7 +70,7 @@
* useful if the list of options is long. To enable the search entry,
* use gtk_drop_down_set_enable_search().
*
* # CSS nodes
* * # CSS nodes
*
* GtkDropDown has a single CSS node with name dropdown,
* with the button and popover nodes as children.
@@ -205,8 +205,9 @@ update_filter (GtkDropDown *self)
if (self->expression)
{
filter = gtk_string_filter_new (gtk_expression_ref (self->expression));
filter = gtk_string_filter_new ();
gtk_string_filter_set_match_mode (GTK_STRING_FILTER (filter), GTK_STRING_FILTER_MATCH_MODE_PREFIX);
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter), self->expression);
}
else
filter = gtk_every_filter_new ();
-34
View File
@@ -30,7 +30,6 @@
#include "gtkshortcut.h"
#include "gtkshortcuttrigger.h"
#include "gtkwidgetprivate.h"
#include "gtkeventcontrollerfocus.h"
#include "gtkintl.h"
/**
@@ -49,22 +48,6 @@
* to click or press the Enter key. The default bindings
* for leaving the edit mode are the Enter key (to save
* the results) or the Escape key (to cancel the editing).
*
* # CSS nodes
*
* |[<!-- language="plain" -->
* editablelabel[.editing]
* stack
* label
* text
* ]|
*
* GtkEditableLabel has a main node with the name editablelabel.
* When the entry is in editing mode, it gets the .editing style
* class.
*
* For all the subnodes added to the text node in various situations,
* see #GtkText.
*/
struct _GtkEditableLabel
@@ -194,20 +177,12 @@ gtk_editable_label_prepare_drag (GtkDragSource *source,
gtk_label_get_label (GTK_LABEL (self->label)));
}
static void
gtk_editable_label_focus_out (GtkEventController *controller,
GtkEditableLabel *self)
{
gtk_editable_label_stop_editing (self, TRUE);
}
static void
gtk_editable_label_init (GtkEditableLabel *self)
{
GtkGesture *gesture;
GtkDropTarget *target;
GtkDragSource *source;
GtkEventController *controller;
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
@@ -237,10 +212,6 @@ gtk_editable_label_init (GtkEditableLabel *self)
g_signal_connect (source, "prepare", G_CALLBACK (gtk_editable_label_prepare_drag), self);
gtk_widget_add_controller (self->label, GTK_EVENT_CONTROLLER (source));
controller = gtk_event_controller_focus_new ();
g_signal_connect (controller, "leave", G_CALLBACK (gtk_editable_label_focus_out), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
gtk_editable_init_delegate (GTK_EDITABLE (self));
}
@@ -473,8 +444,6 @@ gtk_editable_label_start_editing (GtkEditableLabel *self)
gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "entry");
gtk_widget_grab_focus (self->entry);
gtk_widget_add_css_class (GTK_WIDGET (self), "editing");
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EDITING]);
}
@@ -511,8 +480,5 @@ gtk_editable_label_stop_editing (GtkEditableLabel *self,
}
gtk_widget_grab_focus (GTK_WIDGET (self));
gtk_widget_remove_css_class (GTK_WIDGET (self), "editing");
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EDITING]);
}
+9 -83
View File
@@ -53,26 +53,26 @@
*
* Here is an example of a complex expression:
* |[
* color_expr = gtk_property_expression_new (GTK_TYPE_LIST_ITEM,
* NULL, "item");
* expression = gtk_property_expression_new (GTK_TYPE_COLOR,
* color_expr, "name");
* color_expr = gtk_property_expression_new (GTK_TYPE_LIST_ITEM,
* NULL, "item");
* expression = gtk_property_expression_new (GTK_TYPE_COLOR,
* color_expr,
* "name");
* ]|
*
* when evaluated with `this` being a GtkListItem, it will obtain the
* "item" property from the GtkListItem, and then obtain the "name" property
* from the resulting object (which is assumed to be of type GTK_TYPE_COLOR).
*
* A more concise way to describe this would be
* |[
* this->item->name
* this->item->name
* ]|
*
* The most likely place where you will encounter expressions is in the context
* of list models and list widgets using them. For example, #GtkDropDown is
* evaluating a GtkExpression to obtain strings from the items in its model
* that it can then use to match against the contents of its search entry.
* #GtkStringFilter is using a GtkExpression for similar reasons.
* #GtkStringFilter is using a GtkExpression for a similar reason.
*
* By default, expressions are not paying attention to changes and evaluation is
* just a snapshot of the current state at a given time. To get informed about
@@ -127,11 +127,11 @@
* attribute to specify the object type, and a `name` attribute to specify the property
* to look up. The content of <lookup> can either be an element specfiying the expression
* to use the object, or a string that specifies the name of the object to use.
*
*
* Example:
* |[
* <lookup name='search'>string_filter</lookup>
* ]|
* |]
*
* To create a constant expression, use the <constant> element. If the type attribute
* is specified, the element content is interpreted as a value of that type. Otherwise,
@@ -855,24 +855,6 @@ gtk_constant_expression_new_for_value (const GValue *value)
return result;
}
/**
* gtk_constant_expression_get_value:
* @expression: a constant #GtkExpression
*
* Gets the value that a constant expression evaluates to.
*
* Returns: (transfer none): the value
*/
const GValue *
gtk_constant_expression_get_value (GtkExpression *expression)
{
GtkConstantExpression *self = (GtkConstantExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_CONSTANT_EXPRESSION), NULL);
return &self->value;
}
/* }}} */
/* {{{ GtkObjectExpression */
@@ -1020,24 +1002,6 @@ gtk_object_expression_new (GObject *object)
return result;
}
/**
* gtk_object_expression_get_object:
* @expression: an object #GtkExpression
*
* Gets the object that the expression evaluates to.
*
* Returns: (transfer none): the object, or %NULL
*/
GObject *
gtk_object_expression_get_object (GtkExpression *expression)
{
GtkObjectExpression *self = (GtkObjectExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_OBJECT_EXPRESSION), NULL);
return self->object;
}
/* }}} */
/* {{{ GtkPropertyExpression */
@@ -1343,44 +1307,6 @@ gtk_property_expression_new_for_pspec (GtkExpression *expression,
return result;
}
/**
* gtk_property_expression_get_expression:
* @expression: a property #GtkExpression
*
* Gets the expression specifying the object of
* a property expression.
*
* Returns: (transfer none): the object expression
*/
GtkExpression *
gtk_property_expression_get_expression (GtkExpression *expression)
{
GtkPropertyExpression *self = (GtkPropertyExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION), NULL);
return self->expr;
}
/**
* gtk_property_expression_get_pspec:
* @expression: a property #GtkExpression
*
* Gets the #GParamSpec specifying the property of
* a property expression.
*
* Returns: (transfer none): the #GParamSpec
*/
GParamSpec *
gtk_property_expression_get_pspec (GtkExpression *expression)
{
GtkPropertyExpression *self = (GtkPropertyExpression *) expression;
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GTK_TYPE_PROPERTY_EXPRESSION), NULL);
return self->pspec;
}
/* }}} */
/* {{{ GtkClosureExpression */
-11
View File
@@ -93,11 +93,6 @@ GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_new_for_pspec (GtkExpression *expression,
GParamSpec *pspec);
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_property_expression_get_expression (GtkExpression *expression);
GDK_AVAILABLE_IN_ALL
GParamSpec * gtk_property_expression_get_pspec (GtkExpression *expression);
#define GTK_TYPE_CONSTANT_EXPRESSION (gtk_constant_expression_get_type())
typedef struct _GtkConstantExpression GtkConstantExpression;
@@ -110,9 +105,6 @@ GtkExpression * gtk_constant_expression_new (GType
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_constant_expression_new_for_value (const GValue *value);
GDK_AVAILABLE_IN_ALL
const GValue * gtk_constant_expression_get_value (GtkExpression *expression);
#define GTK_TYPE_OBJECT_EXPRESSION (gtk_object_expression_get_type())
typedef struct _GtkObjectExpression GtkObjectExpression;
@@ -122,9 +114,6 @@ GType gtk_object_expression_get_type (void) G_GNUC_CO
GDK_AVAILABLE_IN_ALL
GtkExpression * gtk_object_expression_new (GObject *object);
GDK_AVAILABLE_IN_ALL
GObject * gtk_object_expression_get_object (GtkExpression *expression);
#define GTK_TYPE_CLOSURE_EXPRESSION (gtk_closure_expression_get_type())
typedef struct _GtkClosureExpression GtkClosureExpression;
+18
View File
@@ -540,6 +540,24 @@ gtk_file_chooser_get_file (GtkFileChooser *chooser)
return result;
}
/*< private >
* _gtk_file_chooser_get_file_system:
* @chooser: a #GtkFileChooser
*
* Gets the #GtkFileSystem of @chooser; this is an internal
* implementation detail, used for conversion between paths
* and filenames and URIs.
*
* Returns: the file system for @chooser.
**/
GtkFileSystem *
_gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
{
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
}
/**
* gtk_file_chooser_add_shortcut_folder:
* @chooser: a #GtkFileChooser
+572 -779
View File
File diff suppressed because it is too large Load Diff
+9 -11
View File
@@ -25,6 +25,8 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserembed.h"
#include "gtkfilesystem.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
@@ -263,9 +265,8 @@ static void gtk_file_chooser_dialog_size_allocate (GtkWidget *wid
int width,
int height,
int baseline);
static void gtk_file_chooser_dialog_activate_response (GtkWidget *widget,
const char *action_name,
GVariant *parameters);
static void file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog);
static void response_cb (GtkDialog *dialog,
gint response_id);
@@ -305,8 +306,7 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDialog, widget);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserDialog, buttons);
gtk_widget_class_bind_template_callback (widget_class, response_cb);
gtk_widget_class_install_action (widget_class, "response.activate", NULL, gtk_file_chooser_dialog_activate_response);
gtk_widget_class_bind_template_callback (widget_class, file_chooser_widget_response_requested);
}
static void
@@ -362,11 +362,9 @@ is_accept_response_id (gint response_id)
}
static void
gtk_file_chooser_dialog_activate_response (GtkWidget *widget,
const char *action_name,
GVariant *parameters)
file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
GtkWidget *button;
@@ -609,7 +607,7 @@ gtk_file_chooser_dialog_map (GtkWidget *widget)
setup_save_entry (dialog);
ensure_default_response (dialog);
gtk_file_chooser_widget_initial_focus (GTK_FILE_CHOOSER_WIDGET (priv->widget));
_gtk_file_chooser_embed_initial_focus (GTK_FILE_CHOOSER_EMBED (priv->widget));
GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->map (widget);
}
@@ -673,7 +671,7 @@ response_cb (GtkDialog *dialog,
/* Act only on response IDs we recognize */
if (is_accept_response_id (response_id) &&
!priv->response_requested &&
!gtk_file_chooser_widget_should_respond (GTK_FILE_CHOOSER_WIDGET (priv->widget)))
!_gtk_file_chooser_embed_should_respond (GTK_FILE_CHOOSER_EMBED (priv->widget)))
{
g_signal_stop_emission_by_name (dialog, "response");
}
+152
View File
@@ -0,0 +1,152 @@
/* GTK - The GIMP Toolkit
* gtkfilechooserembed.h: Abstract sizing interface for file selector implementations
* Copyright (C) 2004, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkfilechooserembed.h"
#include "gtkmarshalers.h"
#include "gtkintl.h"
static void gtk_file_chooser_embed_class_init (gpointer g_iface);
static gboolean delegate_should_respond (GtkFileChooserEmbed *chooser_embed);
static void delegate_initial_focus (GtkFileChooserEmbed *chooser_embed);
static void delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
gpointer data);
static GtkFileChooserEmbed *
get_delegate (GtkFileChooserEmbed *receiver)
{
return g_object_get_data (G_OBJECT (receiver), "gtk-file-chooser-embed-delegate");
}
/**
* _gtk_file_chooser_embed_delegate_iface_init:
* @iface: a #GtkFileChoserEmbedIface structure
*
* An interface-initialization function for use in cases where an object is
* simply delegating the methods, signals of the #GtkFileChooserEmbed interface
* to another object. _gtk_file_chooser_embed_set_delegate() must be called on
* each instance of the object so that the delegate object can be found.
**/
void
_gtk_file_chooser_embed_delegate_iface_init (GtkFileChooserEmbedIface *iface)
{
iface->should_respond = delegate_should_respond;
iface->initial_focus = delegate_initial_focus;
}
/**
* _gtk_file_chooser_embed_set_delegate:
* @receiver: a GOobject implementing #GtkFileChooserEmbed
* @delegate: another GObject implementing #GtkFileChooserEmbed
*
* Establishes that calls on @receiver for #GtkFileChooser methods should be
* delegated to @delegate, and that #GtkFileChooser signals emitted on @delegate
* should be forwarded to @receiver. Must be used in conjunction with
* _gtk_file_chooser_embed_delegate_iface_init().
**/
void
_gtk_file_chooser_embed_set_delegate (GtkFileChooserEmbed *receiver,
GtkFileChooserEmbed *delegate)
{
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (receiver));
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (delegate));
g_object_set_data (G_OBJECT (receiver), I_("gtk-file-chooser-embed-delegate"), delegate);
g_signal_connect (delegate, "response-requested",
G_CALLBACK (delegate_response_requested), receiver);
}
static gboolean
delegate_should_respond (GtkFileChooserEmbed *chooser_embed)
{
return _gtk_file_chooser_embed_should_respond (get_delegate (chooser_embed));
}
static void
delegate_initial_focus (GtkFileChooserEmbed *chooser_embed)
{
_gtk_file_chooser_embed_initial_focus (get_delegate (chooser_embed));
}
static void
delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
gpointer data)
{
g_signal_emit_by_name (data, "response-requested");
}
/* publicly callable functions */
GType
_gtk_file_chooser_embed_get_type (void)
{
static GType file_chooser_embed_type = 0;
if (!file_chooser_embed_type)
{
const GTypeInfo file_chooser_embed_info =
{
sizeof (GtkFileChooserEmbedIface), /* class_size */
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc)gtk_file_chooser_embed_class_init, /* class_init */
};
file_chooser_embed_type = g_type_register_static (G_TYPE_INTERFACE,
I_("GtkFileChooserEmbed"),
&file_chooser_embed_info, 0);
g_type_interface_add_prerequisite (file_chooser_embed_type, GTK_TYPE_WIDGET);
}
return file_chooser_embed_type;
}
static void
gtk_file_chooser_embed_class_init (gpointer g_iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
g_signal_new (I_("response-requested"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileChooserEmbedIface, response_requested),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
}
gboolean
_gtk_file_chooser_embed_should_respond (GtkFileChooserEmbed *chooser_embed)
{
g_return_val_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed), FALSE);
return GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->should_respond (chooser_embed);
}
void
_gtk_file_chooser_embed_initial_focus (GtkFileChooserEmbed *chooser_embed)
{
g_return_if_fail (GTK_IS_FILE_CHOOSER_EMBED (chooser_embed));
GTK_FILE_CHOOSER_EMBED_GET_IFACE (chooser_embed)->initial_focus (chooser_embed);
}
+61
View File
@@ -0,0 +1,61 @@
/* GTK - The GIMP Toolkit
* gtkfilechooserembed.h: Abstract sizing interface for file selector implementations
* Copyright (C) 2004, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FILE_CHOOSER_EMBED_H__
#define __GTK_FILE_CHOOSER_EMBED_H__
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_FILE_CHOOSER_EMBED (_gtk_file_chooser_embed_get_type ())
#define GTK_FILE_CHOOSER_EMBED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER_EMBED, GtkFileChooserEmbed))
#define GTK_IS_FILE_CHOOSER_EMBED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER_EMBED))
#define GTK_FILE_CHOOSER_EMBED_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_FILE_CHOOSER_EMBED, GtkFileChooserEmbedIface))
typedef struct _GtkFileChooserEmbed GtkFileChooserEmbed;
typedef struct _GtkFileChooserEmbedIface GtkFileChooserEmbedIface;
struct _GtkFileChooserEmbedIface
{
GTypeInterface base_iface;
/* Methods
*/
gboolean (*should_respond) (GtkFileChooserEmbed *chooser_embed);
void (*initial_focus) (GtkFileChooserEmbed *chooser_embed);
/* Signals
*/
void (*response_requested) (GtkFileChooserEmbed *chooser_embed);
};
GType _gtk_file_chooser_embed_get_type (void) G_GNUC_CONST;
gboolean _gtk_file_chooser_embed_should_respond (GtkFileChooserEmbed *chooser_embed);
void _gtk_file_chooser_embed_initial_focus (GtkFileChooserEmbed *chooser_embed);
void _gtk_file_chooser_embed_delegate_iface_init (GtkFileChooserEmbedIface *iface);
void _gtk_file_chooser_embed_set_delegate (GtkFileChooserEmbed *receiver,
GtkFileChooserEmbed *delegate);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_EMBED_H__ */
+1 -1
View File
@@ -25,7 +25,7 @@
#include "gtkcelllayout.h"
#include "gtkcellrenderertext.h"
#include "gtkentryprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilesystemmodel.h"
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtksizerequest.h"
+1
View File
@@ -19,6 +19,7 @@
#ifndef __GTK_FILE_CHOOSER_ENTRY_H__
#define __GTK_FILE_CHOOSER_ENTRY_H__
#include "gtkfilesystem.h"
#include "gtkfilechooser.h"
G_BEGIN_DECLS
+1 -1
View File
@@ -148,7 +148,7 @@ void
gtk_file_chooser_error_stack_set_custom_error (GtkFileChooserErrorStack *self,
const char *label_text)
{
GtkWidget *label = gtk_stack_get_child_by_name (GTK_STACK (self->stack), "custom");
GtkWidget *label = gtk_stack_get_child_by_name (GTK_STACK (self->stack), "cutsom");
gtk_label_set_text (GTK_LABEL (label), label_text);
+2
View File
@@ -28,6 +28,8 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserembed.h"
#include "gtkfilesystem.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
+2
View File
@@ -28,6 +28,8 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserembed.h"
#include "gtkfilesystem.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
+2
View File
@@ -28,6 +28,8 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserembed.h"
#include "gtkfilesystem.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
+2 -1
View File
@@ -34,6 +34,8 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserembed.h"
#include "gtkfilesystem.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
@@ -906,7 +908,6 @@ gtk_file_chooser_native_win32_show (GtkFileChooserNative *self)
filechooser_win32_thread_data_free (data);
return FALSE;
}
g_object_unref (filter);
}
self->current_filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (self));
}
+4
View File
@@ -20,6 +20,7 @@
#define __GTK_FILE_CHOOSER_PRIVATE_H__
#include "gtkfilechooser.h"
#include "gtkfilesystem.h"
#include "gtkfilesystemmodel.h"
#include "gtkliststore.h"
#include "gtkrecentmanager.h"
@@ -72,6 +73,7 @@ struct _GtkFileChooserIface
void (*select_all) (GtkFileChooser *chooser);
void (*unselect_all) (GtkFileChooser *chooser);
GListModel * (*get_files) (GtkFileChooser *chooser);
GtkFileSystem *(*get_file_system) (GtkFileChooser *chooser);
void (*add_filter) (GtkFileChooser *chooser,
GtkFileFilter *filter);
void (*remove_filter) (GtkFileChooser *chooser,
@@ -107,6 +109,8 @@ struct _GtkFileChooserIface
const char *id);
};
GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser);
void gtk_file_chooser_select_all (GtkFileChooser *chooser);
void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
gboolean gtk_file_chooser_select_file (GtkFileChooser *chooser,
+9 -73
View File
@@ -20,6 +20,7 @@
#include "config.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooser.h"
#include "gtkfilesystem.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
@@ -39,6 +40,7 @@ static void delegate_unselect_file (GtkFileChooser *choose
static void delegate_select_all (GtkFileChooser *chooser);
static void delegate_unselect_all (GtkFileChooser *chooser);
static GListModel * delegate_get_files (GtkFileChooser *chooser);
static GtkFileSystem *delegate_get_file_system (GtkFileChooser *chooser);
static void delegate_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
static void delegate_remove_filter (GtkFileChooser *chooser,
@@ -126,6 +128,7 @@ _gtk_file_chooser_delegate_iface_init (GtkFileChooserIface *iface)
iface->select_all = delegate_select_all;
iface->unselect_all = delegate_unselect_all;
iface->get_files = delegate_get_files;
iface->get_file_system = delegate_get_file_system;
iface->add_filter = delegate_add_filter;
iface->remove_filter = delegate_remove_filter;
iface->get_filters = delegate_get_filters;
@@ -212,6 +215,12 @@ delegate_get_files (GtkFileChooser *chooser)
return gtk_file_chooser_get_files (get_delegate (chooser));
}
static GtkFileSystem *
delegate_get_file_system (GtkFileChooser *chooser)
{
return _gtk_file_chooser_get_file_system (get_delegate (chooser));
}
static void
delegate_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter)
@@ -402,76 +411,3 @@ delegate_get_choice (GtkFileChooser *chooser,
{
return gtk_file_chooser_get_choice (get_delegate (chooser), id);
}
gboolean
_gtk_file_info_consider_as_directory (GFileInfo *info)
{
GFileType type = g_file_info_get_file_type (info);
return (type == G_FILE_TYPE_DIRECTORY ||
type == G_FILE_TYPE_MOUNTABLE ||
type == G_FILE_TYPE_SHORTCUT);
}
gboolean
_gtk_file_has_native_path (GFile *file)
{
char *local_file_path;
gboolean has_native_path;
/* Don't use g_file_is_native(), as we want to support FUSE paths if available */
local_file_path = g_file_get_path (file);
has_native_path = (local_file_path != NULL);
g_free (local_file_path);
return has_native_path;
}
gboolean
_gtk_file_consider_as_remote (GFile *file)
{
GFileInfo *info;
gboolean is_remote;
info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, NULL, NULL);
if (info)
{
is_remote = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
g_object_unref (info);
}
else
is_remote = FALSE;
return is_remote;
}
GIcon *
_gtk_file_info_get_icon (GFileInfo *info,
int icon_size,
int scale)
{
GIcon *icon;
GdkPixbuf *pixbuf;
const gchar *thumbnail_path;
thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
if (thumbnail_path)
{
pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
icon_size*scale, icon_size*scale,
NULL);
if (pixbuf != NULL)
return G_ICON (pixbuf);
}
icon = g_file_info_get_icon (info);
if (icon)
return g_object_ref (icon);
/* Use general fallback for all files without icon */
icon = g_themed_icon_new ("text-x-generic");
return icon;
}
-7
View File
@@ -49,13 +49,6 @@ GSettings *_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget);
gchar * _gtk_file_chooser_label_for_file (GFile *file);
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
gboolean _gtk_file_has_native_path (GFile *file);
gboolean _gtk_file_consider_as_remote (GFile *file);
GIcon * _gtk_file_info_get_icon (GFileInfo *info,
int icon_size,
int scale);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
+303 -168
View File
@@ -34,9 +34,11 @@
#include "gtkentry.h"
#include "gtkfilechooserprivate.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilechooserembed.h"
#include "gtkfilechooserentry.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooser.h"
#include "gtkfilesystem.h"
#include "gtkfilesystemmodel.h"
#include "gtkgrid.h"
#include "gtkicontheme.h"
@@ -87,7 +89,6 @@
#include "gtkshortcuttrigger.h"
#include "gtkshortcutaction.h"
#include "gtkshortcut.h"
#include "gtkstringlist.h"
#include <cairo-gobject.h>
@@ -117,6 +118,56 @@
/* 150 mseconds of delay */
#define LOCATION_CHANGED_TIMEOUT 150
/* Profiling stuff */
#undef PROFILE_FILE_CHOOSER
#ifdef PROFILE_FILE_CHOOSER
#ifndef F_OK
#define F_OK 0
#endif
#define PROFILE_INDENT 4
static int profile_indent;
static void
profile_add_indent (int indent)
{
profile_indent += indent;
if (profile_indent < 0)
g_error ("You screwed up your indentation");
}
static void
_gtk_file_chooser_profile_log (const char *func, int indent, const char *msg1, const char *msg2)
{
char *str;
if (indent < 0)
profile_add_indent (indent);
if (profile_indent == 0)
str = g_strdup_printf ("MARK: %s %s %s", func ? func : "", msg1 ? msg1 : "", msg2 ? msg2 : "");
else
str = g_strdup_printf ("MARK: %*c %s %s %s", profile_indent - 1, ' ', func ? func : "", msg1 ? msg1 : "", msg2 ? msg2 : "");
access (str, F_OK);
g_free (str);
if (indent > 0)
profile_add_indent (indent);
}
#define profile_start(x, y) _gtk_file_chooser_profile_log (G_STRFUNC, PROFILE_INDENT, x, y)
#define profile_end(x, y) _gtk_file_chooser_profile_log (G_STRFUNC, -PROFILE_INDENT, x, y)
#define profile_msg(x, y) _gtk_file_chooser_profile_log (NULL, 0, x, y)
#else
#define profile_start(x, y)
#define profile_end(x, y)
#define profile_msg(x, y)
#endif
enum {
PROP_SEARCH_MODE = 1,
PROP_SUBTITLE
@@ -176,6 +227,8 @@ struct _GtkFileChooserWidget
GtkFileChooserAction action;
GtkFileSystem *file_system;
GtkWidget *box;
GActionGroup *item_actions;
@@ -387,6 +440,7 @@ enum {
#define ICON_SIZE 16
static void gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface);
static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface);
static void gtk_file_chooser_widget_constructed (GObject *object);
static void gtk_file_chooser_widget_finalize (GObject *object);
@@ -426,6 +480,7 @@ static void gtk_file_chooser_widget_unselect_file (GtkF
static void gtk_file_chooser_widget_select_all (GtkFileChooser *chooser);
static void gtk_file_chooser_widget_unselect_all (GtkFileChooser *chooser);
static GListModel * gtk_file_chooser_widget_get_files (GtkFileChooser *chooser);
static GtkFileSystem *gtk_file_chooser_widget_get_file_system (GtkFileChooser *chooser);
static void gtk_file_chooser_widget_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
static void gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
@@ -439,6 +494,9 @@ static gboolean gtk_file_chooser_widget_remove_shortcut_folder (GtkFileCho
GError **error);
static GListModel * gtk_file_chooser_widget_get_shortcut_folders (GtkFileChooser *chooser);
static gboolean gtk_file_chooser_widget_should_respond (GtkFileChooserEmbed *chooser_embed);
static void gtk_file_chooser_widget_initial_focus (GtkFileChooserEmbed *chooser_embed);
static void gtk_file_chooser_widget_add_choice (GtkFileChooser *chooser,
const char *id,
const char *label,
@@ -542,7 +600,9 @@ static void set_show_hidden (GtkFileChooserWidget *impl,
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidget, gtk_file_chooser_widget, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER,
gtk_file_chooser_widget_iface_init))
gtk_file_chooser_widget_iface_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED,
gtk_file_chooser_embed_default_iface_init));
static void
gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface)
@@ -552,6 +612,7 @@ gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface)
iface->select_all = gtk_file_chooser_widget_select_all;
iface->unselect_all = gtk_file_chooser_widget_unselect_all;
iface->get_files = gtk_file_chooser_widget_get_files;
iface->get_file_system = gtk_file_chooser_widget_get_file_system;
iface->set_current_folder = gtk_file_chooser_widget_set_current_folder;
iface->get_current_folder = gtk_file_chooser_widget_get_current_folder;
iface->set_current_name = gtk_file_chooser_widget_set_current_name;
@@ -568,6 +629,13 @@ gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface)
iface->get_choice = gtk_file_chooser_widget_get_choice;
}
static void
gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface)
{
iface->should_respond = gtk_file_chooser_widget_should_respond;
iface->initial_focus = gtk_file_chooser_widget_initial_focus;
}
static void
pending_select_files_free (GtkFileChooserWidget *impl)
{
@@ -595,6 +663,8 @@ gtk_file_chooser_widget_finalize (GObject *object)
if (impl->location_changed_id > 0)
g_source_remove (impl->location_changed_id);
g_clear_object (&impl->file_system);
g_free (impl->browse_files_last_selected_name);
g_clear_object (&impl->filters);
@@ -849,18 +919,22 @@ struct FileExistsData
};
static void
name_exists_get_info_cb (GObject *source,
GAsyncResult *result,
name_exists_get_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
struct FileExistsData *data = user_data;
GFileInfo *info;
GtkFileChooserWidget *impl = data->impl;
g_clear_object (&impl->file_exists_get_info_cancellable);
if (cancellable != impl->file_exists_get_info_cancellable)
goto out;
impl->file_exists_get_info_cancellable = NULL;
if (g_cancellable_is_cancelled (cancellable))
goto out;
info = g_file_query_info_finish (file, result, NULL);
if (info != NULL)
{
gtk_widget_set_sensitive (data->button, FALSE);
@@ -874,10 +948,11 @@ name_exists_get_info_cb (GObject *source,
/* Don't clear the label here, it may contain a warning */
}
out:
g_object_unref (impl);
g_object_unref (data->file);
g_free (data);
g_clear_object (&info);
g_object_unref (cancellable);
}
static void
@@ -939,16 +1014,13 @@ check_valid_child_name (GtkFileChooserWidget *impl,
if (impl->file_exists_get_info_cancellable)
g_cancellable_cancel (impl->file_exists_get_info_cancellable);
g_clear_object (&impl->file_exists_get_info_cancellable);
impl->file_exists_get_info_cancellable = g_cancellable_new ();
g_file_query_info_async (file,
"standard::type",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->file_exists_get_info_cancellable,
name_exists_get_info_cb,
data);
impl->file_exists_get_info_cancellable =
_gtk_file_system_get_info (impl->file_system,
file,
"standard::type",
name_exists_get_info_cb,
data);
g_object_unref (file);
}
@@ -1622,25 +1694,27 @@ typedef struct
} FileListDragData;
static void
file_list_drag_data_received_get_info_cb (GObject *source,
GAsyncResult *result,
file_list_drag_data_received_get_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
FileListDragData *data = user_data;
GFileInfo *info;
GtkFileChooserWidget *impl = data->impl;
GtkFileChooser *chooser = GTK_FILE_CHOOSER (impl);
g_clear_object (&impl->file_list_drag_data_received_cancellable);
if (cancellable != impl->file_list_drag_data_received_cancellable)
goto out;
info = g_file_query_info_finish (file, result, NULL);
if (!info)
impl->file_list_drag_data_received_cancellable = NULL;
if (cancelled || error)
goto out;
if ((impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) &&
data->files->next == NULL && _gtk_file_info_consider_as_directory (info))
data->files->next == NULL && !error && _gtk_file_info_consider_as_directory (info))
change_folder_and_display_error (data->impl, data->files->data, FALSE);
else
{
@@ -1662,7 +1736,7 @@ out:
g_slist_free_full (data->files, g_object_unref);
g_free (data);
g_clear_object (&info);
g_object_unref (cancellable);
}
static gboolean
@@ -1683,16 +1757,12 @@ file_list_drag_drop_cb (GtkDropTarget *dest,
if (impl->file_list_drag_data_received_cancellable)
g_cancellable_cancel (impl->file_list_drag_data_received_cancellable);
g_clear_object (&impl->file_list_drag_data_received_cancellable);
impl->file_list_drag_data_received_cancellable = g_cancellable_new ();
g_file_query_info_async (data->files->data,
"standard::type",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->file_list_drag_data_received_cancellable,
file_list_drag_data_received_get_info_cb,
data);
impl->file_list_drag_data_received_cancellable =
_gtk_file_system_get_info (impl->file_system, data->files->data,
"standard::type",
file_list_drag_data_received_get_info_cb,
data);
return TRUE;
}
@@ -2519,9 +2589,15 @@ gtk_file_chooser_widget_constructed (GObject *object)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (object);
profile_start ("start", NULL);
G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->constructed (object);
g_assert (impl->file_system);
update_appearance (impl);
profile_end ("end", NULL);
}
static void
@@ -3068,18 +3144,10 @@ cancel_all_operations (GtkFileChooserWidget *impl)
{
pending_select_files_free (impl);
if (impl->file_list_drag_data_received_cancellable)
g_cancellable_cancel (impl->file_list_drag_data_received_cancellable);
g_clear_object (&impl->file_list_drag_data_received_cancellable);
if (impl->update_current_folder_cancellable)
g_cancellable_cancel (impl->update_current_folder_cancellable);
g_clear_object (&impl->update_current_folder_cancellable);
if (impl->should_respond_get_info_cancellable)
g_cancellable_cancel (impl->should_respond_get_info_cancellable);
g_clear_object (&impl->should_respond_get_info_cancellable);
if (impl->file_exists_get_info_cancellable)
g_cancellable_cancel (impl->file_exists_get_info_cancellable);
g_clear_object (&impl->file_exists_get_info_cancellable);
g_clear_pointer (&impl->file_list_drag_data_received_cancellable, g_cancellable_cancel);
g_clear_pointer (&impl->update_current_folder_cancellable, g_cancellable_cancel);
g_clear_pointer (&impl->should_respond_get_info_cancellable, g_cancellable_cancel);
g_clear_pointer (&impl->file_exists_get_info_cancellable, g_cancellable_cancel);
search_stop_searching (impl, TRUE);
}
@@ -3177,11 +3245,15 @@ gtk_file_chooser_widget_unroot (GtkWidget *widget)
static void
change_icon_theme (GtkFileChooserWidget *impl)
{
profile_start ("start", NULL);
/* the first cell in the first column is the icon column, and we have a fixed size there */
set_icon_cell_renderer_fixed_size (impl);
clear_model_cache (impl, MODEL_COL_ICON);
gtk_widget_queue_resize (impl->browse_files_tree_view);
profile_end ("end", NULL);
}
/* Callback used when a GtkSettings value changes */
@@ -3192,10 +3264,14 @@ settings_notify_cb (GObject *object,
{
const char *name;
profile_start ("start", NULL);
name = g_param_spec_get_name (pspec);
if (strcmp (name, "gtk-icon-theme-name") == 0)
change_icon_theme (impl);
profile_end ("end", NULL);
}
/* Installs a signal handler for GtkSettings so that we can monitor changes in
@@ -3206,14 +3282,21 @@ check_icon_theme (GtkFileChooserWidget *impl)
{
GtkSettings *settings;
profile_start ("start", NULL);
if (impl->settings_signal_id)
return;
{
profile_end ("end", NULL);
return;
}
settings = gtk_widget_get_settings (GTK_WIDGET (impl));
impl->settings_signal_id = g_signal_connect (settings, "notify",
G_CALLBACK (settings_notify_cb), impl);
change_icon_theme (impl);
profile_end ("end", NULL);
}
static void
@@ -3222,11 +3305,17 @@ gtk_file_chooser_widget_css_changed (GtkWidget *widget,
{
GtkFileChooserWidget *impl;
profile_start ("start", NULL);
impl = GTK_FILE_CHOOSER_WIDGET (widget);
profile_msg (" parent class css_changed start", NULL);
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->css_changed (widget, change);
profile_msg (" parent class css_changed end", NULL);
change_icon_theme (impl);
profile_end ("end", NULL);
}
static void
@@ -3462,6 +3551,8 @@ gtk_file_chooser_widget_map (GtkWidget *widget)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (widget);
profile_start ("start", NULL);
impl->browse_files_interaction_frozen = FALSE;
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->map (widget);
@@ -3488,6 +3579,8 @@ gtk_file_chooser_widget_map (GtkWidget *widget)
g_assert_not_reached ();
}
}
profile_end ("end", NULL);
}
/* GtkWidget::unmap method */
@@ -3787,16 +3880,22 @@ update_columns (GtkFileChooserWidget *impl,
static void
load_set_model (GtkFileChooserWidget *impl)
{
profile_start ("start", NULL);
g_assert (impl->browse_files_model != NULL);
profile_msg (" gtk_tree_view_set_model start", NULL);
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view),
GTK_TREE_MODEL (impl->browse_files_model));
update_columns (impl, FALSE, _("Modified"));
file_list_set_sort_column_ids (impl);
set_sort_column (impl);
profile_msg (" gtk_tree_view_set_model end", NULL);
impl->list_sort_ascending = TRUE;
g_set_object (&impl->model_for_search, impl->browse_files_model);
profile_end ("end", NULL);
}
/* Timeout callback used when the loading timer expires */
@@ -3805,6 +3904,8 @@ load_timeout_cb (gpointer data)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (data);
profile_start ("start", NULL);
g_assert (impl->load_state == LOAD_PRELOAD);
g_assert (impl->load_timeout_id != 0);
g_assert (impl->browse_files_model != NULL);
@@ -3814,6 +3915,8 @@ load_timeout_cb (gpointer data)
load_set_model (impl);
profile_end ("end", NULL);
return FALSE;
}
@@ -4066,6 +4169,8 @@ browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
GError *error,
GtkFileChooserWidget *impl)
{
profile_start ("start", NULL);
if (error)
{
set_busy_cursor (impl, FALSE);
@@ -4086,6 +4191,7 @@ browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
/* We can't g_assert_not_reached(), as something other than us may have
* initiated a folder reload. See #165556.
*/
profile_end ("end", NULL);
return;
}
@@ -4095,6 +4201,11 @@ browse_files_model_finished_loading_cb (GtkFileSystemModel *model,
pending_select_files_process (impl);
set_busy_cursor (impl, FALSE);
#ifdef PROFILE_FILE_CHOOSER
access ("MARK: *** FINISHED LOADING", F_OK);
#endif
profile_end ("end", NULL);
}
/* Callback used when file system model adds or updates a file.
@@ -4611,6 +4722,8 @@ set_list_model (GtkFileChooserWidget *impl,
_gtk_file_system_model_get_directory (impl->browse_files_model) == impl->current_folder)
return TRUE;
profile_start ("start", NULL);
stop_loading_and_clear_list_model (impl, TRUE);
set_busy_cursor (impl, TRUE);
@@ -4624,6 +4737,7 @@ set_list_model (GtkFileChooserWidget *impl,
_gtk_file_system_model_set_show_hidden (impl->browse_files_model, impl->show_hidden);
profile_msg (" set sort function", NULL);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_NAME, name_sort_func, impl, NULL);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_SIZE, size_sort_func, impl, NULL);
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->browse_files_model), MODEL_COL_TYPE, type_sort_func, impl, NULL);
@@ -4644,6 +4758,8 @@ set_list_model (GtkFileChooserWidget *impl,
_gtk_file_system_model_set_filter (impl->browse_files_model, impl->current_filter);
profile_end ("end", NULL);
return TRUE;
}
@@ -4843,19 +4959,24 @@ struct UpdateCurrentFolderData
};
static void
update_current_folder_mount_enclosing_volume_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
update_current_folder_mount_enclosing_volume_cb (GCancellable *cancellable,
GtkFileSystemVolume *volume,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
struct UpdateCurrentFolderData *data = user_data;
GtkFileChooserWidget *impl = data->impl;
GError *error = NULL;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
g_clear_object (&impl->update_current_folder_cancellable);
if (cancellable != impl->update_current_folder_cancellable)
goto out;
impl->update_current_folder_cancellable = NULL;
set_busy_cursor (impl, FALSE);
g_file_mount_enclosing_volume_finish (file, result, &error);
if (cancelled)
goto out;
if (error)
{
error_changing_folder_dialog (data->impl, data->file, g_error_copy (error));
@@ -4870,26 +4991,30 @@ out:
g_object_unref (data->file);
g_free (data);
g_clear_error (&error);
g_object_unref (cancellable);
}
static void
update_current_folder_get_info_cb (GObject *source,
GAsyncResult *result,
update_current_folder_get_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct UpdateCurrentFolderData *data = user_data;
GFileInfo *info;
GError *error = NULL;
GtkFileChooserWidget *impl = data->impl;
g_clear_object (&impl->update_current_folder_cancellable);
if (cancellable != impl->update_current_folder_cancellable)
goto out;
impl->update_current_folder_cancellable = NULL;
impl->reload_state = RELOAD_EMPTY;
set_busy_cursor (impl, FALSE);
info = g_file_query_info_finish (file, result, &error);
if (cancelled)
goto out;
if (error)
{
GFile *parent_file;
@@ -4899,20 +5024,18 @@ update_current_folder_get_info_cb (GObject *source,
GMountOperation *mount_operation;
GtkWidget *toplevel;
g_clear_error (&error);
g_object_unref (cancellable);
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (impl)));
mount_operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
set_busy_cursor (impl, TRUE);
impl->update_current_folder_cancellable = g_cancellable_new ();
g_file_mount_enclosing_volume (data->file,
G_MOUNT_MOUNT_NONE,
mount_operation,
impl->update_current_folder_cancellable,
update_current_folder_mount_enclosing_volume_cb,
data);
impl->update_current_folder_cancellable =
_gtk_file_system_mount_enclosing_volume (impl->file_system, data->file,
mount_operation,
update_current_folder_mount_enclosing_volume_cb,
data);
return;
}
@@ -4931,19 +5054,16 @@ update_current_folder_get_info_cb (GObject *source,
g_object_unref (data->file);
data->file = parent_file;
g_clear_error (&error);
g_object_unref (cancellable);
/* restart the update current folder operation */
impl->reload_state = RELOAD_HAS_FOLDER;
impl->update_current_folder_cancellable = g_cancellable_new ();
g_file_query_info_async (data->file,
"standard::type",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->update_current_folder_cancellable,
update_current_folder_get_info_cb,
data);
impl->update_current_folder_cancellable =
_gtk_file_system_get_info (impl->file_system, data->file,
"standard::type",
update_current_folder_get_info_cb,
data);
set_busy_cursor (impl, TRUE);
@@ -4959,7 +5079,6 @@ update_current_folder_get_info_cb (GObject *source,
else
g_error_free (data->original_error);
g_clear_error (&error);
g_object_unref (data->original_file);
goto out;
@@ -5024,7 +5143,7 @@ out:
g_object_unref (data->file);
g_free (data);
g_clear_object (&info);
g_object_unref (cancellable);
}
static gboolean
@@ -5037,13 +5156,14 @@ gtk_file_chooser_widget_update_current_folder (GtkFileChooser *chooser,
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
struct UpdateCurrentFolderData *data;
profile_start ("start", NULL);
g_object_ref (file);
operation_mode_set (impl, OPERATION_MODE_BROWSE);
if (impl->update_current_folder_cancellable)
g_cancellable_cancel (impl->update_current_folder_cancellable);
g_clear_object (&impl->update_current_folder_cancellable);
/* Test validity of path here. */
data = g_new0 (struct UpdateCurrentFolderData, 1);
@@ -5054,18 +5174,16 @@ gtk_file_chooser_widget_update_current_folder (GtkFileChooser *chooser,
impl->reload_state = RELOAD_HAS_FOLDER;
impl->update_current_folder_cancellable = g_cancellable_new ();
g_file_query_info_async (file,
"standard::type",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->update_current_folder_cancellable,
update_current_folder_get_info_cb,
data);
impl->update_current_folder_cancellable =
_gtk_file_system_get_info (impl->file_system, file,
"standard::type",
update_current_folder_get_info_cb,
data);
set_busy_cursor (impl, TRUE);
g_object_unref (file);
profile_end ("end", NULL);
return TRUE;
}
@@ -5483,6 +5601,14 @@ gtk_file_chooser_widget_get_files (GtkFileChooser *chooser)
return G_LIST_MODEL (info.result);
}
static GtkFileSystem *
gtk_file_chooser_widget_get_file_system (GtkFileChooser *chooser)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
return impl->file_system;
}
/* Shows or hides the filter widgets */
static void
show_filters (GtkFileChooserWidget *impl,
@@ -5700,7 +5826,6 @@ add_custom_button_to_dialog (GtkDialog *dialog,
static void
request_response_and_add_to_recent_list (GtkFileChooserWidget *impl)
{
gtk_widget_activate_action (GTK_WIDGET (impl), "response.activate", NULL);
g_signal_emit_by_name (impl, "response-requested");
add_selection_to_recent_list (impl);
}
@@ -5767,18 +5892,23 @@ struct GetDisplayNameData
};
static void
confirmation_confirm_get_info_cb (GObject *source,
GAsyncResult *result,
confirmation_confirm_get_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct GetDisplayNameData *data = user_data;
GFileInfo *info;
g_clear_object (&data->impl->should_respond_get_info_cancellable);
if (cancellable != data->impl->should_respond_get_info_cancellable)
goto out;
info = g_file_query_info_finish (file, result, NULL);
if (!info)
data->impl->should_respond_get_info_cancellable = NULL;
if (cancelled)
goto out;
if (error)
goto out;
confirm_dialog_should_accept_filename (data->impl, data->file_part,
@@ -5791,7 +5921,7 @@ out:
g_free (data->file_part);
g_free (data);
g_clear_object (&info);
g_object_unref (cancellable);
}
/* Does overwrite confirmation if appropriate, and returns whether the dialog
@@ -5812,38 +5942,38 @@ should_respond_after_confirm_overwrite (GtkFileChooserWidget *impl,
if (impl->should_respond_get_info_cancellable)
g_cancellable_cancel (impl->should_respond_get_info_cancellable);
g_clear_object (&impl->should_respond_get_info_cancellable);
impl->should_respond_get_info_cancellable = g_cancellable_new ();
g_file_query_info_async (parent_file,
"standard::display-name",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->should_respond_get_info_cancellable,
confirmation_confirm_get_info_cb,
data);
impl->should_respond_get_info_cancellable =
_gtk_file_system_get_info (impl->file_system, parent_file,
"standard::display-name",
confirmation_confirm_get_info_cb,
data);
set_busy_cursor (data->impl, TRUE);
return FALSE;
}
static void
name_entry_get_parent_info_cb (GObject *source,
GAsyncResult *result,
name_entry_get_parent_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
struct FileExistsData *data = user_data;
GFileInfo *info;
gboolean parent_is_folder = FALSE;
gboolean parent_is_accessible = FALSE;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct FileExistsData *data = user_data;
GtkFileChooserWidget *impl = data->impl;
GError *error = NULL;
g_clear_object (&impl->should_respond_get_info_cancellable);
if (cancellable != impl->should_respond_get_info_cancellable)
goto out;
impl->should_respond_get_info_cancellable = NULL;
set_busy_cursor (impl, FALSE);
info = g_file_query_info_finish (file, result, &error);
if (cancelled)
goto out;
if (info)
{
parent_is_folder = _gtk_file_info_consider_as_directory (info);
@@ -5929,35 +6059,39 @@ name_entry_get_parent_info_cb (GObject *source,
error_changing_folder_dialog (impl, data->parent_file, error_copy);
}
out:
g_object_unref (data->impl);
g_object_unref (data->file);
g_object_unref (data->parent_file);
g_free (data);
g_clear_error (&error);
g_clear_object (&info);
g_object_unref (cancellable);
}
static void
file_exists_get_info_cb (GObject *source,
GAsyncResult *result,
file_exists_get_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
GFile *file = G_FILE (source);
struct FileExistsData *data = user_data;
GFileInfo *info;
gboolean data_ownership_taken = FALSE;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
gboolean file_exists;
gboolean is_folder;
gboolean needs_parent_check = FALSE;
struct FileExistsData *data = user_data;
GtkFileChooserWidget *impl = data->impl;
GError *error = NULL;
g_clear_object (&impl->file_exists_get_info_cancellable);
if (cancellable != impl->file_exists_get_info_cancellable)
goto out;
impl->file_exists_get_info_cancellable = NULL;
set_busy_cursor (impl, FALSE);
info = g_file_query_info_finish (file, result, &error);
if (cancelled)
goto out;
file_exists = (info != NULL);
is_folder = (file_exists && _gtk_file_info_consider_as_directory (info));
@@ -6014,19 +6148,17 @@ file_exists_get_info_cb (GObject *source,
if (impl->should_respond_get_info_cancellable)
g_cancellable_cancel (impl->should_respond_get_info_cancellable);
g_clear_object (&impl->should_respond_get_info_cancellable);
impl->should_respond_get_info_cancellable = g_cancellable_new ();
g_file_query_info_async (data->parent_file,
"standard::type,access::can-execute",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->should_respond_get_info_cancellable,
name_entry_get_parent_info_cb,
data);
impl->should_respond_get_info_cancellable =
_gtk_file_system_get_info (impl->file_system,
data->parent_file,
"standard::type,access::can-execute",
name_entry_get_parent_info_cb,
data);
set_busy_cursor (impl, TRUE);
}
out:
if (!data_ownership_taken)
{
g_object_unref (impl);
@@ -6035,8 +6167,7 @@ file_exists_get_info_cb (GObject *source,
g_free (data);
}
g_clear_error (&error);
g_clear_object (&info);
g_object_unref (cancellable);
}
static void
@@ -6104,9 +6235,10 @@ add_selection_to_recent_list (GtkFileChooserWidget *impl)
g_object_unref (files);
}
gboolean
gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *impl)
static gboolean
gtk_file_chooser_widget_should_respond (GtkFileChooserEmbed *chooser_embed)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser_embed);
GtkWidget *toplevel;
GtkWidget *current_focus;
gboolean retval;
@@ -6302,16 +6434,12 @@ gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *impl)
if (impl->file_exists_get_info_cancellable)
g_cancellable_cancel (impl->file_exists_get_info_cancellable);
g_clear_object (&impl->file_exists_get_info_cancellable);
impl->file_exists_get_info_cancellable = g_cancellable_new ();
g_file_query_info_async (file,
"standard::type",
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
impl->file_exists_get_info_cancellable,
file_exists_get_info_cb,
data);
impl->file_exists_get_info_cancellable =
_gtk_file_system_get_info (impl->file_system, file,
"standard::type",
file_exists_get_info_cb,
data);
set_busy_cursor (impl, TRUE);
}
@@ -6352,9 +6480,11 @@ gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *impl)
return retval;
}
void
gtk_file_chooser_widget_initial_focus (GtkFileChooserWidget *impl)
/* Implementation for GtkFileChooserEmbed::initial_focus() */
static void
gtk_file_chooser_widget_initial_focus (GtkFileChooserEmbed *chooser_embed)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser_embed);
GtkWidget *widget;
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
@@ -7733,6 +7863,8 @@ post_process_ui (GtkFileChooserWidget *impl)
file_list_set_sort_column_ids (impl);
update_cell_renderer_attributes (impl);
/* Set the GtkPathBar file system backend */
_gtk_path_bar_set_file_system (GTK_PATH_BAR (impl->browse_path_bar), impl->file_system);
file = g_file_new_for_path ("/");
_gtk_path_bar_set_file (GTK_PATH_BAR (impl->browse_path_bar), file, FALSE);
g_object_unref (file);
@@ -7827,6 +7959,11 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
{
GtkExpression *expression;
profile_start ("start", NULL);
#ifdef PROFILE_FILE_CHOOSER
access ("MARK: *** CREATE FILE CHOOSER", F_OK);
#endif
impl->select_multiple = FALSE;
impl->show_hidden = FALSE;
impl->show_size_column = TRUE;
@@ -7857,6 +7994,7 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
g_signal_connect (impl, "notify::display,", G_CALLBACK (display_changed_cb), impl);
check_icon_theme (impl);
impl->file_system = _gtk_file_system_new ();
impl->bookmarks_manager = _gtk_bookmarks_manager_new (NULL, NULL);
impl->filters = g_list_store_new (GTK_TYPE_FILE_FILTER);
@@ -7873,6 +8011,8 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
* which cannot be done with GtkBuilder
*/
post_process_ui (impl);
profile_end ("end", NULL);
}
/**
@@ -7919,7 +8059,6 @@ gtk_file_chooser_widget_add_choice (GtkFileChooser *chooser,
{
GtkWidget *box;
GtkWidget *combo;
GListModel *model;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_append (GTK_BOX (box), gtk_label_new (label));
@@ -7928,9 +8067,8 @@ gtk_file_chooser_widget_add_choice (GtkFileChooser *chooser,
g_hash_table_insert (impl->choices, g_strdup (id), combo);
gtk_box_append (GTK_BOX (box), combo);
model = G_LIST_MODEL (gtk_string_list_new ((const char * const *)options));
gtk_drop_down_set_model (GTK_DROP_DOWN (combo), model);
g_object_unref (model);
gtk_drop_down_set_from_strings (GTK_DROP_DOWN (combo), option_labels);
g_object_set_data_full (G_OBJECT (combo), "options", g_strdupv ((char **)options), (GDestroyNotify)g_strfreev);
widget = box;
}
@@ -7985,15 +8123,11 @@ gtk_file_chooser_widget_set_choice (GtkFileChooser *chooser,
if (GTK_IS_DROP_DOWN (widget))
{
guint i, n;
GListModel *model;
model = gtk_drop_down_get_model (GTK_DROP_DOWN (widget));
n = g_list_model_get_n_items (model);
for (i = 0; i < n; i++)
guint i;
const char **options = (const char **)g_object_get_data (G_OBJECT (widget), "options");
for (i = 0; options[i]; i++)
{
const char *string = gtk_string_list_get_string (GTK_STRING_LIST (model), i);
if (strcmp (string, option) == 0)
if (strcmp (options[i], option) == 0)
{
gtk_drop_down_set_selected (GTK_DROP_DOWN (widget), i);
break;
@@ -8017,10 +8151,11 @@ gtk_file_chooser_widget_get_choice (GtkFileChooser *chooser,
widget = (GtkWidget *)g_hash_table_lookup (impl->choices, id);
if (GTK_IS_DROP_DOWN (widget))
{
gpointer selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (widget));
if (GTK_IS_STRING_OBJECT (selected))
return gtk_string_object_get_string (GTK_STRING_OBJECT (selected));
return NULL;
const char **options = (const char **)g_object_get_data (G_OBJECT (widget), "options");
guint selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (widget));
if (selected == GTK_INVALID_LIST_POSITION)
return NULL;
return options[selected];
}
else if (GTK_IS_TOGGLE_BUTTON (widget))
-6
View File
@@ -30,12 +30,6 @@ void
gtk_file_chooser_widget_set_save_entry (GtkFileChooserWidget *chooser,
GtkWidget *entry);
gboolean
gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *chooser);
void
gtk_file_chooser_widget_initial_focus (GtkFileChooserWidget *chooser);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__ */
+823
View File
@@ -0,0 +1,823 @@
/* GTK - The GIMP Toolkit
* gtkfilesystem.c: Filesystem abstraction functions.
* Copyright (C) 2003, Red Hat, Inc.
* Copyright (C) 2007-2008 Carlos Garnacho
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Carlos Garnacho <carlos@imendio.com>
*/
#include "config.h"
#include "gtkfilesystem.h"
#include <string.h>
#include <glib/gi18n-lib.h>
#include "gtkfilechooser.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkstylecontextprivate.h"
/* #define DEBUG_MODE */
#ifdef DEBUG_MODE
#define DEBUG(x) g_debug (x);
#else
#define DEBUG(x)
#endif
#define FILES_PER_QUERY 100
/* The pointers we return for a GtkFileSystemVolume are opaque tokens; they are
* really pointers to GDrive, GVolume or GMount objects. We need an extra
* token for the fake File System volume. So, well return a pointer to
* this particular string.
*/
static const gchar *root_volume_token = N_("File System");
#define IS_ROOT_VOLUME(volume) ((gpointer) (volume) == (gpointer) root_volume_token)
enum {
PROP_0,
PROP_FILE,
PROP_ENUMERATOR,
PROP_ATTRIBUTES
};
enum {
VOLUMES_CHANGED,
FS_LAST_SIGNAL
};
enum {
FILES_ADDED,
FILES_REMOVED,
FILES_CHANGED,
FINISHED_LOADING,
DELETED,
FOLDER_LAST_SIGNAL
};
static guint fs_signals [FS_LAST_SIGNAL] = { 0, };
typedef struct AsyncFuncData AsyncFuncData;
struct GtkFileSystemPrivate
{
GVolumeMonitor *volume_monitor;
/* This list contains elements that can be
* of type GDrive, GVolume and GMount
*/
GSList *volumes;
};
struct AsyncFuncData
{
GtkFileSystem *file_system;
GFile *file;
GCancellable *cancellable;
gpointer callback;
gpointer data;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkFileSystem, _gtk_file_system, G_TYPE_OBJECT)
/* GtkFileSystem methods */
static void
volumes_changed (GVolumeMonitor *volume_monitor,
gpointer volume,
gpointer user_data)
{
GtkFileSystem *file_system = user_data;
g_signal_emit (file_system, fs_signals[VOLUMES_CHANGED], 0, volume);
}
static void
gtk_file_system_dispose (GObject *object)
{
GtkFileSystem *file_system = GTK_FILE_SYSTEM (object);
GtkFileSystemPrivate *priv = file_system->priv;
DEBUG ("dispose");
if (priv->volumes)
{
g_slist_free_full (priv->volumes, g_object_unref);
priv->volumes = NULL;
}
if (priv->volume_monitor)
{
g_signal_handlers_disconnect_by_func (priv->volume_monitor, volumes_changed, object);
g_object_unref (priv->volume_monitor);
priv->volume_monitor = NULL;
}
G_OBJECT_CLASS (_gtk_file_system_parent_class)->dispose (object);
}
static void
_gtk_file_system_class_init (GtkFileSystemClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = gtk_file_system_dispose;
fs_signals[VOLUMES_CHANGED] =
g_signal_new (I_("volumes-changed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileSystemClass, volumes_changed),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
}
static gboolean
mount_referenced_by_volume_activation_root (GList *volumes, GMount *mount)
{
GList *l;
GFile *mount_root;
gboolean ret;
ret = FALSE;
mount_root = g_mount_get_root (mount);
for (l = volumes; l != NULL; l = l->next)
{
GVolume *volume = G_VOLUME (l->data);
GFile *volume_activation_root;
volume_activation_root = g_volume_get_activation_root (volume);
if (volume_activation_root != NULL)
{
if (g_file_has_prefix (volume_activation_root, mount_root))
{
ret = TRUE;
g_object_unref (volume_activation_root);
break;
}
g_object_unref (volume_activation_root);
}
}
g_object_unref (mount_root);
return ret;
}
static void
get_volumes_list (GtkFileSystem *file_system)
{
GtkFileSystemPrivate *priv = file_system->priv;
GList *l, *ll;
GList *drives;
GList *volumes;
GList *mounts;
GDrive *drive;
GVolume *volume;
GMount *mount;
if (priv->volumes)
{
g_slist_free_full (priv->volumes, g_object_unref);
priv->volumes = NULL;
}
/* first go through all connected drives */
drives = g_volume_monitor_get_connected_drives (priv->volume_monitor);
for (l = drives; l != NULL; l = l->next)
{
drive = l->data;
volumes = g_drive_get_volumes (drive);
if (volumes)
{
for (ll = volumes; ll != NULL; ll = ll->next)
{
volume = ll->data;
mount = g_volume_get_mount (volume);
if (mount)
{
/* Show mounted volume */
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
g_object_unref (mount);
}
else
{
/* Do show the unmounted volumes in the sidebar;
* this is so the user can mount it (in case automounting
* is off).
*
* Also, even if automounting is enabled, this gives a visual
* cue that the user should remember to yank out the media if
* he just unmounted it.
*/
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (volume));
}
g_object_unref (volume);
}
g_list_free (volumes);
}
else if (g_drive_is_media_removable (drive) && !g_drive_is_media_check_automatic (drive))
{
/* If the drive has no mountable volumes and we cannot detect media change.. we
* display the drive in the sidebar so the user can manually poll the drive by
* right clicking and selecting "Rescan..."
*
* This is mainly for drives like floppies where media detection doesn't
* work.. but it's also for human beings who like to turn off media detection
* in the OS to save battery juice.
*/
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (drive));
}
g_object_unref (drive);
}
g_list_free (drives);
/* add all volumes that is not associated with a drive */
volumes = g_volume_monitor_get_volumes (priv->volume_monitor);
for (l = volumes; l != NULL; l = l->next)
{
volume = l->data;
drive = g_volume_get_drive (volume);
if (drive)
{
g_object_unref (drive);
continue;
}
mount = g_volume_get_mount (volume);
if (mount)
{
/* show this mount */
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
g_object_unref (mount);
}
else
{
/* see comment above in why we add an icon for a volume */
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (volume));
}
g_object_unref (volume);
}
/* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */
mounts = g_volume_monitor_get_mounts (priv->volume_monitor);
for (l = mounts; l != NULL; l = l->next)
{
mount = l->data;
volume = g_mount_get_volume (mount);
if (volume)
{
g_object_unref (volume);
continue;
}
/* if there's exists one or more volumes with an activation root inside the mount,
* don't display the mount
*/
if (mount_referenced_by_volume_activation_root (volumes, mount))
{
g_object_unref (mount);
continue;
}
/* show this mount */
priv->volumes = g_slist_prepend (priv->volumes, g_object_ref (mount));
g_object_unref (mount);
}
g_list_free (volumes);
g_list_free (mounts);
}
static void
_gtk_file_system_init (GtkFileSystem *file_system)
{
GtkFileSystemPrivate *priv;
DEBUG ("init");
file_system->priv = priv = _gtk_file_system_get_instance_private (file_system);
/* Volumes */
priv->volume_monitor = g_volume_monitor_get ();
g_signal_connect (priv->volume_monitor, "mount-added",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "mount-removed",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "mount-changed",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "volume-added",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "volume-removed",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "volume-changed",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "drive-connected",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "drive-disconnected",
G_CALLBACK (volumes_changed), file_system);
g_signal_connect (priv->volume_monitor, "drive-changed",
G_CALLBACK (volumes_changed), file_system);
}
/* GtkFileSystem public methods */
GtkFileSystem *
_gtk_file_system_new (void)
{
return g_object_new (GTK_TYPE_FILE_SYSTEM, NULL);
}
GSList *
_gtk_file_system_list_volumes (GtkFileSystem *file_system)
{
GtkFileSystemPrivate *priv = file_system->priv;
GSList *list;
DEBUG ("list_volumes");
get_volumes_list (file_system);
list = g_slist_copy (priv->volumes);
#ifndef G_OS_WIN32
/* Prepend root volume */
list = g_slist_prepend (list, (gpointer) root_volume_token);
#endif
return list;
}
static void
free_async_data (AsyncFuncData *async_data)
{
g_object_unref (async_data->file_system);
g_object_unref (async_data->file);
g_object_unref (async_data->cancellable);
g_free (async_data);
}
static void
query_info_callback (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
AsyncFuncData *async_data;
GError *error = NULL;
GFileInfo *file_info;
GFile *file;
DEBUG ("query_info_callback");
file = G_FILE (source_object);
async_data = (AsyncFuncData *) user_data;
file_info = g_file_query_info_finish (file, result, &error);
if (async_data->callback)
{
((GtkFileSystemGetInfoCallback) async_data->callback) (async_data->cancellable,
file_info, error, async_data->data);
}
if (file_info)
g_object_unref (file_info);
if (error)
g_error_free (error);
free_async_data (async_data);
}
GCancellable *
_gtk_file_system_get_info (GtkFileSystem *file_system,
GFile *file,
const gchar *attributes,
GtkFileSystemGetInfoCallback callback,
gpointer data)
{
GCancellable *cancellable;
AsyncFuncData *async_data;
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
cancellable = g_cancellable_new ();
async_data = g_new0 (AsyncFuncData, 1);
async_data->file_system = g_object_ref (file_system);
async_data->file = g_object_ref (file);
async_data->cancellable = g_object_ref (cancellable);
async_data->callback = callback;
async_data->data = data;
g_file_query_info_async (file,
attributes,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
cancellable,
query_info_callback,
async_data);
return cancellable;
}
static void
drive_poll_for_media_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
AsyncFuncData *async_data;
GError *error = NULL;
g_drive_poll_for_media_finish (G_DRIVE (source_object), result, &error);
async_data = (AsyncFuncData *) user_data;
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable,
(GtkFileSystemVolume *) source_object,
error, async_data->data);
if (error)
g_error_free (error);
}
static void
volume_mount_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
AsyncFuncData *async_data;
GError *error = NULL;
g_volume_mount_finish (G_VOLUME (source_object), result, &error);
async_data = (AsyncFuncData *) user_data;
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable,
(GtkFileSystemVolume *) source_object,
error, async_data->data);
if (error)
g_error_free (error);
}
GCancellable *
_gtk_file_system_mount_volume (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GMountOperation *mount_operation,
GtkFileSystemVolumeMountCallback callback,
gpointer data)
{
GCancellable *cancellable;
AsyncFuncData *async_data;
gboolean handled = FALSE;
DEBUG ("volume_mount");
cancellable = g_cancellable_new ();
async_data = g_new0 (AsyncFuncData, 1);
async_data->file_system = g_object_ref (file_system);
async_data->cancellable = g_object_ref (cancellable);
async_data->callback = callback;
async_data->data = data;
if (G_IS_DRIVE (volume))
{
/* this path happens for drives that are not polled by the OS and where the last media
* check indicated that no media was available. So the thing to do here is to
* invoke poll_for_media() on the drive
*/
g_drive_poll_for_media (G_DRIVE (volume), cancellable, drive_poll_for_media_cb, async_data);
handled = TRUE;
}
else if (G_IS_VOLUME (volume))
{
g_volume_mount (G_VOLUME (volume), G_MOUNT_MOUNT_NONE, mount_operation, cancellable, volume_mount_cb, async_data);
handled = TRUE;
}
if (!handled)
free_async_data (async_data);
return cancellable;
}
static void
enclosing_volume_mount_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
GtkFileSystemVolume *volume;
AsyncFuncData *async_data;
GError *error = NULL;
async_data = (AsyncFuncData *) user_data;
g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error);
volume = _gtk_file_system_get_volume_for_file (async_data->file_system, G_FILE (source_object));
/* Silently drop G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible mounts. */
/* Better than doing query_info with additional I/O every time. */
if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED))
g_clear_error (&error);
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable, volume,
error, async_data->data);
if (error)
g_error_free (error);
_gtk_file_system_volume_unref (volume);
}
GCancellable *
_gtk_file_system_mount_enclosing_volume (GtkFileSystem *file_system,
GFile *file,
GMountOperation *mount_operation,
GtkFileSystemVolumeMountCallback callback,
gpointer data)
{
GCancellable *cancellable;
AsyncFuncData *async_data;
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
DEBUG ("mount_enclosing_volume");
cancellable = g_cancellable_new ();
async_data = g_new0 (AsyncFuncData, 1);
async_data->file_system = g_object_ref (file_system);
async_data->file = g_object_ref (file);
async_data->cancellable = g_object_ref (cancellable);
async_data->callback = callback;
async_data->data = data;
g_file_mount_enclosing_volume (file,
G_MOUNT_MOUNT_NONE,
mount_operation,
cancellable,
enclosing_volume_mount_cb,
async_data);
return cancellable;
}
GtkFileSystemVolume *
_gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
GFile *file)
{
GMount *mount;
DEBUG ("get_volume_for_file");
mount = g_file_find_enclosing_mount (file, NULL, NULL);
if (!mount && g_file_is_native (file))
return (GtkFileSystemVolume *) root_volume_token;
return (GtkFileSystemVolume *) mount;
}
/* GtkFileSystemVolume public methods */
gchar *
_gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume)
{
DEBUG ("volume_get_display_name");
if (IS_ROOT_VOLUME (volume))
return g_strdup (_(root_volume_token));
if (G_IS_DRIVE (volume))
return g_drive_get_name (G_DRIVE (volume));
else if (G_IS_MOUNT (volume))
return g_mount_get_name (G_MOUNT (volume));
else if (G_IS_VOLUME (volume))
return g_volume_get_name (G_VOLUME (volume));
return NULL;
}
gboolean
_gtk_file_system_volume_is_mounted (GtkFileSystemVolume *volume)
{
gboolean mounted;
DEBUG ("volume_is_mounted");
if (IS_ROOT_VOLUME (volume))
return TRUE;
mounted = FALSE;
if (G_IS_MOUNT (volume))
mounted = TRUE;
else if (G_IS_VOLUME (volume))
{
GMount *mount;
mount = g_volume_get_mount (G_VOLUME (volume));
if (mount)
{
mounted = TRUE;
g_object_unref (mount);
}
}
return mounted;
}
GFile *
_gtk_file_system_volume_get_root (GtkFileSystemVolume *volume)
{
GFile *file = NULL;
DEBUG ("volume_get_base");
if (IS_ROOT_VOLUME (volume))
return g_file_new_for_uri ("file:///");
if (G_IS_MOUNT (volume))
file = g_mount_get_root (G_MOUNT (volume));
else if (G_IS_VOLUME (volume))
{
GMount *mount;
mount = g_volume_get_mount (G_VOLUME (volume));
if (mount)
{
file = g_mount_get_root (mount);
g_object_unref (mount);
}
}
return file;
}
GIcon *
_gtk_file_system_volume_get_icon (GtkFileSystemVolume *volume)
{
GIcon *icon = NULL;
if (IS_ROOT_VOLUME (volume))
icon = g_themed_icon_new ("drive-harddisk");
else if (G_IS_DRIVE (volume))
icon = g_drive_get_icon (G_DRIVE (volume));
else if (G_IS_VOLUME (volume))
icon = g_volume_get_icon (G_VOLUME (volume));
else if (G_IS_MOUNT (volume))
icon = g_mount_get_icon (G_MOUNT (volume));
return icon;
}
GIcon *
_gtk_file_system_volume_get_symbolic_icon (GtkFileSystemVolume *volume)
{
if (IS_ROOT_VOLUME (volume))
return g_themed_icon_new ("drive-harddisk-symbolic");
else if (G_IS_DRIVE (volume))
return g_drive_get_symbolic_icon (G_DRIVE (volume));
else if (G_IS_VOLUME (volume))
return g_volume_get_symbolic_icon (G_VOLUME (volume));
else if (G_IS_MOUNT (volume))
return g_mount_get_symbolic_icon (G_MOUNT (volume));
else
return NULL;
}
GtkFileSystemVolume *
_gtk_file_system_volume_ref (GtkFileSystemVolume *volume)
{
if (IS_ROOT_VOLUME (volume))
return volume;
if (G_IS_MOUNT (volume) ||
G_IS_VOLUME (volume) ||
G_IS_DRIVE (volume))
g_object_ref (volume);
return volume;
}
void
_gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
{
/* Root volume doesn't need to be freed */
if (IS_ROOT_VOLUME (volume))
return;
if (G_IS_MOUNT (volume) ||
G_IS_VOLUME (volume) ||
G_IS_DRIVE (volume))
g_object_unref (volume);
}
/* GFileInfo helper functions */
GIcon *
_gtk_file_info_get_icon (GFileInfo *info,
int icon_size,
int scale)
{
GIcon *icon;
GdkPixbuf *pixbuf;
const gchar *thumbnail_path;
thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
if (thumbnail_path)
{
pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
icon_size*scale, icon_size*scale,
NULL);
if (pixbuf != NULL)
return G_ICON (pixbuf);
}
icon = g_file_info_get_icon (info);
if (icon)
return g_object_ref (icon);
/* Use general fallback for all files without icon */
icon = g_themed_icon_new ("text-x-generic");
return icon;
}
gboolean
_gtk_file_info_consider_as_directory (GFileInfo *info)
{
GFileType type = g_file_info_get_file_type (info);
return (type == G_FILE_TYPE_DIRECTORY ||
type == G_FILE_TYPE_MOUNTABLE ||
type == G_FILE_TYPE_SHORTCUT);
}
gboolean
_gtk_file_has_native_path (GFile *file)
{
char *local_file_path;
gboolean has_native_path;
/* Don't use g_file_is_native(), as we want to support FUSE paths if available */
local_file_path = g_file_get_path (file);
has_native_path = (local_file_path != NULL);
g_free (local_file_path);
return has_native_path;
}
gboolean
_gtk_file_consider_as_remote (GFile *file)
{
GFileInfo *info;
gboolean is_remote;
info = g_file_query_filesystem_info (file, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, NULL, NULL);
if (info)
{
is_remote = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE);
g_object_unref (info);
}
else
is_remote = FALSE;
return is_remote;
}
+116
View File
@@ -0,0 +1,116 @@
/* GTK - The GIMP Toolkit
* gtkfilesystem.h: Filesystem abstraction functions.
* Copyright (C) 2003, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_FILE_SYSTEM_H__
#define __GTK_FILE_SYSTEM_H__
#include <gio/gio.h>
#include <gtk/gtkwidget.h> /* For icon handling */
G_BEGIN_DECLS
#define GTK_TYPE_FILE_SYSTEM (_gtk_file_system_get_type ())
#define GTK_FILE_SYSTEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
#define GTK_FILE_SYSTEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass))
#define GTK_IS_FILE_SYSTEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FILE_SYSTEM))
#define GTK_IS_FILE_SYSTEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_FILE_SYSTEM))
#define GTK_FILE_SYSTEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass))
typedef struct GtkFileSystem GtkFileSystem;
typedef struct GtkFileSystemPrivate GtkFileSystemPrivate;
typedef struct GtkFileSystemClass GtkFileSystemClass;
typedef struct GtkFileSystemVolume GtkFileSystemVolume; /* opaque struct */
struct GtkFileSystem
{
GObject parent_object;
GtkFileSystemPrivate *priv;
};
struct GtkFileSystemClass
{
GObjectClass parent_class;
void (*volumes_changed) (GtkFileSystem *file_system);
};
typedef void (* GtkFileSystemGetInfoCallback) (GCancellable *cancellable,
GFileInfo *file_info,
const GError *error,
gpointer data);
typedef void (* GtkFileSystemVolumeMountCallback) (GCancellable *cancellable,
GtkFileSystemVolume *volume,
const GError *error,
gpointer data);
/* GtkFileSystem methods */
GType _gtk_file_system_get_type (void) G_GNUC_CONST;
GtkFileSystem * _gtk_file_system_new (void);
GSList * _gtk_file_system_list_volumes (GtkFileSystem *file_system);
GCancellable * _gtk_file_system_get_info (GtkFileSystem *file_system,
GFile *file,
const gchar *attributes,
GtkFileSystemGetInfoCallback callback,
gpointer data);
GCancellable * _gtk_file_system_mount_volume (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GMountOperation *mount_operation,
GtkFileSystemVolumeMountCallback callback,
gpointer data);
GCancellable * _gtk_file_system_mount_enclosing_volume (GtkFileSystem *file_system,
GFile *file,
GMountOperation *mount_operation,
GtkFileSystemVolumeMountCallback callback,
gpointer data);
GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
GFile *file);
/* GtkFileSystemVolume methods */
gchar * _gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume);
gboolean _gtk_file_system_volume_is_mounted (GtkFileSystemVolume *volume);
GFile * _gtk_file_system_volume_get_root (GtkFileSystemVolume *volume);
GIcon * _gtk_file_system_volume_get_symbolic_icon (GtkFileSystemVolume *volume);
GIcon * _gtk_file_system_volume_get_icon (GtkFileSystemVolume *volume);
GtkFileSystemVolume *_gtk_file_system_volume_ref (GtkFileSystemVolume *volume);
void _gtk_file_system_volume_unref (GtkFileSystemVolume *volume);
/* GFileInfo helper functions */
GIcon * _gtk_file_info_get_icon (GFileInfo *info,
int icon_size,
int scale);
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
/* GFile helper functions */
gboolean _gtk_file_has_native_path (GFile *file);
gboolean _gtk_file_consider_as_remote (GFile *file);
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_H__ */
+1 -1
View File
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include "gtkfilechooserutils.h"
#include "gtkfilesystem.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtktreedatalist.h"
+12 -13
View File
@@ -30,21 +30,20 @@
* @Short_description: Filtering items
* @See_also: #GtkFilerListModel
*
* A #GtkFilter object describes the filtering to be performed by a
* #GtkFilterListModel.
*
* The model will use the filter to determine if it should include items
* or not by calling gtk_filter_match() for each item and only keeping the
* ones that the function returns %TRUE for.
* #GtkFilter is the way to describe filters to be used in #GtkFilterListModel.
*
* The model will use a filter to determine if it should filter items or not
* by calling gtk_filter_match() for each item and only keeping the ones
* visible that the function returns %TRUE for.
*
* Filters may change what items they match through their lifetime. In that
* case, they will emit the #GtkFilter:changed signal to notify that previous
* filter results are no longer valid and that items should be checked again
* via gtk_filter_match().
* case, they can call gtk_filter_changed() which will emit the #GtkFilter:changed
* signal to notify that previous filter results are no longer valid and that
* items should be checked via gtk_filter_match() again.
*
* GTK provides various pre-made filter implementations for common filtering
* GTK provides various premade filter implementations for common filtering
* operations. These filters often include properties that can be linked to
* various widgets to easily allow searches.
* various widgets to easily allow searches.
*
* However, in particular for large lists or complex search methods, it is
* also possible to subclass #GtkFilter and provide one's own filter.
@@ -119,7 +118,7 @@ gtk_filter_init (GtkFilter *self)
* @self: a #GtkFilter
* @item: (type GObject) (transfer none): The item to check
*
* Checks if the given @item is matched by the filter or not.
* Checks if the given @item is matched by the filter or not.
*
* Returns: %TRUE if the filter matches the item and a filter model should
* keep it, %FALSE if not.
@@ -141,7 +140,7 @@ gtk_filter_match (GtkFilter *self,
* Gets the known strictness of @filters. If the strictness is not known,
* %GTK_FILTER_MATCH_SOME is returned.
*
* This value may change after emission of the #GtkFilter:changed signal.
* This value may change after emission of the GtkFilter:changed signal.
*
* This function is meant purely for optimization purposes, filters can
* choose to omit implementing it, but #GtkFilterListModel uses it.
+5 -11
View File
@@ -494,7 +494,7 @@ gtk_filter_list_model_refilter (GtkFilterListModel *self,
{
default:
g_assert_not_reached ();
/* fall thru */
G_GNUC_FALLTHROUGH;
case GTK_FILTER_CHANGE_DIFFERENT:
self->matches = gtk_bitset_new_empty ();
pending = gtk_bitset_new_range (0, g_list_model_get_n_items (self->model));
@@ -771,8 +771,8 @@ gtk_filter_list_model_get_model (GtkFilterListModel *self)
* @self: a #GtkFilterListModel
* @incremental: %TRUE to enable incremental filtering
*
* When incremental filtering is enabled, the GtkFilterListModel will not
* run filters immediately, but will instead queue an idle handler that
* When incremental filtering is enabled, the filterlistmodel will not run
* filters immediately, but will instead queue an idle handler that
* incrementally filters the items and adds them to the list. This of course
* means that items are not instantly added to the list, but only appear
* incrementally.
@@ -837,14 +837,8 @@ gtk_filter_list_model_get_incremental (GtkFilterListModel *self)
*
* You can use this value to check if @self is busy filtering by
* comparing the return value to 0 or you can compute the percentage
* of the filter remaining by dividing the return value by the total
* number of items in the underlying model:
*
* |[
* pending = gtk_filter_list_model_get_pending (self);
* model = gtk_filter_list_model_get_model (self);
* percentage = pending / (double) g_list_model_get_n_items (model);
* ]|
* of the filter remaining by dividing the return value by
* g_list_model_get_n_items(gtk_filter_list_model_get_model (self)).
*
* Returns: The number of items not yet filtered
**/
+1 -1
View File
@@ -300,7 +300,7 @@ gtk_flatten_list_model_add_items (GtkFlattenListModel *self,
G_CALLBACK (gtk_flatten_list_model_items_changed_cb),
node);
node->list = self;
added += g_list_model_get_n_items (node->model);
added +=g_list_model_get_n_items (node->model);
}
return added;
+1 -1
View File
@@ -45,7 +45,7 @@
/**
* SECTION:gtkgridview
* @title: GtkGridView
* @short_description: A widget for displaying grids
* @short_description: A widget for displaying lists in a grid
* @see_also: #GListModel, #GtkListView, #GtkColumnView
*
* GtkGridView is a widget to present a view into a large dynamic grid of items.
+30 -35
View File
@@ -55,14 +55,6 @@
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkprofilerprivate.h"
#define GDK_ARRAY_ELEMENT_TYPE char *
#define GDK_ARRAY_NULL_TERMINATED 1
#define GDK_ARRAY_FREE_FUNC g_free
#define GDK_ARRAY_TYPE_NAME GtkStrvBuilder
#define GDK_ARRAY_NAME gtk_strv_builder
#define GDK_ARRAY_PREALLOC 16
#include "gdk/gdkarrayimpl.c"
/**
* SECTION:gtkicontheme
* @Short_description: Looking up icons by name
@@ -2284,13 +2276,13 @@ real_choose_icon (GtkIconTheme *self,
}
static void
icon_name_list_add_icon (GtkStrvBuilder *icons,
const gchar *dir_suffix,
gchar *icon_name)
icon_name_list_add_icon (GPtrArray *icons,
const gchar *dir_suffix,
gchar *icon_name)
{
if (dir_suffix)
gtk_strv_builder_append (icons, g_strconcat (icon_name, dir_suffix, NULL));
gtk_strv_builder_append (icons, icon_name);
g_ptr_array_add (icons, g_strconcat (icon_name, dir_suffix, NULL));
g_ptr_array_add (icons, icon_name);
}
static GtkIconPaintable *
@@ -2304,7 +2296,7 @@ choose_icon (GtkIconTheme *self,
{
gboolean has_regular = FALSE, has_symbolic = FALSE;
GtkIconPaintable *icon;
GtkStrvBuilder new_names;
GPtrArray *new_names;
const gchar *dir_suffix;
guint i;
@@ -2335,70 +2327,73 @@ choose_icon (GtkIconTheme *self,
if ((flags & GTK_ICON_LOOKUP_FORCE_REGULAR) && has_symbolic)
{
gtk_strv_builder_init (&new_names);
new_names = g_ptr_array_new_with_free_func (g_free);
for (i = 0; icon_names[i]; i++)
{
if (icon_name_is_symbolic (icon_names[i], -1))
icon_name_list_add_icon (&new_names, dir_suffix, g_strndup (icon_names[i], strlen (icon_names[i]) - strlen ("-symbolic")));
icon_name_list_add_icon (new_names, dir_suffix, g_strndup (icon_names[i], strlen (icon_names[i]) - strlen ("-symbolic")));
else
icon_name_list_add_icon (&new_names, dir_suffix, g_strdup (icon_names[i]));
icon_name_list_add_icon (new_names, dir_suffix, g_strdup (icon_names[i]));
}
for (i = 0; icon_names[i]; i++)
{
if (icon_name_is_symbolic (icon_names[i], -1))
icon_name_list_add_icon (&new_names, dir_suffix, g_strdup (icon_names[i]));
icon_name_list_add_icon (new_names, dir_suffix, g_strdup (icon_names[i]));
}
g_ptr_array_add (new_names, NULL);
icon = real_choose_icon (self,
(const char **) gtk_strv_builder_get_data (&new_names),
(const gchar **) new_names->pdata,
size,
scale,
flags & ~(GTK_ICON_LOOKUP_FORCE_REGULAR | GTK_ICON_LOOKUP_FORCE_SYMBOLIC),
non_blocking);
gtk_strv_builder_clear (&new_names);
g_ptr_array_free (new_names, TRUE);
}
else if ((flags & GTK_ICON_LOOKUP_FORCE_SYMBOLIC) && has_regular)
{
gtk_strv_builder_init (&new_names);
new_names = g_ptr_array_new_with_free_func (g_free);
for (i = 0; icon_names[i]; i++)
{
if (!icon_name_is_symbolic (icon_names[i], -1))
icon_name_list_add_icon (&new_names, dir_suffix, g_strconcat (icon_names[i], "-symbolic", NULL));
icon_name_list_add_icon (new_names, dir_suffix, g_strconcat (icon_names[i], "-symbolic", NULL));
else
icon_name_list_add_icon (&new_names, dir_suffix, g_strdup (icon_names[i]));
icon_name_list_add_icon (new_names, dir_suffix, g_strdup (icon_names[i]));
}
for (i = 0; icon_names[i]; i++)
{
if (!icon_name_is_symbolic (icon_names[i], -1))
icon_name_list_add_icon (&new_names, dir_suffix, g_strdup (icon_names[i]));
icon_name_list_add_icon (new_names, dir_suffix, g_strdup (icon_names[i]));
}
g_ptr_array_add (new_names, NULL);
icon = real_choose_icon (self,
(const char **) gtk_strv_builder_get_data (&new_names),
(const gchar **) new_names->pdata,
size,
scale,
flags & ~(GTK_ICON_LOOKUP_FORCE_REGULAR | GTK_ICON_LOOKUP_FORCE_SYMBOLIC),
non_blocking);
gtk_strv_builder_clear (&new_names);
g_ptr_array_free (new_names, TRUE);
}
else if (dir_suffix)
{
gtk_strv_builder_init (&new_names);
new_names = g_ptr_array_new_with_free_func (g_free);
for (i = 0; icon_names[i]; i++)
{
icon_name_list_add_icon (&new_names, dir_suffix, g_strdup (icon_names[i]));
icon_name_list_add_icon (new_names, dir_suffix, g_strdup (icon_names[i]));
}
g_ptr_array_add (new_names, NULL);
icon = real_choose_icon (self,
(const char **) gtk_strv_builder_get_data (&new_names),
(const gchar **) new_names->pdata,
size,
scale,
flags & ~(GTK_ICON_LOOKUP_FORCE_REGULAR | GTK_ICON_LOOKUP_FORCE_SYMBOLIC),
non_blocking);
gtk_strv_builder_clear (&new_names);
g_ptr_array_free (new_names, TRUE);
}
else
{
@@ -3858,11 +3853,11 @@ gtk_icon_paintable_ensure_texture (GtkIconPaintable *self)
static void
init_color_matrix (graphene_matrix_t *color_matrix,
graphene_vec4_t *color_offset,
const GdkRGBA *foreground_color,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color)
graphene_vec4_t *color_offset,
const GdkRGBA *foreground_color,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color)
{
GdkRGBA fg_default = { 0.7450980392156863, 0.7450980392156863, 0.7450980392156863, 1.0};
GdkRGBA success_default = { 0.3046921492332342,0.6015716792553597, 0.023437857633325704, 1.0};
+1 -1
View File
@@ -26,7 +26,7 @@
/**
* SECTION:gtklistitem
* @title: GtkListItem
* @short_description: Object used to represent items of a list model
* @short_description: Object used to represent items of a ListModel
* @see_also: #GtkListView, #GListModel
*
* #GtkListItem is the object that list-handling containers such
+13 -7
View File
@@ -577,11 +577,13 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
GtkListItemManager *self)
{
GHashTable *change;
GHashTableIter iter;
gpointer list_item;
GSList *l;
guint n_items;
n_items = g_list_model_get_n_items (G_LIST_MODEL (self->model));
change = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify )gtk_widget_unparent);
change = g_hash_table_new (g_direct_hash, g_direct_equal);
gtk_list_item_manager_remove_items (self, change, position, removed);
gtk_list_item_manager_add_items (self, position, added);
@@ -725,6 +727,12 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
tracker->widget = GTK_LIST_ITEM_WIDGET (item->widget);
}
g_hash_table_iter_init (&iter, change);
while (g_hash_table_iter_next (&iter, NULL, &list_item))
{
gtk_list_item_manager_release_list_item (self, NULL, list_item);
}
g_hash_table_unref (change);
gtk_widget_queue_resize (self->widget);
@@ -1065,12 +1073,10 @@ gtk_list_item_manager_release_list_item (GtkListItemManager *self,
if (change != NULL)
{
if (!g_hash_table_replace (change, gtk_list_item_widget_get_item (GTK_LIST_ITEM_WIDGET (item)), item))
{
g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should not happen, but here we are.");
}
return;
if (g_hash_table_insert (change, gtk_list_item_widget_get_item (GTK_LIST_ITEM_WIDGET (item)), item))
return;
g_warning ("FIXME: Handle the same item multiple times in the list.\nLars says this totally should not happen, but here we are.");
}
gtk_widget_unparent (item);
+21 -24
View File
@@ -95,6 +95,7 @@
#include "gdk/gdk-private.h"
#include "gsk/gskprivate.h"
#include "gsk/gskrendernodeprivate.h"
#include "gtkarrayimplprivate.h"
#include "gtknative.h"
#include <locale.h>
@@ -137,13 +138,6 @@
#include "a11y/gtkaccessibility.h"
#include "inspector/window.h"
#define GDK_ARRAY_ELEMENT_TYPE GtkWidget *
#define GDK_ARRAY_TYPE_NAME GtkWidgetStack
#define GDK_ARRAY_NAME gtk_widget_stack
#define GDK_ARRAY_FREE_FUNC g_object_unref
#define GDK_ARRAY_PREALLOC 16
#include "gdk/gdkarrayimpl.c"
static GtkWindowGroup *gtk_main_get_window_group (GtkWidget *widget);
static gint pre_initialized = FALSE;
@@ -181,6 +175,7 @@ static const GdkDebugKey gtk_debug_keys[] = {
{ "no-css-cache", GTK_DEBUG_NO_CSS_CACHE, "Disable style property cache" },
{ "interactive", GTK_DEBUG_INTERACTIVE, "Enable the GTK inspector" },
{ "touchscreen", GTK_DEBUG_TOUCHSCREEN, "Pretend the pointer is a touchscreen" },
{ "resize", GTK_DEBUG_RESIZE, "Highlight resizing widgets" },
{ "layout", GTK_DEBUG_LAYOUT, "Show layout borders" },
{ "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
};
@@ -1326,7 +1321,8 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
double x, y;
GtkWidget *prev;
gboolean seen_ancestor;
GtkWidgetStack target_array;
GtkArray target_array;
GtkWidget *stack_targets[16];
int i;
if (old_target == new_target)
@@ -1380,19 +1376,19 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
widget = _gtk_widget_get_parent (widget);
}
gtk_widget_stack_init (&target_array);
gtk_array_init (&target_array, (void**)stack_targets, 16);
for (widget = new_target; widget; widget = _gtk_widget_get_parent (widget))
gtk_widget_stack_append (&target_array, g_object_ref (widget));
gtk_array_add (&target_array, widget);
crossing.direction = GTK_CROSSING_IN;
seen_ancestor = FALSE;
for (i = gtk_widget_stack_get_size (&target_array) - 1; i >= 0; i--)
for (i = (int)target_array.len - 1; i >= 0; i--)
{
widget = gtk_widget_stack_get (&target_array, i);
widget = gtk_array_index (&target_array, i);
if (i < gtk_widget_stack_get_size (&target_array) - 1)
crossing.new_descendent = gtk_widget_stack_get (&target_array, i + 1);
if (i < (int)target_array.len - 1)
crossing.new_descendent = gtk_array_index (&target_array, i + 1);
else
crossing.new_descendent = NULL;
@@ -1421,7 +1417,7 @@ gtk_synthesize_crossing_events (GtkRoot *toplevel,
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_PRELIGHT, FALSE);
}
gtk_widget_stack_clear (&target_array);
gtk_array_free (&target_array, NULL);
}
static GtkWidget *
@@ -1998,12 +1994,13 @@ gtk_propagate_event_internal (GtkWidget *widget,
{
gint handled_event = FALSE;
GtkWidget *target = widget;
GtkWidgetStack widget_array;
GtkArray widget_array;
GtkWidget *stack_widgets[16];
int i;
/* First, propagate event down */
gtk_widget_stack_init (&widget_array);
gtk_widget_stack_append (&widget_array, g_object_ref (widget));
gtk_array_init (&widget_array, (void**)stack_widgets, 16);
gtk_array_add (&widget_array, g_object_ref (widget));
for (;;)
{
@@ -2011,16 +2008,16 @@ gtk_propagate_event_internal (GtkWidget *widget,
if (!widget)
break;
gtk_widget_stack_append (&widget_array, g_object_ref (widget));
gtk_array_add (&widget_array, g_object_ref (widget));
if (widget == topmost)
break;
}
i = gtk_widget_stack_get_size (&widget_array) - 1;
i = widget_array.len - 1;
for (;;)
{
widget = gtk_widget_stack_get (&widget_array, i);
widget = gtk_array_index (&widget_array, i);
if (!_gtk_widget_is_sensitive (widget))
{
@@ -2053,9 +2050,9 @@ gtk_propagate_event_internal (GtkWidget *widget,
* parents can see the button and motion
* events of the children.
*/
for (i = 0; i < gtk_widget_stack_get_size (&widget_array); i++)
for (i = 0; i < widget_array.len; i++)
{
widget = gtk_widget_stack_get (&widget_array, i);
widget = gtk_array_index (&widget_array, i);
/* Scroll events are special cased here because it
* feels wrong when scrolling a GtkViewport, say,
@@ -2074,7 +2071,7 @@ gtk_propagate_event_internal (GtkWidget *widget,
}
}
gtk_widget_stack_clear (&widget_array);
gtk_array_free (&widget_array, g_object_unref);
return handled_event;
}
+65 -44
View File
@@ -25,13 +25,6 @@
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#define GDK_ARRAY_TYPE_NAME GtkFilters
#define GDK_ARRAY_NAME gtk_filters
#define GDK_ARRAY_ELEMENT_TYPE GtkFilter *
#define GDK_ARRAY_FREE_FUNC g_object_unref
#include "gdk/gdkarrayimpl.c"
/*** MULTI FILTER ***/
/**
@@ -42,17 +35,17 @@
* GtkMultiFilter is the base type that implements support for handling
* multiple filters.
*
* GtkAnyFilter is a subclass of GtkMultiFilter that matches an item
* GtkAnyFilter is an implementation of GtkMultiFilter that matches an item
* when at least one of its filters matches.
*
* GtkEveryFilter is a subclass of GtkMultiFilter that matches an item
* GtkEveryFilter is an implementation of GtkMultiFilter that matches an item
* when each of its filters matches.
*/
struct _GtkMultiFilter
{
GtkFilter parent_instance;
GtkFilters filters;
GSequence *filters;
};
struct _GtkMultiFilterClass
@@ -74,7 +67,7 @@ gtk_multi_filter_get_n_items (GListModel *list)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (list);
return gtk_filters_get_size (&self->filters);
return g_sequence_get_length (self->filters);
}
static gpointer
@@ -82,11 +75,14 @@ gtk_multi_filter_get_item (GListModel *list,
guint position)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (list);
GSequenceIter *iter;
if (position < gtk_filters_get_size (&self->filters))
return g_object_ref (gtk_filters_get (&self->filters, position));
else
iter = g_sequence_get_iter_at_pos (self->filters, position);
if (g_sequence_iter_is_end (iter))
return NULL;
else
return g_object_ref (g_sequence_get (iter));
}
static void
@@ -131,35 +127,53 @@ gtk_multi_filter_changed_cb (GtkFilter *filter,
gtk_filter_changed (GTK_FILTER (self), change);
}
static void
gtk_multi_filter_remove_iter (GtkMultiFilter *self,
GSequenceIter *iter)
{
GtkFilter *filter;
filter = g_sequence_get (iter);
g_signal_handlers_disconnect_by_func (filter, gtk_multi_filter_changed_cb, self);
g_object_unref (filter);
g_sequence_remove (iter);
}
static void
gtk_multi_filter_dispose (GObject *object)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (object);
guint i;
for (i = 0; i < gtk_filters_get_size (&self->filters); i++)
{
GtkFilter *filter = gtk_filters_get (&self->filters, i);
g_signal_handlers_disconnect_by_func (filter, gtk_multi_filter_changed_cb, self);
}
gtk_filters_clear (&self->filters);
while (!g_sequence_is_empty (self->filters))
gtk_multi_filter_remove_iter (self, g_sequence_get_begin_iter (self->filters));
G_OBJECT_CLASS (gtk_multi_filter_parent_class)->dispose (object);
}
static void
gtk_multi_filter_finalize (GObject *object)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (object);
g_assert (g_sequence_is_empty (self->filters));
g_sequence_free (self->filters);
G_OBJECT_CLASS (gtk_multi_filter_parent_class)->finalize (object);
}
static void
gtk_multi_filter_class_init (GtkMultiFilterClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->dispose = gtk_multi_filter_dispose;
object_class->finalize = gtk_multi_filter_finalize;
}
static void
gtk_multi_filter_init (GtkMultiFilter *self)
{
gtk_filters_init (&self->filters);
self->filters = g_sequence_new (NULL);
}
/**
@@ -177,7 +191,7 @@ gtk_multi_filter_append (GtkMultiFilter *self,
g_return_if_fail (GTK_IS_FILTER (filter));
g_signal_connect (filter, "changed", G_CALLBACK (gtk_multi_filter_changed_cb), self);
gtk_filters_append (&self->filters, filter);
g_sequence_append (self->filters, filter);
gtk_filter_changed (GTK_FILTER (self),
GTK_MULTI_FILTER_GET_CLASS (self)->addition_change);
@@ -197,16 +211,15 @@ void
gtk_multi_filter_remove (GtkMultiFilter *self,
guint position)
{
GSequenceIter *iter;
guint length;
GtkFilter *filter;
length = gtk_filters_get_size (&self->filters);
length = g_sequence_get_length (self->filters);
if (position >= length)
return;
filter = gtk_filters_get (&self->filters, position);
g_signal_handlers_disconnect_by_func (filter, gtk_multi_filter_changed_cb, self);
gtk_filters_splice (&self->filters, position, 1, NULL, 0);
iter = g_sequence_get_iter_at_pos (self->filters, position);
gtk_multi_filter_remove_iter (self, iter);
gtk_filter_changed (GTK_FILTER (self),
GTK_MULTI_FILTER_GET_CLASS (self)->removal_change);
@@ -231,11 +244,13 @@ gtk_any_filter_match (GtkFilter *filter,
gpointer item)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (filter);
guint i;
GSequenceIter *iter;
for (i = 0; i < gtk_filters_get_size (&self->filters); i++)
for (iter = g_sequence_get_begin_iter (self->filters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkFilter *child = gtk_filters_get (&self->filters, i);
GtkFilter *child = g_sequence_get (iter);
if (gtk_filter_match (child, item))
return TRUE;
@@ -247,13 +262,15 @@ gtk_any_filter_match (GtkFilter *filter,
static GtkFilterMatch
gtk_any_filter_get_strictness (GtkFilter *filter)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (filter);
guint i;
GtkMultiFilter *multi = GTK_MULTI_FILTER (filter);
GSequenceIter *iter;
GtkFilterMatch result = GTK_FILTER_MATCH_NONE;
for (i = 0; i < gtk_filters_get_size (&self->filters); i++)
for (iter = g_sequence_get_begin_iter (multi->filters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkFilter *child = gtk_filters_get (&self->filters, i);
GtkFilter *child = g_sequence_get (iter);
switch (gtk_filter_get_strictness (child))
{
@@ -329,11 +346,13 @@ gtk_every_filter_match (GtkFilter *filter,
gpointer item)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (filter);
guint i;
GSequenceIter *iter;
for (i = 0; i < gtk_filters_get_size (&self->filters); i++)
for (iter = g_sequence_get_begin_iter (self->filters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkFilter *child = gtk_filters_get (&self->filters, i);
GtkFilter *child = g_sequence_get (iter);
if (!gtk_filter_match (child, item))
return FALSE;
@@ -345,13 +364,15 @@ gtk_every_filter_match (GtkFilter *filter,
static GtkFilterMatch
gtk_every_filter_get_strictness (GtkFilter *filter)
{
GtkMultiFilter *self = GTK_MULTI_FILTER (filter);
guint i;
GtkMultiFilter *multi = GTK_MULTI_FILTER (filter);
GSequenceIter *iter;
GtkFilterMatch result = GTK_FILTER_MATCH_ALL;
for (i = 0; i < gtk_filters_get_size (&self->filters); i++)
for (iter = g_sequence_get_begin_iter (multi->filters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkFilter *child = gtk_filters_get (&self->filters, i);
GtkFilter *child = g_sequence_get (iter);
switch (gtk_filter_get_strictness (child))
{
@@ -392,7 +413,7 @@ gtk_every_filter_init (GtkEveryFilter *self)
/**
* gtk_every_filter_new:
*
* Creates a new empty "every" filter.
* Creates a new empty "every" filter.
* Use gtk_multi_filter_append() to add filters to it.
*
* This filter matches an item if each of the filters added to it
+52 -37
View File
@@ -25,13 +25,6 @@
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#define GDK_ARRAY_TYPE_NAME GtkSorters
#define GDK_ARRAY_NAME gtk_sorters
#define GDK_ARRAY_ELEMENT_TYPE GtkSorter *
#define GDK_ARRAY_FREE_FUNC g_object_unref
#include "gdk/gdkarrayimpl.c"
/**
* SECTION:gtkmultisorter
* @Title: GtkMultiSorter
@@ -45,7 +38,7 @@ struct _GtkMultiSorter
{
GtkSorter parent_instance;
GtkSorters sorters;
GSequence *sorters;
};
static GType
@@ -59,7 +52,7 @@ gtk_multi_sorter_get_n_items (GListModel *list)
{
GtkMultiSorter *self = GTK_MULTI_SORTER (list);
return gtk_sorters_get_size (&self->sorters);
return g_sequence_get_length (self->sorters);
}
static gpointer
@@ -67,11 +60,14 @@ gtk_multi_sorter_get_item (GListModel *list,
guint position)
{
GtkMultiSorter *self = GTK_MULTI_SORTER (list);
GSequenceIter *iter;
if (position < gtk_sorters_get_size (&self->sorters))
return g_object_ref (gtk_sorters_get (&self->sorters, position));
else
iter = g_sequence_get_iter_at_pos (self->sorters, position);
if (g_sequence_iter_is_end (iter))
return NULL;
else
return g_object_ref (g_sequence_get (iter));
}
static void
@@ -115,11 +111,13 @@ gtk_multi_sorter_compare (GtkSorter *sorter,
{
GtkMultiSorter *self = GTK_MULTI_SORTER (sorter);
GtkOrdering result = GTK_ORDERING_EQUAL;
guint i;
GSequenceIter *iter;
for (i = 0; i < gtk_sorters_get_size (&self->sorters); i++)
for (iter = g_sequence_get_begin_iter (self->sorters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkSorter *child = gtk_sorters_get (&self->sorters, i);
GtkSorter *child = g_sequence_get (iter);
result = gtk_sorter_compare (child, item1, item2);
if (result != GTK_ORDERING_EQUAL)
@@ -134,11 +132,13 @@ gtk_multi_sorter_get_order (GtkSorter *sorter)
{
GtkMultiSorter *self = GTK_MULTI_SORTER (sorter);
GtkSorterOrder result = GTK_SORTER_ORDER_NONE;
guint i;
GSequenceIter *iter;
for (i = 0; i < gtk_sorters_get_size (&self->sorters); i++)
for (iter = g_sequence_get_begin_iter (self->sorters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkSorter *child = gtk_sorters_get (&self->sorters, i);
GtkSorter *child = g_sequence_get (iter);
GtkSorterOrder child_order;
child_order = gtk_sorter_get_order (child);
@@ -166,14 +166,12 @@ gtk_multi_sorter_changed_cb (GtkSorter *sorter,
GtkMultiSorter *self)
{
/* Using an enum on purpose, so gcc complains about this case if
* new values are added to the enum
*/
* new values are added to the enum */
switch (change)
{
case GTK_SORTER_CHANGE_INVERTED:
/* This could do a lot better with change handling, in particular in
* cases where self->n_sorters == 1 or if sorter == self->sorters[0]
*/
/* This could do a lot better with change handling, in particular in cases where self->n_sorters == 1
* or if sorter == self->sorters[0] */
change = GTK_SORTER_CHANGE_DIFFERENT;
break;
@@ -189,22 +187,39 @@ gtk_multi_sorter_changed_cb (GtkSorter *sorter,
gtk_sorter_changed (GTK_SORTER (self), change);
}
static void
gtk_multi_sorter_remove_iter (GtkMultiSorter *self,
GSequenceIter *iter)
{
GtkSorter *sorter;
sorter = g_sequence_get (iter);
g_signal_handlers_disconnect_by_func (sorter, gtk_multi_sorter_changed_cb, self);
g_object_unref (sorter);
g_sequence_remove (iter);
}
static void
gtk_multi_sorter_dispose (GObject *object)
{
GtkMultiSorter *self = GTK_MULTI_SORTER (object);
guint i;
for (i = 0; i < gtk_sorters_get_size (&self->sorters); i++)
{
GtkSorter *sorter = gtk_sorters_get (&self->sorters, i);
g_signal_handlers_disconnect_by_func (sorter, gtk_multi_sorter_changed_cb, self);
}
gtk_sorters_clear (&self->sorters);
while (!g_sequence_is_empty (self->sorters))
gtk_multi_sorter_remove_iter (self, g_sequence_get_begin_iter (self->sorters));
G_OBJECT_CLASS (gtk_multi_sorter_parent_class)->dispose (object);
}
static void
gtk_multi_sorter_finalize (GObject *object)
{
GtkMultiSorter *self = GTK_MULTI_SORTER (object);
g_sequence_free (self->sorters);
G_OBJECT_CLASS (gtk_multi_sorter_parent_class)->finalize (object);
}
static void
gtk_multi_sorter_class_init (GtkMultiSorterClass *class)
{
@@ -215,12 +230,13 @@ gtk_multi_sorter_class_init (GtkMultiSorterClass *class)
sorter_class->get_order = gtk_multi_sorter_get_order;
object_class->dispose = gtk_multi_sorter_dispose;
object_class->finalize = gtk_multi_sorter_finalize;
}
static void
gtk_multi_sorter_init (GtkMultiSorter *self)
{
gtk_sorters_init (&self->sorters);
self->sorters = g_sequence_new (NULL);
}
/**
@@ -258,7 +274,7 @@ gtk_multi_sorter_append (GtkMultiSorter *self,
g_return_if_fail (GTK_IS_SORTER (sorter));
g_signal_connect (sorter, "changed", G_CALLBACK (gtk_multi_sorter_changed_cb), self);
gtk_sorters_append (&self->sorters, sorter);
g_sequence_append (self->sorters, sorter);
gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_MORE_STRICT);
}
@@ -277,18 +293,17 @@ void
gtk_multi_sorter_remove (GtkMultiSorter *self,
guint position)
{
GSequenceIter *iter;
guint length;
GtkSorter *sorter;
g_return_if_fail (GTK_IS_MULTI_SORTER (self));
length = gtk_sorters_get_size (&self->sorters);
length = g_sequence_get_length (self->sorters);
if (position >= length)
return;
sorter = gtk_sorters_get (&self->sorters, position);
g_signal_handlers_disconnect_by_func (sorter, gtk_multi_sorter_changed_cb, self);
gtk_sorters_splice (&self->sorters, position, 1, NULL, 0);
iter = g_sequence_get_iter_at_pos (self->sorters, position);
gtk_multi_sorter_remove_iter (self, iter);
gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_LESS_STRICT);
}
+2
View File
@@ -27,6 +27,8 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserembed.h"
#include "gtkfilesystem.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
+273 -249
View File
File diff suppressed because it is too large Load Diff
+29 -6
View File
@@ -19,20 +19,43 @@
#define __GTK_PATH_BAR_H__
#include "gtkwidget.h"
#include "gtkfilesystem.h"
G_BEGIN_DECLS
#define GTK_TYPE_PATH_BAR (gtk_path_bar_get_type ())
#define GTK_PATH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PATH_BAR, GtkPathBar))
#define GTK_IS_PATH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PATH_BAR))
typedef struct _GtkPathBar GtkPathBar;
typedef struct _GtkPathBarClass GtkPathBarClass;
typedef struct _GtkPathBar GtkPathBar;
#define GTK_TYPE_PATH_BAR (gtk_path_bar_get_type ())
#define GTK_PATH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PATH_BAR, GtkPathBar))
#define GTK_PATH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PATH_BAR, GtkPathBarClass))
#define GTK_IS_PATH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PATH_BAR))
#define GTK_IS_PATH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PATH_BAR))
#define GTK_PATH_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PATH_BAR, GtkPathBarClass))
struct _GtkPathBar
{
GtkWidget parent_instance;
};
struct _GtkPathBarClass
{
GtkWidgetClass parent_class;
void (* path_clicked) (GtkPathBar *path_bar,
GFile *file,
GFile *child_file,
gboolean child_is_hidden);
};
GDK_AVAILABLE_IN_ALL
GType gtk_path_bar_get_type (void) G_GNUC_CONST;
void _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
GtkFileSystem *file_system);
void _gtk_path_bar_set_file (GtkPathBar *path_bar,
GFile *file,
gboolean keep_trail);
GFile *file,
gboolean keep_trail);
void _gtk_path_bar_up (GtkPathBar *path_bar);
void _gtk_path_bar_down (GtkPathBar *path_bar);
+1 -3
View File
@@ -33,7 +33,7 @@
#include "gdk/gdkkeysyms.h"
#include "gtkbookmarksmanagerprivate.h"
#include "gtkcelllayout.h"
#include "gtkfilechooserutils.h"
#include "gtkfilesystem.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtkmain.h"
@@ -767,8 +767,6 @@ add_application_shortcuts (GtkPlacesSidebar *sidebar)
GFile *file = g_list_model_get_item (G_LIST_MODEL (sidebar->shortcuts), i);
ShortcutData *data;
g_object_unref (file);
if (!should_show_file (sidebar, file))
continue;
+8 -7
View File
@@ -744,6 +744,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
GtkSorter *sorter;
GtkFilter *filter;
GtkFilter *filter1;
GtkExpression *expression;
GtkListItemFactory *factory;
GListStore *store;
GListModel *paper_size_list;
@@ -818,13 +819,15 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
filter = gtk_every_filter_new ();
filter1 = gtk_string_filter_new (
gtk_cclosure_expression_new (G_TYPE_STRING,
NULL, 0, NULL,
G_CALLBACK (get_printer_key),
NULL, NULL));
filter1 = gtk_string_filter_new ();
gtk_string_filter_set_match_mode (GTK_STRING_FILTER (filter1), GTK_STRING_FILTER_MATCH_MODE_SUBSTRING);
gtk_string_filter_set_ignore_case (GTK_STRING_FILTER (filter1), TRUE);
expression = gtk_cclosure_expression_new (G_TYPE_STRING,
NULL, 0, NULL,
G_CALLBACK (get_printer_key),
NULL, NULL);
gtk_string_filter_set_expression (GTK_STRING_FILTER (filter1), expression);
gtk_expression_unref (expression);
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
filter1 = gtk_custom_filter_new (is_printer_active, dialog, NULL);
@@ -3006,8 +3009,6 @@ paper_size_changed (GtkDropDown *combo_box,
gtk_window_present (GTK_WINDOW (custom_paper_dialog));
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_unref (page_setup);
return;
}
-17
View File
@@ -119,7 +119,6 @@ enum {
PROP_SEARCH_MODE_ENABLED,
PROP_SHOW_CLOSE_BUTTON,
PROP_CHILD,
PROP_KEY_CAPTURE_WIDGET,
LAST_PROPERTY
};
@@ -207,9 +206,6 @@ gtk_search_bar_set_property (GObject *object,
case PROP_CHILD:
gtk_search_bar_set_child (bar, g_value_get_object (value));
break;
case PROP_KEY_CAPTURE_WIDGET:
gtk_search_bar_set_key_capture_widget (bar, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -235,9 +231,6 @@ gtk_search_bar_get_property (GObject *object,
case PROP_CHILD:
g_value_set_object (value, gtk_search_bar_get_child (bar));
break;
case PROP_KEY_CAPTURE_WIDGET:
g_value_set_object (value, gtk_search_bar_get_key_capture_widget (bar));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -294,7 +287,6 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass)
object_class->get_property = gtk_search_bar_get_property;
widget_class->compute_expand = gtk_search_bar_compute_expand;
widget_class->focus = gtk_widget_focus_child;
/**
* GtkSearchBar:search-mode-enabled:
@@ -326,13 +318,6 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass)
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
widget_props[PROP_KEY_CAPTURE_WIDGET]
= g_param_spec_object ("key-capture-widget",
P_("Key Capture Widget"),
P_("Key Capture Widget"),
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, LAST_PROPERTY, widget_props);
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
@@ -625,8 +610,6 @@ gtk_search_bar_set_key_capture_widget (GtkSearchBar *bar,
G_CALLBACK (capture_widget_key_handled), bar);
gtk_widget_add_controller (widget, bar->capture_widget_controller);
}
g_object_notify_by_pspec (G_OBJECT (bar), widget_props[PROP_KEY_CAPTURE_WIDGET]);
}
/**
+6 -4
View File
@@ -543,20 +543,21 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
{
GtkWidget *column;
for (column = gtk_widget_get_last_child (page);
for (column = gtk_widget_get_first_child (page);
column != NULL;
column = gtk_widget_get_prev_sibling (column))
column = gtk_widget_get_next_sibling (column))
{
GtkWidget *group;
for (group = gtk_widget_get_last_child (column);
for (group = gtk_widget_get_first_child (column);
group != NULL;
group = gtk_widget_get_prev_sibling (group))
group = gtk_widget_get_next_sibling (group))
{
groups = g_list_prepend (groups, group);
}
}
}
groups = g_list_reverse (groups);
/* create new pages */
current_page = NULL;
@@ -641,6 +642,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self)
child != NULL;
child = gtk_widget_get_prev_sibling (child))
content = g_list_prepend (content, child);
content = g_list_reverse (content);
n = 0;
for (g = g_list_last (content); g; g = g->prev)
+42 -126
View File
@@ -34,11 +34,6 @@
#include "gtk/gskpango.h"
#define GDK_ARRAY_NAME gtk_snapshot_nodes
#define GDK_ARRAY_TYPE_NAME GtkSnapshotNodes
#define GDK_ARRAY_ELEMENT_TYPE GskRenderNode *
#define GDK_ARRAY_FREE_FUNC gsk_render_node_unref
#include "gdk/gdkarrayimpl.c"
/**
* SECTION:gtksnapshot
@@ -59,85 +54,6 @@
* use gtk_snapshot_new().
*/
typedef struct _GtkSnapshotState GtkSnapshotState;
typedef GskRenderNode * (* GtkSnapshotCollectFunc) (GtkSnapshot *snapshot,
GtkSnapshotState *state,
GskRenderNode **nodes,
guint n_nodes);
struct _GtkSnapshotState {
guint start_node_index;
guint n_nodes;
GskTransform * transform;
GtkSnapshotCollectFunc collect_func;
union {
struct {
double opacity;
} opacity;
struct {
double radius;
} blur;
struct {
graphene_matrix_t matrix;
graphene_vec4_t offset;
} color_matrix;
struct {
graphene_rect_t bounds;
graphene_rect_t child_bounds;
} repeat;
struct {
graphene_rect_t bounds;
} clip;
struct {
GskRoundedRect bounds;
} rounded_clip;
struct {
gsize n_shadows;
GskShadow *shadows;
GskShadow a_shadow; /* Used if n_shadows == 1 */
} shadow;
struct {
GskBlendMode blend_mode;
GskRenderNode *bottom_node;
} blend;
struct {
double progress;
GskRenderNode *start_node;
} cross_fade;
struct {
char *message;
} debug;
} data;
};
static void gtk_snapshot_state_clear (GtkSnapshotState *state);
#define GDK_ARRAY_NAME gtk_snapshot_states
#define GDK_ARRAY_TYPE_NAME GtkSnapshotStates
#define GDK_ARRAY_ELEMENT_TYPE GtkSnapshotState
#define GDK_ARRAY_FREE_FUNC gtk_snapshot_state_clear
#define GDK_ARRAY_BY_VALUE 1
#include "gdk/gdkarrayimpl.c"
/* This is a nasty little hack. We typedef GtkSnapshot to the fake object GdkSnapshot
* so that we don't need to typecast between them.
* After all, the GdkSnapshot only exist so poor language bindings don't trip. Hardcore
* C code can just blatantly ignore such layering violations with a typedef.
*/
struct _GdkSnapshot {
GObject parent_instance; /* it's really GdkSnapshot, but don't tell anyone! */
GtkSnapshotStates state_stack;
GtkSnapshotNodes nodes;
};
struct _GtkSnapshotClass {
GObjectClass parent_class; /* it's really GdkSnapshotClass, but don't tell anyone! */
};
G_DEFINE_TYPE (GtkSnapshot, gtk_snapshot, GDK_TYPE_SNAPSHOT)
static void
@@ -145,11 +61,11 @@ gtk_snapshot_dispose (GObject *object)
{
GtkSnapshot *snapshot = GTK_SNAPSHOT (object);
if (!gtk_snapshot_states_is_empty (&snapshot->state_stack))
if (snapshot->state_stack)
gsk_render_node_unref (gtk_snapshot_to_node (snapshot));
g_assert (gtk_snapshot_states_is_empty (&snapshot->state_stack));
g_assert (gtk_snapshot_nodes_is_empty (&snapshot->nodes));
g_assert (snapshot->state_stack == NULL);
g_assert (snapshot->nodes == NULL);
G_OBJECT_CLASS (gtk_snapshot_parent_class)->dispose (object);
}
@@ -196,15 +112,15 @@ gtk_snapshot_push_state (GtkSnapshot *snapshot,
GskTransform *transform,
GtkSnapshotCollectFunc collect_func)
{
const gsize n_states = gtk_snapshot_states_get_size (&snapshot->state_stack);
const gsize n_states = snapshot->state_stack->len;
GtkSnapshotState *state;
gtk_snapshot_states_set_size (&snapshot->state_stack, n_states + 1);
state = gtk_snapshot_states_get (&snapshot->state_stack, n_states);
g_array_set_size (snapshot->state_stack, n_states + 1);
state = &g_array_index (snapshot->state_stack, GtkSnapshotState, n_states);
state->transform = gsk_transform_ref (transform);
state->collect_func = collect_func;
state->start_node_index = gtk_snapshot_nodes_get_size (&snapshot->nodes);
state->start_node_index = snapshot->nodes->len;
state->n_nodes = 0;
return state;
@@ -213,21 +129,17 @@ gtk_snapshot_push_state (GtkSnapshot *snapshot,
static GtkSnapshotState *
gtk_snapshot_get_current_state (const GtkSnapshot *snapshot)
{
gsize size = gtk_snapshot_states_get_size (&snapshot->state_stack);
g_assert (snapshot->state_stack->len > 0);
g_assert (size > 0);
return gtk_snapshot_states_get (&snapshot->state_stack, size - 1);
return &g_array_index (snapshot->state_stack, GtkSnapshotState, snapshot->state_stack->len - 1);
}
static GtkSnapshotState *
gtk_snapshot_get_previous_state (const GtkSnapshot *snapshot)
{
gsize size = gtk_snapshot_states_get_size (&snapshot->state_stack);
g_assert (snapshot->state_stack->len > 1);
g_assert (size > 1);
return gtk_snapshot_states_get (&snapshot->state_stack, size - 2);
return &g_array_index (snapshot->state_stack, GtkSnapshotState, snapshot->state_stack->len - 2);
}
static void
@@ -250,8 +162,9 @@ gtk_snapshot_new (void)
snapshot = g_object_new (GTK_TYPE_SNAPSHOT, NULL);
gtk_snapshot_states_init (&snapshot->state_stack);
gtk_snapshot_nodes_init (&snapshot->nodes);
snapshot->state_stack = g_array_new (FALSE, TRUE, sizeof (GtkSnapshotState));
g_array_set_clear_func (snapshot->state_stack, (GDestroyNotify)gtk_snapshot_state_clear);
snapshot->nodes = g_ptr_array_new_with_free_func ((GDestroyNotify)gsk_render_node_unref);
gtk_snapshot_push_state (snapshot,
NULL,
@@ -351,6 +264,9 @@ gtk_snapshot_collect_debug (GtkSnapshot *snapshot,
if (node == NULL)
return NULL;
if (state->data.debug.message == NULL)
return node;
debug_node = gsk_debug_node_new (node, state->data.debug.message);
gsk_render_node_unref (node);
@@ -374,17 +290,15 @@ gtk_snapshot_push_debug (GtkSnapshot *snapshot,
...)
{
GtkSnapshotState *current_state = gtk_snapshot_get_current_state (snapshot);
GtkSnapshotState *state;
state = gtk_snapshot_push_state (snapshot,
current_state->transform,
gtk_snapshot_collect_debug);
if (GTK_DEBUG_CHECK (SNAPSHOT))
{
va_list args;
GtkSnapshotState *state;
state = gtk_snapshot_push_state (snapshot,
current_state->transform,
gtk_snapshot_collect_debug);
va_start (args, message);
state->data.debug.message = g_strdup_vprintf (message, args);
@@ -392,9 +306,7 @@ gtk_snapshot_push_debug (GtkSnapshot *snapshot,
}
else
{
gtk_snapshot_push_state (snapshot,
current_state->transform,
gtk_snapshot_collect_default);
state->data.debug.message = NULL;
}
}
@@ -1117,28 +1029,30 @@ gtk_snapshot_pop_one (GtkSnapshot *snapshot)
guint state_index;
GskRenderNode *node;
if (gtk_snapshot_states_is_empty (&snapshot->state_stack))
if (snapshot->state_stack->len == 0)
{
g_warning ("Too many gtk_snapshot_pop() calls.");
return NULL;
}
state = gtk_snapshot_get_current_state (snapshot);
state_index = gtk_snapshot_states_get_size (&snapshot->state_stack) - 1;
state_index = snapshot->state_stack->len - 1;
if (state->collect_func)
{
node = state->collect_func (snapshot,
state,
(GskRenderNode **) gtk_snapshot_nodes_index (&snapshot->nodes, state->start_node_index),
(GskRenderNode **) snapshot->nodes->pdata + state->start_node_index,
state->n_nodes);
/* The collect func may not modify the state stack... */
g_assert (state_index == gtk_snapshot_states_get_size (&snapshot->state_stack) - 1);
g_assert (state_index == snapshot->state_stack->len - 1);
/* Remove all the state's nodes from the list of nodes */
g_assert (state->start_node_index + state->n_nodes == gtk_snapshot_nodes_get_size (&snapshot->nodes));
gtk_snapshot_nodes_splice (&snapshot->nodes, state->start_node_index, state->n_nodes, NULL, 0);
g_assert (state->start_node_index + state->n_nodes == snapshot->nodes->len);
g_ptr_array_remove_range (snapshot->nodes,
snapshot->nodes->len - state->n_nodes,
state->n_nodes);
}
else
{
@@ -1149,10 +1063,10 @@ gtk_snapshot_pop_one (GtkSnapshot *snapshot)
/* move the nodes to the parent */
previous_state = gtk_snapshot_get_previous_state (snapshot);
previous_state->n_nodes += state->n_nodes;
g_assert (previous_state->start_node_index + previous_state->n_nodes == gtk_snapshot_nodes_get_size (&snapshot->nodes));
g_assert (previous_state->start_node_index + previous_state->n_nodes == snapshot->nodes->len);
}
gtk_snapshot_states_splice (&snapshot->state_stack, state_index, 1, NULL, 0);
g_array_remove_index (snapshot->state_stack, state_index);
return node;
}
@@ -1167,7 +1081,7 @@ gtk_snapshot_append_node_internal (GtkSnapshot *snapshot,
if (current_state)
{
gtk_snapshot_nodes_append (&snapshot->nodes, node);
g_ptr_array_add (snapshot->nodes, node);
current_state->n_nodes ++;
}
else
@@ -1248,14 +1162,16 @@ gtk_snapshot_to_node (GtkSnapshot *snapshot)
result = gtk_snapshot_pop_internal (snapshot);
/* We should have exactly our initial state */
if (!gtk_snapshot_states_is_empty (&snapshot->state_stack))
if (snapshot->state_stack->len > 0)
{
g_warning ("Too many gtk_snapshot_push() calls. %zu states remaining.",
gtk_snapshot_states_get_size (&snapshot->state_stack));
g_warning ("Too many gtk_snapshot_push() calls. %u states remaining.", snapshot->state_stack->len);
}
gtk_snapshot_states_clear (&snapshot->state_stack);
gtk_snapshot_nodes_clear (&snapshot->nodes);
g_array_free (snapshot->state_stack, TRUE);
g_ptr_array_free (snapshot->nodes, TRUE);
snapshot->state_stack = NULL;
snapshot->nodes = NULL;
return result;
}
@@ -1823,7 +1739,7 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
fg_color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
shadows_value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_TEXT_SHADOW);
has_shadow = gtk_css_shadow_value_push_snapshot (shadows_value, snapshot);
has_shadow = gtk_css_shadow_value_push_snapshot (shadows_value, snapshot);
gtk_snapshot_append_layout (snapshot, layout, fg_color);
+70
View File
@@ -24,6 +24,76 @@
G_BEGIN_DECLS
typedef struct _GtkSnapshotState GtkSnapshotState;
typedef GskRenderNode * (* GtkSnapshotCollectFunc) (GtkSnapshot *snapshot,
GtkSnapshotState *state,
GskRenderNode **nodes,
guint n_nodes);
struct _GtkSnapshotState {
guint start_node_index;
guint n_nodes;
GskTransform * transform;
GtkSnapshotCollectFunc collect_func;
union {
struct {
double opacity;
} opacity;
struct {
double radius;
} blur;
struct {
graphene_matrix_t matrix;
graphene_vec4_t offset;
} color_matrix;
struct {
graphene_rect_t bounds;
graphene_rect_t child_bounds;
} repeat;
struct {
graphene_rect_t bounds;
} clip;
struct {
GskRoundedRect bounds;
} rounded_clip;
struct {
gsize n_shadows;
GskShadow *shadows;
GskShadow a_shadow; /* Used if n_shadows == 1 */
} shadow;
struct {
GskBlendMode blend_mode;
GskRenderNode *bottom_node;
} blend;
struct {
double progress;
GskRenderNode *start_node;
} cross_fade;
struct {
char *message;
} debug;
} data;
};
/* This is a nasty little hack. We typedef GtkSnapshot to the fake object GdkSnapshot
* so that we don't need to typecast between them.
* After all, the GdkSnapshot only exist so poor language bindings don't trip. Hardcore
* C code can just blatantly ignore such layering violations with a typedef.
*/
struct _GdkSnapshot {
GObject parent_instance; /* it's really GdkSnapshot, but don't tell anyone! */
GArray *state_stack;
GPtrArray *nodes;
};
struct _GtkSnapshotClass {
GObjectClass parent_class; /* it's really GdkSnapshotClass, but don't tell anyone! */
};
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,

Some files were not shown because too many files have changed in this diff Show More