Compare commits
1 Commits
async-dial
...
fix-build-
Author | SHA1 | Date | |
---|---|---|---|
|
276535b381 |
@@ -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));
|
||||
|
@@ -21,75 +21,7 @@
|
||||
#include "script-names.h"
|
||||
#include "language-names.h"
|
||||
|
||||
/* {{{ ScriptLang object */
|
||||
|
||||
G_DECLARE_FINAL_TYPE (ScriptLang, script_lang, SCRIPT, LANG, GObject)
|
||||
|
||||
struct _ScriptLang
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
char *langname;
|
||||
unsigned int script_index;
|
||||
unsigned int lang_index;
|
||||
hb_tag_t lang_tag;
|
||||
};
|
||||
|
||||
struct _ScriptLangClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (ScriptLang, script_lang, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
script_lang_init (ScriptLang *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
script_lang_finalize (GObject *object)
|
||||
{
|
||||
ScriptLang *self = SCRIPT_LANG (object);
|
||||
|
||||
g_free (self->langname);
|
||||
|
||||
G_OBJECT_CLASS (script_lang_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
script_lang_class_init (ScriptLangClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
|
||||
object_class->finalize = script_lang_finalize;
|
||||
}
|
||||
|
||||
static ScriptLang *
|
||||
script_lang_new (const char *langname,
|
||||
unsigned int script_index,
|
||||
unsigned int lang_index,
|
||||
hb_tag_t lang_tag)
|
||||
{
|
||||
ScriptLang *self;
|
||||
|
||||
self = g_object_new (script_lang_get_type (), NULL);
|
||||
|
||||
self->langname = g_strdup (langname);
|
||||
self->script_index = script_index;
|
||||
self->lang_index = lang_index;
|
||||
self->lang_tag = lang_tag;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static char *
|
||||
script_lang_get_langname (ScriptLang *self)
|
||||
{
|
||||
return g_strdup (self->langname);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
||||
|
||||
@@ -163,10 +95,6 @@ demo_free (gpointer data)
|
||||
g_clear_pointer (&demo->axes, g_hash_table_unref);
|
||||
g_clear_pointer (&demo->text, g_free);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (demo->provider));
|
||||
g_object_unref (demo->provider);
|
||||
|
||||
g_free (demo);
|
||||
}
|
||||
|
||||
@@ -544,6 +472,8 @@ update_display (void)
|
||||
GString *s;
|
||||
char *text;
|
||||
gboolean has_feature;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
PangoFontDescription *desc;
|
||||
GList *l;
|
||||
PangoAttrList *attrs;
|
||||
@@ -646,13 +576,14 @@ update_display (void)
|
||||
|
||||
features = g_string_free (s, FALSE);
|
||||
|
||||
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) != 0)
|
||||
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
|
||||
{
|
||||
ScriptLang *selected;
|
||||
hb_tag_t lang_tag;
|
||||
|
||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
|
||||
gtk_tree_model_get (model, &iter, 3, &lang_tag, -1);
|
||||
|
||||
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (selected->lang_tag)));
|
||||
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (lang_tag)));
|
||||
}
|
||||
else
|
||||
lang = NULL;
|
||||
@@ -809,30 +740,40 @@ tag_pair_equal (gconstpointer a, gconstpointer b)
|
||||
return pair_a->script_tag == pair_b->script_tag && pair_a->lang_tag == pair_b->lang_tag;
|
||||
}
|
||||
|
||||
|
||||
static GtkOrdering
|
||||
script_sort (const void *item1,
|
||||
const void *item2,
|
||||
void *data)
|
||||
static int
|
||||
script_sort_func (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
ScriptLang *a = (ScriptLang *)item1;
|
||||
ScriptLang *b = (ScriptLang *)item2;
|
||||
char *sa, *sb;
|
||||
int ret;
|
||||
|
||||
return strcmp (a->langname, b->langname);
|
||||
gtk_tree_model_get (model, a, 0, &sa, -1);
|
||||
gtk_tree_model_get (model, b, 0, &sb, -1);
|
||||
|
||||
ret = strcmp (sa, sb);
|
||||
|
||||
g_free (sa);
|
||||
g_free (sb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
update_script_combo (void)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkSortListModel *sortmodel;
|
||||
GtkListStore *store;
|
||||
hb_font_t *hb_font;
|
||||
int i, j, k;
|
||||
PangoFont *pango_font;
|
||||
GHashTable *tags;
|
||||
GHashTableIter iter;
|
||||
TagPair *pair;
|
||||
char *lang;
|
||||
hb_tag_t active;
|
||||
GtkTreeIter active_iter;
|
||||
gboolean have_active = FALSE;
|
||||
|
||||
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
|
||||
|
||||
@@ -842,7 +783,7 @@ update_script_combo (void)
|
||||
|
||||
g_free (lang);
|
||||
|
||||
store = g_list_store_new (script_lang_get_type ());
|
||||
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
||||
|
||||
pango_font = get_pango_font ();
|
||||
hb_font = pango_font_get_hb_font (pango_font);
|
||||
@@ -866,19 +807,19 @@ update_script_combo (void)
|
||||
|
||||
hb_face = hb_font_get_face (hb_font);
|
||||
|
||||
for (guint i = 0; i < 2; i++)
|
||||
for (i= 0; i < 2; i++)
|
||||
{
|
||||
hb_tag_t scripts[80];
|
||||
unsigned int script_count = G_N_ELEMENTS (scripts);
|
||||
|
||||
hb_ot_layout_table_get_script_tags (hb_face, tables[i], 0, &script_count, scripts);
|
||||
for (guint j = 0; j < script_count; j++)
|
||||
for (j = 0; j < script_count; j++)
|
||||
{
|
||||
hb_tag_t languages[80];
|
||||
unsigned int language_count = G_N_ELEMENTS (languages);
|
||||
|
||||
hb_ot_layout_script_get_language_tags (hb_face, tables[i], j, 0, &language_count, languages);
|
||||
for (guint k = 0; k < language_count; k++)
|
||||
for (k = 0; k < language_count; k++)
|
||||
{
|
||||
pair = g_new (TagPair, 1);
|
||||
pair->script_tag = scripts[j];
|
||||
@@ -898,6 +839,7 @@ update_script_combo (void)
|
||||
{
|
||||
const char *langname;
|
||||
char langbuf[5];
|
||||
GtkTreeIter tree_iter;
|
||||
|
||||
if (pair->lang_tag == 0 && pair->script_tag == 0)
|
||||
langname = NC_("Language", "None");
|
||||
@@ -914,31 +856,31 @@ update_script_combo (void)
|
||||
}
|
||||
}
|
||||
|
||||
g_list_store_append (store, script_lang_new (langname,
|
||||
pair->script_index,
|
||||
pair->lang_index,
|
||||
pair->lang_tag));
|
||||
gtk_list_store_insert_with_values (store, &tree_iter, -1,
|
||||
0, langname,
|
||||
1, pair->script_index,
|
||||
2, pair->lang_index,
|
||||
3, pair->lang_tag,
|
||||
-1);
|
||||
if (pair->lang_tag == active)
|
||||
{
|
||||
have_active = TRUE;
|
||||
active_iter = tree_iter;
|
||||
}
|
||||
}
|
||||
|
||||
g_hash_table_destroy (tags);
|
||||
|
||||
sortmodel = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
GTK_SORTER (gtk_custom_sorter_new (script_sort, NULL, NULL)));
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (demo->script_lang), G_LIST_MODEL (sortmodel));
|
||||
|
||||
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (sortmodel)); i++)
|
||||
{
|
||||
ScriptLang *item = g_list_model_get_item (G_LIST_MODEL (sortmodel), i);
|
||||
g_object_unref (item);
|
||||
|
||||
if (item->lang_tag == active)
|
||||
{
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->script_lang), i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (sortmodel);
|
||||
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
|
||||
script_sort_func, NULL, NULL);
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
|
||||
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
|
||||
GTK_SORT_ASCENDING);
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (demo->script_lang), GTK_TREE_MODEL (store));
|
||||
if (have_active)
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (demo->script_lang), &active_iter);
|
||||
else
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (demo->script_lang), 0);
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -963,19 +905,27 @@ static void
|
||||
update_features (void)
|
||||
{
|
||||
int i, j;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
guint script_index, lang_index;
|
||||
hb_tag_t lang_tag;
|
||||
PangoFont *pango_font;
|
||||
hb_font_t *hb_font;
|
||||
GList *l;
|
||||
ScriptLang *selected;
|
||||
|
||||
/* set feature presence checks from the font features */
|
||||
|
||||
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) == 0)
|
||||
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
|
||||
return;
|
||||
|
||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
|
||||
gtk_tree_model_get (model, &iter,
|
||||
1, &script_index,
|
||||
2, &lang_index,
|
||||
3, &lang_tag,
|
||||
-1);
|
||||
|
||||
if (selected->lang_tag == 0) /* None is selected */
|
||||
if (lang_tag == 0) /* None is selected */
|
||||
{
|
||||
for (l = demo->feature_items; l; l = l->next)
|
||||
{
|
||||
@@ -1016,8 +966,8 @@ update_features (void)
|
||||
|
||||
hb_ot_layout_language_get_feature_tags (hb_face,
|
||||
tables[i],
|
||||
selected->script_index,
|
||||
selected->lang_index,
|
||||
script_index,
|
||||
lang_index,
|
||||
0,
|
||||
&count,
|
||||
features);
|
||||
@@ -1039,8 +989,8 @@ update_features (void)
|
||||
|
||||
hb_ot_layout_language_find_feature (hb_face,
|
||||
tables[i],
|
||||
selected->script_index,
|
||||
selected->lang_index,
|
||||
script_index,
|
||||
lang_index,
|
||||
features[j],
|
||||
&feature_index);
|
||||
|
||||
@@ -1372,9 +1322,10 @@ free_instance (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
add_instance (hb_face_t *face,
|
||||
unsigned int index,
|
||||
GtkStringList *strings)
|
||||
add_instance (hb_face_t *face,
|
||||
unsigned int index,
|
||||
GtkWidget *combo,
|
||||
int pos)
|
||||
{
|
||||
Instance *instance;
|
||||
hb_ot_name_id_t name_id;
|
||||
@@ -1390,20 +1341,20 @@ add_instance (hb_face_t *face,
|
||||
instance->index = index;
|
||||
|
||||
g_hash_table_add (demo->instances, instance);
|
||||
gtk_string_list_append (GTK_STRING_LIST (strings), instance->name);
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), instance->name);
|
||||
}
|
||||
|
||||
static void
|
||||
unset_instance (GtkAdjustment *adjustment)
|
||||
{
|
||||
if (demo->instance_combo)
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->instance_combo), 0);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (demo->instance_combo), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
instance_changed (GtkDropDown *combo)
|
||||
instance_changed (GtkComboBox *combo)
|
||||
{
|
||||
const char *text;
|
||||
char *text;
|
||||
Instance *instance;
|
||||
Instance ikey;
|
||||
int i;
|
||||
@@ -1415,12 +1366,11 @@ instance_changed (GtkDropDown *combo)
|
||||
hb_font_t *hb_font;
|
||||
hb_face_t *hb_face;
|
||||
|
||||
text = gtk_string_list_get_string (GTK_STRING_LIST (gtk_drop_down_get_model (combo)),
|
||||
gtk_drop_down_get_selected (combo));
|
||||
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
|
||||
if (text[0] == '\0')
|
||||
goto out;
|
||||
|
||||
ikey.name = (char *) text;
|
||||
ikey.name = text;
|
||||
instance = g_hash_table_lookup (demo->instances, &ikey);
|
||||
if (!instance)
|
||||
{
|
||||
@@ -1461,6 +1411,7 @@ instance_changed (GtkDropDown *combo)
|
||||
}
|
||||
|
||||
out:
|
||||
g_free (text);
|
||||
g_clear_object (&pango_font);
|
||||
g_free (ai);
|
||||
g_free (coords);
|
||||
@@ -1570,7 +1521,6 @@ update_font_variations (void)
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *combo;
|
||||
GtkStringList *strings;
|
||||
|
||||
label = gtk_label_new ("Instance");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
@@ -1578,28 +1528,26 @@ update_font_variations (void)
|
||||
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), label, 0, -1, 1, 1);
|
||||
|
||||
strings = gtk_string_list_new (NULL);
|
||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
|
||||
combo = gtk_combo_box_text_new ();
|
||||
gtk_widget_set_halign (combo, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE);
|
||||
|
||||
gtk_string_list_append (strings, "");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "");
|
||||
|
||||
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
||||
add_instance (hb_face, i, strings);
|
||||
add_instance (hb_face, i, combo, i);
|
||||
|
||||
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
||||
{
|
||||
if (matches_instance (hb_face, i, n_axes, design_coords))
|
||||
{
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i + 1);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), combo, 1, -1, 3, 1);
|
||||
g_signal_connect (combo, "notify::selecte", G_CALLBACK (instance_changed), NULL);
|
||||
g_signal_connect (combo, "changed", G_CALLBACK (instance_changed), NULL);
|
||||
demo->instance_combo = combo;
|
||||
}
|
||||
|
||||
@@ -1746,7 +1694,6 @@ do_font_features (GtkWidget *do_widget)
|
||||
GtkBuilder *builder;
|
||||
GtkBuilderScope *scope;
|
||||
GtkEventController *controller;
|
||||
GtkExpression *expression;
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
|
||||
@@ -1780,9 +1727,6 @@ do_font_features (GtkWidget *do_widget)
|
||||
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
|
||||
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
|
||||
demo->script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
|
||||
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, G_CALLBACK (script_lang_get_langname), NULL, NULL);
|
||||
gtk_drop_down_set_expression (GTK_DROP_DOWN (demo->script_lang), expression);
|
||||
gtk_expression_unref (expression);
|
||||
demo->feature_list = GTK_WIDGET (gtk_builder_get_object (builder, "feature_list"));
|
||||
demo->stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
|
||||
demo->entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
|
||||
@@ -1801,8 +1745,8 @@ do_font_features (GtkWidget *do_widget)
|
||||
demo->swin = GTK_WIDGET (gtk_builder_get_object (builder, "swin"));
|
||||
|
||||
demo->provider = gtk_css_provider_new ();
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (demo->provider), 800);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (demo->swin),
|
||||
GTK_STYLE_PROVIDER (demo->provider), 800);
|
||||
|
||||
basic_value_changed (demo->size_adjustment, demo->size_entry);
|
||||
basic_value_changed (demo->letterspacing_adjustment, demo->letterspacing_entry);
|
||||
@@ -1880,5 +1824,3 @@ do_font_features (GtkWidget *do_widget)
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
|
@@ -259,10 +259,16 @@
|
||||
<object class="GtkBox" id="feature_list">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkDropDown" id="script_lang">
|
||||
<object class="GtkComboBox" id="script_lang">
|
||||
<property name="tooltip-text" translatable="yes">Language System</property>
|
||||
<property name="margin-top">10</property>
|
||||
<signal name="notify::selected" handler="font_features_script_changed" swapped="no"/>
|
||||
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@@ -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);
|
||||
|
@@ -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>
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (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_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -83,32 +83,6 @@ void gtk_color_chooser_add_palette (GtkColorChooser *chooser,
|
||||
int n_colors,
|
||||
GdkRGBA *colors);
|
||||
|
||||
|
||||
typedef void (*GtkColorChooserPrepareCallback) (GtkColorChooser *chooser,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_choose_color (GtkWindow *parent,
|
||||
const char *title,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_choose_color_full (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkColorChooserPrepareCallback prepare,
|
||||
gpointer prepare_data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_choose_color_finish (GtkColorChooser *chooser,
|
||||
GAsyncResult *result,
|
||||
GdkRGBA *color,
|
||||
GError **error);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooser, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -1,439 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkwindow.h"
|
||||
#include "gtkwindowprivate.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkbox.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtksettings.h"
|
||||
|
||||
#include "gtkcolorchooserprivate.h"
|
||||
#include "gtkcolorchooserwindowprivate.h"
|
||||
#include "gtkcolorchooserwidget.h"
|
||||
|
||||
/*
|
||||
* GtkColorChooserWindow:
|
||||
*
|
||||
* A window for choosing a color.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `GtkColorChooserWindow` implements the [iface@Gtk.ColorChooser] interface
|
||||
* and does not provide much API of its own.
|
||||
*
|
||||
* To create a `GtkColorChooserWindow`, use [ctor@Gtk.ColorChooserWindow.new].
|
||||
*
|
||||
* To change the initially selected color, use
|
||||
* [method@Gtk.ColorChooser.set_rgba]. To get the selected color use
|
||||
* [method@Gtk.ColorChooser.get_rgba].
|
||||
*/
|
||||
|
||||
typedef struct _GtkColorChooserWindowClass GtkColorChooserWindowClass;
|
||||
|
||||
struct _GtkColorChooserWindow
|
||||
{
|
||||
GtkWindow parent_instance;
|
||||
|
||||
GtkWidget *chooser;
|
||||
};
|
||||
|
||||
struct _GtkColorChooserWindowClass
|
||||
{
|
||||
GtkWindowClass parent_class;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_ZERO,
|
||||
PROP_RGBA,
|
||||
PROP_USE_ALPHA,
|
||||
PROP_SHOW_EDITOR
|
||||
};
|
||||
|
||||
static void gtk_color_chooser_window_iface_init (GtkColorChooserInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkColorChooserWindow, gtk_color_chooser_window, GTK_TYPE_WINDOW,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
|
||||
gtk_color_chooser_window_iface_init))
|
||||
|
||||
static void
|
||||
propagate_notify (GObject *o,
|
||||
GParamSpec *pspec,
|
||||
GtkColorChooserWindow *cc)
|
||||
{
|
||||
g_object_notify (G_OBJECT (cc), pspec->name);
|
||||
}
|
||||
|
||||
static void
|
||||
save_color (GtkColorChooserWindow *window)
|
||||
{
|
||||
GdkRGBA color;
|
||||
|
||||
/* This causes the color chooser widget to save the
|
||||
* selected and custom colors to GSettings.
|
||||
*/
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (window), &color);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (window), &color);
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
RESPONSE_OK,
|
||||
RESPONSE_CANCEL
|
||||
};
|
||||
|
||||
static void
|
||||
response_cb (GtkWindow *window,
|
||||
int response);
|
||||
|
||||
static void
|
||||
color_activated_cb (GtkColorChooser *chooser,
|
||||
GdkRGBA *color,
|
||||
GtkWindow *window)
|
||||
{
|
||||
save_color (GTK_COLOR_CHOOSER_WINDOW (window));
|
||||
response_cb (GTK_WINDOW (window), RESPONSE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
ok_button_cb (GtkButton *button,
|
||||
GtkWindow *window)
|
||||
{
|
||||
response_cb (window, RESPONSE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_button_cb (GtkButton *button,
|
||||
GtkWindow *window)
|
||||
{
|
||||
response_cb (window, RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_init (GtkColorChooserWindow *cc)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (cc));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_unmap (GtkWidget *widget)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gtk_color_chooser_window_parent_class)->unmap (widget);
|
||||
|
||||
/* We never want the window to come up with the editor,
|
||||
* even if it was showing the editor the last time it was used.
|
||||
*/
|
||||
g_object_set (widget, "show-editor", FALSE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorChooserWindow *cc = GTK_COLOR_CHOOSER_WINDOW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RGBA:
|
||||
{
|
||||
GdkRGBA color;
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (cc), &color);
|
||||
g_value_set_boxed (value, &color);
|
||||
}
|
||||
break;
|
||||
case PROP_USE_ALPHA:
|
||||
g_value_set_boolean (value, gtk_color_chooser_get_use_alpha (GTK_COLOR_CHOOSER (cc->chooser)));
|
||||
break;
|
||||
case PROP_SHOW_EDITOR:
|
||||
{
|
||||
gboolean show_editor;
|
||||
g_object_get (cc->chooser, "show-editor", &show_editor, NULL);
|
||||
g_value_set_boolean (value, show_editor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorChooserWindow *cc = GTK_COLOR_CHOOSER_WINDOW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RGBA:
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc), g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_USE_ALPHA:
|
||||
if (gtk_color_chooser_get_use_alpha (GTK_COLOR_CHOOSER (cc->chooser)) != g_value_get_boolean (value))
|
||||
{
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (cc->chooser), g_value_get_boolean (value));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
break;
|
||||
case PROP_SHOW_EDITOR:
|
||||
g_object_set (cc->chooser,
|
||||
"show-editor", g_value_get_boolean (value),
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_dispose (GObject *object)
|
||||
{
|
||||
GtkColorChooserWindow *cc = GTK_COLOR_CHOOSER_WINDOW (object);
|
||||
|
||||
g_clear_pointer (&cc->chooser, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_chooser_window_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_class_init (GtkColorChooserWindowClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
object_class->dispose = gtk_color_chooser_window_dispose;
|
||||
object_class->get_property = gtk_color_chooser_window_get_property;
|
||||
object_class->set_property = gtk_color_chooser_window_set_property;
|
||||
|
||||
widget_class->unmap = gtk_color_chooser_window_unmap;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_RGBA, "rgba");
|
||||
g_object_class_override_property (object_class, PROP_USE_ALPHA, "use-alpha");
|
||||
g_object_class_install_property (object_class, PROP_SHOW_EDITOR,
|
||||
g_param_spec_boolean ("show-editor", NULL, NULL,
|
||||
FALSE, GTK_PARAM_READWRITE));
|
||||
|
||||
/* Bind class to template
|
||||
*/
|
||||
gtk_widget_class_set_template_from_resource (widget_class,
|
||||
"/org/gtk/libgtk/ui/gtkcolorchooserwindow.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkColorChooserWindow, chooser);
|
||||
gtk_widget_class_bind_template_callback (widget_class, propagate_notify);
|
||||
gtk_widget_class_bind_template_callback (widget_class, color_activated_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, ok_button_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, cancel_button_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_get_rgba (GtkColorChooser *chooser,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GtkColorChooserWindow *cc = GTK_COLOR_CHOOSER_WINDOW (chooser);
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (cc->chooser), color);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_set_rgba (GtkColorChooser *chooser,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
GtkColorChooserWindow *cc = GTK_COLOR_CHOOSER_WINDOW (chooser);
|
||||
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc->chooser), color);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_add_palette (GtkColorChooser *chooser,
|
||||
GtkOrientation orientation,
|
||||
int colors_per_line,
|
||||
int n_colors,
|
||||
GdkRGBA *colors)
|
||||
{
|
||||
GtkColorChooserWindow *cc = GTK_COLOR_CHOOSER_WINDOW (chooser);
|
||||
|
||||
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (cc->chooser),
|
||||
orientation, colors_per_line, n_colors, colors);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_iface_init (GtkColorChooserInterface *iface)
|
||||
{
|
||||
iface->get_rgba = gtk_color_chooser_window_get_rgba;
|
||||
iface->set_rgba = gtk_color_chooser_window_set_rgba;
|
||||
iface->add_palette = gtk_color_chooser_window_add_palette;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_color_chooser_window_new:
|
||||
* @title: (nullable): Title of the window
|
||||
* @parent: (nullable): Transient parent of the window
|
||||
*
|
||||
* Creates a new `GtkColorChooserWindow`.
|
||||
*
|
||||
* Returns: a new `GtkColorChooserWindow`
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_color_chooser_window_new (const char *title,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_COLOR_CHOOSER_WINDOW,
|
||||
"title", title,
|
||||
"transient-for", parent,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GtkWindow *window)
|
||||
{
|
||||
response_cb (window, RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
response_cb (GtkWindow *window,
|
||||
int response)
|
||||
{
|
||||
GTask *task = G_TASK (g_object_get_data (G_OBJECT (window), "task"));
|
||||
GCancellable *cancellable = g_task_get_cancellable (task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, window);
|
||||
|
||||
if (response == RESPONSE_OK)
|
||||
{
|
||||
save_color (GTK_COLOR_CHOOSER_WINDOW (window));
|
||||
g_task_return_boolean (task, TRUE);
|
||||
}
|
||||
else
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
|
||||
|
||||
g_object_unref (task);
|
||||
gtk_window_destroy (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_color:
|
||||
* @parent: (nullable): parent window
|
||||
* @title: title for the color chooser
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): callback to call when the action is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function presents a color chooser to let the user
|
||||
* pick a color.
|
||||
*
|
||||
* The @callback will be called when the window is closed.
|
||||
* It should call [function@Gtk.choose_color_finish] to
|
||||
* find out whether the operation was completed successfully,
|
||||
* and to obtain the resulting color.
|
||||
*/
|
||||
void
|
||||
gtk_choose_color (GtkWindow *parent,
|
||||
const char *title,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_choose_color_full (parent, title, NULL, NULL, cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_color_full:
|
||||
* @parent: (nullable): parent window
|
||||
* @title: title for the color chooser
|
||||
* @prepare: (nullable) (scope call): callback to set up the color chooser
|
||||
* @prepare_data: (closure prepare): data to pass to @prepare
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): callback to call when the action is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function presents a color chooser to let the user
|
||||
* pick a color.
|
||||
*
|
||||
* In addition to [function@Gtk.choose_color], this function takes
|
||||
* a @prepare callback that lets you set up the color chooser according
|
||||
* to your needs.
|
||||
*
|
||||
* The @callback will be called when the window is closed.
|
||||
* It should call [function@Gtk.choose_color_finish] to
|
||||
* find out whether the operation was completed successfully,
|
||||
* and to obtain the resulting color.
|
||||
*/
|
||||
void
|
||||
gtk_choose_color_full (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkColorChooserPrepareCallback prepare,
|
||||
gpointer prepare_data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GTask *task;
|
||||
|
||||
window = gtk_color_chooser_window_new (title, parent);
|
||||
if (prepare)
|
||||
prepare (GTK_COLOR_CHOOSER (window), prepare);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), window);
|
||||
|
||||
task = g_task_new (window, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_choose_color_full);
|
||||
|
||||
g_object_set_data (G_OBJECT (window), "task", task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_color_finish:
|
||||
* @chooser: the `GtkColorChooser`
|
||||
* @result: `GAsyncResult` that was passed to @callback
|
||||
* @color: return location for the color
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes a gtk_choose_color() or gtk_choose_color_full() call
|
||||
* and returns the results.
|
||||
*
|
||||
* If this function returns `TRUE`, @color contains
|
||||
* the color that was chosen.
|
||||
*
|
||||
* Returns: `TRUE` if the operation was successful
|
||||
*/
|
||||
gboolean
|
||||
gtk_choose_color_finish (GtkColorChooser *chooser,
|
||||
GAsyncResult *result,
|
||||
GdkRGBA *color,
|
||||
GError **error)
|
||||
{
|
||||
if (!g_task_propagate_boolean (G_TASK (result), error))
|
||||
return FALSE;
|
||||
|
||||
gtk_color_chooser_get_rgba (chooser, color);
|
||||
|
||||
return TRUE;
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_COLOR_CHOOSER_WINDOW_PRIVATE_H___
|
||||
#define __GTK_COLOR_CHOOSER_WINDOW_PRIVATE_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COLOR_CHOOSER_WINDOW (gtk_color_chooser_window_get_type ())
|
||||
#define GTK_COLOR_CHOOSER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER_WINDOW, GtkColorChooserWindow))
|
||||
#define GTK_IS_COLOR_CHOOSER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER_WINDOW))
|
||||
|
||||
typedef struct _GtkColorChooserWindow GtkColorChooserWindow;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_color_chooser_window_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget * gtk_color_chooser_window_new (const char *title,
|
||||
GtkWindow *parent);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWindow, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_COLOR_CHOOSER_WINDOW_PRIVATE_H__ */
|
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "gtkcomposetable.h"
|
||||
#include "gtkimcontextsimple.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
|
||||
#define GTK_COMPOSE_TABLE_MAGIC "GtkComposeTable"
|
||||
|
@@ -61,8 +61,7 @@ struct _GtkEntryCompletion
|
||||
|
||||
gulong completion_timeout;
|
||||
gulong changed_id;
|
||||
|
||||
GSignalGroup *insert_text_signal_group;
|
||||
gulong insert_text_id;
|
||||
|
||||
int current_selected;
|
||||
|
||||
|
@@ -183,34 +183,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
const char * gtk_file_chooser_get_choice (GtkFileChooser *chooser,
|
||||
const char *id);
|
||||
|
||||
|
||||
typedef void (*GtkFileChooserPrepareCallback) (GtkFileChooser *chooser,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_choose_file (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkFileChooserAction action,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_choose_file_full (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkFileChooserAction action,
|
||||
GtkFileChooserPrepareCallback prepare,
|
||||
gpointer prepare_data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_choose_file_finish (GtkFileChooser *chooser,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_H__ */
|
||||
|
@@ -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);
|
||||
}
|
@@ -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__ */
|
@@ -735,140 +735,3 @@ gtk_file_chooser_dialog_new (const char *title,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GtkDialog *dialog)
|
||||
{
|
||||
gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
choose_response_cb (GtkDialog *dialog,
|
||||
int response,
|
||||
GTask *task)
|
||||
{
|
||||
GCancellable *cancellable = g_task_get_cancellable (task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, dialog);
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
g_task_return_boolean (task, TRUE);
|
||||
else
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
|
||||
|
||||
g_object_unref (task);
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_file:
|
||||
* @parent: (nullable): parent window
|
||||
* @title: title for the font chooser
|
||||
* @action: the action for the file chooser
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): callback to call when the action is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function presents a file chooser to let the user
|
||||
* pick a file.
|
||||
*
|
||||
* The @callback will be called when the dialog is closed.
|
||||
* It should call [function@Gtk.choose_file_finish] to
|
||||
* find out whether the operation was completed successfully,
|
||||
* and use [class@Gtk.FileChooser] API to obtain the results.
|
||||
*/
|
||||
void
|
||||
gtk_choose_file (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkFileChooserAction action,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_choose_file_full (parent, title, action, NULL, NULL, cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_file_full:
|
||||
* @parent: (nullable): parent window
|
||||
* @title: title for the file chooser
|
||||
* @action: the action for the file chooser
|
||||
* @prepare: (nullable) (scope call): callback to set up the file chooser
|
||||
* @prepare_data: (closure prepare): data to pass to @prepare
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): callback to call when the action is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function presents a file chooser to let the user
|
||||
* choose a file.
|
||||
*
|
||||
* In addition to [function@Gtk.choose_file], this function takes
|
||||
* a @prepare callback that lets you set up the file chooser according
|
||||
* to your needs.
|
||||
*
|
||||
* The @callback will be called when the dialog is closed.
|
||||
* It should use [function@Gtk.choose_file_finish] to find
|
||||
* out whether the operation was completed successfully,
|
||||
* and use [class@Gtk.FileChooser] API to obtain the results.
|
||||
*/
|
||||
void
|
||||
gtk_choose_file_full (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkFileChooserAction action,
|
||||
GtkFileChooserPrepareCallback prepare,
|
||||
gpointer prepare_data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GTask *task;
|
||||
const char *button[] = {
|
||||
N_("_Open"),
|
||||
N_("_Save"),
|
||||
N_("_Select")
|
||||
};
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new (title, parent, action,
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_(button[action]), GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
if (prepare)
|
||||
prepare (GTK_FILE_CHOOSER (dialog), prepare);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), dialog);
|
||||
|
||||
task = g_task_new (dialog, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_choose_file_full);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (choose_response_cb), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_file_finish:
|
||||
* @chooser: the `GtkFileChooser`
|
||||
* @result: `GAsyncResult` that was passed to @callback
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes a gtk_choose_file() or gtk_choose_file_full() call
|
||||
* and returns whether the operation was successful.
|
||||
*
|
||||
* If this function returns `TRUE`, you can use
|
||||
* [class@Gtk.FileChooser] API to get the results.
|
||||
*
|
||||
* Returns: `TRUE` if the operation was successful
|
||||
*/
|
||||
gboolean
|
||||
gtk_choose_file_finish (GtkFileChooser *chooser,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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"));
|
||||
}
|
||||
|
@@ -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__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
@@ -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__ */
|
||||
|
@@ -161,31 +161,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_font_chooser_set_language (GtkFontChooser *fontchooser,
|
||||
const char *language);
|
||||
|
||||
typedef void (*GtkFontChooserPrepareCallback) (GtkFontChooser *chooser,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_choose_font (GtkWindow *parent,
|
||||
const char *title,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_choose_font_full (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkFontChooserPrepareCallback prepare,
|
||||
gpointer prepare_data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_choose_font_finish (GtkFontChooser *chooser,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkFontChooser, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -324,127 +324,3 @@ gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildable *buildable,
|
||||
|
||||
return parent_buildable_iface->get_internal_child (buildable, builder, childname);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GtkDialog *dialog)
|
||||
{
|
||||
gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
response_cb (GtkDialog *dialog,
|
||||
int response,
|
||||
GTask *task)
|
||||
{
|
||||
GCancellable *cancellable = g_task_get_cancellable (task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, dialog);
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
g_task_return_boolean (task, TRUE);
|
||||
else
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
|
||||
|
||||
g_object_unref (task);
|
||||
gtk_window_destroy (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_font:
|
||||
* @parent: (nullable): parent window
|
||||
* @title: title for the font chooser
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): callback to call when the action is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function presents a font chooser to let the user
|
||||
* pick a font.
|
||||
*
|
||||
* The @callback will be called when the dialog is closed.
|
||||
* It should call [function@Gtk.choose_font_finish] to
|
||||
* find out whether the operation was completed successfully,
|
||||
* and use [class@Gtk.FontChooser] API to obtain the results.
|
||||
*/
|
||||
void
|
||||
gtk_choose_font (GtkWindow *parent,
|
||||
const char *title,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_choose_font_full (parent, title, NULL, NULL, cancellable, callback, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_font_full:
|
||||
* @parent: (nullable): parent window
|
||||
* @title: title for the font chooser
|
||||
* @prepare: (nullable) (scope call): callback to set up the font chooser
|
||||
* @prepare_data: (closure prepare): data to pass to @prepare
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): callback to call when the action is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
*
|
||||
* This function presents a font chooser to let the user
|
||||
* choose a font.
|
||||
*
|
||||
* In addition to [function@Gtk.choose_font], this function takes
|
||||
* a @prepare callback that lets you set up the font chooser according
|
||||
* to your needs.
|
||||
*
|
||||
* The @callback will be called when the dialog is closed.
|
||||
* It should use [function@Gtk.choose_font_finish] to find
|
||||
* out whether the operation was completed successfully,
|
||||
* and use [class@Gtk.FontChooser] API to obtain the results.
|
||||
*/
|
||||
void
|
||||
gtk_choose_font_full (GtkWindow *parent,
|
||||
const char *title,
|
||||
GtkFontChooserPrepareCallback prepare,
|
||||
gpointer prepare_data,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GTask *task;
|
||||
|
||||
dialog = gtk_font_chooser_dialog_new (title, parent);
|
||||
if (prepare)
|
||||
prepare (GTK_FONT_CHOOSER (dialog), prepare);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), dialog);
|
||||
|
||||
task = g_task_new (dialog, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_choose_font_full);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), task);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_choose_font_finish:
|
||||
* @chooser: the `GtkFontChooser`
|
||||
* @result: `GAsyncResult` that was passed to @callback
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes a gtk_choose_font() or gtk_choose_font_full() call
|
||||
* and returns whether the operation was successful.
|
||||
*
|
||||
* If this function returns `TRUE`, you can use
|
||||
* [class@Gtk.FontChooser] API to get the results.
|
||||
*
|
||||
* Returns: `TRUE` if the operation was successful
|
||||
*/
|
||||
gboolean
|
||||
gtk_choose_font_finish (GtkFontChooser *chooser,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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',
|
||||
@@ -186,7 +184,6 @@ gtk_public_sources = files([
|
||||
'gtkcolorchooser.c',
|
||||
'gtkcolorchooserdialog.c',
|
||||
'gtkcolorchooserwidget.c',
|
||||
'gtkcolorchooserwindow.c',
|
||||
'gtkcolorutils.c',
|
||||
'gtkcolumnview.c',
|
||||
'gtkcolumnviewcolumn.c',
|
||||
|
@@ -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 *
|
||||
*********************/
|
||||
|
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk40">
|
||||
<template class="GtkColorChooserWindow" parent="GtkWindow">
|
||||
<property name="title" translatable="yes">Select a Color</property>
|
||||
<property name="resizable">0</property>
|
||||
<property name="default-widget">ok_button</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="show-title-buttons">0</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton" id="cancel_button">
|
||||
<property name="use-underline">1</property>
|
||||
<property name="label" translatable="yes">_Cancel</property>
|
||||
<signal name="clicked" handler="cancel_button_cb"/>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton" id="ok_button">
|
||||
<property name="label" translatable="yes">_Select</property>
|
||||
<property name="use-underline">1</property>
|
||||
<signal name="clicked" handler="ok_button_cb"/>
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">1</property>
|
||||
<property name="spacing">2</property>
|
||||
<property name="margin-start">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<child>
|
||||
<object class="GtkColorChooserWidget" id="chooser">
|
||||
<property name="margin-start">5</property>
|
||||
<property name="margin-end">5</property>
|
||||
<property name="margin-top">5</property>
|
||||
<property name="margin-bottom">5</property>
|
||||
<property name="rgba">rgb(255,255,255)</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="vexpand">1</property>
|
||||
<signal name="color-activated" handler="color_activated_cb" swapped="no"/>
|
||||
<signal name="notify::rgba" handler="propagate_notify" swapped="no"/>
|
||||
<signal name="notify::show-editor" handler="propagate_notify" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
@@ -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>
|
||||
|
18
meson.build
18
meson.build
@@ -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
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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'))
|
||||
|
Reference in New Issue
Block a user