Compare commits
106 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9dfa663990 | |||
| 831b1e1cde | |||
| 801a261250 | |||
| 93f9b2d519 | |||
| 6f3613a06f | |||
| 3723778f42 | |||
| 3fc3f8d2ff | |||
| 2868f1b509 | |||
| f44570e71a | |||
| 15d39dddc5 | |||
| 1028449bcc | |||
| 01cca279f9 | |||
| a7cae4bffa | |||
| 3e2e29a1dc | |||
| de069e15c2 | |||
| f8edefd7c0 | |||
| 24a15b51fe | |||
| 1f7aba345d | |||
| 230212c59c | |||
| 86f7c19b91 | |||
| e5cea4e39d | |||
| 22aca8952f | |||
| c0e437d163 | |||
| ffe97a453f | |||
| c09ba28b06 | |||
| 81de43eba5 | |||
| 788be8b945 | |||
| 0370979225 | |||
| 943014074c | |||
| c0e8523a01 | |||
| 8374ebe4c4 | |||
| 611d14108d | |||
| 25cf702345 | |||
| 1d9c61cada | |||
| 71adb26a0d | |||
| e27fa33690 | |||
| f7dfead861 | |||
| aac04a0995 | |||
| 8af191e52d | |||
| 06382ff836 | |||
| cd469788c3 | |||
| 44b5076cf2 | |||
| e5be9e1035 | |||
| b831d01f0d | |||
| 278bcf2680 | |||
| c19d0dc9ea | |||
| edd5ed169e | |||
| 8ec9c3fdc6 | |||
| e95022040f | |||
| 3a2ce620e2 | |||
| df49bf9eec | |||
| 53327f3aea | |||
| c0c3d75062 | |||
| d0d0409f9d | |||
| 3a7d094542 | |||
| 280adcbb8c | |||
| 83431a999c | |||
| eeeee99aa8 | |||
| 0f503e0ba2 | |||
| 3e4ae62b44 | |||
| ec4f814bd4 | |||
| 0141ba4e00 | |||
| 52ef16c21b | |||
| 6ca7104015 | |||
| 07d6166ab8 | |||
| dc651c3dc3 | |||
| f520801626 | |||
| 4e3fbd0b0f | |||
| 8a24fdea38 | |||
| b26222b6ba | |||
| c8d291ab86 | |||
| 0a87438432 | |||
| ddf1cd6678 | |||
| 9c6d5e2ca5 | |||
| 1f2561b08e | |||
| d5b31a30fd | |||
| 39c678988d | |||
| 9052c191cb | |||
| 766f442636 | |||
| 27a3d2d09e | |||
| 3a3482e41e | |||
| 44c37fa34a | |||
| 5c41dbfaa5 | |||
| c9d2ff7a0f | |||
| 174af596c5 | |||
| de2624faa7 | |||
| cda784a5f4 | |||
| cc33dbef03 | |||
| ce36611c4e | |||
| 038cb31d27 | |||
| 3b53a6b0a9 | |||
| 619ff2338e | |||
| 2bcd6949df | |||
| abd78ce5f5 | |||
| 7899fc03c4 | |||
| 9984f00781 | |||
| a0d3bdc911 | |||
| b96317b872 | |||
| 6c84958b9f | |||
| f2559b1dbb | |||
| ed2ade4801 | |||
| 4549172825 | |||
| b877804eb6 | |||
| 5310abbcf7 | |||
| 490d4b0b9e | |||
| 230188fb30 |
+41
-28
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
|
||||
|
||||
@@ -26,6 +25,9 @@ struct _CanvasItem {
|
||||
double delta;
|
||||
|
||||
GtkWidget *editor;
|
||||
|
||||
GtkStyleProvider *provider;
|
||||
char *css_class;
|
||||
};
|
||||
|
||||
struct _CanvasItemClass {
|
||||
@@ -36,32 +38,41 @@ G_DEFINE_TYPE (CanvasItem, canvas_item, GTK_TYPE_WIDGET)
|
||||
|
||||
static int n_items = 0;
|
||||
|
||||
static void
|
||||
unstyle_item (CanvasItem *item)
|
||||
{
|
||||
if (item->provider)
|
||||
{
|
||||
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (item->label), item->provider);
|
||||
g_clear_object (&item->provider);
|
||||
}
|
||||
|
||||
if (item->css_class)
|
||||
{
|
||||
gtk_widget_remove_css_class (item->label, item->css_class);
|
||||
g_clear_pointer (&item->css_class, g_free);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_color (CanvasItem *item,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
char *css;
|
||||
char *str;
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
const char *name;
|
||||
|
||||
unstyle_item (item);
|
||||
|
||||
str = gdk_rgba_to_string (color);
|
||||
css = g_strdup_printf ("* { background: %s; }", str);
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
name = gtk_widget_get_name (item->label);
|
||||
css = g_strdup_printf ("#%s { background: %s; }", name, str);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
|
||||
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
|
||||
item->provider = GTK_STYLE_PROVIDER (provider);
|
||||
|
||||
g_free (str);
|
||||
g_free (css);
|
||||
@@ -71,21 +82,10 @@ static void
|
||||
set_css (CanvasItem *item,
|
||||
const char *class)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
unstyle_item (item);
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
|
||||
gtk_widget_add_css_class (item->label, class);
|
||||
item->css_class = g_strdup (class);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -724,6 +724,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
int i;
|
||||
int x, y;
|
||||
GtkCssProvider *provider;
|
||||
GString *css;
|
||||
|
||||
button = gtk_color_button_new ();
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
@@ -735,6 +736,18 @@ do_dnd (GtkWidget *do_widget)
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
|
||||
css = g_string_new ("");
|
||||
for (i = 0; colors[i]; i++)
|
||||
g_string_append_printf (css, ".canvasitem.%s { background: %s; }\n", colors[i], colors[i]);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css->str, css->len);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
g_string_free (css, TRUE);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *font_button = NULL;
|
||||
static GtkWidget *entry = NULL;
|
||||
@@ -45,7 +43,6 @@ update_image (void)
|
||||
cairo_t *cr;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *pixbuf2;
|
||||
const char *hint;
|
||||
cairo_font_options_t *fopt;
|
||||
cairo_hint_style_t hintstyle;
|
||||
cairo_hint_metrics_t hintmetrics;
|
||||
@@ -60,18 +57,23 @@ update_image (void)
|
||||
|
||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||
|
||||
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
|
||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||
if (hint)
|
||||
switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting)))
|
||||
{
|
||||
if (strcmp (hint, "none") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||
else if (strcmp (hint, "slight") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
else if (strcmp (hint, "medium") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||
else if (strcmp (hint, "full") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||
case 0:
|
||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||
break;
|
||||
case 1:
|
||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
break;
|
||||
case 2:
|
||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||
break;
|
||||
case 3:
|
||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||
break;
|
||||
default:
|
||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||
break;
|
||||
}
|
||||
cairo_font_options_set_hint_style (fopt, hintstyle);
|
||||
|
||||
@@ -420,7 +422,7 @@ do_fontrendering (GtkWidget *do_widget)
|
||||
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
|
||||
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (hinting, "notify::selected", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
|
||||
@@ -116,15 +116,18 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="hinting">
|
||||
<property name="active">0</property>
|
||||
<object class="GtkDropDown" id="hinting">
|
||||
<property name="valign">center</property>
|
||||
<items>
|
||||
<item translatable="yes" id="none">None</item>
|
||||
<item translatable="yes" id="slight">Slight</item>
|
||||
<item translatable="yes" id="medium">Medium</item>
|
||||
<item translatable="yes" id="full">Full</item>
|
||||
</items>
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
<item translatable="yes">None</item>
|
||||
<item translatable="yes">Slight</item>
|
||||
<item translatable="yes">Medium</item>
|
||||
<item translatable="yes">Full</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<layout>
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "gtkshadertoy.h"
|
||||
#include "gskshaderpaintable.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *demo_window = NULL;
|
||||
|
||||
static void
|
||||
@@ -146,7 +144,6 @@ make_shader_stack (const char *name,
|
||||
GtkTextBuffer *buffer;
|
||||
GBytes *bytes;
|
||||
GtkEventController *controller;
|
||||
GtkCssProvider *provider;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
stack = gtk_shader_stack_new ();
|
||||
@@ -237,12 +234,6 @@ make_shader_stack (const char *name,
|
||||
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
|
||||
g_object_set_data (G_OBJECT (button), "the-stack", stack);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref (provider);
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
@@ -276,11 +267,21 @@ make_shader_stack (const char *name,
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_gltransition_window (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
|
||||
GdkPaintable *paintable;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
@@ -335,6 +336,14 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
|
||||
1, 1, 1, 1);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "script-names.h"
|
||||
#include "unicode-names.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
#define UCD_TYPE_ITEM (ucd_item_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
|
||||
|
||||
@@ -339,6 +337,15 @@ create_ucd_view (GtkWidget *label)
|
||||
|
||||
static GtkWidget *window;
|
||||
|
||||
static void
|
||||
remove_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_ucd (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -361,7 +368,7 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
gtk_widget_add_css_class (label, "enormous");
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
||||
@@ -371,6 +378,8 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||
gtk_box_prepend (GTK_BOX (box), sw);
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "config.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/* Create an object for the pegs that get moved around in the game.
|
||||
*
|
||||
@@ -361,6 +360,15 @@ drop_drop (GtkDropTarget *target,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
create_board (GtkWidget *window)
|
||||
{
|
||||
@@ -377,6 +385,9 @@ create_board (GtkWidget *window)
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
|
||||
@@ -395,9 +406,6 @@ create_board (GtkWidget *window)
|
||||
continue;
|
||||
|
||||
image = gtk_image_new ();
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (image),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
gtk_widget_add_css_class (image, "solitaire-field");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
if (x != 3 || y != 3)
|
||||
@@ -441,7 +449,7 @@ create_board (GtkWidget *window)
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (provider);
|
||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -16,7 +16,6 @@ enum {
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
static void
|
||||
pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
@@ -37,7 +36,6 @@ pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||
|
||||
g_object_unref (texture);
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
static int
|
||||
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
|
||||
@@ -16,26 +16,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/* Convenience function to create a combo box holding a number of strings
|
||||
*/
|
||||
GtkWidget *
|
||||
create_combo_box (const char **strings)
|
||||
{
|
||||
GtkWidget *combo_box;
|
||||
const char **str;
|
||||
|
||||
combo_box = gtk_combo_box_text_new ();
|
||||
|
||||
for (str = strings; *str; str++)
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), *str);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
|
||||
|
||||
return combo_box;
|
||||
}
|
||||
|
||||
static void
|
||||
add_row (GtkGrid *table,
|
||||
int row,
|
||||
@@ -43,7 +23,7 @@ add_row (GtkGrid *table,
|
||||
const char *label_text,
|
||||
const char **options)
|
||||
{
|
||||
GtkWidget *combo_box;
|
||||
GtkWidget *dropdown;
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new_with_mnemonic (label_text);
|
||||
@@ -52,12 +32,12 @@ add_row (GtkGrid *table,
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (table, label, 0, row, 1, 1);
|
||||
|
||||
combo_box = create_combo_box (options);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
|
||||
gtk_widget_set_halign (combo_box, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (combo_box, GTK_ALIGN_BASELINE);
|
||||
gtk_size_group_add_widget (size_group, combo_box);
|
||||
gtk_grid_attach (table, combo_box, 1, row, 1, 1);
|
||||
dropdown = gtk_drop_down_new_from_strings (options);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dropdown);
|
||||
gtk_widget_set_halign (dropdown, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (dropdown, GTK_ALIGN_BASELINE);
|
||||
gtk_size_group_add_widget (size_group, dropdown);
|
||||
gtk_grid_attach (table, dropdown, 1, row, 1, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <stdlib.h> /* for exit() */
|
||||
#include "paintable.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void easter_egg_callback (GtkWidget *button, gpointer data);
|
||||
|
||||
@@ -431,11 +430,11 @@ attach_widgets (GtkTextView *text_view)
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
widget = gtk_combo_box_text_new ();
|
||||
const char *options[] = {
|
||||
"Option 1", "Option 2", "Option 3", NULL
|
||||
};
|
||||
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 1");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 2");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 3");
|
||||
widget = gtk_drop_down_new_from_strings (options);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
|
||||
+11
-10
@@ -1,8 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkApplication parent_instance;
|
||||
@@ -352,7 +350,8 @@ quit_activated (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
combo_changed (GtkComboBox *combo,
|
||||
combo_changed (GtkDropDown *combo,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkDialog *dialog = user_data;
|
||||
@@ -361,7 +360,7 @@ combo_changed (GtkComboBox *combo,
|
||||
char **accels;
|
||||
char *str;
|
||||
|
||||
action = gtk_combo_box_get_active_id (combo);
|
||||
action = gtk_drop_down_get_selected_string (combo);
|
||||
|
||||
if (!action)
|
||||
return;
|
||||
@@ -390,7 +389,7 @@ response (GtkDialog *dialog,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
||||
GtkComboBox *combo = g_object_get_data (user_data, "combo");
|
||||
GtkDropDown *combo = g_object_get_data (user_data, "combo");
|
||||
const char *action;
|
||||
const char *str;
|
||||
char **accels;
|
||||
@@ -401,7 +400,7 @@ response (GtkDialog *dialog,
|
||||
return;
|
||||
}
|
||||
|
||||
action = gtk_combo_box_get_active_id (combo);
|
||||
action = gtk_drop_down_get_selected_string (combo);
|
||||
|
||||
if (!action)
|
||||
return;
|
||||
@@ -426,6 +425,7 @@ edit_accels (GSimpleAction *action,
|
||||
char **actions;
|
||||
GtkWidget *dialog;
|
||||
int i;
|
||||
GtkStringList *strings;
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Accelerators",
|
||||
NULL,
|
||||
@@ -437,7 +437,8 @@ edit_accels (GSimpleAction *action,
|
||||
gtk_window_set_application (GTK_WINDOW (dialog), app);
|
||||
actions = gtk_application_list_action_descriptions (app);
|
||||
|
||||
combo = gtk_combo_box_text_new ();
|
||||
strings = gtk_string_list_new (NULL);
|
||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
|
||||
"margin-top", 10,
|
||||
"margin-bottom", 10,
|
||||
@@ -448,8 +449,8 @@ edit_accels (GSimpleAction *action,
|
||||
|
||||
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), combo);
|
||||
for (i = 0; actions[i]; i++)
|
||||
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), actions[i], actions[i]);
|
||||
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed), dialog);
|
||||
gtk_string_list_append (strings, actions[i]);
|
||||
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_widget_set_hexpand (entry, TRUE);
|
||||
@@ -460,7 +461,7 @@ edit_accels (GSimpleAction *action,
|
||||
g_object_set_data (G_OBJECT (dialog), "combo", combo);
|
||||
g_object_set_data (G_OBJECT (dialog), "entry", entry);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
@@ -436,6 +436,7 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
|
||||
completion->inline_selection = FALSE;
|
||||
|
||||
completion->filter_model = NULL;
|
||||
completion->insert_text_signal_group = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1384,13 +1385,12 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
||||
{
|
||||
int len;
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
if (completion->changed_id > 0)
|
||||
g_signal_handler_block (text, completion->changed_id);
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_block (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_block (completion->insert_text_signal_group);
|
||||
|
||||
gtk_editable_set_text (GTK_EDITABLE (completion->entry), new_text);
|
||||
|
||||
@@ -1400,8 +1400,8 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
||||
if (completion->changed_id > 0)
|
||||
g_signal_handler_unblock (text, completion->changed_id);
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_unblock (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_unblock (completion->insert_text_signal_group);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1440,11 +1440,9 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
|
||||
|
||||
gboolean done;
|
||||
char *prefix;
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_block (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_block (completion->insert_text_signal_group);
|
||||
|
||||
prefix = gtk_entry_completion_compute_prefix (completion,
|
||||
gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
|
||||
@@ -1456,8 +1454,8 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
|
||||
g_free (prefix);
|
||||
}
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_unblock (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_unblock (completion->insert_text_signal_group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2098,7 +2096,6 @@ connect_completion_signals (GtkEntryCompletion *completion)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
controller = completion->entry_key_controller = gtk_event_controller_key_new ();
|
||||
gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
|
||||
@@ -2113,8 +2110,10 @@ connect_completion_signals (GtkEntryCompletion *completion)
|
||||
completion->changed_id =
|
||||
g_signal_connect (text, "changed", G_CALLBACK (gtk_entry_completion_changed), completion);
|
||||
|
||||
completion->insert_text_id =
|
||||
g_signal_connect (buffer, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
|
||||
completion->insert_text_signal_group = g_signal_group_new (GTK_TYPE_ENTRY_BUFFER);
|
||||
g_signal_group_connect (completion->insert_text_signal_group, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
|
||||
g_object_bind_property (text, "buffer", completion->insert_text_signal_group, "target", G_BINDING_SYNC_CREATE);
|
||||
|
||||
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
|
||||
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
|
||||
}
|
||||
@@ -2123,7 +2122,6 @@ static void
|
||||
disconnect_completion_signals (GtkEntryCompletion *completion)
|
||||
{
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_key_controller);
|
||||
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_focus_controller);
|
||||
@@ -2134,12 +2132,9 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
|
||||
g_signal_handler_disconnect (text, completion->changed_id);
|
||||
completion->changed_id = 0;
|
||||
}
|
||||
if (completion->insert_text_id > 0 &&
|
||||
g_signal_handler_is_connected (buffer, completion->insert_text_id))
|
||||
{
|
||||
g_signal_handler_disconnect (buffer, completion->insert_text_id);
|
||||
completion->insert_text_id = 0;
|
||||
}
|
||||
|
||||
g_clear_object (&completion->insert_text_signal_group);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (clear_completion_callback), completion);
|
||||
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (accept_completion_callback), completion);
|
||||
}
|
||||
|
||||
+10
-2
@@ -27,6 +27,8 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gsettings-mapping.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -846,9 +848,15 @@ gtk_action_muxer_activate_action (GtkActionMuxer *muxer,
|
||||
if (!_gtk_bitmask_get (muxer->widget_actions_disabled, position))
|
||||
{
|
||||
if (action->activate)
|
||||
action->activate (muxer->widget, action->name, parameter);
|
||||
{
|
||||
GTK_DEBUG (ACTIONS, "%s: activate action", action->name);
|
||||
action->activate (muxer->widget, action->name, parameter);
|
||||
}
|
||||
else if (action->pspec)
|
||||
prop_action_activate (muxer->widget, action, parameter);
|
||||
{
|
||||
GTK_DEBUG (ACTIONS, "%s: activate prop action", action->pspec->name);
|
||||
prop_action_activate (muxer->widget, action, parameter);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "gtkcomposetable.h"
|
||||
#include "gtkimcontextsimple.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
|
||||
#define GTK_COMPOSE_TABLE_MAGIC "GtkComposeTable"
|
||||
|
||||
+102
-2
@@ -133,6 +133,7 @@ enum
|
||||
PROP_MODEL,
|
||||
PROP_SELECTED,
|
||||
PROP_SELECTED_ITEM,
|
||||
PROP_SELECTED_STRING,
|
||||
PROP_ENABLE_SEARCH,
|
||||
PROP_EXPRESSION,
|
||||
PROP_SHOW_ARROW,
|
||||
@@ -247,6 +248,7 @@ selection_item_changed (GtkSingleSelection *selection,
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED_ITEM]);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED_STRING]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -358,6 +360,10 @@ gtk_drop_down_get_property (GObject *object,
|
||||
g_value_set_object (value, gtk_drop_down_get_selected_item (self));
|
||||
break;
|
||||
|
||||
case PROP_SELECTED_STRING:
|
||||
g_value_set_string (value, gtk_drop_down_get_selected_string (self));
|
||||
break;
|
||||
|
||||
case PROP_ENABLE_SEARCH:
|
||||
g_value_set_boolean (value, self->enable_search);
|
||||
break;
|
||||
@@ -402,6 +408,10 @@ gtk_drop_down_set_property (GObject *object,
|
||||
gtk_drop_down_set_selected (self, g_value_get_uint (value));
|
||||
break;
|
||||
|
||||
case PROP_SELECTED_STRING:
|
||||
gtk_drop_down_set_selected_string (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_ENABLE_SEARCH:
|
||||
gtk_drop_down_set_enable_search (self, g_value_get_boolean (value));
|
||||
break;
|
||||
@@ -545,6 +555,22 @@ gtk_drop_down_class_init (GtkDropDownClass *klass)
|
||||
G_TYPE_OBJECT,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkDropDown:selected-string: (attributes org.gtk.Property.get=gtk_drop_down_get_selected_string org.gtk.Property.set=gtk_drop_down_set_selected_string)
|
||||
*
|
||||
* The value of the string property of the selected item,
|
||||
* if it is a [class@Gtk.StringObject].
|
||||
*
|
||||
* This is only useful for dropdowns with a [class@Gtk.StringList] as model,
|
||||
* such as those created by [ctor@Gtk.DropDown.new_from_strings].
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_SELECTED_STRING] =
|
||||
g_param_spec_string ("selected-string", NULL, NULL,
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkDropDown:enable-search: (attributes org.gtk.Property.get=gtk_drop_down_get_enable_search org.gtk.Property.set=gtk_drop_down_set_enable_search)
|
||||
*
|
||||
@@ -784,8 +810,7 @@ gtk_drop_down_new (GListModel *model,
|
||||
* gtk_drop_down_new_from_strings:
|
||||
* @strings: (array zero-terminated=1): The strings to put in the dropdown
|
||||
*
|
||||
* Creates a new `GtkDropDown` that is populated with
|
||||
* the strings.
|
||||
* Creates a new `GtkDropDown` that is populated with the strings.
|
||||
*
|
||||
* Returns: a new `GtkDropDown`
|
||||
*/
|
||||
@@ -1016,6 +1041,81 @@ gtk_drop_down_get_selected_item (GtkDropDown *self)
|
||||
return gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (self->selection));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_drop_down_get_selected_string: (attributes org.gtk.Method.get_property=selected-string)
|
||||
* @self: a `GtkDropDown`
|
||||
*
|
||||
* Gets the string value for the selected [class@Gtk.StringObject].
|
||||
*
|
||||
* If no item is selected, or items are of another type, %NULL is returned.
|
||||
*
|
||||
* This function is meant for dropdowns with a [class@Gtk.StringList] as model,
|
||||
* such as those created by [ctor@Gtk.DropDown.new_from_strings].
|
||||
*
|
||||
* Returns: (transfer none) (nullable): The string value for selected item
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char *
|
||||
gtk_drop_down_get_selected_string (GtkDropDown *self)
|
||||
{
|
||||
gpointer item;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_DROP_DOWN (self), NULL);
|
||||
|
||||
if (self->selection == NULL)
|
||||
return NULL;
|
||||
|
||||
item = gtk_single_selection_get_selected_item (GTK_SINGLE_SELECTION (self->selection));
|
||||
|
||||
if (GTK_IS_STRING_OBJECT (item))
|
||||
return gtk_string_object_get_string (GTK_STRING_OBJECT (item));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_drop_down_set_selected_string:
|
||||
* @self: a `GtkDropDown`
|
||||
* @string: the string to select
|
||||
*
|
||||
* Selects the first [class@Gtk.StringObject] whose string property
|
||||
* matches @string.
|
||||
*
|
||||
* If items are not `GtkStringObjects`, the selection is not changed.
|
||||
*
|
||||
* This function is meant for dropdowns with a [class@Gtk.StringList] as model,
|
||||
* such as those created by [ctor@Gtk.DropDown.new_from_strings].
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_drop_down_set_selected_string (GtkDropDown *self,
|
||||
const char *string)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_DROP_DOWN (self));
|
||||
g_return_if_fail (string != NULL);
|
||||
|
||||
if (self->selection == NULL)
|
||||
return;
|
||||
|
||||
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self->selection)); i++)
|
||||
{
|
||||
gpointer item = g_list_model_get_item (G_LIST_MODEL (self->selection), i);
|
||||
|
||||
g_object_unref (item);
|
||||
|
||||
if (!GTK_IS_STRING_OBJECT (item))
|
||||
break;
|
||||
|
||||
if (g_str_equal (gtk_string_object_get_string (GTK_STRING_OBJECT (item)), string))
|
||||
{
|
||||
gtk_single_selection_set_selected (GTK_SINGLE_SELECTION (self->selection), i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_drop_down_set_enable_search: (attributes org.gtk.Method.set_property=enable-search)
|
||||
* @self: a `GtkDropDown`
|
||||
|
||||
@@ -52,6 +52,13 @@ guint gtk_drop_down_get_selected (GtkDropDown
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gpointer gtk_drop_down_get_selected_item (GtkDropDown *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_drop_down_get_selected_string (GtkDropDown *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_drop_down_set_selected_string (GtkDropDown *self,
|
||||
const char *string);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_drop_down_set_factory (GtkDropDown *self,
|
||||
GtkListItemFactory *factory);
|
||||
|
||||
@@ -61,7 +61,8 @@ struct _GtkEntryCompletion
|
||||
|
||||
gulong completion_timeout;
|
||||
gulong changed_id;
|
||||
gulong insert_text_id;
|
||||
|
||||
GSignalGroup *insert_text_signal_group;
|
||||
|
||||
int current_selected;
|
||||
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Copyright © 2022 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 <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfilechoosercellprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturelongpress.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtklistitem.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
|
||||
struct _GtkFileChooserCell
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GFileInfo *item;
|
||||
gboolean selected;
|
||||
guint position;
|
||||
|
||||
gboolean show_time;
|
||||
};
|
||||
|
||||
struct _GtkFileChooserCellClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK_TYPE_WIDGET)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_POSITION = 1,
|
||||
PROP_SELECTED,
|
||||
PROP_ITEM,
|
||||
PROP_SHOW_TIME,
|
||||
};
|
||||
|
||||
#define ICON_SIZE 16
|
||||
|
||||
static void
|
||||
popup_menu (GtkFileChooserCell *self,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (self);
|
||||
GtkSelectionModel *model;
|
||||
GtkWidget *impl;
|
||||
double xx, yy;
|
||||
|
||||
impl = gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_CHOOSER_WIDGET);
|
||||
|
||||
model = gtk_file_chooser_widget_get_selection_model (GTK_FILE_CHOOSER_WIDGET (impl));
|
||||
gtk_selection_model_select_item (model, self->position, TRUE);
|
||||
|
||||
gtk_widget_translate_coordinates (widget, GTK_WIDGET (impl),
|
||||
x, y, &xx, &yy);
|
||||
|
||||
gtk_widget_activate_action (widget, "item.popup-file-list-menu",
|
||||
"(udd)", self->position, xx, yy);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_cell_clicked (GtkEventController *controller,
|
||||
int n_press,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
popup_menu (self, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_cell_long_pressed (GtkEventController *controller,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
popup_menu (self, x, y);
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
drag_prepare_cb (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkContentProvider *provider;
|
||||
GSList *selection;
|
||||
GtkFileChooserWidget *impl;
|
||||
GtkIconTheme *icon_theme;
|
||||
GIcon *icon;
|
||||
int scale;
|
||||
GtkIconPaintable *paintable;
|
||||
GtkFileChooserCell *self = user_data;
|
||||
|
||||
impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (self),
|
||||
GTK_TYPE_FILE_CHOOSER_WIDGET));
|
||||
|
||||
if (!self->selected)
|
||||
{
|
||||
gtk_selection_model_select_item (gtk_file_chooser_widget_get_selection_model (impl),
|
||||
self->position, TRUE);
|
||||
}
|
||||
|
||||
selection = gtk_file_chooser_widget_get_selected_files (impl);
|
||||
if (!selection)
|
||||
return NULL;
|
||||
|
||||
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
|
||||
|
||||
icon = _gtk_file_info_get_icon (self->item, ICON_SIZE, scale, icon_theme);
|
||||
|
||||
paintable = gtk_icon_theme_lookup_by_gicon (icon_theme,icon, ICON_SIZE, scale, GTK_TEXT_DIR_NONE, 0);
|
||||
|
||||
gtk_drag_source_set_icon (source, GDK_PAINTABLE (paintable), x, y);
|
||||
|
||||
provider = gdk_content_provider_new_typed (GDK_TYPE_FILE_LIST, selection);
|
||||
g_slist_free_full (selection, g_object_unref);
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (icon);
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
|
||||
GtkFileChooserWidget *impl;
|
||||
|
||||
impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (self),
|
||||
GTK_TYPE_FILE_CHOOSER_WIDGET));
|
||||
|
||||
g_object_bind_property (impl, "show-time", self, "show-time", G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_init (GtkFileChooserCell *self)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkDragSource *drag_source;
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (file_chooser_cell_clicked), NULL);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
gesture = gtk_gesture_long_press_new ();
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (file_chooser_cell_long_pressed), NULL);
|
||||
|
||||
drag_source = gtk_drag_source_new ();
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drag_source));
|
||||
g_signal_connect (drag_source, "prepare", G_CALLBACK (drag_prepare_cb), self);
|
||||
|
||||
g_signal_connect (self, "realize", G_CALLBACK (gtk_file_chooser_cell_realize), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_dispose (GObject *object)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))))
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
G_OBJECT_CLASS (gtk_file_chooser_cell_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_POSITION:
|
||||
self->position = g_value_get_uint (value);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED:
|
||||
self->selected = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_ITEM:
|
||||
self->item = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_SHOW_TIME:
|
||||
self->show_time = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_POSITION:
|
||||
g_value_set_uint (value, self->position);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED:
|
||||
g_value_set_boolean (value, self->selected);
|
||||
break;
|
||||
|
||||
case PROP_ITEM:
|
||||
g_value_set_object (value, self->item);
|
||||
break;
|
||||
|
||||
case PROP_SHOW_TIME:
|
||||
g_value_set_boolean (value, self->show_time);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_class_init (GtkFileChooserCellClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_file_chooser_cell_dispose;
|
||||
object_class->set_property = gtk_file_chooser_cell_set_property;
|
||||
object_class->get_property = gtk_file_chooser_cell_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_POSITION,
|
||||
g_param_spec_uint ("position", NULL, NULL,
|
||||
0, G_MAXUINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SELECTED,
|
||||
g_param_spec_boolean ("selected", NULL, NULL,
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ITEM,
|
||||
g_param_spec_object ("item", NULL, NULL,
|
||||
G_TYPE_FILE_INFO,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SHOW_TIME,
|
||||
g_param_spec_boolean ("show-time", NULL, NULL,
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("filelistcell"));
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
|
||||
GtkFileChooserCell *
|
||||
gtk_file_chooser_cell_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_FILE_CHOOSER_CELL, NULL);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright © 2022 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_FILE_CHOOSER_CELL_PRIVATE_H__
|
||||
#define __GTK_FILE_CHOOSER_CELL_PRIVATE_H__
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <gtk/gtkexpression.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FILE_CHOOSER_CELL (gtk_file_chooser_cell_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK, FILE_CHOOSER_CELL, GtkWidget)
|
||||
|
||||
GtkFileChooserCell * gtk_file_chooser_cell_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_CELL_PRIVATE_H__ */
|
||||
+83
-72
@@ -60,7 +60,8 @@ struct _GtkFileChooserEntry
|
||||
char *dir_part;
|
||||
char *file_part;
|
||||
|
||||
GtkTreeModel *completion_store;
|
||||
GtkTreeStore *completion_store;
|
||||
GtkFileSystemModel *model;
|
||||
GtkFileFilter *current_filter;
|
||||
|
||||
guint current_folder_loaded : 1;
|
||||
@@ -71,6 +72,7 @@ struct _GtkFileChooserEntry
|
||||
|
||||
enum
|
||||
{
|
||||
FILE_INFO_COLUMN,
|
||||
DISPLAY_NAME_COLUMN,
|
||||
FULL_PATH_COLUMN,
|
||||
N_COLUMNS
|
||||
@@ -197,20 +199,21 @@ match_func (GtkEntryCompletion *compl,
|
||||
* current file filter (e.g. just jpg files) here. */
|
||||
if (chooser_entry->current_filter != NULL)
|
||||
{
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
|
||||
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);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
|
||||
iter,
|
||||
FILE_INFO_COLUMN, &info,
|
||||
-1);
|
||||
|
||||
g_assert (info != NULL);
|
||||
g_object_unref (info);
|
||||
|
||||
/* We always allow navigating into subfolders, so don't ever filter directories */
|
||||
if (g_file_info_get_file_type (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));
|
||||
g_assert (g_file_info_has_attribute (info, "standard::file"));
|
||||
|
||||
return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
|
||||
}
|
||||
@@ -428,7 +431,7 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
chooser_entry->complete_on_load = FALSE;
|
||||
|
||||
if (chooser_entry->completion_store)
|
||||
if (chooser_entry->model)
|
||||
{
|
||||
char *completion, *text;
|
||||
gsize completion_len, text_len;
|
||||
@@ -539,77 +542,93 @@ update_inline_completion (GtkFileChooserEntry *chooser_entry)
|
||||
static void
|
||||
discard_completion_store (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
if (!chooser_entry->completion_store)
|
||||
if (!chooser_entry->model)
|
||||
return;
|
||||
|
||||
g_assert (chooser_entry->completion_store != NULL);
|
||||
|
||||
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);
|
||||
update_inline_completion (chooser_entry);
|
||||
g_object_unref (chooser_entry->completion_store);
|
||||
chooser_entry->completion_store = NULL;
|
||||
g_clear_object (&chooser_entry->completion_store);
|
||||
g_clear_object (&chooser_entry->model);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
completion_store_set (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
GFileInfo *info,
|
||||
int column,
|
||||
GValue *value,
|
||||
gpointer data)
|
||||
static void
|
||||
model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
GtkFileChooserEntry *self)
|
||||
{
|
||||
GtkFileChooserEntry *chooser_entry = data;
|
||||
|
||||
const char *prefix = "";
|
||||
const char *suffix = "";
|
||||
|
||||
switch (column)
|
||||
if (removed > 0)
|
||||
{
|
||||
case FULL_PATH_COLUMN:
|
||||
prefix = chooser_entry->dir_part;
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case DISPLAY_NAME_COLUMN:
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->completion_store),
|
||||
&iter,
|
||||
NULL,
|
||||
position))
|
||||
{
|
||||
while (removed--)
|
||||
gtk_tree_store_remove (self->completion_store, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
while (added-- > 0)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GFileInfo *info;
|
||||
const char *suffix = NULL;
|
||||
char *full_path;
|
||||
char *display_name;
|
||||
|
||||
info = g_list_model_get_item (model, position);
|
||||
|
||||
if (_gtk_file_info_consider_as_directory (info))
|
||||
suffix = G_DIR_SEPARATOR_S;
|
||||
|
||||
g_value_take_string (value,
|
||||
g_strconcat (prefix,
|
||||
g_file_info_get_display_name (info),
|
||||
suffix,
|
||||
NULL));
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
display_name = g_strconcat (g_file_info_get_display_name (info), suffix, NULL);
|
||||
full_path = g_strconcat (self->dir_part, display_name, NULL);
|
||||
|
||||
return TRUE;
|
||||
gtk_tree_store_insert_with_values (self->completion_store,
|
||||
&iter, NULL,
|
||||
position,
|
||||
FILE_INFO_COLUMN, info,
|
||||
FULL_PATH_COLUMN, full_path,
|
||||
DISPLAY_NAME_COLUMN, display_name,
|
||||
-1);
|
||||
|
||||
g_clear_object (&info);
|
||||
|
||||
position++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fills the completion store from the contents of the current folder */
|
||||
static void
|
||||
populate_completion_store (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
chooser_entry->completion_store = GTK_TREE_MODEL (
|
||||
chooser_entry->completion_store = gtk_tree_store_new (N_COLUMNS,
|
||||
G_TYPE_FILE_INFO,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
chooser_entry->model =
|
||||
_gtk_file_system_model_new_for_directory (chooser_entry->current_folder_file,
|
||||
"standard::name,standard::display-name,standard::type,"
|
||||
"standard::content-type",
|
||||
completion_store_set,
|
||||
chooser_entry,
|
||||
N_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING));
|
||||
g_signal_connect (chooser_entry->completion_store, "finished-loading",
|
||||
"standard::content-type");
|
||||
g_signal_connect (chooser_entry->model, "items-changed",
|
||||
G_CALLBACK (model_items_changed_cb), chooser_entry);
|
||||
g_signal_connect (chooser_entry->model, "finished-loading",
|
||||
G_CALLBACK (finished_loading_cb), chooser_entry);
|
||||
|
||||
_gtk_file_system_model_set_filter_folders (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
TRUE);
|
||||
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
_gtk_file_system_model_set_filter_folders (chooser_entry->model, TRUE);
|
||||
_gtk_file_system_model_set_show_files (chooser_entry->model,
|
||||
chooser_entry->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
chooser_entry->action == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store),
|
||||
DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
|
||||
|
||||
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
|
||||
chooser_entry->completion_store);
|
||||
GTK_TREE_MODEL (chooser_entry->completion_store));
|
||||
}
|
||||
|
||||
/* Callback when the current folder finishes loading */
|
||||
@@ -637,7 +656,7 @@ finished_loading_cb (GtkFileSystemModel *model,
|
||||
completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry));
|
||||
update_inline_completion (chooser_entry);
|
||||
|
||||
if (gtk_widget_has_focus (GTK_WIDGET (chooser_entry)))
|
||||
if (gtk_widget_has_focus (GTK_WIDGET (gtk_entry_get_text_widget (GTK_ENTRY (chooser_entry)))))
|
||||
{
|
||||
gtk_entry_completion_complete (completion);
|
||||
gtk_entry_completion_insert_prefix (completion);
|
||||
@@ -658,11 +677,7 @@ set_completion_folder (GtkFileChooserEntry *chooser_entry,
|
||||
return;
|
||||
}
|
||||
|
||||
if (chooser_entry->current_folder_file)
|
||||
{
|
||||
g_object_unref (chooser_entry->current_folder_file);
|
||||
chooser_entry->current_folder_file = NULL;
|
||||
}
|
||||
g_clear_object (&chooser_entry->current_folder_file);
|
||||
|
||||
g_free (chooser_entry->dir_part);
|
||||
chooser_entry->dir_part = g_strdup (dir_part);
|
||||
@@ -710,7 +725,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
|
||||
|
||||
g_free (dir_part);
|
||||
|
||||
if (chooser_entry->completion_store &&
|
||||
if (chooser_entry->model &&
|
||||
(g_strcmp0 (old_file_part, chooser_entry->file_part) != 0))
|
||||
{
|
||||
GtkFileFilter *filter;
|
||||
@@ -720,8 +735,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
|
||||
pattern = g_strconcat (chooser_entry->file_part, "*", NULL);
|
||||
gtk_file_filter_add_pattern (filter, pattern);
|
||||
|
||||
_gtk_file_system_model_set_filter (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
filter);
|
||||
_gtk_file_system_model_set_filter (chooser_entry->model, filter);
|
||||
|
||||
g_free (pattern);
|
||||
g_object_unref (filter);
|
||||
@@ -940,8 +954,8 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
|
||||
break;
|
||||
}
|
||||
|
||||
if (chooser_entry->completion_store)
|
||||
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
if (chooser_entry->model)
|
||||
_gtk_file_system_model_set_show_files (chooser_entry->model,
|
||||
action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
action == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
@@ -971,17 +985,14 @@ gboolean
|
||||
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
|
||||
GFile *file)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GFileInfo *info;
|
||||
|
||||
if (chooser_entry->completion_store == NULL ||
|
||||
!_gtk_file_system_model_get_iter_for_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
&iter,
|
||||
file))
|
||||
if (chooser_entry->model == NULL)
|
||||
return FALSE;
|
||||
|
||||
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
&iter);
|
||||
info = _gtk_file_system_model_get_info_for_file (chooser_entry->model, file);
|
||||
if (!info)
|
||||
return FALSE;
|
||||
|
||||
return _gtk_file_info_consider_as_directory (info);
|
||||
}
|
||||
|
||||
@@ -479,3 +479,12 @@ _gtk_file_info_get_icon (GFileInfo *info,
|
||||
icon = g_themed_icon_new ("text-x-generic");
|
||||
return icon;
|
||||
}
|
||||
|
||||
GFile *
|
||||
_gtk_file_info_get_file (GFileInfo *info)
|
||||
{
|
||||
g_assert (G_IS_FILE_INFO (info));
|
||||
g_assert (g_file_info_has_attribute (info, "standard::file"));
|
||||
|
||||
return G_FILE (g_file_info_get_attribute_object (info, "standard::file"));
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ GIcon * _gtk_file_info_get_icon (GFileInfo *info,
|
||||
int scale,
|
||||
GtkIconTheme *icon_theme);
|
||||
|
||||
GFile * _gtk_file_info_get_file (GFileInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
|
||||
|
||||
+1124
-1868
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -36,6 +37,12 @@ gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *chooser);
|
||||
void
|
||||
gtk_file_chooser_widget_initial_focus (GtkFileChooserWidget *chooser);
|
||||
|
||||
GSList *
|
||||
gtk_file_chooser_widget_get_selected_files (GtkFileChooserWidget *impl);
|
||||
|
||||
GtkSelectionModel *
|
||||
gtk_file_chooser_widget_get_selection_model (GtkFileChooserWidget *chooser);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__ */
|
||||
|
||||
+80
-1047
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gtk/deprecated/gtktreemodel.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -33,39 +32,13 @@ typedef struct _GtkFileSystemModel GtkFileSystemModel;
|
||||
|
||||
GType _gtk_file_system_model_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef gboolean (*GtkFileSystemModelGetValue) (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
GFileInfo *info,
|
||||
int column,
|
||||
GValue *value,
|
||||
gpointer user_data);
|
||||
|
||||
GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystemModelGetValue get_func,
|
||||
gpointer get_data,
|
||||
guint n_columns,
|
||||
...);
|
||||
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile * dir,
|
||||
const char * attributes,
|
||||
GtkFileSystemModelGetValue get_func,
|
||||
gpointer get_data,
|
||||
guint n_columns,
|
||||
...);
|
||||
GtkFileSystemModel *_gtk_file_system_model_new (void);
|
||||
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile *dir,
|
||||
const char *attributes);
|
||||
GFile * _gtk_file_system_model_get_directory (GtkFileSystemModel *model);
|
||||
GCancellable * _gtk_file_system_model_get_cancellable (GtkFileSystemModel *model);
|
||||
gboolean _gtk_file_system_model_iter_is_visible (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean _gtk_file_system_model_iter_is_filtered_out (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
GFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean _gtk_file_system_model_get_iter_for_file(GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter,
|
||||
GFileInfo * _gtk_file_system_model_get_info_for_file(GtkFileSystemModel *model,
|
||||
GFile *file);
|
||||
GFile * _gtk_file_system_model_get_file (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
const GValue * _gtk_file_system_model_get_value (GtkFileSystemModel *model,
|
||||
GtkTreeIter * iter,
|
||||
int column);
|
||||
|
||||
void _gtk_file_system_model_add_and_query_file (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
@@ -88,8 +61,6 @@ void _gtk_file_system_model_set_show_files (GtkFileSystemModel
|
||||
gboolean show_files);
|
||||
void _gtk_file_system_model_set_filter_folders (GtkFileSystemModel *model,
|
||||
gboolean show_folders);
|
||||
void _gtk_file_system_model_clear_cache (GtkFileSystemModel *model,
|
||||
int column);
|
||||
|
||||
void _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
|
||||
GtkFileFilter *filter);
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
/* gtkfilethumbnail.c
|
||||
*
|
||||
* Copyright 2022 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This file 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 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This file 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfilethumbnail.h"
|
||||
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidget.h"
|
||||
|
||||
#define ICON_SIZE 16
|
||||
|
||||
struct _GtkFileThumbnail
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkWidget *image;
|
||||
|
||||
GCancellable *cancellable;
|
||||
GFileInfo *info;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidgetClass parent;
|
||||
} GtkFileThumbnailClass;
|
||||
|
||||
G_DEFINE_FINAL_TYPE (GtkFileThumbnail, _gtk_file_thumbnail, GTK_TYPE_WIDGET)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_INFO,
|
||||
N_PROPS,
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
copy_attribute (GFileInfo *to,
|
||||
GFileInfo *from,
|
||||
const char *attribute)
|
||||
{
|
||||
GFileAttributeType type;
|
||||
gpointer value;
|
||||
|
||||
if (g_file_info_get_attribute_data (from, attribute, &type, &value, NULL))
|
||||
g_file_info_set_attribute (to, attribute, type, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_image (GtkFileThumbnail *self)
|
||||
{
|
||||
GtkIconTheme *icon_theme;
|
||||
GIcon *icon;
|
||||
int scale;
|
||||
|
||||
if (!g_file_info_has_attribute (self->info, G_FILE_ATTRIBUTE_STANDARD_ICON))
|
||||
return FALSE;
|
||||
|
||||
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
|
||||
|
||||
icon = _gtk_file_info_get_icon (self->info, ICON_SIZE, scale, icon_theme);
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (self->image), icon);
|
||||
|
||||
g_object_unref (icon);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
thumbnail_queried_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileThumbnail *self = user_data; /* might be unreffed if operation was cancelled */
|
||||
GFile *file = G_FILE (object);
|
||||
GFileInfo *queried;
|
||||
|
||||
queried = g_file_query_info_finish (file, result, NULL);
|
||||
if (queried == NULL)
|
||||
return;
|
||||
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_STANDARD_ICON);
|
||||
|
||||
update_image (self);
|
||||
|
||||
g_clear_object (&queried);
|
||||
|
||||
g_clear_object (&self->cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_thumbnail (GtkFileThumbnail *self)
|
||||
{
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_clear_object (&self->cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
get_thumbnail (GtkFileThumbnail *self)
|
||||
{
|
||||
if (!self->info)
|
||||
return;
|
||||
|
||||
if (!update_image (self))
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
if (g_file_info_has_attribute (self->info, "filechooser::queried"))
|
||||
return;
|
||||
|
||||
g_assert (self->cancellable == NULL);
|
||||
self->cancellable = g_cancellable_new ();
|
||||
|
||||
file = _gtk_file_info_get_file (self->info);
|
||||
g_file_info_set_attribute_boolean (self->info, "filechooser::queried", TRUE);
|
||||
g_file_query_info_async (file,
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_ICON,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
G_PRIORITY_DEFAULT,
|
||||
self->cancellable,
|
||||
thumbnail_queried_cb,
|
||||
self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_dispose (GObject *object)
|
||||
{
|
||||
GtkFileThumbnail *self = (GtkFileThumbnail *)object;
|
||||
|
||||
_gtk_file_thumbnail_set_info (self, NULL);
|
||||
|
||||
g_clear_pointer (&self->image, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_file_thumbnail_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileThumbnail *self = GTK_FILE_THUMBNAIL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_INFO:
|
||||
g_value_set_object (value, self->info);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileThumbnail *self = GTK_FILE_THUMBNAIL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_INFO:
|
||||
_gtk_file_thumbnail_set_info (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_class_init (GtkFileThumbnailClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = _gtk_file_thumbnail_dispose;
|
||||
object_class->get_property = _gtk_file_thumbnail_get_property;
|
||||
object_class->set_property = _gtk_file_thumbnail_set_property;
|
||||
|
||||
properties[PROP_INFO] =
|
||||
g_param_spec_object ("file-info", NULL, NULL,
|
||||
G_TYPE_FILE_INFO,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("filethumbnail"));
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_init (GtkFileThumbnail *self)
|
||||
{
|
||||
self->image = gtk_image_new ();
|
||||
gtk_widget_set_parent (self->image, GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GFileInfo *
|
||||
_gtk_file_thumbnail_get_info (GtkFileThumbnail *self)
|
||||
{
|
||||
g_assert (GTK_IS_FILE_THUMBNAIL (self));
|
||||
|
||||
return self->info;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_file_thumbnail_set_info (GtkFileThumbnail *self,
|
||||
GFileInfo *info)
|
||||
{
|
||||
g_assert (GTK_IS_FILE_THUMBNAIL (self));
|
||||
g_assert (info == NULL || G_IS_FILE_INFO (info));
|
||||
|
||||
if (g_set_object (&self->info, info))
|
||||
{
|
||||
cancel_thumbnail (self);
|
||||
get_thumbnail (self);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INFO]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/* gtkfilethumbnail.h
|
||||
*
|
||||
* Copyright 2022 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This file 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 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This file 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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GTK_FILE_THUMBNAIL_H__
|
||||
#define __GTK_FILE_THUMBNAIL_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "gtkfilesystemmodel.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FILE_THUMBNAIL (_gtk_file_thumbnail_get_type ())
|
||||
#define GTK_FILE_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_THUMBNAIL, GtkFileThumbnail))
|
||||
#define GTK_IS_FILE_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_THUMBNAIL))
|
||||
|
||||
typedef struct _GtkFileThumbnail GtkFileThumbnail;
|
||||
|
||||
GType _gtk_file_thumbnail_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GFileInfo *_gtk_file_thumbnail_get_info (GtkFileThumbnail *self);
|
||||
void _gtk_file_thumbnail_set_info (GtkFileThumbnail *self,
|
||||
GFileInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_THUMBNAIL_H__ */
|
||||
|
||||
@@ -1870,9 +1870,7 @@ find_affected_text (GtkFontChooserWidget *fontchooser,
|
||||
|
||||
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
|
||||
|
||||
if (hb_ot_layout_language_find_feature (hb_face,
|
||||
HB_OT_TAG_GSUB,
|
||||
@@ -2013,9 +2011,7 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
|
||||
|
||||
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
|
||||
|
||||
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
|
||||
{
|
||||
@@ -2565,9 +2561,7 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
|
||||
{
|
||||
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_find_language (hb_face, table[i], script_index, lang_tag, &lang_index);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_select_language (hb_face, table[i], script_index, 1, &lang_tag, &lang_index);
|
||||
|
||||
feat = features + n_features;
|
||||
count = G_N_ELEMENTS (features) - n_features;
|
||||
|
||||
@@ -520,8 +520,6 @@ on_remove_server_button_clicked (RemoveServerData *data)
|
||||
populate_servers (data->view);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
populate_servers (GtkPlacesView *view)
|
||||
{
|
||||
@@ -617,8 +615,6 @@ populate_servers (GtkPlacesView *view)
|
||||
g_bookmark_file_free (server_list);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
update_view_mode (GtkPlacesView *view)
|
||||
{
|
||||
|
||||
+20
-25
@@ -24,12 +24,11 @@
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include "gtksearchenginemodelprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
struct _GtkSearchEngineModel
|
||||
{
|
||||
GtkSearchEngine parent;
|
||||
@@ -81,37 +80,33 @@ static gboolean
|
||||
do_search (gpointer data)
|
||||
{
|
||||
GtkSearchEngineModel *model = data;
|
||||
GtkTreeIter iter;
|
||||
GList *hits = NULL;
|
||||
gboolean got_results = FALSE;
|
||||
|
||||
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model->model), &iter))
|
||||
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model->model)); i++)
|
||||
{
|
||||
do
|
||||
GFileInfo *info = g_list_model_get_item (G_LIST_MODEL (model->model), i);
|
||||
|
||||
if (info_matches_query (model->query, info))
|
||||
{
|
||||
GFileInfo *info;
|
||||
GFile *file;
|
||||
GtkSearchHit *hit;
|
||||
|
||||
info = _gtk_file_system_model_get_info (model->model, &iter);
|
||||
if (info_matches_query (model->query, info))
|
||||
{
|
||||
GFile *file;
|
||||
GtkSearchHit *hit;
|
||||
|
||||
file = _gtk_file_system_model_get_file (model->model, &iter);
|
||||
hit = g_new (GtkSearchHit, 1);
|
||||
hit->file = g_object_ref (file);
|
||||
hit->info = g_object_ref (info);
|
||||
hits = g_list_prepend (hits, hit);
|
||||
}
|
||||
file = _gtk_file_info_get_file (info);
|
||||
hit = g_new (GtkSearchHit, 1);
|
||||
hit->file = g_object_ref (file);
|
||||
hit->info = g_object_ref (info);
|
||||
hits = g_list_prepend (hits, hit);
|
||||
}
|
||||
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model->model), &iter));
|
||||
|
||||
if (hits)
|
||||
{
|
||||
_gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
|
||||
g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
|
||||
got_results = TRUE;
|
||||
}
|
||||
g_clear_object (&info);
|
||||
}
|
||||
|
||||
if (hits)
|
||||
{
|
||||
_gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
|
||||
g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
|
||||
got_results = TRUE;
|
||||
}
|
||||
|
||||
model->idle = 0;
|
||||
|
||||
@@ -114,7 +114,8 @@ free_hit (gpointer data)
|
||||
}
|
||||
|
||||
static GFileInfo *
|
||||
create_file_info (TrackerSparqlCursor *cursor)
|
||||
create_file_info (GFile *file,
|
||||
TrackerSparqlCursor *cursor)
|
||||
{
|
||||
GFileInfo *info;
|
||||
const char *str;
|
||||
@@ -140,6 +141,10 @@ create_file_info (TrackerSparqlCursor *cursor)
|
||||
g_date_time_unref (creation);
|
||||
}
|
||||
|
||||
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
|
||||
g_file_info_set_attribute_boolean (info, "filechooser::filtered-out", FALSE);
|
||||
g_file_info_set_attribute_boolean (info, "filechooser::visible", TRUE);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -175,7 +180,7 @@ query_callback (TrackerSparqlStatement *statement,
|
||||
url = tracker_sparql_cursor_get_string (cursor, 0, NULL);
|
||||
hit = g_slice_new0 (GtkSearchHit);
|
||||
hit->file = g_file_new_for_uri (url);
|
||||
hit->info = create_file_info (cursor);
|
||||
hit->info = create_file_info (hit->file, cursor);
|
||||
hits = g_list_prepend (hits, hit);
|
||||
}
|
||||
|
||||
|
||||
@@ -1259,13 +1259,13 @@ property_editor (GObject *object,
|
||||
g_strdup_printf ("%s: %s",
|
||||
self->name,
|
||||
gtk_label_get_text (GTK_LABEL (prop_edit))),
|
||||
NULL);
|
||||
-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (prop_edit),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, self->name,
|
||||
NULL);
|
||||
-1);
|
||||
}
|
||||
|
||||
return prop_edit;
|
||||
|
||||
@@ -72,7 +72,7 @@ add_string (GtkInspectorStrvEditor *editor,
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), str);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Value"),
|
||||
NULL);
|
||||
-1);
|
||||
gtk_widget_show (entry);
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
g_object_set_data (G_OBJECT (box), "entry", entry);
|
||||
@@ -83,7 +83,7 @@ add_string (GtkInspectorStrvEditor *editor,
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL,
|
||||
g_strdup_printf (_("Remove %s"), str),
|
||||
NULL);
|
||||
-1);
|
||||
gtk_widget_show (button);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (remove_string), editor);
|
||||
@@ -116,7 +116,7 @@ gtk_inspector_strv_editor_init (GtkInspectorStrvEditor *editor)
|
||||
gtk_widget_set_halign (editor->button, GTK_ALIGN_END);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (editor->button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Add"),
|
||||
NULL);
|
||||
-1);
|
||||
gtk_widget_show (editor->button);
|
||||
g_signal_connect (editor->button, "clicked", G_CALLBACK (add_cb), editor);
|
||||
|
||||
|
||||
@@ -108,7 +108,9 @@ gtk_private_sources = files([
|
||||
'gtkfilechoosererrorstack.c',
|
||||
'gtkfilechoosernativeportal.c',
|
||||
'gtkfilechooserutils.c',
|
||||
'gtkfilechoosercell.c',
|
||||
'gtkfilesystemmodel.c',
|
||||
'gtkfilethumbnail.c',
|
||||
'gtkgizmo.c',
|
||||
'gtkiconcache.c',
|
||||
'gtkiconcachevalidator.c',
|
||||
|
||||
@@ -3369,6 +3369,30 @@ columnview row:not(:selected) cell editablelabel.editing text selection {
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Complex Lists *
|
||||
* Put padding on the cell content so event controllers *
|
||||
* can cover the whole area. *
|
||||
********************************************************/
|
||||
|
||||
columnview.complex {
|
||||
> listview > row > cell {
|
||||
padding: 0;
|
||||
> * {
|
||||
padding: 8px 6px;
|
||||
}
|
||||
}
|
||||
|
||||
// shrink vertically for .data-table
|
||||
&.data-table > listview > row > cell {
|
||||
padding: 0;
|
||||
> * {
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************
|
||||
* App Notifications *
|
||||
*********************/
|
||||
|
||||
+242
-67
@@ -140,103 +140,278 @@
|
||||
<property name="hscrollbar-policy">2</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="browse_files_tree_view">
|
||||
<property name="has-tooltip">1</property>
|
||||
<property name="enable-search">0</property>
|
||||
<object class="GtkColumnView" id="browse_files_column_view">
|
||||
<style>
|
||||
<class name="complex"/>
|
||||
</style>
|
||||
<signal name="activate" handler="column_view_row_activated_cb" swapped="no"/>
|
||||
<signal name="keynav-failed" handler="browse_files_column_view_keynav_failed_cb"/>
|
||||
<child>
|
||||
<object class="GtkGestureLongPress">
|
||||
<property name="touch-only">1</property>
|
||||
<signal name="pressed" handler="long_press_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGestureClick">
|
||||
<property name="button">3</property>
|
||||
<signal name="pressed" handler="click_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<signal name="query-tooltip" handler="file_list_query_tooltip_cb" swapped="no"/>
|
||||
<signal name="row-activated" handler="list_row_activated" swapped="no"/>
|
||||
<signal name="keynav-failed" handler="browse_files_tree_view_keynav_failed_cb"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection2">
|
||||
<signal name="changed" handler="list_selection_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_name_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_name_column">
|
||||
<property name="title" translatable="yes">Name</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="expand">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="list_pixbuf_renderer">
|
||||
<property name="xpad">6</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkFileThumbnail">
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
<binding name="file-info">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="min-chars">10</property>
|
||||
<binding name="text">
|
||||
<closure type="gchararray" function="column_view_get_file_display_name">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_name_renderer">
|
||||
<property name="width-chars">10</property>
|
||||
<property name="ellipsize">3</property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_location_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_location_column">
|
||||
<property name="title" translatable="yes">Location</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="visible">0</property>
|
||||
<property name="expand">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_location_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="width-chars">10</property>
|
||||
<property name="ellipsize">1</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="min-chars">10</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
<binding name="text">
|
||||
<closure type="gchararray" function="column_view_get_location">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_size_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_size_column">
|
||||
<property name="title" translatable="yes">Size</property>
|
||||
<property name="sizing">2</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_size_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_size">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_type_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_type_column">
|
||||
<property name="title" translatable="yes">Type</property>
|
||||
<property name="resizable">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_type_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_file_type">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_time_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_time_column">
|
||||
<property name="title" translatable="yes">Modified</property>
|
||||
<property name="sizing">2</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_date_renderer">
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell" id="file_chooser_cell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_file_date">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible" bind-source="file_chooser_cell" bind-property="show-time" bind-flags="sync-create"/>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_file_time">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_time_renderer">
|
||||
<property name="xpad">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ project('gtk', 'c',
|
||||
meson_version : '>= 0.60.0',
|
||||
license: 'LGPL-2.1-or-later')
|
||||
|
||||
glib_req = '>= 2.66.0'
|
||||
glib_req = '>= 2.72.0'
|
||||
pango_req = '>= 1.50.0' # keep this in sync with .gitlab-ci/test-msys.sh
|
||||
harfbuzz_req = '>= 2.6.0'
|
||||
fribidi_req = '>= 0.19.7'
|
||||
|
||||
Reference in New Issue
Block a user