Compare commits

..

1 Commits

Author SHA1 Message Date
Matthias Clasen 276535b381 Revert "modules: Fix build on Visual Studio"
This reverts commit acd9c12667.

This commit breaks the build with GLib main,
we now get complaints about _GLIB_EXTERN being
redefined.

Maybe it is not needed anymore anyway, since
export macros have seen Window-related fixes.
2022-10-20 22:16:59 -04:00
43 changed files with 3287 additions and 2540 deletions
+28 -41
View File
@@ -11,6 +11,7 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
@@ -25,9 +26,6 @@ struct _CanvasItem {
double delta;
GtkWidget *editor;
GtkStyleProvider *provider;
char *css_class;
};
struct _CanvasItemClass {
@@ -38,41 +36,32 @@ 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 *name;
unstyle_item (item);
const char *old_class;
str = gdk_rgba_to_string (color);
name = gtk_widget_get_name (item->label);
css = g_strdup_printf ("#%s { background: %s; }", name, str);
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);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
item->provider = GTK_STYLE_PROVIDER (provider);
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);
g_free (str);
g_free (css);
@@ -82,10 +71,21 @@ static void
set_css (CanvasItem *item,
const char *class)
{
unstyle_item (item);
GtkStyleContext *context;
GtkCssProvider *provider;
const char *old_class;
context = gtk_widget_get_style_context (item->label);
provider = g_object_get_data (G_OBJECT (context), "style-provider");
if (provider)
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
if (old_class)
gtk_widget_remove_css_class (item->label, old_class);
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
gtk_widget_add_css_class (item->label, class);
item->css_class = g_strdup (class);
}
static gboolean
@@ -724,7 +724,6 @@ 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));
@@ -736,18 +735,6 @@ 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));
+15 -17
View File
@@ -10,6 +10,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
static GtkWidget *font_button = NULL;
static GtkWidget *entry = NULL;
@@ -43,6 +45,7 @@ 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;
@@ -57,23 +60,18 @@ update_image (void)
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting)))
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
if (hint)
{
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;
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;
}
cairo_font_options_set_hint_style (fopt, hintstyle);
@@ -422,7 +420,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::selected", G_CALLBACK (update_image), NULL);
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
+8 -11
View File
@@ -116,18 +116,15 @@
</object>
</child>
<child>
<object class="GtkDropDown" id="hinting">
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<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>
<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>
</object>
</child>
<layout>
+9 -18
View File
@@ -20,6 +20,8 @@
#include "gtkshadertoy.h"
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *demo_window = NULL;
static void
@@ -144,6 +146,7 @@ make_shader_stack (const char *name,
GtkTextBuffer *buffer;
GBytes *bytes;
GtkEventController *controller;
GtkCssProvider *provider;
GdkPaintable *paintable;
stack = gtk_shader_stack_new ();
@@ -234,6 +237,12 @@ 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");
@@ -267,21 +276,11 @@ 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));
@@ -336,14 +335,6 @@ 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;
}
+3 -12
View File
@@ -10,6 +10,8 @@
#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)
@@ -337,15 +339,6 @@ 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)
{
@@ -368,7 +361,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_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
gtk_widget_set_hexpand (label, TRUE);
gtk_box_append (GTK_BOX (box), label);
@@ -378,8 +371,6 @@ 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))
+5 -13
View File
@@ -8,6 +8,7 @@
#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.
*
@@ -360,15 +361,6 @@ 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)
{
@@ -385,9 +377,6 @@ 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);
@@ -406,6 +395,9 @@ 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)
@@ -449,7 +441,7 @@ create_board (GtkWidget *window)
}
}
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
g_object_unref (provider);
}
static void
+2
View File
@@ -16,6 +16,7 @@ enum {
NUM_PROPERTIES
};
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
static void
pixbuf_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
@@ -36,6 +37,7 @@ pixbuf_paintable_snapshot (GdkPaintable *paintable,
g_object_unref (texture);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
static int
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
+27 -7
View File
@@ -16,6 +16,26 @@
#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,
@@ -23,7 +43,7 @@ add_row (GtkGrid *table,
const char *label_text,
const char **options)
{
GtkWidget *dropdown;
GtkWidget *combo_box;
GtkWidget *label;
label = gtk_label_new_with_mnemonic (label_text);
@@ -32,12 +52,12 @@ add_row (GtkGrid *table,
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (table, label, 0, 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);
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);
}
static void
+5 -4
View File
@@ -11,6 +11,7 @@
#include <stdlib.h> /* for exit() */
#include "paintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void easter_egg_callback (GtkWidget *button, gpointer data);
@@ -430,11 +431,11 @@ attach_widgets (GtkTextView *text_view)
}
else if (i == 1)
{
const char *options[] = {
"Option 1", "Option 2", "Option 3", NULL
};
widget = gtk_combo_box_text_new ();
widget = gtk_drop_down_new_from_strings (options);
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");
}
else if (i == 2)
{
+10 -11
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct
{
GtkApplication parent_instance;
@@ -350,8 +352,7 @@ quit_activated (GSimpleAction *action,
}
static void
combo_changed (GtkDropDown *combo,
GParamSpec *pspec,
combo_changed (GtkComboBox *combo,
gpointer user_data)
{
GtkDialog *dialog = user_data;
@@ -360,7 +361,7 @@ combo_changed (GtkDropDown *combo,
char **accels;
char *str;
action = gtk_drop_down_get_selected_string (combo);
action = gtk_combo_box_get_active_id (combo);
if (!action)
return;
@@ -389,7 +390,7 @@ response (GtkDialog *dialog,
gpointer user_data)
{
GtkEntry *entry = g_object_get_data (user_data, "entry");
GtkDropDown *combo = g_object_get_data (user_data, "combo");
GtkComboBox *combo = g_object_get_data (user_data, "combo");
const char *action;
const char *str;
char **accels;
@@ -400,7 +401,7 @@ response (GtkDialog *dialog,
return;
}
action = gtk_drop_down_get_selected_string (combo);
action = gtk_combo_box_get_active_id (combo);
if (!action)
return;
@@ -425,7 +426,6 @@ edit_accels (GSimpleAction *action,
char **actions;
GtkWidget *dialog;
int i;
GtkStringList *strings;
dialog = gtk_dialog_new_with_buttons ("Accelerators",
NULL,
@@ -437,8 +437,7 @@ edit_accels (GSimpleAction *action,
gtk_window_set_application (GTK_WINDOW (dialog), app);
actions = gtk_application_list_action_descriptions (app);
strings = gtk_string_list_new (NULL);
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
combo = gtk_combo_box_text_new ();
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
"margin-top", 10,
"margin-bottom", 10,
@@ -449,8 +448,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_string_list_append (strings, actions[i]);
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), actions[i], actions[i]);
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed), dialog);
entry = gtk_entry_new ();
gtk_widget_set_hexpand (entry, TRUE);
@@ -461,7 +460,7 @@ edit_accels (GSimpleAction *action,
g_object_set_data (G_OBJECT (dialog), "combo", combo);
g_object_set_data (G_OBJECT (dialog), "entry", entry);
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
gtk_widget_show (dialog);
}
+21 -16
View File
@@ -436,7 +436,6 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
completion->inline_selection = FALSE;
completion->filter_model = NULL;
completion->insert_text_signal_group = NULL;
}
static gboolean
@@ -1385,12 +1384,13 @@ 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_signal_group != NULL)
g_signal_group_block (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_block (buffer, completion->insert_text_id);
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_signal_group != NULL)
g_signal_group_unblock (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_unblock (buffer, completion->insert_text_id);
}
static gboolean
@@ -1440,9 +1440,11 @@ 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_signal_group != NULL)
g_signal_group_block (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_block (buffer, completion->insert_text_id);
prefix = gtk_entry_completion_compute_prefix (completion,
gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
@@ -1454,8 +1456,8 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
g_free (prefix);
}
if (completion->insert_text_signal_group != NULL)
g_signal_group_unblock (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_unblock (buffer, completion->insert_text_id);
}
/**
@@ -2096,6 +2098,7 @@ 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");
@@ -2110,10 +2113,8 @@ connect_completion_signals (GtkEntryCompletion *completion)
completion->changed_id =
g_signal_connect (text, "changed", G_CALLBACK (gtk_entry_completion_changed), 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);
completion->insert_text_id =
g_signal_connect (buffer, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
}
@@ -2122,6 +2123,7 @@ 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);
@@ -2132,9 +2134,12 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
g_signal_handler_disconnect (text, completion->changed_id);
completion->changed_id = 0;
}
g_clear_object (&completion->insert_text_signal_group);
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_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);
}
+2 -10
View File
@@ -27,8 +27,6 @@
#include "gtkmarshalers.h"
#include "gtkwidgetprivate.h"
#include "gsettings-mapping.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include <string.h>
@@ -848,15 +846,9 @@ gtk_action_muxer_activate_action (GtkActionMuxer *muxer,
if (!_gtk_bitmask_get (muxer->widget_actions_disabled, position))
{
if (action->activate)
{
GTK_DEBUG (ACTIONS, "%s: activate action", action->name);
action->activate (muxer->widget, action->name, parameter);
}
action->activate (muxer->widget, action->name, parameter);
else if (action->pspec)
{
GTK_DEBUG (ACTIONS, "%s: activate prop action", action->pspec->name);
prop_action_activate (muxer->widget, action, parameter);
}
prop_action_activate (muxer->widget, action, parameter);
}
return;
-1
View File
@@ -25,7 +25,6 @@
#include "gtkcomposetable.h"
#include "gtkimcontextsimple.h"
#include "gtkprivate.h"
#define GTK_COMPOSE_TABLE_MAGIC "GtkComposeTable"
+2 -102
View File
@@ -133,7 +133,6 @@ enum
PROP_MODEL,
PROP_SELECTED,
PROP_SELECTED_ITEM,
PROP_SELECTED_STRING,
PROP_ENABLE_SEARCH,
PROP_EXPRESSION,
PROP_SHOW_ARROW,
@@ -248,7 +247,6 @@ 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
@@ -360,10 +358,6 @@ 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;
@@ -408,10 +402,6 @@ 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;
@@ -555,22 +545,6 @@ 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)
*
@@ -810,7 +784,8 @@ 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`
*/
@@ -1041,81 +1016,6 @@ 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`
-7
View File
@@ -52,13 +52,6 @@ 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);
+1 -2
View File
@@ -61,8 +61,7 @@ struct _GtkEntryCompletion
gulong completion_timeout;
gulong changed_id;
GSignalGroup *insert_text_signal_group;
gulong insert_text_id;
int current_selected;
-304
View File
@@ -1,304 +0,0 @@
/*
* 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);
}
-37
View File
@@ -1,37 +0,0 @@
/*
* 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__ */
+72 -83
View File
@@ -60,8 +60,7 @@ struct _GtkFileChooserEntry
char *dir_part;
char *file_part;
GtkTreeStore *completion_store;
GtkFileSystemModel *model;
GtkTreeModel *completion_store;
GtkFileFilter *current_filter;
guint current_folder_loaded : 1;
@@ -72,7 +71,6 @@ struct _GtkFileChooserEntry
enum
{
FILE_INFO_COLUMN,
DISPLAY_NAME_COLUMN,
FULL_PATH_COLUMN,
N_COLUMNS
@@ -199,21 +197,20 @@ match_func (GtkEntryCompletion *compl,
* current file filter (e.g. just jpg files) here. */
if (chooser_entry->current_filter != NULL)
{
GFile *file;
GFileInfo *info;
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);
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);
/* 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;
g_assert (g_file_info_has_attribute (info, "standard::file"));
if (!g_file_info_has_attribute (info, "standard::file"))
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
}
@@ -431,7 +428,7 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
{
chooser_entry->complete_on_load = FALSE;
if (chooser_entry->model)
if (chooser_entry->completion_store)
{
char *completion, *text;
gsize completion_len, text_len;
@@ -542,93 +539,77 @@ update_inline_completion (GtkFileChooserEntry *chooser_entry)
static void
discard_completion_store (GtkFileChooserEntry *chooser_entry)
{
if (!chooser_entry->model)
if (!chooser_entry->completion_store)
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_clear_object (&chooser_entry->completion_store);
g_clear_object (&chooser_entry->model);
g_object_unref (chooser_entry->completion_store);
chooser_entry->completion_store = NULL;
}
static void
model_items_changed_cb (GListModel *model,
guint position,
guint removed,
guint added,
GtkFileChooserEntry *self)
static gboolean
completion_store_set (GtkFileSystemModel *model,
GFile *file,
GFileInfo *info,
int column,
GValue *value,
gpointer data)
{
if (removed > 0)
GtkFileChooserEntry *chooser_entry = data;
const char *prefix = "";
const char *suffix = "";
switch (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);
case FULL_PATH_COLUMN:
prefix = chooser_entry->dir_part;
G_GNUC_FALLTHROUGH;
case DISPLAY_NAME_COLUMN:
if (_gtk_file_info_consider_as_directory (info))
suffix = G_DIR_SEPARATOR_S;
display_name = g_strconcat (g_file_info_get_display_name (info), suffix, NULL);
full_path = g_strconcat (self->dir_part, display_name, NULL);
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++;
g_value_take_string (value,
g_strconcat (prefix,
g_file_info_get_display_name (info),
suffix,
NULL));
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
/* 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_store_new (N_COLUMNS,
G_TYPE_FILE_INFO,
G_TYPE_STRING,
G_TYPE_STRING);
chooser_entry->model =
chooser_entry->completion_store = GTK_TREE_MODEL (
_gtk_file_system_model_new_for_directory (chooser_entry->current_folder_file,
"standard::name,standard::display-name,standard::type,"
"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",
"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",
G_CALLBACK (finished_loading_cb), chooser_entry);
_gtk_file_system_model_set_filter_folders (chooser_entry->model, TRUE);
_gtk_file_system_model_set_show_files (chooser_entry->model,
_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),
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)),
GTK_TREE_MODEL (chooser_entry->completion_store));
chooser_entry->completion_store);
}
/* Callback when the current folder finishes loading */
@@ -656,7 +637,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 (gtk_entry_get_text_widget (GTK_ENTRY (chooser_entry)))))
if (gtk_widget_has_focus (GTK_WIDGET (chooser_entry)))
{
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
@@ -677,7 +658,11 @@ set_completion_folder (GtkFileChooserEntry *chooser_entry,
return;
}
g_clear_object (&chooser_entry->current_folder_file);
if (chooser_entry->current_folder_file)
{
g_object_unref (chooser_entry->current_folder_file);
chooser_entry->current_folder_file = NULL;
}
g_free (chooser_entry->dir_part);
chooser_entry->dir_part = g_strdup (dir_part);
@@ -725,7 +710,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
g_free (dir_part);
if (chooser_entry->model &&
if (chooser_entry->completion_store &&
(g_strcmp0 (old_file_part, chooser_entry->file_part) != 0))
{
GtkFileFilter *filter;
@@ -735,7 +720,8 @@ 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 (chooser_entry->model, filter);
_gtk_file_system_model_set_filter (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
filter);
g_free (pattern);
g_object_unref (filter);
@@ -954,8 +940,8 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
break;
}
if (chooser_entry->model)
_gtk_file_system_model_set_show_files (chooser_entry->model,
if (chooser_entry->completion_store)
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
action == GTK_FILE_CHOOSER_ACTION_OPEN ||
action == GTK_FILE_CHOOSER_ACTION_SAVE);
@@ -985,14 +971,17 @@ gboolean
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
GFile *file)
{
GtkTreeIter iter;
GFileInfo *info;
if (chooser_entry->model == NULL)
if (chooser_entry->completion_store == NULL ||
!_gtk_file_system_model_get_iter_for_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
&iter,
file))
return FALSE;
info = _gtk_file_system_model_get_info_for_file (chooser_entry->model, file);
if (!info)
return FALSE;
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
&iter);
return _gtk_file_info_consider_as_directory (info);
}
-9
View File
@@ -479,12 +479,3 @@ _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"));
}
-2
View File
@@ -58,8 +58,6 @@ 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__ */
+1860 -1116
View File
File diff suppressed because it is too large Load Diff
-7
View File
@@ -23,7 +23,6 @@
#include <glib.h>
#include "gtkfilechooserwidget.h"
#include "gtkselectionmodel.h"
G_BEGIN_DECLS
@@ -37,12 +36,6 @@ 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__ */
+1049 -82
View File
File diff suppressed because it is too large Load Diff
+33 -4
View File
@@ -21,6 +21,7 @@
#include <gio/gio.h>
#include <gtk/gtkfilefilter.h>
#include <gtk/deprecated/gtktreemodel.h>
G_BEGIN_DECLS
@@ -32,13 +33,39 @@ typedef struct _GtkFileSystemModel GtkFileSystemModel;
GType _gtk_file_system_model_get_type (void) G_GNUC_CONST;
GtkFileSystemModel *_gtk_file_system_model_new (void);
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile *dir,
const char *attributes);
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,
...);
GFile * _gtk_file_system_model_get_directory (GtkFileSystemModel *model);
GCancellable * _gtk_file_system_model_get_cancellable (GtkFileSystemModel *model);
GFileInfo * _gtk_file_system_model_get_info_for_file(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,
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,
@@ -61,6 +88,8 @@ 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);
-255
View File
@@ -1,255 +0,0 @@
/* 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]);
}
}
-46
View File
@@ -1,46 +0,0 @@
/* 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__ */
+9 -3
View File
@@ -1870,7 +1870,9 @@ find_affected_text (GtkFontChooserWidget *fontchooser,
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_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
if (hb_ot_layout_language_find_feature (hb_face,
HB_OT_TAG_GSUB,
@@ -2011,7 +2013,9 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_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
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
{
@@ -2561,7 +2565,9 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
{
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
hb_ot_layout_script_select_language (hb_face, table[i], script_index, 1, &lang_tag, &lang_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
feat = features + n_features;
count = G_N_ELEMENTS (features) - n_features;
+4
View File
@@ -520,6 +520,8 @@ on_remove_server_button_clicked (RemoveServerData *data)
populate_servers (data->view);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void
populate_servers (GtkPlacesView *view)
{
@@ -615,6 +617,8 @@ populate_servers (GtkPlacesView *view)
g_bookmark_file_free (server_list);
}
G_GNUC_END_IGNORE_DEPRECATIONS
static void
update_view_mode (GtkPlacesView *view)
{
+25 -20
View File
@@ -24,11 +24,12 @@
#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;
@@ -80,33 +81,37 @@ static gboolean
do_search (gpointer data)
{
GtkSearchEngineModel *model = data;
GtkTreeIter iter;
GList *hits = NULL;
gboolean got_results = FALSE;
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model->model)); i++)
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model->model), &iter))
{
GFileInfo *info = g_list_model_get_item (G_LIST_MODEL (model->model), i);
if (info_matches_query (model->query, info))
do
{
GFile *file;
GtkSearchHit *hit;
GFileInfo *info;
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);
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);
}
}
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model->model), &iter));
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;
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;
+2 -7
View File
@@ -114,8 +114,7 @@ free_hit (gpointer data)
}
static GFileInfo *
create_file_info (GFile *file,
TrackerSparqlCursor *cursor)
create_file_info (TrackerSparqlCursor *cursor)
{
GFileInfo *info;
const char *str;
@@ -141,10 +140,6 @@ create_file_info (GFile *file,
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;
}
@@ -180,7 +175,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 (hit->file, cursor);
hit->info = create_file_info (cursor);
hits = g_list_prepend (hits, hit);
}
+2 -2
View File
@@ -1259,13 +1259,13 @@ property_editor (GObject *object,
g_strdup_printf ("%s: %s",
self->name,
gtk_label_get_text (GTK_LABEL (prop_edit))),
-1);
NULL);
}
else
{
gtk_accessible_update_property (GTK_ACCESSIBLE (prop_edit),
GTK_ACCESSIBLE_PROPERTY_LABEL, self->name,
-1);
NULL);
}
return prop_edit;
+3 -3
View File
@@ -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"),
-1);
NULL);
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),
-1);
NULL);
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"),
-1);
NULL);
gtk_widget_show (editor->button);
g_signal_connect (editor->button, "clicked", G_CALLBACK (add_cb), editor);
-2
View File
@@ -108,9 +108,7 @@ gtk_private_sources = files([
'gtkfilechoosererrorstack.c',
'gtkfilechoosernativeportal.c',
'gtkfilechooserutils.c',
'gtkfilechoosercell.c',
'gtkfilesystemmodel.c',
'gtkfilethumbnail.c',
'gtkgizmo.c',
'gtkiconcache.c',
'gtkiconcachevalidator.c',
-24
View File
@@ -3369,30 +3369,6 @@ 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 *
*********************/
+70 -245
View File
@@ -140,278 +140,103 @@
<property name="hscrollbar-policy">2</property>
<property name="vexpand">1</property>
<child>
<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"/>
<object class="GtkTreeView" id="browse_files_tree_view">
<property name="has-tooltip">1</property>
<property name="enable-search">0</property>
<child>
<object class="GtkColumnViewColumn" id="column_view_name_column">
<property name="title" translatable="yes">Name</property>
<property name="expand">1</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>
</property>
<object class="GtkGestureLongPress">
<property name="touch-only">1</property>
<signal name="pressed" handler="long_press_cb" swapped="no"/>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="column_view_location_column">
<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">
<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>
</object>
</child>
<child>
<object class="GtkCellRendererText" id="list_name_renderer">
<property name="width-chars">10</property>
<property name="ellipsize">3</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="list_location_column">
<property name="title" translatable="yes">Location</property>
<property name="resizable">1</property>
<property name="visible">0</property>
<property name="expand">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="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>
<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>
</object>
</property>
</child>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="column_view_size_column">
<object class="GtkTreeViewColumn" id="list_size_column">
<property name="title" translatable="yes">Size</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>
<property name="sizing">2</property>
<child>
<object class="GtkCellRendererText" id="list_size_renderer">
<property name="xalign">0</property>
<property name="xpad">6</property>
</object>
</property>
</child>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="column_view_type_column">
<object class="GtkTreeViewColumn" id="list_type_column">
<property name="title" translatable="yes">Type</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="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>
<child>
<object class="GtkCellRendererText" id="list_type_renderer">
<property name="xalign">0</property>
<property name="xpad">6</property>
</object>
</property>
</child>
</object>
</child>
<child>
<object class="GtkColumnViewColumn" id="column_view_time_column">
<object class="GtkTreeViewColumn" id="list_time_column">
<property name="title" translatable="yes">Modified</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>
<property name="sizing">2</property>
<child>
<object class="GtkCellRendererText" id="list_date_renderer">
<property name="xpad">6</property>
</object>
</property>
</child>
<child>
<object class="GtkCellRendererText" id="list_time_renderer">
<property name="xpad">6</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
+7 -11
View File
@@ -10,7 +10,7 @@ project('gtk', 'c',
meson_version : '>= 0.60.0',
license: 'LGPL-2.1-or-later')
glib_req = '>= 2.72.0'
glib_req = '>= 2.66.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'
@@ -342,19 +342,15 @@ endif
common_cflags = cc.get_supported_arguments(test_cflags)
# Symbol visibility
if os_win32
visibility_define = '__declspec(dllexport) extern'
else
visibility_define = '__attribute__((visibility("default"))) extern'
endif
if get_option('default_library') != 'static'
cdata.set('_GDK_EXTERN', visibility_define)
if os_win32
cdata.set('DLL_EXPORT', true)
endif
if cc.get_id() != 'msvc'
cdata.set('_GDK_EXTERN', '__declspec(dllexport) extern')
if cc.get_id() != 'msvc'
common_cflags += ['-fvisibility=hidden']
endif
else
cdata.set('_GDK_EXTERN', '__attribute__((visibility("default"))) extern')
common_cflags += ['-fvisibility=hidden']
endif
endif
+3
View File
@@ -97,6 +97,7 @@ G_DEFINE_TYPE_EXTENDED (GtkGstMediaFile, gtk_gst_media_file, GTK_TYPE_MEDIA_FILE
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_gst_media_file_paintable_init))
G_MODULE_EXPORT
void
g_io_module_load (GIOModule *module)
{
@@ -108,6 +109,7 @@ g_io_module_load (GIOModule *module)
10);
}
G_MODULE_EXPORT
G_GNUC_NORETURN
void
g_io_module_unload (GIOModule *module)
@@ -115,6 +117,7 @@ g_io_module_unload (GIOModule *module)
g_assert_not_reached ();
}
G_MODULE_EXPORT
char **
g_io_module_query (void)
{
+1 -5
View File
@@ -2,11 +2,7 @@ media_subdir = 'gtk-4.0/@0@/media'.format(gtk_binary_version)
media_install_dir = join_paths(get_option('libdir'), media_subdir)
media_backends = []
extra_c_args = [
'-DGTK_COMPILATION',
'-D_GLIB_EXTERN=@0@'.format(visibility_define),
]
extra_c_args = ['-DGTK_COMPILATION']
extra_c_args += common_cflags
ffmpeg_opt = get_option('media-ffmpeg')
@@ -246,6 +246,7 @@ static void secrets_service_vanished_cb (GDBusConnec
G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendCups, gtk_print_backend_cups, GTK_TYPE_PRINT_BACKEND)
G_MODULE_EXPORT
void
g_io_module_load (GIOModule *module)
{
@@ -260,11 +261,13 @@ g_io_module_load (GIOModule *module)
10);
}
G_MODULE_EXPORT
void
g_io_module_unload (GIOModule *module)
{
}
G_MODULE_EXPORT
char **
g_io_module_query (void)
{
@@ -103,6 +103,7 @@ static GtkPageSetup * file_printer_get_default_page_size (GtkPrinter
G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendFile, gtk_print_backend_file, GTK_TYPE_PRINT_BACKEND)
G_MODULE_EXPORT
void
g_io_module_load (GIOModule *module)
{
@@ -116,11 +117,13 @@ g_io_module_load (GIOModule *module)
10);
}
G_MODULE_EXPORT
void
g_io_module_unload (GIOModule *module)
{
}
G_MODULE_EXPORT
char **
g_io_module_query (void)
{
@@ -82,6 +82,7 @@ static void gtk_print_backend_lpr_print_stream (GtkPrintBacke
G_DEFINE_DYNAMIC_TYPE (GtkPrintBackendLpr, gtk_print_backend_lpr, GTK_TYPE_PRINT_BACKEND)
G_MODULE_EXPORT
void
g_io_module_load (GIOModule *module)
{
@@ -95,11 +96,13 @@ g_io_module_load (GIOModule *module)
10);
}
G_MODULE_EXPORT
void
g_io_module_unload (GIOModule *module)
{
}
G_MODULE_EXPORT
char **
g_io_module_query (void)
{
-1
View File
@@ -8,7 +8,6 @@ printbackends_args = [
'-DGTK_COMPILATION',
'-DGTK_DISABLE_DEPRECATION_WARNINGS',
'-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
'-D_GLIB_EXTERN=@0@'.format(visibility_define),
] + common_cflags
cups_dep = dependency('cups', version : '>=2.0', required: get_option('print-cups'))