Compare commits
111 Commits
fix-build-
...
async-colo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c42750efd | ||
|
|
ab833951db | ||
|
|
aa5041e65c | ||
|
|
4022786847 | ||
|
|
029bb9ad18 | ||
|
|
799fb41937 | ||
|
|
e6f4c596fa | ||
|
|
3d7fb26588 | ||
|
|
93f9b2d519 | ||
|
|
6f3613a06f | ||
|
|
3723778f42 | ||
|
|
3fc3f8d2ff | ||
|
|
2868f1b509 | ||
|
|
f44570e71a | ||
|
|
15d39dddc5 | ||
|
|
1028449bcc | ||
|
|
01cca279f9 | ||
|
|
a7cae4bffa | ||
|
|
3e2e29a1dc | ||
|
|
de069e15c2 | ||
|
|
f8edefd7c0 | ||
|
|
24a15b51fe | ||
|
|
1f7aba345d | ||
|
|
230212c59c | ||
|
|
86f7c19b91 | ||
|
|
e5cea4e39d | ||
|
|
22aca8952f | ||
|
|
c0e437d163 | ||
|
|
ffe97a453f | ||
|
|
c09ba28b06 | ||
|
|
81de43eba5 | ||
|
|
788be8b945 | ||
|
|
0370979225 | ||
|
|
943014074c | ||
|
|
c0e8523a01 | ||
|
|
8374ebe4c4 | ||
|
|
611d14108d | ||
|
|
25cf702345 | ||
|
|
1d9c61cada | ||
|
|
71adb26a0d | ||
|
|
e27fa33690 | ||
|
|
f7dfead861 | ||
|
|
aac04a0995 | ||
|
|
8af191e52d | ||
|
|
06382ff836 | ||
|
|
cd469788c3 | ||
|
|
44b5076cf2 | ||
|
|
e5be9e1035 | ||
|
|
b831d01f0d | ||
|
|
278bcf2680 | ||
|
|
c19d0dc9ea | ||
|
|
edd5ed169e | ||
|
|
8ec9c3fdc6 | ||
|
|
e95022040f | ||
|
|
3a2ce620e2 | ||
|
|
df49bf9eec | ||
|
|
53327f3aea | ||
|
|
c0c3d75062 | ||
|
|
d0d0409f9d | ||
|
|
3a7d094542 | ||
|
|
280adcbb8c | ||
|
|
83431a999c | ||
|
|
eeeee99aa8 | ||
|
|
0f503e0ba2 | ||
|
|
3e4ae62b44 | ||
|
|
ec4f814bd4 | ||
|
|
0141ba4e00 | ||
|
|
52ef16c21b | ||
|
|
6ca7104015 | ||
|
|
07d6166ab8 | ||
|
|
dc651c3dc3 | ||
|
|
f520801626 | ||
|
|
4e3fbd0b0f | ||
|
|
8a24fdea38 | ||
|
|
b26222b6ba | ||
|
|
c8d291ab86 | ||
|
|
0a87438432 | ||
|
|
ddf1cd6678 | ||
|
|
9c6d5e2ca5 | ||
|
|
1f2561b08e | ||
|
|
d5b31a30fd | ||
|
|
39c678988d | ||
|
|
9052c191cb | ||
|
|
766f442636 | ||
|
|
27a3d2d09e | ||
|
|
3a3482e41e | ||
|
|
44c37fa34a | ||
|
|
5c41dbfaa5 | ||
|
|
c9d2ff7a0f | ||
|
|
174af596c5 | ||
|
|
de2624faa7 | ||
|
|
cda784a5f4 | ||
|
|
cc33dbef03 | ||
|
|
ce36611c4e | ||
|
|
038cb31d27 | ||
|
|
3b53a6b0a9 | ||
|
|
619ff2338e | ||
|
|
2bcd6949df | ||
|
|
abd78ce5f5 | ||
|
|
7899fc03c4 | ||
|
|
9984f00781 | ||
|
|
a0d3bdc911 | ||
|
|
b96317b872 | ||
|
|
6c84958b9f | ||
|
|
f2559b1dbb | ||
|
|
ed2ade4801 | ||
|
|
4549172825 | ||
|
|
b877804eb6 | ||
|
|
5310abbcf7 | ||
|
|
490d4b0b9e | ||
|
|
230188fb30 |
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
|
||||
|
||||
@@ -26,6 +25,9 @@ struct _CanvasItem {
|
||||
double delta;
|
||||
|
||||
GtkWidget *editor;
|
||||
|
||||
GtkStyleProvider *provider;
|
||||
char *css_class;
|
||||
};
|
||||
|
||||
struct _CanvasItemClass {
|
||||
@@ -36,32 +38,41 @@ G_DEFINE_TYPE (CanvasItem, canvas_item, GTK_TYPE_WIDGET)
|
||||
|
||||
static int n_items = 0;
|
||||
|
||||
static void
|
||||
unstyle_item (CanvasItem *item)
|
||||
{
|
||||
if (item->provider)
|
||||
{
|
||||
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (item->label), item->provider);
|
||||
g_clear_object (&item->provider);
|
||||
}
|
||||
|
||||
if (item->css_class)
|
||||
{
|
||||
gtk_widget_remove_css_class (item->label, item->css_class);
|
||||
g_clear_pointer (&item->css_class, g_free);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_color (CanvasItem *item,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
char *css;
|
||||
char *str;
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
const char *name;
|
||||
|
||||
unstyle_item (item);
|
||||
|
||||
str = gdk_rgba_to_string (color);
|
||||
css = g_strdup_printf ("* { background: %s; }", str);
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
name = gtk_widget_get_name (item->label);
|
||||
css = g_strdup_printf ("#%s { background: %s; }", name, str);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
|
||||
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
|
||||
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
|
||||
item->provider = GTK_STYLE_PROVIDER (provider);
|
||||
|
||||
g_free (str);
|
||||
g_free (css);
|
||||
@@ -71,21 +82,10 @@ static void
|
||||
set_css (CanvasItem *item,
|
||||
const char *class)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *provider;
|
||||
const char *old_class;
|
||||
unstyle_item (item);
|
||||
|
||||
context = gtk_widget_get_style_context (item->label);
|
||||
provider = g_object_get_data (G_OBJECT (context), "style-provider");
|
||||
if (provider)
|
||||
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
|
||||
|
||||
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
|
||||
if (old_class)
|
||||
gtk_widget_remove_css_class (item->label, old_class);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
|
||||
gtk_widget_add_css_class (item->label, class);
|
||||
item->css_class = g_strdup (class);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -724,6 +724,7 @@ do_dnd (GtkWidget *do_widget)
|
||||
int i;
|
||||
int x, y;
|
||||
GtkCssProvider *provider;
|
||||
GString *css;
|
||||
|
||||
button = gtk_color_button_new ();
|
||||
g_object_unref (g_object_ref_sink (button));
|
||||
@@ -735,6 +736,18 @@ do_dnd (GtkWidget *do_widget)
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
|
||||
css = g_string_new ("");
|
||||
for (i = 0; colors[i]; i++)
|
||||
g_string_append_printf (css, ".canvasitem.%s { background: %s; }\n", colors[i], colors[i]);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css->str, css->len);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
g_object_unref (provider);
|
||||
g_string_free (css, TRUE);
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (do_widget));
|
||||
|
||||
@@ -21,7 +21,75 @@
|
||||
#include "script-names.h"
|
||||
#include "language-names.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
/* {{{ 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);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
||||
|
||||
@@ -95,6 +163,10 @@ 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);
|
||||
}
|
||||
|
||||
@@ -472,8 +544,6 @@ update_display (void)
|
||||
GString *s;
|
||||
char *text;
|
||||
gboolean has_feature;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
PangoFontDescription *desc;
|
||||
GList *l;
|
||||
PangoAttrList *attrs;
|
||||
@@ -576,14 +646,13 @@ update_display (void)
|
||||
|
||||
features = g_string_free (s, FALSE);
|
||||
|
||||
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
|
||||
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) != 0)
|
||||
{
|
||||
hb_tag_t lang_tag;
|
||||
ScriptLang *selected;
|
||||
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
|
||||
gtk_tree_model_get (model, &iter, 3, &lang_tag, -1);
|
||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
||||
|
||||
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (lang_tag)));
|
||||
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (selected->lang_tag)));
|
||||
}
|
||||
else
|
||||
lang = NULL;
|
||||
@@ -740,40 +809,30 @@ 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 int
|
||||
script_sort_func (GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
|
||||
static GtkOrdering
|
||||
script_sort (const void *item1,
|
||||
const void *item2,
|
||||
void *data)
|
||||
{
|
||||
char *sa, *sb;
|
||||
int ret;
|
||||
ScriptLang *a = (ScriptLang *)item1;
|
||||
ScriptLang *b = (ScriptLang *)item2;
|
||||
|
||||
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;
|
||||
return strcmp (a->langname, b->langname);
|
||||
}
|
||||
|
||||
static void
|
||||
update_script_combo (void)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GListStore *store;
|
||||
GtkSortListModel *sortmodel;
|
||||
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));
|
||||
|
||||
@@ -783,7 +842,7 @@ update_script_combo (void)
|
||||
|
||||
g_free (lang);
|
||||
|
||||
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
|
||||
store = g_list_store_new (script_lang_get_type ());
|
||||
|
||||
pango_font = get_pango_font ();
|
||||
hb_font = pango_font_get_hb_font (pango_font);
|
||||
@@ -807,19 +866,19 @@ update_script_combo (void)
|
||||
|
||||
hb_face = hb_font_get_face (hb_font);
|
||||
|
||||
for (i= 0; i < 2; i++)
|
||||
for (guint 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 (j = 0; j < script_count; j++)
|
||||
for (guint 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 (k = 0; k < language_count; k++)
|
||||
for (guint k = 0; k < language_count; k++)
|
||||
{
|
||||
pair = g_new (TagPair, 1);
|
||||
pair->script_tag = scripts[j];
|
||||
@@ -839,7 +898,6 @@ 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");
|
||||
@@ -856,31 +914,31 @@ update_script_combo (void)
|
||||
}
|
||||
}
|
||||
|
||||
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_list_store_append (store, script_lang_new (langname,
|
||||
pair->script_index,
|
||||
pair->lang_index,
|
||||
pair->lang_tag));
|
||||
}
|
||||
|
||||
g_hash_table_destroy (tags);
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -905,27 +963,19 @@ 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_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
|
||||
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) == 0)
|
||||
return;
|
||||
|
||||
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);
|
||||
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
|
||||
|
||||
if (lang_tag == 0) /* None is selected */
|
||||
if (selected->lang_tag == 0) /* None is selected */
|
||||
{
|
||||
for (l = demo->feature_items; l; l = l->next)
|
||||
{
|
||||
@@ -966,8 +1016,8 @@ update_features (void)
|
||||
|
||||
hb_ot_layout_language_get_feature_tags (hb_face,
|
||||
tables[i],
|
||||
script_index,
|
||||
lang_index,
|
||||
selected->script_index,
|
||||
selected->lang_index,
|
||||
0,
|
||||
&count,
|
||||
features);
|
||||
@@ -989,8 +1039,8 @@ update_features (void)
|
||||
|
||||
hb_ot_layout_language_find_feature (hb_face,
|
||||
tables[i],
|
||||
script_index,
|
||||
lang_index,
|
||||
selected->script_index,
|
||||
selected->lang_index,
|
||||
features[j],
|
||||
&feature_index);
|
||||
|
||||
@@ -1322,10 +1372,9 @@ free_instance (gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
add_instance (hb_face_t *face,
|
||||
unsigned int index,
|
||||
GtkWidget *combo,
|
||||
int pos)
|
||||
add_instance (hb_face_t *face,
|
||||
unsigned int index,
|
||||
GtkStringList *strings)
|
||||
{
|
||||
Instance *instance;
|
||||
hb_ot_name_id_t name_id;
|
||||
@@ -1341,20 +1390,20 @@ add_instance (hb_face_t *face,
|
||||
instance->index = index;
|
||||
|
||||
g_hash_table_add (demo->instances, instance);
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), instance->name);
|
||||
gtk_string_list_append (GTK_STRING_LIST (strings), instance->name);
|
||||
}
|
||||
|
||||
static void
|
||||
unset_instance (GtkAdjustment *adjustment)
|
||||
{
|
||||
if (demo->instance_combo)
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (demo->instance_combo), 0);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->instance_combo), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
instance_changed (GtkComboBox *combo)
|
||||
instance_changed (GtkDropDown *combo)
|
||||
{
|
||||
char *text;
|
||||
const char *text;
|
||||
Instance *instance;
|
||||
Instance ikey;
|
||||
int i;
|
||||
@@ -1366,11 +1415,12 @@ instance_changed (GtkComboBox *combo)
|
||||
hb_font_t *hb_font;
|
||||
hb_face_t *hb_face;
|
||||
|
||||
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
|
||||
text = gtk_string_list_get_string (GTK_STRING_LIST (gtk_drop_down_get_model (combo)),
|
||||
gtk_drop_down_get_selected (combo));
|
||||
if (text[0] == '\0')
|
||||
goto out;
|
||||
|
||||
ikey.name = text;
|
||||
ikey.name = (char *) text;
|
||||
instance = g_hash_table_lookup (demo->instances, &ikey);
|
||||
if (!instance)
|
||||
{
|
||||
@@ -1411,7 +1461,6 @@ instance_changed (GtkComboBox *combo)
|
||||
}
|
||||
|
||||
out:
|
||||
g_free (text);
|
||||
g_clear_object (&pango_font);
|
||||
g_free (ai);
|
||||
g_free (coords);
|
||||
@@ -1521,6 +1570,7 @@ update_font_variations (void)
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *combo;
|
||||
GtkStringList *strings;
|
||||
|
||||
label = gtk_label_new ("Instance");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
@@ -1528,26 +1578,28 @@ 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);
|
||||
|
||||
combo = gtk_combo_box_text_new ();
|
||||
strings = gtk_string_list_new (NULL);
|
||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
|
||||
gtk_widget_set_halign (combo, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE);
|
||||
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "");
|
||||
gtk_string_list_append (strings, "");
|
||||
|
||||
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
|
||||
add_instance (hb_face, i, combo, i);
|
||||
add_instance (hb_face, i, strings);
|
||||
|
||||
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_combo_box_set_active (GTK_COMBO_BOX (combo), i + 1);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_grid_attach (GTK_GRID (demo->variations_grid), combo, 1, -1, 3, 1);
|
||||
g_signal_connect (combo, "changed", G_CALLBACK (instance_changed), NULL);
|
||||
g_signal_connect (combo, "notify::selecte", G_CALLBACK (instance_changed), NULL);
|
||||
demo->instance_combo = combo;
|
||||
}
|
||||
|
||||
@@ -1694,6 +1746,7 @@ do_font_features (GtkWidget *do_widget)
|
||||
GtkBuilder *builder;
|
||||
GtkBuilderScope *scope;
|
||||
GtkEventController *controller;
|
||||
GtkExpression *expression;
|
||||
|
||||
builder = gtk_builder_new ();
|
||||
|
||||
@@ -1727,6 +1780,9 @@ 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"));
|
||||
@@ -1745,8 +1801,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 (gtk_widget_get_style_context (demo->swin),
|
||||
GTK_STYLE_PROVIDER (demo->provider), 800);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (demo->provider), 800);
|
||||
|
||||
basic_value_changed (demo->size_adjustment, demo->size_entry);
|
||||
basic_value_changed (demo->letterspacing_adjustment, demo->letterspacing_entry);
|
||||
@@ -1824,3 +1880,5 @@ do_font_features (GtkWidget *do_widget)
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
|
||||
@@ -259,16 +259,10 @@
|
||||
<object class="GtkBox" id="feature_list">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="script_lang">
|
||||
<object class="GtkDropDown" id="script_lang">
|
||||
<property name="tooltip-text" translatable="yes">Language System</property>
|
||||
<property name="margin-top">10</property>
|
||||
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
<signal name="notify::selected" handler="font_features_script_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *font_button = NULL;
|
||||
static GtkWidget *entry = NULL;
|
||||
@@ -45,7 +43,6 @@ update_image (void)
|
||||
cairo_t *cr;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *pixbuf2;
|
||||
const char *hint;
|
||||
cairo_font_options_t *fopt;
|
||||
cairo_hint_style_t hintstyle;
|
||||
cairo_hint_metrics_t hintmetrics;
|
||||
@@ -60,18 +57,23 @@ update_image (void)
|
||||
|
||||
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
|
||||
|
||||
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
|
||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||
if (hint)
|
||||
switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting)))
|
||||
{
|
||||
if (strcmp (hint, "none") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||
else if (strcmp (hint, "slight") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
else if (strcmp (hint, "medium") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||
else if (strcmp (hint, "full") == 0)
|
||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||
case 0:
|
||||
hintstyle = CAIRO_HINT_STYLE_NONE;
|
||||
break;
|
||||
case 1:
|
||||
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
|
||||
break;
|
||||
case 2:
|
||||
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
|
||||
break;
|
||||
case 3:
|
||||
hintstyle = CAIRO_HINT_STYLE_FULL;
|
||||
break;
|
||||
default:
|
||||
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
|
||||
break;
|
||||
}
|
||||
cairo_font_options_set_hint_style (fopt, hintstyle);
|
||||
|
||||
@@ -420,7 +422,7 @@ do_fontrendering (GtkWidget *do_widget)
|
||||
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
|
||||
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (hinting, "notify::selected", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
|
||||
|
||||
@@ -116,15 +116,18 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="hinting">
|
||||
<property name="active">0</property>
|
||||
<object class="GtkDropDown" id="hinting">
|
||||
<property name="valign">center</property>
|
||||
<items>
|
||||
<item translatable="yes" id="none">None</item>
|
||||
<item translatable="yes" id="slight">Slight</item>
|
||||
<item translatable="yes" id="medium">Medium</item>
|
||||
<item translatable="yes" id="full">Full</item>
|
||||
</items>
|
||||
<property name="model">
|
||||
<object class="GtkStringList">
|
||||
<items>
|
||||
<item translatable="yes">None</item>
|
||||
<item translatable="yes">Slight</item>
|
||||
<item translatable="yes">Medium</item>
|
||||
<item translatable="yes">Full</item>
|
||||
</items>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<layout>
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "gtkshadertoy.h"
|
||||
#include "gskshaderpaintable.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkWidget *demo_window = NULL;
|
||||
|
||||
static void
|
||||
@@ -146,7 +144,6 @@ make_shader_stack (const char *name,
|
||||
GtkTextBuffer *buffer;
|
||||
GBytes *bytes;
|
||||
GtkEventController *controller;
|
||||
GtkCssProvider *provider;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
stack = gtk_shader_stack_new ();
|
||||
@@ -237,12 +234,6 @@ make_shader_stack (const char *name,
|
||||
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
|
||||
g_object_set_data (G_OBJECT (button), "the-stack", stack);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref (provider);
|
||||
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
|
||||
gtk_widget_add_css_class (button, "small");
|
||||
@@ -276,11 +267,21 @@ make_shader_stack (const char *name,
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_gltransition_window (GtkWidget *do_widget)
|
||||
{
|
||||
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
|
||||
GdkPaintable *paintable;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
|
||||
@@ -335,6 +336,14 @@ create_gltransition_window (GtkWidget *do_widget)
|
||||
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
|
||||
1, 1, 1, 1);
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "script-names.h"
|
||||
#include "unicode-names.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
#define UCD_TYPE_ITEM (ucd_item_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
|
||||
|
||||
@@ -339,6 +337,15 @@ create_ucd_view (GtkWidget *label)
|
||||
|
||||
static GtkWidget *window;
|
||||
|
||||
static void
|
||||
remove_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_listview_ucd (GtkWidget *do_widget)
|
||||
{
|
||||
@@ -361,7 +368,7 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
gtk_widget_add_css_class (label, "enormous");
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
||||
@@ -371,6 +378,8 @@ do_listview_ucd (GtkWidget *do_widget)
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
|
||||
gtk_box_prepend (GTK_BOX (box), sw);
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "config.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/* Create an object for the pegs that get moved around in the game.
|
||||
*
|
||||
@@ -361,6 +360,15 @@ drop_drop (GtkDropTarget *target,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
remove_provider (gpointer data)
|
||||
{
|
||||
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
|
||||
|
||||
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
|
||||
g_object_unref (provider);
|
||||
}
|
||||
|
||||
static void
|
||||
create_board (GtkWidget *window)
|
||||
{
|
||||
@@ -377,6 +385,9 @@ create_board (GtkWidget *window)
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
|
||||
@@ -395,9 +406,6 @@ create_board (GtkWidget *window)
|
||||
continue;
|
||||
|
||||
image = gtk_image_new ();
|
||||
gtk_style_context_add_provider (gtk_widget_get_style_context (image),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
800);
|
||||
gtk_widget_add_css_class (image, "solitaire-field");
|
||||
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
||||
if (x != 3 || y != 3)
|
||||
@@ -441,7 +449,7 @@ create_board (GtkWidget *window)
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (provider);
|
||||
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -16,7 +16,6 @@ enum {
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
static void
|
||||
pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||
GdkSnapshot *snapshot,
|
||||
@@ -37,7 +36,6 @@ pixbuf_paintable_snapshot (GdkPaintable *paintable,
|
||||
|
||||
g_object_unref (texture);
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
static int
|
||||
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
|
||||
|
||||
@@ -16,26 +16,6 @@
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
/* Convenience function to create a combo box holding a number of strings
|
||||
*/
|
||||
GtkWidget *
|
||||
create_combo_box (const char **strings)
|
||||
{
|
||||
GtkWidget *combo_box;
|
||||
const char **str;
|
||||
|
||||
combo_box = gtk_combo_box_text_new ();
|
||||
|
||||
for (str = strings; *str; str++)
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), *str);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
|
||||
|
||||
return combo_box;
|
||||
}
|
||||
|
||||
static void
|
||||
add_row (GtkGrid *table,
|
||||
int row,
|
||||
@@ -43,7 +23,7 @@ add_row (GtkGrid *table,
|
||||
const char *label_text,
|
||||
const char **options)
|
||||
{
|
||||
GtkWidget *combo_box;
|
||||
GtkWidget *dropdown;
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new_with_mnemonic (label_text);
|
||||
@@ -52,12 +32,12 @@ add_row (GtkGrid *table,
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_grid_attach (table, label, 0, row, 1, 1);
|
||||
|
||||
combo_box = create_combo_box (options);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
|
||||
gtk_widget_set_halign (combo_box, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (combo_box, GTK_ALIGN_BASELINE);
|
||||
gtk_size_group_add_widget (size_group, combo_box);
|
||||
gtk_grid_attach (table, combo_box, 1, row, 1, 1);
|
||||
dropdown = gtk_drop_down_new_from_strings (options);
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dropdown);
|
||||
gtk_widget_set_halign (dropdown, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (dropdown, GTK_ALIGN_BASELINE);
|
||||
gtk_size_group_add_widget (size_group, dropdown);
|
||||
gtk_grid_attach (table, dropdown, 1, row, 1, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <stdlib.h> /* for exit() */
|
||||
#include "paintable.h"
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void easter_egg_callback (GtkWidget *button, gpointer data);
|
||||
|
||||
@@ -431,11 +430,11 @@ attach_widgets (GtkTextView *text_view)
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
widget = gtk_combo_box_text_new ();
|
||||
const char *options[] = {
|
||||
"Option 1", "Option 2", "Option 3", NULL
|
||||
};
|
||||
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 1");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 2");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 3");
|
||||
widget = gtk_drop_down_new_from_strings (options);
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkApplication parent_instance;
|
||||
@@ -352,7 +350,8 @@ quit_activated (GSimpleAction *action,
|
||||
}
|
||||
|
||||
static void
|
||||
combo_changed (GtkComboBox *combo,
|
||||
combo_changed (GtkDropDown *combo,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkDialog *dialog = user_data;
|
||||
@@ -361,7 +360,7 @@ combo_changed (GtkComboBox *combo,
|
||||
char **accels;
|
||||
char *str;
|
||||
|
||||
action = gtk_combo_box_get_active_id (combo);
|
||||
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
|
||||
|
||||
if (!action)
|
||||
return;
|
||||
@@ -390,7 +389,7 @@ response (GtkDialog *dialog,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkEntry *entry = g_object_get_data (user_data, "entry");
|
||||
GtkComboBox *combo = g_object_get_data (user_data, "combo");
|
||||
GtkDropDown *combo = g_object_get_data (user_data, "combo");
|
||||
const char *action;
|
||||
const char *str;
|
||||
char **accels;
|
||||
@@ -401,7 +400,7 @@ response (GtkDialog *dialog,
|
||||
return;
|
||||
}
|
||||
|
||||
action = gtk_combo_box_get_active_id (combo);
|
||||
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
|
||||
|
||||
if (!action)
|
||||
return;
|
||||
@@ -426,6 +425,7 @@ edit_accels (GSimpleAction *action,
|
||||
char **actions;
|
||||
GtkWidget *dialog;
|
||||
int i;
|
||||
GtkStringList *strings;
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Accelerators",
|
||||
NULL,
|
||||
@@ -437,7 +437,8 @@ edit_accels (GSimpleAction *action,
|
||||
gtk_window_set_application (GTK_WINDOW (dialog), app);
|
||||
actions = gtk_application_list_action_descriptions (app);
|
||||
|
||||
combo = gtk_combo_box_text_new ();
|
||||
strings = gtk_string_list_new (NULL);
|
||||
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
|
||||
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
|
||||
"margin-top", 10,
|
||||
"margin-bottom", 10,
|
||||
@@ -448,8 +449,8 @@ edit_accels (GSimpleAction *action,
|
||||
|
||||
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), combo);
|
||||
for (i = 0; actions[i]; i++)
|
||||
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), actions[i], actions[i]);
|
||||
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed), dialog);
|
||||
gtk_string_list_append (strings, actions[i]);
|
||||
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
|
||||
|
||||
entry = gtk_entry_new ();
|
||||
gtk_widget_set_hexpand (entry, TRUE);
|
||||
@@ -460,7 +461,7 @@ edit_accels (GSimpleAction *action,
|
||||
g_object_set_data (G_OBJECT (dialog), "combo", combo);
|
||||
g_object_set_data (G_OBJECT (dialog), "entry", entry);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
@@ -436,6 +436,7 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
|
||||
completion->inline_selection = FALSE;
|
||||
|
||||
completion->filter_model = NULL;
|
||||
completion->insert_text_signal_group = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1384,13 +1385,12 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
||||
{
|
||||
int len;
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
if (completion->changed_id > 0)
|
||||
g_signal_handler_block (text, completion->changed_id);
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_block (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_block (completion->insert_text_signal_group);
|
||||
|
||||
gtk_editable_set_text (GTK_EDITABLE (completion->entry), new_text);
|
||||
|
||||
@@ -1400,8 +1400,8 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
||||
if (completion->changed_id > 0)
|
||||
g_signal_handler_unblock (text, completion->changed_id);
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_unblock (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_unblock (completion->insert_text_signal_group);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -1440,11 +1440,9 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
|
||||
|
||||
gboolean done;
|
||||
char *prefix;
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_block (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_block (completion->insert_text_signal_group);
|
||||
|
||||
prefix = gtk_entry_completion_compute_prefix (completion,
|
||||
gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
|
||||
@@ -1456,8 +1454,8 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
|
||||
g_free (prefix);
|
||||
}
|
||||
|
||||
if (completion->insert_text_id > 0)
|
||||
g_signal_handler_unblock (buffer, completion->insert_text_id);
|
||||
if (completion->insert_text_signal_group != NULL)
|
||||
g_signal_group_unblock (completion->insert_text_signal_group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2098,7 +2096,6 @@ connect_completion_signals (GtkEntryCompletion *completion)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
controller = completion->entry_key_controller = gtk_event_controller_key_new ();
|
||||
gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
|
||||
@@ -2113,8 +2110,10 @@ connect_completion_signals (GtkEntryCompletion *completion)
|
||||
completion->changed_id =
|
||||
g_signal_connect (text, "changed", G_CALLBACK (gtk_entry_completion_changed), completion);
|
||||
|
||||
completion->insert_text_id =
|
||||
g_signal_connect (buffer, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
|
||||
completion->insert_text_signal_group = g_signal_group_new (GTK_TYPE_ENTRY_BUFFER);
|
||||
g_signal_group_connect (completion->insert_text_signal_group, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
|
||||
g_object_bind_property (text, "buffer", completion->insert_text_signal_group, "target", G_BINDING_SYNC_CREATE);
|
||||
|
||||
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
|
||||
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
|
||||
}
|
||||
@@ -2123,7 +2122,6 @@ static void
|
||||
disconnect_completion_signals (GtkEntryCompletion *completion)
|
||||
{
|
||||
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
|
||||
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
|
||||
|
||||
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_key_controller);
|
||||
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_focus_controller);
|
||||
@@ -2134,12 +2132,9 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
|
||||
g_signal_handler_disconnect (text, completion->changed_id);
|
||||
completion->changed_id = 0;
|
||||
}
|
||||
if (completion->insert_text_id > 0 &&
|
||||
g_signal_handler_is_connected (buffer, completion->insert_text_id))
|
||||
{
|
||||
g_signal_handler_disconnect (buffer, completion->insert_text_id);
|
||||
completion->insert_text_id = 0;
|
||||
}
|
||||
|
||||
g_clear_object (&completion->insert_text_signal_group);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (clear_completion_callback), completion);
|
||||
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (accept_completion_callback), completion);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@
|
||||
#include <gtk/gtkcenterlayout.h>
|
||||
#include <gtk/gtkcheckbutton.h>
|
||||
#include <gtk/gtkcolorbutton.h>
|
||||
#include <gtk/gtkcolorchoice.h>
|
||||
#include <gtk/gtkcolorchoicebutton.h>
|
||||
#include <gtk/gtkcolorchooser.h>
|
||||
#include <gtk/gtkcolorchooserdialog.h>
|
||||
#include <gtk/gtkcolorchooserwidget.h>
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gsettings-mapping.h"
|
||||
#include "gtkdebug.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -846,9 +848,15 @@ gtk_action_muxer_activate_action (GtkActionMuxer *muxer,
|
||||
if (!_gtk_bitmask_get (muxer->widget_actions_disabled, position))
|
||||
{
|
||||
if (action->activate)
|
||||
action->activate (muxer->widget, action->name, parameter);
|
||||
{
|
||||
GTK_DEBUG (ACTIONS, "%s: activate action", action->name);
|
||||
action->activate (muxer->widget, action->name, parameter);
|
||||
}
|
||||
else if (action->pspec)
|
||||
prop_action_activate (muxer->widget, action, parameter);
|
||||
{
|
||||
GTK_DEBUG (ACTIONS, "%s: activate prop action", action->pspec->name);
|
||||
prop_action_activate (muxer->widget, action, parameter);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
195
gtk/gtkcolorchoice.c
Normal file
195
gtk/gtkcolorchoice.c
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcolorchoice.h"
|
||||
#include "gtkcolorchooserwindowprivate.h"
|
||||
#include "gtkcolorchooser.h"
|
||||
#include "gtkbutton.h"
|
||||
|
||||
/* {{{ GObject implementation */
|
||||
|
||||
struct _GtkColorChoice
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkWindow *parent;
|
||||
char *title;
|
||||
gboolean use_alpha;
|
||||
|
||||
GTask *task;
|
||||
GtkColorChooserWindow *window;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkColorChoice, gtk_color_choice, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_color_choice_init (GtkColorChoice *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_finalize (GObject *object)
|
||||
{
|
||||
GtkColorChoice *self = GTK_COLOR_CHOICE (object);
|
||||
|
||||
g_assert (self->task == NULL);
|
||||
g_assert (self->window == NULL);
|
||||
|
||||
g_free (self->title);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_choice_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_class_init (GtkColorChoiceClass *class)
|
||||
{
|
||||
G_OBJECT_CLASS (class)->finalize = gtk_color_choice_finalize;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
/* {{{ Constructor */
|
||||
|
||||
GtkColorChoice *
|
||||
gtk_color_choice_new (GtkWindow *parent,
|
||||
const char *title,
|
||||
gboolean use_alpha)
|
||||
{
|
||||
GtkColorChoice *self;
|
||||
|
||||
self = g_object_new (GTK_TYPE_COLOR_CHOICE, NULL);
|
||||
|
||||
self->parent = parent;
|
||||
self->title = g_strdup (title);
|
||||
self->use_alpha = use_alpha;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Async API */
|
||||
|
||||
enum
|
||||
{
|
||||
RESPONSE_OK,
|
||||
RESPONSE_CANCEL
|
||||
};
|
||||
|
||||
static void response_cb (GtkColorChoice *self,
|
||||
int response);
|
||||
|
||||
static void
|
||||
cancelled_cb (GCancellable *cancellable,
|
||||
GtkColorChoice *self)
|
||||
{
|
||||
response_cb (self, RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
static void
|
||||
response_cb (GtkColorChoice *self,
|
||||
int response)
|
||||
{
|
||||
GCancellable *cancellable;
|
||||
|
||||
g_assert (self->window != NULL);
|
||||
g_assert (self->task != NULL);
|
||||
|
||||
cancellable = g_task_get_cancellable (self->task);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, self);
|
||||
|
||||
if (response == RESPONSE_OK)
|
||||
{
|
||||
GdkRGBA color;
|
||||
|
||||
gtk_color_chooser_window_save_color (GTK_COLOR_CHOOSER_WINDOW (self->window));
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->window), &color);
|
||||
g_task_return_pointer (self->task, gdk_rgba_copy (&color), (GDestroyNotify) gdk_rgba_free);
|
||||
}
|
||||
else
|
||||
g_task_return_new_error (self->task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
|
||||
|
||||
g_clear_pointer ((GtkWindow **)&self->window, gtk_window_destroy);
|
||||
g_clear_object (&self->task);
|
||||
}
|
||||
|
||||
static void
|
||||
ok_button_clicked (GtkButton *button,
|
||||
GtkColorChoice *self)
|
||||
{
|
||||
response_cb (self, RESPONSE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_button_clicked (GtkButton *button,
|
||||
GtkColorChoice *self)
|
||||
{
|
||||
response_cb (self, RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_color_choice_choose (GtkColorChoice *self,
|
||||
const GdkRGBA *initial_color,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkColorChooserWindow *window;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_CHOICE (self));
|
||||
|
||||
window = GTK_COLOR_CHOOSER_WINDOW (gtk_color_chooser_window_new (self->title, self->parent));
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (window), self->use_alpha);
|
||||
if (initial_color)
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (window), initial_color);
|
||||
|
||||
if (cancellable)
|
||||
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), self);
|
||||
|
||||
g_signal_connect (gtk_color_chooser_window_get_ok_button (window), "clicked",
|
||||
G_CALLBACK (ok_button_clicked), self);
|
||||
g_signal_connect (gtk_color_chooser_window_get_cancel_button (window), "clicked",
|
||||
G_CALLBACK (cancel_button_clicked), self);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, gtk_color_choice_choose);
|
||||
|
||||
self->window = window;
|
||||
self->task = task;
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
}
|
||||
|
||||
GdkRGBA *
|
||||
gtk_color_choice_choose_finish (GtkColorChoice *self,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
52
gtk/gtkcolorchoice.h
Normal file
52
gtk/gtkcolorchoice.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 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 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COLOR_CHOICE (gtk_color_choice_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkColorChoice, gtk_color_choice, GTK, COLOR_CHOICE, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkColorChoice * gtk_color_choice_new (GtkWindow *parent,
|
||||
const char *title,
|
||||
gboolean use_alpha);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_choice_choose (GtkColorChoice *choice,
|
||||
const GdkRGBA *initial_color,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GdkRGBA * gtk_color_choice_choose_finish (GtkColorChoice *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
409
gtk/gtkcolorchoicebutton.c
Normal file
409
gtk/gtkcolorchoicebutton.c
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcolorchoicebutton.h"
|
||||
#include "gtkcolorchoice.h"
|
||||
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkcolorswatchprivate.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkdroptarget.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
//#include "gtkmain.h"
|
||||
#include "gtkprivate.h"
|
||||
//#include "gtksnapshot.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
|
||||
static gboolean drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorChoiceButton *self);
|
||||
static GdkContentProvider *
|
||||
drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorChoiceButton *self);
|
||||
static void button_clicked (GtkColorChoiceButton *self);
|
||||
|
||||
/* {{{ GObject implementation */
|
||||
|
||||
struct _GtkColorChoiceButton
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GdkRGBA color;
|
||||
gboolean use_alpha;
|
||||
char *title;
|
||||
|
||||
GtkWidget *button;
|
||||
GtkWidget *swatch;
|
||||
GtkColorChoice *choice;
|
||||
};
|
||||
|
||||
/* Properties */
|
||||
enum
|
||||
{
|
||||
PROP_COLOR = 1,
|
||||
PROP_USE_ALPHA,
|
||||
PROP_TITLE,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *properties[NUM_PROPERTIES];
|
||||
|
||||
G_DEFINE_TYPE (GtkColorChoiceButton, gtk_color_choice_button, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
gtk_color_choice_button_init (GtkColorChoiceButton *self)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoRectangle rect;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
self->use_alpha = TRUE;
|
||||
self->title = g_strdup ("");
|
||||
|
||||
self->button = gtk_button_new ();
|
||||
g_signal_connect_swapped (self->button, "clicked", G_CALLBACK (button_clicked), self);
|
||||
gtk_widget_set_parent (self->button, GTK_WIDGET (self));
|
||||
|
||||
self->swatch = g_object_new (GTK_TYPE_COLOR_SWATCH,
|
||||
"accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
|
||||
"selectable", FALSE,
|
||||
"has-menu", FALSE,
|
||||
"can-drag", FALSE,
|
||||
NULL);
|
||||
gtk_widget_set_can_focus (self->swatch, FALSE);
|
||||
gtk_widget_remove_css_class (self->swatch, "activatable");
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), "Black");
|
||||
pango_layout_get_pixel_extents (layout, NULL, &rect);
|
||||
g_object_unref (layout);
|
||||
|
||||
gtk_widget_set_size_request (self->swatch, rect.width, rect.height);
|
||||
|
||||
gtk_button_set_child (GTK_BUTTON (self->button), self->swatch);
|
||||
|
||||
dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (drop), self);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self->button), GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (drag_prepare), self);
|
||||
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (source),
|
||||
GTK_PHASE_CAPTURE);
|
||||
gtk_widget_add_controller (self->button, GTK_EVENT_CONTROLLER (source));
|
||||
gtk_widget_add_css_class (self->button, "color");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_button_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorChoiceButton *self = GTK_COLOR_CHOICE_BUTTON (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
gtk_color_choice_button_set_color (self, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
case PROP_USE_ALPHA:
|
||||
gtk_color_choice_button_set_use_alpha (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_TITLE:
|
||||
gtk_color_choice_button_set_title (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_button_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkColorChoiceButton *self = GTK_COLOR_CHOICE_BUTTON (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
g_value_set_boxed (value, &self->color);
|
||||
break;
|
||||
|
||||
case PROP_USE_ALPHA:
|
||||
g_value_set_boolean (value, self->use_alpha);
|
||||
break;
|
||||
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, self->title);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_button_dispose (GObject *object)
|
||||
{
|
||||
GtkColorChoiceButton *self = GTK_COLOR_CHOICE_BUTTON (object);
|
||||
|
||||
g_clear_pointer (&self->button, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_choice_button_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_button_finalize (GObject *object)
|
||||
{
|
||||
GtkColorChoiceButton *self = GTK_COLOR_CHOICE_BUTTON (object);
|
||||
|
||||
g_free (self->title);
|
||||
|
||||
G_OBJECT_CLASS (gtk_color_choice_button_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_choice_button_class_init (GtkColorChoiceButtonClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
object_class->get_property = gtk_color_choice_button_get_property;
|
||||
object_class->set_property = gtk_color_choice_button_set_property;
|
||||
object_class->dispose = gtk_color_choice_button_dispose;
|
||||
object_class->finalize = gtk_color_choice_button_finalize;
|
||||
|
||||
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
||||
widget_class->focus = gtk_widget_focus_child;
|
||||
|
||||
properties[PROP_COLOR] =
|
||||
g_param_spec_boxed ("color", NULL, NULL,
|
||||
GDK_TYPE_RGBA,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_USE_ALPHA] =
|
||||
g_param_spec_boolean ("use-alpha", NULL, NULL,
|
||||
TRUE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_TITLE] =
|
||||
g_param_spec_string ("title", NULL, NULL,
|
||||
"",
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
gtk_widget_class_set_css_name (widget_class, "colorbutton");
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Private API, callbacks */
|
||||
|
||||
static guint
|
||||
scale_round (double value,
|
||||
double scale)
|
||||
{
|
||||
value = floor (value * scale + 0.5);
|
||||
value = CLAMP (value, 0, scale);
|
||||
return (guint)value;
|
||||
}
|
||||
|
||||
static char *
|
||||
accessible_color_name (const GdkRGBA *color)
|
||||
{
|
||||
if (color->alpha < 1.0)
|
||||
return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%, Alpha %d%%"),
|
||||
scale_round (color->red, 100),
|
||||
scale_round (color->green, 100),
|
||||
scale_round (color->blue, 100),
|
||||
scale_round (color->alpha, 100));
|
||||
else
|
||||
return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%"),
|
||||
scale_round (color->red, 100),
|
||||
scale_round (color->green, 100),
|
||||
scale_round (color->blue, 100));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorChoiceButton *self)
|
||||
{
|
||||
GdkRGBA *color = g_value_get_boxed (value);
|
||||
|
||||
gtk_color_choice_button_set_color (self, color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
drag_prepare (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
GtkColorChoiceButton *self)
|
||||
{
|
||||
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &self->color);
|
||||
}
|
||||
|
||||
static void
|
||||
color_chosen (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorChoice *choice = GTK_COLOR_CHOICE (source);
|
||||
GtkColorChoiceButton *self = data;
|
||||
GdkRGBA *color;
|
||||
GError *error = NULL;
|
||||
|
||||
color = gtk_color_choice_choose_finish (choice, result, &error);
|
||||
if (color)
|
||||
{
|
||||
gtk_color_choice_button_set_color (self, color);
|
||||
gdk_rgba_free (color);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
button_clicked (GtkColorChoiceButton *self)
|
||||
{
|
||||
GtkRoot *root;
|
||||
GtkWindow *parent = NULL;
|
||||
GtkColorChoice *choice;
|
||||
|
||||
root = gtk_widget_get_root (GTK_WIDGET (self));
|
||||
if (GTK_IS_WINDOW (root))
|
||||
parent = GTK_WINDOW (root);
|
||||
|
||||
choice = gtk_color_choice_new (parent, self->title, self->use_alpha);
|
||||
gtk_color_choice_choose (choice, &self->color, NULL, color_chosen, self);
|
||||
g_object_unref (choice);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Public API */
|
||||
/* {{{ Constructor */
|
||||
|
||||
GtkColorChoiceButton *
|
||||
gtk_color_choice_button_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_COLOR_CHOICE_BUTTON, NULL);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Setters and Getters */
|
||||
|
||||
void
|
||||
gtk_color_choice_button_set_color (GtkColorChoiceButton *self,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
char *text;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_CHOICE_BUTTON (self));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
if (gdk_rgba_equal (&self->color, color))
|
||||
return;
|
||||
|
||||
self->color = *color;
|
||||
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (self->swatch), color);
|
||||
|
||||
text = accessible_color_name (color);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (self->swatch),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, text,
|
||||
-1);
|
||||
g_free (text);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLOR]);
|
||||
}
|
||||
|
||||
const GdkRGBA *
|
||||
gtk_color_choice_button_get_color (GtkColorChoiceButton *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_CHOICE_BUTTON (self), NULL);
|
||||
|
||||
return &self->color;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_color_choice_button_set_use_alpha (GtkColorChoiceButton *self,
|
||||
gboolean use_alpha)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLOR_CHOICE_BUTTON (self));
|
||||
|
||||
if (self->use_alpha == use_alpha)
|
||||
return;
|
||||
|
||||
self->use_alpha = use_alpha;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USE_ALPHA]);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_color_choice_button_get_use_alpha (GtkColorChoiceButton *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_COLOR_CHOICE_BUTTON (self), TRUE);
|
||||
|
||||
return self->use_alpha;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_color_choice_button_set_title (GtkColorChoiceButton *self,
|
||||
const char *title)
|
||||
{
|
||||
char *new_title;
|
||||
|
||||
g_return_if_fail (GTK_IS_COLOR_CHOICE_BUTTON (self));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
||||
if (g_str_equal (self->title, title))
|
||||
return;
|
||||
|
||||
new_title = g_strdup (title);
|
||||
g_free (self->title);
|
||||
self->title = new_title;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
60
gtk/gtkcolorchoicebutton.h
Normal file
60
gtk/gtkcolorchoicebutton.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2022 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COLOR_CHOICE_BUTTON (gtk_color_choice_button_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
G_DECLARE_FINAL_TYPE (GtkColorChoiceButton, gtk_color_choice_button, GTK, COLOR_CHOICE_BUTTON, GtkWidget)
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkColorChoiceButton *
|
||||
gtk_color_choice_button_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_choice_button_set_color (GtkColorChoiceButton *self,
|
||||
const GdkRGBA *color);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const GdkRGBA * gtk_color_choice_button_get_color (GtkColorChoiceButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_choice_button_set_use_alpha (GtkColorChoiceButton *self,
|
||||
gboolean use_alpha);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
gboolean gtk_color_choice_button_get_use_alpha (GtkColorChoiceButton *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_color_choice_button_set_title (GtkColorChoiceButton *self,
|
||||
const char *title);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_color_choice_button_get_title (GtkColorChoiceButton *self);
|
||||
|
||||
G_END_DECLS
|
||||
278
gtk/gtkcolorchooserwindow.c
Normal file
278
gtk/gtkcolorchooserwindow.c
Normal file
@@ -0,0 +1,278 @@
|
||||
/* 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].
|
||||
*/
|
||||
|
||||
struct _GtkColorChooserWindow
|
||||
{
|
||||
GtkWindow parent_instance;
|
||||
|
||||
GtkWidget *chooser;
|
||||
GtkWidget *ok_button;
|
||||
GtkWidget *cancel_button;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_RGBA = 1,
|
||||
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 *self)
|
||||
{
|
||||
g_object_notify (G_OBJECT (self), pspec->name);
|
||||
}
|
||||
|
||||
static void
|
||||
color_activated_cb (GtkColorChooser *chooser,
|
||||
GdkRGBA *color,
|
||||
GtkColorChooserWindow *window)
|
||||
{
|
||||
g_signal_emit_by_name (window->ok_button, "clicked");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_init (GtkColorChooserWindow *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
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 *self = GTK_COLOR_CHOOSER_WINDOW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RGBA:
|
||||
{
|
||||
GdkRGBA color;
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self), &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 (self->chooser)));
|
||||
break;
|
||||
case PROP_SHOW_EDITOR:
|
||||
{
|
||||
gboolean show_editor;
|
||||
g_object_get (self->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 *self = GTK_COLOR_CHOOSER_WINDOW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_RGBA:
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self), g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_USE_ALPHA:
|
||||
if (gtk_color_chooser_get_use_alpha (GTK_COLOR_CHOOSER (self->chooser)) != g_value_get_boolean (value))
|
||||
{
|
||||
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (self->chooser), g_value_get_boolean (value));
|
||||
g_object_notify_by_pspec (object, pspec);
|
||||
}
|
||||
break;
|
||||
case PROP_SHOW_EDITOR:
|
||||
g_object_set (self->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 *self = GTK_COLOR_CHOOSER_WINDOW (object);
|
||||
|
||||
g_clear_pointer (&self->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));
|
||||
|
||||
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_child (widget_class, GtkColorChooserWindow, ok_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkColorChooserWindow, cancel_button);
|
||||
gtk_widget_class_bind_template_callback (widget_class, propagate_notify);
|
||||
gtk_widget_class_bind_template_callback (widget_class, color_activated_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_get_rgba (GtkColorChooser *chooser,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GtkColorChooserWindow *self = GTK_COLOR_CHOOSER_WINDOW (chooser);
|
||||
|
||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (self->chooser), color);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_set_rgba (GtkColorChooser *chooser,
|
||||
const GdkRGBA *color)
|
||||
{
|
||||
GtkColorChooserWindow *self = GTK_COLOR_CHOOSER_WINDOW (chooser);
|
||||
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->chooser), color);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_color_chooser_window_add_palette (GtkColorChooser *chooser,
|
||||
GtkOrientation orientation,
|
||||
int colors_per_line,
|
||||
int n_colors,
|
||||
GdkRGBA *colors)
|
||||
{
|
||||
GtkColorChooserWindow *self = GTK_COLOR_CHOOSER_WINDOW (chooser);
|
||||
|
||||
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (self->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;
|
||||
}
|
||||
|
||||
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,
|
||||
"modal", TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_color_chooser_window_save_color (GtkColorChooserWindow *self)
|
||||
{
|
||||
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 (self), &color);
|
||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self), &color);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_color_chooser_window_get_ok_button (GtkColorChooserWindow *self)
|
||||
{
|
||||
return self->ok_button;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_color_chooser_window_get_cancel_button (GtkColorChooserWindow *self)
|
||||
{
|
||||
return self->cancel_button;
|
||||
}
|
||||
|
||||
34
gtk/gtkcolorchooserwindowprivate.h
Normal file
34
gtk/gtkcolorchooserwindowprivate.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COLOR_CHOOSER_WINDOW (gtk_color_chooser_window_get_type ())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GtkColorChooserWindow, gtk_color_chooser_window, GTK, COLOR_CHOOSER_WINDOW, GtkWindow)
|
||||
|
||||
GtkWidget * gtk_color_chooser_window_new (const char *title,
|
||||
GtkWindow *parent);
|
||||
void gtk_color_chooser_window_save_color (GtkColorChooserWindow *self);
|
||||
GtkWidget *gtk_color_chooser_window_get_ok_button (GtkColorChooserWindow *self);
|
||||
GtkWidget *gtk_color_chooser_window_get_cancel_button (GtkColorChooserWindow *self);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "gtkcomposetable.h"
|
||||
#include "gtkimcontextsimple.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
|
||||
#define GTK_COMPOSE_TABLE_MAGIC "GtkComposeTable"
|
||||
|
||||
@@ -61,7 +61,8 @@ struct _GtkEntryCompletion
|
||||
|
||||
gulong completion_timeout;
|
||||
gulong changed_id;
|
||||
gulong insert_text_id;
|
||||
|
||||
GSignalGroup *insert_text_signal_group;
|
||||
|
||||
int current_selected;
|
||||
|
||||
|
||||
304
gtk/gtkfilechoosercell.c
Normal file
304
gtk/gtkfilechoosercell.c
Normal file
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Copyright © 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfilechoosercellprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkdragsource.h"
|
||||
#include "gtkgestureclick.h"
|
||||
#include "gtkgesturelongpress.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtklistitem.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkfilechooserwidgetprivate.h"
|
||||
|
||||
struct _GtkFileChooserCell
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GFileInfo *item;
|
||||
gboolean selected;
|
||||
guint position;
|
||||
|
||||
gboolean show_time;
|
||||
};
|
||||
|
||||
struct _GtkFileChooserCellClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK_TYPE_WIDGET)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_POSITION = 1,
|
||||
PROP_SELECTED,
|
||||
PROP_ITEM,
|
||||
PROP_SHOW_TIME,
|
||||
};
|
||||
|
||||
#define ICON_SIZE 16
|
||||
|
||||
static void
|
||||
popup_menu (GtkFileChooserCell *self,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (self);
|
||||
GtkSelectionModel *model;
|
||||
GtkWidget *impl;
|
||||
double xx, yy;
|
||||
|
||||
impl = gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_CHOOSER_WIDGET);
|
||||
|
||||
model = gtk_file_chooser_widget_get_selection_model (GTK_FILE_CHOOSER_WIDGET (impl));
|
||||
gtk_selection_model_select_item (model, self->position, TRUE);
|
||||
|
||||
gtk_widget_translate_coordinates (widget, GTK_WIDGET (impl),
|
||||
x, y, &xx, &yy);
|
||||
|
||||
gtk_widget_activate_action (widget, "item.popup-file-list-menu",
|
||||
"(udd)", self->position, xx, yy);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_cell_clicked (GtkEventController *controller,
|
||||
int n_press,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
popup_menu (self, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_cell_long_pressed (GtkEventController *controller,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
GtkWidget *widget = gtk_event_controller_get_widget (controller);
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
|
||||
|
||||
gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED);
|
||||
popup_menu (self, x, y);
|
||||
}
|
||||
|
||||
static GdkContentProvider *
|
||||
drag_prepare_cb (GtkDragSource *source,
|
||||
double x,
|
||||
double y,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkContentProvider *provider;
|
||||
GSList *selection;
|
||||
GtkFileChooserWidget *impl;
|
||||
GtkIconTheme *icon_theme;
|
||||
GIcon *icon;
|
||||
int scale;
|
||||
GtkIconPaintable *paintable;
|
||||
GtkFileChooserCell *self = user_data;
|
||||
|
||||
impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (self),
|
||||
GTK_TYPE_FILE_CHOOSER_WIDGET));
|
||||
|
||||
if (!self->selected)
|
||||
{
|
||||
gtk_selection_model_select_item (gtk_file_chooser_widget_get_selection_model (impl),
|
||||
self->position, TRUE);
|
||||
}
|
||||
|
||||
selection = gtk_file_chooser_widget_get_selected_files (impl);
|
||||
if (!selection)
|
||||
return NULL;
|
||||
|
||||
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
|
||||
|
||||
icon = _gtk_file_info_get_icon (self->item, ICON_SIZE, scale, icon_theme);
|
||||
|
||||
paintable = gtk_icon_theme_lookup_by_gicon (icon_theme,icon, ICON_SIZE, scale, GTK_TEXT_DIR_NONE, 0);
|
||||
|
||||
gtk_drag_source_set_icon (source, GDK_PAINTABLE (paintable), x, y);
|
||||
|
||||
provider = gdk_content_provider_new_typed (GDK_TYPE_FILE_LIST, selection);
|
||||
g_slist_free_full (selection, g_object_unref);
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (icon);
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_realize (GtkWidget *widget)
|
||||
{
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
|
||||
GtkFileChooserWidget *impl;
|
||||
|
||||
impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (self),
|
||||
GTK_TYPE_FILE_CHOOSER_WIDGET));
|
||||
|
||||
g_object_bind_property (impl, "show-time", self, "show-time", G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_init (GtkFileChooserCell *self)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkDragSource *drag_source;
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (file_chooser_cell_clicked), NULL);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
|
||||
|
||||
gesture = gtk_gesture_long_press_new ();
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
|
||||
g_signal_connect (gesture, "pressed", G_CALLBACK (file_chooser_cell_long_pressed), NULL);
|
||||
|
||||
drag_source = gtk_drag_source_new ();
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drag_source));
|
||||
g_signal_connect (drag_source, "prepare", G_CALLBACK (drag_prepare_cb), self);
|
||||
|
||||
g_signal_connect (self, "realize", G_CALLBACK (gtk_file_chooser_cell_realize), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_dispose (GObject *object)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))))
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
G_OBJECT_CLASS (gtk_file_chooser_cell_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_POSITION:
|
||||
self->position = g_value_get_uint (value);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED:
|
||||
self->selected = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_ITEM:
|
||||
self->item = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_SHOW_TIME:
|
||||
self->show_time = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_POSITION:
|
||||
g_value_set_uint (value, self->position);
|
||||
break;
|
||||
|
||||
case PROP_SELECTED:
|
||||
g_value_set_boolean (value, self->selected);
|
||||
break;
|
||||
|
||||
case PROP_ITEM:
|
||||
g_value_set_object (value, self->item);
|
||||
break;
|
||||
|
||||
case PROP_SHOW_TIME:
|
||||
g_value_set_boolean (value, self->show_time);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_file_chooser_cell_class_init (GtkFileChooserCellClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = gtk_file_chooser_cell_dispose;
|
||||
object_class->set_property = gtk_file_chooser_cell_set_property;
|
||||
object_class->get_property = gtk_file_chooser_cell_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_POSITION,
|
||||
g_param_spec_uint ("position", NULL, NULL,
|
||||
0, G_MAXUINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SELECTED,
|
||||
g_param_spec_boolean ("selected", NULL, NULL,
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ITEM,
|
||||
g_param_spec_object ("item", NULL, NULL,
|
||||
G_TYPE_FILE_INFO,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SHOW_TIME,
|
||||
g_param_spec_boolean ("show-time", NULL, NULL,
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("filelistcell"));
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
|
||||
GtkFileChooserCell *
|
||||
gtk_file_chooser_cell_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_FILE_CHOOSER_CELL, NULL);
|
||||
}
|
||||
37
gtk/gtkfilechoosercellprivate.h
Normal file
37
gtk/gtkfilechoosercellprivate.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright © 2022 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Matthias Clasen
|
||||
*/
|
||||
|
||||
#ifndef __GTK_FILE_CHOOSER_CELL_PRIVATE_H__
|
||||
#define __GTK_FILE_CHOOSER_CELL_PRIVATE_H__
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <gtk/gtkexpression.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FILE_CHOOSER_CELL (gtk_file_chooser_cell_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK, FILE_CHOOSER_CELL, GtkWidget)
|
||||
|
||||
GtkFileChooserCell * gtk_file_chooser_cell_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_CELL_PRIVATE_H__ */
|
||||
@@ -60,7 +60,8 @@ struct _GtkFileChooserEntry
|
||||
char *dir_part;
|
||||
char *file_part;
|
||||
|
||||
GtkTreeModel *completion_store;
|
||||
GtkTreeStore *completion_store;
|
||||
GtkFileSystemModel *model;
|
||||
GtkFileFilter *current_filter;
|
||||
|
||||
guint current_folder_loaded : 1;
|
||||
@@ -71,6 +72,7 @@ struct _GtkFileChooserEntry
|
||||
|
||||
enum
|
||||
{
|
||||
FILE_INFO_COLUMN,
|
||||
DISPLAY_NAME_COLUMN,
|
||||
FULL_PATH_COLUMN,
|
||||
N_COLUMNS
|
||||
@@ -197,20 +199,21 @@ match_func (GtkEntryCompletion *compl,
|
||||
* current file filter (e.g. just jpg files) here. */
|
||||
if (chooser_entry->current_filter != NULL)
|
||||
{
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
|
||||
file = _gtk_file_system_model_get_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
iter);
|
||||
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
iter);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
|
||||
iter,
|
||||
FILE_INFO_COLUMN, &info,
|
||||
-1);
|
||||
|
||||
g_assert (info != NULL);
|
||||
g_object_unref (info);
|
||||
|
||||
/* We always allow navigating into subfolders, so don't ever filter directories */
|
||||
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
|
||||
return TRUE;
|
||||
|
||||
if (!g_file_info_has_attribute (info, "standard::file"))
|
||||
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
|
||||
g_assert (g_file_info_has_attribute (info, "standard::file"));
|
||||
|
||||
return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
|
||||
}
|
||||
@@ -428,7 +431,7 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
chooser_entry->complete_on_load = FALSE;
|
||||
|
||||
if (chooser_entry->completion_store)
|
||||
if (chooser_entry->model)
|
||||
{
|
||||
char *completion, *text;
|
||||
gsize completion_len, text_len;
|
||||
@@ -539,77 +542,93 @@ update_inline_completion (GtkFileChooserEntry *chooser_entry)
|
||||
static void
|
||||
discard_completion_store (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
if (!chooser_entry->completion_store)
|
||||
if (!chooser_entry->model)
|
||||
return;
|
||||
|
||||
g_assert (chooser_entry->completion_store != NULL);
|
||||
|
||||
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);
|
||||
update_inline_completion (chooser_entry);
|
||||
g_object_unref (chooser_entry->completion_store);
|
||||
chooser_entry->completion_store = NULL;
|
||||
g_clear_object (&chooser_entry->completion_store);
|
||||
g_clear_object (&chooser_entry->model);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
completion_store_set (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
GFileInfo *info,
|
||||
int column,
|
||||
GValue *value,
|
||||
gpointer data)
|
||||
static void
|
||||
model_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
GtkFileChooserEntry *self)
|
||||
{
|
||||
GtkFileChooserEntry *chooser_entry = data;
|
||||
|
||||
const char *prefix = "";
|
||||
const char *suffix = "";
|
||||
|
||||
switch (column)
|
||||
if (removed > 0)
|
||||
{
|
||||
case FULL_PATH_COLUMN:
|
||||
prefix = chooser_entry->dir_part;
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case DISPLAY_NAME_COLUMN:
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->completion_store),
|
||||
&iter,
|
||||
NULL,
|
||||
position))
|
||||
{
|
||||
while (removed--)
|
||||
gtk_tree_store_remove (self->completion_store, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
while (added-- > 0)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GFileInfo *info;
|
||||
const char *suffix = NULL;
|
||||
char *full_path;
|
||||
char *display_name;
|
||||
|
||||
info = g_list_model_get_item (model, position);
|
||||
|
||||
if (_gtk_file_info_consider_as_directory (info))
|
||||
suffix = G_DIR_SEPARATOR_S;
|
||||
|
||||
g_value_take_string (value,
|
||||
g_strconcat (prefix,
|
||||
g_file_info_get_display_name (info),
|
||||
suffix,
|
||||
NULL));
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
display_name = g_strconcat (g_file_info_get_display_name (info), suffix, NULL);
|
||||
full_path = g_strconcat (self->dir_part, display_name, NULL);
|
||||
|
||||
return TRUE;
|
||||
gtk_tree_store_insert_with_values (self->completion_store,
|
||||
&iter, NULL,
|
||||
position,
|
||||
FILE_INFO_COLUMN, info,
|
||||
FULL_PATH_COLUMN, full_path,
|
||||
DISPLAY_NAME_COLUMN, display_name,
|
||||
-1);
|
||||
|
||||
g_clear_object (&info);
|
||||
|
||||
position++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fills the completion store from the contents of the current folder */
|
||||
static void
|
||||
populate_completion_store (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
chooser_entry->completion_store = GTK_TREE_MODEL (
|
||||
chooser_entry->completion_store = gtk_tree_store_new (N_COLUMNS,
|
||||
G_TYPE_FILE_INFO,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
chooser_entry->model =
|
||||
_gtk_file_system_model_new_for_directory (chooser_entry->current_folder_file,
|
||||
"standard::name,standard::display-name,standard::type,"
|
||||
"standard::content-type",
|
||||
completion_store_set,
|
||||
chooser_entry,
|
||||
N_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING));
|
||||
g_signal_connect (chooser_entry->completion_store, "finished-loading",
|
||||
"standard::content-type");
|
||||
g_signal_connect (chooser_entry->model, "items-changed",
|
||||
G_CALLBACK (model_items_changed_cb), chooser_entry);
|
||||
g_signal_connect (chooser_entry->model, "finished-loading",
|
||||
G_CALLBACK (finished_loading_cb), chooser_entry);
|
||||
|
||||
_gtk_file_system_model_set_filter_folders (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
TRUE);
|
||||
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
_gtk_file_system_model_set_filter_folders (chooser_entry->model, TRUE);
|
||||
_gtk_file_system_model_set_show_files (chooser_entry->model,
|
||||
chooser_entry->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
chooser_entry->action == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store),
|
||||
DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
|
||||
|
||||
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
|
||||
chooser_entry->completion_store);
|
||||
GTK_TREE_MODEL (chooser_entry->completion_store));
|
||||
}
|
||||
|
||||
/* Callback when the current folder finishes loading */
|
||||
@@ -637,7 +656,7 @@ finished_loading_cb (GtkFileSystemModel *model,
|
||||
completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry));
|
||||
update_inline_completion (chooser_entry);
|
||||
|
||||
if (gtk_widget_has_focus (GTK_WIDGET (chooser_entry)))
|
||||
if (gtk_widget_has_focus (GTK_WIDGET (gtk_entry_get_text_widget (GTK_ENTRY (chooser_entry)))))
|
||||
{
|
||||
gtk_entry_completion_complete (completion);
|
||||
gtk_entry_completion_insert_prefix (completion);
|
||||
@@ -658,11 +677,7 @@ set_completion_folder (GtkFileChooserEntry *chooser_entry,
|
||||
return;
|
||||
}
|
||||
|
||||
if (chooser_entry->current_folder_file)
|
||||
{
|
||||
g_object_unref (chooser_entry->current_folder_file);
|
||||
chooser_entry->current_folder_file = NULL;
|
||||
}
|
||||
g_clear_object (&chooser_entry->current_folder_file);
|
||||
|
||||
g_free (chooser_entry->dir_part);
|
||||
chooser_entry->dir_part = g_strdup (dir_part);
|
||||
@@ -710,7 +725,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
|
||||
|
||||
g_free (dir_part);
|
||||
|
||||
if (chooser_entry->completion_store &&
|
||||
if (chooser_entry->model &&
|
||||
(g_strcmp0 (old_file_part, chooser_entry->file_part) != 0))
|
||||
{
|
||||
GtkFileFilter *filter;
|
||||
@@ -720,8 +735,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
|
||||
pattern = g_strconcat (chooser_entry->file_part, "*", NULL);
|
||||
gtk_file_filter_add_pattern (filter, pattern);
|
||||
|
||||
_gtk_file_system_model_set_filter (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
filter);
|
||||
_gtk_file_system_model_set_filter (chooser_entry->model, filter);
|
||||
|
||||
g_free (pattern);
|
||||
g_object_unref (filter);
|
||||
@@ -940,8 +954,8 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
|
||||
break;
|
||||
}
|
||||
|
||||
if (chooser_entry->completion_store)
|
||||
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
if (chooser_entry->model)
|
||||
_gtk_file_system_model_set_show_files (chooser_entry->model,
|
||||
action == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||
action == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
|
||||
@@ -971,17 +985,14 @@ gboolean
|
||||
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
|
||||
GFile *file)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GFileInfo *info;
|
||||
|
||||
if (chooser_entry->completion_store == NULL ||
|
||||
!_gtk_file_system_model_get_iter_for_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
&iter,
|
||||
file))
|
||||
if (chooser_entry->model == NULL)
|
||||
return FALSE;
|
||||
|
||||
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
|
||||
&iter);
|
||||
info = _gtk_file_system_model_get_info_for_file (chooser_entry->model, file);
|
||||
if (!info)
|
||||
return FALSE;
|
||||
|
||||
return _gtk_file_info_consider_as_directory (info);
|
||||
}
|
||||
|
||||
@@ -479,3 +479,12 @@ _gtk_file_info_get_icon (GFileInfo *info,
|
||||
icon = g_themed_icon_new ("text-x-generic");
|
||||
return icon;
|
||||
}
|
||||
|
||||
GFile *
|
||||
_gtk_file_info_get_file (GFileInfo *info)
|
||||
{
|
||||
g_assert (G_IS_FILE_INFO (info));
|
||||
g_assert (g_file_info_has_attribute (info, "standard::file"));
|
||||
|
||||
return G_FILE (g_file_info_get_attribute_object (info, "standard::file"));
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ GIcon * _gtk_file_info_get_icon (GFileInfo *info,
|
||||
int scale,
|
||||
GtkIconTheme *icon_theme);
|
||||
|
||||
GFile * _gtk_file_info_get_file (GFileInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include "gtkfilechooserwidget.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -36,6 +37,12 @@ gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *chooser);
|
||||
void
|
||||
gtk_file_chooser_widget_initial_focus (GtkFileChooserWidget *chooser);
|
||||
|
||||
GSList *
|
||||
gtk_file_chooser_widget_get_selected_files (GtkFileChooserWidget *impl);
|
||||
|
||||
GtkSelectionModel *
|
||||
gtk_file_chooser_widget_get_selection_model (GtkFileChooserWidget *chooser);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gtk/deprecated/gtktreemodel.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -33,39 +32,13 @@ typedef struct _GtkFileSystemModel GtkFileSystemModel;
|
||||
|
||||
GType _gtk_file_system_model_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef gboolean (*GtkFileSystemModelGetValue) (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
GFileInfo *info,
|
||||
int column,
|
||||
GValue *value,
|
||||
gpointer user_data);
|
||||
|
||||
GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystemModelGetValue get_func,
|
||||
gpointer get_data,
|
||||
guint n_columns,
|
||||
...);
|
||||
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile * dir,
|
||||
const char * attributes,
|
||||
GtkFileSystemModelGetValue get_func,
|
||||
gpointer get_data,
|
||||
guint n_columns,
|
||||
...);
|
||||
GtkFileSystemModel *_gtk_file_system_model_new (void);
|
||||
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile *dir,
|
||||
const char *attributes);
|
||||
GFile * _gtk_file_system_model_get_directory (GtkFileSystemModel *model);
|
||||
GCancellable * _gtk_file_system_model_get_cancellable (GtkFileSystemModel *model);
|
||||
gboolean _gtk_file_system_model_iter_is_visible (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean _gtk_file_system_model_iter_is_filtered_out (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
GFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean _gtk_file_system_model_get_iter_for_file(GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter,
|
||||
GFileInfo * _gtk_file_system_model_get_info_for_file(GtkFileSystemModel *model,
|
||||
GFile *file);
|
||||
GFile * _gtk_file_system_model_get_file (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
const GValue * _gtk_file_system_model_get_value (GtkFileSystemModel *model,
|
||||
GtkTreeIter * iter,
|
||||
int column);
|
||||
|
||||
void _gtk_file_system_model_add_and_query_file (GtkFileSystemModel *model,
|
||||
GFile *file,
|
||||
@@ -88,8 +61,6 @@ void _gtk_file_system_model_set_show_files (GtkFileSystemModel
|
||||
gboolean show_files);
|
||||
void _gtk_file_system_model_set_filter_folders (GtkFileSystemModel *model,
|
||||
gboolean show_folders);
|
||||
void _gtk_file_system_model_clear_cache (GtkFileSystemModel *model,
|
||||
int column);
|
||||
|
||||
void _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
|
||||
GtkFileFilter *filter);
|
||||
|
||||
255
gtk/gtkfilethumbnail.c
Normal file
255
gtk/gtkfilethumbnail.c
Normal file
@@ -0,0 +1,255 @@
|
||||
/* gtkfilethumbnail.c
|
||||
*
|
||||
* Copyright 2022 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkfilethumbnail.h"
|
||||
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkwidget.h"
|
||||
|
||||
#define ICON_SIZE 16
|
||||
|
||||
struct _GtkFileThumbnail
|
||||
{
|
||||
GtkWidget parent;
|
||||
|
||||
GtkWidget *image;
|
||||
|
||||
GCancellable *cancellable;
|
||||
GFileInfo *info;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidgetClass parent;
|
||||
} GtkFileThumbnailClass;
|
||||
|
||||
G_DEFINE_FINAL_TYPE (GtkFileThumbnail, _gtk_file_thumbnail, GTK_TYPE_WIDGET)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_INFO,
|
||||
N_PROPS,
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
copy_attribute (GFileInfo *to,
|
||||
GFileInfo *from,
|
||||
const char *attribute)
|
||||
{
|
||||
GFileAttributeType type;
|
||||
gpointer value;
|
||||
|
||||
if (g_file_info_get_attribute_data (from, attribute, &type, &value, NULL))
|
||||
g_file_info_set_attribute (to, attribute, type, value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_image (GtkFileThumbnail *self)
|
||||
{
|
||||
GtkIconTheme *icon_theme;
|
||||
GIcon *icon;
|
||||
int scale;
|
||||
|
||||
if (!g_file_info_has_attribute (self->info, G_FILE_ATTRIBUTE_STANDARD_ICON))
|
||||
return FALSE;
|
||||
|
||||
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
|
||||
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
|
||||
|
||||
icon = _gtk_file_info_get_icon (self->info, ICON_SIZE, scale, icon_theme);
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (self->image), icon);
|
||||
|
||||
g_object_unref (icon);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
thumbnail_queried_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileThumbnail *self = user_data; /* might be unreffed if operation was cancelled */
|
||||
GFile *file = G_FILE (object);
|
||||
GFileInfo *queried;
|
||||
|
||||
queried = g_file_query_info_finish (file, result, NULL);
|
||||
if (queried == NULL)
|
||||
return;
|
||||
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
|
||||
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_STANDARD_ICON);
|
||||
|
||||
update_image (self);
|
||||
|
||||
g_clear_object (&queried);
|
||||
|
||||
g_clear_object (&self->cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
cancel_thumbnail (GtkFileThumbnail *self)
|
||||
{
|
||||
g_cancellable_cancel (self->cancellable);
|
||||
g_clear_object (&self->cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
get_thumbnail (GtkFileThumbnail *self)
|
||||
{
|
||||
if (!self->info)
|
||||
return;
|
||||
|
||||
if (!update_image (self))
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
if (g_file_info_has_attribute (self->info, "filechooser::queried"))
|
||||
return;
|
||||
|
||||
g_assert (self->cancellable == NULL);
|
||||
self->cancellable = g_cancellable_new ();
|
||||
|
||||
file = _gtk_file_info_get_file (self->info);
|
||||
g_file_info_set_attribute_boolean (self->info, "filechooser::queried", TRUE);
|
||||
g_file_query_info_async (file,
|
||||
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
|
||||
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_ICON,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
G_PRIORITY_DEFAULT,
|
||||
self->cancellable,
|
||||
thumbnail_queried_cb,
|
||||
self);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_dispose (GObject *object)
|
||||
{
|
||||
GtkFileThumbnail *self = (GtkFileThumbnail *)object;
|
||||
|
||||
_gtk_file_thumbnail_set_info (self, NULL);
|
||||
|
||||
g_clear_pointer (&self->image, gtk_widget_unparent);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_file_thumbnail_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileThumbnail *self = GTK_FILE_THUMBNAIL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_INFO:
|
||||
g_value_set_object (value, self->info);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileThumbnail *self = GTK_FILE_THUMBNAIL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_INFO:
|
||||
_gtk_file_thumbnail_set_info (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_class_init (GtkFileThumbnailClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = _gtk_file_thumbnail_dispose;
|
||||
object_class->get_property = _gtk_file_thumbnail_get_property;
|
||||
object_class->set_property = _gtk_file_thumbnail_set_property;
|
||||
|
||||
properties[PROP_INFO] =
|
||||
g_param_spec_object ("file-info", NULL, NULL,
|
||||
G_TYPE_FILE_INFO,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, I_("filethumbnail"));
|
||||
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_file_thumbnail_init (GtkFileThumbnail *self)
|
||||
{
|
||||
self->image = gtk_image_new ();
|
||||
gtk_widget_set_parent (self->image, GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GFileInfo *
|
||||
_gtk_file_thumbnail_get_info (GtkFileThumbnail *self)
|
||||
{
|
||||
g_assert (GTK_IS_FILE_THUMBNAIL (self));
|
||||
|
||||
return self->info;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_file_thumbnail_set_info (GtkFileThumbnail *self,
|
||||
GFileInfo *info)
|
||||
{
|
||||
g_assert (GTK_IS_FILE_THUMBNAIL (self));
|
||||
g_assert (info == NULL || G_IS_FILE_INFO (info));
|
||||
|
||||
if (g_set_object (&self->info, info))
|
||||
{
|
||||
cancel_thumbnail (self);
|
||||
get_thumbnail (self);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INFO]);
|
||||
}
|
||||
}
|
||||
|
||||
46
gtk/gtkfilethumbnail.h
Normal file
46
gtk/gtkfilethumbnail.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* gtkfilethumbnail.h
|
||||
*
|
||||
* Copyright 2022 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GTK_FILE_THUMBNAIL_H__
|
||||
#define __GTK_FILE_THUMBNAIL_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "gtkfilesystemmodel.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_FILE_THUMBNAIL (_gtk_file_thumbnail_get_type ())
|
||||
#define GTK_FILE_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_THUMBNAIL, GtkFileThumbnail))
|
||||
#define GTK_IS_FILE_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_THUMBNAIL))
|
||||
|
||||
typedef struct _GtkFileThumbnail GtkFileThumbnail;
|
||||
|
||||
GType _gtk_file_thumbnail_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GFileInfo *_gtk_file_thumbnail_get_info (GtkFileThumbnail *self);
|
||||
void _gtk_file_thumbnail_set_info (GtkFileThumbnail *self,
|
||||
GFileInfo *info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_THUMBNAIL_H__ */
|
||||
|
||||
@@ -1870,9 +1870,7 @@ find_affected_text (GtkFontChooserWidget *fontchooser,
|
||||
|
||||
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
|
||||
|
||||
if (hb_ot_layout_language_find_feature (hb_face,
|
||||
HB_OT_TAG_GSUB,
|
||||
@@ -2013,9 +2011,7 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
|
||||
|
||||
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
|
||||
|
||||
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
|
||||
{
|
||||
@@ -2565,9 +2561,7 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
|
||||
{
|
||||
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_find_language (hb_face, table[i], script_index, lang_tag, &lang_index);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
hb_ot_layout_script_select_language (hb_face, table[i], script_index, 1, &lang_tag, &lang_index);
|
||||
|
||||
feat = features + n_features;
|
||||
count = G_N_ELEMENTS (features) - n_features;
|
||||
|
||||
@@ -520,8 +520,6 @@ on_remove_server_button_clicked (RemoveServerData *data)
|
||||
populate_servers (data->view);
|
||||
}
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
populate_servers (GtkPlacesView *view)
|
||||
{
|
||||
@@ -617,8 +615,6 @@ populate_servers (GtkPlacesView *view)
|
||||
g_bookmark_file_free (server_list);
|
||||
}
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
static void
|
||||
update_view_mode (GtkPlacesView *view)
|
||||
{
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
#include "gtksearchenginemodelprivate.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
struct _GtkSearchEngineModel
|
||||
{
|
||||
GtkSearchEngine parent;
|
||||
@@ -81,37 +80,33 @@ static gboolean
|
||||
do_search (gpointer data)
|
||||
{
|
||||
GtkSearchEngineModel *model = data;
|
||||
GtkTreeIter iter;
|
||||
GList *hits = NULL;
|
||||
gboolean got_results = FALSE;
|
||||
|
||||
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model->model), &iter))
|
||||
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model->model)); i++)
|
||||
{
|
||||
do
|
||||
GFileInfo *info = g_list_model_get_item (G_LIST_MODEL (model->model), i);
|
||||
|
||||
if (info_matches_query (model->query, info))
|
||||
{
|
||||
GFileInfo *info;
|
||||
GFile *file;
|
||||
GtkSearchHit *hit;
|
||||
|
||||
info = _gtk_file_system_model_get_info (model->model, &iter);
|
||||
if (info_matches_query (model->query, info))
|
||||
{
|
||||
GFile *file;
|
||||
GtkSearchHit *hit;
|
||||
|
||||
file = _gtk_file_system_model_get_file (model->model, &iter);
|
||||
hit = g_new (GtkSearchHit, 1);
|
||||
hit->file = g_object_ref (file);
|
||||
hit->info = g_object_ref (info);
|
||||
hits = g_list_prepend (hits, hit);
|
||||
}
|
||||
file = _gtk_file_info_get_file (info);
|
||||
hit = g_new (GtkSearchHit, 1);
|
||||
hit->file = g_object_ref (file);
|
||||
hit->info = g_object_ref (info);
|
||||
hits = g_list_prepend (hits, hit);
|
||||
}
|
||||
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model->model), &iter));
|
||||
|
||||
if (hits)
|
||||
{
|
||||
_gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
|
||||
g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
|
||||
got_results = TRUE;
|
||||
}
|
||||
g_clear_object (&info);
|
||||
}
|
||||
|
||||
if (hits)
|
||||
{
|
||||
_gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
|
||||
g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
|
||||
got_results = TRUE;
|
||||
}
|
||||
|
||||
model->idle = 0;
|
||||
|
||||
@@ -114,7 +114,8 @@ free_hit (gpointer data)
|
||||
}
|
||||
|
||||
static GFileInfo *
|
||||
create_file_info (TrackerSparqlCursor *cursor)
|
||||
create_file_info (GFile *file,
|
||||
TrackerSparqlCursor *cursor)
|
||||
{
|
||||
GFileInfo *info;
|
||||
const char *str;
|
||||
@@ -140,6 +141,10 @@ create_file_info (TrackerSparqlCursor *cursor)
|
||||
g_date_time_unref (creation);
|
||||
}
|
||||
|
||||
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
|
||||
g_file_info_set_attribute_boolean (info, "filechooser::filtered-out", FALSE);
|
||||
g_file_info_set_attribute_boolean (info, "filechooser::visible", TRUE);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -175,7 +180,7 @@ query_callback (TrackerSparqlStatement *statement,
|
||||
url = tracker_sparql_cursor_get_string (cursor, 0, NULL);
|
||||
hit = g_slice_new0 (GtkSearchHit);
|
||||
hit->file = g_file_new_for_uri (url);
|
||||
hit->info = create_file_info (cursor);
|
||||
hit->info = create_file_info (hit->file, cursor);
|
||||
hits = g_list_prepend (hits, hit);
|
||||
}
|
||||
|
||||
|
||||
@@ -1259,13 +1259,13 @@ property_editor (GObject *object,
|
||||
g_strdup_printf ("%s: %s",
|
||||
self->name,
|
||||
gtk_label_get_text (GTK_LABEL (prop_edit))),
|
||||
NULL);
|
||||
-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (prop_edit),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, self->name,
|
||||
NULL);
|
||||
-1);
|
||||
}
|
||||
|
||||
return prop_edit;
|
||||
|
||||
@@ -72,7 +72,7 @@ add_string (GtkInspectorStrvEditor *editor,
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), str);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (entry),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Value"),
|
||||
NULL);
|
||||
-1);
|
||||
gtk_widget_show (entry);
|
||||
gtk_box_append (GTK_BOX (box), entry);
|
||||
g_object_set_data (G_OBJECT (box), "entry", entry);
|
||||
@@ -83,7 +83,7 @@ add_string (GtkInspectorStrvEditor *editor,
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL,
|
||||
g_strdup_printf (_("Remove %s"), str),
|
||||
NULL);
|
||||
-1);
|
||||
gtk_widget_show (button);
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (remove_string), editor);
|
||||
@@ -116,7 +116,7 @@ gtk_inspector_strv_editor_init (GtkInspectorStrvEditor *editor)
|
||||
gtk_widget_set_halign (editor->button, GTK_ALIGN_END);
|
||||
gtk_accessible_update_property (GTK_ACCESSIBLE (editor->button),
|
||||
GTK_ACCESSIBLE_PROPERTY_LABEL, _("Add"),
|
||||
NULL);
|
||||
-1);
|
||||
gtk_widget_show (editor->button);
|
||||
g_signal_connect (editor->button, "clicked", G_CALLBACK (add_cb), editor);
|
||||
|
||||
|
||||
@@ -108,7 +108,9 @@ gtk_private_sources = files([
|
||||
'gtkfilechoosererrorstack.c',
|
||||
'gtkfilechoosernativeportal.c',
|
||||
'gtkfilechooserutils.c',
|
||||
'gtkfilechoosercell.c',
|
||||
'gtkfilesystemmodel.c',
|
||||
'gtkfilethumbnail.c',
|
||||
'gtkgizmo.c',
|
||||
'gtkiconcache.c',
|
||||
'gtkiconcachevalidator.c',
|
||||
@@ -181,9 +183,12 @@ gtk_public_sources = files([
|
||||
'gtkcenterlayout.c',
|
||||
'gtkcheckbutton.c',
|
||||
'gtkcolorbutton.c',
|
||||
'gtkcolorchoice.c',
|
||||
'gtkcolorchoicebutton.c',
|
||||
'gtkcolorchooser.c',
|
||||
'gtkcolorchooserdialog.c',
|
||||
'gtkcolorchooserwidget.c',
|
||||
'gtkcolorchooserwindow.c',
|
||||
'gtkcolorutils.c',
|
||||
'gtkcolumnview.c',
|
||||
'gtkcolumnviewcolumn.c',
|
||||
@@ -437,6 +442,8 @@ gtk_public_headers = files([
|
||||
'gtkcenterlayout.h',
|
||||
'gtkcheckbutton.h',
|
||||
'gtkcolorbutton.h',
|
||||
'gtkcolorchoice.h',
|
||||
'gtkcolorchoicebutton.h',
|
||||
'gtkcolorchooser.h',
|
||||
'gtkcolorchooserdialog.h',
|
||||
'gtkcolorchooserwidget.h',
|
||||
|
||||
@@ -3369,6 +3369,30 @@ columnview row:not(:selected) cell editablelabel.editing text selection {
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* Complex Lists *
|
||||
* Put padding on the cell content so event controllers *
|
||||
* can cover the whole area. *
|
||||
********************************************************/
|
||||
|
||||
columnview.complex {
|
||||
> listview > row > cell {
|
||||
padding: 0;
|
||||
> * {
|
||||
padding: 8px 6px;
|
||||
}
|
||||
}
|
||||
|
||||
// shrink vertically for .data-table
|
||||
&.data-table > listview > row > cell {
|
||||
padding: 0;
|
||||
> * {
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************
|
||||
* App Notifications *
|
||||
*********************/
|
||||
|
||||
52
gtk/ui/gtkcolorchooserwindow.ui
Normal file
52
gtk/ui/gtkcolorchooserwindow.ui
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton" id="ok_button">
|
||||
<property name="label" translatable="yes">_Select</property>
|
||||
<property name="use-underline">1</property>
|
||||
<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,103 +140,278 @@
|
||||
<property name="hscrollbar-policy">2</property>
|
||||
<property name="vexpand">1</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="browse_files_tree_view">
|
||||
<property name="has-tooltip">1</property>
|
||||
<property name="enable-search">0</property>
|
||||
<object class="GtkColumnView" id="browse_files_column_view">
|
||||
<style>
|
||||
<class name="complex"/>
|
||||
</style>
|
||||
<signal name="activate" handler="column_view_row_activated_cb" swapped="no"/>
|
||||
<signal name="keynav-failed" handler="browse_files_column_view_keynav_failed_cb"/>
|
||||
<child>
|
||||
<object class="GtkGestureLongPress">
|
||||
<property name="touch-only">1</property>
|
||||
<signal name="pressed" handler="long_press_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGestureClick">
|
||||
<property name="button">3</property>
|
||||
<signal name="pressed" handler="click_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<signal name="query-tooltip" handler="file_list_query_tooltip_cb" swapped="no"/>
|
||||
<signal name="row-activated" handler="list_row_activated" swapped="no"/>
|
||||
<signal name="keynav-failed" handler="browse_files_tree_view_keynav_failed_cb"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection2">
|
||||
<signal name="changed" handler="list_selection_changed" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_name_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_name_column">
|
||||
<property name="title" translatable="yes">Name</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="expand">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererPixbuf" id="list_pixbuf_renderer">
|
||||
<property name="xpad">6</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkFileThumbnail">
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
<binding name="file-info">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="min-chars">10</property>
|
||||
<binding name="text">
|
||||
<closure type="gchararray" function="column_view_get_file_display_name">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_name_renderer">
|
||||
<property name="width-chars">10</property>
|
||||
<property name="ellipsize">3</property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_location_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_location_column">
|
||||
<property name="title" translatable="yes">Location</property>
|
||||
<property name="resizable">1</property>
|
||||
<property name="visible">0</property>
|
||||
<property name="expand">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_location_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="width-chars">10</property>
|
||||
<property name="ellipsize">1</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkInscription">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="min-chars">10</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">6</property>
|
||||
<binding name="text">
|
||||
<closure type="gchararray" function="column_view_get_location">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_size_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_size_column">
|
||||
<property name="title" translatable="yes">Size</property>
|
||||
<property name="sizing">2</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_size_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_size">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_type_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_type_column">
|
||||
<property name="title" translatable="yes">Type</property>
|
||||
<property name="resizable">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_type_renderer">
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="hexpand">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_file_type">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="list_time_column">
|
||||
<object class="GtkColumnViewColumn" id="column_view_time_column">
|
||||
<property name="title" translatable="yes">Modified</property>
|
||||
<property name="sizing">2</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_date_renderer">
|
||||
<property name="xpad">6</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkFileChooserCell" id="file_chooser_cell">
|
||||
<binding name="position">
|
||||
<lookup name="position">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="item">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
<binding name="selected">
|
||||
<lookup name="selected">GtkListItem</lookup>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
<binding name="tooltip-text">
|
||||
<closure type="gchararray" function="column_view_get_tooltip_text">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_file_date">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible" bind-source="file_chooser_cell" bind-property="show-time" bind-flags="sync-create"/>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="column_view_get_file_time">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]></property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="list_time_renderer">
|
||||
<property name="xpad">6</property>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
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.66.0'
|
||||
glib_req = '>= 2.72.0'
|
||||
pango_req = '>= 1.50.0' # keep this in sync with .gitlab-ci/test-msys.sh
|
||||
harfbuzz_req = '>= 2.6.0'
|
||||
fribidi_req = '>= 0.19.7'
|
||||
@@ -342,15 +342,19 @@ 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)
|
||||
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')
|
||||
endif
|
||||
if cc.get_id() != 'msvc'
|
||||
common_cflags += ['-fvisibility=hidden']
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -97,7 +97,6 @@ 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)
|
||||
{
|
||||
@@ -109,7 +108,6 @@ g_io_module_load (GIOModule *module)
|
||||
10);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
G_GNUC_NORETURN
|
||||
void
|
||||
g_io_module_unload (GIOModule *module)
|
||||
@@ -117,7 +115,6 @@ g_io_module_unload (GIOModule *module)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
char **
|
||||
g_io_module_query (void)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,11 @@ 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']
|
||||
extra_c_args = [
|
||||
'-DGTK_COMPILATION',
|
||||
'-D_GLIB_EXTERN=@0@'.format(visibility_define),
|
||||
]
|
||||
|
||||
extra_c_args += common_cflags
|
||||
|
||||
ffmpeg_opt = get_option('media-ffmpeg')
|
||||
|
||||
@@ -246,7 +246,6 @@ 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)
|
||||
{
|
||||
@@ -261,13 +260,11 @@ 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,7 +103,6 @@ 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)
|
||||
{
|
||||
@@ -117,13 +116,11 @@ 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,7 +82,6 @@ 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)
|
||||
{
|
||||
@@ -96,13 +95,11 @@ 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,6 +8,7 @@ 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