Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 155899a1e4 | |||
| 70cbdd138a | |||
| 3e1b9703e7 | |||
| 31404c5d2f | |||
| bf367b219b | |||
| 77435d31fa | |||
| 6edb8f096f | |||
| c4dfee8860 | |||
| 8ac1e77c9a | |||
| 65ceb6c15a | |||
| f70d10f6ac | |||
| 0bbd083d79 | |||
| 102d2986c6 | |||
| c74201ca87 | |||
| b09019a5b4 | |||
| 1dd08ad8db | |||
| eb0704855f | |||
| c4c1d4a1b3 | |||
| e6756f605e | |||
| 1f4b8e089e | |||
| c0e08db739 | |||
| 1c337d350d | |||
| 81e675dfbf | |||
| 8556221429 | |||
| 1b4109a7fd | |||
| df0786be7a | |||
| 3f545da08d |
@@ -9,6 +9,7 @@
|
||||
<property name="default-height">768</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">document-open-symbolic</property>
|
||||
|
||||
@@ -188,7 +188,7 @@ constraint_view_init (ConstraintView *self)
|
||||
g_list_store_append (list, children);
|
||||
g_list_store_append (list, guides);
|
||||
g_list_store_append (list, constraints);
|
||||
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_TYPE_OBJECT, G_LIST_MODEL (list)));
|
||||
g_object_unref (children);
|
||||
g_object_unref (guides);
|
||||
g_object_unref (constraints);
|
||||
|
||||
@@ -140,7 +140,6 @@
|
||||
</gresource>
|
||||
<gresource prefix="/listview_colors">
|
||||
<file compressed="true">color.names.txt</file>
|
||||
<file>listview_colors.css</file>
|
||||
</gresource>
|
||||
<gresource prefix="/shortcuts">
|
||||
<file>shortcuts.ui</file>
|
||||
|
||||
@@ -92,7 +92,7 @@ strings_setup_item_full (GtkSignalListItemFactory *factory,
|
||||
gtk_label_set_xalign (GTK_LABEL (title), 0.0);
|
||||
description = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (description), 0.0);
|
||||
gtk_widget_add_css_class (description, "dim-label");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (description), "dim-label");
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<property name="title">Font Explorer</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset">
|
||||
<property name="receives-default">1</property>
|
||||
|
||||
@@ -30,6 +30,7 @@ do_headerbar (GtkWidget *do_widget)
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
|
||||
button = gtk_button_new ();
|
||||
icon = g_themed_icon_new ("mail-send-receive-symbolic");
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">500</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
|
||||
@@ -627,23 +627,6 @@ setup_listitem_cb (GtkListItemFactory *factory,
|
||||
gtk_expression_unref (color_expression);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_selection_listitem_cb (GtkListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GtkExpression *color_expression, *expression;
|
||||
|
||||
expression = gtk_constant_expression_new (GTK_TYPE_LIST_ITEM, list_item);
|
||||
color_expression = gtk_property_expression_new (GTK_TYPE_LIST_ITEM, expression, "item");
|
||||
|
||||
picture = gtk_picture_new ();
|
||||
gtk_widget_set_size_request (picture, 8, 8);
|
||||
gtk_expression_bind (color_expression, picture, "paintable", NULL);
|
||||
|
||||
gtk_list_item_set_child (list_item, picture);
|
||||
}
|
||||
|
||||
static void
|
||||
set_title (gpointer item,
|
||||
const char *title)
|
||||
@@ -676,7 +659,7 @@ create_color_grid (void)
|
||||
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (gridview), 24);
|
||||
gtk_grid_view_set_enable_rubberband (GTK_GRID_VIEW (gridview), TRUE);
|
||||
|
||||
model = G_LIST_MODEL (gtk_sor3_list_model_new (gtk_color_list_new (0), NULL));
|
||||
model = G_LIST_MODEL (gtk_sort_list_model_new (gtk_color_list_new (0), NULL));
|
||||
|
||||
selection = G_LIST_MODEL (gtk_multi_selection_new (model));
|
||||
gtk_grid_view_set_model (GTK_GRID_VIEW (gridview), selection);
|
||||
@@ -794,95 +777,6 @@ bind_number_item (GtkSignalListItemFactory *factory,
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
static void
|
||||
update_selection_count (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer data)
|
||||
{
|
||||
char *text;
|
||||
text = g_strdup_printf ("%u", g_list_model_get_n_items (model));
|
||||
gtk_label_set_label (GTK_LABEL (data), text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
update_selection_average (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer data)
|
||||
{
|
||||
guint n = g_list_model_get_n_items (model);
|
||||
GdkRGBA c = { 0, 0, 0, 1 };
|
||||
guint i;
|
||||
GtkColor *color;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
color = g_list_model_get_item (model, i);
|
||||
|
||||
c.red += color->color.red;
|
||||
c.green += color->color.green;
|
||||
c.blue += color->color.blue;
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
color = gtk_color_new ("", c.red / n, c.green / n, c.blue / n);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (data), GDK_PAINTABLE (color));
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static int
|
||||
compare_red (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkColor *colora = (GtkColor *) a;
|
||||
GtkColor *colorb = (GtkColor *) b;
|
||||
|
||||
if (colora->color.red < colorb->color.red)
|
||||
return GTK_ORDERING_LARGER;
|
||||
else if (colora->color.red > colorb->color.red)
|
||||
return GTK_ORDERING_SMALLER;
|
||||
else
|
||||
return GTK_ORDERING_EQUAL;
|
||||
}
|
||||
|
||||
static int
|
||||
compare_green (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkColor *colora = (GtkColor *) a;
|
||||
GtkColor *colorb = (GtkColor *) b;
|
||||
|
||||
if (colora->color.green < colorb->color.green)
|
||||
return GTK_ORDERING_LARGER;
|
||||
else if (colora->color.green > colorb->color.green)
|
||||
return GTK_ORDERING_SMALLER;
|
||||
else
|
||||
return GTK_ORDERING_EQUAL;
|
||||
}
|
||||
|
||||
static int
|
||||
compare_blue (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkColor *colora = (GtkColor *) a;
|
||||
GtkColor *colorb = (GtkColor *) b;
|
||||
|
||||
if (colora->color.blue < colorb->color.blue)
|
||||
return GTK_ORDERING_LARGER;
|
||||
else if (colora->color.blue > colorb->color.blue)
|
||||
return GTK_ORDERING_SMALLER;
|
||||
else
|
||||
return GTK_ORDERING_EQUAL;
|
||||
}
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
|
||||
GtkWidget *
|
||||
@@ -903,26 +797,11 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
PangoAttrList *attrs;
|
||||
char *string;
|
||||
guint len;
|
||||
GtkWidget *selection_view;
|
||||
GListModel *selection_filter;
|
||||
GListModel *no_selection;
|
||||
GtkWidget *grid;
|
||||
GtkWidget *selection_size_label;
|
||||
GtkWidget *selection_average_picture;
|
||||
GtkWidget *selection_info_toggle;
|
||||
GtkWidget *selection_info_revealer;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_resource (provider, "/listview_colors/listview_colors.css");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Colors");
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
@@ -930,89 +809,18 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
gtk_widget_get_display (do_widget));
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer*)&window);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
|
||||
selection_info_revealer = gtk_revealer_new ();
|
||||
gtk_box_append (GTK_BOX (box), selection_info_revealer);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_revealer_set_child (GTK_REVEALER (selection_info_revealer), grid);
|
||||
gtk_widget_set_margin_start (grid, 10);
|
||||
gtk_widget_set_margin_end (grid, 10);
|
||||
gtk_widget_set_margin_top (grid, 10);
|
||||
gtk_widget_set_margin_bottom (grid, 10);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
|
||||
|
||||
label = gtk_label_new ("Selection");
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_add_css_class (label, "title-3");
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 5, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Size:"), 0, 2, 1, 1);
|
||||
|
||||
selection_size_label = gtk_label_new ("0");
|
||||
gtk_grid_attach (GTK_GRID (grid), selection_size_label, 1, 2, 1, 1);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gtk_label_new ("Average:"), 2, 2, 1, 1);
|
||||
|
||||
selection_average_picture = gtk_picture_new ();
|
||||
gtk_widget_set_size_request (selection_average_picture, 32, 32);
|
||||
gtk_grid_attach (GTK_GRID (grid), selection_average_picture, 3, 2, 1, 1);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 4, 2, 1, 1);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_widget_set_hexpand (sw, TRUE);
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), sw, 0, 1, 5, 1);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_selection_listitem_cb), NULL);
|
||||
selection_view = gtk_grid_view_new_with_factory (factory);
|
||||
gtk_widget_add_css_class (selection_view, "compact");
|
||||
gtk_grid_view_set_max_columns (GTK_GRID_VIEW (selection_view), 200);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), selection_view);
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
gtk_box_append (GTK_BOX (box), sw);
|
||||
gtk_window_set_child (GTK_WINDOW (window), sw);
|
||||
|
||||
gridview = create_color_grid ();
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), gridview);
|
||||
gtk_widget_set_hexpand (sw, TRUE);
|
||||
gtk_widget_set_vexpand (sw, TRUE);
|
||||
model = gtk_grid_view_get_model (GTK_GRID_VIEW (gridview));
|
||||
|
||||
selection_filter = G_LIST_MODEL (gtk_selection_filter_model_new (GTK_SELECTION_MODEL (model)));
|
||||
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_count), selection_size_label);
|
||||
g_signal_connect (selection_filter, "items-changed", G_CALLBACK (update_selection_average), selection_average_picture);
|
||||
|
||||
no_selection = G_LIST_MODEL (gtk_no_selection_new (selection_filter));
|
||||
gtk_grid_view_set_model (GTK_GRID_VIEW (selection_view), no_selection);
|
||||
g_object_unref (selection_filter);
|
||||
g_object_unref (no_selection);
|
||||
|
||||
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");
|
||||
gtk_widget_set_tooltip_text (selection_info_toggle, "Show selection info");
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), selection_info_toggle);
|
||||
|
||||
g_object_bind_property (selection_info_toggle, "active",
|
||||
selection_info_revealer, "reveal-child",
|
||||
G_BINDING_DEFAULT);
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Refill");
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (refill),
|
||||
gtk_sor3_list_model_get_model (GTK_SOR3_LIST_MODEL (model)));
|
||||
gtk_sort_list_model_get_model (GTK_SORT_LIST_MODEL (model)));
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
|
||||
|
||||
@@ -1035,7 +843,7 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
gtk_drop_down_set_from_strings (GTK_DROP_DOWN (dropdown), (const char *[]) { "8", "64", "512", "4096", "32768", "262144", "2097152", "16777216", NULL });
|
||||
g_signal_connect (dropdown, "notify::selected",
|
||||
G_CALLBACK (limit_changed_cb),
|
||||
gtk_sor3_list_model_get_model (GTK_SOR3_LIST_MODEL (model)));
|
||||
gtk_sort_list_model_get_model (GTK_SORT_LIST_MODEL (model)));
|
||||
g_signal_connect (dropdown, "notify::selected",
|
||||
G_CALLBACK (limit_changed_cb2),
|
||||
label);
|
||||
@@ -1070,30 +878,18 @@ do_listview_colors (GtkWidget *do_widget)
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_red, NULL, NULL);
|
||||
set_title (sorter, "Red (fast)");
|
||||
g_list_store_append (sorters, sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "green"));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Green");
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_green, NULL, NULL);
|
||||
set_title (sorter, "Green (fast)");
|
||||
g_list_store_append (sorters, sorter);
|
||||
|
||||
sorter = gtk_numeric_sorter_new (gtk_property_expression_new (GTK_TYPE_COLOR, NULL, "blue"));
|
||||
gtk_numeric_sorter_set_sort_order (GTK_NUMERIC_SORTER (sorter), GTK_SORT_DESCENDING);
|
||||
set_title (sorter, "Blue");
|
||||
g_list_store_append (sorters, sorter);
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi_sorter), sorter);
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_blue, NULL, NULL);
|
||||
set_title (sorter, "Blue (fast)");
|
||||
g_list_store_append (sorters, sorter);
|
||||
|
||||
set_title (multi_sorter, "RGB");
|
||||
g_list_store_append (sorters, multi_sorter);
|
||||
g_object_unref (multi_sorter);
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
.view.compact > child {
|
||||
padding: 1px;
|
||||
}
|
||||
@@ -174,6 +174,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">go-up-symbolic</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="title" translatable="yes">Minesweeper</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">New Game</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">480</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="end">
|
||||
<object class="GtkToggleButton" id="search_button">
|
||||
<property name="icon-name">system-search-symbolic</property>
|
||||
|
||||
@@ -194,8 +194,8 @@ create_weather_model (void)
|
||||
}
|
||||
|
||||
static void
|
||||
setup_widget (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
setup_widget (GtkListItem *list_item,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkWidget *box, *child;
|
||||
|
||||
@@ -218,8 +218,8 @@ setup_widget (GtkSignalListItemFactory *factory,
|
||||
}
|
||||
|
||||
static void
|
||||
bind_widget (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *list_item)
|
||||
bind_widget (GtkListItem *list_item,
|
||||
gpointer unused)
|
||||
{
|
||||
GtkWidget *box, *child;
|
||||
GtkWeatherInfo *info;
|
||||
@@ -282,12 +282,11 @@ create_weather_view (void)
|
||||
{
|
||||
GtkWidget *listview;
|
||||
GListModel *model, *selection;
|
||||
GtkListItemFactory *factory;
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget), NULL);
|
||||
listview = gtk_list_view_new_with_factory (factory);
|
||||
listview = gtk_list_view_new_with_factory (
|
||||
gtk_functions_list_item_factory_new (setup_widget,
|
||||
bind_widget,
|
||||
NULL, NULL));
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (listview), GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_list_view_set_show_separators (GTK_LIST_VIEW (listview), TRUE);
|
||||
model = create_weather_model ();
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<property name="default-height">600</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
|
||||
@@ -69,6 +69,7 @@ do_markup (GtkWidget *do_widget)
|
||||
g_signal_connect (show_source, "toggled", G_CALLBACK (source_toggled), stack);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), show_source);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
<property name="title" translatable="yes">Model Button</property>
|
||||
<property name="resizable">0</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar"/>
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
||||
@@ -392,6 +392,7 @@ do_paint (GtkWidget *toplevel)
|
||||
gtk_window_set_child (GTK_WINDOW (window), draw_area);
|
||||
|
||||
headerbar = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE);
|
||||
|
||||
colorbutton = gtk_color_button_new ();
|
||||
g_signal_connect (colorbutton, "color-set",
|
||||
|
||||
@@ -276,6 +276,7 @@ do_peg_solitaire (GtkWidget *do_widget)
|
||||
g_signal_connect (restart, "clicked", G_CALLBACK (restart), NULL);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
|
||||
@@ -40,6 +40,7 @@ do_sidebar (GtkWidget *do_widget)
|
||||
gtk_widget_set_size_request (window, 500, 350);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR(header), TRUE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW(window), header);
|
||||
gtk_window_set_title (GTK_WINDOW(window), "Stack Sidebar");
|
||||
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
|
||||
|
||||
@@ -470,6 +470,7 @@ do_sliding_puzzle (GtkWidget *do_widget)
|
||||
g_signal_connect (restart, "clicked", G_CALLBACK (reshuffle), NULL);
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
|
||||
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), tweak);
|
||||
window = gtk_window_new ();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<property name="resizable">0</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="start">
|
||||
<object class="GtkToggleButton" id="toggle">
|
||||
<property name="label">Cycle</property>
|
||||
|
||||
@@ -73,6 +73,7 @@ do_video_player (GtkWidget *do_widget)
|
||||
gtk_window_set_child (GTK_WINDOW (window), video);
|
||||
|
||||
title = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (title), TRUE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), title);
|
||||
|
||||
open_button = gtk_button_new_with_mnemonic ("_Open");
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<property name="default-height">768</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkBox">
|
||||
<style>
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
<property name="focus-widget">text_view</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="icon-name">document-open-symbolic</property>
|
||||
|
||||
@@ -436,6 +436,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
|
||||
<property name="title">GTK Widget Factory</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar1">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="stack_switcher">
|
||||
<property name="stack">toplevel_stack</property>
|
||||
|
||||
@@ -1423,6 +1423,7 @@ the search bar below the header bar.
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
@@ -1536,6 +1537,7 @@ GtkMenuButton, GtkRevealer and GtkListBox.
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -54,9 +54,8 @@
|
||||
<section>
|
||||
<xi:include href="xml/gtkfilter.xml" />
|
||||
<xi:include href="xml/gtkcustomfilter.xml" />
|
||||
<xi:include href="xml/gtkmultifilter.xml" />
|
||||
<xi:include href="xml/gtkstringfilter.xml" />
|
||||
<xi:include href="xml/gtkfilefilter.xml" />
|
||||
<xi:include href="xml/gtkmultifilter.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gtkflattenlistmodel.xml" />
|
||||
<xi:include href="xml/gtkmaplistmodel.xml" />
|
||||
@@ -75,7 +74,6 @@
|
||||
<xi:include href="xml/gtksingleselection.xml" />
|
||||
<xi:include href="xml/gtkmultiselection.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gtkselectionfiltermodel.xml" />
|
||||
<xi:include href="xml/gtkbookmarklist.xml" />
|
||||
<xi:include href="xml/gtkdirectorylist.xml" />
|
||||
<xi:include href="xml/gtkstringlist.xml" />
|
||||
@@ -286,6 +284,7 @@
|
||||
<xi:include href="xml/gtkfilechoosernative.xml" />
|
||||
<xi:include href="xml/gtkfilechooserdialog.xml" />
|
||||
<xi:include href="xml/gtkfilechooserwidget.xml" />
|
||||
<xi:include href="xml/gtkfilefilter.xml" />
|
||||
<xi:include href="xml/gtkfontchooser.xml" />
|
||||
<xi:include href="xml/gtkfontbutton.xml" />
|
||||
<xi:include href="xml/gtkfontchooserwidget.xml" />
|
||||
|
||||
@@ -375,7 +375,7 @@ gtk_bitset_subtract
|
||||
gtk_bitset_difference
|
||||
gtk_bitset_shift_left
|
||||
gtk_bitset_shift_right
|
||||
gtk_bitset_splice
|
||||
gtk_bitset_slice
|
||||
<SUBSECTION>
|
||||
GtkBitsetIter
|
||||
gtk_bitset_iter_init_first
|
||||
@@ -423,7 +423,6 @@ gtk_selection_model_get_type
|
||||
GtkNoSelection
|
||||
gtk_no_selection_new
|
||||
gtk_no_selection_get_model
|
||||
gtk_no_selection_set_model
|
||||
<SUBSECTION Private>
|
||||
gtk_no_selection_get_type
|
||||
</SECTION>
|
||||
@@ -435,7 +434,6 @@ GtkSingleSelection
|
||||
GTK_INVALID_LIST_POSITION
|
||||
gtk_single_selection_new
|
||||
gtk_single_selection_get_model
|
||||
gtk_single_selection_set_model
|
||||
gtk_single_selection_get_selected
|
||||
gtk_single_selection_set_selected
|
||||
gtk_single_selection_get_selected_item
|
||||
@@ -452,8 +450,6 @@ gtk_single_selection_get_type
|
||||
<TITLE>GtkMultiSeledction</TITLE>
|
||||
GtkMultiSelection
|
||||
gtk_multi_selection_new
|
||||
gtk_multi_selection_get_model
|
||||
gtk_multi_selection_set_model
|
||||
<SUBSECTION Private>
|
||||
gtk_multi_selection_get_type
|
||||
</SECTION>
|
||||
@@ -1310,7 +1306,7 @@ gtk_file_chooser_get_current_folder
|
||||
<SUBSECTION>
|
||||
gtk_file_chooser_add_filter
|
||||
gtk_file_chooser_remove_filter
|
||||
gtk_file_chooser_get_filters
|
||||
gtk_file_chooser_list_filters
|
||||
gtk_file_chooser_set_filter
|
||||
gtk_file_chooser_get_filter
|
||||
<SUBSECTION>
|
||||
@@ -1413,13 +1409,18 @@ GtkFileChooserButtonPrivate
|
||||
<SECTION>
|
||||
<FILE>gtkfilefilter</FILE>
|
||||
GtkFileFilter
|
||||
GtkFileFilterInfo
|
||||
GtkFileFilterFlags
|
||||
GtkFileFilterFunc
|
||||
gtk_file_filter_new
|
||||
gtk_file_filter_set_name
|
||||
gtk_file_filter_get_name
|
||||
gtk_file_filter_add_mime_type
|
||||
gtk_file_filter_add_pattern
|
||||
gtk_file_filter_add_pixbuf_formats
|
||||
gtk_file_filter_get_attributes
|
||||
gtk_file_filter_add_custom
|
||||
gtk_file_filter_get_needed
|
||||
gtk_file_filter_filter
|
||||
|
||||
<SUBSECTION Serialization>
|
||||
gtk_file_filter_new_from_gvariant
|
||||
@@ -1538,6 +1539,7 @@ gtk_custom_filter_get_type
|
||||
<TITLE>GtkFilterListModel</TITLE>
|
||||
GtkFilterListModel
|
||||
gtk_filter_list_model_new
|
||||
gtk_filter_list_model_new_for_type
|
||||
gtk_filter_list_model_set_model
|
||||
gtk_filter_list_model_get_model
|
||||
gtk_filter_list_model_set_filter
|
||||
@@ -2699,6 +2701,7 @@ gtk_size_group_get_type
|
||||
<TITLE>GtkSliceListModel</TITLE>
|
||||
GtkSliceListModel
|
||||
gtk_slice_list_model_new
|
||||
gtk_slice_list_model_new_for_type
|
||||
gtk_slice_list_model_set_model
|
||||
gtk_slice_list_model_get_model
|
||||
gtk_slice_list_model_set_offset
|
||||
@@ -2830,6 +2833,7 @@ gtk_tree_list_row_sorter_get_type
|
||||
<TITLE>GtkSortListModel</TITLE>
|
||||
GtkSortListModel
|
||||
gtk_sort_list_model_new
|
||||
gtk_sort_list_model_new_for_type
|
||||
gtk_sort_list_model_set_sorter
|
||||
gtk_sort_list_model_get_sorter
|
||||
gtk_sort_list_model_set_model
|
||||
@@ -7609,18 +7613,6 @@ gtk_string_list_take
|
||||
gtk_string_list_remove
|
||||
gtk_string_list_splice
|
||||
gtk_string_list_get_string
|
||||
<SUBSECTION>
|
||||
GtkStringObject
|
||||
gtk_string_object_new
|
||||
gtk_string_object_get_string
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkselectionfiltermodel</FILE>
|
||||
<TITLE>GtkSelectionFilterModel</TITLE>
|
||||
GtkSelectionFilterModel
|
||||
gtk_selection_filter_model_new
|
||||
gtk_selection_filter_model_new_for_type
|
||||
gtk_selection_filter_model_set_model
|
||||
gtk_selection_filter_model_get_model
|
||||
</SECTION>
|
||||
|
||||
@@ -184,7 +184,6 @@ gtk_scrollbar_get_type
|
||||
gtk_scrolled_window_get_type
|
||||
gtk_search_bar_get_type
|
||||
gtk_search_entry_get_type
|
||||
gtk_selection_filter_model_get_type
|
||||
gtk_selection_model_get_type
|
||||
gtk_separator_get_type
|
||||
gtk_settings_get_type
|
||||
|
||||
@@ -411,7 +411,6 @@ and gtk_box_append(). You can also reorder box children as necessary.
|
||||
The gtk_header_bar_set_show_close_button() function has been renamed to
|
||||
the more accurate name gtk_header_bar_set_show_title_buttons(). The
|
||||
corresponding getter and the property itself have also been renamed.
|
||||
The default value of the property is now %TRUE instead of %FALSE.
|
||||
|
||||
The gtk_header_bar_set_custom_title() function has been renamed to
|
||||
the more accurate name gtk_header_bar_set_title_widget(). The
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child type="title">
|
||||
<object class="GtkStackSwitcher" id="tabs">
|
||||
<property name="stack">stack</property>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<property name="default-height">400</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="header">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lines_label">
|
||||
<property name="visible">0</property>
|
||||
|
||||
@@ -15,6 +15,7 @@ new_window (GApplication *app,
|
||||
gtk_window_set_icon_name (GTK_WINDOW (window), "sunny");
|
||||
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_window_set_titlebar (GTK_WINDOW (window), header);
|
||||
|
||||
overlay = gtk_overlay_new ();
|
||||
|
||||
@@ -1184,7 +1184,7 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
|
||||
if (timings)
|
||||
timings->drawn_time = frame_drawn_time;
|
||||
|
||||
if (!surface_impl->toplevel->frame_still_painting && surface_impl->toplevel->frame_pending)
|
||||
if (surface_impl->toplevel->frame_pending)
|
||||
{
|
||||
surface_impl->toplevel->frame_pending = FALSE;
|
||||
gdk_surface_thaw_updates (win);
|
||||
|
||||
+10
-49
@@ -582,23 +582,6 @@ create_legacy_context (GdkDisplay *display,
|
||||
}
|
||||
|
||||
#ifdef HAVE_XDAMAGE
|
||||
static void
|
||||
finish_frame (GdkGLContext *context)
|
||||
{
|
||||
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
||||
|
||||
if (context_x11->xdamage == 0)
|
||||
return;
|
||||
|
||||
if (context_x11->frame_fence == 0)
|
||||
return;
|
||||
|
||||
glDeleteSync (context_x11->frame_fence);
|
||||
context_x11->frame_fence = 0;
|
||||
_gdk_x11_surface_set_frame_still_painting (surface, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_context_for_frame_fence (GdkGLContext *context)
|
||||
{
|
||||
@@ -645,6 +628,7 @@ on_gl_surface_xevent (GdkGLContext *context,
|
||||
GdkX11Display *display_x11)
|
||||
{
|
||||
GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
||||
XDamageNotifyEvent *damage_xevent;
|
||||
|
||||
if (!context_x11->is_attached)
|
||||
@@ -691,7 +675,9 @@ on_gl_surface_xevent (GdkGLContext *context,
|
||||
case GL_WAIT_FAILED:
|
||||
if (wait_result == GL_WAIT_FAILED)
|
||||
g_warning ("failed to wait on GL fence associated with last swap buffers call");
|
||||
finish_frame (context);
|
||||
glDeleteSync (context_x11->frame_fence);
|
||||
context_x11->frame_fence = 0;
|
||||
_gdk_x11_surface_set_frame_still_painting (surface, FALSE);
|
||||
break;
|
||||
|
||||
/* We assume that if the fence hasn't been signaled, that this
|
||||
@@ -710,21 +696,6 @@ on_gl_surface_xevent (GdkGLContext *context,
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
on_surface_state_changed (GdkGLContext *context)
|
||||
{
|
||||
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
||||
|
||||
if ((surface->state & GDK_SURFACE_STATE_WITHDRAWN) == 0)
|
||||
return;
|
||||
|
||||
/* If we're about to withdraw the surface, then we don't care if the frame is
|
||||
* still getting rendered by the GPU. The compositor is going to remove the surface
|
||||
* from the scene anyway, so wrap up the frame.
|
||||
*/
|
||||
finish_frame (context);
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
@@ -907,23 +878,13 @@ gdk_x11_gl_context_realize (GdkGLContext *context,
|
||||
gdk_x11_surface_get_xid (surface),
|
||||
XDamageReportRawRectangles);
|
||||
if (gdk_x11_display_error_trap_pop (display))
|
||||
{
|
||||
context_x11->xdamage = 0;
|
||||
}
|
||||
context_x11->xdamage = 0;
|
||||
else
|
||||
{
|
||||
g_signal_connect_object (G_OBJECT (display),
|
||||
"xevent",
|
||||
G_CALLBACK (on_gl_surface_xevent),
|
||||
context,
|
||||
G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (G_OBJECT (surface),
|
||||
"notify::state",
|
||||
G_CALLBACK (on_surface_state_changed),
|
||||
context,
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
}
|
||||
g_signal_connect_object (G_OBJECT (display),
|
||||
"xevent",
|
||||
G_CALLBACK (on_gl_surface_xevent),
|
||||
context,
|
||||
G_CONNECT_SWAPPED);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+6
-16
@@ -2241,23 +2241,12 @@ render_cross_fade_node (GskGLRenderer *self,
|
||||
{
|
||||
GskRenderNode *start_node = gsk_cross_fade_node_get_start_child (node);
|
||||
GskRenderNode *end_node = gsk_cross_fade_node_get_end_child (node);
|
||||
const float progress = gsk_cross_fade_node_get_progress (node);
|
||||
float progress = gsk_cross_fade_node_get_progress (node);
|
||||
TextureRegion start_region;
|
||||
TextureRegion end_region;
|
||||
gboolean is_offscreen1, is_offscreen2;
|
||||
OpCrossFade *op;
|
||||
|
||||
if (progress <= 0)
|
||||
{
|
||||
gsk_gl_renderer_add_render_ops (self, start_node, builder);
|
||||
return;
|
||||
}
|
||||
else if (progress >= 1)
|
||||
{
|
||||
gsk_gl_renderer_add_render_ops (self, end_node, builder);
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: We create 2 textures here as big as the cross-fade node, but both the
|
||||
* start and the end node might be a lot smaller than that. */
|
||||
|
||||
@@ -2277,10 +2266,11 @@ render_cross_fade_node (GskGLRenderer *self,
|
||||
&end_region, &is_offscreen2,
|
||||
FORCE_OFFSCREEN | RESET_CLIP | RESET_OPACITY))
|
||||
{
|
||||
const float prev_opacity = ops_set_opacity (builder, builder->current_opacity * progress);
|
||||
gsk_gl_renderer_add_render_ops (self, start_node, builder);
|
||||
ops_set_opacity (builder, prev_opacity);
|
||||
|
||||
load_vertex_data_with_region (ops_draw (builder, NULL),
|
||||
node,
|
||||
builder,
|
||||
&start_region,
|
||||
TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -104,7 +104,7 @@ gsk_color_node_peek_color (GskRenderNode *node)
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_color_node_new:
|
||||
* gsk_color_node_new:
|
||||
* @rgba: a #GdkRGBA specifying a color
|
||||
* @bounds: the rectangle to render the color into
|
||||
*
|
||||
@@ -216,7 +216,7 @@ gsk_linear_gradient_node_diff (GskRenderNode *node1,
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gsk_render_node_diff_impossible (node1, node2, region);
|
||||
}
|
||||
|
||||
@@ -1163,7 +1163,7 @@ gsk_inset_shadow_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_inset_shadow_node_new:
|
||||
* gsk_inset_shadow_node_new:
|
||||
* @outline: outline of the region containing the shadow
|
||||
* @color: color of the shadow
|
||||
* @dx: horizontal offset of shadow
|
||||
@@ -1465,7 +1465,7 @@ gsk_outset_shadow_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_outset_shadow_node_new:
|
||||
* gsk_outset_shadow_node_new:
|
||||
* @outline: outline of the region surrounded by shadow
|
||||
* @color: color of the shadow
|
||||
* @dx: horizontal offset of shadow
|
||||
@@ -1672,7 +1672,7 @@ gsk_cairo_node_peek_surface (GskRenderNode *node)
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_cairo_node_new:
|
||||
* gsk_cairo_node_new:
|
||||
* @bounds: the rectangle to render to
|
||||
*
|
||||
* Creates a #GskRenderNode that will render a cairo surface
|
||||
@@ -1982,7 +1982,7 @@ gsk_transform_node_draw (GskRenderNode *node,
|
||||
ctm.xy, ctm.yy,
|
||||
ctm.x0, ctm.y0));
|
||||
cairo_transform (cr, &ctm);
|
||||
|
||||
|
||||
gsk_render_node_draw (self->child, cr);
|
||||
}
|
||||
|
||||
@@ -2062,7 +2062,7 @@ gsk_transform_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_transform_node_new:
|
||||
* gsk_transform_node_new:
|
||||
* @child: The node to transform
|
||||
* @transform: (transfer none): The transform to apply
|
||||
*
|
||||
@@ -2188,7 +2188,7 @@ gsk_opacity_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_opacity_node_new:
|
||||
* gsk_opacity_node_new:
|
||||
* @child: The node to draw
|
||||
* @opacity: The opacity to apply
|
||||
*
|
||||
@@ -2380,7 +2380,7 @@ nope:
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_color_matrix_node_new:
|
||||
* gsk_color_matrix_node_new:
|
||||
* @child: The node to draw
|
||||
* @color_matrix: The matrix to apply
|
||||
* @color_offset: Values to add to the color
|
||||
@@ -2533,7 +2533,7 @@ gsk_repeat_node_draw (GskRenderNode *node,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_repeat_node_new:
|
||||
* gsk_repeat_node_new:
|
||||
* @bounds: The bounds of the area to be painted
|
||||
* @child: The child to repeat
|
||||
* @child_bounds: (allow-none): The area of the child to repeat or %NULL to
|
||||
@@ -2670,7 +2670,7 @@ gsk_clip_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_clip_node_new:
|
||||
* gsk_clip_node_new:
|
||||
* @child: The node to draw
|
||||
* @clip: The clip to apply
|
||||
*
|
||||
@@ -2800,7 +2800,7 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_rounded_clip_node_new:
|
||||
* gsk_rounded_clip_node_new:
|
||||
* @child: The node to draw
|
||||
* @clip: The clip to apply
|
||||
*
|
||||
@@ -3013,7 +3013,7 @@ gsk_shadow_node_get_bounds (GskShadowNode *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_shadow_node_new:
|
||||
* gsk_shadow_node_new:
|
||||
* @child: The node to draw
|
||||
* @shadows: (array length=n_shadows): The shadows to apply
|
||||
* @n_shadows: number of entries in the @shadows array
|
||||
@@ -3210,7 +3210,7 @@ gsk_blend_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_blend_node_new:
|
||||
* gsk_blend_node_new:
|
||||
* @bottom: The bottom node to be drawn
|
||||
* @top: The node to be blended onto the @bottom node
|
||||
* @blend_mode: The blend mode to use
|
||||
@@ -3359,7 +3359,7 @@ gsk_cross_fade_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_cross_fade_node_new:
|
||||
* gsk_cross_fade_node_new:
|
||||
* @start: The start node to be drawn
|
||||
* @end: The node to be cross_fadeed onto the @start node
|
||||
* @progress: How far the fade has progressed from start to end. The value will
|
||||
@@ -3549,7 +3549,7 @@ font_has_color_glyphs (const PangoFont *font)
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_text_node_new:
|
||||
* gsk_text_node_new:
|
||||
* @font: the #PangoFont containing the glyphs
|
||||
* @glyphs: the #PangoGlyphString to render
|
||||
* @color: the foreground color to render with
|
||||
@@ -3953,7 +3953,7 @@ gsk_blur_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_blur_node_new:
|
||||
* gsk_blur_node_new:
|
||||
* @child: the child node to blur
|
||||
* @radius: the blur radius
|
||||
*
|
||||
@@ -4076,9 +4076,9 @@ gsk_debug_node_diff (GskRenderNode *node1,
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_debug_node_new:
|
||||
* gsk_debug_node_new:
|
||||
* @child: The child to add debug info for
|
||||
* @message: (transfer full): The debug message
|
||||
* @message: (transfer full): The debug message
|
||||
*
|
||||
* Creates a #GskRenderNode that will add debug information about
|
||||
* the given @child.
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
#include <gtk/gtkfontchooserdialog.h>
|
||||
#include <gtk/gtkfontchooserwidget.h>
|
||||
#include <gtk/gtkframe.h>
|
||||
#include <gtk/gtkfunctionslistitemfactory.h>
|
||||
#include <gtk/gtkgesture.h>
|
||||
#include <gtk/gtkgestureclick.h>
|
||||
#include <gtk/gtkgesturedrag.h>
|
||||
@@ -213,7 +214,6 @@
|
||||
#include <gtk/gtkscrolledwindow.h>
|
||||
#include <gtk/gtksearchbar.h>
|
||||
#include <gtk/gtksearchentry.h>
|
||||
#include <gtk/gtkselectionfiltermodel.h>
|
||||
#include <gtk/gtkselectionmodel.h>
|
||||
#include <gtk/gtkseparator.h>
|
||||
#include <gtk/gtksettings.h>
|
||||
@@ -233,8 +233,6 @@
|
||||
#include <gtk/gtkslicelistmodel.h>
|
||||
#include <gtk/gtksnapshot.h>
|
||||
#include <gtk/gtksorter.h>
|
||||
#include <gtk/gtksor2listmodel.h>
|
||||
#include <gtk/gtksor3listmodel.h>
|
||||
#include <gtk/gtksortlistmodel.h>
|
||||
#include <gtk/gtkstacksidebar.h>
|
||||
#include <gtk/gtksizegroup.h>
|
||||
|
||||
@@ -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
|
||||
+6
-6
@@ -707,7 +707,7 @@ gtk_bitset_shift_right (GtkBitset *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_bitset_splice:
|
||||
* gtk_bitset_slice:
|
||||
* @self: a #GtkBitset
|
||||
* @position: position at which to slice
|
||||
* @removed: number of values to remove
|
||||
@@ -725,10 +725,10 @@ gtk_bitset_shift_right (GtkBitset *self,
|
||||
* up space that can then be filled.
|
||||
**/
|
||||
void
|
||||
gtk_bitset_splice (GtkBitset *self,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added)
|
||||
gtk_bitset_slice (GtkBitset *self,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
/* overflow */
|
||||
@@ -742,7 +742,7 @@ gtk_bitset_splice (GtkBitset *self,
|
||||
GtkBitset *shift = gtk_bitset_copy (self);
|
||||
|
||||
gtk_bitset_remove_range (shift, 0, position);
|
||||
gtk_bitset_remove_range_closed (self, position, G_MAXUINT);
|
||||
gtk_bitset_remove_range (self, position, G_MAXUINT - position + 1);
|
||||
if (added > removed)
|
||||
gtk_bitset_shift_right (shift, added - removed);
|
||||
else
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_bitset_shift_right (GtkBitset *self,
|
||||
guint amount);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_bitset_splice (GtkBitset *self,
|
||||
void gtk_bitset_slice (GtkBitset *self,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
/**
|
||||
* SECTION:gtkbuilderlistitemfactory
|
||||
* @Title: GtkBuilderListItemFactory
|
||||
* @Tiitle: GtkBuilderListItemFactory
|
||||
* @Short_description: A listitem factory using ui files
|
||||
*
|
||||
* #GtkBuilderListItemFactory is a #GtkListItemFactory that creates
|
||||
|
||||
+2
-2
@@ -940,7 +940,7 @@ header_drag_end (GtkGestureDrag *gesture,
|
||||
|
||||
column = g_list_model_get_item (G_LIST_MODEL (self->columns), self->drag_pos);
|
||||
header = gtk_column_view_column_get_header (column);
|
||||
gtk_widget_remove_css_class (header, "dnd");
|
||||
gtk_style_context_remove_class (gtk_widget_get_style_context (header), "dnd");
|
||||
|
||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||
if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
|
||||
@@ -1027,7 +1027,7 @@ header_drag_update (GtkGestureDrag *gesture,
|
||||
header = gtk_column_view_column_get_header (column);
|
||||
|
||||
gtk_widget_insert_after (header, self->header, gtk_widget_get_last_child (self->header));
|
||||
gtk_widget_add_css_class (header, "dnd");
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (header), "dnd");
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
if (!gtk_widget_has_focus (GTK_WIDGET (self)))
|
||||
|
||||
+15
-13
@@ -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
@@ -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);
|
||||
|
||||
@@ -21,12 +21,7 @@
|
||||
#include "gtk/gtkcountingbloomfilterprivate.h"
|
||||
#include "gtk/gtkcsstypesprivate.h"
|
||||
#include "gtk/gtkcssparserprivate.h"
|
||||
|
||||
#define GTK_VECTOR_ELEMENT_TYPE gpointer
|
||||
#define GTK_VECTOR_TYPE_NAME GtkCssSelectorMatches
|
||||
#define GTK_VECTOR_NAME gtk_css_selector_matches
|
||||
#define GTK_VECTOR_PREALLOC 32
|
||||
#include "gtk/gtkvectorimpl.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);
|
||||
|
||||
@@ -321,7 +321,7 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
|
||||
g_list_store_append (printer_list_list, printer_list);
|
||||
g_object_unref (printer_list);
|
||||
|
||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
|
||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (GTK_TYPE_PRINTER, G_LIST_MODEL (printer_list_list)));
|
||||
g_object_unref (printer_list_list);
|
||||
|
||||
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||
|
||||
@@ -224,7 +224,7 @@ gtk_drop_controller_motion_class_init (GtkDropControllerMotionClass *klass)
|
||||
props[PROP_CONTAINS_POINTER] =
|
||||
g_param_spec_boolean ("contains-pointer",
|
||||
P_("Contains Pointer"),
|
||||
P_("Whether the pointer is in the controllers widget or a descendant"),
|
||||
P_("Whether the pointer is inthe controllers widget or a descendant"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ gtk_event_controller_motion_class_init (GtkEventControllerMotionClass *klass)
|
||||
props[PROP_CONTAINS_POINTER] =
|
||||
g_param_spec_boolean ("contains-pointer",
|
||||
P_("Contains Pointer"),
|
||||
P_("Whether the pointer is in the controllers widget or a descendant"),
|
||||
P_("Whether the pointer is inthe controllers widget or a descendant"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE);
|
||||
|
||||
|
||||
+11
-44
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright © 2019 Benjamin Otte
|
||||
*
|
||||
@@ -29,50 +28,18 @@
|
||||
* @Short_description: Expressions to values
|
||||
* @Title: GtkExpression
|
||||
*
|
||||
* GtkExpression provides a way to describe references to values.
|
||||
* GtkExpression provides a way to describe references to #GValues.
|
||||
*
|
||||
* An important aspect of expressions is that the value can be obtained
|
||||
* from a source that is several steps away. For example, an expression
|
||||
* may describe ‘the value of property A of @object1, which is itself the
|
||||
* value of a property of @object2’. And @object1 may not even exist yet
|
||||
* at the time that the expression is created. This is contrast to GObject
|
||||
* property bindings, which can only create direct connections between
|
||||
* the properties of two objects that must both exist for the duration
|
||||
* of the binding.
|
||||
*
|
||||
* An expression needs to be "evaluated" to obtain the value that it currently
|
||||
* refers to. An evaluation always happens in the context of a current object
|
||||
* called `this` (it mirrors the behavior of object-oriented languages),
|
||||
* which may or may not influence the result of the evaluation. Use
|
||||
* gtk_expression_evaluate() for evaluating an expression.
|
||||
* An expression needs to be "evaluated" to obtain the value that it currently refers
|
||||
* to. An evaluation always happens in the context of a current object called `this`
|
||||
* (it mirrors the behavior of object-oriented languages), which may or may not
|
||||
* influence the result of the evaluation. Use gtk_expression_evaluate() for
|
||||
* evaluating an expression.
|
||||
*
|
||||
* Various methods for defining expressions exist, from simple constants via
|
||||
* gtk_constant_expression_new() to looking up properties in a #GObject (even
|
||||
* recursively) via gtk_property_expression_new() or providing custom functions
|
||||
* to transform and combine expressions via gtk_closure_expression_new().
|
||||
*
|
||||
* 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");
|
||||
* ]|
|
||||
* 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
|
||||
* ]|
|
||||
*
|
||||
* 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 a similar reason.
|
||||
* recursively) via gtk_property_expression_new() or providing custom functions to
|
||||
* transform and combine expressions via gtk_closure_expression_new().
|
||||
*
|
||||
* 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
|
||||
@@ -1570,12 +1537,12 @@ GTK_DEFINE_EXPRESSION_TYPE (GtkCClosureExpression,
|
||||
/**
|
||||
* gtk_cclosure_expression_new:
|
||||
* @value_type: the type of the value that this expression evaluates to
|
||||
* @marshal: (scope call) (nullable): marshaller used for creating a closure
|
||||
* @marshal: (scope call): marshaller used for creating a closure
|
||||
* @n_params: the number of params needed for evaluating @closure
|
||||
* @params: (array length=n_params) (transfer full): expressions for each parameter
|
||||
* @callback_func: (scope notified) (closure user_data) (destroy user_destroy): callback used for creating a closure
|
||||
* @user_data: (nullable): user data used for creating a closure
|
||||
* @user_destroy: (nullable): destroy notify for @user_data
|
||||
* @user_data: user data used for creating a closure
|
||||
* @user_destroy: destroy notify for @user_data
|
||||
*
|
||||
* This function is a variant of gtk_closure_expression_new() that
|
||||
* creates a #GClosure by calling gtk_cclosure_new() with the given
|
||||
|
||||
+15
-50
@@ -168,38 +168,6 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkFileChooser:filters:
|
||||
*
|
||||
* A #GListModel containing the filters that have been
|
||||
* added with gtk_file_chooser_add_filter().
|
||||
*
|
||||
* The returned object should not be modified. It may
|
||||
* or may not be updated for later changes.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("filters",
|
||||
P_("Filters"),
|
||||
P_("List model of filters"),
|
||||
G_TYPE_LIST_MODEL,
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* GtkFileChooser:shortcut-folders:
|
||||
*
|
||||
* A #GListModel containing the shortcut folders that have been
|
||||
* added with gtk_file_chooser_add_shortcut().
|
||||
*
|
||||
* The returned object should not be modified. It may
|
||||
* or may not be updated for later changes.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("shortcut-folders",
|
||||
P_("Shortcut Folders"),
|
||||
P_("List model of shortcut folders"),
|
||||
G_TYPE_LIST_MODEL,
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* GtkFileChooser:create-folders:
|
||||
*
|
||||
@@ -714,24 +682,23 @@ gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_chooser_get_filters:
|
||||
* gtk_file_chooser_list_filters:
|
||||
* @chooser: a #GtkFileChooser
|
||||
*
|
||||
* Gets the current set of user-selectable filters, as a list model; see
|
||||
* Lists the current set of user-selectable filters; see
|
||||
* gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
|
||||
*
|
||||
* You should not modify the returned list model. Future changes to
|
||||
* @chooser may or may not affect the returned model.
|
||||
*
|
||||
* Returns: (transfer full): a #GListModel containing the current set
|
||||
* of user-selectable filters.
|
||||
* Returns: (element-type GtkFileFilter) (transfer container): a
|
||||
* #GSList containing the current set of user selectable filters. The
|
||||
* contents of the list are owned by GTK+, but you must free the list
|
||||
* itself with g_slist_free() when you are done with it.
|
||||
**/
|
||||
GListModel *
|
||||
gtk_file_chooser_get_filters (GtkFileChooser *chooser)
|
||||
GSList *
|
||||
gtk_file_chooser_list_filters (GtkFileChooser *chooser)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
|
||||
|
||||
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_filters (chooser);
|
||||
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -783,23 +750,21 @@ gtk_file_chooser_get_filter (GtkFileChooser *chooser)
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_chooser_get_shortcut_folders:
|
||||
* gtk_file_chooser_list_shortcut_folders:
|
||||
* @chooser: a #GtkFileChooser
|
||||
*
|
||||
* Queries the list of shortcut folders in the file chooser, as set by
|
||||
* gtk_file_chooser_add_shortcut_folder().
|
||||
*
|
||||
* You should not modify the returned list model. Future changes to
|
||||
* @chooser may or may not affect the returned model.
|
||||
*
|
||||
* Returns: (transfer full): A list model of #GFiles
|
||||
* Returns: (nullable) (element-type Gio.File) (transfer full): A list
|
||||
* of folder filenames, or %NULL if there are no shortcut folders.
|
||||
*/
|
||||
GListModel *
|
||||
gtk_file_chooser_get_shortcut_folders (GtkFileChooser *chooser)
|
||||
GSList *
|
||||
gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
|
||||
|
||||
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_shortcut_folders (chooser);
|
||||
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -145,18 +145,18 @@ GFile * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_add_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel *gtk_file_chooser_get_filters (GtkFileChooser *chooser);
|
||||
GSList *gtk_file_chooser_list_filters (GtkFileChooser *chooser);
|
||||
|
||||
/* Current filter
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_set_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
|
||||
|
||||
@@ -164,14 +164,14 @@ GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *folder,
|
||||
GError **error);
|
||||
GFile *folder,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *folder,
|
||||
GError **error);
|
||||
GFile *folder,
|
||||
GError **error);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel *gtk_file_chooser_get_shortcut_folders (GtkFileChooser *chooser);
|
||||
GSList *gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_chooser_add_choice (GtkFileChooser *chooser,
|
||||
|
||||
@@ -1035,8 +1035,6 @@ gtk_file_chooser_button_get_property (GObject *object,
|
||||
case GTK_FILE_CHOOSER_PROP_FILTER:
|
||||
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
|
||||
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
|
||||
case GTK_FILE_CHOOSER_PROP_FILTERS:
|
||||
case GTK_FILE_CHOOSER_PROP_SHORTCUT_FOLDERS:
|
||||
g_object_get_property (G_OBJECT (button->chooser), pspec->name, value);
|
||||
break;
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkfilefilterprivate.h"
|
||||
#include "gtkfilter.h"
|
||||
#include "gtkeventcontrollerfocus.h"
|
||||
|
||||
typedef struct _GtkFileChooserEntryClass GtkFileChooserEntryClass;
|
||||
@@ -195,22 +194,65 @@ match_func (GtkEntryCompletion *compl,
|
||||
* current file filter (e.g. just jpg files) here. */
|
||||
if (chooser_entry->current_filter != NULL)
|
||||
{
|
||||
char *mime_type = NULL;
|
||||
gboolean matches;
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
GFileInfo *file_info;
|
||||
GtkFileFilterInfo filter_info;
|
||||
GtkFileFilterFlags needed_flags;
|
||||
|
||||
file = _gtk_file_system_model_get_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
iter);
|
||||
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
iter);
|
||||
file_info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
iter);
|
||||
|
||||
/* We always allow navigating into subfolders, so don't ever filter directories */
|
||||
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
|
||||
if (g_file_info_get_file_type (file_info) != G_FILE_TYPE_REGULAR)
|
||||
return TRUE;
|
||||
|
||||
if (!g_file_info_has_attribute (info, "standard::file"))
|
||||
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
|
||||
needed_flags = gtk_file_filter_get_needed (chooser_entry->current_filter);
|
||||
|
||||
return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
|
||||
filter_info.display_name = g_file_info_get_display_name (file_info);
|
||||
filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME;
|
||||
|
||||
if (needed_flags & GTK_FILE_FILTER_MIME_TYPE)
|
||||
{
|
||||
const char *s = g_file_info_get_content_type (file_info);
|
||||
if (s != NULL)
|
||||
{
|
||||
mime_type = g_content_type_get_mime_type (s);
|
||||
if (mime_type != NULL)
|
||||
{
|
||||
filter_info.mime_type = mime_type;
|
||||
filter_info.contains |= GTK_FILE_FILTER_MIME_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needed_flags & GTK_FILE_FILTER_FILENAME)
|
||||
{
|
||||
const char *path = g_file_get_path (file);
|
||||
if (path != NULL)
|
||||
{
|
||||
filter_info.filename = path;
|
||||
filter_info.contains |= GTK_FILE_FILTER_FILENAME;
|
||||
}
|
||||
}
|
||||
|
||||
if (needed_flags & GTK_FILE_FILTER_URI)
|
||||
{
|
||||
const char *uri = g_file_get_uri (file);
|
||||
if (uri)
|
||||
{
|
||||
filter_info.uri = uri;
|
||||
filter_info.contains |= GTK_FILE_FILTER_URI;
|
||||
}
|
||||
}
|
||||
|
||||
matches = gtk_file_filter_filter (chooser_entry->current_filter, &filter_info);
|
||||
|
||||
g_free (mime_type);
|
||||
return matches;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -126,7 +126,7 @@ response_cb (GDBusConnection *connection,
|
||||
if (current_filter)
|
||||
{
|
||||
GtkFileFilter *filter = gtk_file_filter_new_from_gvariant (current_filter);
|
||||
const char *current_filter_name = gtk_file_filter_get_name (filter);
|
||||
const gchar *current_filter_name = gtk_file_filter_get_name (filter);
|
||||
|
||||
/* Try to find the given filter in the list of filters.
|
||||
* Since filters are compared by pointer value, using the passed
|
||||
@@ -137,24 +137,18 @@ response_cb (GDBusConnection *connection,
|
||||
* If there is no match, just set the filter as it was retrieved.
|
||||
*/
|
||||
GtkFileFilter *filter_to_select = filter;
|
||||
GListModel *filters;
|
||||
guint j, n;
|
||||
|
||||
filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (self));
|
||||
n = g_list_model_get_n_items (filters);
|
||||
for (j = 0; j < n; j++)
|
||||
GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (self));
|
||||
for (GSList *l = filters; l; l = l->next)
|
||||
{
|
||||
GtkFileFilter *f = g_list_model_get_item (filters, j);
|
||||
GtkFileFilter *f = l->data;
|
||||
if (g_strcmp0 (gtk_file_filter_get_name (f), current_filter_name) == 0)
|
||||
{
|
||||
filter_to_select = f;
|
||||
break;
|
||||
}
|
||||
g_object_unref (f);
|
||||
}
|
||||
g_object_unref (filters);
|
||||
g_slist_free (filters);
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (self), filter_to_select);
|
||||
g_object_unref (filter_to_select);
|
||||
}
|
||||
|
||||
g_slist_free_full (self->custom_files, g_object_unref);
|
||||
@@ -270,20 +264,17 @@ open_file_msg_cb (GObject *source_object,
|
||||
static GVariant *
|
||||
get_filters (GtkFileChooser *self)
|
||||
{
|
||||
GListModel *filters;
|
||||
guint n, i;
|
||||
GSList *list, *l;
|
||||
GVariantBuilder builder;
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(sa(us))"));
|
||||
filters = gtk_file_chooser_get_filters (self);
|
||||
n = g_list_model_get_n_items (filters);
|
||||
for (i = 0; i < n; i++)
|
||||
list = gtk_file_chooser_list_filters (self);
|
||||
for (l = list; l; l = l->next)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (filters, i);
|
||||
GtkFileFilter *filter = l->data;
|
||||
g_variant_builder_add (&builder, "@(sa(us))", gtk_file_filter_to_gvariant (filter));
|
||||
g_object_unref (filter);
|
||||
}
|
||||
g_object_unref (filters);
|
||||
g_slist_free (list);
|
||||
|
||||
return g_variant_builder_end (&builder);
|
||||
}
|
||||
|
||||
@@ -99,10 +99,9 @@ typedef struct {
|
||||
else
|
||||
[data->panel setAllowedFileTypes:filter];
|
||||
|
||||
GListModel *filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (data->self));
|
||||
data->self->current_filter = g_list_model_get_item (filters, selected_index);
|
||||
g_object_unref (data->self->current_filter);
|
||||
g_object_unref (filters);
|
||||
GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (data->self));
|
||||
data->self->current_filter = g_slist_nth_data (filters, selected_index);
|
||||
g_slist_free (filters);
|
||||
g_object_notify (G_OBJECT (data->self), "filter");
|
||||
}
|
||||
@end
|
||||
@@ -308,28 +307,13 @@ filechooser_quartz_launch (FileChooserQuartzData *data)
|
||||
|
||||
if (data->self->current_filter)
|
||||
{
|
||||
GListModel *filters;
|
||||
guint i, n;
|
||||
guint current_filter_index = GTK_INVALID_LIST_POSITION;
|
||||
GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (data->self));
|
||||
gint current_filter_index = g_slist_index (filters, data->self->current_filter);
|
||||
g_slist_free (filters);
|
||||
|
||||
filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (data->self));
|
||||
n = g_list_model_get_n_items (filters);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
gpointer item = g_list_model_get_item (filters, i);
|
||||
if (item == data->self->current_filter)
|
||||
{
|
||||
g_object_unref (item);
|
||||
current_filter_index = i;
|
||||
break;
|
||||
}
|
||||
g_object_unref (item);
|
||||
}
|
||||
g_object_unref (filters);
|
||||
|
||||
if (current_filter_index != GTK_INVALID_LIST_POSITION)
|
||||
if (current_filter_index >= 0)
|
||||
[data->filter_combo_box selectItemAtIndex:current_filter_index];
|
||||
else
|
||||
else
|
||||
[data->filter_combo_box selectItemAtIndex:0];
|
||||
}
|
||||
else
|
||||
@@ -453,15 +437,15 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
GtkWindow *transient_for;
|
||||
GtkFileChooserAction action;
|
||||
|
||||
GListModel *filters;
|
||||
guint n_filters, i;
|
||||
GSList *filters, *l;
|
||||
int n_filters, i;
|
||||
char *message = NULL;
|
||||
|
||||
data = g_new0 (FileChooserQuartzData, 1);
|
||||
|
||||
// examine filters!
|
||||
filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (self));
|
||||
n_filters = g_list_model_get_n_items (filters);
|
||||
filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (self));
|
||||
n_filters = g_slist_length (filters);
|
||||
if (n_filters > 0)
|
||||
{
|
||||
data->filters = [NSMutableArray arrayWithCapacity:n_filters];
|
||||
@@ -469,17 +453,13 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
data->filter_names = [NSMutableArray arrayWithCapacity:n_filters];
|
||||
[data->filter_names retain];
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (l = filters, i = 0; l != NULL; l = l->next, i++)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (filters, i);
|
||||
if (!file_filter_to_quartz (filter, data->filters, data->filter_names))
|
||||
if (!file_filter_to_quartz (l->data, data->filters, data->filter_names))
|
||||
{
|
||||
filechooser_quartz_data_free (data);
|
||||
g_object_unref (filter);
|
||||
g_object_unref (filters);
|
||||
return FALSE;
|
||||
}
|
||||
g_object_unref (filter);
|
||||
}
|
||||
self->current_filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (self));
|
||||
}
|
||||
@@ -487,8 +467,6 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
{
|
||||
self->current_filter = NULL;
|
||||
}
|
||||
g_object_unref (filters);
|
||||
|
||||
self->mode_data = data;
|
||||
data->self = g_object_ref (self);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ typedef struct {
|
||||
char *cancel_label;
|
||||
char *title;
|
||||
|
||||
GListModel *shortcut_files;
|
||||
GSList *shortcut_files;
|
||||
GArray *choices_selections;
|
||||
|
||||
GFile *current_folder;
|
||||
@@ -244,11 +244,9 @@ ifiledialogevents_OnTypeChange (IFileDialogEvents * self,
|
||||
return S_OK;
|
||||
}
|
||||
fileType--; // fileTypeIndex starts at 1
|
||||
GListModel *filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (events->data->self));
|
||||
GtkFileFilter *filter = g_list_model_get_item (filters, fileType);
|
||||
events->data->self->current_filter = filter;
|
||||
g_object_unref (filter);
|
||||
g_object_unref (filters);
|
||||
GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (events->data->self));
|
||||
events->data->self->current_filter = g_slist_nth_data (filters, fileType);
|
||||
g_slist_free (filters);
|
||||
g_object_notify (G_OBJECT (events->data->self), "filter");
|
||||
return S_OK;
|
||||
}
|
||||
@@ -330,7 +328,7 @@ filechooser_win32_thread_data_free (FilechooserWin32ThreadData *data)
|
||||
g_array_free (data->choices_selections, TRUE);
|
||||
data->choices_selections = NULL;
|
||||
}
|
||||
g_object_unref (data->shortcut_files);
|
||||
g_slist_free_full (data->shortcut_files, g_object_unref);
|
||||
g_slist_free_full (data->files, g_object_unref);
|
||||
if (data->self)
|
||||
g_object_unref (data->self);
|
||||
@@ -465,7 +463,7 @@ filechooser_win32_thread (gpointer _data)
|
||||
IFileDialog2 *pfd2 = NULL;
|
||||
DWORD flags;
|
||||
DWORD cookie;
|
||||
guint j, n_items;
|
||||
GSList *l;
|
||||
|
||||
CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
|
||||
|
||||
@@ -531,11 +529,9 @@ filechooser_win32_thread (gpointer _data)
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
n_items = g_list_model_get_n_items (data->shortcut_files);
|
||||
for (j = 0; j < n_items; j++)
|
||||
for (l = data->shortcut_files; l != NULL; l = l->next)
|
||||
{
|
||||
GFile *file = g_list_model_get_item (data->shortcut_files, j);
|
||||
IShellItem *item = get_shell_item_for_file (file);
|
||||
IShellItem *item = get_shell_item_for_file (l->data);
|
||||
if (item)
|
||||
{
|
||||
hr = IFileDialog_AddPlace (pfd, item, FDAP_BOTTOM);
|
||||
@@ -543,7 +539,6 @@ filechooser_win32_thread (gpointer _data)
|
||||
g_warning_hr ("Can't add dialog shortcut", hr);
|
||||
IShellItem_Release (item);
|
||||
}
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
if (data->current_file)
|
||||
@@ -596,23 +591,9 @@ filechooser_win32_thread (gpointer _data)
|
||||
|
||||
if (data->self->current_filter)
|
||||
{
|
||||
GListModel *filters;
|
||||
guint current_filter_index = GTK_INVALID_LIST_POSITION;
|
||||
|
||||
filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (data->self));
|
||||
n_items = g_list_model_get_n_items (filters);
|
||||
for (j = 0; j < n_items; j++)
|
||||
{
|
||||
gpointer item = g_list_model_get_item (filters, j);
|
||||
if (item == data->self->current_filter)
|
||||
{
|
||||
current_filter_index = j;
|
||||
g_object_unref (item);
|
||||
break;
|
||||
}
|
||||
g_object_unref (item);
|
||||
}
|
||||
g_object_unref (filters);
|
||||
GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (data->self));
|
||||
gint current_filter_index = g_slist_index (filters, data->self->current_filter);
|
||||
g_slist_free (filters);
|
||||
|
||||
if (current_filter_index >= 0)
|
||||
hr = IFileDialog_SetFileTypeIndex (pfd, current_filter_index + 1);
|
||||
@@ -636,8 +617,6 @@ filechooser_win32_thread (gpointer _data)
|
||||
hr = IFileDialog_QueryInterface (pfd, &IID_IFileDialogCustomize, (LPVOID *) &pfdc);
|
||||
if (SUCCEEDED (hr))
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = data->self->choices; l; l = l->next, dialog_control_id++)
|
||||
{
|
||||
GtkFileChooserNativeChoice *choice = (GtkFileChooserNativeChoice*) l->data;
|
||||
@@ -763,8 +742,6 @@ filechooser_win32_thread (gpointer _data)
|
||||
hr = IFileDialog_QueryInterface (pfd, &IID_IFileDialogCustomize, (LPVOID *) &pfdc);
|
||||
if (SUCCEEDED (hr))
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = data->self->choices; l; l = l->next)
|
||||
{
|
||||
GtkFileChooserNativeChoice *choice = (GtkFileChooserNativeChoice*) l->data;
|
||||
@@ -887,24 +864,21 @@ gtk_file_chooser_native_win32_show (GtkFileChooserNative *self)
|
||||
FilechooserWin32ThreadData *data;
|
||||
GtkWindow *transient_for;
|
||||
GtkFileChooserAction action;
|
||||
GListModel *filters;
|
||||
guint n_filters, i;
|
||||
GSList *filters, *l;
|
||||
int n_filters, i;
|
||||
|
||||
data = g_new0 (FilechooserWin32ThreadData, 1);
|
||||
|
||||
filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (self));
|
||||
n_filters = g_list_model_get_n_items (filters);
|
||||
filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (self));
|
||||
n_filters = g_slist_length (filters);
|
||||
if (n_filters > 0)
|
||||
{
|
||||
data->filters = g_new0 (COMDLG_FILTERSPEC, n_filters + 1);
|
||||
|
||||
for (i = 0; i < n_filters; i++)
|
||||
for (l = filters, i = 0; l != NULL; l = l->next, i++)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (filters, i);
|
||||
if (!file_filter_to_win32 (filter, &data->filters[i]))
|
||||
if (!file_filter_to_win32 (l->data, &data->filters[i]))
|
||||
{
|
||||
g_object_unref (filter);
|
||||
g_object_unref (filters);
|
||||
filechooser_win32_thread_data_free (data);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -915,13 +889,12 @@ gtk_file_chooser_native_win32_show (GtkFileChooserNative *self)
|
||||
{
|
||||
self->current_filter = NULL;
|
||||
}
|
||||
g_object_unref (filters);
|
||||
|
||||
self->mode_data = data;
|
||||
data->self = g_object_ref (self);
|
||||
|
||||
data->shortcut_files =
|
||||
gtk_file_chooser_get_shortcut_folders (GTK_FILE_CHOOSER (self->dialog));
|
||||
gtk_file_chooser_list_shortcut_folders (GTK_FILE_CHOOSER (self->dialog));
|
||||
|
||||
data->accept_label = translate_mnemonics (self->accept_label);
|
||||
data->cancel_label = translate_mnemonics (self->cancel_label);
|
||||
|
||||
+25
-25
@@ -58,34 +58,34 @@ struct _GtkFileChooserIface
|
||||
|
||||
/* Methods
|
||||
*/
|
||||
gboolean (*set_current_folder) (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GFile * (*get_current_folder) (GtkFileChooser *chooser);
|
||||
void (*set_current_name) (GtkFileChooser *chooser,
|
||||
const gchar *name);
|
||||
gboolean (*set_current_folder) (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GFile * (*get_current_folder) (GtkFileChooser *chooser);
|
||||
void (*set_current_name) (GtkFileChooser *chooser,
|
||||
const gchar *name);
|
||||
gchar * (*get_current_name) (GtkFileChooser *chooser);
|
||||
gboolean (*select_file) (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
void (*unselect_file) (GtkFileChooser *chooser,
|
||||
GFile *file);
|
||||
void (*select_all) (GtkFileChooser *chooser);
|
||||
void (*unselect_all) (GtkFileChooser *chooser);
|
||||
GSList * (*get_files) (GtkFileChooser *chooser);
|
||||
GtkFileSystem *(*get_file_system) (GtkFileChooser *chooser);
|
||||
void (*add_filter) (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
void (*remove_filter) (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GListModel * (*get_filters) (GtkFileChooser *chooser);
|
||||
gboolean (*select_file) (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
void (*unselect_file) (GtkFileChooser *chooser,
|
||||
GFile *file);
|
||||
void (*select_all) (GtkFileChooser *chooser);
|
||||
void (*unselect_all) (GtkFileChooser *chooser);
|
||||
GSList * (*get_files) (GtkFileChooser *chooser);
|
||||
GtkFileSystem *(*get_file_system) (GtkFileChooser *chooser);
|
||||
void (*add_filter) (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
void (*remove_filter) (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
GSList * (*list_filters) (GtkFileChooser *chooser);
|
||||
gboolean (*add_shortcut_folder) (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GFile *file,
|
||||
GError **error);
|
||||
gboolean (*remove_shortcut_folder) (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GListModel * (*get_shortcut_folders) (GtkFileChooser *chooser);
|
||||
GFile *file,
|
||||
GError **error);
|
||||
GSList * (*list_shortcut_folders) (GtkFileChooser *chooser);
|
||||
|
||||
/* Signals
|
||||
*/
|
||||
|
||||
+18
-24
@@ -45,14 +45,14 @@ static void delegate_add_filter (GtkFileChooser *choose
|
||||
GtkFileFilter *filter);
|
||||
static void delegate_remove_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
static GListModel * delegate_get_filters (GtkFileChooser *chooser);
|
||||
static GSList * delegate_list_filters (GtkFileChooser *chooser);
|
||||
static gboolean delegate_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
static gboolean delegate_remove_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
static GListModel * delegate_get_shortcut_folders (GtkFileChooser *chooser);
|
||||
static GSList * delegate_list_shortcut_folders (GtkFileChooser *chooser);
|
||||
static void delegate_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer data);
|
||||
@@ -92,23 +92,17 @@ void
|
||||
_gtk_file_chooser_install_properties (GObjectClass *klass)
|
||||
{
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_ACTION,
|
||||
"action");
|
||||
GTK_FILE_CHOOSER_PROP_ACTION,
|
||||
"action");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_FILTER,
|
||||
"filter");
|
||||
GTK_FILE_CHOOSER_PROP_FILTER,
|
||||
"filter");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
|
||||
"select-multiple");
|
||||
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
|
||||
"select-multiple");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
|
||||
"create-folders");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_FILTERS,
|
||||
"filters");
|
||||
g_object_class_override_property (klass,
|
||||
GTK_FILE_CHOOSER_PROP_SHORTCUT_FOLDERS,
|
||||
"shortcut-folders");
|
||||
GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
|
||||
"create-folders");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,10 +131,10 @@ _gtk_file_chooser_delegate_iface_init (GtkFileChooserIface *iface)
|
||||
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;
|
||||
iface->list_filters = delegate_list_filters;
|
||||
iface->add_shortcut_folder = delegate_add_shortcut_folder;
|
||||
iface->remove_shortcut_folder = delegate_remove_shortcut_folder;
|
||||
iface->get_shortcut_folders = delegate_get_shortcut_folders;
|
||||
iface->list_shortcut_folders = delegate_list_shortcut_folders;
|
||||
iface->add_choice = delegate_add_choice;
|
||||
iface->remove_choice = delegate_remove_choice;
|
||||
iface->set_choice = delegate_set_choice;
|
||||
@@ -247,10 +241,10 @@ delegate_remove_filter (GtkFileChooser *chooser,
|
||||
gtk_file_chooser_remove_filter (get_delegate (chooser), filter);
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
delegate_get_filters (GtkFileChooser *chooser)
|
||||
static GSList *
|
||||
delegate_list_filters (GtkFileChooser *chooser)
|
||||
{
|
||||
return gtk_file_chooser_get_filters (get_delegate (chooser));
|
||||
return gtk_file_chooser_list_filters (get_delegate (chooser));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -269,10 +263,10 @@ delegate_remove_shortcut_folder (GtkFileChooser *chooser,
|
||||
return gtk_file_chooser_remove_shortcut_folder (get_delegate (chooser), file, error);
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
delegate_get_shortcut_folders (GtkFileChooser *chooser)
|
||||
static GSList *
|
||||
delegate_list_shortcut_folders (GtkFileChooser *chooser)
|
||||
{
|
||||
return gtk_file_chooser_get_shortcut_folders (get_delegate (chooser));
|
||||
return gtk_file_chooser_list_shortcut_folders (get_delegate (chooser));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
@@ -32,9 +32,7 @@ typedef enum {
|
||||
GTK_FILE_CHOOSER_PROP_FILTER,
|
||||
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
|
||||
GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS,
|
||||
GTK_FILE_CHOOSER_PROP_FILTERS,
|
||||
GTK_FILE_CHOOSER_PROP_SHORTCUT_FOLDERS,
|
||||
GTK_FILE_CHOOSER_PROP_LAST = GTK_FILE_CHOOSER_PROP_SHORTCUT_FOLDERS
|
||||
GTK_FILE_CHOOSER_PROP_LAST = GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS
|
||||
} GtkFileChooserProp;
|
||||
|
||||
void _gtk_file_chooser_install_properties (GObjectClass *klass);
|
||||
|
||||
+28
-39
@@ -485,14 +485,14 @@ static void gtk_file_chooser_widget_add_filter (GtkF
|
||||
GtkFileFilter *filter);
|
||||
static void gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
|
||||
GtkFileFilter *filter);
|
||||
static GListModel * gtk_file_chooser_widget_get_filters (GtkFileChooser *chooser);
|
||||
static GSList * gtk_file_chooser_widget_list_filters (GtkFileChooser *chooser);
|
||||
static gboolean gtk_file_chooser_widget_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
static gboolean gtk_file_chooser_widget_remove_shortcut_folder (GtkFileChooser *chooser,
|
||||
GFile *file,
|
||||
GError **error);
|
||||
static GListModel * gtk_file_chooser_widget_get_shortcut_folders (GtkFileChooser *chooser);
|
||||
static GSList * gtk_file_chooser_widget_list_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);
|
||||
@@ -619,10 +619,10 @@ gtk_file_chooser_widget_iface_init (GtkFileChooserIface *iface)
|
||||
iface->get_current_name = gtk_file_chooser_widget_get_current_name;
|
||||
iface->add_filter = gtk_file_chooser_widget_add_filter;
|
||||
iface->remove_filter = gtk_file_chooser_widget_remove_filter;
|
||||
iface->get_filters = gtk_file_chooser_widget_get_filters;
|
||||
iface->list_filters = gtk_file_chooser_widget_list_filters;
|
||||
iface->add_shortcut_folder = gtk_file_chooser_widget_add_shortcut_folder;
|
||||
iface->remove_shortcut_folder = gtk_file_chooser_widget_remove_shortcut_folder;
|
||||
iface->get_shortcut_folders = gtk_file_chooser_widget_get_shortcut_folders;
|
||||
iface->list_shortcut_folders = gtk_file_chooser_widget_list_shortcut_folders;
|
||||
iface->add_choice = gtk_file_chooser_widget_add_choice;
|
||||
iface->remove_choice = gtk_file_chooser_widget_remove_choice;
|
||||
iface->set_choice = gtk_file_chooser_widget_set_choice;
|
||||
@@ -3072,14 +3072,6 @@ gtk_file_chooser_widget_get_property (GObject *object,
|
||||
g_value_set_boolean (value, impl->create_folders);
|
||||
break;
|
||||
|
||||
case GTK_FILE_CHOOSER_PROP_FILTERS:
|
||||
g_value_set_object (value, impl->filters);
|
||||
break;
|
||||
|
||||
case GTK_FILE_CHOOSER_PROP_SHORTCUT_FOLDERS:
|
||||
g_value_take_object (value, gtk_file_chooser_get_shortcut_folders (GTK_FILE_CHOOSER (impl)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@@ -3437,27 +3429,25 @@ set_startup_mode (GtkFileChooserWidget *impl)
|
||||
static gboolean
|
||||
shortcut_exists (GtkFileChooserWidget *impl, GFile *needle)
|
||||
{
|
||||
GListModel *haystack;
|
||||
guint n, i;
|
||||
GSList *haystack;
|
||||
GSList *l;
|
||||
gboolean exists;
|
||||
|
||||
exists = FALSE;
|
||||
|
||||
haystack = gtk_places_sidebar_get_shortcuts (GTK_PLACES_SIDEBAR (impl->places_sidebar));
|
||||
n = g_list_model_get_n_items (haystack);
|
||||
for (i = 0; i < n; i++)
|
||||
haystack = gtk_places_sidebar_list_shortcuts (GTK_PLACES_SIDEBAR (impl->places_sidebar));
|
||||
for (l = haystack; l; l = l->next)
|
||||
{
|
||||
GFile *hay = g_list_model_get_item (haystack, i);
|
||||
GFile *hay;
|
||||
|
||||
hay = G_FILE (l->data);
|
||||
if (g_file_equal (hay, needle))
|
||||
{
|
||||
g_object_unref (hay);
|
||||
exists = TRUE;
|
||||
break;
|
||||
}
|
||||
g_object_unref (hay);
|
||||
}
|
||||
g_object_unref (haystack);
|
||||
g_slist_free_full (haystack, g_object_unref);
|
||||
|
||||
return exists;
|
||||
}
|
||||
@@ -5574,8 +5564,6 @@ gtk_file_chooser_widget_add_filter (GtkFileChooser *chooser,
|
||||
set_current_filter (impl, filter);
|
||||
|
||||
show_filters (impl, TRUE);
|
||||
|
||||
g_object_notify (G_OBJECT (chooser), "filters");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -5609,16 +5597,25 @@ gtk_file_chooser_widget_remove_filter (GtkFileChooser *chooser,
|
||||
|
||||
if (!impl->filters)
|
||||
show_filters (impl, FALSE);
|
||||
|
||||
g_object_notify (G_OBJECT (chooser), "filters");
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
gtk_file_chooser_widget_get_filters (GtkFileChooser *chooser)
|
||||
static GSList *
|
||||
gtk_file_chooser_widget_list_filters (GtkFileChooser *chooser)
|
||||
{
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
|
||||
GSList *filters;
|
||||
guint i;
|
||||
|
||||
return G_LIST_MODEL (g_object_ref (impl->filters));
|
||||
filters = NULL;
|
||||
|
||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (impl->filters)); i++)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (G_LIST_MODEL (impl->filters), i);
|
||||
filters = g_slist_append (filters, filter);
|
||||
g_object_unref (filter);
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -5629,9 +5626,6 @@ gtk_file_chooser_widget_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
|
||||
|
||||
gtk_places_sidebar_add_shortcut (GTK_PLACES_SIDEBAR (impl->places_sidebar), file);
|
||||
|
||||
g_object_notify (G_OBJECT (chooser), "shortcut-folders");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -5643,18 +5637,15 @@ gtk_file_chooser_widget_remove_shortcut_folder (GtkFileChooser *chooser,
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
|
||||
|
||||
gtk_places_sidebar_remove_shortcut (GTK_PLACES_SIDEBAR (impl->places_sidebar), file);
|
||||
|
||||
g_object_notify (G_OBJECT (chooser), "shortcut-folders");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
gtk_file_chooser_widget_get_shortcut_folders (GtkFileChooser *chooser)
|
||||
static GSList *
|
||||
gtk_file_chooser_widget_list_shortcut_folders (GtkFileChooser *chooser)
|
||||
{
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (chooser);
|
||||
|
||||
return gtk_places_sidebar_get_shortcuts (GTK_PLACES_SIDEBAR (impl->places_sidebar));
|
||||
return gtk_places_sidebar_list_shortcuts (GTK_PLACES_SIDEBAR (impl->places_sidebar));
|
||||
}
|
||||
|
||||
struct switch_folder_closure {
|
||||
@@ -6942,8 +6933,6 @@ filter_combo_changed (GtkDropDown *dropdown,
|
||||
|
||||
new_filter = gtk_drop_down_get_selected_item (dropdown);
|
||||
|
||||
set_current_filter (impl, new_filter);
|
||||
|
||||
if (impl->location_entry != NULL)
|
||||
_gtk_file_chooser_entry_set_file_filter (GTK_FILE_CHOOSER_ENTRY (impl->location_entry),
|
||||
new_filter);
|
||||
|
||||
+373
-336
File diff suppressed because it is too large
Load Diff
+78
-13
@@ -33,34 +33,99 @@ G_BEGIN_DECLS
|
||||
#define GTK_IS_FILE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FILTER))
|
||||
|
||||
typedef struct _GtkFileFilter GtkFileFilter;
|
||||
typedef struct _GtkFileFilterInfo GtkFileFilterInfo;
|
||||
|
||||
/**
|
||||
* GtkFileFilterFlags:
|
||||
* @GTK_FILE_FILTER_FILENAME: the filename of the file being tested
|
||||
* @GTK_FILE_FILTER_URI: the URI for the file being tested
|
||||
* @GTK_FILE_FILTER_DISPLAY_NAME: the string that will be used to
|
||||
* display the file in the file chooser
|
||||
* @GTK_FILE_FILTER_MIME_TYPE: the mime type of the file
|
||||
*
|
||||
* These flags indicate what parts of a #GtkFileFilterInfo struct
|
||||
* are filled or need to be filled.
|
||||
*/
|
||||
typedef enum {
|
||||
GTK_FILE_FILTER_FILENAME = 1 << 0,
|
||||
GTK_FILE_FILTER_URI = 1 << 1,
|
||||
GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
|
||||
GTK_FILE_FILTER_MIME_TYPE = 1 << 3
|
||||
} GtkFileFilterFlags;
|
||||
|
||||
/**
|
||||
* GtkFileFilterFunc:
|
||||
* @filter_info: a #GtkFileFilterInfo that is filled according
|
||||
* to the @needed flags passed to gtk_file_filter_add_custom()
|
||||
* @data: (closure): user data passed to gtk_file_filter_add_custom()
|
||||
*
|
||||
* The type of function that is used with custom filters, see
|
||||
* gtk_file_filter_add_custom().
|
||||
*
|
||||
* Returns: %TRUE if the file should be displayed
|
||||
*/
|
||||
typedef gboolean (*GtkFileFilterFunc) (const GtkFileFilterInfo *filter_info,
|
||||
gpointer data);
|
||||
|
||||
/**
|
||||
* GtkFileFilterInfo:
|
||||
* @contains: Flags indicating which of the following fields need
|
||||
* are filled
|
||||
* @filename: the filename of the file being tested
|
||||
* @uri: the URI for the file being tested
|
||||
* @display_name: the string that will be used to display the file
|
||||
* in the file chooser
|
||||
* @mime_type: the mime type of the file
|
||||
*
|
||||
* A #GtkFileFilterInfo is used to pass information about the
|
||||
* tested file to gtk_file_filter_filter().
|
||||
*/
|
||||
struct _GtkFileFilterInfo
|
||||
{
|
||||
GtkFileFilterFlags contains;
|
||||
|
||||
const gchar *filename;
|
||||
const gchar *uri;
|
||||
const gchar *display_name;
|
||||
const gchar *mime_type;
|
||||
};
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_file_filter_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_file_filter_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkFileFilter * gtk_file_filter_new (void);
|
||||
GtkFileFilter * gtk_file_filter_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_filter_set_name (GtkFileFilter *filter,
|
||||
const char *name);
|
||||
void gtk_file_filter_set_name (GtkFileFilter *filter,
|
||||
const gchar *name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char * gtk_file_filter_get_name (GtkFileFilter *filter);
|
||||
const gchar * gtk_file_filter_get_name (GtkFileFilter *filter);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_filter_add_mime_type (GtkFileFilter *filter,
|
||||
const char *mime_type);
|
||||
void gtk_file_filter_add_mime_type (GtkFileFilter *filter,
|
||||
const gchar *mime_type);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_filter_add_pattern (GtkFileFilter *filter,
|
||||
const char *pattern);
|
||||
void gtk_file_filter_add_pattern (GtkFileFilter *filter,
|
||||
const gchar *pattern);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter);
|
||||
void gtk_file_filter_add_pixbuf_formats (GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_file_filter_add_custom (GtkFileFilter *filter,
|
||||
GtkFileFilterFlags needed,
|
||||
GtkFileFilterFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const char ** gtk_file_filter_get_attributes (GtkFileFilter *filter);
|
||||
GtkFileFilterFlags gtk_file_filter_get_needed (GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_file_filter_filter (GtkFileFilter *filter,
|
||||
const GtkFileFilterInfo *filter_info);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GVariant * gtk_file_filter_to_gvariant (GtkFileFilter *filter);
|
||||
GVariant *gtk_file_filter_to_gvariant (GtkFileFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkFileFilter * gtk_file_filter_new_from_gvariant (GVariant *variant);
|
||||
GtkFileFilter *gtk_file_filter_new_from_gvariant (GVariant *variant);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "gtktreedatalist.h"
|
||||
#include "gtktreednd.h"
|
||||
#include "gtktreemodel.h"
|
||||
#include "gtkfilter.h"
|
||||
|
||||
/*** Structure: how GtkFileSystemModel works
|
||||
*
|
||||
@@ -376,6 +375,12 @@ static gboolean
|
||||
node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
|
||||
{
|
||||
FileModelNode *node = get_node (model, id);
|
||||
GtkFileFilterInfo filter_info = { 0, };
|
||||
GtkFileFilterFlags required;
|
||||
gboolean result;
|
||||
char *mime_type = NULL;
|
||||
char *filename = NULL;
|
||||
char *uri = NULL;
|
||||
|
||||
if (node->info == NULL)
|
||||
return TRUE;
|
||||
@@ -383,10 +388,57 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
|
||||
if (model->filter == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!g_file_info_has_attribute (node->info, "standard::file"))
|
||||
g_file_info_set_attribute_object (node->info, "standard::file", G_OBJECT (node->file));
|
||||
/* fill info */
|
||||
required = gtk_file_filter_get_needed (model->filter);
|
||||
|
||||
return !gtk_filter_match (GTK_FILTER (model->filter), node->info);
|
||||
filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME;
|
||||
filter_info.display_name = g_file_info_get_display_name (node->info);
|
||||
|
||||
if (required & GTK_FILE_FILTER_MIME_TYPE)
|
||||
{
|
||||
const char *s = g_file_info_get_content_type (node->info);
|
||||
|
||||
if (!s)
|
||||
s = g_file_info_get_attribute_string (node->info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
|
||||
|
||||
if (s)
|
||||
{
|
||||
mime_type = g_content_type_get_mime_type (s);
|
||||
if (mime_type)
|
||||
{
|
||||
filter_info.mime_type = mime_type;
|
||||
filter_info.contains |= GTK_FILE_FILTER_MIME_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (required & GTK_FILE_FILTER_FILENAME)
|
||||
{
|
||||
filename = g_file_get_path (node->file);
|
||||
if (filename)
|
||||
{
|
||||
filter_info.filename = filename;
|
||||
filter_info.contains |= GTK_FILE_FILTER_FILENAME;
|
||||
}
|
||||
}
|
||||
|
||||
if (required & GTK_FILE_FILTER_URI)
|
||||
{
|
||||
uri = g_file_get_uri (node->file);
|
||||
if (uri)
|
||||
{
|
||||
filter_info.uri = uri;
|
||||
filter_info.contains |= GTK_FILE_FILTER_URI;
|
||||
}
|
||||
}
|
||||
|
||||
result = !gtk_file_filter_filter (model->filter, &filter_info);
|
||||
|
||||
g_free (mime_type);
|
||||
g_free (filename);
|
||||
g_free (uri);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
+54
-15
@@ -45,6 +45,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_FILTER,
|
||||
PROP_INCREMENTAL,
|
||||
PROP_ITEM_TYPE,
|
||||
PROP_MODEL,
|
||||
PROP_PENDING,
|
||||
NUM_PROPERTIES
|
||||
@@ -54,6 +55,7 @@ struct _GtkFilterListModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GType item_type;
|
||||
GListModel *model;
|
||||
GtkFilter *filter;
|
||||
GtkFilterMatch strictness;
|
||||
@@ -74,7 +76,9 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
||||
static GType
|
||||
gtk_filter_list_model_get_item_type (GListModel *list)
|
||||
{
|
||||
return G_TYPE_OBJECT;
|
||||
GtkFilterListModel *self = GTK_FILTER_LIST_MODEL (list);
|
||||
|
||||
return self->item_type;
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -302,21 +306,16 @@ gtk_filter_list_model_items_changed_cb (GListModel *model,
|
||||
else
|
||||
filter_removed = 0;
|
||||
|
||||
gtk_bitset_splice (self->matches, position, removed, added);
|
||||
gtk_bitset_slice (self->matches, position, removed, added);
|
||||
if (self->pending)
|
||||
gtk_bitset_splice (self->pending, position, removed, added);
|
||||
gtk_bitset_slice (self->pending, position, removed, added);
|
||||
|
||||
if (added > 0)
|
||||
{
|
||||
gtk_filter_list_model_start_filtering (self, gtk_bitset_new_range (position, added));
|
||||
filter_added = gtk_bitset_get_size_in_range (self->matches, position, position + added - 1);
|
||||
}
|
||||
else
|
||||
filter_added = 0;
|
||||
gtk_filter_list_model_start_filtering (self, gtk_bitset_new_range (position, added));
|
||||
filter_added = gtk_bitset_get_size_in_range (self->matches, position, position + added - 1);
|
||||
|
||||
if (filter_removed > 0 || filter_added > 0)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self),
|
||||
position > 0 ? gtk_bitset_get_size_in_range (self->matches, 0, position - 1) : 0,
|
||||
gtk_bitset_get_size_in_range (self->matches, 0, position),
|
||||
filter_removed, filter_added);
|
||||
}
|
||||
|
||||
@@ -338,6 +337,10 @@ gtk_filter_list_model_set_property (GObject *object,
|
||||
gtk_filter_list_model_set_incremental (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_ITEM_TYPE:
|
||||
self->item_type = g_value_get_gtype (value);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
gtk_filter_list_model_set_model (self, g_value_get_object (value));
|
||||
break;
|
||||
@@ -366,6 +369,10 @@ gtk_filter_list_model_get_property (GObject *object,
|
||||
g_value_set_boolean (value, self->incremental);
|
||||
break;
|
||||
|
||||
case PROP_ITEM_TYPE:
|
||||
g_value_set_gtype (value, self->item_type);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
g_value_set_object (value, self->model);
|
||||
break;
|
||||
@@ -579,6 +586,18 @@ gtk_filter_list_model_class_init (GtkFilterListModelClass *class)
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFilterListModel:item-type:
|
||||
*
|
||||
* The #GType for elements of this object
|
||||
*/
|
||||
properties[PROP_ITEM_TYPE] =
|
||||
g_param_spec_gtype ("item-type",
|
||||
P_("Item type"),
|
||||
P_("The type of elements of this object"),
|
||||
G_TYPE_OBJECT,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFilterListModel:model:
|
||||
*
|
||||
@@ -589,7 +608,7 @@ gtk_filter_list_model_class_init (GtkFilterListModelClass *class)
|
||||
P_("Model"),
|
||||
P_("The model being filtered"),
|
||||
G_TYPE_LIST_MODEL,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFilterListModel:pending:
|
||||
@@ -614,7 +633,7 @@ gtk_filter_list_model_init (GtkFilterListModel *self)
|
||||
|
||||
/**
|
||||
* gtk_filter_list_model_new:
|
||||
* @model: (allow-none): the model to sort
|
||||
* @model: the model to sort
|
||||
* @filter: (allow-none): filter or %NULL to not filter items
|
||||
*
|
||||
* Creates a new #GtkFilterListModel that will filter @model using the given
|
||||
@@ -628,10 +647,10 @@ gtk_filter_list_model_new (GListModel *model,
|
||||
{
|
||||
GtkFilterListModel *result;
|
||||
|
||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
||||
g_return_val_if_fail (filter == NULL || GTK_IS_FILTER (filter), NULL);
|
||||
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_FILTER_LIST_MODEL,
|
||||
"item-type", g_list_model_get_item_type (model),
|
||||
"model", model,
|
||||
"filter", filter,
|
||||
NULL);
|
||||
@@ -639,6 +658,26 @@ gtk_filter_list_model_new (GListModel *model,
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_filter_list_model_new_for_type:
|
||||
* @item_type: the type of the items that will be returned
|
||||
*
|
||||
* Creates a new empty filter list model set up to return items of type @item_type.
|
||||
* It is up to the application to set a proper filter and model to ensure
|
||||
* the item type is matches.
|
||||
*
|
||||
* Returns: a new #GtkFilterListModel
|
||||
**/
|
||||
GtkFilterListModel *
|
||||
gtk_filter_list_model_new_for_type (GType item_type)
|
||||
{
|
||||
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_FILTER_LIST_MODEL,
|
||||
"item-type", item_type,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_filter_list_model_set_filter:
|
||||
* @self: a #GtkFilterListModel
|
||||
|
||||
@@ -39,6 +39,8 @@ G_DECLARE_FINAL_TYPE (GtkFilterListModel, gtk_filter_list_model, GTK, FILTER_LIS
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkFilterListModel * gtk_filter_list_model_new (GListModel *model,
|
||||
GtkFilter *filter);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkFilterListModel * gtk_filter_list_model_new_for_type (GType item_type);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_filter_list_model_set_filter (GtkFilterListModel *self,
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ITEM_TYPE,
|
||||
PROP_MODEL,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
@@ -63,6 +64,7 @@ struct _GtkFlattenListModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GType item_type;
|
||||
GListModel *model;
|
||||
GtkRbTree *items; /* NULL if model == NULL */
|
||||
};
|
||||
@@ -155,7 +157,9 @@ gtk_flatten_list_model_get_nth_model (GtkRbTree *tree,
|
||||
static GType
|
||||
gtk_flatten_list_model_get_item_type (GListModel *list)
|
||||
{
|
||||
return G_TYPE_OBJECT;
|
||||
GtkFlattenListModel *self = GTK_FLATTEN_LIST_MODEL (list);
|
||||
|
||||
return self->item_type;
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -295,6 +299,7 @@ gtk_flatten_list_model_add_items (GtkFlattenListModel *self,
|
||||
{
|
||||
node = gtk_rb_tree_insert_before (self->items, after);
|
||||
node->model = g_list_model_get_item (self->model, position + i);
|
||||
g_warn_if_fail (g_type_is_a (g_list_model_get_item_type (node->model), self->item_type));
|
||||
g_signal_connect (node->model,
|
||||
"items-changed",
|
||||
G_CALLBACK (gtk_flatten_list_model_items_changed_cb),
|
||||
@@ -316,6 +321,10 @@ gtk_flatten_list_model_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ITEM_TYPE:
|
||||
self->item_type = g_value_get_gtype (value);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
gtk_flatten_list_model_set_model (self, g_value_get_object (value));
|
||||
break;
|
||||
@@ -336,6 +345,10 @@ gtk_flatten_list_model_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ITEM_TYPE:
|
||||
g_value_set_gtype (value, self->item_type);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
g_value_set_object (value, self->model);
|
||||
break;
|
||||
@@ -403,6 +416,18 @@ gtk_flatten_list_model_class_init (GtkFlattenListModelClass *class)
|
||||
gobject_class->get_property = gtk_flatten_list_model_get_property;
|
||||
gobject_class->dispose = gtk_flatten_list_model_dispose;
|
||||
|
||||
/**
|
||||
* GtkFlattenListModel:item-type:
|
||||
*
|
||||
* The #GType for elements of this object
|
||||
*/
|
||||
properties[PROP_ITEM_TYPE] =
|
||||
g_param_spec_gtype ("item-type",
|
||||
P_("Item type"),
|
||||
P_("The type of elements of this object"),
|
||||
G_TYPE_OBJECT,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFlattenListModel:model:
|
||||
*
|
||||
@@ -425,20 +450,26 @@ gtk_flatten_list_model_init (GtkFlattenListModel *self)
|
||||
|
||||
/**
|
||||
* gtk_flatten_list_model_new:
|
||||
* @model: (nullable) (transfer none): the model to be flattened
|
||||
* @item_type: The type of items in the to-be-flattened models
|
||||
* @model: (nullable) (transfer none): the item to be flattened
|
||||
*
|
||||
* Creates a new #GtkFlattenListModel that flattens @list.
|
||||
* Creates a new #GtkFlattenListModel that flattens @list. The
|
||||
* models returned by @model must conform to the given @item_type,
|
||||
* either by having an identical type or a subtype.
|
||||
*
|
||||
* Returns: a new #GtkFlattenListModel
|
||||
**/
|
||||
GtkFlattenListModel *
|
||||
gtk_flatten_list_model_new (GListModel *model)
|
||||
gtk_flatten_list_model_new (GType item_type,
|
||||
GListModel *model)
|
||||
{
|
||||
GtkFlattenListModel *result;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_FLATTEN_LIST_MODEL,
|
||||
"item-type", item_type,
|
||||
"model", model,
|
||||
NULL);
|
||||
|
||||
@@ -450,7 +481,8 @@ gtk_flatten_list_model_new (GListModel *model)
|
||||
* @self: a #GtkFlattenListModel
|
||||
* @model: (nullable) (transfer none): the new model or %NULL
|
||||
*
|
||||
* Sets a new model to be flattened.
|
||||
* Sets a new model to be flattened. The model must contain items of
|
||||
* #GListModel that conform to the item type of @self.
|
||||
**/
|
||||
void
|
||||
gtk_flatten_list_model_set_model (GtkFlattenListModel *self,
|
||||
@@ -460,6 +492,10 @@ gtk_flatten_list_model_set_model (GtkFlattenListModel *self,
|
||||
|
||||
g_return_if_fail (GTK_IS_FLATTEN_LIST_MODEL (self));
|
||||
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
|
||||
if (model)
|
||||
{
|
||||
g_return_if_fail (g_type_is_a (g_list_model_get_item_type (model), G_TYPE_LIST_MODEL));
|
||||
}
|
||||
|
||||
if (self->model == model)
|
||||
return;
|
||||
|
||||
@@ -36,7 +36,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkFlattenListModel, gtk_flatten_list_model, GTK, FLATTEN_LIST_MODEL, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkFlattenListModel * gtk_flatten_list_model_new (GListModel *model);
|
||||
GtkFlattenListModel * gtk_flatten_list_model_new (GType item_type,
|
||||
GListModel *model);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_flatten_list_model_set_model (GtkFlattenListModel *self,
|
||||
|
||||
@@ -784,7 +784,7 @@ update_fontlist (GtkFontChooserWidget *self)
|
||||
if ((self->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
|
||||
model = g_object_ref (G_LIST_MODEL (fontmap));
|
||||
else
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (fontmap)));
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (PANGO_TYPE_FONT_FACE, G_LIST_MODEL (fontmap)));
|
||||
gtk_filter_list_model_set_model (self->filter_model, model);
|
||||
g_object_unref (model);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright © 2019 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 "config.h"
|
||||
|
||||
#include "gtkfunctionslistitemfactory.h"
|
||||
|
||||
#include "gtklistitemfactoryprivate.h"
|
||||
#include "gtklistitemprivate.h"
|
||||
|
||||
struct _GtkFunctionsListItemFactory
|
||||
{
|
||||
GtkListItemFactory parent_instance;
|
||||
|
||||
GtkListItemSetupFunc setup_func;
|
||||
GtkListItemBindFunc bind_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
};
|
||||
|
||||
struct _GtkFunctionsListItemFactoryClass
|
||||
{
|
||||
GtkListItemFactoryClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkFunctionsListItemFactory, gtk_functions_list_item_factory, GTK_TYPE_LIST_ITEM_FACTORY)
|
||||
|
||||
static void
|
||||
gtk_functions_list_item_factory_setup (GtkListItemFactory *factory,
|
||||
GtkListItemWidget *widget,
|
||||
GtkListItem *list_item)
|
||||
{
|
||||
GtkFunctionsListItemFactory *self = GTK_FUNCTIONS_LIST_ITEM_FACTORY (factory);
|
||||
|
||||
if (self->setup_func)
|
||||
self->setup_func (list_item, self->user_data);
|
||||
|
||||
GTK_LIST_ITEM_FACTORY_CLASS (gtk_functions_list_item_factory_parent_class)->setup (factory, widget, list_item);
|
||||
|
||||
if (gtk_list_item_get_item (list_item) != NULL && self->bind_func)
|
||||
self->bind_func (list_item, self->user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_functions_list_item_factory_update (GtkListItemFactory *factory,
|
||||
GtkListItemWidget *widget,
|
||||
GtkListItem *list_item,
|
||||
guint position,
|
||||
gpointer item,
|
||||
gboolean selected)
|
||||
{
|
||||
GtkFunctionsListItemFactory *self = GTK_FUNCTIONS_LIST_ITEM_FACTORY (factory);
|
||||
|
||||
GTK_LIST_ITEM_FACTORY_CLASS (gtk_functions_list_item_factory_parent_class)->update (factory, widget, list_item, position, item, selected);
|
||||
|
||||
if (item != NULL && self->bind_func)
|
||||
self->bind_func (list_item, self->user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_functions_list_item_factory_finalize (GObject *object)
|
||||
{
|
||||
GtkFunctionsListItemFactory *self = GTK_FUNCTIONS_LIST_ITEM_FACTORY (object);
|
||||
|
||||
if (self->user_destroy)
|
||||
self->user_destroy (self->user_data);
|
||||
|
||||
G_OBJECT_CLASS (gtk_functions_list_item_factory_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_functions_list_item_factory_class_init (GtkFunctionsListItemFactoryClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkListItemFactoryClass *factory_class = GTK_LIST_ITEM_FACTORY_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_functions_list_item_factory_finalize;
|
||||
|
||||
factory_class->setup = gtk_functions_list_item_factory_setup;
|
||||
factory_class->update = gtk_functions_list_item_factory_update;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_functions_list_item_factory_init (GtkFunctionsListItemFactory *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_functions_list_item_factory_new: (skip)
|
||||
* @setup_func: (scope call) (destroy user_destroy): the setup function for the list item factory
|
||||
* @bind_func: (scope call) (destroy user_destroy): the bind function for the list item factory
|
||||
* @user_data: user data for the @setup_func and @bind_func functions
|
||||
* @user_destroy: a function called to destroy @user_data
|
||||
*
|
||||
* Creates a new #GtkListItemFactory with the given functions.
|
||||
*
|
||||
* Returns: (transfer full): the newly created list item factory object
|
||||
*/
|
||||
GtkListItemFactory *
|
||||
gtk_functions_list_item_factory_new (GtkListItemSetupFunc setup_func,
|
||||
GtkListItemBindFunc bind_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
GtkFunctionsListItemFactory *self;
|
||||
|
||||
g_return_val_if_fail (setup_func || bind_func, NULL);
|
||||
g_return_val_if_fail (user_data != NULL || user_destroy == NULL, NULL);
|
||||
|
||||
self = g_object_new (GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, NULL);
|
||||
|
||||
self->setup_func = setup_func;
|
||||
self->bind_func = bind_func;
|
||||
self->user_data = user_data;
|
||||
self->user_destroy = user_destroy;
|
||||
|
||||
return GTK_LIST_ITEM_FACTORY (self);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright © 2019 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>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__
|
||||
#define __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtklistitemfactory.h>
|
||||
#include <gtk/gtklistitem.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY (gtk_functions_list_item_factory_get_type ())
|
||||
#define GTK_FUNCTIONS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactory))
|
||||
#define GTK_FUNCTIONS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactoryClass))
|
||||
#define GTK_IS_FUNCTIONS_LIST_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY))
|
||||
#define GTK_IS_FUNCTIONS_LIST_ITEM_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY))
|
||||
#define GTK_FUNCTIONS_LIST_ITEM_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FUNCTIONS_LIST_ITEM_FACTORY, GtkFunctionsListItemFactoryClass))
|
||||
|
||||
typedef struct _GtkFunctionsListItemFactory GtkFunctionsListItemFactory;
|
||||
typedef struct _GtkFunctionsListItemFactoryClass GtkFunctionsListItemFactoryClass;
|
||||
|
||||
/**
|
||||
* GtkListItemSetupFunc:
|
||||
* @item: the #GtkListItem to set up
|
||||
* @user_data: (closure): user data
|
||||
*
|
||||
* Called whenever a new list item needs to be setup for managing a row in
|
||||
* the list.
|
||||
*
|
||||
* At this point, the list item is not bound yet, so gtk_list_item_get_item()
|
||||
* will return %NULL.
|
||||
* The list item will later be bound to an item via the #GtkListItemBindFunc.
|
||||
*/
|
||||
typedef void (* GtkListItemSetupFunc) (GtkListItem *item, gpointer user_data);
|
||||
|
||||
/**
|
||||
* GtkListItemBindFunc:
|
||||
* @item: the #GtkListItem to bind
|
||||
* @user_data: (closure): user data
|
||||
*
|
||||
* Binds a#GtkListItem previously set up via a #GtkListItemSetupFunc to
|
||||
* an @item.
|
||||
*
|
||||
* Rebinding a @item to different @items is supported as well as
|
||||
* unbinding it by setting @item to %NULL.
|
||||
*/
|
||||
typedef void (* GtkListItemBindFunc) (GtkListItem *item,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_functions_list_item_factory_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkListItemFactory * gtk_functions_list_item_factory_new (GtkListItemSetupFunc setup_func,
|
||||
GtkListItemBindFunc bind_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FUNCTIONS_LIST_ITEM_FACTORY_H__ */
|
||||
@@ -1171,8 +1171,6 @@ gtk_grid_view_init (GtkGridView *self)
|
||||
gtk_list_base_set_anchor_max_widgets (GTK_LIST_BASE (self),
|
||||
self->max_columns * GTK_GRID_VIEW_MAX_VISIBLE_ROWS,
|
||||
self->max_columns);
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "view");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-3
@@ -595,7 +595,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
|
||||
g_param_spec_boolean ("show-title-buttons",
|
||||
P_("Show title buttons"),
|
||||
P_("Whether to show title buttons"),
|
||||
TRUE,
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
@@ -629,7 +629,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
|
||||
|
||||
priv->title_widget = NULL;
|
||||
priv->decoration_layout = NULL;
|
||||
priv->show_title_buttons = TRUE;
|
||||
priv->state = GDK_SURFACE_STATE_WITHDRAWN;
|
||||
|
||||
priv->handle = gtk_window_handle_new ();
|
||||
@@ -647,7 +646,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
|
||||
gtk_center_box_set_end_widget (GTK_CENTER_BOX (priv->center_box), priv->end_box);
|
||||
|
||||
construct_title_label (bar);
|
||||
create_window_controls (bar);
|
||||
}
|
||||
|
||||
static GtkBuildableIface *parent_buildable_iface;
|
||||
|
||||
+25
-30
@@ -55,14 +55,6 @@
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdkprofilerprivate.h"
|
||||
|
||||
#define GTK_VECTOR_ELEMENT_TYPE char *
|
||||
#define GTK_VECTOR_NULL_TERMINATED 1
|
||||
#define GTK_VECTOR_FREE_FUNC g_free
|
||||
#define GTK_VECTOR_TYPE_NAME GtkStrvBuilder
|
||||
#define GTK_VECTOR_NAME gtk_strv_builder
|
||||
#define GTK_VECTOR_PREALLOC 16
|
||||
#include "gtkvectorimpl.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
|
||||
{
|
||||
|
||||
+4
-7
@@ -3573,15 +3573,12 @@ static void
|
||||
gtk_label_unrealize (GtkWidget *widget)
|
||||
{
|
||||
GtkLabel *self = GTK_LABEL (widget);
|
||||
GdkClipboard *clipboard;
|
||||
|
||||
clipboard = gtk_widget_get_primary_clipboard (widget);
|
||||
if (self->select_info &&
|
||||
self->select_info->provider)
|
||||
{
|
||||
GdkClipboard *clipboard = gtk_widget_get_primary_clipboard (widget);
|
||||
|
||||
if (gdk_clipboard_get_content (clipboard) == self->select_info->provider)
|
||||
gdk_clipboard_set_content (clipboard, NULL);
|
||||
}
|
||||
gdk_clipboard_get_content (clipboard) == self->select_info->provider)
|
||||
gdk_clipboard_set_content (clipboard, NULL);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* Because views do not display the whole list at once but only a few
|
||||
* items, they only need to maintain a few widgets at a time. They will
|
||||
* instruct the #GtkListItemFactory to create these widgets and bind them
|
||||
* to the items that are currently displayed.
|
||||
* to the items that are currently displayed.
|
||||
* As the list model changes or the user scrolls to the list, the items will
|
||||
* change and the view will instruct the factory to bind the widgets to those
|
||||
* new items.
|
||||
@@ -56,13 +56,13 @@
|
||||
* Various implementations of #GtkListItemFactory exist to allow you different
|
||||
* ways to provide those widgets. The most common implementations are
|
||||
* #GtkBuilderListItemFactory which takes a #GtkBuilder .ui file and then creates
|
||||
* widgets and manages everything automatically from the information in that file
|
||||
* and manages widgets everything automatically from the information in that file
|
||||
* and #GtkSignalListItemFactory which allows you to connect to signals with your
|
||||
* own code and retain full control over how the widgets are setup and managed.
|
||||
*
|
||||
* A #GtkListItemFactory is supposed to be final - that means its behavior should
|
||||
* not change and the first widget created from it should behave the same way as
|
||||
* the last widget created from it.
|
||||
* the last widget created from it.
|
||||
* If you intend to do changes to the behavior, it is recommended that you create
|
||||
* a new #GtkListItemFactory which will allow the views to recreate its widgets.
|
||||
*
|
||||
|
||||
@@ -925,8 +925,6 @@ gtk_list_view_init (GtkListView *self)
|
||||
gtk_list_base_set_anchor_max_widgets (GTK_LIST_BASE (self),
|
||||
GTK_LIST_VIEW_MAX_LIST_ITEMS,
|
||||
GTK_LIST_VIEW_EXTRA_ITEMS);
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "view");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+20
-24
@@ -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 GTK_VECTOR_ELEMENT_TYPE GtkWidget *
|
||||
#define GTK_VECTOR_TYPE_NAME GtkWidgetStack
|
||||
#define GTK_VECTOR_NAME gtk_widget_stack
|
||||
#define GTK_VECTOR_FREE_FUNC g_object_unref
|
||||
#define GTK_VECTOR_PREALLOC 16
|
||||
#include "gtkvectorimpl.c"
|
||||
|
||||
static GtkWindowGroup *gtk_main_get_window_group (GtkWidget *widget);
|
||||
|
||||
static gint pre_initialized = FALSE;
|
||||
@@ -1327,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)
|
||||
@@ -1381,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;
|
||||
|
||||
@@ -1422,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 *
|
||||
@@ -1999,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 (;;)
|
||||
{
|
||||
@@ -2012,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))
|
||||
{
|
||||
@@ -2054,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,
|
||||
@@ -2075,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;
|
||||
}
|
||||
|
||||
|
||||
+35
-2
@@ -63,6 +63,7 @@
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_HAS_MAP,
|
||||
PROP_ITEM_TYPE,
|
||||
PROP_MODEL,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
@@ -85,6 +86,7 @@ struct _GtkMapListModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GType item_type;
|
||||
GListModel *model;
|
||||
GtkMapListModelMapFunc map_func;
|
||||
gpointer user_data;
|
||||
@@ -143,7 +145,9 @@ gtk_map_list_model_get_nth (GtkRbTree *tree,
|
||||
static GType
|
||||
gtk_map_list_model_get_item_type (GListModel *list)
|
||||
{
|
||||
return G_TYPE_OBJECT;
|
||||
GtkMapListModel *self = GTK_MAP_LIST_MODEL (list);
|
||||
|
||||
return self->item_type;
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -195,6 +199,11 @@ gtk_map_list_model_get_item (GListModel *list,
|
||||
}
|
||||
|
||||
node->item = self->map_func (g_list_model_get_item (self->model, position), self->user_data);
|
||||
if (!G_TYPE_CHECK_INSTANCE_TYPE (node->item, self->item_type))
|
||||
{
|
||||
g_critical ("Map function returned a %s, but it is not a subtype of the model's type %s",
|
||||
G_OBJECT_TYPE_NAME (node->item), g_type_name (self->item_type));
|
||||
}
|
||||
g_object_add_weak_pointer (node->item, &node->item);
|
||||
|
||||
return node->item;
|
||||
@@ -284,6 +293,10 @@ gtk_map_list_model_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ITEM_TYPE:
|
||||
self->item_type = g_value_get_gtype (value);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
gtk_map_list_model_set_model (self, g_value_get_object (value));
|
||||
break;
|
||||
@@ -308,6 +321,10 @@ gtk_map_list_model_get_property (GObject *object,
|
||||
g_value_set_boolean (value, self->items != NULL);
|
||||
break;
|
||||
|
||||
case PROP_ITEM_TYPE:
|
||||
g_value_set_gtype (value, self->item_type);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
g_value_set_object (value, self->model);
|
||||
break;
|
||||
@@ -365,6 +382,18 @@ gtk_map_list_model_class_init (GtkMapListModelClass *class)
|
||||
FALSE,
|
||||
GTK_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkMapListModel:item-type:
|
||||
*
|
||||
* The #GType for elements of this object
|
||||
*/
|
||||
properties[PROP_ITEM_TYPE] =
|
||||
g_param_spec_gtype ("item-type",
|
||||
P_("Item type"),
|
||||
P_("The type of elements of this object"),
|
||||
G_TYPE_OBJECT,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkMapListModel:model:
|
||||
*
|
||||
@@ -412,6 +441,7 @@ gtk_map_list_model_augment (GtkRbTree *map,
|
||||
|
||||
/**
|
||||
* gtk_map_list_model_new:
|
||||
* @item_type: the #GType to use as the model's item type
|
||||
* @model: (allow-none): The model to map or %NULL for none
|
||||
* @map_func: (allow-none): map function or %NULL to not map items
|
||||
* @user_data: (closure): user data passed to @map_func
|
||||
@@ -422,16 +452,19 @@ gtk_map_list_model_augment (GtkRbTree *map,
|
||||
* Returns: a new #GtkMapListModel
|
||||
**/
|
||||
GtkMapListModel *
|
||||
gtk_map_list_model_new (GListModel *model,
|
||||
gtk_map_list_model_new (GType item_type,
|
||||
GListModel *model,
|
||||
GtkMapListModelMapFunc map_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
GtkMapListModel *result;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_MAP_LIST_MODEL,
|
||||
"item-type", item_type,
|
||||
"model", model,
|
||||
NULL);
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ G_DECLARE_FINAL_TYPE (GtkMapListModel, gtk_map_list_model, GTK, MAP_LIST_MODEL,
|
||||
typedef gpointer (* GtkMapListModelMapFunc) (gpointer item, gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMapListModel * gtk_map_list_model_new (GListModel *model,
|
||||
GtkMapListModel * gtk_map_list_model_new (GType item_type,
|
||||
GListModel *model,
|
||||
GtkMapListModelMapFunc map_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
|
||||
+12
-73
@@ -62,7 +62,9 @@ static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
static GType
|
||||
gtk_multi_selection_get_item_type (GListModel *list)
|
||||
{
|
||||
return G_TYPE_OBJECT;
|
||||
GtkMultiSelection *self = GTK_MULTI_SELECTION (list);
|
||||
|
||||
return g_list_model_get_item_type (self->model);
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -70,9 +72,6 @@ gtk_multi_selection_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkMultiSelection *self = GTK_MULTI_SELECTION (list);
|
||||
|
||||
if (self->model == NULL)
|
||||
return 0;
|
||||
|
||||
return g_list_model_get_n_items (self->model);
|
||||
}
|
||||
|
||||
@@ -82,9 +81,6 @@ gtk_multi_selection_get_item (GListModel *list,
|
||||
{
|
||||
GtkMultiSelection *self = GTK_MULTI_SELECTION (list);
|
||||
|
||||
if (self->model == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_list_model_get_item (self->model, position);
|
||||
}
|
||||
|
||||
@@ -178,7 +174,7 @@ gtk_multi_selection_set_selection (GtkSelectionModel *model,
|
||||
max = gtk_bitset_get_maximum (changes);
|
||||
|
||||
/* sanity check */
|
||||
n_items = self->model ? g_list_model_get_n_items (self->model) : 0;
|
||||
n_items = g_list_model_get_n_items (self->model);
|
||||
if (max >= n_items)
|
||||
{
|
||||
gtk_bitset_remove_range_closed (changes, n_items, max);
|
||||
@@ -222,7 +218,7 @@ gtk_multi_selection_items_changed_cb (GListModel *model,
|
||||
GHashTable *pending = NULL;
|
||||
guint i;
|
||||
|
||||
gtk_bitset_splice (self->selected, position, removed, added);
|
||||
gtk_bitset_slice (self->selected, position, removed, added);
|
||||
|
||||
g_hash_table_iter_init (&iter, self->items);
|
||||
while (g_hash_table_iter_next (&iter, &item, &pos_pointer))
|
||||
@@ -295,7 +291,12 @@ gtk_multi_selection_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MODEL:
|
||||
gtk_multi_selection_set_model (self, g_value_get_object (value));
|
||||
self->model = g_value_dup_object (value);
|
||||
g_warn_if_fail (self->model != NULL);
|
||||
g_signal_connect (self->model,
|
||||
"items-changed",
|
||||
G_CALLBACK (gtk_multi_selection_items_changed_cb),
|
||||
self);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -356,7 +357,7 @@ gtk_multi_selection_class_init (GtkMultiSelectionClass *klass)
|
||||
P_("Model"),
|
||||
P_("List managed by this selection"),
|
||||
G_TYPE_LIST_MODEL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
@@ -385,65 +386,3 @@ gtk_multi_selection_new (GListModel *model)
|
||||
"model", model,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_multi_selection_get_model:
|
||||
* @self: a #GtkMultiSelection
|
||||
*
|
||||
* Returns the underlying model of @self.
|
||||
*
|
||||
* Returns: (transfer none): the underlying model
|
||||
*/
|
||||
GListModel *
|
||||
gtk_multi_selection_get_model (GtkMultiSelection *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_MULTI_SELECTION (self), NULL);
|
||||
|
||||
return self->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_multi_selection_set_model:
|
||||
* @self: a #GtkMultiSelection
|
||||
* @model: (allow-none): A #GListModel to wrap
|
||||
*
|
||||
* Sets the model that @self should wrap. If @model is %NULL, @self
|
||||
* will be empty.
|
||||
**/
|
||||
void
|
||||
gtk_multi_selection_set_model (GtkMultiSelection *self,
|
||||
GListModel *model)
|
||||
{
|
||||
guint n_items_before;
|
||||
|
||||
g_return_if_fail (GTK_IS_MULTI_SELECTION (self));
|
||||
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
|
||||
|
||||
if (self->model == model)
|
||||
return;
|
||||
|
||||
n_items_before = self->model ? g_list_model_get_n_items (self->model) : 0;
|
||||
gtk_multi_selection_clear_model (self);
|
||||
|
||||
if (model)
|
||||
{
|
||||
self->model = g_object_ref (model);
|
||||
g_signal_connect (self->model,
|
||||
"items-changed",
|
||||
G_CALLBACK (gtk_multi_selection_items_changed_cb),
|
||||
self);
|
||||
gtk_multi_selection_items_changed_cb (self->model,
|
||||
0,
|
||||
n_items_before,
|
||||
g_list_model_get_n_items (model),
|
||||
self);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_bitset_remove_all (self->selected);
|
||||
g_hash_table_remove_all (self->items);
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), 0, n_items_before, 0);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
||||
}
|
||||
|
||||
@@ -33,11 +33,6 @@ G_DECLARE_FINAL_TYPE (GtkMultiSelection, gtk_multi_selection, GTK, MULTI_SELECTI
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel * gtk_multi_selection_new (GListModel *model);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_multi_selection_set_model (GtkMultiSelection *self,
|
||||
GListModel *model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+12
-50
@@ -60,7 +60,9 @@ static GParamSpec *properties[N_PROPS] = { NULL, };
|
||||
static GType
|
||||
gtk_no_selection_get_item_type (GListModel *list)
|
||||
{
|
||||
return G_TYPE_OBJECT;
|
||||
GtkNoSelection *self = GTK_NO_SELECTION (list);
|
||||
|
||||
return g_list_model_get_item_type (self->model);
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -68,21 +70,15 @@ gtk_no_selection_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkNoSelection *self = GTK_NO_SELECTION (list);
|
||||
|
||||
if (self->model == NULL)
|
||||
return 0;
|
||||
|
||||
return g_list_model_get_n_items (self->model);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gtk_no_selection_get_item (GListModel *list,
|
||||
guint position)
|
||||
guint position)
|
||||
{
|
||||
GtkNoSelection *self = GTK_NO_SELECTION (list);
|
||||
|
||||
if (self->model == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_list_model_get_item (self->model, position);
|
||||
}
|
||||
|
||||
@@ -136,9 +132,9 @@ gtk_no_selection_clear_model (GtkNoSelection *self)
|
||||
|
||||
static void
|
||||
gtk_no_selection_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
|
||||
{
|
||||
GtkNoSelection *self = GTK_NO_SELECTION (object);
|
||||
@@ -146,7 +142,10 @@ gtk_no_selection_set_property (GObject *object,
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_MODEL:
|
||||
gtk_no_selection_set_model (self, g_value_get_object (value));
|
||||
gtk_no_selection_clear_model (self);
|
||||
self->model = g_value_dup_object (value);
|
||||
g_signal_connect_swapped (self->model, "items-changed",
|
||||
G_CALLBACK (g_list_model_items_changed), self);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -204,7 +203,7 @@ gtk_no_selection_class_init (GtkNoSelectionClass *klass)
|
||||
P_("The model"),
|
||||
P_("The model being managed"),
|
||||
G_TYPE_LIST_MODEL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
}
|
||||
@@ -248,40 +247,3 @@ gtk_no_selection_get_model (GtkNoSelection *self)
|
||||
return self->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_no_selection_set_model:
|
||||
* @self: a #GtkNoSelection
|
||||
* @model: (allow-none): A #GListModel to wrap
|
||||
*
|
||||
* Sets the model that @self should wrap. If @model is %NULL, this
|
||||
* model will be empty.
|
||||
**/
|
||||
void
|
||||
gtk_no_selection_set_model (GtkNoSelection *self,
|
||||
GListModel *model)
|
||||
{
|
||||
guint n_items_before;
|
||||
|
||||
g_return_if_fail (GTK_IS_NO_SELECTION (self));
|
||||
g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));
|
||||
|
||||
if (self->model == model)
|
||||
return;
|
||||
|
||||
n_items_before = self->model ? g_list_model_get_n_items (self->model) : 0;
|
||||
gtk_no_selection_clear_model (self);
|
||||
|
||||
if (model)
|
||||
{
|
||||
self->model = g_object_ref (model);
|
||||
g_signal_connect_swapped (self->model, "items-changed",
|
||||
G_CALLBACK (g_list_model_items_changed), self);
|
||||
}
|
||||
|
||||
g_list_model_items_changed (G_LIST_MODEL (self),
|
||||
0,
|
||||
n_items_before,
|
||||
model ? g_list_model_get_n_items (self->model) : 0);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ GtkNoSelection * gtk_no_selection_new (GListModel
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GListModel * gtk_no_selection_get_model (GtkNoSelection *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_no_selection_set_model (GtkNoSelection *self,
|
||||
GListModel *model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
||||
g_list_store_append (store, dialog->page_setup_list);
|
||||
g_list_store_append (store, dialog->custom_paper_list);
|
||||
g_list_store_append (store, dialog->manage_papers_list);
|
||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (GTK_TYPE_PAGE_SETUP, G_LIST_MODEL (store)));
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
|
||||
g_object_unref (store);
|
||||
g_object_unref (paper_size_list);
|
||||
@@ -321,7 +321,7 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
||||
g_list_store_append (printer_list_list, printer_list);
|
||||
g_object_unref (printer_list);
|
||||
|
||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
|
||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (GTK_TYPE_PRINTER, G_LIST_MODEL (printer_list_list)));
|
||||
|
||||
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
|
||||
|
||||
+56
-47
@@ -162,7 +162,7 @@ struct _GtkPlacesSidebar {
|
||||
|
||||
GtkWidget *popover;
|
||||
GtkSidebarRow *context_row;
|
||||
GListStore *shortcuts;
|
||||
GSList *shortcuts;
|
||||
|
||||
GDBusProxy *hostnamed_proxy;
|
||||
GCancellable *hostnamed_cancellable;
|
||||
@@ -709,25 +709,15 @@ file_is_shown (GtkPlacesSidebar *sidebar,
|
||||
return found;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkPlacesSidebar *sidebar;
|
||||
guint position;
|
||||
} ShortcutData;
|
||||
|
||||
static void
|
||||
on_app_shortcuts_query_complete (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
ShortcutData *sdata = data;
|
||||
GtkPlacesSidebar *sidebar = sdata->sidebar;
|
||||
guint pos = sdata->position;
|
||||
GtkPlacesSidebar *sidebar = data;
|
||||
GFile *file = G_FILE (source);
|
||||
GFileInfo *info;
|
||||
|
||||
g_free (sdata);
|
||||
|
||||
info = g_file_query_info_finish (file, result, NULL);
|
||||
|
||||
if (info)
|
||||
@@ -736,12 +726,20 @@ on_app_shortcuts_query_complete (GObject *source,
|
||||
gchar *tooltip;
|
||||
const gchar *name;
|
||||
GIcon *start_icon;
|
||||
int pos = 0;
|
||||
|
||||
name = g_file_info_get_display_name (info);
|
||||
start_icon = g_file_info_get_symbolic_icon (info);
|
||||
uri = g_file_get_uri (file);
|
||||
tooltip = g_file_get_parse_name (file);
|
||||
|
||||
/* XXX: we could avoid this by using an ancillary closure
|
||||
* with the index coming from add_application_shortcuts(),
|
||||
* but in terms of algorithmic overhead, the application
|
||||
* shortcuts is not going to be really big
|
||||
*/
|
||||
pos = g_slist_index (sidebar->shortcuts, file);
|
||||
|
||||
add_place (sidebar, PLACES_BUILT_IN,
|
||||
SECTION_COMPUTER,
|
||||
name, start_icon, NULL, uri,
|
||||
@@ -759,13 +757,11 @@ on_app_shortcuts_query_complete (GObject *source,
|
||||
static void
|
||||
add_application_shortcuts (GtkPlacesSidebar *sidebar)
|
||||
{
|
||||
guint i, n;
|
||||
GSList *l;
|
||||
|
||||
n = g_list_model_get_n_items (G_LIST_MODEL (sidebar->shortcuts));
|
||||
for (i = 0; i < n; i++)
|
||||
for (l = sidebar->shortcuts; l; l = l->next)
|
||||
{
|
||||
GFile *file = g_list_model_get_item (G_LIST_MODEL (sidebar->shortcuts), i);
|
||||
ShortcutData *data;
|
||||
GFile *file = l->data;
|
||||
|
||||
if (!should_show_file (sidebar, file))
|
||||
continue;
|
||||
@@ -773,16 +769,13 @@ add_application_shortcuts (GtkPlacesSidebar *sidebar)
|
||||
if (file_is_shown (sidebar, file))
|
||||
continue;
|
||||
|
||||
data = g_new (ShortcutData, 1);
|
||||
data->sidebar = sidebar;
|
||||
data->position = i;
|
||||
g_file_query_info_async (file,
|
||||
"standard::display-name,standard::symbolic-icon",
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
G_PRIORITY_DEFAULT,
|
||||
sidebar->cancellable,
|
||||
on_app_shortcuts_query_complete,
|
||||
data);
|
||||
sidebar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3755,8 +3748,6 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
|
||||
sidebar->show_recent = TRUE;
|
||||
sidebar->show_desktop = TRUE;
|
||||
|
||||
sidebar->shortcuts = g_list_store_new (G_TYPE_FILE);
|
||||
|
||||
create_volume_monitor (sidebar);
|
||||
|
||||
sidebar->open_flags = GTK_PLACES_OPEN_NORMAL;
|
||||
@@ -4027,7 +4018,9 @@ gtk_places_sidebar_dispose (GObject *object)
|
||||
|
||||
g_clear_object (&sidebar->current_location);
|
||||
g_clear_pointer (&sidebar->rename_uri, g_free);
|
||||
g_clear_object (&sidebar->shortcuts);
|
||||
|
||||
g_slist_free_full (sidebar->shortcuts, g_object_unref);
|
||||
sidebar->shortcuts = NULL;
|
||||
|
||||
#ifdef HAVE_CLOUDPROVIDERS
|
||||
for (l = cloud_providers_collector_get_providers (sidebar->cloud_manager);
|
||||
@@ -4789,6 +4782,24 @@ gtk_places_sidebar_get_show_trash (GtkPlacesSidebar *sidebar)
|
||||
return sidebar->show_trash;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
find_shortcut_link (GtkPlacesSidebar *sidebar,
|
||||
GFile *location)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = sidebar->shortcuts; l; l = l->next)
|
||||
{
|
||||
GFile *shortcut;
|
||||
|
||||
shortcut = G_FILE (l->data);
|
||||
if (g_file_equal (shortcut, location))
|
||||
return l;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_places_sidebar_add_shortcut:
|
||||
* @sidebar: a places sidebar
|
||||
@@ -4812,7 +4823,8 @@ gtk_places_sidebar_add_shortcut (GtkPlacesSidebar *sidebar,
|
||||
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
|
||||
g_return_if_fail (G_IS_FILE (location));
|
||||
|
||||
g_list_store_append (sidebar->shortcuts, location);
|
||||
g_object_ref (location);
|
||||
sidebar->shortcuts = g_slist_append (sidebar->shortcuts, location);
|
||||
|
||||
update_places (sidebar);
|
||||
}
|
||||
@@ -4830,46 +4842,43 @@ void
|
||||
gtk_places_sidebar_remove_shortcut (GtkPlacesSidebar *sidebar,
|
||||
GFile *location)
|
||||
{
|
||||
guint i, n;
|
||||
GSList *link;
|
||||
GFile *shortcut;
|
||||
|
||||
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
|
||||
g_return_if_fail (G_IS_FILE (location));
|
||||
|
||||
n = g_list_model_get_n_items (G_LIST_MODEL (sidebar->shortcuts));
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
GFile *shortcut = g_list_model_get_item (G_LIST_MODEL (sidebar->shortcuts), i);
|
||||
link = find_shortcut_link (sidebar, location);
|
||||
if (!link)
|
||||
return;
|
||||
|
||||
if (shortcut == location)
|
||||
{
|
||||
g_list_store_remove (sidebar->shortcuts, i);
|
||||
g_object_unref (shortcut);
|
||||
update_places (sidebar);
|
||||
return;
|
||||
}
|
||||
shortcut = G_FILE (link->data);
|
||||
g_object_unref (shortcut);
|
||||
|
||||
g_object_unref (shortcut);
|
||||
}
|
||||
sidebar->shortcuts = g_slist_delete_link (sidebar->shortcuts, link);
|
||||
update_places (sidebar);
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_places_sidebar_list_shortcuts:
|
||||
* @sidebar: a places sidebar
|
||||
*
|
||||
* Gets the list of shortcuts, as a list model containing #GFile objects.
|
||||
* Gets the list of shortcuts.
|
||||
*
|
||||
* You should not modify the returned list model. Future changes to
|
||||
* @sidebar may or may not affect the returned model.
|
||||
*
|
||||
* Returns: (transfer full): a list model of #GFiles that have been added as
|
||||
* Returns: (element-type GFile) (transfer full):
|
||||
* A #GSList of #GFile of the locations that have been added as
|
||||
* application-specific shortcuts with gtk_places_sidebar_add_shortcut().
|
||||
* To free this list, you can use
|
||||
* |[<!-- language="C" -->
|
||||
* g_slist_free_full (list, (GDestroyNotify) g_object_unref);
|
||||
* ]|
|
||||
*/
|
||||
GListModel *
|
||||
gtk_places_sidebar_get_shortcuts (GtkPlacesSidebar *sidebar)
|
||||
GSList *
|
||||
gtk_places_sidebar_list_shortcuts (GtkPlacesSidebar *sidebar)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar), NULL);
|
||||
|
||||
return G_LIST_MODEL (g_object_ref (sidebar->shortcuts));
|
||||
return g_slist_copy_deep (sidebar->shortcuts, (GCopyFunc) g_object_ref, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -92,7 +92,7 @@ void gtk_places_sidebar_add_shortcut (GtkPlacesSideb
|
||||
GFile *location);
|
||||
void gtk_places_sidebar_remove_shortcut (GtkPlacesSidebar *sidebar,
|
||||
GFile *location);
|
||||
GListModel * gtk_places_sidebar_get_shortcuts (GtkPlacesSidebar *sidebar);
|
||||
GSList * gtk_places_sidebar_list_shortcuts (GtkPlacesSidebar *sidebar);
|
||||
|
||||
GFile * gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar,
|
||||
gint n);
|
||||
|
||||
@@ -806,7 +806,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
g_list_store_append (store, dialog->page_setup_list);
|
||||
g_list_store_append (store, dialog->custom_paper_list);
|
||||
g_list_store_append (store, dialog->manage_papers_list);
|
||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (GTK_TYPE_PAGE_SETUP, G_LIST_MODEL (store)));
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
|
||||
g_object_unref (store);
|
||||
g_object_unref (paper_size_list);
|
||||
@@ -1056,7 +1056,7 @@ load_print_backends (GtkPrintUnixDialog *dialog)
|
||||
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
|
||||
}
|
||||
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (GTK_TYPE_PRINTER, G_LIST_MODEL (lists)));
|
||||
|
||||
g_object_unref (lists);
|
||||
|
||||
|
||||
@@ -250,6 +250,16 @@ G_DEFINE_TYPE_WITH_CODE (GtkRange, gtk_range, GTK_TYPE_WIDGET,
|
||||
static guint signals[LAST_SIGNAL];
|
||||
static GParamSpec *properties[LAST_PROP];
|
||||
|
||||
static void
|
||||
gtk_range_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkRange *range = GTK_RANGE (widget);
|
||||
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
|
||||
|
||||
gtk_widget_snapshot_child (widget, priv->trough_widget, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_range_class_init (GtkRangeClass *class)
|
||||
{
|
||||
@@ -265,6 +275,7 @@ gtk_range_class_init (GtkRangeClass *class)
|
||||
gobject_class->dispose = gtk_range_dispose;
|
||||
|
||||
widget_class->measure = gtk_range_measure;
|
||||
widget_class->snapshot = gtk_range_snapshot;
|
||||
widget_class->size_allocate = gtk_range_size_allocate;
|
||||
widget_class->unmap = gtk_range_unmap;
|
||||
widget_class->direction_changed = gtk_range_direction_changed;
|
||||
|
||||
+12
-14
@@ -47,12 +47,14 @@ static void
|
||||
gtk_theming_background_snapshot_color (GtkCssBoxes *boxes,
|
||||
GtkSnapshot *snapshot,
|
||||
const GdkRGBA *bg_color,
|
||||
guint n_bg_values)
|
||||
const GtkCssValue *background_image)
|
||||
{
|
||||
const GskRoundedRect *box;
|
||||
gint n_values;
|
||||
GtkCssArea clip;
|
||||
|
||||
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_bg_values - 1));
|
||||
|
||||
n_values = _gtk_css_array_value_get_n_values (background_image);
|
||||
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_values - 1));
|
||||
box = gtk_css_boxes_get_box (boxes, clip);
|
||||
|
||||
if (gsk_rounded_rect_is_rectilinear (box))
|
||||
@@ -92,6 +94,9 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
|
||||
|
||||
pos = _gtk_css_array_value_get_nth (background->background_position, idx);
|
||||
repeat = _gtk_css_array_value_get_nth (background->background_repeat, idx);
|
||||
hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
|
||||
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
|
||||
|
||||
|
||||
origin = gtk_css_boxes_get_box (bg,
|
||||
_gtk_css_area_value_get (
|
||||
@@ -120,13 +125,8 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
|
||||
/* optimization */
|
||||
if (image_width == width)
|
||||
hrepeat = GTK_CSS_REPEAT_STYLE_NO_REPEAT;
|
||||
else
|
||||
hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
|
||||
|
||||
if (image_height == height)
|
||||
vrepeat = GTK_CSS_REPEAT_STYLE_NO_REPEAT;
|
||||
else
|
||||
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
|
||||
|
||||
gtk_snapshot_push_debug (snapshot, "Layer %u", idx);
|
||||
gtk_snapshot_push_rounded_clip (snapshot, clip);
|
||||
@@ -262,8 +262,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||
gboolean has_bg_color;
|
||||
gboolean has_bg_image;
|
||||
gboolean has_shadow;
|
||||
int idx;
|
||||
guint number_of_layers;
|
||||
gint idx;
|
||||
|
||||
if (background->base.type == GTK_CSS_BACKGROUND_INITIAL_VALUES)
|
||||
return;
|
||||
@@ -287,11 +286,10 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||
snapshot,
|
||||
gtk_css_boxes_get_border_box (boxes));
|
||||
|
||||
number_of_layers = _gtk_css_array_value_get_n_values (background_image);
|
||||
|
||||
if (has_bg_image)
|
||||
{
|
||||
GtkCssValue *blend_modes = background->background_blend_mode;
|
||||
const int number_of_layers = _gtk_css_array_value_get_n_values (background_image);
|
||||
GskBlendMode *blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
|
||||
|
||||
for (idx = number_of_layers - 1; idx >= 0; idx--)
|
||||
@@ -303,7 +301,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||
}
|
||||
|
||||
if (has_bg_color)
|
||||
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, number_of_layers);
|
||||
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
|
||||
|
||||
for (idx = number_of_layers - 1; idx >= 0; idx--)
|
||||
{
|
||||
@@ -321,7 +319,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||
}
|
||||
else if (has_bg_color)
|
||||
{
|
||||
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, number_of_layers);
|
||||
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
|
||||
}
|
||||
|
||||
if (has_shadow)
|
||||
|
||||
+44
-14
@@ -79,23 +79,22 @@
|
||||
*
|
||||
* |[<!-- language="plain" -->
|
||||
* scale[.fine-tune][.marks-before][.marks-after]
|
||||
* ├── [value][.top][.right][.bottom][.left]
|
||||
* ├── marks.top
|
||||
* │ ├── mark
|
||||
* │ ┊ ├── [label]
|
||||
* │ ┊ ╰── indicator
|
||||
* ┊ ┊
|
||||
* │ ╰── mark
|
||||
* ├── marks.bottom
|
||||
* │ ├── mark
|
||||
* │ ┊ ├── indicator
|
||||
* │ ┊ ╰── [label]
|
||||
* ┊ ┊
|
||||
* │ ╰── mark
|
||||
* ╰── trough
|
||||
* ├── [fill]
|
||||
* ├── [highlight]
|
||||
* ╰── slider
|
||||
* ├── [value][.top][.right][.bottom][.left]
|
||||
* ├── trough
|
||||
* │ ├── [fill]
|
||||
* │ ├── [highlight]
|
||||
* │ ╰── slider
|
||||
* ╰── marks.bottom
|
||||
* ├── mark
|
||||
* ┊ ├── indicator
|
||||
* ┊ ╰── [label]
|
||||
* ╰── mark
|
||||
* ]|
|
||||
*
|
||||
* GtkScale has a main CSS node with name scale and a subnode for its contents,
|
||||
@@ -198,6 +197,8 @@ static void gtk_scale_measure (GtkWidget *widget,
|
||||
static void gtk_scale_get_range_border (GtkRange *range,
|
||||
GtkBorder *border);
|
||||
static void gtk_scale_finalize (GObject *object);
|
||||
static void gtk_scale_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static void gtk_scale_real_get_layout_offsets (GtkScale *scale,
|
||||
gint *x,
|
||||
gint *y);
|
||||
@@ -660,6 +661,7 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
gobject_class->notify = gtk_scale_notify;
|
||||
gobject_class->finalize = gtk_scale_finalize;
|
||||
|
||||
widget_class->snapshot = gtk_scale_snapshot;
|
||||
widget_class->size_allocate = gtk_scale_size_allocate;
|
||||
widget_class->measure = gtk_scale_measure;
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_self;
|
||||
@@ -1091,9 +1093,14 @@ gtk_scale_set_draw_value (GtkScale *scale,
|
||||
"css-name", "value",
|
||||
"label", txt,
|
||||
NULL);
|
||||
|
||||
g_free (txt);
|
||||
|
||||
gtk_widget_insert_after (priv->value_widget, GTK_WIDGET (scale), NULL);
|
||||
if (priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)
|
||||
gtk_widget_insert_after (priv->value_widget, GTK_WIDGET (scale), NULL);
|
||||
else
|
||||
gtk_widget_insert_before (priv->value_widget, GTK_WIDGET (scale), NULL);
|
||||
|
||||
gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
|
||||
update_value_position (scale);
|
||||
update_label_request (scale);
|
||||
@@ -1462,6 +1469,25 @@ gtk_scale_measure (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkScale *scale = GTK_SCALE (widget);
|
||||
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
||||
|
||||
if (priv->top_marks_widget)
|
||||
gtk_widget_snapshot_child (widget, priv->top_marks_widget, snapshot);
|
||||
|
||||
if (priv->bottom_marks_widget)
|
||||
gtk_widget_snapshot_child (widget, priv->bottom_marks_widget, snapshot);
|
||||
|
||||
if (priv->value_widget)
|
||||
gtk_widget_snapshot_child (widget, priv->value_widget, snapshot);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_scale_parent_class)->snapshot (widget, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_real_get_layout_offsets (GtkScale *scale,
|
||||
gint *x,
|
||||
@@ -1696,7 +1722,9 @@ gtk_scale_add_mark (GtkScale *scale,
|
||||
|
||||
gtk_widget_insert_after (priv->top_marks_widget,
|
||||
GTK_WIDGET (scale),
|
||||
priv->value_widget);
|
||||
(priv->value_widget &&
|
||||
(priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)) ?
|
||||
priv->value_widget : NULL);
|
||||
gtk_widget_add_css_class (priv->top_marks_widget, GTK_STYLE_CLASS_TOP);
|
||||
}
|
||||
marks_widget = priv->top_marks_widget;
|
||||
@@ -1714,7 +1742,9 @@ gtk_scale_add_mark (GtkScale *scale,
|
||||
|
||||
gtk_widget_insert_before (priv->bottom_marks_widget,
|
||||
GTK_WIDGET (scale),
|
||||
gtk_range_get_trough_widget (GTK_RANGE (scale)));
|
||||
(priv->value_widget &&
|
||||
(priv->value_pos == GTK_POS_BOTTOM || priv->value_pos == GTK_POS_RIGHT)) ?
|
||||
priv->value_widget: NULL);
|
||||
gtk_widget_add_css_class (priv->bottom_marks_widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
}
|
||||
marks_widget = priv->bottom_marks_widget;
|
||||
|
||||
+2
-13
@@ -546,19 +546,8 @@ gtk_scrolled_window_compute_expand (GtkWidget *widget,
|
||||
gboolean *hexpand,
|
||||
gboolean *vexpand)
|
||||
{
|
||||
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
|
||||
|
||||
if (priv->child)
|
||||
{
|
||||
*hexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_HORIZONTAL);
|
||||
*vexpand = gtk_widget_compute_expand (priv->child, GTK_ORIENTATION_VERTICAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
*hexpand = FALSE;
|
||||
*vexpand = FALSE;
|
||||
}
|
||||
*hexpand = TRUE;
|
||||
*vexpand = TRUE;
|
||||
}
|
||||
|
||||
static GtkSizeRequestMode
|
||||
|
||||
@@ -1,373 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 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.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: Matthias Clasen
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkselectionfiltermodel.h"
|
||||
#include "gtkbitset.h"
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkselectionfiltermodel
|
||||
* @title: GtkSelectionFilterModel
|
||||
* @short_description: A list model that turns a selection in a model
|
||||
* @see_also: #GtkSelectionModel
|
||||
*
|
||||
* #GtkSelectionFilterModel is a list model that presents the
|
||||
* selected items in a #GtkSelectionModel as its own list model.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ITEM_TYPE,
|
||||
PROP_MODEL,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
struct _GtkSelectionFilterModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GType item_type;
|
||||
GtkSelectionModel *model;
|
||||
GtkBitset *selection;
|
||||
};
|
||||
|
||||
struct _GtkSelectionFilterModelClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
|
||||
|
||||
static GType
|
||||
gtk_selection_filter_model_get_item_type (GListModel *list)
|
||||
{
|
||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
|
||||
|
||||
return self->item_type;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_selection_filter_model_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
|
||||
|
||||
if (self->selection)
|
||||
return gtk_bitset_get_size (self->selection);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gtk_selection_filter_model_get_item (GListModel *list,
|
||||
guint position)
|
||||
{
|
||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (list);
|
||||
|
||||
position = gtk_bitset_get_nth (self->selection, position);
|
||||
|
||||
return g_list_model_get_item (G_LIST_MODEL (self->model), position);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_list_model_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = gtk_selection_filter_model_get_item_type;
|
||||
iface->get_n_items = gtk_selection_filter_model_get_n_items;
|
||||
iface->get_item = gtk_selection_filter_model_get_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkSelectionFilterModel, gtk_selection_filter_model, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_selection_filter_model_list_model_init))
|
||||
|
||||
static void
|
||||
selection_filter_model_items_changed (GtkSelectionFilterModel *self,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added)
|
||||
{
|
||||
GtkBitset *selection;
|
||||
guint sel_position = 0;
|
||||
guint sel_removed = 0;
|
||||
guint sel_added = 0;
|
||||
|
||||
selection = gtk_selection_model_get_selection (self->model);
|
||||
|
||||
if (position > 0)
|
||||
sel_position = gtk_bitset_get_size_in_range (self->selection, 0, position - 1);
|
||||
|
||||
if (removed > 0)
|
||||
sel_removed = gtk_bitset_get_size_in_range (self->selection, position, position + removed - 1);
|
||||
|
||||
if (added > 0)
|
||||
sel_added = gtk_bitset_get_size_in_range (selection, position, position + added - 1);
|
||||
|
||||
gtk_bitset_unref (self->selection);
|
||||
self->selection = gtk_bitset_copy (selection);
|
||||
|
||||
gtk_bitset_unref (selection);
|
||||
|
||||
if (sel_removed > 0 || sel_added > 0)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), sel_position, sel_removed, sel_added);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
GtkSelectionFilterModel *self)
|
||||
{
|
||||
selection_filter_model_items_changed (self, position, removed, added);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_selection_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GtkSelectionFilterModel *self)
|
||||
{
|
||||
selection_filter_model_items_changed (self, position, n_items, n_items);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ITEM_TYPE:
|
||||
self->item_type = g_value_get_gtype (value);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
gtk_selection_filter_model_set_model (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ITEM_TYPE:
|
||||
g_value_set_gtype (value, self->item_type);
|
||||
break;
|
||||
|
||||
case PROP_MODEL:
|
||||
g_value_set_object (value, self->model);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_clear_model (GtkSelectionFilterModel *self)
|
||||
{
|
||||
if (self->model == NULL)
|
||||
return;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->model, gtk_selection_filter_model_items_changed_cb, self);
|
||||
g_signal_handlers_disconnect_by_func (self->model, gtk_selection_filter_model_selection_changed_cb, self);
|
||||
|
||||
g_clear_object (&self->model);
|
||||
g_clear_pointer (&self->selection, gtk_bitset_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_dispose (GObject *object)
|
||||
{
|
||||
GtkSelectionFilterModel *self = GTK_SELECTION_FILTER_MODEL (object);
|
||||
|
||||
gtk_selection_filter_model_clear_model (self);
|
||||
|
||||
G_OBJECT_CLASS (gtk_selection_filter_model_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_class_init (GtkSelectionFilterModelClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
gobject_class->set_property = gtk_selection_filter_model_set_property;
|
||||
gobject_class->get_property = gtk_selection_filter_model_get_property;
|
||||
gobject_class->dispose = gtk_selection_filter_model_dispose;
|
||||
|
||||
/**
|
||||
* GtkSelectionFilterModel:item-type:
|
||||
*
|
||||
* The #GType for elements of this object
|
||||
*/
|
||||
properties[PROP_ITEM_TYPE] =
|
||||
g_param_spec_gtype ("item-type",
|
||||
P_("Item type"),
|
||||
P_("The type of elements of this object"),
|
||||
G_TYPE_OBJECT,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkSelectionFilterModel:model:
|
||||
*
|
||||
* The model being filtered
|
||||
*/
|
||||
properties[PROP_MODEL] =
|
||||
g_param_spec_object ("model",
|
||||
P_("Model"),
|
||||
P_("The model being filtered"),
|
||||
GTK_TYPE_SELECTION_MODEL,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_selection_filter_model_init (GtkSelectionFilterModel *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_filter_model_new:
|
||||
* @model: the selection model to filter
|
||||
*
|
||||
* Creates a new #GtkSelectionFilterModel that will include the
|
||||
* selected items from the underlying selection model.
|
||||
*
|
||||
* Returns: a new #GtkSelectionFilterModel
|
||||
**/
|
||||
GtkSelectionFilterModel *
|
||||
gtk_selection_filter_model_new (GtkSelectionModel *model)
|
||||
{
|
||||
GtkSelectionFilterModel *result;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), NULL);
|
||||
|
||||
result = g_object_new (GTK_TYPE_SELECTION_FILTER_MODEL,
|
||||
"item-type", g_list_model_get_item_type (G_LIST_MODEL (model)),
|
||||
"model", model,
|
||||
NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_filter_model_new_for_type:
|
||||
* @item_type: the type of the items that will be returned
|
||||
*
|
||||
* Creates a new empty selection filter model set up to return items
|
||||
* of type @item_type. It is up to the application to set a proper
|
||||
* selection model to ensure the item type is matched.
|
||||
*
|
||||
* Returns: a new #GtkSelectionFilterModel
|
||||
**/
|
||||
GtkSelectionFilterModel *
|
||||
gtk_selection_filter_model_new_for_type (GType item_type)
|
||||
{
|
||||
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_SELECTION_FILTER_MODEL,
|
||||
"item-type", item_type,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_filter_model_set_model:
|
||||
* @self: a #GtkSelectionFilterModel
|
||||
* @model: (allow-none): The model to be filtered
|
||||
*
|
||||
* Sets the model to be filtered.
|
||||
*
|
||||
* Note that GTK makes no effort to ensure that @model conforms to
|
||||
* the item type of @self. It assumes that the caller knows what they
|
||||
* are doing and have set up an appropriate filter to ensure that item
|
||||
* types match.
|
||||
**/
|
||||
void
|
||||
gtk_selection_filter_model_set_model (GtkSelectionFilterModel *self,
|
||||
GtkSelectionModel *model)
|
||||
{
|
||||
guint removed, added;
|
||||
|
||||
g_return_if_fail (GTK_IS_SELECTION_FILTER_MODEL (self));
|
||||
g_return_if_fail (model == NULL || GTK_IS_SELECTION_MODEL (model));
|
||||
g_return_if_fail (model == NULL || g_type_is_a (g_list_model_get_item_type (G_LIST_MODEL (model)),
|
||||
self->item_type));
|
||||
|
||||
if (self->model == model)
|
||||
return;
|
||||
|
||||
removed = g_list_model_get_n_items (G_LIST_MODEL (self));
|
||||
gtk_selection_filter_model_clear_model (self);
|
||||
|
||||
if (model)
|
||||
{
|
||||
GtkBitset *selection;
|
||||
|
||||
self->model = g_object_ref (model);
|
||||
|
||||
selection = gtk_selection_model_get_selection (self->model);
|
||||
self->selection = gtk_bitset_copy (selection);
|
||||
gtk_bitset_unref (selection);
|
||||
|
||||
g_signal_connect (model, "items-changed", G_CALLBACK (gtk_selection_filter_model_items_changed_cb), self);
|
||||
g_signal_connect (model, "selection-changed", G_CALLBACK (gtk_selection_filter_model_selection_changed_cb), self);
|
||||
}
|
||||
|
||||
added = g_list_model_get_n_items (G_LIST_MODEL (self));
|
||||
|
||||
if (removed > 0 || added > 0)
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), 0, removed, added);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_filter_model_get_model:
|
||||
* @self: a #GtkSelectionFilterModel
|
||||
*
|
||||
* Gets the model currently filtered or %NULL if none.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): The model that gets filtered
|
||||
**/
|
||||
GtkSelectionModel *
|
||||
gtk_selection_filter_model_get_model (GtkSelectionFilterModel *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SELECTION_FILTER_MODEL (self), NULL);
|
||||
|
||||
return self->model;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 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.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: Matthias Clasen
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SELECTION_FILTER_MODEL_H__
|
||||
#define __GTK_SELECTION_FILTER_MODEL_H__
|
||||
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtkselectionmodel.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_SELECTION_FILTER_MODEL (gtk_selection_filter_model_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkSelectionFilterModel, gtk_selection_filter_model, GTK, SELECTION_FILTER_MODEL, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSelectionFilterModel * gtk_selection_filter_model_new (GtkSelectionModel *model);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSelectionFilterModel * gtk_selection_filter_model_new_for_type (GType item_type);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_selection_filter_model_set_model (GtkSelectionFilterModel *self,
|
||||
GtkSelectionModel *model);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkSelectionModel * gtk_selection_filter_model_get_model (GtkSelectionFilterModel *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SELECTION_FILTER_MODEL_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user