Compare commits

..

4 Commits

Author SHA1 Message Date
Matthias Clasen 019650ff26 columnview: Clarify docs
Mention that gtk_column_view_sort_by_column
can be called multiple times to ste up
complex sorting.
2022-10-20 06:56:25 -04:00
Matthias Clasen eb045fe936 columnview: Reimplement column view sorting
Replace the private GtkColumnViewSorter implementation
with a GtkMultiSorter containing GtkInvertibleSorters
wrapping the individual column sorters.
2022-10-20 06:56:25 -04:00
Matthias Clasen 173f82772e Add GtkInvertibleSorter
This is a sorter that wraps another sorter
and allows to invert its sort order.
2022-10-20 06:56:25 -04:00
Matthias Clasen 3d521d3b56 Add gtk_multi_sorter_splice
There is no reason to have a weaker list api
on this sorter than on a list store. We will
need this function in the following commits.
2022-10-19 23:34:11 -04:00
115 changed files with 5866 additions and 10180 deletions
+28 -41
View File
@@ -11,6 +11,7 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
G_DECLARE_FINAL_TYPE (CanvasItem, canvas_item, CANVAS, ITEM, GtkWidget)
@@ -25,9 +26,6 @@ struct _CanvasItem {
double delta;
GtkWidget *editor;
GtkStyleProvider *provider;
char *css_class;
};
struct _CanvasItemClass {
@@ -38,41 +36,32 @@ G_DEFINE_TYPE (CanvasItem, canvas_item, GTK_TYPE_WIDGET)
static int n_items = 0;
static void
unstyle_item (CanvasItem *item)
{
if (item->provider)
{
gtk_style_context_remove_provider_for_display (gtk_widget_get_display (item->label), item->provider);
g_clear_object (&item->provider);
}
if (item->css_class)
{
gtk_widget_remove_css_class (item->label, item->css_class);
g_clear_pointer (&item->css_class, g_free);
}
}
static void
set_color (CanvasItem *item,
GdkRGBA *color)
{
char *css;
char *str;
GtkStyleContext *context;
GtkCssProvider *provider;
const char *name;
unstyle_item (item);
const char *old_class;
str = gdk_rgba_to_string (color);
name = gtk_widget_get_name (item->label);
css = g_strdup_printf ("#%s { background: %s; }", name, str);
css = g_strdup_printf ("* { background: %s; }", str);
context = gtk_widget_get_style_context (item->label);
provider = g_object_get_data (G_OBJECT (context), "style-provider");
if (provider)
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
if (old_class)
gtk_widget_remove_css_class (item->label, old_class);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gtk_widget_get_display (item->label), GTK_STYLE_PROVIDER (provider), 700);
item->provider = GTK_STYLE_PROVIDER (provider);
gtk_style_context_add_provider (gtk_widget_get_style_context (item->label), GTK_STYLE_PROVIDER (provider), 800);
g_object_set_data_full (G_OBJECT (context), "style-provider", provider, g_object_unref);
g_free (str);
g_free (css);
@@ -82,10 +71,21 @@ static void
set_css (CanvasItem *item,
const char *class)
{
unstyle_item (item);
GtkStyleContext *context;
GtkCssProvider *provider;
const char *old_class;
context = gtk_widget_get_style_context (item->label);
provider = g_object_get_data (G_OBJECT (context), "style-provider");
if (provider)
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (provider));
old_class = (const char *)g_object_get_data (G_OBJECT (item->label), "css-class");
if (old_class)
gtk_widget_remove_css_class (item->label, old_class);
g_object_set_data_full (G_OBJECT (item->label), "css-class", g_strdup (class), g_free);
gtk_widget_add_css_class (item->label, class);
item->css_class = g_strdup (class);
}
static gboolean
@@ -724,7 +724,6 @@ do_dnd (GtkWidget *do_widget)
int i;
int x, y;
GtkCssProvider *provider;
GString *css;
button = gtk_color_button_new ();
g_object_unref (g_object_ref_sink (button));
@@ -736,18 +735,6 @@ do_dnd (GtkWidget *do_widget)
800);
g_object_unref (provider);
css = g_string_new ("");
for (i = 0; colors[i]; i++)
g_string_append_printf (css, ".canvasitem.%s { background: %s; }\n", colors[i], colors[i]);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css->str, css->len);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
g_string_free (css, TRUE);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
+88 -146
View File
@@ -21,75 +21,7 @@
#include "script-names.h"
#include "language-names.h"
/* {{{ ScriptLang object */
G_DECLARE_FINAL_TYPE (ScriptLang, script_lang, SCRIPT, LANG, GObject)
struct _ScriptLang
{
GObject parent;
char *langname;
unsigned int script_index;
unsigned int lang_index;
hb_tag_t lang_tag;
};
struct _ScriptLangClass
{
GObjectClass parent_class;
};
G_DEFINE_TYPE (ScriptLang, script_lang, G_TYPE_OBJECT)
static void
script_lang_init (ScriptLang *self)
{
}
static void
script_lang_finalize (GObject *object)
{
ScriptLang *self = SCRIPT_LANG (object);
g_free (self->langname);
G_OBJECT_CLASS (script_lang_parent_class)->finalize (object);
}
static void
script_lang_class_init (ScriptLangClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = script_lang_finalize;
}
static ScriptLang *
script_lang_new (const char *langname,
unsigned int script_index,
unsigned int lang_index,
hb_tag_t lang_tag)
{
ScriptLang *self;
self = g_object_new (script_lang_get_type (), NULL);
self->langname = g_strdup (langname);
self->script_index = script_index;
self->lang_index = lang_index;
self->lang_tag = lang_tag;
return self;
}
static char *
script_lang_get_langname (ScriptLang *self)
{
return g_strdup (self->langname);
}
/* }}} */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#define MAKE_TAG(a,b,c,d) (unsigned int)(((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
@@ -163,10 +95,6 @@ demo_free (gpointer data)
g_clear_pointer (&demo->axes, g_hash_table_unref);
g_clear_pointer (&demo->text, g_free);
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (demo->provider));
g_object_unref (demo->provider);
g_free (demo);
}
@@ -544,6 +472,8 @@ update_display (void)
GString *s;
char *text;
gboolean has_feature;
GtkTreeIter iter;
GtkTreeModel *model;
PangoFontDescription *desc;
GList *l;
PangoAttrList *attrs;
@@ -646,13 +576,14 @@ update_display (void)
features = g_string_free (s, FALSE);
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) != 0)
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
{
ScriptLang *selected;
hb_tag_t lang_tag;
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
gtk_tree_model_get (model, &iter, 3, &lang_tag, -1);
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (selected->lang_tag)));
lang = pango_language_from_string (hb_language_to_string (hb_ot_tag_to_language (lang_tag)));
}
else
lang = NULL;
@@ -809,30 +740,40 @@ tag_pair_equal (gconstpointer a, gconstpointer b)
return pair_a->script_tag == pair_b->script_tag && pair_a->lang_tag == pair_b->lang_tag;
}
static GtkOrdering
script_sort (const void *item1,
const void *item2,
void *data)
static int
script_sort_func (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer user_data)
{
ScriptLang *a = (ScriptLang *)item1;
ScriptLang *b = (ScriptLang *)item2;
char *sa, *sb;
int ret;
return strcmp (a->langname, b->langname);
gtk_tree_model_get (model, a, 0, &sa, -1);
gtk_tree_model_get (model, b, 0, &sb, -1);
ret = strcmp (sa, sb);
g_free (sa);
g_free (sb);
return ret;
}
static void
update_script_combo (void)
{
GListStore *store;
GtkSortListModel *sortmodel;
GtkListStore *store;
hb_font_t *hb_font;
int i, j, k;
PangoFont *pango_font;
GHashTable *tags;
GHashTableIter iter;
TagPair *pair;
char *lang;
hb_tag_t active;
GtkTreeIter active_iter;
gboolean have_active = FALSE;
lang = gtk_font_chooser_get_language (GTK_FONT_CHOOSER (demo->font));
@@ -842,7 +783,7 @@ update_script_combo (void)
g_free (lang);
store = g_list_store_new (script_lang_get_type ());
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
pango_font = get_pango_font ();
hb_font = pango_font_get_hb_font (pango_font);
@@ -866,19 +807,19 @@ update_script_combo (void)
hb_face = hb_font_get_face (hb_font);
for (guint i = 0; i < 2; i++)
for (i= 0; i < 2; i++)
{
hb_tag_t scripts[80];
unsigned int script_count = G_N_ELEMENTS (scripts);
hb_ot_layout_table_get_script_tags (hb_face, tables[i], 0, &script_count, scripts);
for (guint j = 0; j < script_count; j++)
for (j = 0; j < script_count; j++)
{
hb_tag_t languages[80];
unsigned int language_count = G_N_ELEMENTS (languages);
hb_ot_layout_script_get_language_tags (hb_face, tables[i], j, 0, &language_count, languages);
for (guint k = 0; k < language_count; k++)
for (k = 0; k < language_count; k++)
{
pair = g_new (TagPair, 1);
pair->script_tag = scripts[j];
@@ -898,6 +839,7 @@ update_script_combo (void)
{
const char *langname;
char langbuf[5];
GtkTreeIter tree_iter;
if (pair->lang_tag == 0 && pair->script_tag == 0)
langname = NC_("Language", "None");
@@ -914,31 +856,31 @@ update_script_combo (void)
}
}
g_list_store_append (store, script_lang_new (langname,
pair->script_index,
pair->lang_index,
pair->lang_tag));
gtk_list_store_insert_with_values (store, &tree_iter, -1,
0, langname,
1, pair->script_index,
2, pair->lang_index,
3, pair->lang_tag,
-1);
if (pair->lang_tag == active)
{
have_active = TRUE;
active_iter = tree_iter;
}
}
g_hash_table_destroy (tags);
sortmodel = gtk_sort_list_model_new (G_LIST_MODEL (store),
GTK_SORTER (gtk_custom_sorter_new (script_sort, NULL, NULL)));
gtk_drop_down_set_model (GTK_DROP_DOWN (demo->script_lang), G_LIST_MODEL (sortmodel));
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (sortmodel)); i++)
{
ScriptLang *item = g_list_model_get_item (G_LIST_MODEL (sortmodel), i);
g_object_unref (item);
if (item->lang_tag == active)
{
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->script_lang), i);
break;
}
}
g_object_unref (sortmodel);
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
script_sort_func, NULL, NULL);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);
gtk_combo_box_set_model (GTK_COMBO_BOX (demo->script_lang), GTK_TREE_MODEL (store));
if (have_active)
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (demo->script_lang), &active_iter);
else
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (demo->script_lang), 0);
}
static char *
@@ -963,19 +905,27 @@ static void
update_features (void)
{
int i, j;
GtkTreeModel *model;
GtkTreeIter iter;
guint script_index, lang_index;
hb_tag_t lang_tag;
PangoFont *pango_font;
hb_font_t *hb_font;
GList *l;
ScriptLang *selected;
/* set feature presence checks from the font features */
if (gtk_drop_down_get_selected (GTK_DROP_DOWN (demo->script_lang)) == 0)
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (demo->script_lang), &iter))
return;
selected = gtk_drop_down_get_selected_item (GTK_DROP_DOWN (demo->script_lang));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (demo->script_lang));
gtk_tree_model_get (model, &iter,
1, &script_index,
2, &lang_index,
3, &lang_tag,
-1);
if (selected->lang_tag == 0) /* None is selected */
if (lang_tag == 0) /* None is selected */
{
for (l = demo->feature_items; l; l = l->next)
{
@@ -1016,8 +966,8 @@ update_features (void)
hb_ot_layout_language_get_feature_tags (hb_face,
tables[i],
selected->script_index,
selected->lang_index,
script_index,
lang_index,
0,
&count,
features);
@@ -1039,8 +989,8 @@ update_features (void)
hb_ot_layout_language_find_feature (hb_face,
tables[i],
selected->script_index,
selected->lang_index,
script_index,
lang_index,
features[j],
&feature_index);
@@ -1372,9 +1322,10 @@ free_instance (gpointer data)
}
static void
add_instance (hb_face_t *face,
unsigned int index,
GtkStringList *strings)
add_instance (hb_face_t *face,
unsigned int index,
GtkWidget *combo,
int pos)
{
Instance *instance;
hb_ot_name_id_t name_id;
@@ -1390,20 +1341,20 @@ add_instance (hb_face_t *face,
instance->index = index;
g_hash_table_add (demo->instances, instance);
gtk_string_list_append (GTK_STRING_LIST (strings), instance->name);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), instance->name);
}
static void
unset_instance (GtkAdjustment *adjustment)
{
if (demo->instance_combo)
gtk_drop_down_set_selected (GTK_DROP_DOWN (demo->instance_combo), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (demo->instance_combo), 0);
}
static void
instance_changed (GtkDropDown *combo)
instance_changed (GtkComboBox *combo)
{
const char *text;
char *text;
Instance *instance;
Instance ikey;
int i;
@@ -1415,12 +1366,11 @@ instance_changed (GtkDropDown *combo)
hb_font_t *hb_font;
hb_face_t *hb_face;
text = gtk_string_list_get_string (GTK_STRING_LIST (gtk_drop_down_get_model (combo)),
gtk_drop_down_get_selected (combo));
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
if (text[0] == '\0')
goto out;
ikey.name = (char *) text;
ikey.name = text;
instance = g_hash_table_lookup (demo->instances, &ikey);
if (!instance)
{
@@ -1461,6 +1411,7 @@ instance_changed (GtkDropDown *combo)
}
out:
g_free (text);
g_clear_object (&pango_font);
g_free (ai);
g_free (coords);
@@ -1570,7 +1521,6 @@ update_font_variations (void)
{
GtkWidget *label;
GtkWidget *combo;
GtkStringList *strings;
label = gtk_label_new ("Instance");
gtk_label_set_xalign (GTK_LABEL (label), 0);
@@ -1578,28 +1528,26 @@ update_font_variations (void)
gtk_widget_set_valign (label, GTK_ALIGN_BASELINE);
gtk_grid_attach (GTK_GRID (demo->variations_grid), label, 0, -1, 1, 1);
strings = gtk_string_list_new (NULL);
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
combo = gtk_combo_box_text_new ();
gtk_widget_set_halign (combo, GTK_ALIGN_START);
gtk_widget_set_valign (combo, GTK_ALIGN_BASELINE);
gtk_string_list_append (strings, "");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "");
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
add_instance (hb_face, i, strings);
add_instance (hb_face, i, combo, i);
for (i = 0; i < hb_ot_var_get_named_instance_count (hb_face); i++)
{
if (matches_instance (hb_face, i, n_axes, design_coords))
{
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), i + 1);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i + 1);
break;
}
}
gtk_grid_attach (GTK_GRID (demo->variations_grid), combo, 1, -1, 3, 1);
g_signal_connect (combo, "notify::selecte", G_CALLBACK (instance_changed), NULL);
g_signal_connect (combo, "changed", G_CALLBACK (instance_changed), NULL);
demo->instance_combo = combo;
}
@@ -1746,7 +1694,6 @@ do_font_features (GtkWidget *do_widget)
GtkBuilder *builder;
GtkBuilderScope *scope;
GtkEventController *controller;
GtkExpression *expression;
builder = gtk_builder_new ();
@@ -1780,9 +1727,6 @@ do_font_features (GtkWidget *do_widget)
demo->description = GTK_WIDGET (gtk_builder_get_object (builder, "description"));
demo->font = GTK_WIDGET (gtk_builder_get_object (builder, "font"));
demo->script_lang = GTK_WIDGET (gtk_builder_get_object (builder, "script_lang"));
expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, G_CALLBACK (script_lang_get_langname), NULL, NULL);
gtk_drop_down_set_expression (GTK_DROP_DOWN (demo->script_lang), expression);
gtk_expression_unref (expression);
demo->feature_list = GTK_WIDGET (gtk_builder_get_object (builder, "feature_list"));
demo->stack = GTK_WIDGET (gtk_builder_get_object (builder, "stack"));
demo->entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry"));
@@ -1801,8 +1745,8 @@ do_font_features (GtkWidget *do_widget)
demo->swin = GTK_WIDGET (gtk_builder_get_object (builder, "swin"));
demo->provider = gtk_css_provider_new ();
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (demo->provider), 800);
gtk_style_context_add_provider (gtk_widget_get_style_context (demo->swin),
GTK_STYLE_PROVIDER (demo->provider), 800);
basic_value_changed (demo->size_adjustment, demo->size_entry);
basic_value_changed (demo->letterspacing_adjustment, demo->letterspacing_entry);
@@ -1880,5 +1824,3 @@ do_font_features (GtkWidget *do_widget)
return window;
}
/* vim:set foldmethod=marker expandtab: */
+8 -2
View File
@@ -259,10 +259,16 @@
<object class="GtkBox" id="feature_list">
<property name="orientation">vertical</property>
<child>
<object class="GtkDropDown" id="script_lang">
<object class="GtkComboBox" id="script_lang">
<property name="tooltip-text" translatable="yes">Language System</property>
<property name="margin-top">10</property>
<signal name="notify::selected" handler="font_features_script_changed" swapped="no"/>
<signal name="changed" handler="font_features_script_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
+15 -17
View File
@@ -10,6 +10,8 @@
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *window = NULL;
static GtkWidget *font_button = NULL;
static GtkWidget *entry = NULL;
@@ -43,6 +45,7 @@ update_image (void)
cairo_t *cr;
GdkPixbuf *pixbuf;
GdkPixbuf *pixbuf2;
const char *hint;
cairo_font_options_t *fopt;
cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics;
@@ -57,23 +60,18 @@ update_image (void)
fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context));
switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting)))
hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting));
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
if (hint)
{
case 0:
hintstyle = CAIRO_HINT_STYLE_NONE;
break;
case 1:
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
break;
case 2:
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
break;
case 3:
hintstyle = CAIRO_HINT_STYLE_FULL;
break;
default:
hintstyle = CAIRO_HINT_STYLE_DEFAULT;
break;
if (strcmp (hint, "none") == 0)
hintstyle = CAIRO_HINT_STYLE_NONE;
else if (strcmp (hint, "slight") == 0)
hintstyle = CAIRO_HINT_STYLE_SLIGHT;
else if (strcmp (hint, "medium") == 0)
hintstyle = CAIRO_HINT_STYLE_MEDIUM;
else if (strcmp (hint, "full") == 0)
hintstyle = CAIRO_HINT_STYLE_FULL;
}
cairo_font_options_set_hint_style (fopt, hintstyle);
@@ -422,7 +420,7 @@ do_fontrendering (GtkWidget *do_widget)
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL);
g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL);
g_signal_connect (hinting, "notify::selected", G_CALLBACK (update_image), NULL);
g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
+8 -11
View File
@@ -116,18 +116,15 @@
</object>
</child>
<child>
<object class="GtkDropDown" id="hinting">
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<property name="model">
<object class="GtkStringList">
<items>
<item translatable="yes">None</item>
<item translatable="yes">Slight</item>
<item translatable="yes">Medium</item>
<item translatable="yes">Full</item>
</items>
</object>
</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="slight">Slight</item>
<item translatable="yes" id="medium">Medium</item>
<item translatable="yes" id="full">Full</item>
</items>
</object>
</child>
<layout>
+9 -18
View File
@@ -20,6 +20,8 @@
#include "gtkshadertoy.h"
#include "gskshaderpaintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static GtkWidget *demo_window = NULL;
static void
@@ -144,6 +146,7 @@ make_shader_stack (const char *name,
GtkTextBuffer *buffer;
GBytes *bytes;
GtkEventController *controller;
GtkCssProvider *provider;
GdkPaintable *paintable;
stack = gtk_shader_stack_new ();
@@ -234,6 +237,12 @@ make_shader_stack (const char *name,
g_signal_connect (buffer, "changed", G_CALLBACK (text_changed), button);
g_object_set_data (G_OBJECT (button), "the-stack", stack);
g_signal_connect (button, "clicked", G_CALLBACK (apply_text), buffer);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (button),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
gtk_widget_add_css_class (button, "small");
@@ -267,21 +276,11 @@ make_shader_stack (const char *name,
return vbox;
}
static void
remove_provider (gpointer data)
{
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
g_object_unref (provider);
}
static GtkWidget *
create_gltransition_window (GtkWidget *do_widget)
{
GtkWidget *window, *headerbar, *scale, *outer_grid, *grid, *background;
GdkPaintable *paintable;
GtkCssProvider *provider;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
@@ -336,14 +335,6 @@ create_gltransition_window (GtkWidget *do_widget)
make_shader_stack ("Kaleidoscope", "/gltransition/kaleidoscope.glsl", 3, scale),
1, 1, 1, 1);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "button.small { padding: 0; }", -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
return window;
}
-4
View File
@@ -422,10 +422,6 @@ do_listview_settings (GtkWidget *do_widget)
gtk_column_view_column_set_sorter (name_column, sorter);
g_object_unref (sorter);
sorter = GTK_SORTER (gtk_string_sorter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "type")));
gtk_column_view_column_set_sorter (type_column, sorter);
g_object_unref (sorter);
g_object_unref (builder);
}
+3 -12
View File
@@ -10,6 +10,8 @@
#include "script-names.h"
#include "unicode-names.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
#define UCD_TYPE_ITEM (ucd_item_get_type ())
G_DECLARE_FINAL_TYPE (UcdItem, ucd_item, UCD, ITEM, GObject)
@@ -337,15 +339,6 @@ create_ucd_view (GtkWidget *label)
static GtkWidget *window;
static void
remove_provider (gpointer data)
{
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
g_object_unref (provider);
}
GtkWidget *
do_listview_ucd (GtkWidget *do_widget)
{
@@ -368,7 +361,7 @@ do_listview_ucd (GtkWidget *do_widget)
gtk_widget_add_css_class (label, "enormous");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, "label.enormous { font-size: 80px; }", -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
gtk_style_context_add_provider (gtk_widget_get_style_context (label), GTK_STYLE_PROVIDER (provider), 800);
gtk_widget_set_hexpand (label, TRUE);
gtk_box_append (GTK_BOX (box), label);
@@ -378,8 +371,6 @@ do_listview_ucd (GtkWidget *do_widget)
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), listview);
gtk_box_prepend (GTK_BOX (box), sw);
gtk_window_set_child (GTK_WINDOW (window), box);
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
}
if (!gtk_widget_get_visible (window))
+5 -13
View File
@@ -8,6 +8,7 @@
#include "config.h"
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* Create an object for the pegs that get moved around in the game.
*
@@ -360,15 +361,6 @@ drop_drop (GtkDropTarget *target,
return TRUE;
}
static void
remove_provider (gpointer data)
{
GtkStyleProvider *provider = GTK_STYLE_PROVIDER (data);
gtk_style_context_remove_provider_for_display (gdk_display_get_default (), provider);
g_object_unref (provider);
}
static void
create_board (GtkWidget *window)
{
@@ -385,9 +377,6 @@ create_board (GtkWidget *window)
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
grid = gtk_grid_new ();
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
@@ -406,6 +395,9 @@ create_board (GtkWidget *window)
continue;
image = gtk_image_new ();
gtk_style_context_add_provider (gtk_widget_get_style_context (image),
GTK_STYLE_PROVIDER (provider),
800);
gtk_widget_add_css_class (image, "solitaire-field");
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
if (x != 3 || y != 3)
@@ -449,7 +441,7 @@ create_board (GtkWidget *window)
}
}
g_object_set_data_full (G_OBJECT (window), "provider", provider, remove_provider);
g_object_unref (provider);
}
static void
+2
View File
@@ -16,6 +16,7 @@ enum {
NUM_PROPERTIES
};
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
static void
pixbuf_paintable_snapshot (GdkPaintable *paintable,
GdkSnapshot *snapshot,
@@ -36,6 +37,7 @@ pixbuf_paintable_snapshot (GdkPaintable *paintable,
g_object_unref (texture);
}
G_GNUC_END_IGNORE_DEPRECATIONS;
static int
pixbuf_paintable_get_intrinsic_width (GdkPaintable *paintable)
+27 -7
View File
@@ -16,6 +16,26 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/* Convenience function to create a combo box holding a number of strings
*/
GtkWidget *
create_combo_box (const char **strings)
{
GtkWidget *combo_box;
const char **str;
combo_box = gtk_combo_box_text_new ();
for (str = strings; *str; str++)
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), *str);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
return combo_box;
}
static void
add_row (GtkGrid *table,
int row,
@@ -23,7 +43,7 @@ add_row (GtkGrid *table,
const char *label_text,
const char **options)
{
GtkWidget *dropdown;
GtkWidget *combo_box;
GtkWidget *label;
label = gtk_label_new_with_mnemonic (label_text);
@@ -32,12 +52,12 @@ add_row (GtkGrid *table,
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (table, label, 0, row, 1, 1);
dropdown = gtk_drop_down_new_from_strings (options);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), dropdown);
gtk_widget_set_halign (dropdown, GTK_ALIGN_END);
gtk_widget_set_valign (dropdown, GTK_ALIGN_BASELINE);
gtk_size_group_add_widget (size_group, dropdown);
gtk_grid_attach (table, dropdown, 1, row, 1, 1);
combo_box = create_combo_box (options);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
gtk_widget_set_halign (combo_box, GTK_ALIGN_END);
gtk_widget_set_valign (combo_box, GTK_ALIGN_BASELINE);
gtk_size_group_add_widget (size_group, combo_box);
gtk_grid_attach (table, combo_box, 1, row, 1, 1);
}
static void
+5 -4
View File
@@ -11,6 +11,7 @@
#include <stdlib.h> /* for exit() */
#include "paintable.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static void easter_egg_callback (GtkWidget *button, gpointer data);
@@ -430,11 +431,11 @@ attach_widgets (GtkTextView *text_view)
}
else if (i == 1)
{
const char *options[] = {
"Option 1", "Option 2", "Option 3", NULL
};
widget = gtk_combo_box_text_new ();
widget = gtk_drop_down_new_from_strings (options);
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 1");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 2");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 3");
}
else if (i == 2)
{
+10 -11
View File
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct
{
GtkApplication parent_instance;
@@ -350,8 +352,7 @@ quit_activated (GSimpleAction *action,
}
static void
combo_changed (GtkDropDown *combo,
GParamSpec *pspec,
combo_changed (GtkComboBox *combo,
gpointer user_data)
{
GtkDialog *dialog = user_data;
@@ -360,7 +361,7 @@ combo_changed (GtkDropDown *combo,
char **accels;
char *str;
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
action = gtk_combo_box_get_active_id (combo);
if (!action)
return;
@@ -389,7 +390,7 @@ response (GtkDialog *dialog,
gpointer user_data)
{
GtkEntry *entry = g_object_get_data (user_data, "entry");
GtkDropDown *combo = g_object_get_data (user_data, "combo");
GtkComboBox *combo = g_object_get_data (user_data, "combo");
const char *action;
const char *str;
char **accels;
@@ -400,7 +401,7 @@ response (GtkDialog *dialog,
return;
}
action = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_drop_down_get_selected_item (combo)));
action = gtk_combo_box_get_active_id (combo);
if (!action)
return;
@@ -425,7 +426,6 @@ edit_accels (GSimpleAction *action,
char **actions;
GtkWidget *dialog;
int i;
GtkStringList *strings;
dialog = gtk_dialog_new_with_buttons ("Accelerators",
NULL,
@@ -437,8 +437,7 @@ edit_accels (GSimpleAction *action,
gtk_window_set_application (GTK_WINDOW (dialog), app);
actions = gtk_application_list_action_descriptions (app);
strings = gtk_string_list_new (NULL);
combo = gtk_drop_down_new (G_LIST_MODEL (strings), NULL);
combo = gtk_combo_box_text_new ();
g_object_set (gtk_dialog_get_content_area (GTK_DIALOG (dialog)),
"margin-top", 10,
"margin-bottom", 10,
@@ -449,8 +448,8 @@ edit_accels (GSimpleAction *action,
gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), combo);
for (i = 0; actions[i]; i++)
gtk_string_list_append (strings, actions[i]);
g_signal_connect (combo, "notify::selected", G_CALLBACK (combo_changed), dialog);
gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), actions[i], actions[i]);
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed), dialog);
entry = gtk_entry_new ();
gtk_widget_set_hexpand (entry, TRUE);
@@ -461,7 +460,7 @@ edit_accels (GSimpleAction *action,
g_object_set_data (G_OBJECT (dialog), "combo", combo);
g_object_set_data (G_OBJECT (dialog), "entry", entry);
gtk_drop_down_set_selected (GTK_DROP_DOWN (combo), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
gtk_widget_show (dialog);
}
+1 -1
View File
@@ -203,7 +203,7 @@ gdk_wayland_keymap_get_entries_for_keycode (GdkKeymap *keymap,
{
const xkb_keysym_t *syms;
int num_syms;
num_syms = xkb_keymap_key_get_syms_by_level (xkb_keymap, hardware_keycode, layout, level, &syms);
num_syms = xkb_keymap_key_get_syms_by_level (xkb_keymap, hardware_keycode, layout, 0, &syms);
if (keys)
{
(*keys)[i].keycode = hardware_keycode;
-4
View File
@@ -41,10 +41,6 @@
*
* To obtain the application that has been selected in a `GtkAppChooser`,
* use [method@Gtk.AppChooser.get_app_info].
*
* Deprecated: 4.10: The application selection widgets should be
* implemented according to the design of each platform and/or
* application requiring them.
*/
#include "config.h"
+1 -5
View File
@@ -45,13 +45,9 @@
* To track changes in the selected application, use the
* [signal@Gtk.AppChooserButton::changed] signal.
*
* ## CSS nodes
* # CSS nodes
*
* `GtkAppChooserButton` has a single CSS node with the name “appchooserbutton”.
*
* Deprecated: 4.10: The application selection widgets should be
* implemented according to the design of each platform and/or
* application requiring them.
*/
#include "config.h"
+3 -7
View File
@@ -37,10 +37,6 @@
*
* To set the heading that is shown above the `GtkAppChooserWidget`,
* use [method@Gtk.AppChooserDialog.set_heading].
*
* Deprecated: 4.10: The application selection widgets should be
* implemented according to the design of each platform and/or
* application requiring them.
*/
#include "config.h"
@@ -220,13 +216,13 @@ set_dialog_properties (GtkAppChooserDialog *self)
else if (self->content_type)
{
/* Translators: %s is a file type description */
subtitle = g_strdup_printf (_("Opening “%s” files."),
subtitle = g_strdup_printf (_("Opening “%s” files."),
unknown ? self->content_type : description);
string = g_strdup_printf (_("No applications found for “%s” files"),
unknown ? self->content_type : description);
}
g_object_get (self, "use-header-bar", &use_header, NULL);
g_object_get (self, "use-header-bar", &use_header, NULL);
if (use_header)
{
GtkWidget *box, *label;
@@ -498,7 +494,7 @@ static void
gtk_app_chooser_dialog_dispose (GObject *object)
{
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
g_clear_object (&self->gfile);
self->dismissed = TRUE;
+3 -7
View File
@@ -69,13 +69,9 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* [signal@Gtk.AppChooserWidget::application-selected] and
* [signal@Gtk.AppChooserWidget::application-activated] signals.
*
* ## CSS nodes
* # CSS nodes
*
* `GtkAppChooserWidget` has a single CSS node with name appchooser.
*
* Deprecated: 4.10: The application selection widgets should be
* implemented according to the design of each platform and/or
* application requiring them.
*/
typedef struct _GtkAppChooserWidgetClass GtkAppChooserWidgetClass;
@@ -316,7 +312,7 @@ gtk_app_chooser_sort_func (GtkTreeModel *model,
retval = 1;
goto out;
}
/* the recommended one always wins */
if (a_recommended && !b_recommended)
{
@@ -448,7 +444,7 @@ gtk_app_chooser_widget_add_section (GtkAppChooserWidget *self,
retval = FALSE;
heading_added = FALSE;
bold_string = g_strdup_printf ("<b>%s</b>", heading_title);
for (l = applications; l != NULL; l = l->next)
{
app = l->data;
+4 -7
View File
@@ -35,7 +35,7 @@
* Usually users dont have to interact with the `GtkCellArea` directly
* unless they are implementing a cell-layouting widget themselves.
*
* ## Requesting area sizes
* # Requesting area sizes
*
* As outlined in
* [GtkWidgets geometry management section](class.Widget.html#height-for-width-geometry-management),
@@ -186,7 +186,7 @@
* values while more and more height is required for the row heights
* that are calculated in the background.
*
* ## Rendering Areas
* # Rendering Areas
*
* Once area sizes have been acquired at least for the rows in the
* visible area of the layouting widget they can be rendered at
@@ -227,7 +227,7 @@
* would make sense to calculate the allocation for each row at
* the time the widget is allocated using [func@Gtk.distribute_natural_allocation].
*
* ## Handling Events and Driving Keyboard Focus
* # Handling Events and Driving Keyboard Focus
*
* Passing events to the area is as simple as handling events on any
* normal widget and then passing them to the [method@Gtk.CellArea.event]
@@ -316,7 +316,7 @@
* Note that the layouting widget is responsible for matching the
* `GtkDirectionType` values to the way it lays out its cells.
*
* ## Cell Properties
* # Cell Properties
*
* The `GtkCellArea` introduces cell properties for `GtkCellRenderer`s.
* This provides some general interfaces for defining the relationship
@@ -335,9 +335,6 @@
* [method@Gtk.CellArea.cell_set] or [method@Gtk.CellArea.cell_set_valist]. To obtain
* the value of a cell property, use [method@Gtk.CellArea.cell_get_property]
* [method@Gtk.CellArea.cell_get] or [method@Gtk.CellArea.cell_get_valist].
*
* Deprecated: 4.10: List views use widgets for displaying their
* contents
*/
#include "config.h"
+3 -6
View File
@@ -42,9 +42,6 @@
* configured by configuring the `GtkCellAreaBox` align child cell property
* with gtk_cell_area_cell_set_property() or by specifying the "align"
* argument to gtk_cell_area_box_pack_start() and gtk_cell_area_box_pack_end().
*
* Deprecated: 4.10: List views use widgets for displaying their
* contents
*/
#include "config.h"
@@ -505,7 +502,7 @@ cell_groups_rebuild (GtkCellAreaBox *box)
CellInfo *info = l->data;
/* A new group starts with any aligned cell, or
* at the beginning and end of a fixed size cell.
* at the beginning and end of a fixed size cell.
* the first group is implied */
if ((info->align || info->fixed || last_cell_fixed) && l != cells)
{
@@ -895,7 +892,7 @@ get_allocated_cells (GtkCellAreaBox *box,
if (visible_cells == 0)
continue;
/* If were not aligned, place the cell after the last cell
/* If were not aligned, place the cell after the last cell
* and eat up the extra space
*/
if (group->align)
@@ -2089,7 +2086,7 @@ _gtk_cell_area_box_group_visible (GtkCellAreaBox *box,
{
GtkCellAreaBoxPrivate *priv = gtk_cell_area_box_get_instance_private (box);
CellGroup *group;
g_assert (group_idx >= 0 && group_idx < priv->groups->len);
group = &g_array_index (priv->groups, CellGroup, group_idx);
+11 -11
View File
@@ -139,7 +139,7 @@ get_array (GtkCellAreaBoxContext *context,
return array;
}
static gboolean
static gboolean
group_expands (GtkCellAreaBoxContext *context,
int group_idx)
{
@@ -161,7 +161,7 @@ count_expand_groups (GtkCellAreaBoxContext *context)
if (priv->expand[i])
expand++;
}
return expand;
}
@@ -182,7 +182,7 @@ _gtk_cell_area_box_context_init (GtkCellAreaBoxContext *box_context)
NULL, (GDestroyNotify)free_cache_array);
}
static void
static void
_gtk_cell_area_box_context_class_init (GtkCellAreaBoxContextClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -267,11 +267,11 @@ _gtk_cell_area_box_context_sum (GtkCellAreaBoxContext *context,
box_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (area));
array = get_array (context, orientation, for_size);
/* Get the last visible aligned group
/* Get the last visible aligned group
* (we need to get space at least up till this group) */
for (i = array->len - 1; i >= 0; i--)
{
if (priv->align[i] &&
if (priv->align[i] &&
_gtk_cell_area_box_group_visible (area, i))
break;
}
@@ -326,7 +326,7 @@ _gtk_cell_area_box_context_get_preferred_height_for_width (GtkCellAreaContext *c
int *minimum_height,
int *natural_height)
{
_gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_VERTICAL,
_gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_VERTICAL,
width, minimum_height, natural_height);
}
@@ -336,7 +336,7 @@ _gtk_cell_area_box_context_get_preferred_width_for_height (GtkCellAreaContext *c
int *minimum_width,
int *natural_width)
{
_gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_HORIZONTAL,
_gtk_cell_area_box_context_sum (GTK_CELL_AREA_BOX_CONTEXT (context), GTK_ORIENTATION_HORIZONTAL,
height, minimum_width, natural_width);
}
@@ -686,11 +686,11 @@ _gtk_cell_area_box_context_get_requests (GtkCellAreaBoxContext *box_context,
int last_aligned_group_idx = 0;
int i, j;
/* Get the last visible aligned group
/* Get the last visible aligned group
* (we need to get space at least up till this group) */
for (i = priv->base_widths->len - 1; i >= 0; i--)
{
if (priv->align[i] &&
if (priv->align[i] &&
_gtk_cell_area_box_group_visible (area, i))
break;
}
@@ -846,11 +846,11 @@ _gtk_cell_area_box_context_get_orientation_allocs (GtkCellAreaBoxContext *contex
gtk_cell_area_context_get_allocation (ctx, &width, &height);
if (orientation == GTK_ORIENTATION_HORIZONTAL && width > 0)
allocs = allocate_for_orientation (context, area, orientation,
allocs = allocate_for_orientation (context, area, orientation,
spacing, width, height,
&alloc_count);
else if (orientation == GTK_ORIENTATION_VERTICAL && height > 0)
allocs = allocate_for_orientation (context, area, orientation,
allocs = allocate_for_orientation (context, area, orientation,
spacing, height, width,
&alloc_count);
-3
View File
@@ -23,9 +23,6 @@
* The `GtkCellEditable` interface must be implemented for widgets to be usable
* to edit the contents of a `GtkTreeView` cell. It provides a way to specify how
* temporary widgets should be configured for editing, get the new value, etc.
*
* Deprecated: 4.10: List views use widgets for displaying their
* contents. See [iface@Gtk.Editable] for editable text widgets
*/
#include "config.h"
+8 -11
View File
@@ -24,7 +24,7 @@
* want to provide a `GtkTreeViewColumn` like API for packing cells,
* setting attributes and data funcs.
*
* One of the notable features provided by implementations of
* One of the notable features provided by implementations of
* `GtkCellLayout` are attributes. Attributes let you set the properties
* in flexible ways. They can just be set to constant values like regular
* properties. But they can also be mapped to a column of the underlying
@@ -34,7 +34,7 @@
* gtk_cell_layout_set_cell_data_func() that is called to determine the
* value of the attribute for each cell that is rendered.
*
* ## GtkCellLayouts as GtkBuildable
* # GtkCellLayouts as GtkBuildable
*
* Implementations of GtkCellLayout which also implement the GtkBuildable
* interface (`GtkCellView`, `GtkIconView`, `GtkComboBox`,
@@ -78,7 +78,7 @@
* </object>
* ```
*
* ## Subclassing GtkCellLayout implementations
* # Subclassing GtkCellLayout implementations
*
* When subclassing a widget that implements `GtkCellLayout` like
* `GtkIconView` or `GtkComboBox`, there are some considerations related
@@ -126,9 +126,6 @@
* to support alternative cell areas, you can do so by moving the
* problematic calls out of `init()` and into a `constructor()`
* for your class.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* See [class@Gtk.LayoutManager] for layout manager delegate objects
*/
#include "config.h"
@@ -284,8 +281,8 @@ gtk_cell_layout_default_set_cell_data_func (GtkCellLayout *cell_layout,
area = iface->get_area (cell_layout);
if (area)
_gtk_cell_area_set_cell_data_func_with_proxy (area, cell,
(GFunc)func, func_data, destroy,
_gtk_cell_area_set_cell_data_func_with_proxy (area, cell,
(GFunc)func, func_data, destroy,
cell_layout);
else
warn_no_cell_area ("GtkCellLayoutIface->set_cell_data_func()");
@@ -449,7 +446,7 @@ gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout,
* @cell: a `GtkCellRenderer`
* @...: a %NULL-terminated list of attributes
*
* Sets the attributes in the parameter list as the attributes
* Sets the attributes in the parameter list as the attributes
* of @cell_layout.
*
* See [method@Gtk.CellLayout.add_attribute] for more details.
@@ -534,7 +531,7 @@ gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout,
g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
GTK_CELL_LAYOUT_GET_IFACE
GTK_CELL_LAYOUT_GET_IFACE
(cell_layout)->set_cell_data_func (cell_layout, cell, func, func_data, destroy);
}
@@ -622,7 +619,7 @@ gtk_cell_layout_get_area (GtkCellLayout *cell_layout)
g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);
if (iface->get_area)
return iface->get_area (cell_layout);
+27 -30
View File
@@ -68,9 +68,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* corresponding set property, e.g. cell-background-set corresponds
* to cell-background. These set properties reflect whether a property
* has been set or not. You should not set them independently.
*
* Deprecated: 4.10: List views use widgets for displaying their
* contents
*/
@@ -216,7 +213,7 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
*
* This signal gets emitted when the user cancels the process of editing a
* cell. For example, an editable cell renderer could be written to cancel
* editing when the user presses Escape.
* editing when the user presses Escape.
*
* See also: gtk_cell_renderer_stop_editing().
*/
@@ -254,12 +251,12 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
* const char *path,
* gpointer data)
* {
* if (GTK_IS_ENTRY (editable))
* if (GTK_IS_ENTRY (editable))
* {
* GtkEntry *entry = GTK_ENTRY (editable);
*
*
* // ... create a GtkEntryCompletion
*
*
* gtk_entry_set_completion (entry, completion);
* }
* }
@@ -631,7 +628,7 @@ set_cell_bg_color (GtkCellRenderer *cell,
* @cell: a `GtkCellRenderer`
* @snapshot: a `GtkSnapshot` to draw to
* @widget: the widget owning @window
* @background_area: entire cell area (including tree expanders and maybe
* @background_area: entire cell area (including tree expanders and maybe
* padding on the sides)
* @cell_area: area normally rendered by a cell renderer
* @flags: flags that affect rendering
@@ -805,7 +802,7 @@ gtk_cell_renderer_start_editing (GtkCellRenderer *cell,
gtk_widget_add_css_class (GTK_WIDGET (editable), "cell");
g_signal_emit (cell,
g_signal_emit (cell,
cell_renderer_signals[EDITING_STARTED], 0,
editable, path);
@@ -1199,7 +1196,7 @@ gtk_cell_renderer_real_get_preferred_size (GtkCellRenderer *cell,
}
}
static GtkSizeRequestMode
static GtkSizeRequestMode
gtk_cell_renderer_real_get_request_mode (GtkCellRenderer *cell)
{
/* By default cell renderers are height-for-width. */
@@ -1212,7 +1209,7 @@ gtk_cell_renderer_real_get_preferred_width (GtkCellRenderer *cell,
int *minimum_size,
int *natural_size)
{
gtk_cell_renderer_real_get_preferred_size (cell, widget, GTK_ORIENTATION_HORIZONTAL,
gtk_cell_renderer_real_get_preferred_size (cell, widget, GTK_ORIENTATION_HORIZONTAL,
minimum_size, natural_size);
}
@@ -1222,7 +1219,7 @@ gtk_cell_renderer_real_get_preferred_height (GtkCellRenderer *cell,
int *minimum_size,
int *natural_size)
{
gtk_cell_renderer_real_get_preferred_size (cell, widget, GTK_ORIENTATION_VERTICAL,
gtk_cell_renderer_real_get_preferred_size (cell, widget, GTK_ORIENTATION_VERTICAL,
minimum_size, natural_size);
}
@@ -1271,35 +1268,35 @@ gtk_cell_renderer_real_get_aligned_area (GtkCellRenderer *cell,
/* Trim up the aligned size */
if (gtk_cell_renderer_get_request_mode (cell) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
{
gtk_cell_renderer_get_preferred_width (cell, widget,
gtk_cell_renderer_get_preferred_width (cell, widget,
NULL, &natural_size);
aligned_area->width = MIN (aligned_area->width, natural_size);
gtk_cell_renderer_get_preferred_height_for_width (cell, widget,
aligned_area->width,
gtk_cell_renderer_get_preferred_height_for_width (cell, widget,
aligned_area->width,
NULL, &opposite_size);
aligned_area->height = MIN (opposite_size, aligned_area->height);
}
else
{
gtk_cell_renderer_get_preferred_height (cell, widget,
gtk_cell_renderer_get_preferred_height (cell, widget,
NULL, &natural_size);
aligned_area->height = MIN (aligned_area->width, natural_size);
gtk_cell_renderer_get_preferred_width_for_height (cell, widget,
aligned_area->height,
gtk_cell_renderer_get_preferred_width_for_height (cell, widget,
aligned_area->height,
NULL, &opposite_size);
aligned_area->width = MIN (opposite_size, aligned_area->width);
}
/* offset the cell position */
_gtk_cell_renderer_calc_offset (cell, cell_area,
_gtk_cell_renderer_calc_offset (cell, cell_area,
gtk_widget_get_direction (widget),
aligned_area->width,
aligned_area->width,
aligned_area->height,
&x_offset, &y_offset);
@@ -1322,7 +1319,7 @@ _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
int height,
int *x_offset,
int *y_offset)
{
{
GtkCellRendererPrivate *priv;
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
@@ -1334,7 +1331,7 @@ _gtk_cell_renderer_calc_offset (GtkCellRenderer *cell,
if (x_offset)
{
*x_offset = (((direction == GTK_TEXT_DIR_RTL) ?
(1.0 - priv->xalign) : priv->xalign) *
(1.0 - priv->xalign) : priv->xalign) *
(cell_area->width - width));
*x_offset = MAX (*x_offset, 0);
}
@@ -1406,8 +1403,8 @@ gtk_cell_renderer_get_preferred_width (GtkCellRenderer *cell,
#if DEBUG_CELL_SIZE_REQUEST
g_message ("%s returning minimum width: %d and natural width: %d",
G_OBJECT_TYPE_NAME (cell),
minimum_size ? *minimum_size : 20000,
G_OBJECT_TYPE_NAME (cell),
minimum_size ? *minimum_size : 20000,
natural_size ? *natural_size : 20000);
#endif
}
@@ -1454,8 +1451,8 @@ gtk_cell_renderer_get_preferred_height (GtkCellRenderer *cell,
#if DEBUG_CELL_SIZE_REQUEST
g_message ("%s returning minimum height: %d and natural height: %d",
G_OBJECT_TYPE_NAME (cell),
minimum_size ? *minimum_size : 20000,
G_OBJECT_TYPE_NAME (cell),
minimum_size ? *minimum_size : 20000,
natural_size ? *natural_size : 20000);
#endif
}
@@ -1469,7 +1466,7 @@ gtk_cell_renderer_get_preferred_height (GtkCellRenderer *cell,
* @minimum_width: (out) (optional): location for storing the minimum size
* @natural_width: (out) (optional): location for storing the preferred size
*
* Retrieves a cell rendererss minimum and natural width if it were rendered to
* Retrieves a cell rendererss minimum and natural width if it were rendered to
* @widget with the specified @height.
*
* Deprecated: 4.10
@@ -1506,7 +1503,7 @@ gtk_cell_renderer_get_preferred_width_for_height (GtkCellRenderer *cell,
#if DEBUG_CELL_SIZE_REQUEST
g_message ("%s width for height: %d is minimum %d and natural: %d",
G_OBJECT_TYPE_NAME (cell), height,
minimum_width ? *minimum_width : 20000,
minimum_width ? *minimum_width : 20000,
natural_width ? *natural_width : 20000);
#endif
}
@@ -1519,7 +1516,7 @@ gtk_cell_renderer_get_preferred_width_for_height (GtkCellRenderer *cell,
* @minimum_height: (out) (optional): location for storing the minimum size
* @natural_height: (out) (optional): location for storing the preferred size
*
* Retrieves a cell rendererss minimum and natural height if it were rendered to
* Retrieves a cell rendererss minimum and natural height if it were rendered to
* @widget with the specified @width.
*
* Deprecated: 4.10
@@ -1556,7 +1553,7 @@ gtk_cell_renderer_get_preferred_height_for_width (GtkCellRenderer *cell,
#if DEBUG_CELL_SIZE_REQUEST
g_message ("%s height for width: %d is minimum %d and natural: %d",
G_OBJECT_TYPE_NAME (cell), width,
minimum_height ? *minimum_height : 20000,
minimum_height ? *minimum_height : 20000,
natural_height ? *natural_height : 20000);
#endif
}
+11 -15
View File
@@ -41,10 +41,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* `GtkCellRendererAccel` displays a keyboard accelerator (i.e. a key
* combination like `Control + a`). If the cell renderer is editable,
* the accelerator can be changed by simply typing the new combination.
*
* Deprecated: 4.10: Applications editing keyboard accelerators should
* provide their own implementation according to platform design
* guidelines
*/
@@ -56,7 +52,7 @@ static void gtk_cell_renderer_accel_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_cell_renderer_accel_get_preferred_width
static void gtk_cell_renderer_accel_get_preferred_width
(GtkCellRenderer *cell,
GtkWidget *widget,
int *minimum_size,
@@ -181,7 +177,7 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class)
G_MAXINT,
0,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkCellRendererAccel:accel-mods:
*
@@ -200,7 +196,7 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class)
* The hardware keycode of the accelerator. Note that the hardware keycode is
* only relevant if the key does not have a keyval. Normally, the keyboard
* configuration should assign keyvals to all keys.
*/
*/
g_object_class_install_property (object_class,
PROP_KEYCODE,
g_param_spec_uint ("keycode", NULL, NULL,
@@ -223,7 +219,7 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class)
GTK_TYPE_CELL_RENDERER_ACCEL_MODE,
GTK_CELL_RENDERER_ACCEL_MODE_GTK,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkCellRendererAccel::accel-edited:
* @accel: the object reveiving the signal
@@ -268,7 +264,7 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class)
* gtk_cell_renderer_accel_new:
*
* Creates a new `GtkCellRendererAccel`.
*
*
* Returns: the new cell renderer
*
* Deprecated: 4.10
@@ -292,7 +288,7 @@ convert_keysym_state_to_string (GtkCellRendererAccel *accel,
* a disabled accelerator key combination.
*/
return g_strdup (C_("Accelerator", "Disabled"));
else
else
{
if (priv->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
{
@@ -305,7 +301,7 @@ convert_keysym_state_to_string (GtkCellRendererAccel *accel,
return gtk_accelerator_get_label (keysym, mask);
}
else
else
{
char *name;
@@ -406,7 +402,7 @@ gtk_cell_renderer_accel_set_property (GObject *object,
g_object_notify (object, "accel-mode");
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
}
@@ -541,7 +537,7 @@ key_controller_key_pressed (GtkEventControllerKey *key,
event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (key));
if (!gdk_key_event_get_match (event, &accel_key, &accel_mods))
return FALSE;
if (accel_mods == 0)
{
switch (keyval)
@@ -583,8 +579,8 @@ static void
gtk_cell_editable_widget_unrealize (GtkWidget *widget)
{
gtk_grab_remove (widget);
GTK_WIDGET_CLASS (gtk_cell_editable_widget_parent_class)->unrealize (widget);
GTK_WIDGET_CLASS (gtk_cell_editable_widget_parent_class)->unrealize (widget);
}
static void
+22 -25
View File
@@ -43,9 +43,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* box and sets it to display the column specified by its
* `GtkCellRendererCombo`:text-column property. Further properties of the combo box
* can be set in a handler for the `GtkCellRenderer::editing-started` signal.
*
* Deprecated: 4.10: List views use widgets to display their contents. You
* should use [class@Gtk.DropDown] instead
*/
typedef struct _GtkCellRendererComboPrivate GtkCellRendererComboPrivate;
@@ -128,7 +125,7 @@ gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass)
/**
* GtkCellRendererCombo:model:
*
* Holds a tree model containing the possible values for the combo box.
* Holds a tree model containing the possible values for the combo box.
* Use the text_column property to specify the column holding the values.
*/
g_object_class_install_property (object_class,
@@ -140,14 +137,14 @@ gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass)
/**
* GtkCellRendererCombo:text-column:
*
* Specifies the model column which holds the possible values for the
* combo box.
* Specifies the model column which holds the possible values for the
* combo box.
*
* Note that this refers to the model specified in the model property,
* not the model backing the tree view to which
* Note that this refers to the model specified in the model property,
* not the model backing the tree view to which
* this cell renderer is attached.
*
* `GtkCellRendererCombo` automatically adds a text cell renderer for
*
* `GtkCellRendererCombo` automatically adds a text cell renderer for
* this column to its combo box.
*/
g_object_class_install_property (object_class,
@@ -158,11 +155,11 @@ gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass)
-1,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
/**
* GtkCellRendererCombo:has-entry:
*
* If %TRUE, the cell renderer will include an entry and allow to enter
* values other than the ones in the popup list.
* If %TRUE, the cell renderer will include an entry and allow to enter
* values other than the ones in the popup list.
*/
g_object_class_install_property (object_class,
PROP_HAS_ENTRY,
@@ -235,7 +232,7 @@ gtk_cell_renderer_combo_init (GtkCellRendererCombo *self)
GtkCellRenderer *
gtk_cell_renderer_combo_new (void)
{
return g_object_new (GTK_TYPE_CELL_RENDERER_COMBO, NULL);
return g_object_new (GTK_TYPE_CELL_RENDERER_COMBO, NULL);
}
static void
@@ -243,13 +240,13 @@ gtk_cell_renderer_combo_finalize (GObject *object)
{
GtkCellRendererCombo *cell = GTK_CELL_RENDERER_COMBO (object);
GtkCellRendererComboPrivate *priv = gtk_cell_renderer_combo_get_instance_private (cell);
if (priv->model)
{
g_object_unref (priv->model);
priv->model = NULL;
}
G_OBJECT_CLASS (gtk_cell_renderer_combo_parent_class)->finalize (object);
}
@@ -266,7 +263,7 @@ gtk_cell_renderer_combo_get_property (GObject *object,
{
case PROP_MODEL:
g_value_set_object (value, priv->model);
break;
break;
case PROP_TEXT_COLUMN:
g_value_set_int (value, priv->text_column);
break;
@@ -372,7 +369,7 @@ gtk_cell_renderer_combo_editing_done (GtkCellEditable *combo,
entry = GTK_ENTRY (gtk_combo_box_get_child (GTK_COMBO_BOX (combo)));
new_text = g_strdup (gtk_editable_get_text (GTK_EDITABLE (entry)));
}
else
else
{
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
@@ -398,17 +395,17 @@ gtk_cell_renderer_combo_focus_change (GtkWidget *widget,
gtk_cell_renderer_combo_editing_done (GTK_CELL_EDITABLE (widget), data);
}
typedef struct
typedef struct
{
GtkCellRendererCombo *cell;
gboolean found;
GtkTreeIter iter;
} SearchData;
static gboolean
find_text (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
static gboolean
find_text (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data)
{
SearchData *search_data = (SearchData *)data;
@@ -427,7 +424,7 @@ find_text (GtkTreeModel *model,
g_free (cell_text);
g_free (text);
return search_data->found;
}
@@ -477,7 +474,7 @@ gtk_cell_renderer_combo_start_editing (GtkCellRenderer *cell,
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), priv->model);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
cell, "text", priv->text_column,
NULL);
+8 -11
View File
@@ -48,9 +48,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* renders that pixbuf, if the `GtkCellRenderer:is-expanded` property is %FALSE
* and the `GtkCellRendererPixbuf:pixbuf-expander-closed` property is set to a
* pixbuf, it renders that one.
*
* Deprecated: 4.10: List views use widgets to display their contents. You
* should use [class@Gtk.Image] for icons, and [class@Gtk.Picture] for images
*/
@@ -324,13 +321,13 @@ take_image_definition (GtkCellRendererPixbuf *cellpixbuf,
{
GtkCellRendererPixbufPrivate *priv = gtk_cell_renderer_pixbuf_get_instance_private (cellpixbuf);
GtkImageType old_storage_type, new_storage_type;
if (def == NULL)
def = gtk_image_definition_new_empty ();
old_storage_type = gtk_image_definition_get_storage_type (priv->image_def);
new_storage_type = gtk_image_definition_get_storage_type (def);
if (new_storage_type != old_storage_type)
notify_storage_type (cellpixbuf, old_storage_type);
@@ -404,7 +401,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
/**
* gtk_cell_renderer_pixbuf_new:
*
*
* Creates a new `GtkCellRendererPixbuf`. Adjust rendering
* parameters using object properties. Object properties can be set
* globally (with g_object_set()). Also, with `GtkTreeViewColumn`, you
@@ -412,7 +409,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
* can bind the pixbuf property on the cell renderer to a pixbuf value
* in the model, thus rendering a different image in each row of the
* `GtkTreeView`.
*
*
* Returns: the new cell renderer
*
* Deprecated: 4.10
@@ -472,7 +469,7 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRendererPixbuf *self,
pixbuf_height = gdk_paintable_get_intrinsic_height (paintable);
}
else
pixbuf_width = pixbuf_height = gtk_icon_helper_get_size (icon_helper);
pixbuf_width = pixbuf_height = gtk_icon_helper_get_size (icon_helper);
g_object_unref (icon_helper);
gtk_style_context_restore (context);
@@ -491,7 +488,7 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRendererPixbuf *self,
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
calc_width = (int) xpad * 2 + pixbuf_width;
calc_height = (int) ypad * 2 + pixbuf_height;
if (cell_area && pixbuf_width > 0 && pixbuf_height > 0)
{
float xalign, yalign;
@@ -519,7 +516,7 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRendererPixbuf *self,
if (width)
*width = calc_width;
if (height)
*height = calc_height;
}
@@ -543,7 +540,7 @@ gtk_cell_renderer_pixbuf_snapshot (GtkCellRenderer *cell,
gtk_cell_renderer_pixbuf_get_size (cellpixbuf, widget,
cell_area,
&pix_rect.x,
&pix_rect.x,
&pix_rect.y,
&pix_rect.width,
&pix_rect.height);
-3
View File
@@ -42,9 +42,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
*
* `GtkCellRendererProgress` renders a numeric value as a progress par in a cell.
* Additionally, it can display a text on top of the progress bar.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You should use [class@Gtk.ProgressBar] instead
*/
+5 -6
View File
@@ -47,8 +47,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* of `GtkCellRendererSpin:digits` to display. Other `GtkSpinButton` properties
* can be set in a handler for the `GtkCellRenderer::editing-started` signal.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You should use [class@Gtk.SpinButton] instead
* The `GtkCellRendererSpin` cell renderer was added in GTK 2.10.
*/
typedef struct _GtkCellRendererSpinClass GtkCellRendererSpinClass;
@@ -123,7 +122,7 @@ gtk_cell_renderer_spin_class_init (GtkCellRendererSpinClass *klass)
/**
* GtkCellRendererSpin:adjustment:
*
* The adjustment that holds the value of the spinbutton.
* The adjustment that holds the value of the spinbutton.
* This must be non-%NULL for the cell renderer to be editable.
*/
g_object_class_install_property (object_class,
@@ -142,7 +141,7 @@ gtk_cell_renderer_spin_class_init (GtkCellRendererSpinClass *klass)
PROP_CLIMB_RATE,
g_param_spec_double ("climb-rate", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
GTK_PARAM_READWRITE));
GTK_PARAM_READWRITE));
/**
* GtkCellRendererSpin:digits:
*
@@ -152,7 +151,7 @@ gtk_cell_renderer_spin_class_init (GtkCellRendererSpinClass *klass)
PROP_DIGITS,
g_param_spec_uint ("digits", NULL, NULL,
0, 20, 0,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
}
static void
@@ -367,7 +366,7 @@ gtk_cell_renderer_spin_start_editing (GtkCellRenderer *cell,
/**
* gtk_cell_renderer_spin_new:
*
* Creates a new `GtkCellRendererSpin`.
* Creates a new `GtkCellRendererSpin`.
*
* Returns: a new `GtkCellRendererSpin`
*
-3
View File
@@ -54,9 +54,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* at regular intervals. The usual way to set the cell renderer properties
* for each cell is to bind them to columns in your tree model using e.g.
* gtk_tree_view_column_add_attribute().
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You should use [class@Gtk.Spinner] instead
*/
+24 -27
View File
@@ -45,9 +45,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
*
* If the `GtkCellRenderer:mode` is %GTK_CELL_RENDERER_MODE_EDITABLE,
* the `GtkCellRendererText` allows to edit its text using an entry.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You should use [class@Gtk.Inscription] or [class@Gtk.Label] instead
*/
@@ -241,7 +238,7 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class)
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
object_class->finalize = gtk_cell_renderer_text_finalize;
object_class->get_property = gtk_cell_renderer_text_get_property;
object_class->set_property = gtk_cell_renderer_text_set_property;
@@ -626,7 +623,7 @@ gtk_cell_renderer_text_get_property (GObject *object,
case PROP_FONT:
g_value_take_string (value, pango_font_description_to_string (priv->font));
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, priv->font);
break;
@@ -662,7 +659,7 @@ gtk_cell_renderer_text_get_property (GObject *object,
case PROP_SCALE:
g_value_set_double (value, priv->font_scale);
break;
case PROP_EDITABLE:
g_value_set_boolean (value, priv->editable);
break;
@@ -677,7 +674,7 @@ gtk_cell_renderer_text_get_property (GObject *object,
case PROP_RISE:
g_value_set_int (value, priv->rise);
break;
break;
case PROP_LANGUAGE:
g_value_set_static_string (value, pango_language_to_string (priv->language));
@@ -686,7 +683,7 @@ gtk_cell_renderer_text_get_property (GObject *object,
case PROP_ELLIPSIZE:
g_value_set_enum (value, priv->ellipsize);
break;
case PROP_WRAP_MODE:
g_value_set_enum (value, priv->wrap_mode);
break;
@@ -694,7 +691,7 @@ gtk_cell_renderer_text_get_property (GObject *object,
case PROP_WRAP_WIDTH:
g_value_set_int (value, priv->wrap_width);
break;
case PROP_ALIGN:
g_value_set_enum (value, priv->align);
break;
@@ -716,14 +713,14 @@ gtk_cell_renderer_text_get_property (GObject *object,
{
PangoFontMask mask = get_property_font_set_mask (param_id);
g_value_set_boolean (value, (pango_font_description_get_set_fields (priv->font) & mask) != 0);
break;
}
case PROP_SCALE_SET:
g_value_set_boolean (value, priv->scale_set);
break;
case PROP_EDITABLE_SET:
g_value_set_boolean (value, priv->editable_set);
break;
@@ -751,14 +748,14 @@ gtk_cell_renderer_text_get_property (GObject *object,
case PROP_ALIGN_SET:
g_value_set_boolean (value, priv->align_set);
break;
case PROP_WIDTH_CHARS:
g_value_set_int (value, priv->width_chars);
break;
break;
case PROP_MAX_WIDTH_CHARS:
g_value_set_int (value, priv->max_width_chars);
break;
break;
case PROP_PLACEHOLDER_TEXT:
g_value_set_string (value, priv->placeholder_text);
@@ -831,7 +828,7 @@ set_font_desc_fields (PangoFontDescription *desc,
PangoFontMask to_set)
{
PangoFontMask changed_mask = 0;
if (to_set & PANGO_FONT_MASK_FAMILY)
{
const char *family = pango_font_description_get_family (desc);
@@ -859,7 +856,7 @@ set_font_desc_fields (PangoFontDescription *desc,
size = 10 * PANGO_SCALE;
changed_mask |= PANGO_FONT_MASK_SIZE;
}
pango_font_description_set_size (desc, size);
}
@@ -1293,7 +1290,7 @@ gtk_cell_renderer_text_set_property (GObject *object,
/**
* gtk_cell_renderer_text_new:
*
*
* Creates a new `GtkCellRendererText`. Adjust how text is drawn using
* object properties. Object properties can be
* set globally (with g_object_set()). Also, with `GtkTreeViewColumn`,
@@ -1301,7 +1298,7 @@ gtk_cell_renderer_text_set_property (GObject *object,
* you can bind the text property on the cell renderer to a string
* value in the model, thus rendering a different string in each row
* of the `GtkTreeView`.
*
*
* Returns: the new cell renderer
*
* Deprecated: 4.10
@@ -1327,7 +1324,7 @@ add_attr (PangoAttrList *attr_list,
{
attr->start_index = 0;
attr->end_index = G_MAXINT;
pango_attr_list_insert (attr_list, attr);
}
@@ -1359,11 +1356,11 @@ get_layout (GtkCellRendererText *celltext,
if (!placeholder_layout && cell_area)
{
/* Add options that affect appearance but not size */
/* note that background doesn't go here, since it affects
* background_area not the PangoLayout area
*/
if (priv->foreground_set
&& (flags & GTK_CELL_RENDERER_SELECTED) == 0)
{
@@ -1500,7 +1497,7 @@ get_layout (GtkCellRendererText *celltext,
pango_layout_set_alignment (layout, align);
}
return layout;
}
@@ -1557,7 +1554,7 @@ get_size (GtkCellRenderer *cell,
gtk_cell_renderer_set_fixed_size (cell,
cell_width, 2 * ypad +
priv->fixed_height_rows * PANGO_PIXELS (row_height));
if (height)
{
*height = cell_height;
@@ -1734,7 +1731,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
if (priv->text)
gtk_editable_set_text (GTK_EDITABLE (priv->entry), priv->text);
g_object_set_data_full (G_OBJECT (priv->entry), I_(GTK_CELL_RENDERER_TEXT_PATH), g_strdup (path), g_free);
gtk_editable_select_region (GTK_EDITABLE (priv->entry), 0, -1);
priv->in_entry_menu = FALSE;
@@ -1757,7 +1754,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
* gtk_cell_renderer_text_set_fixed_height_from_font:
* @renderer: A `GtkCellRendererText`
* @number_of_rows: Number of rows of text each cell renderer is allocated, or -1
*
*
* Sets the height of a renderer to explicitly be determined by the font and
* y_pad property set on it. Further changes in these properties do not
* affect the height, so they must be accompanied by a subsequent call to this
@@ -1862,7 +1859,7 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
if (priv->max_width_chars > 0)
{
int max_width = xpad * 2 + PANGO_PIXELS (char_width) * priv->max_width_chars;
min_width = MIN (min_width, max_width);
nat_width = MIN (nat_width, max_width);
}
@@ -1934,7 +1931,7 @@ gtk_cell_renderer_text_get_aligned_area (GtkCellRenderer *cell,
int y_offset = 0;
layout = get_layout (celltext, widget, cell_area, flags);
get_size (cell, widget, cell_area, layout, &x_offset, &y_offset,
get_size (cell, widget, cell_area, layout, &x_offset, &y_offset,
&aligned_area->width, &aligned_area->height);
aligned_area->x = cell_area->x + x_offset;
+9 -12
View File
@@ -42,9 +42,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* button is drawn as a radio or a checkbutton, depending on the
* `GtkCellRendererToggle:radio` property.
* When activated, it emits the `GtkCellRendererToggle::toggled` signal.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You should use [class@Gtk.ToggleButton] instead
*/
@@ -193,7 +190,7 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
cell_class->get_preferred_height = gtk_cell_renderer_toggle_get_preferred_height;
cell_class->snapshot = gtk_cell_renderer_toggle_snapshot;
cell_class->activate = gtk_cell_renderer_toggle_activate;
g_object_class_install_property (object_class,
PROP_ACTIVE,
g_param_spec_boolean ("active", NULL, NULL,
@@ -205,7 +202,7 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
g_param_spec_boolean ("inconsistent", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
g_object_class_install_property (object_class,
PROP_ACTIVATABLE,
g_param_spec_boolean ("activatable", NULL, NULL,
@@ -218,14 +215,14 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkCellRendererToggle::toggled:
* @cell_renderer: the object which received the signal
* @path: string representation of `GtkTreePath` describing the
* @path: string representation of `GtkTreePath` describing the
* event location
*
* The ::toggled signal is emitted when the cell is toggled.
* The ::toggled signal is emitted when the cell is toggled.
*
* It is the responsibility of the application to update the model
* with the correct value to store at @path. Often this is simply the
@@ -470,7 +467,7 @@ gtk_cell_renderer_toggle_snapshot (GtkCellRenderer *cell,
if (priv->inconsistent)
state |= GTK_STATE_FLAG_INCONSISTENT;
if (priv->active)
state |= GTK_STATE_FLAG_CHECKED;
@@ -531,7 +528,7 @@ gtk_cell_renderer_toggle_activate (GtkCellRenderer *cell,
* gtk_cell_renderer_toggle_set_radio:
* @toggle: a `GtkCellRendererToggle`
* @radio: %TRUE to make the toggle look like a radio button
*
*
* If @radio is %TRUE, the cell renderer renders a radio toggle
* (i.e. a toggle in a group of mutually-exclusive toggles).
* If %FALSE, it renders a check toggle (a standalone boolean option).
@@ -557,8 +554,8 @@ gtk_cell_renderer_toggle_set_radio (GtkCellRendererToggle *toggle,
* gtk_cell_renderer_toggle_get_radio:
* @toggle: a `GtkCellRendererToggle`
*
* Returns whether were rendering radio toggles rather than checkboxes.
*
* Returns whether were rendering radio toggles rather than checkboxes.
*
* Returns: %TRUE if were rendering radio toggles rather than checkboxes
*
* Deprecated: 4.10
+16 -19
View File
@@ -40,7 +40,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* A widget displaying a single row of a GtkTreeModel
*
* A `GtkCellView` displays a single row of a `GtkTreeModel` using a `GtkCellArea`
* and `GtkCellAreaContext`. A `GtkCellAreaContext` can be provided to the
* and `GtkCellAreaContext`. A `GtkCellAreaContext` can be provided to the
* `GtkCellView` at construction time in order to keep the cellview in context
* of a group of cell views, this ensures that the renderers displayed will
* be properly aligned with each other (like the aligned cells in the menus
@@ -53,12 +53,9 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* individual heights (left-to-right menus should be allocated vertically since
* they all share the same height but may have variable widths).
*
* ## CSS nodes
* # CSS nodes
*
* GtkCellView has a single CSS node with name cellview.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You can use [class@Gtk.Box] instead
*/
static void gtk_cell_view_constructed (GObject *object);
@@ -209,7 +206,7 @@ gtk_cell_view_class_init (GtkCellViewClass *klass)
*
* The `GtkCellArea` rendering cells
*
* If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
* If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
* a horizontally oriented `GtkCellArea`Box will be used.
*
* since 3.0
@@ -527,19 +524,19 @@ gtk_cell_view_request_model (GtkCellView *cellview,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (for_size < 0)
gtk_cell_area_get_preferred_width (priv->area, priv->context,
gtk_cell_area_get_preferred_width (priv->area, priv->context,
GTK_WIDGET (cellview), &min, &nat);
else
gtk_cell_area_get_preferred_width_for_height (priv->area, priv->context,
gtk_cell_area_get_preferred_width_for_height (priv->area, priv->context,
GTK_WIDGET (cellview), for_size, &min, &nat);
}
else
{
if (for_size < 0)
gtk_cell_area_get_preferred_height (priv->area, priv->context,
gtk_cell_area_get_preferred_height (priv->area, priv->context,
GTK_WIDGET (cellview), &min, &nat);
else
gtk_cell_area_get_preferred_height_for_width (priv->area, priv->context,
gtk_cell_area_get_preferred_height_for_width (priv->area, priv->context,
GTK_WIDGET (cellview), for_size, &min, &nat);
}
@@ -553,7 +550,7 @@ gtk_cell_view_request_model (GtkCellView *cellview,
}
}
static GtkSizeRequestMode
static GtkSizeRequestMode
gtk_cell_view_get_request_mode (GtkWidget *widget)
{
GtkCellView *cellview = GTK_CELL_VIEW (widget);
@@ -701,13 +698,13 @@ gtk_cell_view_set_cell_data (GtkCellView *cell_view)
gtk_tree_model_get_iter (priv->model, &iter, path);
gtk_tree_path_free (path);
gtk_cell_area_apply_attributes (priv->area,
priv->model,
gtk_cell_area_apply_attributes (priv->area,
priv->model,
&iter, FALSE, FALSE);
if (priv->draw_sensitive)
{
GList *l, *cells =
GList *l, *cells =
gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->area));
for (l = cells; l; l = l->next)
@@ -849,7 +846,7 @@ gtk_cell_view_new_with_context (GtkCellArea *area,
g_return_val_if_fail (GTK_IS_CELL_AREA (area), NULL);
g_return_val_if_fail (context == NULL || GTK_IS_CELL_AREA_CONTEXT (context), NULL);
return (GtkWidget *)g_object_new (GTK_TYPE_CELL_VIEW,
return (GtkWidget *)g_object_new (GTK_TYPE_CELL_VIEW,
"cell-area", area,
"cell-area-context", context,
NULL);
@@ -958,7 +955,7 @@ gtk_cell_view_new_with_texture (GdkTexture *texture)
* @renderer: one of the renderers of @cell_view
* @property: the name of the property of @renderer to set
* @value: the new value to set the property to
*
*
* Sets a property of a cell renderer of @cell_view, and
* makes sure the display of @cell_view is updated.
*
@@ -1015,7 +1012,7 @@ gtk_cell_view_set_model (GtkCellView *cell_view,
{
g_object_ref (priv->model);
priv->row_changed_id =
priv->row_changed_id =
g_signal_connect (priv->model, "row-changed",
G_CALLBACK (row_changed_cb), cell_view);
}
@@ -1082,8 +1079,8 @@ gtk_cell_view_set_displayed_row (GtkCellView *cell_view,
* gtk_cell_view_get_displayed_row:
* @cell_view: a `GtkCellView`
*
* Returns a `GtkTreePath` referring to the currently
* displayed row. If no row is currently displayed,
* Returns a `GtkTreePath` referring to the currently
* displayed row. If no row is currently displayed,
* %NULL is returned.
*
* Returns: (nullable) (transfer full): the currently displayed row
+32 -34
View File
@@ -104,11 +104,9 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* a button, both with the .combo class added. The button also contains another
* node with name arrow.
*
* ## Accessibility
* # Accessibility
*
* `GtkComboBox` uses the %GTK_ACCESSIBLE_ROLE_COMBO_BOX role.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown] instead
*/
typedef struct
@@ -1375,7 +1373,7 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box)
*
* Before calling this, @combo_box must be mapped, or nothing will happen.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_popup (GtkComboBox *combo_box)
@@ -1398,7 +1396,7 @@ gtk_combo_box_popup (GtkComboBox *combo_box)
* in GTK 4. However, it is retained in case similar functionality is added
* back later.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
@@ -1449,7 +1447,7 @@ gtk_combo_box_real_popdown (GtkComboBox *combo_box)
* This function is mostly intended for use by accessibility technologies;
* applications should have little use for it.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_popdown (GtkComboBox *combo_box)
@@ -1853,7 +1851,7 @@ gtk_combo_box_cell_layout_get_area (GtkCellLayout *cell_layout)
*
* Returns: A new `GtkComboBox`
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_new (void)
@@ -1868,11 +1866,11 @@ gtk_combo_box_new (void)
*
* In order to use a combo box with entry, you need to tell it
* which column of the model contains the text for the entry
* by calling [method@Gtk.ComboBox.set_entry_text_column].
* by calling [method@Gtk.ComboBox.set_entry_text_column].
*
* Returns: A new `GtkComboBox`
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_new_with_entry (void)
@@ -1888,7 +1886,7 @@ gtk_combo_box_new_with_entry (void)
*
* Returns: A new `GtkComboBox`
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_new_with_model (GtkTreeModel *model)
@@ -1912,7 +1910,7 @@ gtk_combo_box_new_with_model (GtkTreeModel *model)
*
* Returns: A new `GtkComboBox`
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model)
@@ -1937,7 +1935,7 @@ gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model)
* Returns: An integer which is the index of the currently active item,
* or -1 if theres no active item
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
int
gtk_combo_box_get_active (GtkComboBox *combo_box)
@@ -1969,7 +1967,7 @@ gtk_combo_box_get_active (GtkComboBox *combo_box)
*
* Sets the active item of @combo_box to be the item at @index.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_active (GtkComboBox *combo_box,
@@ -2068,7 +2066,7 @@ gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
*
* Returns: %TRUE if @iter was set, %FALSE otherwise
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
gboolean
gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
@@ -2099,7 +2097,7 @@ gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
*
* If @iter is %NULL, the active item is unset.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
@@ -2130,7 +2128,7 @@ gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
* call [method@Gtk.CellLayout.clear] yourself if you need to set up different
* cell renderers for the new model.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_model (GtkComboBox *combo_box,
@@ -2193,7 +2191,7 @@ out:
* Returns: (nullable) (transfer none): A `GtkTreeModel` which was passed
* during construction.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkTreeModel *
gtk_combo_box_get_model (GtkComboBox *combo_box)
@@ -2552,7 +2550,7 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
* If @fixed is %TRUE, the popup's width is set to match the
* allocated width of the combo box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
@@ -2578,7 +2576,7 @@ gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
*
* Returns: %TRUE if the popup uses a fixed width
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
gboolean
gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box)
@@ -2598,7 +2596,7 @@ gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box)
*
* Returns: (nullable): the current row separator function.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkTreeViewRowSeparatorFunc
gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box)
@@ -2623,7 +2621,7 @@ gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box)
* If the row separator function is %NULL, no separators are drawn.
* This is the default value.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box,
@@ -2657,7 +2655,7 @@ gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box,
* Sets whether the dropdown button of the combo box should update
* its sensitivity depending on the model contents.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
@@ -2689,7 +2687,7 @@ gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
* if it is only sensitive as long as the model has one item to
* be selected.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkSensitivityType
gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
@@ -2709,7 +2707,7 @@ gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
*
* Returns: whether there is an entry in @combo_box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
gboolean
gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
@@ -2727,9 +2725,9 @@ gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
* the internal entry
*
* Sets the model column which @combo_box should use to get strings
* from to be @text_column.
* from to be @text_column.
*
* For this column no separate
* For this column no separate
* [class@Gtk.CellRenderer] is needed.
*
* The column @text_column in the model of @combo_box must be of
@@ -2738,7 +2736,7 @@ gtk_combo_box_get_has_entry (GtkComboBox *combo_box)
* This is only relevant if @combo_box has been created with
* [property@Gtk.ComboBox:has-entry] as %TRUE.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
@@ -2773,7 +2771,7 @@ gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
*
* Returns: A column in the data source model of @combo_box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
int
gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box)
@@ -2851,7 +2849,7 @@ gtk_combo_box_buildable_get_internal_child (GtkBuildable *buildable,
* The column @id_column in the model of @combo_box must be of type
* %G_TYPE_STRING.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_id_column (GtkComboBox *combo_box,
@@ -2882,7 +2880,7 @@ gtk_combo_box_set_id_column (GtkComboBox *combo_box,
*
* Returns: A column in the data source model of @combo_box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
int
gtk_combo_box_get_id_column (GtkComboBox *combo_box)
@@ -2914,7 +2912,7 @@ gtk_combo_box_get_id_column (GtkComboBox *combo_box)
*
* Returns: (nullable): the ID of the active row
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
const char *
gtk_combo_box_get_active_id (GtkComboBox *combo_box)
@@ -2969,7 +2967,7 @@ gtk_combo_box_get_active_id (GtkComboBox *combo_box)
* @active_id was given to unset the active row, the function
* always returns %TRUE.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
gboolean
gtk_combo_box_set_active_id (GtkComboBox *combo_box,
@@ -3034,7 +3032,7 @@ gtk_combo_box_get_popup (GtkComboBox *combo_box)
*
* Sets the child widget of @combo_box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_set_child (GtkComboBox *combo_box,
@@ -3062,7 +3060,7 @@ gtk_combo_box_set_child (GtkComboBox *combo_box,
*
* Returns: (nullable) (transfer none): the child widget of @combo_box
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_get_child (GtkComboBox *combo_box)
+28 -28
View File
@@ -71,87 +71,87 @@ struct _GtkComboBoxClass
/* construction */
GDK_AVAILABLE_IN_ALL
GType gtk_combo_box_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_combo_box_new (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_combo_box_new_with_entry (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_combo_box_new_with_model (GtkTreeModel *model);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_combo_box_new_with_model_and_entry (GtkTreeModel *model);
/* get/set active item */
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
int gtk_combo_box_get_active (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_active (GtkComboBox *combo_box,
int index_);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
GtkTreeIter *iter);
/* getters and setters */
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_model (GtkComboBox *combo_box,
GtkTreeModel *model);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_combo_box_get_model (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box,
GtkTreeViewRowSeparatorFunc func,
gpointer data,
GDestroyNotify destroy);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
GtkSensitivityType sensitivity);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkSensitivityType gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
gboolean gtk_combo_box_get_has_entry (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_entry_text_column (GtkComboBox *combo_box,
int text_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
int gtk_combo_box_get_entry_text_column (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_popup_fixed_width (GtkComboBox *combo_box,
gboolean fixed);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
gboolean gtk_combo_box_get_popup_fixed_width (GtkComboBox *combo_box);
/* programmatic control */
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_popup (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
GdkDevice *device);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_popdown (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
int gtk_combo_box_get_id_column (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_id_column (GtkComboBox *combo_box,
int id_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
const char * gtk_combo_box_get_active_id (GtkComboBox *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
gboolean gtk_combo_box_set_active_id (GtkComboBox *combo_box,
const char *active_id);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_set_child (GtkComboBox *combo_box,
GtkWidget *child);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown)
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_combo_box_get_child (GtkComboBox *combo_box);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkComboBox, g_object_unref)
+13 -16
View File
@@ -56,7 +56,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* You should not call [method@Gtk.ComboBox.set_model] or attempt to pack more
* cells into this combo box via its [iface@Gtk.CellLayout] interface.
*
* ## GtkComboBoxText as GtkBuildable
* # GtkComboBoxText as GtkBuildable
*
* The `GtkComboBoxText` implementation of the `GtkBuildable` interface supports
* adding items directly using the <items> element and specifying <item>
@@ -75,7 +75,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* </object>
* ```
*
* ## CSS nodes
* # CSS nodes
*
* ```
* combobox
@@ -88,9 +88,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* `GtkComboBoxText` has a single CSS node with name combobox. It adds
* the style class .combo to the main CSS nodes of its entry and button
* children, and the .linked class to the node of its internal box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown] with a [class@Gtk.StringList]
* instead
*/
typedef struct _GtkComboBoxTextClass GtkComboBoxTextClass;
@@ -356,7 +353,7 @@ gtk_combo_box_text_buildable_custom_finished (GtkBuildable *buildable,
*
* Returns: A new `GtkComboBoxText`
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_text_new (void)
@@ -372,7 +369,7 @@ gtk_combo_box_text_new (void)
*
* Returns: a new `GtkComboBoxText`
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
GtkWidget *
gtk_combo_box_text_new_with_entry (void)
@@ -392,7 +389,7 @@ gtk_combo_box_text_new_with_entry (void)
* This is the same as calling [method@Gtk.ComboBoxText.insert_text]
* with a position of -1.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
@@ -411,7 +408,7 @@ gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
* This is the same as calling [method@Gtk.ComboBoxText.insert_text]
* with a position of 0.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box,
@@ -433,7 +430,7 @@ gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box,
* This is the same as calling [method@Gtk.ComboBoxText.insert]
* with a %NULL ID string.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box,
@@ -456,7 +453,7 @@ gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box,
* This is the same as calling [method@Gtk.ComboBoxText.insert]
* with a position of -1.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_append (GtkComboBoxText *combo_box,
@@ -479,7 +476,7 @@ gtk_combo_box_text_append (GtkComboBoxText *combo_box,
* This is the same as calling [method@Gtk.ComboBoxText.insert]
* with a position of 0.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_prepend (GtkComboBoxText *combo_box,
@@ -504,7 +501,7 @@ gtk_combo_box_text_prepend (GtkComboBoxText *combo_box,
*
* If @position is negative then @text is appended.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_insert (GtkComboBoxText *combo_box,
@@ -557,7 +554,7 @@ gtk_combo_box_text_insert (GtkComboBoxText *combo_box,
*
* Removes the string at @position from @combo_box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_remove (GtkComboBoxText *combo_box,
@@ -584,7 +581,7 @@ gtk_combo_box_text_remove (GtkComboBoxText *combo_box,
*
* Removes all the text entries from the combo box.
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
void
gtk_combo_box_text_remove_all (GtkComboBoxText *combo_box)
@@ -612,7 +609,7 @@ gtk_combo_box_text_remove_all (GtkComboBoxText *combo_box)
* string containing the currently active text.
* Must be freed with g_free().
*
* Deprecated: 4.10: Use [class@Gtk.DropDown]
* Deprecated: 4.10: Use GtkDropDown
*/
char *
gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box)
+11 -11
View File
@@ -35,38 +35,38 @@ typedef struct _GtkComboBoxText GtkComboBoxText;
GDK_AVAILABLE_IN_ALL
GType gtk_combo_box_text_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_combo_box_text_new (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
GtkWidget* gtk_combo_box_text_new_with_entry (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_append_text (GtkComboBoxText *combo_box,
const char *text);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_insert_text (GtkComboBoxText *combo_box,
int position,
const char *text);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_prepend_text (GtkComboBoxText *combo_box,
const char *text);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_remove (GtkComboBoxText *combo_box,
int position);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_remove_all (GtkComboBoxText *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
char *gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_insert (GtkComboBoxText *combo_box,
int position,
const char *id,
const char *text);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_append (GtkComboBoxText *combo_box,
const char *id,
const char *text);
GDK_DEPRECATED_IN_4_10_FOR(GtkDropDown and GtkStringList)
GDK_DEPRECATED_IN_4_10
void gtk_combo_box_text_prepend (GtkComboBoxText *combo_box,
const char *id,
const char *text);
+22 -19
View File
@@ -56,8 +56,6 @@
* [method@Gtk.TreeModelFilter.get_model]. Dont forget to use
* [method@Gtk.TreeModelFilter.convert_iter_to_child_iter] to obtain a
* matching iter.
*
* Deprecated: 4.10
*/
#include "config.h"
@@ -436,7 +434,6 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
completion->inline_selection = FALSE;
completion->filter_model = NULL;
completion->insert_text_signal_group = NULL;
}
static gboolean
@@ -1385,12 +1382,13 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
{
int len;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
if (completion->changed_id > 0)
g_signal_handler_block (text, completion->changed_id);
if (completion->insert_text_signal_group != NULL)
g_signal_group_block (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_block (buffer, completion->insert_text_id);
gtk_editable_set_text (GTK_EDITABLE (completion->entry), new_text);
@@ -1400,8 +1398,8 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
if (completion->changed_id > 0)
g_signal_handler_unblock (text, completion->changed_id);
if (completion->insert_text_signal_group != NULL)
g_signal_group_unblock (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_unblock (buffer, completion->insert_text_id);
}
static gboolean
@@ -1440,9 +1438,11 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
gboolean done;
char *prefix;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
if (completion->insert_text_signal_group != NULL)
g_signal_group_block (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_block (buffer, completion->insert_text_id);
prefix = gtk_entry_completion_compute_prefix (completion,
gtk_editable_get_text (GTK_EDITABLE (completion->entry)));
@@ -1454,8 +1454,8 @@ gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
g_free (prefix);
}
if (completion->insert_text_signal_group != NULL)
g_signal_group_unblock (completion->insert_text_signal_group);
if (completion->insert_text_id > 0)
g_signal_handler_unblock (buffer, completion->insert_text_id);
}
/**
@@ -2028,7 +2028,7 @@ static gboolean
check_completion_callback (GtkEntryCompletion *completion)
{
completion->check_completion_idle = NULL;
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
@@ -2096,6 +2096,7 @@ connect_completion_signals (GtkEntryCompletion *completion)
{
GtkEventController *controller;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
controller = completion->entry_key_controller = gtk_event_controller_key_new ();
gtk_event_controller_set_static_name (controller, "gtk-entry-completion");
@@ -2110,10 +2111,8 @@ connect_completion_signals (GtkEntryCompletion *completion)
completion->changed_id =
g_signal_connect (text, "changed", G_CALLBACK (gtk_entry_completion_changed), completion);
completion->insert_text_signal_group = g_signal_group_new (GTK_TYPE_ENTRY_BUFFER);
g_signal_group_connect (completion->insert_text_signal_group, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
g_object_bind_property (text, "buffer", completion->insert_text_signal_group, "target", G_BINDING_SYNC_CREATE);
completion->insert_text_id =
g_signal_connect (buffer, "inserted-text", G_CALLBACK (completion_inserted_text_callback), completion);
g_signal_connect (text, "notify", G_CALLBACK (clear_completion_callback), completion);
g_signal_connect_swapped (text, "activate", G_CALLBACK (accept_completion_callback), completion);
}
@@ -2122,6 +2121,7 @@ static void
disconnect_completion_signals (GtkEntryCompletion *completion)
{
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
GtkEntryBuffer *buffer = gtk_text_get_buffer (text);
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_key_controller);
gtk_widget_remove_controller (GTK_WIDGET (text), completion->entry_focus_controller);
@@ -2132,9 +2132,12 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
g_signal_handler_disconnect (text, completion->changed_id);
completion->changed_id = 0;
}
g_clear_object (&completion->insert_text_signal_group);
if (completion->insert_text_id > 0 &&
g_signal_handler_is_connected (buffer, completion->insert_text_id))
{
g_signal_handler_disconnect (buffer, completion->insert_text_id);
completion->insert_text_id = 0;
}
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (clear_completion_callback), completion);
g_signal_handlers_disconnect_by_func (text, G_CALLBACK (accept_completion_callback), completion);
}
File diff suppressed because it is too large Load Diff
+63 -63
View File
@@ -74,138 +74,138 @@ typedef enum
GDK_AVAILABLE_IN_ALL
GType gtk_icon_view_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_icon_view_new (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_icon_view_new_with_area (GtkCellArea *area);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_icon_view_new_with_model (GtkTreeModel *model);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_model (GtkIconView *icon_view,
GtkTreeModel *model);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkTreeModel * gtk_icon_view_get_model (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_text_column (GtkIconView *icon_view,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_text_column (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_markup_column (GtkIconView *icon_view,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_markup_column (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_pixbuf_column (GtkIconView *icon_view,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_pixbuf_column (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_item_orientation (GtkIconView *icon_view,
GtkOrientation orientation);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkOrientation gtk_icon_view_get_item_orientation (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_columns (GtkIconView *icon_view,
int columns);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_columns (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_item_width (GtkIconView *icon_view,
int item_width);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_item_width (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_spacing (GtkIconView *icon_view,
int spacing);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_spacing (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_row_spacing (GtkIconView *icon_view,
int row_spacing);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_row_spacing (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_column_spacing (GtkIconView *icon_view,
int column_spacing);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_column_spacing (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_margin (GtkIconView *icon_view,
int margin);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_margin (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_item_padding (GtkIconView *icon_view,
int item_padding);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_item_padding (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkTreePath * gtk_icon_view_get_path_at_pos (GtkIconView *icon_view,
int x,
int y);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_item_at_pos (GtkIconView *icon_view,
int x,
int y,
GtkTreePath **path,
GtkCellRenderer **cell);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_visible_range (GtkIconView *icon_view,
GtkTreePath **start_path,
GtkTreePath **end_path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_activate_on_single_click (GtkIconView *icon_view,
gboolean single);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_activate_on_single_click (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_selected_foreach (GtkIconView *icon_view,
GtkIconViewForeachFunc func,
gpointer data);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_selection_mode (GtkIconView *icon_view,
GtkSelectionMode mode);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GtkSelectionMode gtk_icon_view_get_selection_mode (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_select_path (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_unselect_path (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_path_is_selected (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_item_row (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_item_column (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GList *gtk_icon_view_get_selected_items (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_select_all (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_unselect_all (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_item_activated (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_cursor (GtkIconView *icon_view,
GtkTreePath *path,
GtkCellRenderer *cell,
gboolean start_editing);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_cursor (GtkIconView *icon_view,
GtkTreePath **path,
GtkCellRenderer **cell);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
GtkTreePath *path,
gboolean use_align,
@@ -213,62 +213,62 @@ void gtk_icon_view_scroll_to_path (GtkIconView *icon_
float col_align);
/* Drag-and-Drop support */
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
GdkModifierType start_button_mask,
GdkContentFormats *formats,
GdkDragAction actions);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
GdkContentFormats *formats,
GdkDragAction actions);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_reorderable (GtkIconView *icon_view,
gboolean reorderable);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_reorderable (GtkIconView *icon_view);
/* These are useful to implement your own custom stuff. */
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_drag_dest_item (GtkIconView *icon_view,
GtkTreePath *path,
GtkIconViewDropPosition pos);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_get_drag_dest_item (GtkIconView *icon_view,
GtkTreePath **path,
GtkIconViewDropPosition *pos);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_dest_item_at_pos (GtkIconView *icon_view,
int drag_x,
int drag_y,
GtkTreePath **path,
GtkIconViewDropPosition *pos);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
GdkPaintable *gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_cell_rect (GtkIconView *icon_view,
GtkTreePath *path,
GtkCellRenderer *cell,
GdkRectangle *rect);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_tooltip_item (GtkIconView *icon_view,
GtkTooltip *tooltip,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_tooltip_cell (GtkIconView *icon_view,
GtkTooltip *tooltip,
GtkTreePath *path,
GtkCellRenderer *cell);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_icon_view_get_tooltip_context (GtkIconView *icon_view,
int x,
int y,
@@ -276,10 +276,10 @@ gboolean gtk_icon_view_get_tooltip_context (GtkIconView
GtkTreeModel **model,
GtkTreePath **path,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
void gtk_icon_view_set_tooltip_column (GtkIconView *icon_view,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkGridView)
GDK_DEPRECATED_IN_4_10
int gtk_icon_view_get_tooltip_column (GtkIconView *icon_view);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconView, g_object_unref)
+60 -82
View File
@@ -104,11 +104,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* }
* ```
*
* `GtkListStore` is deprecated since GTK 4.10, and should not be used in newly
* written code. You should use [class@Gio.ListStore] instead, and the various
* list models provided by GTK.
*
* ## Performance Considerations
* # Performance Considerations
*
* Internally, the `GtkListStore` was originally implemented with a linked list
* with a tail pointer. As a result, it was fast at data insertion and deletion,
@@ -118,7 +114,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* often and your code is expected to run on older versions of GTK, it is worth
* keeping the iter around.
*
* ## Atomic Operations
* # Atomic Operations
*
* It is important to note that only the methods
* gtk_list_store_insert_with_values() and gtk_list_store_insert_with_valuesv()
@@ -135,7 +131,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* `GtkTreeModel`FilterVisibleFunc to be visited with an empty row first; the
* function must be prepared for that.
*
* ## GtkListStore as GtkBuildable
* # GtkListStore as GtkBuildable
*
* The GtkListStore implementation of the [iface@Gtk.Buildable] interface allows
* to specify the model columns with a `<columns>` element that may contain
@@ -175,8 +171,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* </data>
* </object>
* ```
*
* Deprecated: 4.10: Use [class@Gio.ListStore] instead
*/
@@ -396,7 +390,7 @@ static gboolean
iter_is_valid (GtkTreeIter *iter,
GtkListStore *list_store)
{
return iter != NULL &&
return iter != NULL &&
iter->user_data != NULL &&
list_store->priv->stamp == iter->stamp &&
!g_sequence_iter_is_end (iter->user_data) &&
@@ -408,27 +402,17 @@ iter_is_valid (GtkTreeIter *iter,
* @n_columns: number of columns in the list store
* @...: all `GType` types for the columns, from first to last
*
* Creates a new list store.
*
* The list store will have @n_columns columns, with each column using
* the given type passed to this function.
*
*
* Note that only types derived from standard GObject fundamental types
* Creates a new list store as with @n_columns columns each of the types passed
* in. Note that only types derived from standard GObject fundamental types
* are supported.
*
* As an example:
*
* ```c
* gtk_list_store_new (3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_TEXTURE);
* ```
*
* will create a new `GtkListStore` with three columns, of type `int`,
* `gchararray` and `GdkTexture`, respectively.
* As an example, `gtk_list_store_new (3, G_TYPE_INT, G_TYPE_STRING,
* GDK_TYPE_TEXTURE);` will create a new `GtkListStore` with three columns, of type
* int, string and `GdkTexture`, respectively.
*
* Returns: a new `GtkListStore`
*
* Deprecated: 4.10: Use [class@Gio.ListStore] instead
* Deprecated: 4.10: Use list models
*/
GtkListStore *
gtk_list_store_new (int n_columns,
@@ -471,13 +455,11 @@ gtk_list_store_new (int n_columns,
* @n_columns: number of columns in the list store
* @types: (array length=n_columns): an array of `GType` types for the columns, from first to last
*
* Creates a new `GtkListStore`.
*
* This function is meant to be used by language bindings.
* Non-vararg creation function. Used primarily by language bindings.
*
* Returns: (transfer full): a new `GtkListStore`
*
* Deprecated: 4.10: Use [class@Gio.ListStore] instead
* Deprecated: 4.10: Use list models
**/
GtkListStore *
gtk_list_store_newv (int n_columns,
@@ -512,14 +494,10 @@ gtk_list_store_newv (int n_columns,
* @n_columns: Number of columns for the list store
* @types: (array length=n_columns): An array length n of `GType`s
*
* Sets the types of the columns of a list store.
*
* This function is meant primarily for objects that inherit
* from `GtkListStore`, and should only be used when constructing
* a new instance.
*
* This function cannot be called after a row has been added, or
* a method on the `GtkTreeModel` interface is called.
* This function is meant primarily for `GObject`s that inherit from `GtkListStore`,
* and should only be used when constructing a new `GtkListStore`. It will not
* function after a row has been added, or a method on the `GtkTreeModel`
* interface is called.
*
* Deprecated: 4.10: Use list models
**/
@@ -683,10 +661,10 @@ gtk_list_store_get_path (GtkTreeModel *tree_model,
if (g_sequence_iter_is_end (iter->user_data))
return NULL;
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, g_sequence_iter_get_position (iter->user_data));
return path;
}
@@ -703,7 +681,7 @@ gtk_list_store_get_value (GtkTreeModel *tree_model,
g_return_if_fail (column < priv->n_columns);
g_return_if_fail (iter_is_valid (iter, list_store));
list = g_sequence_get (iter->user_data);
while (tmp_column-- > 0 && list)
@@ -1020,8 +998,8 @@ gtk_list_store_set_vector_internal (GtkListStore *list_store,
for (i = 0; i < n_values; i++)
{
*emit_signal = gtk_list_store_real_set_value (list_store,
iter,
*emit_signal = gtk_list_store_real_set_value (list_store,
iter,
columns[i],
&values[i],
FALSE) || *emit_signal;
@@ -1079,7 +1057,7 @@ gtk_list_store_set_valist_internal (GtkListStore *list_store,
column,
&value,
FALSE) || *emit_signal;
if (func == _gtk_tree_data_list_compare_func &&
column == priv->sort_column_id)
*maybe_need_sort = TRUE;
@@ -1100,7 +1078,7 @@ gtk_list_store_set_valist_internal (GtkListStore *list_store,
*
* A variant of gtk_list_store_set_valist() which
* takes the columns and values as two arrays, instead of
* varargs. This function is mainly intended for
* varargs. This function is mainly intended for
* language-bindings and in case the number of columns to
* change is not known until run-time.
*
@@ -1165,8 +1143,8 @@ gtk_list_store_set_valist (GtkListStore *list_store,
priv = list_store->priv;
gtk_list_store_set_valist_internal (list_store, iter,
&emit_signal,
gtk_list_store_set_valist_internal (list_store, iter,
&emit_signal,
&maybe_need_sort,
var_args);
@@ -1218,8 +1196,8 @@ gtk_list_store_set (GtkListStore *list_store,
* @list_store: A `GtkListStore`
* @iter: A valid `GtkTreeIter`
*
* Removes the given row from the list store. After being removed,
* @iter is set to be the next valid row, or invalidated if it pointed
* Removes the given row from the list store. After being removed,
* @iter is set to be the next valid row, or invalidated if it pointed
* to the last row in @list_store.
*
* Returns: %TRUE if @iter is valid, %FALSE if not.
@@ -1243,12 +1221,12 @@ gtk_list_store_remove (GtkListStore *list_store,
ptr = iter->user_data;
next = g_sequence_iter_next (ptr);
_gtk_tree_data_list_free (g_sequence_get (ptr), priv->column_headers);
g_sequence_remove (iter->user_data);
priv->length--;
gtk_tree_model_row_deleted (GTK_TREE_MODEL (list_store), path);
gtk_tree_path_free (path);
@@ -1312,7 +1290,7 @@ gtk_list_store_insert (GtkListStore *list_store,
g_assert (iter_is_valid (iter, list_store));
priv->length++;
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, position);
gtk_tree_model_row_inserted (GTK_TREE_MODEL (list_store), path, iter);
@@ -1325,9 +1303,9 @@ gtk_list_store_insert (GtkListStore *list_store,
* @iter: (out): An unset `GtkTreeIter` to set to the new row
* @sibling: (nullable): A valid `GtkTreeIter`
*
* Inserts a new row before @sibling. If @sibling is %NULL, then the row will
* be appended to the end of the list. @iter will be changed to point to this
* new row. The row will be empty after this function is called. To fill in
* Inserts a new row before @sibling. If @sibling is %NULL, then the row will
* be appended to the end of the list. @iter will be changed to point to this
* new row. The row will be empty after this function is called. To fill in
* values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
*
* Deprecated: 4.10: Use list models
@@ -1339,7 +1317,7 @@ gtk_list_store_insert_before (GtkListStore *list_store,
{
GtkListStorePrivate *priv;
GSequenceIter *after;
g_return_if_fail (GTK_IS_LIST_STORE (list_store));
g_return_if_fail (iter != NULL);
@@ -1451,7 +1429,7 @@ gtk_list_store_increment_stamp (GtkListStore *list_store)
* gtk_list_store_clear:
* @list_store: a `GtkListStore`.
*
* Removes all rows from the list store.
* Removes all rows from the list store.
*
* Deprecated: 4.10: Use list models
**/
@@ -1528,7 +1506,7 @@ static gboolean real_gtk_list_store_row_draggable (GtkTreeDragSource *drag_sourc
{
return TRUE;
}
static gboolean
gtk_list_store_drag_data_delete (GtkTreeDragSource *drag_source,
GtkTreePath *path)
@@ -1699,7 +1677,7 @@ gtk_list_store_row_drop_possible (GtkTreeDragDest *drag_dest,
out:
if (src_path)
gtk_tree_path_free (src_path);
return retval;
}
@@ -1721,7 +1699,7 @@ gtk_list_store_reorder_func (GSequenceIter *a,
return 1;
return 0;
}
/**
* gtk_list_store_reorder:
* @store: A `GtkListStore`.
@@ -1745,7 +1723,7 @@ gtk_list_store_reorder (GtkListStore *store,
GHashTable *new_positions;
GSequenceIter *ptr;
int *order;
g_return_if_fail (GTK_IS_LIST_STORE (store));
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
g_return_if_fail (new_order != NULL);
@@ -1755,7 +1733,7 @@ gtk_list_store_reorder (GtkListStore *store,
order = g_new (int, g_sequence_get_length (priv->seq));
for (i = 0; i < g_sequence_get_length (priv->seq); i++)
order[new_order[i]] = i;
new_positions = g_hash_table_new (g_direct_hash, g_direct_equal);
ptr = g_sequence_get_begin_iter (priv->seq);
@@ -1767,11 +1745,11 @@ gtk_list_store_reorder (GtkListStore *store,
ptr = g_sequence_iter_next (ptr);
}
g_free (order);
g_sequence_sort_iter (priv->seq, gtk_list_store_reorder_func, new_positions);
g_hash_table_destroy (new_positions);
/* emit signal */
path = gtk_tree_path_new ();
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (store),
@@ -1850,12 +1828,12 @@ gtk_list_store_swap (GtkListStore *store,
return;
old_positions = save_positions (priv->seq);
g_sequence_swap (a->user_data, b->user_data);
order = generate_order (priv->seq, old_positions);
path = gtk_tree_path_new ();
gtk_tree_model_rows_reordered (GTK_TREE_MODEL (store),
path, NULL, order);
@@ -1904,7 +1882,7 @@ gtk_list_store_move_before (GtkListStore *store,
GtkTreeIter *position)
{
int pos;
g_return_if_fail (GTK_IS_LIST_STORE (store));
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
g_return_if_fail (iter_is_valid (iter, store));
@@ -1915,7 +1893,7 @@ gtk_list_store_move_before (GtkListStore *store,
pos = g_sequence_iter_get_position (position->user_data);
else
pos = -1;
gtk_list_store_move_to (store, iter, pos);
}
@@ -1937,7 +1915,7 @@ gtk_list_store_move_after (GtkListStore *store,
GtkTreeIter *position)
{
int pos;
g_return_if_fail (GTK_IS_LIST_STORE (store));
g_return_if_fail (!GTK_LIST_STORE_IS_SORTED (store));
g_return_if_fail (iter_is_valid (iter, store));
@@ -1948,10 +1926,10 @@ gtk_list_store_move_after (GtkListStore *store,
pos = g_sequence_iter_get_position (position->user_data) + 1;
else
pos = 0;
gtk_list_store_move_to (store, iter, pos);
}
/* Sorting */
static int
gtk_list_store_compare_func (GSequenceIter *a,
@@ -2051,7 +2029,7 @@ iter_is_sorted (GtkListStore *list_store,
if (gtk_list_store_compare_func (iter->user_data, cmp, list_store) > 0)
return FALSE;
}
return TRUE;
}
@@ -2124,7 +2102,7 @@ gtk_list_store_set_sort_column_id (GtkTreeSortable *sortable,
{
GtkTreeDataSortHeader *header = NULL;
header = _gtk_tree_data_list_get_header (priv->sort_list,
header = _gtk_tree_data_list_get_header (priv->sort_list,
sort_column_id);
/* We want to make sure that we have a function */
@@ -2156,8 +2134,8 @@ gtk_list_store_set_sort_func (GtkTreeSortable *sortable,
GtkListStore *list_store = GTK_LIST_STORE (sortable);
GtkListStorePrivate *priv = list_store->priv;
priv->sort_list = _gtk_tree_data_list_set_header (priv->sort_list,
sort_column_id,
priv->sort_list = _gtk_tree_data_list_set_header (priv->sort_list,
sort_column_id,
func, data, destroy);
if (priv->sort_column_id == sort_column_id)
@@ -2284,7 +2262,7 @@ gtk_list_store_insert_with_values (GtkListStore *list_store,
priv->length++;
va_start (var_args, position);
gtk_list_store_set_valist_internal (list_store, iter,
gtk_list_store_set_valist_internal (list_store, iter,
&changed, &maybe_need_sort,
var_args);
va_end (var_args);
@@ -2308,9 +2286,9 @@ gtk_list_store_insert_with_values (GtkListStore *list_store,
* @iter: (out) (optional): An unset `GtkTreeIter` to set to the new row
* @position: position to insert the new row, or -1 for last
* @columns: (array length=n_values): an array of column numbers
* @values: (array length=n_values): an array of GValues
* @values: (array length=n_values): an array of GValues
* @n_values: the length of the @columns and @values arrays
*
*
* A variant of gtk_list_store_insert_with_values() which
* takes the columns and values as two arrays, instead of
* varargs.
@@ -2323,7 +2301,7 @@ void
gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
GtkTreeIter *iter,
int position,
int *columns,
int *columns,
GValue *values,
int n_values)
{
@@ -2336,8 +2314,8 @@ gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
gboolean changed = FALSE;
gboolean maybe_need_sort = FALSE;
/* FIXME refactor to reduce overlap with
* gtk_list_store_insert_with_values()
/* FIXME refactor to reduce overlap with
* gtk_list_store_insert_with_values()
*/
g_return_if_fail (GTK_IS_LIST_STORE (list_store));
@@ -2362,7 +2340,7 @@ gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
g_assert (iter_is_valid (iter, list_store));
priv->length++;
priv->length++;
gtk_list_store_set_vector_internal (list_store, iter,
&changed, &maybe_need_sort,
+21 -21
View File
@@ -60,88 +60,88 @@ struct _GtkListStoreClass
GDK_AVAILABLE_IN_ALL
GType gtk_list_store_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
GtkListStore *gtk_list_store_new (int n_columns,
...);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
GtkListStore *gtk_list_store_newv (int n_columns,
GType *types);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_set_column_types (GtkListStore *list_store,
int n_columns,
GType *types);
/* NOTE: use gtk_tree_model_get to get values from a GtkListStore */
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_set_value (GtkListStore *list_store,
GtkTreeIter *iter,
int column,
GValue *value);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_set (GtkListStore *list_store,
GtkTreeIter *iter,
...);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_set_valuesv (GtkListStore *list_store,
GtkTreeIter *iter,
int *columns,
GValue *values,
int n_values);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_set_valist (GtkListStore *list_store,
GtkTreeIter *iter,
va_list var_args);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
gboolean gtk_list_store_remove (GtkListStore *list_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_insert (GtkListStore *list_store,
GtkTreeIter *iter,
int position);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_insert_before (GtkListStore *list_store,
GtkTreeIter *iter,
GtkTreeIter *sibling);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_insert_after (GtkListStore *list_store,
GtkTreeIter *iter,
GtkTreeIter *sibling);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_insert_with_values (GtkListStore *list_store,
GtkTreeIter *iter,
int position,
...);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_insert_with_valuesv (GtkListStore *list_store,
GtkTreeIter *iter,
int position,
int *columns,
GValue *values,
int n_values);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_prepend (GtkListStore *list_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_append (GtkListStore *list_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_clear (GtkListStore *list_store);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
gboolean gtk_list_store_iter_is_valid (GtkListStore *list_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_reorder (GtkListStore *store,
int *new_order);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_swap (GtkListStore *store,
GtkTreeIter *a,
GtkTreeIter *b);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_move_after (GtkListStore *store,
GtkTreeIter *iter,
GtkTreeIter *position);
GDK_DEPRECATED_IN_4_10_FOR(GListStore)
GDK_DEPRECATED_IN_4_10
void gtk_list_store_move_before (GtkListStore *store,
GtkTreeIter *iter,
GtkTreeIter *position);
+1 -5
View File
@@ -48,7 +48,7 @@
* and RTL/LTR information set. The style context will also be updated
* automatically if any of these settings change on the widget.
*
* ## Style Classes
* # Style Classes
*
* Widgets can add style classes to their context, which can be used to associate
* different styles by class. The documentation for individual widgets lists
@@ -71,10 +71,6 @@
* `XDG_CONFIG_HOME/gtk-4.0/gtk.css` will
* still take precedence over your changes, as it uses the
* %GTK_STYLE_PROVIDER_PRIORITY_USER priority.
*
* Deprecated: 4.10: The relevant API has been moved to [class@Gtk.Widget]
* where applicable; otherwise, there is no replacement for querying the
* style machinery. Stylable UI elements should use widgets.
*/
#define CURSOR_ASPECT_RATIO (0.04)
+24 -30
View File
@@ -49,18 +49,12 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* GtkTreeDragDest:
*
* Interface for Drag-and-Drop destinations in `GtkTreeView`.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You can use [class@Gtk.DropTarget] to implement a drop destination
*/
/**
* GtkTreeDragSource:
*
* Interface for Drag-and-Drop destinations in `GtkTreeView`.
*
* Deprecated: 4.10: List views use widgets to display their contents.
* You can use [class@Gtk.DragSource] to implement a drag source
*/
GType
@@ -83,11 +77,11 @@ gtk_tree_drag_source_get_type (void)
NULL
};
our_type = g_type_register_static (G_TYPE_INTERFACE,
our_type = g_type_register_static (G_TYPE_INTERFACE,
I_("GtkTreeDragSource"),
&our_info, 0);
}
return our_type;
}
@@ -114,7 +108,7 @@ gtk_tree_drag_dest_get_type (void)
our_type = g_type_register_static (G_TYPE_INTERFACE, I_("GtkTreeDragDest"), &our_info, 0);
}
return our_type;
}
@@ -122,7 +116,7 @@ gtk_tree_drag_dest_get_type (void)
* gtk_tree_drag_source_row_draggable:
* @drag_source: a `GtkTreeDragSource`
* @path: row on which user is initiating a drag
*
*
* Asks the `GtkTreeDragSource` whether a particular row can be used as
* the source of a DND operation. If the source doesnt implement
* this interface, the row is assumed draggable.
@@ -153,13 +147,13 @@ gtk_tree_drag_source_row_draggable (GtkTreeDragSource *drag_source,
* gtk_tree_drag_source_drag_data_delete:
* @drag_source: a `GtkTreeDragSource`
* @path: row that was being dragged
*
*
* Asks the `GtkTreeDragSource` to delete the row at @path, because
* it was moved somewhere else via drag-and-drop. Returns %FALSE
* if the deletion fails because @path no longer exists, or for
* some model-specific reason. Should robustly handle a @path no
* longer found in the model!
*
*
* Returns: %TRUE if the row was successfully deleted
*
* Deprecated: 4.10: Use list models instead
@@ -180,11 +174,11 @@ gtk_tree_drag_source_drag_data_delete (GtkTreeDragSource *drag_source,
* gtk_tree_drag_source_drag_data_get:
* @drag_source: a `GtkTreeDragSource`
* @path: row that was dragged
*
*
* Asks the `GtkTreeDragSource` to return a `GdkContentProvider` representing
* the row at @path. Should robustly handle a @path no
* longer found in the model!
*
*
* Returns: (nullable) (transfer full): a `GdkContentProvider` for the
* given @path
*
@@ -207,14 +201,14 @@ gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source,
* @drag_dest: a `GtkTreeDragDest`
* @dest: row to drop in front of
* @value: data to drop
*
*
* Asks the `GtkTreeDragDest` to insert a row before the path @dest,
* deriving the contents of the row from @value. If @dest is
* outside the tree so that inserting before it is impossible, %FALSE
* will be returned. Also, %FALSE may be returned if the new row is
* not created for some model-specific reason. Should robustly handle
* a @dest no longer found in the model!
*
*
* Returns: whether a new row was created before position @dest
*
* Deprecated: 4.10: Use list models instead
@@ -239,13 +233,13 @@ gtk_tree_drag_dest_drag_data_received (GtkTreeDragDest *drag_dest,
* @drag_dest: a `GtkTreeDragDest`
* @dest_path: destination row
* @value: the data being dropped
*
*
* Determines whether a drop is possible before the given @dest_path,
* at the same depth as @dest_path. i.e., can we drop the data in
* @value at that location. @dest_path does not have to
* exist; the return value will almost certainly be %FALSE if the
* parent of @dest_path doesnt exist, though.
*
*
* Returns: %TRUE if a drop is possible before @dest_path
*
* Deprecated: 4.10: Use list models instead
@@ -287,9 +281,9 @@ G_DEFINE_BOXED_TYPE (GtkTreeRowData, gtk_tree_row_data,
* gtk_tree_create_row_drag_content:
* @tree_model: a `GtkTreeModel`
* @path: a row in @tree_model
*
*
* Creates a content provider for dragging @path from @tree_model.
*
*
* Returns: (transfer full): a new `GdkContentProvider`
*
* Deprecated: 4.10: Use list models instead
@@ -303,7 +297,7 @@ gtk_tree_create_row_drag_content (GtkTreeModel *tree_model,
char *path_str;
int len;
int struct_size;
g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
@@ -315,18 +309,18 @@ gtk_tree_create_row_drag_content (GtkTreeModel *tree_model,
struct_size = sizeof (GtkTreeRowData) + len + 1 -
(sizeof (GtkTreeRowData) - G_STRUCT_OFFSET (GtkTreeRowData, path));
trd = g_malloc (struct_size);
trd = g_malloc (struct_size);
strcpy (trd->path, path_str);
g_free (path_str);
trd->model = tree_model;
content = gdk_content_provider_new_typed (GTK_TYPE_TREE_ROW_DATA, trd);
g_free (trd);
return content;
}
@@ -335,12 +329,12 @@ gtk_tree_create_row_drag_content (GtkTreeModel *tree_model,
* @value: a `GValue`
* @tree_model: (nullable) (optional) (transfer none) (out): a `GtkTreeModel`
* @path: (nullable) (optional) (out): row in @tree_model
*
*
* Obtains a @tree_model and @path from value of target type
* %GTK_TYPE_TREE_ROW_DATA.
*
* The returned path must be freed with gtk_tree_path_free().
*
*
* Returns: %TRUE if @selection_data had target type %GTK_TYPE_TREE_ROW_DATA
* is otherwise valid
*
@@ -352,8 +346,8 @@ gtk_tree_get_row_drag_data (const GValue *value,
GtkTreePath **path)
{
GtkTreeRowData *trd;
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
if (tree_model)
*tree_model = NULL;
@@ -373,6 +367,6 @@ gtk_tree_get_row_drag_data (const GValue *value,
if (path)
*path = gtk_tree_path_new_from_string (trd->path);
return TRUE;
}
+10 -10
View File
@@ -74,23 +74,23 @@ struct _GtkTreeDragSourceIface
GtkTreePath *path);
};
GDK_DEPRECATED_IN_4_10_FOR(GtkDragSource)
GDK_DEPRECATED_IN_4_10
GType gtk_tree_drag_source_get_type (void) G_GNUC_CONST;
/* Returns whether the given row can be dragged */
GDK_DEPRECATED_IN_4_10_FOR(GtkDragSource)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_drag_source_row_draggable (GtkTreeDragSource *drag_source,
GtkTreePath *path);
/* Deletes the given row, or returns FALSE if it can't */
GDK_DEPRECATED_IN_4_10_FOR(GtkDragSource)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_drag_source_drag_data_delete (GtkTreeDragSource *drag_source,
GtkTreePath *path);
/* Fills in selection_data with type selection_data->target based on
* the row denoted by path, returns TRUE if it does anything
*/
GDK_DEPRECATED_IN_4_10_FOR(GtkDragSource)
GDK_DEPRECATED_IN_4_10
GdkContentProvider *
gtk_tree_drag_source_drag_data_get (GtkTreeDragSource *drag_source,
GtkTreePath *path);
@@ -129,20 +129,20 @@ struct _GtkTreeDragDestIface
const GValue *value);
};
GDK_DEPRECATED_IN_4_10_FOR(GtkDropTarget)
GDK_DEPRECATED_IN_4_10
GType gtk_tree_drag_dest_get_type (void) G_GNUC_CONST;
/* Inserts a row before dest which contains data in selection_data,
* or returns FALSE if it can't
*/
GDK_DEPRECATED_IN_4_10_FOR(GtkDropTarget)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_drag_dest_drag_data_received (GtkTreeDragDest *drag_dest,
GtkTreePath *dest,
const GValue *value);
/* Returns TRUE if we can drop before path; path may not exist. */
GDK_DEPRECATED_IN_4_10_FOR(GtkDropTarget)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_drag_dest_row_drop_possible (GtkTreeDragDest *drag_dest,
GtkTreePath *dest_path,
const GValue *value);
@@ -151,11 +151,11 @@ gboolean gtk_tree_drag_dest_row_drop_possible (GtkTreeDragDest *drag_dest,
/* The selection data would normally have target type GTK_TREE_MODEL_ROW in this
* case. If the target is wrong these functions return FALSE.
*/
GDK_DEPRECATED_IN_4_10_FOR(GtkDragSource and GtkDropTarget)
GdkContentProvider *
GDK_DEPRECATED_IN_4_10
GdkContentProvider *
gtk_tree_create_row_drag_content (GtkTreeModel *tree_model,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkDragSource and GtkDropTarget)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_get_row_drag_data (const GValue *value,
GtkTreeModel **tree_model,
GtkTreePath **path);
+1 -3
View File
@@ -228,8 +228,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* required for levels in which nodes are referenced. For the root level
* however, signals must be emitted at all times (however the root level
* is always referenced when any view is attached).
*
* Deprecated: 4.10: Use [iface@Gio.ListModel] instead
*/
#define INITIALIZE_TREE_ITER(Iter) \
@@ -364,7 +362,7 @@ gtk_tree_model_base_init (gpointer g_class)
tree_model_signals[ROW_CHANGED] =
g_signal_new (I_("row-changed"),
GTK_TYPE_TREE_MODEL,
G_SIGNAL_RUN_LAST,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTreeModelIface, row_changed),
NULL, NULL,
_gtk_marshal_VOID__BOXED_BOXED,
+59 -59
View File
@@ -192,57 +192,57 @@ struct _GtkTreeModelIface
/* GtkTreePath operations */
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_path_new (void);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_path_new_from_string (const char *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_path_new_from_indices (int first_index,
...);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_path_new_from_indicesv (int *indices,
gsize length);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
char *gtk_tree_path_to_string (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_path_new_first (void);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_path_append_index (GtkTreePath *path,
int index_);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_path_prepend_index (GtkTreePath *path,
int index_);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
int gtk_tree_path_get_depth (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
int *gtk_tree_path_get_indices (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
int *gtk_tree_path_get_indices_with_depth (GtkTreePath *path,
int *depth);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_path_free (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_path_copy (const GtkTreePath *path);
GDK_AVAILABLE_IN_ALL
GType gtk_tree_path_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
int gtk_tree_path_compare (const GtkTreePath *a,
const GtkTreePath *b);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_path_next (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_path_prev (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_path_up (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_path_down (GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_path_is_ancestor (GtkTreePath *path,
GtkTreePath *descendant);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_path_is_descendant (GtkTreePath *path,
GtkTreePath *ancestor);
@@ -256,147 +256,147 @@ gboolean gtk_tree_path_is_descendant (GtkTreePath *path,
GDK_AVAILABLE_IN_ALL
GType gtk_tree_row_reference_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeRowReference *gtk_tree_row_reference_new (GtkTreeModel *model,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeRowReference *gtk_tree_row_reference_new_proxy (GObject *proxy,
GtkTreeModel *model,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_row_reference_get_path (GtkTreeRowReference *reference);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_tree_row_reference_get_model (GtkTreeRowReference *reference);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_row_reference_valid (GtkTreeRowReference *reference);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeRowReference *gtk_tree_row_reference_copy (GtkTreeRowReference *reference);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_row_reference_free (GtkTreeRowReference *reference);
/* These two functions are only needed if you created the row reference with a
* proxy object */
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_row_reference_inserted (GObject *proxy,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_row_reference_deleted (GObject *proxy,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_row_reference_reordered (GObject *proxy,
GtkTreePath *path,
GtkTreeIter *iter,
int *new_order);
/* GtkTreeIter operations */
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeIter * gtk_tree_iter_copy (GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_iter_free (GtkTreeIter *iter);
GDK_AVAILABLE_IN_ALL
GType gtk_tree_iter_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GType gtk_tree_model_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeModelFlags gtk_tree_model_get_flags (GtkTreeModel *tree_model);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
int gtk_tree_model_get_n_columns (GtkTreeModel *tree_model);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GType gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
int index_);
/* Iterator movement */
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_get_iter_from_string (GtkTreeModel *tree_model,
GtkTreeIter *iter,
const char *path_string);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
char * gtk_tree_model_get_string_from_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_get_iter_first (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath * gtk_tree_model_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
int column,
GValue *value);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_iter_previous (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
int gtk_tree_model_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
int n);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_ref_node (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_unref_node (GtkTreeModel *tree_model,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_get (GtkTreeModel *tree_model,
GtkTreeIter *iter,
...);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_get_valist (GtkTreeModel *tree_model,
GtkTreeIter *iter,
va_list var_args);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_foreach (GtkTreeModel *model,
GtkTreeModelForeachFunc func,
gpointer user_data);
/* Signals */
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_row_changed (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_row_inserted (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_row_has_child_toggled (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_row_deleted (GtkTreeModel *tree_model,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_rows_reordered (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter,
int *new_order);
GDK_DEPRECATED_IN_4_10_FOR(GListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_rows_reordered_with_length (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter,
+6 -8
View File
@@ -31,13 +31,13 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
*
* A `GtkTreeModelFilter` is a tree model which wraps another tree model,
* and can do the following things:
*
*
* - Filter specific rows, based on data from a visible column, a column
* storing booleans indicating whether the row should be filtered or not,
* or based on the return value of a visible function, which gets a
* model, iter and user_data and returns a boolean indicating whether the
* row should be filtered or not.
*
*
* - Modify the appearance of the model, using a modify function.
* This is extremely powerful and allows for just changing some
* values and also for creating a completely different model based
@@ -94,8 +94,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* because it does not implement reference counting, or for models that
* do implement reference counting, obtain references on these child levels
* yourself.
*
* Deprecated: 4.10: Use [class@Gtk.FilterListModel] instead.
*/
/* Notes on this implementation of GtkTreeModelFilter
@@ -590,7 +588,7 @@ gtk_tree_model_filter_finalize (GObject *object)
gtk_tree_model_filter_free_level (filter, filter->priv->root, TRUE, TRUE, FALSE);
g_free (filter->priv->modify_types);
if (filter->priv->modify_destroy)
filter->priv->modify_destroy (filter->priv->modify_data);
@@ -3803,7 +3801,7 @@ gtk_tree_model_filter_get_model (GtkTreeModelFilter *filter)
* %FALSE otherwise.
*
* If the condition calculated by the function changes over time (e.g.
* because it depends on some global parameters), you must call
* because it depends on some global parameters), you must call
* gtk_tree_model_filter_refilter() to keep the visibility information
* of the model up-to-date.
*
@@ -3866,8 +3864,8 @@ gtk_tree_model_filter_set_visible_func (GtkTreeModelFilter *filter,
* types for this model (which will be exposed to the parent model/view).
* The @func, @data and @destroy parameters are for specifying the modify
* function. The modify function will get called for each
* data access, the goal of the modify function is to return the data which
* should be displayed at the location specified using the parameters of the
* data access, the goal of the modify function is to return the data which
* should be displayed at the location specified using the parameters of the
* modify function.
*
* Note that gtk_tree_model_filter_set_modify_func()
+11 -11
View File
@@ -105,48 +105,48 @@ struct _GtkTreeModelFilterClass
/* base */
GDK_AVAILABLE_IN_ALL
GType gtk_tree_model_filter_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_tree_model_filter_new (GtkTreeModel *child_model,
GtkTreePath *root);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_filter_set_visible_func (GtkTreeModelFilter *filter,
GtkTreeModelFilterVisibleFunc func,
gpointer data,
GDestroyNotify destroy);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_filter_set_modify_func (GtkTreeModelFilter *filter,
int n_columns,
GType *types,
GtkTreeModelFilterModifyFunc func,
gpointer data,
GDestroyNotify destroy);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_filter_set_visible_column (GtkTreeModelFilter *filter,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_tree_model_filter_get_model (GtkTreeModelFilter *filter);
/* conversion */
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter *filter,
GtkTreeIter *filter_iter,
GtkTreeIter *child_iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_filter_convert_iter_to_child_iter (GtkTreeModelFilter *filter,
GtkTreeIter *child_iter,
GtkTreeIter *filter_iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_model_filter_convert_child_path_to_path (GtkTreeModelFilter *filter,
GtkTreePath *child_path);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_model_filter_convert_path_to_child_path (GtkTreeModelFilter *filter,
GtkTreePath *filter_path);
/* extras */
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_filter_refilter (GtkTreeModelFilter *filter);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_filter_clear_cache (GtkTreeModelFilter *filter);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeModelFilter, g_object_unref)
+25 -27
View File
@@ -127,8 +127,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* g_free (modified_data);
* }
* ]|
*
* Deprecated: 4.10: Use [class@Gtk.SortListModel] instead
*/
@@ -661,13 +659,13 @@ fill_sort_data (SortData *data,
if (priv->sort_column_id != GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID)
{
GtkTreeDataSortHeader *header;
header = _gtk_tree_data_list_get_header (priv->sort_list,
priv->sort_column_id);
g_return_if_fail (header != NULL);
g_return_if_fail (header->func != NULL);
data->sort_func = header->func;
data->sort_data = header->data;
}
@@ -1423,7 +1421,7 @@ gtk_tree_model_sort_iter_children (GtkTreeModel *tree_model,
iter->stamp = 0;
g_return_val_if_fail (priv->child_model != NULL, FALSE);
if (parent)
if (parent)
g_return_val_if_fail (VALID_ITER (parent, tree_model_sort), FALSE);
if (parent == NULL)
@@ -1484,7 +1482,7 @@ gtk_tree_model_sort_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter child_iter;
g_return_val_if_fail (priv->child_model != NULL, 0);
if (iter)
if (iter)
g_return_val_if_fail (VALID_ITER (iter, tree_model_sort), 0);
if (iter == NULL)
@@ -1506,7 +1504,7 @@ gtk_tree_model_sort_iter_nth_child (GtkTreeModel *tree_model,
/* We have this for the iter == parent case */
GtkTreeIter children;
if (parent)
if (parent)
g_return_val_if_fail (VALID_ITER (parent, tree_model_sort), FALSE);
/* Use this instead of has_child to force us to build the level, if needed */
@@ -1534,7 +1532,7 @@ static gboolean
gtk_tree_model_sort_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child)
{
{
GtkTreeModelSort *tree_model_sort = (GtkTreeModelSort *) tree_model;
GtkTreeModelSortPrivate *priv = tree_model_sort->priv;
SortLevel *level;
@@ -1672,7 +1670,7 @@ gtk_tree_model_sort_get_sort_column_id (GtkTreeSortable *sortable,
if (priv->sort_column_id == GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID ||
priv->sort_column_id == GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID)
return FALSE;
return TRUE;
}
@@ -2113,9 +2111,9 @@ gtk_tree_model_sort_elt_get_path (SortLevel *level,
* @tree_model_sort: The `GtkTreeModelSort`.
* @child_model: (nullable): A `GtkTreeModel`
*
* Sets the model of @tree_model_sort to be @model. If @model is %NULL,
* then the old model is unset. The sort function is unset as a result
* of this call. The model will be in an unsorted state until a sort
* Sets the model of @tree_model_sort to be @model. If @model is %NULL,
* then the old model is unset. The sort function is unset as a result
* of this call. The model will be in an unsorted state until a sort
* function is set.
*
* Deprecated: 4.10
@@ -2276,12 +2274,12 @@ gtk_real_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_mode
* gtk_tree_model_sort_convert_child_path_to_path:
* @tree_model_sort: A `GtkTreeModelSort`
* @child_path: A `GtkTreePath` to convert
*
*
* Converts @child_path to a path relative to @tree_model_sort. That is,
* @child_path points to a path in the child model. The returned path will
* point to the same row in the sorted model. If @child_path isnt a valid
* point to the same row in the sorted model. If @child_path isnt a valid
* path on the child model, then %NULL is returned.
*
*
* Returns: (nullable) (transfer full): A newly allocated `GtkTreePath`
*
* Deprecated: 4.10
@@ -2302,7 +2300,7 @@ gtk_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_model_sor
* @tree_model_sort: A `GtkTreeModelSort`
* @sort_iter: (out): An uninitialized `GtkTreeIter`
* @child_iter: A valid `GtkTreeIter` pointing to a row on the child model
*
*
* Sets @sort_iter to point to the row in @tree_model_sort that corresponds to
* the row pointed at by @child_iter. If @sort_iter was not set, %FALSE
* is returned. Note: a boolean is only returned since 2.14.
@@ -2352,13 +2350,13 @@ gtk_tree_model_sort_convert_child_iter_to_iter (GtkTreeModelSort *tree_model_sor
* gtk_tree_model_sort_convert_path_to_child_path:
* @tree_model_sort: A `GtkTreeModelSort`
* @sorted_path: A `GtkTreePath` to convert
*
* Converts @sorted_path to a path on the child model of @tree_model_sort.
* That is, @sorted_path points to a location in @tree_model_sort. The
* returned path will point to the same location in the model not being
* sorted. If @sorted_path does not point to a location in the child model,
*
* Converts @sorted_path to a path on the child model of @tree_model_sort.
* That is, @sorted_path points to a location in @tree_model_sort. The
* returned path will point to the same location in the model not being
* sorted. If @sorted_path does not point to a location in the child model,
* %NULL is returned.
*
*
* Returns: (nullable) (transfer full): A newly allocated `GtkTreePath`
*
* Deprecated: 4.10
@@ -2416,7 +2414,7 @@ gtk_tree_model_sort_convert_path_to_child_path (GtkTreeModelSort *tree_model_sor
gtk_tree_path_append_index (retval, elt->offset);
level = elt->children;
}
return retval;
}
@@ -2425,7 +2423,7 @@ gtk_tree_model_sort_convert_path_to_child_path (GtkTreeModelSort *tree_model_sor
* @tree_model_sort: A `GtkTreeModelSort`
* @child_iter: (out): An uninitialized `GtkTreeIter`
* @sorted_iter: A valid `GtkTreeIter` pointing to a row on @tree_model_sort.
*
*
* Sets @child_iter to point to the row pointed to by @sorted_iter.
*
* Deprecated: 4.10
@@ -2691,7 +2689,7 @@ gtk_tree_model_sort_clear_cache_helper (GtkTreeModelSort *tree_model_sort,
/**
* gtk_tree_model_sort_reset_default_sort_func:
* @tree_model_sort: A `GtkTreeModelSort`
*
*
* This resets the default sort function to be in the unsorted state. That
* is, it is in the same order as the child model. It will re-sort the model
* to be in the same order as the child model only if the `GtkTreeModelSort`
@@ -2726,7 +2724,7 @@ gtk_tree_model_sort_reset_default_sort_func (GtkTreeModelSort *tree_model_sort)
/**
* gtk_tree_model_sort_clear_cache:
* @tree_model_sort: A `GtkTreeModelSort`
*
*
* This function should almost never be called. It clears the @tree_model_sort
* of any cached iterators that havent been reffed with
* gtk_tree_model_ref_node(). This might be useful if the child model being
+9 -9
View File
@@ -58,30 +58,30 @@ struct _GtkTreeModelSortClass
GDK_AVAILABLE_IN_ALL
GType gtk_tree_model_sort_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_tree_model_sort_new_with_model (GtkTreeModel *child_model);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_tree_model_sort_get_model (GtkTreeModelSort *tree_model);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_model_sort_convert_child_path_to_path (GtkTreeModelSort *tree_model_sort,
GtkTreePath *child_path);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_sort_convert_child_iter_to_iter (GtkTreeModelSort *tree_model_sort,
GtkTreeIter *sort_iter,
GtkTreeIter *child_iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
GtkTreePath *gtk_tree_model_sort_convert_path_to_child_path (GtkTreeModelSort *tree_model_sort,
GtkTreePath *sorted_path);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_sort_convert_iter_to_child_iter (GtkTreeModelSort *tree_model_sort,
GtkTreeIter *child_iter,
GtkTreeIter *sorted_iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_sort_reset_default_sort_func (GtkTreeModelSort *tree_model_sort);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_model_sort_clear_cache (GtkTreeModelSort *tree_model_sort);
GDK_DEPRECATED_IN_4_10_FOR(GtkFilterListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_model_sort_iter_is_valid (GtkTreeModelSort *tree_model_sort,
GtkTreeIter *iter);
+18 -20
View File
@@ -55,8 +55,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* Additionally, it may on occasion emit a `GtkTreeSelection`::changed signal
* when nothing has happened (mostly as a result of programmers calling
* select_row on an already selected row).
*
* Deprecated: 4.10: Use [iface@Gtk.SelectionModel] instead
*/
typedef struct _GtkTreeSelectionClass GtkTreeSelectionClass;
@@ -126,7 +124,7 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
class->changed = NULL;
/* Properties */
/**
* GtkTreeSelection:mode:
*
@@ -140,9 +138,9 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
/* Install all properties */
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
/* Signals */
/**
* GtkTreeSelection::changed:
* @treeselection: the object which received the signal.
@@ -333,7 +331,7 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
anchor_path,
&tree,
&node);
if (node && GTK_TREE_RBNODE_FLAG_SET (node, GTK_TREE_RBNODE_IS_SELECTED))
selected = TRUE;
}
@@ -357,7 +355,7 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
}
selection->type = type;
g_object_notify_by_pspec (G_OBJECT (selection), properties[PROP_MODE]);
}
@@ -452,9 +450,9 @@ gtk_tree_selection_get_user_data (GtkTreeSelection *selection)
/**
* gtk_tree_selection_get_tree_view:
* @selection: A `GtkTreeSelection`
*
*
* Returns the tree view associated with @selection.
*
*
* Returns: (transfer none): A `GtkTreeView`
*
* Deprecated: 4.10: Use GtkListView or GtkColumnView
@@ -631,7 +629,7 @@ gtk_tree_selection_get_selected_rows (GtkTreeSelection *selection,
{
gtk_tree_path_free (path);
goto done;
goto done;
}
gtk_tree_path_up (path);
@@ -780,7 +778,7 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
G_CALLBACK (model_changed),
&stop);
changed_id = g_signal_connect_swapped (selection->tree_view, "notify::model",
G_CALLBACK (model_changed),
G_CALLBACK (model_changed),
&stop);
/* find the node internally */
@@ -1003,10 +1001,10 @@ gtk_tree_selection_unselect_iter (GtkTreeSelection *selection,
* gtk_tree_selection_path_is_selected:
* @selection: A `GtkTreeSelection`.
* @path: A `GtkTreePath` to check selection on.
*
*
* Returns %TRUE if the row pointed to by @path is currently selected. If @path
* does not point to a valid location, %FALSE is returned
*
*
* Returns: %TRUE if @path is selected.
*
* Deprecated: 4.10: Use GtkListView or GtkColumnView
@@ -1042,9 +1040,9 @@ gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
* gtk_tree_selection_iter_is_selected:
* @selection: A `GtkTreeSelection`
* @iter: A valid `GtkTreeIter`
*
*
* Returns %TRUE if the row at @iter is currently selected.
*
*
* Returns: %TRUE, if @iter is selected
*
* Deprecated: 4.10: Use GtkListView or GtkColumnView
@@ -1257,7 +1255,7 @@ gtk_tree_selection_unselect_all (GtkTreeSelection *selection)
if (_gtk_tree_view_get_rbtree (selection->tree_view) == NULL ||
gtk_tree_view_get_model (selection->tree_view) == NULL)
return;
if (gtk_tree_selection_real_unselect_all (selection))
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
@@ -1359,7 +1357,7 @@ gtk_tree_selection_real_modify_range (GtkTreeSelection *selection,
* @end_path: The final node of the range.
*
* Selects a range of nodes, determined by @start_path and @end_path inclusive.
* @selection must be set to %GTK_SELECTION_MULTIPLE mode.
* @selection must be set to %GTK_SELECTION_MULTIPLE mode.
*
* Deprecated: 4.10: Use GtkListView or GtkColumnView
**/
@@ -1564,14 +1562,14 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
gtk_tree_path_free (anchor_path);
if (dirty)
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
void
void
_gtk_tree_selection_emit_changed (GtkTreeSelection *selection)
{
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
g_signal_emit (selection, tree_selection_signals[CHANGED], 0);
}
/* NOTE: Any {un,}selection ever done _MUST_ be done through this function!
+20 -23
View File
@@ -32,9 +32,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* `GtkTreeSortable` is an interface to be implemented by tree models which
* support sorting. The `GtkTreeView` uses the methods provided by this interface
* to sort the model.
*
* Deprecated: 4.10: There is no replacement for this interface. You should
* use [class@Gtk.SortListModel] to wrap your list model instead
*/
@@ -99,7 +96,7 @@ gtk_tree_sortable_base_init (gpointer g_class)
/**
* gtk_tree_sortable_sort_column_changed:
* @sortable: A `GtkTreeSortable`
*
*
* Emits a `GtkTreeSortable::sort-column-changed` signal on @sortable.
*
* Deprecated: 4.10
@@ -117,12 +114,12 @@ gtk_tree_sortable_sort_column_changed (GtkTreeSortable *sortable)
* @sortable: A `GtkTreeSortable`
* @sort_column_id: (out): The sort column id to be filled in
* @order: (out): The `GtkSortType` to be filled in
*
*
* Fills in @sort_column_id and @order with the current sort column and the
* order. It returns %TRUE unless the @sort_column_id is
* %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or
* order. It returns %TRUE unless the @sort_column_id is
* %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or
* %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
*
*
* Returns: %TRUE if the sort column is not one of the special sort
* column ids.
*
@@ -150,15 +147,15 @@ gtk_tree_sortable_get_sort_column_id (GtkTreeSortable *sortable,
* @sortable: A `GtkTreeSortable`
* @sort_column_id: the sort column id to set
* @order: The sort order of the column
*
*
* Sets the current sort column to be @sort_column_id. The @sortable will
* resort itself to reflect this change, after emitting a
* `GtkTreeSortable::sort-column-changed` signal. @sort_column_id may either be
* a regular column id, or one of the following special values:
*
*
* - %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID: the default sort function
* will be used, if it is set
*
*
* - %GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID: no sorting will occur
*
* Deprecated: 4.10
@@ -176,7 +173,7 @@ gtk_tree_sortable_set_sort_column_id (GtkTreeSortable *sortable,
g_return_if_fail (iface != NULL);
g_return_if_fail (iface->set_sort_column_id != NULL);
(* iface->set_sort_column_id) (sortable, sort_column_id, order);
}
@@ -187,9 +184,9 @@ gtk_tree_sortable_set_sort_column_id (GtkTreeSortable *sortable,
* @sort_func: The comparison function
* @user_data: (closure): User data to pass to @sort_func
* @destroy: (nullable): Destroy notifier of @user_data
*
*
* Sets the comparison function used when sorting to be @sort_func. If the
* current sort column id of @sortable is the same as @sort_column_id, then
* current sort column id of @sortable is the same as @sort_column_id, then
* the model will sort using this function.
*
* Deprecated: 4.10
@@ -221,15 +218,15 @@ gtk_tree_sortable_set_sort_func (GtkTreeSortable *sortable,
* @sort_func: The comparison function
* @user_data: (closure): User data to pass to @sort_func
* @destroy: (nullable): Destroy notifier of @user_data
*
* Sets the default comparison function used when sorting to be @sort_func.
*
* Sets the default comparison function used when sorting to be @sort_func.
* If the current sort column id of @sortable is
* %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using
* %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the model will sort using
* this function.
*
* If @sort_func is %NULL, then there will be no default comparison function.
* This means that once the model has been sorted, it cant go back to the
* default state. In this case, when the current sort column id of @sortable
* default state. In this case, when the current sort column id of @sortable
* is %GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
*
* Deprecated: 4.10
@@ -248,18 +245,18 @@ gtk_tree_sortable_set_default_sort_func (GtkTreeSortable *sortable,
g_return_if_fail (iface != NULL);
g_return_if_fail (iface->set_default_sort_func != NULL);
(* iface->set_default_sort_func) (sortable, sort_func, user_data, destroy);
}
/**
* gtk_tree_sortable_has_default_sort_func:
* @sortable: A `GtkTreeSortable`
*
*
* Returns %TRUE if the model has a default sort function. This is used
* primarily by GtkTreeViewColumns in order to determine if a model can
* primarily by GtkTreeViewColumns in order to determine if a model can
* go back to the default state, or not.
*
*
* Returns: %TRUE, if the model has a default sort function
*
* Deprecated: 4.10
@@ -275,6 +272,6 @@ gtk_tree_sortable_has_default_sort_func (GtkTreeSortable *sortable)
g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (iface->has_default_sort_func != NULL, FALSE);
return (* iface->has_default_sort_func) (sortable);
}
+123 -204
View File
@@ -31,20 +31,17 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkTreeStore:
*
* A tree-like data structure that can be used with the [class@Gtk.TreeView].
* A tree-like data structure that can be used with the GtkTreeView
*
* The `GtkTreeStore` object is a list model for use with a `GtkTreeView`
* widget. It implements the [iface@Gtk.TreeModel] interface, and consequently,
* can use all of the methods available there. It also implements the
* [iface@Gtk.TreeSortable] interface so it can be sorted by the view.
* Finally, it also implements the tree [drag][iface@Gtk.TreeDragSource]
* and [drop][iface@Gtk.TreeDragDest] interfaces.
* widget. It implements the `GtkTreeModel` interface, and consequently,
* can use all of the methods available there. It also implements the
* `GtkTreeSortable` interface so it can be sorted by the view. Finally,
* it also implements the tree
* [drag and drop][gtk3-GtkTreeView-drag-and-drop]
* interfaces.
*
* `GtkTreeStore` is deprecated since GTK 4.10, and should not be used in newly
* written code. You should use [class@Gtk.TreeListModel] for a tree-like model
* object.
*
* ## GtkTreeStore as GtkBuildable
* # GtkTreeStore as GtkBuildable
*
* The GtkTreeStore implementation of the `GtkBuildable` interface allows
* to specify the model columns with a <columns> element that may contain
@@ -52,8 +49,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* attribute specifies the data type for the column.
*
* An example of a UI Definition fragment for a tree store:
*
* ```xml
* |[
* <object class="GtkTreeStore">
* <columns>
* <column type="gchararray"/>
@@ -61,9 +57,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* <column type="gint"/>
* </columns>
* </object>
* ```
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* ]|
*/
struct _GtkTreeStorePrivate
@@ -309,26 +303,22 @@ gtk_tree_store_init (GtkTreeStore *tree_store)
* @n_columns: number of columns in the tree store
* @...: all `GType` types for the columns, from first to last
*
* Creates a new tree store.
*
* The tree store will have @n_columns, with each column using the
* corresponding type passed to this function.
*
* Note that only types derived from standard GObject fundamental types
* Creates a new tree store as with @n_columns columns each of the types passed
* in. Note that only types derived from standard GObject fundamental types
* are supported.
*
* As an example:
* As an example,
*
* ```c
* ```
* gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_TEXTURE);
* ```
*
* will create a new `GtkTreeStore` with three columns of type
* will create a new `GtkTreeStore` with three columns, of type
* `int`, `gchararray`, and `GdkTexture` respectively.
*
* Returns: a new `GtkTreeStore`
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
GtkTreeStore *
gtk_tree_store_new (int n_columns,
@@ -366,13 +356,11 @@ gtk_tree_store_new (int n_columns,
* @n_columns: number of columns in the tree store
* @types: (array length=n_columns): an array of `GType` types for the columns, from first to last
*
* Creates a new tree store.
*
* This constructor is meant for language bindings.
* Non vararg creation function. Used primarily by language bindings.
*
* Returns: (transfer full): a new `GtkTreeStore`
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
GtkTreeStore *
gtk_tree_store_newv (int n_columns,
@@ -407,17 +395,12 @@ gtk_tree_store_newv (int n_columns,
* @n_columns: Number of columns for the tree store
* @types: (array length=n_columns): An array of `GType` types, one for each column
*
* Sets the type of the columns in a tree store.
*
* This function is meant primarily for types that inherit from
* This function is meant primarily for `GObjects` that inherit from
* `GtkTreeStore`, and should only be used when constructing a new
* `GtkTreeStore`.
* `GtkTreeStore`. It will not function after a row has been added,
* or a method on the `GtkTreeModel` interface is called.
*
* This functions cannot be called after a row has been added,
* or a method on the `GtkTreeModel` interface is called on the
* tree store.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_set_column_types (GtkTreeStore *tree_store,
@@ -468,31 +451,12 @@ gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
* @column: column number
* @type: type of the data to be stored in @column
*
* Sets the type of the given column in a tree store.
* Supported types include: %G_TYPE_UINT, %G_TYPE_INT, %G_TYPE_UCHAR,
* %G_TYPE_CHAR, %G_TYPE_BOOLEAN, %G_TYPE_POINTER, %G_TYPE_FLOAT,
* %G_TYPE_DOUBLE, %G_TYPE_STRING, %G_TYPE_OBJECT, and %G_TYPE_BOXED, along with
* subclasses of those types such as %GDK_TYPE_PIXBUF.
*
* This function is meant primarily for types that inherit from
* `GtkTreeStore`, and should only be used when constructing a new
* `GtkTreeStore`.
*
* This functions cannot be called after a row has been added,
* or a method on the `GtkTreeModel` interface is called on the
* tree store.
*
* Supported types include:
*
* - `G_TYPE_UINT`
* - `G_TYPE_INT`
* - `G_TYPE_UCHAR`
* - `G_TYPE_CHAR`
* - `G_TYPE_BOOLEAN`
* - `G_TYPE_POINTER`
* - `G_TYPE_FLOAT`
* - `G_TYPE_DOUBLE`
* - `G_TYPE_STRING`
* - `G_TYPE_BOXED` and its derived types
* - `G_TYPE_OBJECT` and its derived types
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
static void
gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
@@ -986,11 +950,10 @@ gtk_tree_store_real_set_value (GtkTreeStore *tree_store,
* @value: new value for the cell
*
* Sets the data in the cell specified by @iter and @column.
*
* The type of @value must be convertible to the type of the
* column.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_set_value (GtkTreeStore *tree_store,
@@ -1134,13 +1097,11 @@ gtk_tree_store_set_valist_internal (GtkTreeStore *tree_store,
* @n_values: the length of the @columns and @values arrays
*
* A variant of gtk_tree_store_set_valist() which takes
* the columns and values as two arrays, instead of using variadic
* arguments.
*
* This function is mainly intended for language bindings or in case
* the columns and values as two arrays, instead of varargs. This
* function is mainly intended for language bindings or in case
* the number of columns to change is not known until run-time.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
@@ -1180,9 +1141,10 @@ gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
* @iter: A valid `GtkTreeIter` for the row being modified
* @var_args: va_list of column/value pairs
*
* A version of gtk_tree_store_set() using `va_list`.
* See gtk_tree_store_set(); this version takes a va_list for
* use by language bindings.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_set_valist (GtkTreeStore *tree_store,
@@ -1221,23 +1183,16 @@ gtk_tree_store_set_valist (GtkTreeStore *tree_store,
* @...: pairs of column number and value, terminated with -1
*
* Sets the value of one or more cells in the row referenced by @iter.
*
* The variable argument list should contain integer column numbers,
* each column number followed by the value to be set.
* The list is terminated by a -1. For example, to set column 0 with type
* %G_TYPE_STRING to Foo, you would write
* `gtk_tree_store_set (store, iter, 0, "Foo", -1)`.
*
* The list is terminated by a value of `-1`.
* The value will be referenced by the store if it is a %G_TYPE_OBJECT, and it
* will be copied if it is a %G_TYPE_STRING or %G_TYPE_BOXED.
*
* For example, to set column 0 with type `G_TYPE_STRING` to Foo, you would
* write
*
* ```c
* gtk_tree_store_set (store, iter, 0, "Foo", -1);
* ```
*
* The value will be referenced by the store if it is a `G_TYPE_OBJECT`, and it
* will be copied if it is a `G_TYPE_STRING` or `G_TYPE_BOXED`.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_set (GtkTreeStore *tree_store,
@@ -1256,14 +1211,13 @@ gtk_tree_store_set (GtkTreeStore *tree_store,
* @tree_store: A `GtkTreeStore`
* @iter: A valid `GtkTreeIter`
*
* Removes @iter from @tree_store.
* Removes @iter from @tree_store. After being removed, @iter is set to the
* next valid row at that level, or invalidated if it previously pointed to the
* last one.
*
* After being removed, @iter is set to the next valid row at that level, or
* invalidated if it previously pointed to the last one.
* Returns: %TRUE if @iter is still valid, %FALSE if not.
*
* Returns: true if @iter is still valid, and false otherwise
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
gboolean
gtk_tree_store_remove (GtkTreeStore *tree_store,
@@ -1329,19 +1283,15 @@ gtk_tree_store_remove (GtkTreeStore *tree_store,
* @parent: (nullable): A valid `GtkTreeIter`
* @position: position to insert the new row, or -1 for last
*
* Creates a new row at @position.
* Creates a new row at @position. If parent is non-%NULL, then the row will be
* made a child of @parent. Otherwise, the row will be created at the toplevel.
* If @position is -1 or is larger than the number of rows at that level, then
* the new row will be inserted to the end of the list. @iter will be changed
* to point to this new row. The row will be empty after this function is
* called. To fill in values, you need to call gtk_tree_store_set() or
* gtk_tree_store_set_value().
*
* If parent is non-%NULL, then the row will be made a child of @parent.
* Otherwise, the row will be created at the toplevel.
*
* If @position is `-1` or is larger than the number of rows at that level,
* then the new row will be inserted to the end of the list.
*
* The @iter parameter will be changed to point to this new row. The row
* will be empty after this function is called. To fill in values, you
* need to call gtk_tree_store_set() or gtk_tree_store_set_value().
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_insert (GtkTreeStore *tree_store,
@@ -1396,21 +1346,17 @@ gtk_tree_store_insert (GtkTreeStore *tree_store,
* @parent: (nullable): A valid `GtkTreeIter`
* @sibling: (nullable): A valid `GtkTreeIter`
*
* Inserts a new row before @sibling.
* Inserts a new row before @sibling. If @sibling is %NULL, then the row will
* be appended to @parent s children. If @parent and @sibling are %NULL, then
* the row will be appended to the toplevel. If both @sibling and @parent are
* set, then @parent must be the parent of @sibling. When @sibling is set,
* @parent is optional.
*
* If @sibling is %NULL, then the row will be appended to @parents children.
*
* If @parent and @sibling are %NULL, then the row will be appended to the
* toplevel.
*
* If both @sibling and @parent are set, then @parent must be the parent
* of @sibling. When @sibling is set, @parent is optional.
*
* The @iter parameter will be changed to point to this new row. The row will
* be empty after this function is called. To fill in values, you need to call
* @iter will be changed to point to this new row. The row will be empty after
* this function is called. To fill in values, you need to call
* gtk_tree_store_set() or gtk_tree_store_set_value().
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_insert_before (GtkTreeStore *tree_store,
@@ -1482,21 +1428,17 @@ gtk_tree_store_insert_before (GtkTreeStore *tree_store,
* @parent: (nullable): A valid `GtkTreeIter`
* @sibling: (nullable): A valid `GtkTreeIter`
*
* Inserts a new row after @sibling.
* Inserts a new row after @sibling. If @sibling is %NULL, then the row will be
* prepended to @parent s children. If @parent and @sibling are %NULL, then
* the row will be prepended to the toplevel. If both @sibling and @parent are
* set, then @parent must be the parent of @sibling. When @sibling is set,
* @parent is optional.
*
* If @sibling is %NULL, then the row will be prepended to @parents children.
*
* If @parent and @sibling are %NULL, then the row will be prepended to the
* toplevel.
*
* If both @sibling and @parent are set, then @parent must be the parent
* of @sibling. When @sibling is set, @parent is optional.
*
* The @iter parameter will be changed to point to this new row. The row will
* be empty after this function is called. To fill in values, you need to call
* @iter will be changed to point to this new row. The row will be empty after
* this function is called. To fill in values, you need to call
* gtk_tree_store_set() or gtk_tree_store_set_value().
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_insert_after (GtkTreeStore *tree_store,
@@ -1570,34 +1512,26 @@ gtk_tree_store_insert_after (GtkTreeStore *tree_store,
* @position: position to insert the new row, or -1 to append after existing rows
* @...: pairs of column number and value, terminated with -1
*
* Creates a new row at the given @position.
*
* The @iter parameter will be changed to point to this new row.
*
* If @position is -1, or larger than the number of rows on the list, then
* Creates a new row at @position. @iter will be changed to point to this
* new row. If @position is -1, or larger than the number of rows on the list, then
* the new row will be appended to the list. The row will be filled with
* the values given to this function.
*
* Calling
*
* gtk_tree_store_insert_with_values (tree_store, iter, position, ...)
*
* `gtk_tree_store_insert_with_values (tree_store, iter, position, ...)`
* has the same effect as calling
*
* ```c
* |[<!-- language="C" -->
* gtk_tree_store_insert (tree_store, iter, position);
* gtk_tree_store_set (tree_store, iter, ...);
* ```
*
* ]|
* with the different that the former will only emit a row_inserted signal,
* while the latter will emit row_inserted, row_changed and if the tree store
* is sorted, rows_reordered.
* is sorted, rows_reordered. Since emitting the rows_reordered signal
* repeatedly can affect the performance of the program,
* gtk_tree_store_insert_with_values() should generally be preferred when
* inserting rows in a sorted tree store.
*
* Since emitting the rows_reordered signal repeatedly can affect the
* performance of the program, gtk_tree_store_insert_with_values() should
* generally be preferred when inserting rows in a sorted tree store.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
*/
void
gtk_tree_store_insert_with_values (GtkTreeStore *tree_store,
@@ -1673,11 +1607,10 @@ gtk_tree_store_insert_with_values (GtkTreeStore *tree_store,
* @n_values: the length of the @columns and @values arrays
*
* A variant of gtk_tree_store_insert_with_values() which takes
* the columns and values as two arrays, instead of varargs.
* the columns and values as two arrays, instead of varargs. This
* function is mainly intended for language bindings.
*
* This function is mainly intended for language bindings.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
*/
void
gtk_tree_store_insert_with_valuesv (GtkTreeStore *tree_store,
@@ -1747,15 +1680,13 @@ gtk_tree_store_insert_with_valuesv (GtkTreeStore *tree_store,
* @iter: (out): An unset `GtkTreeIter` to set to the prepended row
* @parent: (nullable): A valid `GtkTreeIter`
*
* Prepends a new row to @tree_store.
*
* If @parent is non-%NULL, then it will prepend the new row before the first
* child of @parent, otherwise it will prepend a row to the top level. The
* `iter` parameter will be changed to point to this new row. The row will
* be empty after this function is called. To fill in values, you need to
* Prepends a new row to @tree_store. If @parent is non-%NULL, then it will prepend
* the new row before the first child of @parent, otherwise it will prepend a row
* to the top level. @iter will be changed to point to this new row. The row
* will be empty after this function is called. To fill in values, you need to
* call gtk_tree_store_set() or gtk_tree_store_set_value().
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_prepend (GtkTreeStore *tree_store,
@@ -1810,16 +1741,13 @@ gtk_tree_store_prepend (GtkTreeStore *tree_store,
* @iter: (out): An unset `GtkTreeIter` to set to the appended row
* @parent: (nullable): A valid `GtkTreeIter`
*
* Appends a new row to @tree_store.
*
* If @parent is non-%NULL, then it will append the new row after the last
* child of @parent, otherwise it will append a row to the top level.
*
* The @iter parameter will be changed to point to this new row. The row will
* be empty after this function is called. To fill in values, you need to call
* Appends a new row to @tree_store. If @parent is non-%NULL, then it will append the
* new row after the last child of @parent, otherwise it will append a row to
* the top level. @iter will be changed to point to this new row. The row will
* be empty after this function is called. To fill in values, you need to call
* gtk_tree_store_set() or gtk_tree_store_set_value().
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_append (GtkTreeStore *tree_store,
@@ -1874,11 +1802,12 @@ gtk_tree_store_append (GtkTreeStore *tree_store,
* @iter: A valid `GtkTreeIter`
* @descendant: A valid `GtkTreeIter`
*
* Checks if @iter is an ancestor of @descendant.
* Returns %TRUE if @iter is an ancestor of @descendant. That is, @iter is the
* parent (or grandparent or great-grandparent) of @descendant.
*
* Returns: true if @iter is an ancestor of @descendant, and false otherwise
* Returns: %TRUE, if @iter is an ancestor of @descendant
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
gboolean
gtk_tree_store_is_ancestor (GtkTreeStore *tree_store,
@@ -1899,14 +1828,12 @@ gtk_tree_store_is_ancestor (GtkTreeStore *tree_store,
* @tree_store: A `GtkTreeStore`
* @iter: A valid `GtkTreeIter`
*
* Returns the depth of the position pointed by the iterator
* Returns the depth of @iter. This will be 0 for anything on the root level, 1
* for anything down a level, etc.
*
* The depth will be 0 for anything on the root level, 1 for anything down
* a level, etc.
* Returns: The depth of @iter
*
* Returns: The depth of the position pointed by the iterator
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
int
gtk_tree_store_iter_depth (GtkTreeStore *tree_store,
@@ -1976,7 +1903,7 @@ gtk_tree_store_increment_stamp (GtkTreeStore *tree_store)
*
* Removes all rows from @tree_store
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_clear (GtkTreeStore *tree_store)
@@ -2021,9 +1948,9 @@ gtk_tree_store_iter_is_valid_helper (GtkTreeIter *iter,
* This function is slow. Only use it for debugging and/or testing
* purposes.
*
* Returns: true if the iter is valid, and false otherwise
* Returns: %TRUE if the iter is valid, %FALSE if the iter is invalid.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
gboolean
gtk_tree_store_iter_is_valid (GtkTreeStore *tree_store,
@@ -2343,17 +2270,16 @@ gtk_tree_store_reorder_func (gconstpointer a,
/**
* gtk_tree_store_reorder: (skip)
* @tree_store: A `GtkTreeStore`
* @parent: (nullable): the parent of the children to re-order
* @new_order: (array): an array of integers mapping the new position
* of each child to its old position before the re-ordering,
* i.e. `new_order[newpos] = oldpos`
* @parent: (nullable): A `GtkTreeIter`
* @new_order: (array): an array of integers mapping the new position of each child
* to its old position before the re-ordering,
* i.e. @new_order`[newpos] = oldpos`.
*
* Reorders the children of @parent in @tree_store to follow the order
* indicated by @new_order.
* indicated by @new_order. Note that this function only works with
* unsorted stores.
*
* Note that this function only works with unsorted stores.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
*/
void
gtk_tree_store_reorder (GtkTreeStore *tree_store,
@@ -2438,11 +2364,10 @@ gtk_tree_store_reorder (GtkTreeStore *tree_store,
* @a: A `GtkTreeIter`.
* @b: Another `GtkTreeIter`.
*
* Swaps @a and @b in the same level of @tree_store.
* Swaps @a and @b in the same level of @tree_store. Note that this function
* only works with unsorted stores.
*
* Note that this function only works with unsorted stores.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_swap (GtkTreeStore *tree_store,
@@ -2905,15 +2830,12 @@ free_paths_and_out:
* @iter: A `GtkTreeIter`
* @position: (nullable): A `GtkTreeIter`
*
* Moves @iter in @tree_store to the position before @position.
* Moves @iter in @tree_store to the position before @position. @iter and
* @position should be in the same level. Note that this function only
* works with unsorted stores. If @position is %NULL, @iter will be
* moved to the end of the level.
*
* @iter and @position should be in the same level.
*
* Note that this function only works with unsorted stores.
*
* If @position is %NULL, @iter will be moved to the end of the level.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_move_before (GtkTreeStore *tree_store,
@@ -2929,15 +2851,12 @@ gtk_tree_store_move_before (GtkTreeStore *tree_store,
* @iter: A `GtkTreeIter`.
* @position: (nullable): A `GtkTreeIter`.
*
* Moves @iter in @tree_store to the position after @position.
* Moves @iter in @tree_store to the position after @position. @iter and
* @position should be in the same level. Note that this function only
* works with unsorted stores. If @position is %NULL, @iter will be moved
* to the start of the level.
*
* @iter and @position should be in the same level.
*
* Note that this function only works with unsorted stores.
*
* If @position is %NULL, @iter will be moved to the start of the level.
*
* Deprecated: 4.10: Use [class@Gtk.TreeListModel] instead
* Deprecated: 4.10
**/
void
gtk_tree_store_move_after (GtkTreeStore *tree_store,
+23 -23
View File
@@ -60,63 +60,63 @@ struct _GtkTreeStoreClass
GDK_AVAILABLE_IN_ALL
GType gtk_tree_store_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeStore *gtk_tree_store_new (int n_columns,
...);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
GtkTreeStore *gtk_tree_store_newv (int n_columns,
GType *types);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_set_column_types (GtkTreeStore *tree_store,
int n_columns,
GType *types);
/* NOTE: use gtk_tree_model_get to get values from a GtkTreeStore */
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_set_value (GtkTreeStore *tree_store,
GtkTreeIter *iter,
int column,
GValue *value);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_set (GtkTreeStore *tree_store,
GtkTreeIter *iter,
...);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_set_valuesv (GtkTreeStore *tree_store,
GtkTreeIter *iter,
int *columns,
GValue *values,
int n_values);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_set_valist (GtkTreeStore *tree_store,
GtkTreeIter *iter,
va_list var_args);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_store_remove (GtkTreeStore *tree_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_insert (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent,
int position);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_insert_before (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent,
GtkTreeIter *sibling);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_insert_after (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent,
GtkTreeIter *sibling);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_insert_with_values (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent,
int position,
...);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_insert_with_valuesv (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent,
@@ -124,39 +124,39 @@ void gtk_tree_store_insert_with_valuesv (GtkTreeStore *tree_store,
int *columns,
GValue *values,
int n_values);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_prepend (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_append (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *parent);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_store_is_ancestor (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *descendant);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
int gtk_tree_store_iter_depth (GtkTreeStore *tree_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_clear (GtkTreeStore *tree_store);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_store_iter_is_valid (GtkTreeStore *tree_store,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_reorder (GtkTreeStore *tree_store,
GtkTreeIter *parent,
int *new_order);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_swap (GtkTreeStore *tree_store,
GtkTreeIter *a,
GtkTreeIter *b);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_move_before (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *position);
GDK_DEPRECATED_IN_4_10_FOR(GtkTreeListModel)
GDK_DEPRECATED_IN_4_10
void gtk_tree_store_move_after (GtkTreeStore *tree_store,
GtkTreeIter *iter,
GtkTreeIter *position);
File diff suppressed because it is too large Load Diff
+91 -91
View File
@@ -190,56 +190,56 @@ GDK_AVAILABLE_IN_ALL
GType gtk_tree_view_get_type (void) G_GNUC_CONST;
/* Creators */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_tree_view_new (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_tree_view_new_with_model (GtkTreeModel *model);
/* Accessors */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeModel *gtk_tree_view_get_model (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_model (GtkTreeView *tree_view,
GtkTreeModel *model);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeSelection *gtk_tree_view_get_selection (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_headers_visible (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
gboolean headers_visible);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_columns_autosize (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_headers_clickable (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_headers_clickable (GtkTreeView *tree_view,
gboolean setting);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_activate_on_single_click (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view,
gboolean single);
/* Column functions */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_append_column (GtkTreeView *tree_view,
GtkTreeViewColumn *column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_remove_column (GtkTreeView *tree_view,
GtkTreeViewColumn *column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_insert_column (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
int position);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_insert_column_with_attributes (GtkTreeView *tree_view,
int position,
const char *title,
GtkCellRenderer *cell,
...) G_GNUC_NULL_TERMINATED;
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_insert_column_with_data_func (GtkTreeView *tree_view,
int position,
const char *title,
@@ -248,89 +248,89 @@ int gtk_tree_view_insert_column_with_data_func (GtkTreeView
gpointer data,
GDestroyNotify dnotify);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
guint gtk_tree_view_get_n_columns (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeViewColumn *gtk_tree_view_get_column (GtkTreeView *tree_view,
int n);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GList *gtk_tree_view_get_columns (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_move_column_after (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GtkTreeViewColumn *base_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_expander_column (GtkTreeView *tree_view,
GtkTreeViewColumn *column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeViewColumn *gtk_tree_view_get_expander_column (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_column_drag_function (GtkTreeView *tree_view,
GtkTreeViewColumnDropFunc func,
gpointer user_data,
GDestroyNotify destroy);
/* Actions */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_scroll_to_point (GtkTreeView *tree_view,
int tree_x,
int tree_y);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_scroll_to_cell (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gboolean use_align,
float row_align,
float col_align);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_row_activated (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_expand_all (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_collapse_all (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_expand_to_path (GtkTreeView *tree_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_expand_row (GtkTreeView *tree_view,
GtkTreePath *path,
gboolean open_all);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_collapse_row (GtkTreeView *tree_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_map_expanded_rows (GtkTreeView *tree_view,
GtkTreeViewMappingFunc func,
gpointer data);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_row_expanded (GtkTreeView *tree_view,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
gboolean reorderable);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_reorderable (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_cursor (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *focus_column,
gboolean start_editing);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_cursor_on_cell (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *focus_column,
GtkCellRenderer *focus_cell,
gboolean start_editing);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_get_cursor (GtkTreeView *tree_view,
GtkTreePath **path,
GtkTreeViewColumn **focus_column);
/* Layout information */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_path_at_pos (GtkTreeView *tree_view,
int x,
int y,
@@ -338,24 +338,24 @@ gboolean gtk_tree_view_get_path_at_pos (GtkTreeView
GtkTreeViewColumn **column,
int *cell_x,
int *cell_y);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_get_cell_area (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GdkRectangle *rect);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_get_background_area (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GdkRectangle *rect);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
GdkRectangle *visible_rect);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_visible_range (GtkTreeView *tree_view,
GtkTreePath **start_path,
GtkTreePath **end_path);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_is_blank_at_pos (GtkTreeView *tree_view,
int x,
int y,
@@ -365,168 +365,168 @@ gboolean gtk_tree_view_is_blank_at_pos (GtkTreeView
int *cell_y);
/* Drag-and-Drop support */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
GdkModifierType start_button_mask,
GdkContentFormats *formats,
GdkDragAction actions);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
GdkContentFormats *formats,
GdkDragAction actions);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_unset_rows_drag_source (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_unset_rows_drag_dest (GtkTreeView *tree_view);
/* These are useful to implement your own custom stuff. */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_drag_dest_row (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewDropPosition pos);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_get_drag_dest_row (GtkTreeView *tree_view,
GtkTreePath **path,
GtkTreeViewDropPosition *pos);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_dest_row_at_pos (GtkTreeView *tree_view,
int drag_x,
int drag_y,
GtkTreePath **path,
GtkTreeViewDropPosition *pos);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GdkPaintable *gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GtkTreePath *path);
/* Interactive search */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_enable_search (GtkTreeView *tree_view,
gboolean enable_search);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_enable_search (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_get_search_column (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_search_column (GtkTreeView *tree_view,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeViewSearchEqualFunc gtk_tree_view_get_search_equal_func (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_search_equal_func (GtkTreeView *tree_view,
GtkTreeViewSearchEqualFunc search_equal_func,
gpointer search_user_data,
GDestroyNotify search_destroy);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkEditable *gtk_tree_view_get_search_entry (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_search_entry (GtkTreeView *tree_view,
GtkEditable *entry);
/* Convert between the different coordinate systems */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_convert_widget_to_tree_coords (GtkTreeView *tree_view,
int wx,
int wy,
int *tx,
int *ty);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_convert_tree_to_widget_coords (GtkTreeView *tree_view,
int tx,
int ty,
int *wx,
int *wy);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_convert_widget_to_bin_window_coords (GtkTreeView *tree_view,
int wx,
int wy,
int *bx,
int *by);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_convert_bin_window_to_widget_coords (GtkTreeView *tree_view,
int bx,
int by,
int *wx,
int *wy);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_convert_tree_to_bin_window_coords (GtkTreeView *tree_view,
int tx,
int ty,
int *bx,
int *by);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_convert_bin_window_to_tree_coords (GtkTreeView *tree_view,
int bx,
int by,
int *tx,
int *ty);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_fixed_height_mode (GtkTreeView *tree_view,
gboolean enable);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_fixed_height_mode (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_hover_selection (GtkTreeView *tree_view,
gboolean hover);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_hover_selection (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_hover_expand (GtkTreeView *tree_view,
gboolean expand);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_hover_expand (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_rubber_banding (GtkTreeView *tree_view,
gboolean enable);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_rubber_banding (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_is_rubber_banding_active (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeViewRowSeparatorFunc gtk_tree_view_get_row_separator_func (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_row_separator_func (GtkTreeView *tree_view,
GtkTreeViewRowSeparatorFunc func,
gpointer data,
GDestroyNotify destroy);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
GtkTreeViewGridLines gtk_tree_view_get_grid_lines (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_grid_lines (GtkTreeView *tree_view,
GtkTreeViewGridLines grid_lines);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_enable_tree_lines (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_enable_tree_lines (GtkTreeView *tree_view,
gboolean enabled);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_show_expanders (GtkTreeView *tree_view,
gboolean enabled);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_show_expanders (GtkTreeView *tree_view);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_level_indentation (GtkTreeView *tree_view,
int indentation);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_get_level_indentation (GtkTreeView *tree_view);
/* Convenience functions for setting tooltips */
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_tooltip_row (GtkTreeView *tree_view,
GtkTooltip *tooltip,
GtkTreePath *path);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_tooltip_cell (GtkTreeView *tree_view,
GtkTooltip *tooltip,
GtkTreePath *path,
GtkTreeViewColumn *column,
GtkCellRenderer *cell);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_get_tooltip_context(GtkTreeView *tree_view,
int x,
int y,
@@ -534,10 +534,10 @@ gboolean gtk_tree_view_get_tooltip_context(GtkTreeView *tree_view,
GtkTreeModel **model,
GtkTreePath **path,
GtkTreeIter *iter);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_set_tooltip_column (GtkTreeView *tree_view,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkListView)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_get_tooltip_column (GtkTreeView *tree_view);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeView, g_object_unref)
+79 -82
View File
@@ -56,9 +56,6 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
* for an overview of all the objects and data types related to the tree widget and
* how they work together, and to the [class@Gtk.TreeView] documentation for specifics
* about the CSS node structure for treeviews and their headers.
*
* Deprecated: 4.10: Use [class@Gtk.ColumnView] and [class@Gtk.ColumnViewColumn]
* instead of [class@Gtk.TreeView] to show a tabular list
*/
@@ -152,7 +149,7 @@ struct _GtkTreeViewColumnClass
};
struct _GtkTreeViewColumnPrivate
struct _GtkTreeViewColumnPrivate
{
GtkWidget *tree_view;
GtkWidget *button;
@@ -384,7 +381,7 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
*
* The `GtkCellArea` used to layout cell renderers for this column.
*
* If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area()
* If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area()
* a horizontally oriented `GtkCellAreaBox` will be used.
*/
tree_column_props[PROP_CELL_AREA] =
@@ -470,14 +467,14 @@ gtk_tree_view_column_dispose (GObject *object)
GtkTreeViewColumn *tree_column = (GtkTreeViewColumn *) object;
GtkTreeViewColumnPrivate *priv = tree_column->priv;
/* Remove this column from its treeview,
/* Remove this column from its treeview,
* in case this column is destroyed before its treeview.
*/
*/
if (priv->tree_view)
gtk_tree_view_remove_column (GTK_TREE_VIEW (priv->tree_view), tree_column);
if (priv->cell_area_context)
{
{
g_signal_handler_disconnect (priv->cell_area_context,
priv->context_changed_signal);
@@ -609,7 +606,7 @@ gtk_tree_view_column_set_property (GObject *object,
gtk_tree_view_column_set_sort_order (tree_column,
g_value_get_enum (value));
break;
case PROP_SORT_COLUMN_ID:
gtk_tree_view_column_set_sort_column_id (tree_column,
g_value_get_int (value));
@@ -734,7 +731,7 @@ gtk_tree_view_column_get_property (GObject *object,
g_value_set_enum (value,
gtk_tree_view_column_get_sort_order (tree_column));
break;
case PROP_SORT_COLUMN_ID:
g_value_set_int (value,
gtk_tree_view_column_get_sort_column_id (tree_column));
@@ -743,7 +740,7 @@ gtk_tree_view_column_get_property (GObject *object,
case PROP_CELL_AREA:
g_value_set_object (value, tree_column->priv->cell_area);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -982,7 +979,7 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
gtk_widget_hide (priv->button);
}
}
if (priv->reorderable || priv->clickable)
{
gtk_widget_set_focusable (priv->button, TRUE);
@@ -1180,7 +1177,7 @@ gtk_tree_view_column_setup_sort_column_id_callback (GtkTreeViewColumn *tree_colu
gtk_tree_view_column_set_sort_indicator (tree_column, TRUE);
gtk_tree_view_column_set_sort_order (tree_column, real_order);
}
else
else
{
gtk_tree_view_column_set_sort_indicator (tree_column, FALSE);
}
@@ -1195,7 +1192,7 @@ gtk_tree_view_column_context_changed (GtkCellAreaContext *context,
/* Here we want the column re-requested if the underlying context was
* actually reset for any reason, this can happen if the underlying
* area/cell configuration changes (i.e. cell packing properties
* or cell spacing and the like)
* or cell spacing and the like)
*
* Note that we block this handler while requesting for sizes
* so there is no need to check for the new context size being -1,
@@ -1224,13 +1221,13 @@ gtk_tree_view_column_add_editable_callback (GtkCellArea *area,
if (priv->tree_view)
{
path = gtk_tree_path_new_from_string (path_string);
_gtk_tree_view_add_editable (GTK_TREE_VIEW (priv->tree_view),
column,
path,
edit_widget,
cell_area);
gtk_tree_path_free (path);
}
}
@@ -1452,9 +1449,9 @@ _gtk_tree_view_column_is_blank_at_pos (GtkTreeViewColumn *column,
/**
* gtk_tree_view_column_new:
*
*
* Creates a new `GtkTreeViewColumn`.
*
*
* Returns: A newly created `GtkTreeViewColumn`.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1472,9 +1469,9 @@ gtk_tree_view_column_new (void)
/**
* gtk_tree_view_column_new_with_area:
* @area: the `GtkCellArea` that the newly created column should use to layout cells.
*
*
* Creates a new `GtkTreeViewColumn` using @area to render its cells.
*
*
* Returns: A newly created `GtkTreeViewColumn`.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1508,7 +1505,7 @@ gtk_tree_view_column_new_with_area (GtkCellArea *area)
* {
* GtkTreeViewColumn *column;
* GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
*
*
* column = gtk_tree_view_column_new_with_attributes ("Title",
* renderer,
* "text", TEXT_COLUMN,
@@ -1516,7 +1513,7 @@ gtk_tree_view_column_new_with_area (GtkCellArea *area)
* NULL);
* }
* ]|
*
*
* Returns: A newly created `GtkTreeViewColumn`.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1584,7 +1581,7 @@ gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_clear:
* @tree_column: A `GtkTreeViewColumn`
*
*
* Unsets all the mappings on all renderers on the @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1601,7 +1598,7 @@ gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column)
* @cell_renderer: the `GtkCellRenderer` to set attributes on
* @attribute: An attribute on the renderer
* @column: The column position on the model to get the attribute from.
*
*
* Adds an attribute mapping to the list in @tree_column.
*
* The @column is the
@@ -1636,7 +1633,7 @@ gtk_tree_view_column_set_attributesv (GtkTreeViewColumn *tree_column,
gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (priv->cell_area),
cell_renderer);
while (attribute != NULL)
{
column = va_arg (args, int);
@@ -1680,10 +1677,10 @@ gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
* gtk_tree_view_column_set_cell_data_func:
* @tree_column: A `GtkTreeViewColumn`
* @cell_renderer: A `GtkCellRenderer`
* @func: (nullable): The `GtkTreeCellDataFunc` to use.
* @func: (nullable): The `GtkTreeCellDataFunc` to use.
* @func_data: (closure): The user data for @func.
* @destroy: The destroy notification for @func_data
*
*
* Sets the `GtkTreeCellDataFunc` to use for the column.
*
* This
@@ -1730,7 +1727,7 @@ gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
* gtk_tree_view_column_set_spacing:
* @tree_column: A `GtkTreeViewColumn`.
* @spacing: distance between cell renderers in pixels.
*
*
* Sets the spacing field of @tree_column, which is the number of pixels to
* place between cell renderers packed into it.
*
@@ -1759,9 +1756,9 @@ gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_spacing:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the spacing of @tree_column.
*
*
* Returns: the spacing of @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1784,7 +1781,7 @@ gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_visible:
* @tree_column: A `GtkTreeViewColumn`.
* @visible: %TRUE if the @tree_column is visible.
*
*
* Sets the visibility of @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1817,9 +1814,9 @@ gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_visible:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns %TRUE if @tree_column is visible.
*
*
* Returns: whether the column is visible or not. If it is visible, then
* the tree will show the column.
*
@@ -1837,7 +1834,7 @@ gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_resizable:
* @tree_column: A `GtkTreeViewColumn`
* @resizable: %TRUE, if the column can be resized
*
*
* If @resizable is %TRUE, then the user can explicitly resize the column by
* grabbing the outer edge of the column button.
*
@@ -1874,9 +1871,9 @@ gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_resizable:
* @tree_column: A `GtkTreeViewColumn`
*
*
* Returns %TRUE if the @tree_column can be resized by the end user.
*
*
* Returns: %TRUE, if the @tree_column can be resized.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1894,7 +1891,7 @@ gtk_tree_view_column_get_resizable (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_sizing:
* @tree_column: A `GtkTreeViewColumn`.
* @type: The `GtkTreeViewColumn`Sizing.
*
*
* Sets the growth behavior of @tree_column to @type.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1925,9 +1922,9 @@ gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_sizing:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the current type of @tree_column.
*
*
* Returns: The type of @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1943,9 +1940,9 @@ gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column)
/**
* gtk_tree_view_column_get_width:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the current size of @tree_column in pixels.
*
*
* Returns: The current width of @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -1961,9 +1958,9 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
/**
* gtk_tree_view_column_get_x_offset:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the current X offset of @tree_column in pixels.
*
*
* Returns: The current X offset of @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2124,7 +2121,7 @@ gtk_tree_view_column_get_fixed_width (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_min_width:
* @tree_column: A `GtkTreeViewColumn`.
* @min_width: The minimum width of the column in pixels, or -1.
*
*
* Sets the minimum width of the @tree_column. If @min_width is -1, then the
* minimum width is unset.
*
@@ -2170,10 +2167,10 @@ gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_min_width:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the minimum width in pixels of the @tree_column, or -1 if no minimum
* width is set.
*
*
* Returns: The minimum width of the @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2190,7 +2187,7 @@ gtk_tree_view_column_get_min_width (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_max_width:
* @tree_column: A `GtkTreeViewColumn`.
* @max_width: The maximum width of the column in pixels, or -1.
*
*
* Sets the maximum width of the @tree_column. If @max_width is -1, then the
* maximum width is unset. Note, the column can actually be wider than max
* width if its the last column in a view. In this case, the column expands to
@@ -2238,10 +2235,10 @@ gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_max_width:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the maximum width in pixels of the @tree_column, or -1 if no maximum
* width is set.
*
*
* Returns: The maximum width of the @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2257,7 +2254,7 @@ gtk_tree_view_column_get_max_width (GtkTreeViewColumn *tree_column)
/**
* gtk_tree_view_column_clicked:
* @tree_column: a `GtkTreeViewColumn`
*
*
* Emits the clicked signal on the column. This function will only work if
* @tree_column is clickable.
*
@@ -2280,7 +2277,7 @@ gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_title:
* @tree_column: A `GtkTreeViewColumn`.
* @title: The title of the @tree_column.
*
*
* Sets the title of the @tree_column. If a custom widget has been set, then
* this value is ignored.
*
@@ -2308,9 +2305,9 @@ gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_title:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the title of the widget.
*
*
* Returns: the title of the column. This string should not be
* modified or freed.
*
@@ -2386,7 +2383,7 @@ gtk_tree_view_column_get_expand (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_clickable:
* @tree_column: A `GtkTreeViewColumn`.
* @clickable: %TRUE if the header is active.
*
*
* Sets the header to be active if @clickable is %TRUE. When the header is
* active, then it can take keyboard focus, and can be clicked.
*
@@ -2414,9 +2411,9 @@ gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_clickable:
* @tree_column: a `GtkTreeViewColumn`
*
*
* Returns %TRUE if the user can click on the header for the column.
*
*
* Returns: %TRUE if user can click the column header.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2485,7 +2482,7 @@ gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_alignment:
* @tree_column: A `GtkTreeViewColumn`.
* @xalign: The alignment, which is between [0.0 and 1.0] inclusive.
*
*
* Sets the alignment of the title or custom widget inside the column header.
* The alignment determines its location inside the button -- 0.0 for left, 0.5
* for center, 1.0 for right.
@@ -2515,10 +2512,10 @@ gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_alignment:
* @tree_column: A `GtkTreeViewColumn`.
*
*
* Returns the current x alignment of @tree_column. This value can range
* between 0.0 and 1.0.
*
*
* Returns: The current alignent of @tree_column.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2535,7 +2532,7 @@ gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column)
* gtk_tree_view_column_set_reorderable:
* @tree_column: A `GtkTreeViewColumn`
* @reorderable: %TRUE, if the column can be reordered.
*
*
* If @reorderable is %TRUE, then the column can be reordered by the end user
* dragging the header.
*
@@ -2565,9 +2562,9 @@ gtk_tree_view_column_set_reorderable (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_reorderable:
* @tree_column: A `GtkTreeViewColumn`
*
*
* Returns %TRUE if the @tree_column can be reordered by the user.
*
*
* Returns: %TRUE if the @tree_column can be reordered by the user.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2586,7 +2583,7 @@ gtk_tree_view_column_get_reorderable (GtkTreeViewColumn *tree_column)
* @tree_column: a `GtkTreeViewColumn`
* @sort_column_id: The @sort_column_id of the model to sort on.
*
* Sets the logical @sort_column_id that this column sorts on when this column
* Sets the logical @sort_column_id that this column sorts on when this column
* is selected for sorting. Doing so makes the column header clickable.
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2696,9 +2693,9 @@ gtk_tree_view_column_set_sort_indicator (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_sort_indicator:
* @tree_column: a `GtkTreeViewColumn`
*
*
* Gets the value set by gtk_tree_view_column_set_sort_indicator().
*
*
* Returns: whether the sort indicator arrow is displayed
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2716,16 +2713,16 @@ gtk_tree_view_column_get_sort_indicator (GtkTreeViewColumn *tree_column)
* @tree_column: a `GtkTreeViewColumn`
* @order: sort order that the sort indicator should indicate
*
* Changes the appearance of the sort indicator.
*
* Changes the appearance of the sort indicator.
*
* This does not actually sort the model. Use
* gtk_tree_view_column_set_sort_column_id() if you want automatic sorting
* support. This function is primarily for custom sorting behavior, and should
* be used in conjunction with gtk_tree_sortable_set_sort_column_id() to do
* that. For custom models, the mechanism will vary.
*
* that. For custom models, the mechanism will vary.
*
* The sort indicator changes direction to indicate normal sort or reverse sort.
* Note that you must have the sort indicator enabled to see anything when
* Note that you must have the sort indicator enabled to see anything when
* calling this function; see gtk_tree_view_column_set_sort_indicator().
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2747,9 +2744,9 @@ gtk_tree_view_column_set_sort_order (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_get_sort_order:
* @tree_column: a `GtkTreeViewColumn`
*
*
* Gets the value set by gtk_tree_view_column_set_sort_order().
*
*
* Returns: the sort order the sort indicator is indicating
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2769,7 +2766,7 @@ gtk_tree_view_column_get_sort_order (GtkTreeViewColumn *tree_column)
* @iter: The `GtkTreeIter` to get the cell renderers attributes from.
* @is_expander: %TRUE, if the row has children
* @is_expanded: %TRUE, if the row has visible children
*
*
* Sets the cell renderer based on the @tree_model and @iter. That is, for
* every attribute mapping in @tree_column, it will get a value from the set
* column on the @iter, and use that value to set the attribute on the cell
@@ -2800,7 +2797,7 @@ gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
* @y_offset: (out) (optional): location to return y offset of a cell relative to @cell_area
* @width: (out) (optional): location to return width needed to render a cell
* @height: (out) (optional): location to return height needed to render a cell
*
*
* Obtains the width and height needed to render the column. This is used
* primarily by the `GtkTreeView`.
*
@@ -2820,7 +2817,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
priv = tree_column->priv;
g_signal_handler_block (priv->cell_area_context,
g_signal_handler_block (priv->cell_area_context,
priv->context_changed_signal);
gtk_cell_area_get_preferred_width (priv->cell_area,
@@ -2837,7 +2834,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
&min_height,
NULL);
g_signal_handler_unblock (priv->cell_area_context,
g_signal_handler_unblock (priv->cell_area_context,
priv->context_changed_signal);
@@ -2855,7 +2852,7 @@ gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
* @background_area: entire cell area (including tree expanders and maybe padding on the sides)
* @cell_area: area normally rendered by a cell renderer
* @flags: flags that affect rendering
*
*
* Renders the cell contained by #tree_column. This is used primarily by the
* `GtkTreeView`.
*
@@ -2907,11 +2904,11 @@ _gtk_tree_view_column_cell_event (GtkTreeViewColumn *tree_column,
/**
* gtk_tree_view_column_cell_is_visible:
* @tree_column: A `GtkTreeViewColumn`
*
*
* Returns %TRUE if any of the cells packed into the @tree_column are visible.
* For this to be meaningful, you must first initialize the cells with
* gtk_tree_view_column_cell_set_cell_data()
*
*
* Returns: %TRUE, if any of the cells packed into the @tree_column are currently visible
*
* Deprecated: 4.10: Use GtkColumnView instead
@@ -2975,10 +2972,10 @@ _gtk_tree_view_column_cell_set_dirty (GtkTreeViewColumn *tree_column,
/* Issue a manual reset on the context to have all
* sizes re-requested for the context.
*/
g_signal_handler_block (priv->cell_area_context,
g_signal_handler_block (priv->cell_area_context,
priv->context_changed_signal);
gtk_cell_area_context_reset (priv->cell_area_context);
g_signal_handler_unblock (priv->cell_area_context,
g_signal_handler_unblock (priv->cell_area_context,
priv->context_changed_signal);
if (priv->tree_view &&
+53 -53
View File
@@ -80,117 +80,117 @@ typedef void (* GtkTreeCellDataFunc) (GtkTreeViewColumn *tree_column,
GDK_AVAILABLE_IN_ALL
GType gtk_tree_view_column_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkTreeViewColumn *gtk_tree_view_column_new (void);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkTreeViewColumn *gtk_tree_view_column_new_with_area (GtkCellArea *area);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkTreeViewColumn *gtk_tree_view_column_new_with_attributes (const char *title,
GtkCellRenderer *cell,
...) G_GNUC_NULL_TERMINATED;
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_pack_start (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
gboolean expand);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
gboolean expand);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_clear (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_add_attribute (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
const char *attribute,
int column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_attributes (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
...) G_GNUC_NULL_TERMINATED;
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_cell_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
GtkTreeCellDataFunc func,
gpointer func_data,
GDestroyNotify destroy);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_clear_attributes (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
int spacing);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_spacing (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
gboolean visible);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_get_visible (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column,
gboolean resizable);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_get_resizable (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
GtkTreeViewColumnSizing type);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkTreeViewColumnSizing gtk_tree_view_column_get_sizing (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_x_offset (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_fixed_width (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
int fixed_width);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
int min_width);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_min_width (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
int max_width);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_max_width (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_clicked (GtkTreeViewColumn *tree_column);
/* Options for manipulating the column headers
*/
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
const char *title);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
const char * gtk_tree_view_column_get_title (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_expand (GtkTreeViewColumn *tree_column,
gboolean expand);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_get_expand (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
gboolean clickable);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_get_clickable (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
GtkWidget *widget);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_tree_view_column_get_widget (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
float xalign);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
float gtk_tree_view_column_get_alignment (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_reorderable (GtkTreeViewColumn *tree_column,
gboolean reorderable);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_get_reorderable (GtkTreeViewColumn *tree_column);
@@ -198,52 +198,52 @@ gboolean gtk_tree_view_column_get_reorderable (GtkTreeViewCol
/* You probably only want to use gtk_tree_view_column_set_sort_column_id. The
* other sorting functions exist primarily to let others do their own custom sorting.
*/
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
int sort_column_id);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
int gtk_tree_view_column_get_sort_column_id (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_sort_indicator (GtkTreeViewColumn *tree_column,
gboolean setting);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_get_sort_indicator (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_set_sort_order (GtkTreeViewColumn *tree_column,
GtkSortType order);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkSortType gtk_tree_view_column_get_sort_order (GtkTreeViewColumn *tree_column);
/* These functions are meant primarily for interaction between the GtkTreeView and the column.
*/
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_cell_set_cell_data (GtkTreeViewColumn *tree_column,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_cell_get_size (GtkTreeViewColumn *tree_column,
int *x_offset,
int *y_offset,
int *width,
int *height);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_focus_cell (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
gboolean gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer,
int *x_offset,
int *width);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
void gtk_tree_view_column_queue_resize (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_tree_view_column_get_tree_view (GtkTreeViewColumn *tree_column);
GDK_DEPRECATED_IN_4_10_FOR(GtkColumnView and GtkColumnViewColumn)
GDK_DEPRECATED_IN_4_10
GtkWidget *gtk_tree_view_column_get_button (GtkTreeViewColumn *tree_column);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkTreeViewColumn, g_object_unref)
+1 -9
View File
@@ -78,20 +78,15 @@
#include <gtk/gtkcenterbox.h>
#include <gtk/gtkcenterlayout.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkchoice.h>
#include <gtk/gtkcolorbutton.h>
#include <gtk/gtkcolorchooser.h>
#include <gtk/gtkcolorchooserdialog.h>
#include <gtk/gtkcolorchooserwidget.h>
#include <gtk/gtkcolordialog.h>
#include <gtk/gtkcolordialogbutton.h>
#include <gtk/gtkcolorutils.h>
#include <gtk/gtkcolumnview.h>
#include <gtk/gtkcolumnviewcolumn.h>
#include <gtk/gtkcolumnviewsorter.h>
#include <gtk/deprecated/gtkcombobox.h>
#include <gtk/deprecated/gtkcomboboxtext.h>
#include <gtk/gtkchoice.h>
#include <gtk/gtkconstraintlayout.h>
#include <gtk/gtkconstraint.h>
#include <gtk/gtkcssprovider.h>
@@ -128,7 +123,6 @@
#include <gtk/gtkfilechooserdialog.h>
#include <gtk/gtkfilechoosernative.h>
#include <gtk/gtkfilechooserwidget.h>
#include <gtk/gtkfiledialog.h>
#include <gtk/gtkfilefilter.h>
#include <gtk/gtkfilter.h>
#include <gtk/gtkfilterlistmodel.h>
@@ -139,8 +133,6 @@
#include <gtk/gtkfontchooser.h>
#include <gtk/gtkfontchooserdialog.h>
#include <gtk/gtkfontchooserwidget.h>
#include <gtk/gtkfontdialog.h>
#include <gtk/gtkfontdialogbutton.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkgesture.h>
#include <gtk/gtkgestureclick.h>
@@ -164,8 +156,8 @@
#include <gtk/gtkimcontextsimple.h>
#include <gtk/gtkimmulticontext.h>
#include <gtk/gtkinfobar.h>
#include <gtk/gtkinfodialog.h>
#include <gtk/gtkinscription.h>
#include <gtk/gtkinvertiblesorter.h>
#include <gtk/gtklabel.h>
#include <gtk/gtklayoutmanager.h>
#include <gtk/gtklayoutchild.h>
+2 -10
View File
@@ -27,8 +27,6 @@
#include "gtkmarshalers.h"
#include "gtkwidgetprivate.h"
#include "gsettings-mapping.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include <string.h>
@@ -848,15 +846,9 @@ gtk_action_muxer_activate_action (GtkActionMuxer *muxer,
if (!_gtk_bitmask_get (muxer->widget_actions_disabled, position))
{
if (action->activate)
{
GTK_DEBUG (ACTIONS, "%s: activate action", action->name);
action->activate (muxer->widget, action->name, parameter);
}
action->activate (muxer->widget, action->name, parameter);
else if (action->pspec)
{
GTK_DEBUG (ACTIONS, "%s: activate prop action", action->pspec->name);
prop_action_activate (muxer->widget, action, parameter);
}
prop_action_activate (muxer->widget, action, parameter);
}
return;
-14
View File
@@ -225,7 +225,6 @@
#include "gtkicontheme.h"
#include "gtkiconthemeprivate.h"
#include "gtkdebug.h"
#include "gtkstringlist.h"
static void gtk_builder_finalize (GObject *object);
@@ -552,19 +551,6 @@ gtk_builder_get_parameters (GtkBuilder *builder,
if (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) == GTK_TYPE_EXPRESSION)
gtk_value_set_expression (&property_value, prop->value);
else if (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) == G_TYPE_STRV)
{
GStrvBuilder *strv = g_strv_builder_new ();
for (guint j = 0; j < g_list_model_get_n_items (G_LIST_MODEL (prop->value)); j++)
{
GtkStringObject *s = g_list_model_get_item (G_LIST_MODEL (prop->value), j);
g_strv_builder_add (strv, gtk_string_object_get_string (s));
g_object_unref (s);
}
g_value_set_boxed (&property_value, g_strv_builder_end (strv));
}
else
g_assert_not_reached ();
}
+4 -14
View File
@@ -1039,10 +1039,6 @@ free_property_info (PropertyInfo *info)
{
if (G_PARAM_SPEC_VALUE_TYPE (info->pspec) == GTK_TYPE_EXPRESSION)
gtk_expression_unref (info->value);
else if (G_PARAM_SPEC_VALUE_TYPE (info->pspec) == G_TYPE_STRV)
{
/* info->value is in the hash table of objects */
}
else
g_assert_not_reached();
}
@@ -1727,11 +1723,8 @@ parse_custom (GtkBuildableParseContext *context,
object = ((ObjectInfo*)child_info->parent)->object;
child = child_info->object;
}
else if (parent_info->tag_type == TAG_PROPERTY)
{
g_print ("custom markup in <property>\n");
return FALSE;
}
else
return FALSE;
if (!gtk_buildable_custom_tag_start (GTK_BUILDABLE (object),
data->builder,
@@ -1954,10 +1947,7 @@ end_element (GtkBuildableParseContext *context,
if (child_info)
child_info->object = object_info->object;
if (prop_info)
{
g_string_assign (prop_info->text, object_info->id);
prop_info->value = object_info->object;
}
g_string_assign (prop_info->text, object_info->id);
if (GTK_IS_BUILDABLE (object_info->object) &&
GTK_BUILDABLE_GET_IFACE (object_info->object)->parser_finished)
@@ -2084,7 +2074,7 @@ end_element (GtkBuildableParseContext *context,
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_UNHANDLED_TAG,
"Unhandled end tag: </%s>", element_name);
"Unhandled tag: <%s>", element_name);
_gtk_builder_prefix_error (data->builder, context, error);
}
}
-93
View File
@@ -1,93 +0,0 @@
/*
* 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 "gtkchoice.h"
struct _GtkChoice
{
GObject parent_instance;
char *label;
char **options;
};
G_DEFINE_TYPE (GtkChoice, gtk_choice, G_TYPE_OBJECT)
static void
gtk_choice_init (GtkChoice *self)
{
}
static void
gtk_choice_finalize (GObject *object)
{
GtkChoice *self = GTK_CHOICE (object);
g_free (self->label);
g_strfreev (self->options);
G_OBJECT_CLASS (gtk_choice_parent_class)->finalize (object);
}
static void
gtk_choice_class_init (GtkChoiceClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_choice_finalize;
}
/* }}} */
/* {{{ Public API */
GtkChoice *
gtk_choice_new (const char *label,
const char * const *options)
{
GtkChoice *self;
self = g_object_new (GTK_TYPE_CHOICE, NULL);
self->label = g_strdup (label);
self->options = g_strdupv ((char **)options);
return self;
}
const char *
gtk_choice_get_label (GtkChoice *choice)
{
g_return_val_if_fail (GTK_IS_CHOICE (choice), NULL);
return choice->label;
}
const char * const *
gtk_choice_get_options (GtkChoice *choice)
{
g_return_val_if_fail (GTK_IS_CHOICE (choice), NULL);
return (const char * const *)choice->options;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-45
View File
@@ -1,45 +0,0 @@
/* 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>
G_BEGIN_DECLS
#define GTK_TYPE_CHOICE (gtk_choice_get_type ())
GDK_AVAILABLE_IN_4_10
G_DECLARE_FINAL_TYPE (GtkChoice, gtk_choice, GTK, CHOICE, GObject)
GDK_AVAILABLE_IN_4_10
GtkChoice * gtk_choice_new (const char *label,
const char * const *options);
GDK_AVAILABLE_IN_4_10
const char * gtk_choice_get_label (GtkChoice *choice);
GDK_AVAILABLE_IN_4_10
const char * const *
gtk_choice_get_options (GtkChoice *choice);
G_END_DECLS
-475
View File
@@ -1,475 +0,0 @@
/*
* 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 "gtkcolordialog.h"
#include "gtkcolorchooserdialog.h"
#include "gtkcolorchooser.h"
#include "gtkbutton.h"
#include <glib/gi18n-lib.h>
/**
* GtkColorDialog:
*
* A `GtkColorDialog` object collects the arguments that
* are needed to present a color chooser dialog to the
* user, such as a title for the dialog and whether it
* should be modal.
*
* The dialog is shown with the [function@Gtk.ColorDialog.choose_rgba]
* function. This API follows the GIO async pattern, and the
* result can be obtained by calling
* [function@Gtk.ColorDialog.choose_rgba_finish].
*
* See [class@Gtk.ColorDialogButton] for a convenient control
* that uses `GtkColorDialog` and presents the results.
*
* `GtkColorDialog was added in GTK 4.10.
*/
/* {{{ GObject implementation */
struct _GtkColorDialog
{
GObject parent_instance;
char *title;
unsigned int modal : 1;
unsigned int with_alpha : 1;
};
enum
{
PROP_TITLE = 1,
PROP_MODAL,
PROP_WITH_ALPHA,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkColorDialog, gtk_color_dialog, G_TYPE_OBJECT)
static void
gtk_color_dialog_init (GtkColorDialog *self)
{
self->title = g_strdup (_("Pick a Color"));
self->modal = TRUE;
self->with_alpha = TRUE;
}
static void
gtk_color_dialog_finalize (GObject *object)
{
GtkColorDialog *self = GTK_COLOR_DIALOG (object);
g_free (self->title);
G_OBJECT_CLASS (gtk_color_dialog_parent_class)->finalize (object);
}
static void
gtk_color_dialog_get_property (GObject *object,
unsigned int property_id,
GValue *value,
GParamSpec *pspec)
{
GtkColorDialog *self = GTK_COLOR_DIALOG (object);
switch (property_id)
{
case PROP_TITLE:
g_value_set_string (value, self->title);
break;
case PROP_MODAL:
g_value_set_boolean (value, self->modal);
break;
case PROP_WITH_ALPHA:
g_value_set_boolean (value, self->with_alpha);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_color_dialog_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkColorDialog *self = GTK_COLOR_DIALOG (object);
switch (prop_id)
{
case PROP_TITLE:
gtk_color_dialog_set_title (self, g_value_get_string (value));
break;
case PROP_MODAL:
gtk_color_dialog_set_modal (self, g_value_get_boolean (value));
break;
case PROP_WITH_ALPHA:
gtk_color_dialog_set_with_alpha (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_color_dialog_class_init (GtkColorDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_color_dialog_finalize;
object_class->get_property = gtk_color_dialog_get_property;
object_class->set_property = gtk_color_dialog_set_property;
/**
* GtkColorDialog:title: (attributes org.gtk.Property.get=gtk_color_dialog_get_title org.gtk.Property.set=gtk_color_dialog_set_title)
*
* A title that may be shown on the color chooser
* dialog that is presented by [function@Gtk.ColorDialog.choose_rgba].
*
* Since: 4.10
*/
properties[PROP_TITLE] =
g_param_spec_string ("title", NULL, NULL,
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkColorDialog:modal: (attributes org.gtk.Property.get=gtk_color_dialog_get_modal org.gtk.Property.set=gtk_color_dialog_set_modal)
*
* Whether the color chooser dialog is modal.
*
* Since: 4.10
*/
properties[PROP_MODAL] =
g_param_spec_boolean ("modal", NULL, NULL,
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkColorDialog:with-alpha: (attributes org.gtk.Property.get=gtk_color_dialog_get_with_alpha org.gtk.Property.set=gtk_color_dialog_set_with_alpha)
*
* Whether colors may have alpha (translucency).
*
* When with-alpha is %FALSE, the color that is selected
* will be forced to have alpha == 1.
*
* Since: 4.10
*/
properties[PROP_WITH_ALPHA] =
g_param_spec_boolean ("with-alpha", NULL, NULL,
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
/* }}} */
/* {{{ Constructor */
/**
* gtk_color_dialog_new:
*
* Creates a new `GtkColorDialog` object.
*
* Returns: the new `GtkColorDialog`
*
* Since: 4.10
*/
GtkColorDialog *
gtk_color_dialog_new (void)
{
return g_object_new (GTK_TYPE_COLOR_DIALOG, NULL);
}
/* }}} */
/* {{{ Getters and setters */
/**
* gtk_color_dialog_get_title:
* @self: a `GtkColorDialog`
*
* Returns the title that will be shown on the
* color chooser dialog.
*
* Returns: the title
*
* Since: 4.10
*/
const char *
gtk_color_dialog_get_title (GtkColorDialog *self)
{
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), NULL);
return self->title;
}
/**
* gtk_color_dialog_set_title:
* @self: a `GtkColorDialog`
* @title: the new title
*
* Sets the title that will be shown on the
* color chooser dialog.
*
* Since: 4.10
*/
void
gtk_color_dialog_set_title (GtkColorDialog *self,
const char *title)
{
char *new_title;
g_return_if_fail (GTK_IS_COLOR_DIALOG (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]);
}
/**
* gtk_color_dialog_get_modal:
* @self: a `GtkColorDialog`
*
* Returns whether the color chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Returns: `TRUE` if the color chooser dialog is modal
*
* Since: 4.10
*/
gboolean
gtk_color_dialog_get_modal (GtkColorDialog *self)
{
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), TRUE);
return self->modal;
}
/**
* gtk_color_dialog_set_modal:
* @self: a `GtkColorDialog`
* @modal: the new value
*
* Sets whether the color chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Since: 4.10
*/
void
gtk_color_dialog_set_modal (GtkColorDialog *self,
gboolean modal)
{
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
if (self->modal == modal)
return;
self->modal = modal;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
}
/**
* gtk_color_dialog_get_with_alpha:
* @self: a `GtkColorDialog`
*
* Returns whether colors may have alpha.
*
* Returns: `TRUE` if colors may have alpha
*
* Since: 4.10
*/
gboolean
gtk_color_dialog_get_with_alpha (GtkColorDialog *self)
{
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (self), TRUE);
return self->with_alpha;
}
/**
* gtk_color_dialog_set_with_alpha:
* @self: a `GtkColorDialog`
* @with_alpha: the new value
*
* Sets whether colors may have alpha.
*
* Since: 4.10
*/
void
gtk_color_dialog_set_with_alpha (GtkColorDialog *self,
gboolean with_alpha)
{
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
if (self->with_alpha == with_alpha)
return;
self->with_alpha = with_alpha;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WITH_ALPHA]);
}
/* }}} */
/* {{{ Async API */
static void response_cb (GTask *task,
int response);
static void
cancelled_cb (GCancellable *cancellable,
GTask *task)
{
response_cb (task, GTK_RESPONSE_CANCEL);
}
static void
response_cb (GTask *task,
int response)
{
GCancellable *cancellable;
cancellable = g_task_get_cancellable (task);
if (cancellable)
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
if (response == GTK_RESPONSE_OK)
{
GtkColorChooserDialog *window;
GdkRGBA color;
window = GTK_COLOR_CHOOSER_DIALOG (g_task_get_task_data (task));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (window), &color);
g_task_return_pointer (task, &color, NULL);
}
else
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
g_object_unref (task);
}
/**
* gtk_color_dialog_choose_rgba:
* @self: a `GtkColorDialog`
* @parent: (nullable): the parent `GtkWindow`
* @initial_color: (nullable): the color to select initially
* @cancellable: (nullable): a `GCancellable` to cancel the operation
* @callback: (scope async): a callback to call when the operation is complete
* @user_data: (closure callback): data to pass to @callback
*
* This function initiates a color choice operation by
* presenting a color chooser dialog to the user.
*
* The @callback will be called when the dialog is dismissed.
* It should call [function@Gtk.ColorDialog.choose_rgba_finish]
* to obtain the result.
*
* Since: 4.10
*/
void
gtk_color_dialog_choose_rgba (GtkColorDialog *self,
GtkWindow *parent,
const GdkRGBA *initial_color,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkWidget *window;
GTask *task;
g_return_if_fail (GTK_IS_COLOR_DIALOG (self));
window = gtk_color_chooser_dialog_new (self->title, parent);
if (initial_color)
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (window), initial_color);
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (window), self->with_alpha);
gtk_window_set_modal (GTK_WINDOW (window), self->modal);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_color_dialog_choose_rgba);
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
g_signal_connect_swapped (window, "response", G_CALLBACK (response_cb), task);
gtk_window_present (GTK_WINDOW (window));
}
/**
* gtk_color_dialog_choose_rgba_finish:
* @self: a `GtkColorDialog`
* @result: a `GAsyncResult`
* @color: (out caller-allocates): return location for the color
* @error: return location for an error
*
* Finishes the [function@Gtk.ColorDialog.choose_rgba] call and
* returns the resulting color.
*
* Returns: `TRUE` if a color was selected. Otherwise,
* `FALSE` is returned and @error is set
*
* Since: 4.10
*/
gboolean
gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
GAsyncResult *result,
GdkRGBA *color,
GError **error)
{
GdkRGBA *ret;
ret = g_task_propagate_pointer (G_TASK (result), error);
if (ret)
{
*color = *ret;
return TRUE;
}
return FALSE;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-73
View File
@@ -1,73 +0,0 @@
/* 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_DIALOG (gtk_color_dialog_get_type ())
GDK_AVAILABLE_IN_4_10
G_DECLARE_FINAL_TYPE (GtkColorDialog, gtk_color_dialog, GTK, COLOR_DIALOG, GObject)
GDK_AVAILABLE_IN_4_10
GtkColorDialog *gtk_color_dialog_new (void);
GDK_AVAILABLE_IN_4_10
const char * gtk_color_dialog_get_title (GtkColorDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_set_title (GtkColorDialog *self,
const char *title);
GDK_AVAILABLE_IN_4_10
gboolean gtk_color_dialog_get_modal (GtkColorDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_set_modal (GtkColorDialog *self,
gboolean modal);
GDK_AVAILABLE_IN_4_10
gboolean gtk_color_dialog_get_with_alpha (GtkColorDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_set_with_alpha (GtkColorDialog *self,
gboolean with_alpha);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_choose_rgba (GtkColorDialog *self,
GtkWindow *parent,
const GdkRGBA *initial_color,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_4_10
gboolean gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
GAsyncResult *result,
GdkRGBA *color,
GError **error);
G_END_DECLS
-483
View File
@@ -1,483 +0,0 @@
/*
* 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 "gtkcolordialogbutton.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 "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtkwidgetprivate.h"
static gboolean drop (GtkDropTarget *dest,
const GValue *value,
double x,
double y,
GtkColorDialogButton *self);
static GdkContentProvider *
drag_prepare (GtkDragSource *source,
double x,
double y,
GtkColorDialogButton *self);
static void button_clicked (GtkColorDialogButton *self);
/**
* GtkColorDialogButton:
*
* The `GtkColorDialogButton` is a wrapped around a [class@Gtk.ColorDialog]
* and allows to open a color chooser dialog to change the color.
*
* ![An example GtkColorDialogButton](color-button.png)
*
* It is suitable widget for selecting a color in a preference dialog.
*
* # CSS nodes
*
* ```
* colorbutton
* button.color
* [content]
* ```
*
* `GtkColorDialogButton` has a single CSS node with name colorbutton which
* contains a button node. To differentiate it from a plain `GtkButton`,
* it gets the .color style class.
*/
/* {{{ GObject implementation */
struct _GtkColorDialogButton
{
GtkWidget parent_instance;
GtkWidget *button;
GtkWidget *swatch;
GtkColorDialog *dialog;
GdkRGBA color;
};
/* Properties */
enum
{
PROP_DIALOG = 1,
PROP_COLOR,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkColorDialogButton, gtk_color_dialog_button, GTK_TYPE_WIDGET)
static void
gtk_color_dialog_button_init (GtkColorDialogButton *self)
{
PangoLayout *layout;
PangoRectangle rect;
GtkDragSource *source;
GtkDropTarget *dest;
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_dialog_button_set_property (GObject *object,
unsigned int param_id,
const GValue *value,
GParamSpec *pspec)
{
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
switch (param_id)
{
case PROP_DIALOG:
gtk_color_dialog_button_set_dialog (self, g_value_get_object (value));
break;
case PROP_COLOR:
gtk_color_dialog_button_set_color (self, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
gtk_color_dialog_button_get_property (GObject *object,
unsigned int param_id,
GValue *value,
GParamSpec *pspec)
{
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
switch (param_id)
{
case PROP_DIALOG:
g_value_set_object (value, self->dialog);
break;
case PROP_COLOR:
g_value_set_boxed (value, &self->color);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
gtk_color_dialog_button_dispose (GObject *object)
{
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
g_clear_pointer (&self->button, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_color_dialog_button_parent_class)->dispose (object);
}
static void
gtk_color_dialog_button_finalize (GObject *object)
{
GtkColorDialogButton *self = GTK_COLOR_DIALOG_BUTTON (object);
g_clear_object (&self->dialog);
G_OBJECT_CLASS (gtk_color_dialog_button_parent_class)->finalize (object);
}
static void
gtk_color_dialog_button_class_init (GtkColorDialogButtonClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->get_property = gtk_color_dialog_button_get_property;
object_class->set_property = gtk_color_dialog_button_set_property;
object_class->dispose = gtk_color_dialog_button_dispose;
object_class->finalize = gtk_color_dialog_button_finalize;
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->focus = gtk_widget_focus_child;
/**
* GtkColorDialogButton:dialog: (attributes org.gtk.Property.get=gtk_color_dialog_button_get_dialog org.gtk.Property.set=gtk_color_dialog_button_set_dialog)
*
* The `GtkColorDialog` that contains parameters for
* the color chooser dialog.
*
* Since: 4.10
*/
properties[PROP_DIALOG] =
g_param_spec_object ("dialog", NULL, NULL,
GTK_TYPE_COLOR_DIALOG,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkColorDialogButton:color: (attributes org.gtk.Property.get=gtk_color_dialog_button_get_color org.gtk.Property.set=gtk_color_dialog_button_set_color)
*
* The selected color.
*
* This property can be set to give the button its initial
* color, and it will be updated to reflect the users choice
* in the color chooser dialog.
*
* Listen to `notify::color` to get informed about changes
* to the buttons color.
*
* Since: 4.10
*/
properties[PROP_COLOR] =
g_param_spec_boxed ("color", NULL, NULL,
GDK_TYPE_RGBA,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
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,
GtkColorDialogButton *self)
{
GdkRGBA *color = g_value_get_boxed (value);
gtk_color_dialog_button_set_color (self, color);
return TRUE;
}
static GdkContentProvider *
drag_prepare (GtkDragSource *source,
double x,
double y,
GtkColorDialogButton *self)
{
GdkRGBA color;
gtk_color_swatch_get_rgba (GTK_COLOR_SWATCH (self->swatch), &color);
return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &color);
}
static void
color_chosen (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkColorDialogButton *self = data;
GdkRGBA color;
GError *error = NULL;
if (gtk_color_dialog_choose_rgba_finish (self->dialog, result, &color, &error))
{
gtk_color_dialog_button_set_color (self, &color);
}
else
{
g_print ("%s\n", error->message);
g_error_free (error);
}
}
static void
button_clicked (GtkColorDialogButton *self)
{
GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (self));
GtkWindow *parent = NULL;
if (GTK_IS_WINDOW (root))
parent = GTK_WINDOW (root);
gtk_color_dialog_choose_rgba (self->dialog, parent, &self->color,
NULL, color_chosen, self);
}
/* }}} */
/* {{{ Constructor */
/**
* gtk_color_dialog_button_new:
* @dialog: (nullable) (transfer full): the `GtkColorDialog` to use
*
* Creates a new `GtkColorDialogButton` with the
* given `GtkColorDialog`.
*
* You can pass `NULL` to this function and set a `GtkColorDialog`
* later. The button will be insensitive until that happens.
*
* Returns: the new `GtkColorDialogButton`
*
* Since: 4.10
*/
GtkWidget *
gtk_color_dialog_button_new (GtkColorDialog *dialog)
{
GtkWidget *self;
g_return_val_if_fail (GTK_IS_COLOR_DIALOG (dialog), NULL);
self = g_object_new (GTK_TYPE_COLOR_DIALOG_BUTTON,
"dialog", dialog,
NULL);
g_clear_object (&dialog);
return self;
}
/* }}} */
/* {{{ Getters and setters */
/**
* gtk_color_dialog_button_get_dialog:
* @self: a `GtkColorDialogButton`
*
* Returns the `GtkColorDialog` of @self.
*
* Returns: (transfer none) (nullable): the `GtkColorDialog`
*
* Since: 4.10
*/
GtkColorDialog *
gtk_color_dialog_button_get_dialog (GtkColorDialogButton *self)
{
g_return_val_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self), NULL);
return self->dialog;
}
/**
* gtk_color_dialog_button_set_dialog:
* @self: a `GtkColorDialogButton`
* @dialog: the new `GtkColorDialog`
*
* Sets a `GtkColorDialog` object to use for
* creating the color chooser dialog that is
* presented when the user clicks the button.
*
* Since: 4.10
*/
void
gtk_color_dialog_button_set_dialog (GtkColorDialogButton *self,
GtkColorDialog *dialog)
{
g_return_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self));
g_return_if_fail (GTK_IS_COLOR_DIALOG (dialog));
if (!g_set_object (&self->dialog, dialog))
return;
gtk_widget_set_sensitive (self->button, dialog != NULL);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DIALOG]);
}
/**
* gtk_color_dialog_button_get_color:
* @self: a `GtkColorDialogButton`
*
* Returns the color of the button.
*
* This function is what should be used to obtain
* the color that was choosen by the user. To get
* informed about changes, listen to "notify::color".
*
* Returns: the color
*
* Since: 4.10
*/
const GdkRGBA *
gtk_color_dialog_button_get_color (GtkColorDialogButton *self)
{
g_return_val_if_fail (GTK_IS_COLOR_DIALOG_BUTTON (self), NULL);
return &self->color;
}
/**
* gtk_color_dialog_button_set_color:
* @self: a `GtkColorDialogButton`
* @color: the new color
*
* Sets the color of the button.
*
* Since: 4.10
*/
void
gtk_color_dialog_button_set_color (GtkColorDialogButton *self,
const GdkRGBA *color)
{
char *text;
g_return_if_fail (GTK_IS_COLOR_DIALOG_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]);
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-53
View File
@@ -1,53 +0,0 @@
/*
* 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/gtkbutton.h>
#include <gtk/gtkcolordialog.h>
G_BEGIN_DECLS
#define GTK_TYPE_COLOR_DIALOG_BUTTON (gtk_color_dialog_button_get_type ())
GDK_AVAILABLE_IN_4_10
G_DECLARE_FINAL_TYPE (GtkColorDialogButton, gtk_color_dialog_button, GTK, COLOR_DIALOG_BUTTON, GtkWidget)
GDK_AVAILABLE_IN_4_10
GtkWidget * gtk_color_dialog_button_new (GtkColorDialog *dialog);
GDK_AVAILABLE_IN_4_10
GtkColorDialog *gtk_color_dialog_button_get_dialog (GtkColorDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_button_set_dialog (GtkColorDialogButton *self,
GtkColorDialog *dialog);
GDK_AVAILABLE_IN_4_10
const GdkRGBA * gtk_color_dialog_button_get_color (GtkColorDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_color_dialog_button_set_color (GtkColorDialogButton *self,
const GdkRGBA *color);
G_END_DECLS
+12 -6
View File
@@ -27,6 +27,7 @@
#include "gtkcolumnviewcolumnprivate.h"
#include "gtkcolumnviewlayoutprivate.h"
#include "gtkcolumnviewsorterprivate.h"
#include "gtkmultisorter.h"
#include "gtkcssnodeprivate.h"
#include "gtkdropcontrollermotion.h"
#include "gtklistviewprivate.h"
@@ -1303,7 +1304,7 @@ gtk_column_view_init (GtkColumnView *self)
g_signal_connect (controller, "leave", G_CALLBACK (gtk_column_view_drag_leave), NULL);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
self->sorter = GTK_SORTER (gtk_column_view_sorter_new ());
self->sorter = GTK_SORTER (gtk_multi_sorter_new ());
self->factory = gtk_column_list_item_factory_new (self);
self->listview = GTK_LIST_VIEW (g_object_new (GTK_TYPE_COLUMN_LIST_VIEW, NULL));
gtk_list_view_set_factory (self->listview, GTK_LIST_ITEM_FACTORY (self->factory));
@@ -1537,7 +1538,7 @@ gtk_column_view_remove_column (GtkColumnView *self,
break;
}
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (self->sorter), column);
gtk_column_view_sorter_remove_column (self->sorter, column);
gtk_column_view_column_set_column_view (column, NULL);
g_list_store_remove (self->columns, i);
}
@@ -1688,6 +1689,13 @@ gtk_column_view_get_sorter (GtkColumnView *self)
* on @column to associate a sorter with the column.
*
* If @column is %NULL, the view will be unsorted.
*
* This function can be called multiple times to set up
* sorting with multiple columns:
*
* gtk_column_view_sort_by_column (view, NULL, 0);
* gtk_column_view_sort_by_column (view, col1, GTK_SORT_DESCENDING);
* gtk_column_view_sort_by_column (view, col0, GTK_SORT_ASCENDING);
*/
void
gtk_column_view_sort_by_column (GtkColumnView *self,
@@ -1699,11 +1707,9 @@ gtk_column_view_sort_by_column (GtkColumnView *self,
g_return_if_fail (column == NULL || gtk_column_view_column_get_column_view (column) == self);
if (column == NULL)
gtk_column_view_sorter_clear (GTK_COLUMN_VIEW_SORTER (self->sorter));
gtk_column_view_sorter_clear (self->sorter);
else
gtk_column_view_sorter_set_column (GTK_COLUMN_VIEW_SORTER (self->sorter),
column,
direction == GTK_SORT_DESCENDING);
gtk_column_view_sorter_set_column (self->sorter, column, direction);
}
/**
+34 -83
View File
@@ -31,7 +31,7 @@
#include "gtkrbtreeprivate.h"
#include "gtksizegroup.h"
#include "gtkwidgetprivate.h"
#include "gtksorter.h"
#include "gtkinvertiblesorter.h"
/**
* GtkColumnViewColumn:
@@ -56,8 +56,7 @@ struct _GtkColumnViewColumn
GtkListItemFactory *factory;
char *title;
char *id;
GtkSorter *sorter;
GtkInvertibleSorter *invertible_sorter;
/* data for the view */
GtkColumnView *view;
@@ -98,7 +97,6 @@ enum
PROP_RESIZABLE,
PROP_EXPAND,
PROP_FIXED_WIDTH,
PROP_ID,
N_PROPS
};
@@ -116,7 +114,7 @@ gtk_column_view_column_dispose (GObject *object)
g_assert (self->first_cell == NULL); /* no view = no children */
g_clear_object (&self->factory);
g_clear_object (&self->sorter);
g_clear_object (&self->invertible_sorter);
g_clear_pointer (&self->title, g_free);
g_clear_object (&self->menu);
@@ -146,7 +144,7 @@ gtk_column_view_column_get_property (GObject *object,
break;
case PROP_SORTER:
g_value_set_object (value, self->sorter);
g_value_set_object (value, gtk_column_view_column_get_sorter (self));
break;
case PROP_VISIBLE:
@@ -169,10 +167,6 @@ gtk_column_view_column_get_property (GObject *object,
g_value_set_int (value, self->fixed_width);
break;
case PROP_ID:
g_value_set_string (value, self->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -221,10 +215,6 @@ gtk_column_view_column_set_property (GObject *object,
gtk_column_view_column_set_fixed_width (self, g_value_get_int (value));
break;
case PROP_ID:
gtk_column_view_column_set_id (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -331,24 +321,6 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkColumnViewColumn:id: (attributes org.gtk.Property.get=gtk_column_view_column_get_id org.gtk.Property.set=gtk_column_view_column_set_id)
*
* An ID for the column.
*
* GTK is not currently using the ID for anything, but
* it can be used by applications when saving column view
* configurations.
*
* It is up to applications to ensure uniqueness of IDs.
*
* Since: 4.10
*/
properties[PROP_ID] =
g_param_spec_string ("id", NULL, NULL,
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
}
@@ -706,7 +678,7 @@ gtk_column_view_column_set_title (GtkColumnViewColumn *self,
self->title = g_strdup (title);
if (self->header)
gtk_column_view_title_set_title (GTK_COLUMN_VIEW_TITLE (self->header), title);
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
}
@@ -733,7 +705,7 @@ gtk_column_view_column_remove_from_sorter (GtkColumnViewColumn *self)
if (self->view == NULL)
return;
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
gtk_column_view_sorter_remove_column (gtk_column_view_get_sorter (self->view), self);
}
/**
@@ -759,13 +731,29 @@ gtk_column_view_column_set_sorter (GtkColumnViewColumn *self,
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
g_return_if_fail (sorter == NULL || GTK_IS_SORTER (sorter));
if (!g_set_object (&self->sorter, sorter))
if (self->invertible_sorter == NULL && sorter == NULL)
return;
if (self->invertible_sorter != NULL &&
sorter == gtk_invertible_sorter_get_sorter (self->invertible_sorter))
return;
if (sorter)
{
if (!self->invertible_sorter)
{
self->invertible_sorter = gtk_invertible_sorter_new (NULL);
g_object_set_data (G_OBJECT (self->invertible_sorter), "column", self);
}
gtk_invertible_sorter_set_sorter (self->invertible_sorter, sorter);
}
else
g_clear_object (&self->invertible_sorter);
gtk_column_view_column_remove_from_sorter (self);
if (self->header)
gtk_column_view_title_update_sort (GTK_COLUMN_VIEW_TITLE (self->header));
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTER]);
}
@@ -783,14 +771,17 @@ gtk_column_view_column_get_sorter (GtkColumnViewColumn *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
return self->sorter;
if (self->invertible_sorter)
return gtk_invertible_sorter_get_sorter (self->invertible_sorter);
return NULL;
}
void
gtk_column_view_column_notify_sort (GtkColumnViewColumn *self)
{
if (self->header)
gtk_column_view_title_update_sort (GTK_COLUMN_VIEW_TITLE (self->header));
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
}
/**
@@ -862,7 +853,7 @@ gtk_column_view_column_set_header_menu (GtkColumnViewColumn *self,
return;
if (self->header)
gtk_column_view_title_set_menu (GTK_COLUMN_VIEW_TITLE (self->header), menu);
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADER_MENU]);
}
@@ -1033,50 +1024,10 @@ gtk_column_view_column_get_header_allocation (GtkColumnViewColumn *self,
*size = self->allocation_size;
}
/**
* gtk_column_view_column_set_id: (attributes org.gtk.Method.set_property=id)
* @self: a `GtkColumnViewColumn`
* @id: (nullable): ID to use for this column
*
* Sets the id of this column.
*
* GTK makes no use of this, but applications can use it when
* storing column view configuration.
*
* It is up to callers to ensure uniqueness of IDs.
*
* Since: 4.10
*/
void
gtk_column_view_column_set_id (GtkColumnViewColumn *self,
const char *id)
GtkInvertibleSorter *
gtk_column_view_column_get_invertible_sorter (GtkColumnViewColumn *self)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
if (g_strcmp0 (self->id, id) == 0)
return;
g_free (self->id);
self->id = g_strdup (id);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ID]);
}
/**
* gtk_column_view_column_get_id: (attributes org.gtk.Method.get_property=id)
* @self: a `GtkColumnViewColumn`
*
* Returns the ID set with gtk_column_view_column_set_id().
*
* Returns: (nullable): The column's ID
*
* Since: 4.10
*/
const char *
gtk_column_view_column_get_id (GtkColumnViewColumn *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
return self->id;
return self->invertible_sorter;
}
+1 -7
View File
@@ -95,13 +95,7 @@ GDK_AVAILABLE_IN_ALL
void gtk_column_view_column_set_expand (GtkColumnViewColumn *self,
gboolean expand);
GDK_AVAILABLE_IN_ALL
gboolean gtk_column_view_column_get_expand (GtkColumnViewColumn *self);
GDK_AVAILABLE_IN_4_10
void gtk_column_view_column_set_id (GtkColumnViewColumn *self,
const char *id);
GDK_AVAILABLE_IN_4_10
const char * gtk_column_view_column_get_id (GtkColumnViewColumn *self);
gboolean gtk_column_view_column_get_expand (GtkColumnViewColumn *self);
G_END_DECLS
+3
View File
@@ -23,6 +23,7 @@
#include "gtk/gtkcolumnviewcolumn.h"
#include "gtk/gtkcolumnviewcellprivate.h"
#include "gtk/gtkinvertiblesorter.h"
void gtk_column_view_column_set_column_view (GtkColumnViewColumn *self,
@@ -57,4 +58,6 @@ void gtk_column_view_column_get_header_allocation (GtkColu
int *offset,
int *size);
GtkInvertibleSorter * gtk_column_view_column_get_invertible_sorter (GtkColumnViewColumn *self);
#endif /* __GTK_COLUMN_VIEW_COLUMN_PRIVATE_H__ */
+114 -540
View File
@@ -20,572 +20,146 @@
#include "config.h"
#include "gtkcolumnviewsorterprivate.h"
#include "gtkcolumnviewcolumnprivate.h"
#include "gtktypebuiltins.h"
#include "gtkmultisorter.h"
/* {{{ GObject implementation */
typedef struct
static GtkColumnViewColumn *
get_column (GtkInvertibleSorter *sorter)
{
GtkColumnViewColumn *column;
GtkSorter *sorter;
gboolean inverted;
gulong changed_id;
} Sorter;
static void
free_sorter (gpointer data)
{
Sorter *s = data;
g_signal_handler_disconnect (s->sorter, s->changed_id);
g_object_unref (s->sorter);
g_object_unref (s->column);
g_free (s);
}
/**
* GtkColumnViewSorter:
*
* `GtkColumnViewSorter` is a sorter implementation that
* is geared towards the needs of `GtkColumnView`.
*
* The sorter returned by [method@Gtk.ColumnView.get_sorter] is
* a `GtkColumnViewSorter`.
*
* In column views, sorting can be configured by associating
* sorters with columns, and users can invert sort order by clicking
* on column headers. The API of `GtkColumnViewSorter` is designed
* to allow saving and restoring this configuration.
*
* If you are only interested in the primary sort column (i.e. the
* column where a sort indicator is shown in the header), then
* you can just look at [property@Gtk.ColumnViewSorter:primary-sort-column]
* and [property@Gtk.ColumnViewSorter:primary-sort-order].
*
* If you want to store the full sort configuration, including
* secondary sort columns that are used for tie breaking, then
* you can use [method@Gtk.ColumnViewSorter.get_nth_sort_column].
* To get notified about changes, use [signal@Gtk.Sorter::changed].
*
* To restore a saved sort configuration on a `GtkColumnView`,
* use code like:
*
* ```
* sorter = gtk_column_view_get_sorter (view);
* for (i = gtk_column_view_sorter_get_n_sort_columns (sorter) - 1; i >= 0; i--)
* {
* column = gtk_column_view_sorter_get_nth_sort_column (sorter, i, &order);
* gtk_column_view_sort_by_column (view, column, order);
* }
* ```
*
* `GtkColumnViewSorter` was added in GTK 4.10
*/
struct _GtkColumnViewSorter
{
GtkSorter parent_instance;
GSequence *sorters;
};
enum
{
PROP_PRIMARY_SORT_COLUMN = 1,
PROP_PRIMARY_SORT_ORDER,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkColumnViewSorter, gtk_column_view_sorter, GTK_TYPE_SORTER)
static GtkOrdering
gtk_column_view_sorter_compare (GtkSorter *sorter,
gpointer item1,
gpointer item2)
{
GtkColumnViewSorter *self = GTK_COLUMN_VIEW_SORTER (sorter);
GtkOrdering result = GTK_ORDERING_EQUAL;
GSequenceIter *iter;
for (iter = g_sequence_get_begin_iter (self->sorters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
Sorter *s = g_sequence_get (iter);
result = gtk_sorter_compare (s->sorter, item1, item2);
if (s->inverted)
result = - result;
if (result != GTK_ORDERING_EQUAL)
break;
}
return result;
}
static GtkSorterOrder
gtk_column_view_sorter_get_order (GtkSorter *sorter)
{
GtkColumnViewSorter *self = GTK_COLUMN_VIEW_SORTER (sorter);
GtkSorterOrder result = GTK_SORTER_ORDER_NONE;
GSequenceIter *iter;
for (iter = g_sequence_get_begin_iter (self->sorters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
Sorter *s = g_sequence_get (iter);
switch (gtk_sorter_get_order (s->sorter))
{
case GTK_SORTER_ORDER_PARTIAL:
result = GTK_SORTER_ORDER_PARTIAL;
break;
case GTK_SORTER_ORDER_NONE:
break;
case GTK_SORTER_ORDER_TOTAL:
return GTK_SORTER_ORDER_TOTAL;
default:
g_assert_not_reached ();
break;
}
}
return result;
return GTK_COLUMN_VIEW_COLUMN (g_object_get_data (G_OBJECT (sorter), "column"));
}
static void
gtk_column_view_sorter_dispose (GObject *object)
{
GtkColumnViewSorter *self = GTK_COLUMN_VIEW_SORTER (object);
/* The sorter is owned by the columview and is unreffed
* after the columns, so the sequence must be empty at
* this point.
* The sorter can outlive the columview it comes from
* (the model might still have a ref), but that does
* not change the fact that all columns will be gone.
*/
g_assert (g_sequence_is_empty (self->sorters));
g_clear_pointer (&self->sorters, g_sequence_free);
G_OBJECT_CLASS (gtk_column_view_sorter_parent_class)->dispose (object);
}
static void
gtk_column_view_sorter_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkColumnViewSorter *self = GTK_COLUMN_VIEW_SORTER (object);
switch (prop_id)
{
case PROP_PRIMARY_SORT_COLUMN:
g_value_set_object (value, gtk_column_view_sorter_get_primary_sort_column (self));
break;
case PROP_PRIMARY_SORT_ORDER:
g_value_set_enum (value, gtk_column_view_sorter_get_primary_sort_order (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_column_view_sorter_class_init (GtkColumnViewSorterClass *class)
{
GtkSorterClass *sorter_class = GTK_SORTER_CLASS (class);
GObjectClass *object_class = G_OBJECT_CLASS (class);
sorter_class->compare = gtk_column_view_sorter_compare;
sorter_class->get_order = gtk_column_view_sorter_get_order;
object_class->dispose = gtk_column_view_sorter_dispose;
object_class->get_property = gtk_column_view_sorter_get_property;
/**
* GtkColumnViewSorter:primary-sort-column: (attributes org.gtk.Property.get=gtk_column_view_sorter_get_primary_sort_column)
*
* The primary sort column.
*
* The primary sort column is the one that displays the triangle
* in a column view header.
*
* Since: 4.10
*/
properties[PROP_PRIMARY_SORT_COLUMN] =
g_param_spec_object ("primary-sort-column", NULL, NULL,
GTK_TYPE_COLUMN_VIEW_COLUMN,
G_PARAM_READABLE|G_PARAM_STATIC_STRINGS);
/**
* GtkColumnViewSorter:primary-sort-order: (attributes org.gtk.Property.get=gtk_column_view_sorter_get_primary_sort_order)
*
* The primary sort order.
*
* The primary sort order determines whether the triangle displayed
* in the column view header of the primary sort column points upwards
* or downwards.
*
* Since: 4.10
*/
properties[PROP_PRIMARY_SORT_ORDER] =
g_param_spec_enum ("primary-sort-order", NULL, NULL,
GTK_TYPE_SORT_TYPE,
GTK_SORT_ASCENDING,
G_PARAM_READABLE|G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
static void
gtk_column_view_sorter_init (GtkColumnViewSorter *self)
{
self->sorters = g_sequence_new (free_sorter);
}
/* }}} */
/* {{{ Private API */
GtkColumnViewSorter *
gtk_column_view_sorter_new (void)
{
return g_object_new (GTK_TYPE_COLUMN_VIEW_SORTER, NULL);
}
static void
gtk_column_view_sorter_changed_cb (GtkSorter *sorter, int change, gpointer data)
{
gtk_sorter_changed (GTK_SORTER (data), GTK_SORTER_CHANGE_DIFFERENT);
}
static gboolean
remove_column (GtkColumnViewSorter *self,
remove_column (GtkSorter *self,
GtkColumnViewColumn *column)
{
GSequenceIter *iter;
GtkInvertibleSorter *sorter = gtk_column_view_column_get_invertible_sorter (column);
for (iter = g_sequence_get_begin_iter (self->sorters);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
if (sorter == NULL)
return;
for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self)); i++)
{
Sorter *s = g_sequence_get (iter);
GtkInvertibleSorter *s;
if (s->column == column)
s = g_list_model_get_item (G_LIST_MODEL (self), i);
g_object_unref (s);
if (s == sorter)
{
g_sequence_remove (iter);
return TRUE;
gtk_multi_sorter_remove (GTK_MULTI_SORTER (self), i);
break;
}
}
return FALSE;
}
gboolean
gtk_column_view_sorter_add_column (GtkColumnViewSorter *self,
GtkColumnViewColumn *column)
{
GSequenceIter *iter;
GtkSorter *sorter;
Sorter *s, *first;
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), FALSE);
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (column), FALSE);
sorter = gtk_column_view_column_get_sorter (column);
if (sorter == NULL)
return FALSE;
iter = g_sequence_get_begin_iter (self->sorters);
if (!g_sequence_iter_is_end (iter))
{
first = g_sequence_get (iter);
if (first->column == column)
{
first->inverted = !first->inverted;
goto out;
}
}
else
first = NULL;
remove_column (self, column);
s = g_new (Sorter, 1);
s->column = g_object_ref (column);
s->sorter = g_object_ref (sorter);
s->changed_id = g_signal_connect (sorter, "changed", G_CALLBACK (gtk_column_view_sorter_changed_cb), self);
s->inverted = FALSE;
g_sequence_insert_before (iter, s);
/* notify the previous first column to stop drawing an arrow */
if (first)
gtk_column_view_column_notify_sort (first->column);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_COLUMN]);
out:
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_ORDER]);
gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_DIFFERENT);
gtk_column_view_column_notify_sort (column);
return TRUE;
}
gboolean
gtk_column_view_sorter_remove_column (GtkColumnViewSorter *self,
GtkColumnViewColumn *column)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), FALSE);
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (column), FALSE);
if (remove_column (self, column))
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_COLUMN]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_ORDER]);
gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_DIFFERENT);
gtk_column_view_column_notify_sort (column);
return TRUE;
}
return FALSE;
}
gboolean
gtk_column_view_sorter_set_column (GtkColumnViewSorter *self,
GtkColumnViewColumn *column,
gboolean inverted)
{
GtkSorter *sorter;
Sorter *s;
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), FALSE);
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (column), FALSE);
sorter = gtk_column_view_column_get_sorter (column);
if (sorter == NULL)
return FALSE;
g_object_ref (column);
g_sequence_remove_range (g_sequence_get_begin_iter (self->sorters),
g_sequence_get_end_iter (self->sorters));
s = g_new (Sorter, 1);
s->column = g_object_ref (column);
s->sorter = g_object_ref (sorter);
s->changed_id = g_signal_connect (sorter, "changed", G_CALLBACK (gtk_column_view_sorter_changed_cb), self);
s->inverted = inverted;
g_sequence_prepend (self->sorters, s);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_COLUMN]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_ORDER]);
gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_DIFFERENT);
gtk_column_view_column_notify_sort (column);
g_object_unref (column);
return TRUE;
}
void
gtk_column_view_sorter_clear (GtkColumnViewSorter *self)
gtk_column_view_sorter_activate_column (GtkSorter *self,
GtkColumnViewColumn *column)
{
GSequenceIter *iter;
Sorter *s;
GtkColumnViewColumn *column;
GtkMultiSorter *multi = GTK_MULTI_SORTER (self);
GtkInvertibleSorter *sorter, *s;
g_return_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self));
g_return_if_fail (GTK_IS_MULTI_SORTER (self));
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (column));
if (g_sequence_is_empty (self->sorters))
sorter = gtk_column_view_column_get_invertible_sorter (column);
if (sorter == NULL)
return;
iter = g_sequence_get_begin_iter (self->sorters);
s = g_sequence_get (iter);
column = g_object_ref (s->column);
g_sequence_remove_range (iter, g_sequence_get_end_iter (self->sorters));
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_COLUMN]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_SORT_ORDER]);
gtk_sorter_changed (GTK_SORTER (self), GTK_SORTER_CHANGE_DIFFERENT);
gtk_column_view_column_notify_sort (column);
g_object_unref (column);
}
GtkColumnViewColumn *
gtk_column_view_sorter_get_sort_column (GtkColumnViewSorter *self,
gboolean *inverted)
{
GSequenceIter *iter;
Sorter *s;
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), NULL);
if (g_sequence_is_empty (self->sorters))
return NULL;
iter = g_sequence_get_begin_iter (self->sorters);
s = g_sequence_get (iter);
*inverted = s->inverted;
return s->column;
}
/* }}} */
/* {{{ Public API */
/**
* gtk_column_view_sorter_get_primary_sort_column:
* @self: a `GtkColumnViewSorter`
*
* Returns the primary sort column.
*
* The primary sort column is the one that displays the triangle
* in a column view header.
*
* Returns: (nullable) (transfer none): the primary sort column
*
* Since: 4.10
*/
GtkColumnViewColumn *
gtk_column_view_sorter_get_primary_sort_column (GtkColumnViewSorter *self)
{
GSequenceIter *iter;
Sorter *s;
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), NULL);
iter = g_sequence_get_begin_iter (self->sorters);
if (g_sequence_iter_is_end (iter))
return NULL;
s = g_sequence_get (iter);
return s->column;
}
/**
* gtk_column_view_sorter_get_primary_sort_order:
* @self: a `GtkColumnViewSorter`
*
* Returns the primary sort order.
*
* The primary sort order determines whether the triangle displayed
* in the column view header of the primary sort column points upwards
* or downwards.
*
* If there is no primary sort column, then this function returns
* `GTK_SORT_ASCENDING`.
*
* Returns: the primary sort order
*
* Since: 4.10
*/
GtkSortType
gtk_column_view_sorter_get_primary_sort_order (GtkColumnViewSorter *self)
{
GSequenceIter *iter;
Sorter *s;
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), GTK_SORT_ASCENDING);
iter = g_sequence_get_begin_iter (self->sorters);
if (g_sequence_iter_is_end (iter))
return GTK_SORT_ASCENDING;
s = g_sequence_get (iter);
return s->inverted ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING;
}
/**
* gtk_column_view_sorter_get_n_sort_columns:
* @self: a `GtkColumnViewSorter`
*
* Returns the number of columns by which the sorter sorts.
*
* If the sorter of the primary sort column does not determine
* a total order, then the secondary sorters are consulted to
* break the ties.
*
* Use the [signal@Gtk.Sorter::changed] signal to get notified
* when the number of sort columns changes.
*
* Returns: the number of sort columns
*
* Since: 4.10
*/
guint
gtk_column_view_sorter_get_n_sort_columns (GtkColumnViewSorter *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), 0);
return (guint) g_sequence_get_length (self->sorters);
}
/**
* gtk_column_view_sorter_get_nth_sort_column:
* @self: a `GtkColumnViewSorter`
* @position: the position of the sort column to retrieve (0 for the
* primary sort column)
* @sort_order: (out): return location for the sort order
*
* Gets the @position'th sort column and its associated sort order.
*
* Use the [signal@Gtk.Sorter::changed] signal to get notified
* when sort columns change.
*
* Returns: (nullable) (transfer none): the @positions sort column
*
* Since: 4.10
*/
GtkColumnViewColumn *
gtk_column_view_sorter_get_nth_sort_column (GtkColumnViewSorter *self,
guint position,
GtkSortType *sort_order)
{
GSequenceIter *iter;
Sorter *s;
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_SORTER (self), NULL);
iter = g_sequence_get_iter_at_pos (self->sorters, (int) position);
if (g_sequence_iter_is_end (iter))
if (g_list_model_get_n_items (G_LIST_MODEL (self)) > 0)
{
*sort_order = GTK_SORT_ASCENDING;
return NULL;
s = g_list_model_get_item (G_LIST_MODEL (self), 0);
}
else
s = NULL;
if (s == sorter)
{
/* column is already first, toggle sort order */
gtk_invertible_sorter_set_sort_order (s, 1 - gtk_invertible_sorter_get_sort_order (s));
gtk_column_view_column_notify_sort (column);
}
else
{
/* move column to the first position */
remove_column (self, column);
gtk_invertible_sorter_set_sort_order (GTK_INVERTIBLE_SORTER (sorter), GTK_SORT_ASCENDING);
g_object_ref (sorter);
gtk_multi_sorter_splice (multi, 0, 0, (GtkSorter **)&sorter, 1);
if (s)
{
gtk_column_view_column_notify_sort (get_column (s));
g_object_unref (s);
}
gtk_column_view_column_notify_sort (column);
}
}
void
gtk_column_view_sorter_remove_column (GtkSorter *self,
GtkColumnViewColumn *column)
{
g_return_if_fail (GTK_IS_MULTI_SORTER (self));
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (column));
remove_column (self, column);
}
void
gtk_column_view_sorter_set_column (GtkSorter *self,
GtkColumnViewColumn *column,
GtkSortType direction)
{
GtkMultiSorter *multi = GTK_MULTI_SORTER (self);
GtkSorter *sorter;
GtkInvertibleSorter *s;
g_return_if_fail (GTK_IS_MULTI_SORTER (self));
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (column));
sorter = GTK_SORTER (gtk_column_view_column_get_invertible_sorter (column));
if (sorter == NULL)
return;
if (g_list_model_get_n_items (G_LIST_MODEL (self)) > 0)
s = g_list_model_get_item (G_LIST_MODEL (self), 0);
else
s = NULL;
remove_column (self, column);
gtk_invertible_sorter_set_sort_order (GTK_INVERTIBLE_SORTER (sorter), direction);
g_object_ref (sorter);
gtk_multi_sorter_splice (multi, 0, 0, &sorter, 1);
if (s)
{
gtk_column_view_column_notify_sort (get_column (s));
g_object_unref (s);
}
s = g_sequence_get (iter);
*sort_order = s->inverted ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING;
return s->column;
gtk_column_view_column_notify_sort (column);
}
/* }}} */
void
gtk_column_view_sorter_clear (GtkSorter *self)
{
GtkMultiSorter *multi = GTK_MULTI_SORTER (self);
GtkInvertibleSorter *s;
/* vim:set foldmethod=marker expandtab: */
g_return_if_fail (GTK_IS_MULTI_SORTER (self));
if (g_list_model_get_n_items (G_LIST_MODEL (self)) == 0)
return;
s = g_list_model_get_item (G_LIST_MODEL (self), 0);
gtk_multi_sorter_splice (multi, 0, g_list_model_get_n_items (G_LIST_MODEL (self)), NULL, 0);
gtk_column_view_column_notify_sort (get_column (s));
g_object_unref (s);
}
+14 -17
View File
@@ -17,35 +17,32 @@
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __GTK_COLUMN_VIEW_SORTER_PRIVATE_H__
#define __GTK_COLUMN_VIEW_SORTER_PRIVATE_H__
#ifndef __GTK_COLUMN_VIEW_SORTER_H__
#define __GTK_COLUMN_VIEW_SORTER_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkcolumnviewsorter.h>
#include <gdk/gdk.h>
#include <gtk/gtksorter.h>
#include <gtk/gtkcolumnviewcolumn.h>
G_BEGIN_DECLS
GtkColumnViewSorter * gtk_column_view_sorter_new (void);
void gtk_column_view_sorter_activate_column (GtkSorter *self,
GtkColumnViewColumn *column);
void gtk_column_view_sorter_remove_column (GtkSorter *self,
GtkColumnViewColumn *column);
gboolean gtk_column_view_sorter_add_column (GtkColumnViewSorter *self,
GtkColumnViewColumn *column);
gboolean gtk_column_view_sorter_remove_column (GtkColumnViewSorter *self,
GtkColumnViewColumn *column);
void gtk_column_view_sorter_clear (GtkSorter *self);
void gtk_column_view_sorter_clear (GtkColumnViewSorter *self);
GtkColumnViewColumn * gtk_column_view_sorter_get_sort_column (GtkColumnViewSorter *self,
gboolean *inverted);
gboolean gtk_column_view_sorter_set_column (GtkColumnViewSorter *self,
GtkColumnViewColumn *column,
gboolean inverted);
void gtk_column_view_sorter_set_column (GtkSorter *self,
GtkColumnViewColumn *column,
GtkSortType direction);
G_END_DECLS
#endif /* __GTK_COLUMN_VIEW_SORTER_PRIVATE_H__ */
#endif /* __GTK_COLUMN_VIEW_SORTER_H__ */
+24 -29
View File
@@ -189,15 +189,15 @@ activate_sort (GtkColumnViewTitle *self)
{
GtkSorter *sorter;
GtkColumnView *view;
GtkColumnViewSorter *view_sorter;
GtkSorter *view_sorter;
sorter = gtk_column_view_column_get_sorter (self->column);
if (sorter == NULL)
return;
view = gtk_column_view_column_get_column_view (self->column);
view_sorter = GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (view));
gtk_column_view_sorter_add_column (view_sorter, self->column);
view_sorter = gtk_column_view_get_sorter (view);
gtk_column_view_sorter_activate_column (view_sorter, self->column);
}
static void
@@ -283,56 +283,51 @@ gtk_column_view_title_new (GtkColumnViewColumn *column)
title = g_object_new (GTK_TYPE_COLUMN_VIEW_TITLE, NULL);
title->column = g_object_ref (column);
gtk_column_view_title_update_sort (title);
gtk_column_view_title_set_title (title, gtk_column_view_column_get_title (column));
gtk_column_view_title_set_menu (title, gtk_column_view_column_get_header_menu (column));
gtk_column_view_title_update (title);
return GTK_WIDGET (title);
}
void
gtk_column_view_title_set_title (GtkColumnViewTitle *self,
const char *title)
gtk_column_view_title_update (GtkColumnViewTitle *self)
{
gtk_label_set_label (GTK_LABEL (self->title), title);
}
GtkInvertibleSorter *sorter;
void
gtk_column_view_title_set_menu (GtkColumnViewTitle *self,
GMenuModel *model)
{
g_clear_pointer (&self->popup_menu, gtk_widget_unparent);
}
gtk_label_set_label (GTK_LABEL (self->title), gtk_column_view_column_get_title (self->column));
void
gtk_column_view_title_update_sort (GtkColumnViewTitle *self)
{
if (gtk_column_view_column_get_sorter (self->column))
sorter = gtk_column_view_column_get_invertible_sorter (self->column);
if (sorter)
{
GtkColumnView *view;
GtkColumnViewSorter *view_sorter;
GtkColumnViewColumn *primary;
GtkSortType sort_order;
GtkSorter *view_sorter;
GtkInvertibleSorter *active = NULL;
GtkSortType direction = GTK_SORT_ASCENDING;
view = gtk_column_view_column_get_column_view (self->column);
view_sorter = GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (view));
primary = gtk_column_view_sorter_get_primary_sort_column (view_sorter);
sort_order = gtk_column_view_sorter_get_primary_sort_order (view_sorter);
view_sorter = gtk_column_view_get_sorter (view);
if (g_list_model_get_n_items (G_LIST_MODEL (view_sorter)) > 0)
{
active = g_list_model_get_item (G_LIST_MODEL (view_sorter), 0);
g_object_unref (active);
direction = gtk_invertible_sorter_get_sort_order (active);
}
gtk_widget_show (self->sort);
gtk_widget_remove_css_class (self->sort, "ascending");
gtk_widget_remove_css_class (self->sort, "descending");
gtk_widget_remove_css_class (self->sort, "unsorted");
if (self->column != primary)
if (sorter != active)
gtk_widget_add_css_class (self->sort, "unsorted");
else if (sort_order == GTK_SORT_DESCENDING)
else if (direction == GTK_SORT_DESCENDING)
gtk_widget_add_css_class (self->sort, "descending");
else
gtk_widget_add_css_class (self->sort, "ascending");
}
else
gtk_widget_hide (self->sort);
g_clear_pointer (&self->popup_menu, gtk_widget_unparent);
}
GtkColumnViewColumn *
+1 -6
View File
@@ -38,12 +38,7 @@ GType gtk_column_view_title_get_type (void) G_GNUC_CO
GtkWidget * gtk_column_view_title_new (GtkColumnViewColumn *column);
void gtk_column_view_title_set_title (GtkColumnViewTitle *self,
const char *title);
void gtk_column_view_title_set_menu (GtkColumnViewTitle *self,
GMenuModel *model);
void gtk_column_view_title_update_sort (GtkColumnViewTitle *self);
void gtk_column_view_title_update (GtkColumnViewTitle *self);
GtkColumnViewColumn * gtk_column_view_title_get_column (GtkColumnViewTitle *self);
+2 -26
View File
@@ -25,7 +25,6 @@
#include "gtkcomposetable.h"
#include "gtkimcontextsimple.h"
#include "gtkprivate.h"
#define GTK_COMPOSE_TABLE_MAGIC "GtkComposeTable"
@@ -285,20 +284,6 @@ fail:
static void parser_parse_file (GtkComposeParser *parser,
const char *path);
char *
gtk_compose_table_get_x11_compose_file_dir (void)
{
char * compose_file_dir;
#if defined (X11_DATA_PREFIX)
compose_file_dir = g_strdup (X11_DATA_PREFIX "/share/X11/locale");
#else
compose_file_dir = g_build_filename (_gtk_get_datadir (), "X11", "locale", NULL);
#endif
return compose_file_dir;
}
/* Substitute %H, %L and %S */
static char *
handle_substitutions (const char *start,
@@ -320,9 +305,6 @@ handle_substitutions (const char *start,
}
else
{
char *x11_compose_file_dir;
char *path;
switch (p[1])
{
case 'H':
@@ -331,17 +313,11 @@ handle_substitutions (const char *start,
break;
case 'L':
p++;
x11_compose_file_dir = gtk_compose_table_get_x11_compose_file_dir ();
path = g_build_filename (x11_compose_file_dir, locale_name, "Compose", NULL);
g_string_append (s, path);
g_free (path);
g_free (x11_compose_file_dir);
g_string_append_printf (s, "/usr/share/X11/locale/%s/Compose", locale_name);
break;
case 'S':
p++;
x11_compose_file_dir = gtk_compose_table_get_x11_compose_file_dir ();
g_string_append (s, x11_compose_file_dir);
g_free (x11_compose_file_dir);
g_string_append (s, "/usr/share/X11/locale");
break;
default: ;
/* do nothing, next iteration handles p[1] */
-2
View File
@@ -93,8 +93,6 @@ guint32 gtk_compose_table_data_hash (const guint16 *data,
int max_seq_len,
int n_seqs);
char * gtk_compose_table_get_x11_compose_file_dir (void);
G_END_DECLS
#endif /* __GTK_COMPOSETABLE_H__ */
+1 -2
View File
@@ -61,8 +61,7 @@ struct _GtkEntryCompletion
gulong completion_timeout;
gulong changed_id;
GSignalGroup *insert_text_signal_group;
gulong insert_text_id;
int current_selected;
-304
View File
@@ -1,304 +0,0 @@
/*
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*/
#include "config.h"
#include "gtkfilechoosercellprivate.h"
#include "gtkprivate.h"
#include "gtkbinlayout.h"
#include "gtkdragsource.h"
#include "gtkgestureclick.h"
#include "gtkgesturelongpress.h"
#include "gtkicontheme.h"
#include "gtklistitem.h"
#include "gtkselectionmodel.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserwidgetprivate.h"
struct _GtkFileChooserCell
{
GtkWidget parent_instance;
GFileInfo *item;
gboolean selected;
guint position;
gboolean show_time;
};
struct _GtkFileChooserCellClass
{
GtkWidgetClass parent_class;
};
G_DEFINE_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK_TYPE_WIDGET)
enum
{
PROP_POSITION = 1,
PROP_SELECTED,
PROP_ITEM,
PROP_SHOW_TIME,
};
#define ICON_SIZE 16
static void
popup_menu (GtkFileChooserCell *self,
double x,
double y)
{
GtkWidget *widget = GTK_WIDGET (self);
GtkSelectionModel *model;
GtkWidget *impl;
double xx, yy;
impl = gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_CHOOSER_WIDGET);
model = gtk_file_chooser_widget_get_selection_model (GTK_FILE_CHOOSER_WIDGET (impl));
gtk_selection_model_select_item (model, self->position, TRUE);
gtk_widget_translate_coordinates (widget, GTK_WIDGET (impl),
x, y, &xx, &yy);
gtk_widget_activate_action (widget, "item.popup-file-list-menu",
"(udd)", self->position, xx, yy);
}
static void
file_chooser_cell_clicked (GtkEventController *controller,
int n_press,
double x,
double y)
{
GtkWidget *widget = gtk_event_controller_get_widget (controller);
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED);
popup_menu (self, x, y);
}
static void
file_chooser_cell_long_pressed (GtkEventController *controller,
double x,
double y)
{
GtkWidget *widget = gtk_event_controller_get_widget (controller);
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
gtk_gesture_set_state (GTK_GESTURE (controller), GTK_EVENT_SEQUENCE_CLAIMED);
popup_menu (self, x, y);
}
static GdkContentProvider *
drag_prepare_cb (GtkDragSource *source,
double x,
double y,
gpointer user_data)
{
GdkContentProvider *provider;
GSList *selection;
GtkFileChooserWidget *impl;
GtkIconTheme *icon_theme;
GIcon *icon;
int scale;
GtkIconPaintable *paintable;
GtkFileChooserCell *self = user_data;
impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (self),
GTK_TYPE_FILE_CHOOSER_WIDGET));
if (!self->selected)
{
gtk_selection_model_select_item (gtk_file_chooser_widget_get_selection_model (impl),
self->position, TRUE);
}
selection = gtk_file_chooser_widget_get_selected_files (impl);
if (!selection)
return NULL;
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
icon = _gtk_file_info_get_icon (self->item, ICON_SIZE, scale, icon_theme);
paintable = gtk_icon_theme_lookup_by_gicon (icon_theme,icon, ICON_SIZE, scale, GTK_TEXT_DIR_NONE, 0);
gtk_drag_source_set_icon (source, GDK_PAINTABLE (paintable), x, y);
provider = gdk_content_provider_new_typed (GDK_TYPE_FILE_LIST, selection);
g_slist_free_full (selection, g_object_unref);
g_object_unref (paintable);
g_object_unref (icon);
return provider;
}
static void
gtk_file_chooser_cell_realize (GtkWidget *widget)
{
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (widget);
GtkFileChooserWidget *impl;
impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (GTK_WIDGET (self),
GTK_TYPE_FILE_CHOOSER_WIDGET));
g_object_bind_property (impl, "show-time", self, "show-time", G_BINDING_SYNC_CREATE);
}
static void
gtk_file_chooser_cell_init (GtkFileChooserCell *self)
{
GtkGesture *gesture;
GtkDragSource *drag_source;
gesture = gtk_gesture_click_new ();
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
g_signal_connect (gesture, "pressed", G_CALLBACK (file_chooser_cell_clicked), NULL);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture));
gesture = gtk_gesture_long_press_new ();
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
g_signal_connect (gesture, "pressed", G_CALLBACK (file_chooser_cell_long_pressed), NULL);
drag_source = gtk_drag_source_new ();
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drag_source));
g_signal_connect (drag_source, "prepare", G_CALLBACK (drag_prepare_cb), self);
g_signal_connect (self, "realize", G_CALLBACK (gtk_file_chooser_cell_realize), NULL);
}
static void
gtk_file_chooser_cell_dispose (GObject *object)
{
GtkWidget *child;
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))))
gtk_widget_unparent (child);
G_OBJECT_CLASS (gtk_file_chooser_cell_parent_class)->dispose (object);
}
static void
gtk_file_chooser_cell_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (object);
switch (prop_id)
{
case PROP_POSITION:
self->position = g_value_get_uint (value);
break;
case PROP_SELECTED:
self->selected = g_value_get_boolean (value);
break;
case PROP_ITEM:
self->item = g_value_get_object (value);
break;
case PROP_SHOW_TIME:
self->show_time = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_file_chooser_cell_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkFileChooserCell *self = GTK_FILE_CHOOSER_CELL (object);
switch (prop_id)
{
case PROP_POSITION:
g_value_set_uint (value, self->position);
break;
case PROP_SELECTED:
g_value_set_boolean (value, self->selected);
break;
case PROP_ITEM:
g_value_set_object (value, self->item);
break;
case PROP_SHOW_TIME:
g_value_set_boolean (value, self->show_time);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_file_chooser_cell_class_init (GtkFileChooserCellClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gtk_file_chooser_cell_dispose;
object_class->set_property = gtk_file_chooser_cell_set_property;
object_class->get_property = gtk_file_chooser_cell_get_property;
g_object_class_install_property (object_class, PROP_POSITION,
g_param_spec_uint ("position", NULL, NULL,
0, G_MAXUINT, 0,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SELECTED,
g_param_spec_boolean ("selected", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ITEM,
g_param_spec_object ("item", NULL, NULL,
G_TYPE_FILE_INFO,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SHOW_TIME,
g_param_spec_boolean ("show-time", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE));
gtk_widget_class_set_css_name (widget_class, I_("filelistcell"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
}
GtkFileChooserCell *
gtk_file_chooser_cell_new (void)
{
return g_object_new (GTK_TYPE_FILE_CHOOSER_CELL, NULL);
}
-37
View File
@@ -1,37 +0,0 @@
/*
* Copyright © 2022 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Matthias Clasen
*/
#ifndef __GTK_FILE_CHOOSER_CELL_PRIVATE_H__
#define __GTK_FILE_CHOOSER_CELL_PRIVATE_H__
#include <gtk/gtkwidget.h>
#include <gtk/gtkexpression.h>
G_BEGIN_DECLS
#define GTK_TYPE_FILE_CHOOSER_CELL (gtk_file_chooser_cell_get_type ())
GDK_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK, FILE_CHOOSER_CELL, GtkWidget)
GtkFileChooserCell * gtk_file_chooser_cell_new (void);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_CELL_PRIVATE_H__ */
+72 -83
View File
@@ -60,8 +60,7 @@ struct _GtkFileChooserEntry
char *dir_part;
char *file_part;
GtkTreeStore *completion_store;
GtkFileSystemModel *model;
GtkTreeModel *completion_store;
GtkFileFilter *current_filter;
guint current_folder_loaded : 1;
@@ -72,7 +71,6 @@ struct _GtkFileChooserEntry
enum
{
FILE_INFO_COLUMN,
DISPLAY_NAME_COLUMN,
FULL_PATH_COLUMN,
N_COLUMNS
@@ -199,21 +197,20 @@ match_func (GtkEntryCompletion *compl,
* current file filter (e.g. just jpg files) here. */
if (chooser_entry->current_filter != NULL)
{
GFile *file;
GFileInfo *info;
gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
iter,
FILE_INFO_COLUMN, &info,
-1);
g_assert (info != NULL);
g_object_unref (info);
file = _gtk_file_system_model_get_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
iter);
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
iter);
/* We always allow navigating into subfolders, so don't ever filter directories */
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
return TRUE;
g_assert (g_file_info_has_attribute (info, "standard::file"));
if (!g_file_info_has_attribute (info, "standard::file"))
g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file));
return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
}
@@ -431,7 +428,7 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
{
chooser_entry->complete_on_load = FALSE;
if (chooser_entry->model)
if (chooser_entry->completion_store)
{
char *completion, *text;
gsize completion_len, text_len;
@@ -542,93 +539,77 @@ update_inline_completion (GtkFileChooserEntry *chooser_entry)
static void
discard_completion_store (GtkFileChooserEntry *chooser_entry)
{
if (!chooser_entry->model)
if (!chooser_entry->completion_store)
return;
g_assert (chooser_entry->completion_store != NULL);
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);
update_inline_completion (chooser_entry);
g_clear_object (&chooser_entry->completion_store);
g_clear_object (&chooser_entry->model);
g_object_unref (chooser_entry->completion_store);
chooser_entry->completion_store = NULL;
}
static void
model_items_changed_cb (GListModel *model,
guint position,
guint removed,
guint added,
GtkFileChooserEntry *self)
static gboolean
completion_store_set (GtkFileSystemModel *model,
GFile *file,
GFileInfo *info,
int column,
GValue *value,
gpointer data)
{
if (removed > 0)
GtkFileChooserEntry *chooser_entry = data;
const char *prefix = "";
const char *suffix = "";
switch (column)
{
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->completion_store),
&iter,
NULL,
position))
{
while (removed--)
gtk_tree_store_remove (self->completion_store, &iter);
}
}
while (added-- > 0)
{
GtkTreeIter iter;
GFileInfo *info;
const char *suffix = NULL;
char *full_path;
char *display_name;
info = g_list_model_get_item (model, position);
case FULL_PATH_COLUMN:
prefix = chooser_entry->dir_part;
G_GNUC_FALLTHROUGH;
case DISPLAY_NAME_COLUMN:
if (_gtk_file_info_consider_as_directory (info))
suffix = G_DIR_SEPARATOR_S;
display_name = g_strconcat (g_file_info_get_display_name (info), suffix, NULL);
full_path = g_strconcat (self->dir_part, display_name, NULL);
gtk_tree_store_insert_with_values (self->completion_store,
&iter, NULL,
position,
FILE_INFO_COLUMN, info,
FULL_PATH_COLUMN, full_path,
DISPLAY_NAME_COLUMN, display_name,
-1);
g_clear_object (&info);
position++;
g_value_take_string (value,
g_strconcat (prefix,
g_file_info_get_display_name (info),
suffix,
NULL));
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
/* Fills the completion store from the contents of the current folder */
static void
populate_completion_store (GtkFileChooserEntry *chooser_entry)
{
chooser_entry->completion_store = gtk_tree_store_new (N_COLUMNS,
G_TYPE_FILE_INFO,
G_TYPE_STRING,
G_TYPE_STRING);
chooser_entry->model =
chooser_entry->completion_store = GTK_TREE_MODEL (
_gtk_file_system_model_new_for_directory (chooser_entry->current_folder_file,
"standard::name,standard::display-name,standard::type,"
"standard::content-type");
g_signal_connect (chooser_entry->model, "items-changed",
G_CALLBACK (model_items_changed_cb), chooser_entry);
g_signal_connect (chooser_entry->model, "finished-loading",
"standard::content-type",
completion_store_set,
chooser_entry,
N_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING));
g_signal_connect (chooser_entry->completion_store, "finished-loading",
G_CALLBACK (finished_loading_cb), chooser_entry);
_gtk_file_system_model_set_filter_folders (chooser_entry->model, TRUE);
_gtk_file_system_model_set_show_files (chooser_entry->model,
_gtk_file_system_model_set_filter_folders (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
TRUE);
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
chooser_entry->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
chooser_entry->action == GTK_FILE_CHOOSER_ACTION_SAVE);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store),
DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
GTK_TREE_MODEL (chooser_entry->completion_store));
chooser_entry->completion_store);
}
/* Callback when the current folder finishes loading */
@@ -656,7 +637,7 @@ finished_loading_cb (GtkFileSystemModel *model,
completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry));
update_inline_completion (chooser_entry);
if (gtk_widget_has_focus (GTK_WIDGET (gtk_entry_get_text_widget (GTK_ENTRY (chooser_entry)))))
if (gtk_widget_has_focus (GTK_WIDGET (chooser_entry)))
{
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
@@ -677,7 +658,11 @@ set_completion_folder (GtkFileChooserEntry *chooser_entry,
return;
}
g_clear_object (&chooser_entry->current_folder_file);
if (chooser_entry->current_folder_file)
{
g_object_unref (chooser_entry->current_folder_file);
chooser_entry->current_folder_file = NULL;
}
g_free (chooser_entry->dir_part);
chooser_entry->dir_part = g_strdup (dir_part);
@@ -725,7 +710,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
g_free (dir_part);
if (chooser_entry->model &&
if (chooser_entry->completion_store &&
(g_strcmp0 (old_file_part, chooser_entry->file_part) != 0))
{
GtkFileFilter *filter;
@@ -735,7 +720,8 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry)
pattern = g_strconcat (chooser_entry->file_part, "*", NULL);
gtk_file_filter_add_pattern (filter, pattern);
_gtk_file_system_model_set_filter (chooser_entry->model, filter);
_gtk_file_system_model_set_filter (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
filter);
g_free (pattern);
g_object_unref (filter);
@@ -954,8 +940,8 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
break;
}
if (chooser_entry->model)
_gtk_file_system_model_set_show_files (chooser_entry->model,
if (chooser_entry->completion_store)
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
action == GTK_FILE_CHOOSER_ACTION_OPEN ||
action == GTK_FILE_CHOOSER_ACTION_SAVE);
@@ -985,14 +971,17 @@ gboolean
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
GFile *file)
{
GtkTreeIter iter;
GFileInfo *info;
if (chooser_entry->model == NULL)
if (chooser_entry->completion_store == NULL ||
!_gtk_file_system_model_get_iter_for_file (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
&iter,
file))
return FALSE;
info = _gtk_file_system_model_get_info_for_file (chooser_entry->model, file);
if (!info)
return FALSE;
info = _gtk_file_system_model_get_info (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
&iter);
return _gtk_file_info_consider_as_directory (info);
}
-9
View File
@@ -479,12 +479,3 @@ _gtk_file_info_get_icon (GFileInfo *info,
icon = g_themed_icon_new ("text-x-generic");
return icon;
}
GFile *
_gtk_file_info_get_file (GFileInfo *info)
{
g_assert (G_IS_FILE_INFO (info));
g_assert (g_file_info_has_attribute (info, "standard::file"));
return G_FILE (g_file_info_get_attribute_object (info, "standard::file"));
}
-2
View File
@@ -58,8 +58,6 @@ GIcon * _gtk_file_info_get_icon (GFileInfo *info,
int scale,
GtkIconTheme *icon_theme);
GFile * _gtk_file_info_get_file (GFileInfo *info);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_UTILS_H__ */
+1831 -1112
View File
File diff suppressed because it is too large Load Diff
-7
View File
@@ -23,7 +23,6 @@
#include <glib.h>
#include "gtkfilechooserwidget.h"
#include "gtkselectionmodel.h"
G_BEGIN_DECLS
@@ -37,12 +36,6 @@ gtk_file_chooser_widget_should_respond (GtkFileChooserWidget *chooser);
void
gtk_file_chooser_widget_initial_focus (GtkFileChooserWidget *chooser);
GSList *
gtk_file_chooser_widget_get_selected_files (GtkFileChooserWidget *impl);
GtkSelectionModel *
gtk_file_chooser_widget_get_selection_model (GtkFileChooserWidget *chooser);
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__ */
-914
View File
@@ -1,914 +0,0 @@
/*
* 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 "gtkfiledialog.h"
#include "gtk/gtkchoice.h"
#include "gtkfilechooserdialog.h"
#include <glib/gi18n-lib.h>
/**
* GtkFileDialog:
*
* A `GtkFileDialog` object collects the arguments that
* are needed to present a file chooser dialog to the
* user, such as a title for the dialog and whether it
* should be modal.
*
* The dialog is shown with the [function@Gtk.FileDialog.choose_rgba]
* function. This API follows the GIO async pattern, and the
* result can be obtained by calling
* [function@Gtk.FileDialog.choose_rgba_finish].
*
* See [class@Gtk.FileDialogButton] for a convenient control
* that uses `GtkFileDialog` and presents the results.
*
* `GtkFileDialog was added in GTK 4.10.
*/
/* {{{ GObject implementation */
struct _GtkFileDialog
{
GObject parent_instance;
char *title;
unsigned int modal : 1;
unsigned int select_multiple : 1;
unsigned int create_folders : 1;
GListModel *filters;
GListModel *shortcuts;
GListModel *choices;
};
enum
{
PROP_TITLE = 1,
PROP_MODAL,
PROP_SELECT_MULTIPLE,
PROP_CREATE_FOLDERS,
PROP_FILTERS,
PROP_SHORTCUTS,
PROP_CHOICES,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkFileDialog, gtk_file_dialog, G_TYPE_OBJECT)
static void
gtk_file_dialog_init (GtkFileDialog *self)
{
self->title = g_strdup (_("Pick a File"));
self->modal = TRUE;
self->create_folders = TRUE;
}
static void
gtk_file_dialog_finalize (GObject *object)
{
GtkFileDialog *self = GTK_FILE_DIALOG (object);
g_free (self->title);
g_clear_object (&self->filters);
g_clear_object (&self->shortcuts);
g_clear_object (&self->choices);
G_OBJECT_CLASS (gtk_file_dialog_parent_class)->finalize (object);
}
static void
gtk_file_dialog_get_property (GObject *object,
unsigned int property_id,
GValue *value,
GParamSpec *pspec)
{
GtkFileDialog *self = GTK_FILE_DIALOG (object);
switch (property_id)
{
case PROP_TITLE:
g_value_set_string (value, self->title);
break;
case PROP_MODAL:
g_value_set_boolean (value, self->modal);
break;
case PROP_SELECT_MULTIPLE:
g_value_set_boolean (value, self->select_multiple);
break;
case PROP_CREATE_FOLDERS:
g_value_set_boolean (value, self->create_folders);
break;
case PROP_FILTERS:
g_value_set_object (value, self->filters);
break;
case PROP_SHORTCUTS:
g_value_set_object (value, self->shortcuts);
break;
case PROP_CHOICES:
g_value_set_object (value, self->choices);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_file_dialog_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFileDialog *self = GTK_FILE_DIALOG (object);
switch (prop_id)
{
case PROP_TITLE:
gtk_file_dialog_set_title (self, g_value_get_string (value));
break;
case PROP_MODAL:
gtk_file_dialog_set_modal (self, g_value_get_boolean (value));
break;
case PROP_SELECT_MULTIPLE:
gtk_file_dialog_set_select_multiple (self, g_value_get_boolean (value));
break;
case PROP_CREATE_FOLDERS:
gtk_file_dialog_set_create_folders (self, g_value_get_boolean (value));
break;
case PROP_FILTERS:
gtk_file_dialog_set_filters (self, g_value_get_object (value));
break;
case PROP_SHORTCUTS:
gtk_file_dialog_set_shortcuts (self, g_value_get_object (value));
break;
case PROP_CHOICES:
gtk_file_dialog_set_choices (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_file_dialog_class_init (GtkFileDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_file_dialog_finalize;
object_class->get_property = gtk_file_dialog_get_property;
object_class->set_property = gtk_file_dialog_set_property;
/**
* GtkFileDialog:title: (attributes org.gtk.Property.get=gtk_file_dialog_get_title org.gtk.Property.set=gtk_color_dialog_set_title)
*
* A title that may be shown on the file chooser
* dialog that is presented by [function@Gtk.FileDialog.choose_rgba].
*
* Since: 4.10
*/
properties[PROP_TITLE] =
g_param_spec_string ("title", NULL, NULL,
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFileDialog:modal: (attributes org.gtk.Property.get=gtk_file_dialog_get_modal org.gtk.Property.set=gtk_color_dialog_set_modal)
*
* Whether the file chooser dialog is modal.
*
* Since: 4.10
*/
properties[PROP_MODAL] =
g_param_spec_boolean ("modal", NULL, NULL,
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFileDialog:select-multiple: (attributes org.gtk.Property.get=gtk_file_dialog_get_select_multiple org.gtk.Property.set=gtk_color_dialog_set_select_multiple)
*
* Whether the file chooser dialog allows to select more than one file.
*
* Since: 4.10
*/
properties[PROP_SELECT_MULTIPLE] =
g_param_spec_boolean ("select-multiple", NULL, NULL,
FALSE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFileDialog:create-folders: (attributes org.gtk.Property.get=gtk_file_dialog_get_create_folders org.gtk.Property.set=gtk_color_dialog_set_create_folders)
*
* Whether the file chooser dialog will allow to create new folders.
*
* Since: 4.10
*/
properties[PROP_CREATE_FOLDERS] =
g_param_spec_boolean ("create-folders", NULL, NULL,
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_FILTERS] =
g_param_spec_object ("filters", NULL, NULL,
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_SHORTCUTS] =
g_param_spec_object ("shortcuts", NULL, NULL,
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_CHOICES] =
g_param_spec_object ("choices", NULL, NULL,
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
/* }}} */
/* {{{ Utilities */
static void
file_chooser_set_filters (GtkFileChooser *chooser,
GListModel *filters)
{
if (!filters)
return;
for (unsigned int i = 0; i < g_list_model_get_n_items (filters); i++)
{
GtkFileFilter *filter = g_list_model_get_item (filters, i);
gtk_file_chooser_add_filter (chooser, filter);
g_object_unref (filter);
}
}
static void
file_chooser_set_shortcuts (GtkFileChooser *chooser,
GListModel *shortcuts)
{
if (!shortcuts)
return;
for (unsigned int i = 0; i < g_list_model_get_n_items (shortcuts); i++)
{
GFile *shortcut = g_list_model_get_item (shortcuts, i);
gtk_file_chooser_add_shortcut_folder (chooser, shortcut, NULL);
g_object_unref (shortcut);
}
}
static void
file_chooser_set_choices (GtkFileChooser *chooser,
GListModel *choices)
{
if (!choices)
return;
for (unsigned int i = 0; i < g_list_model_get_n_items (choices); i++)
{
GtkChoice *choice = g_list_model_get_item (choices, i);
char *id;
const char *label;
char **options;
const char * const *option_labels;
label = gtk_choice_get_label (choice);
option_labels = gtk_choice_get_options (choice);
id = g_strdup_printf ("choice %u", i);
if (option_labels)
{
GStrvBuilder *strv = g_strv_builder_new ();
for (unsigned int j = 0; option_labels[j]; j++)
{
char *option = g_strdup_printf ("option %u", j);
g_strv_builder_add (strv, option);
g_free (option);
}
options = g_strv_builder_end (strv);
}
else
options = NULL;
gtk_file_chooser_add_choice (chooser, id, label, (const char **)options, (const char **)option_labels);
g_free (id);
g_strfreev (options);
g_object_unref (choice);
}
}
static char **
file_chooser_get_options (GtkFileChooser *chooser,
GListModel *choices)
{
GStrvBuilder *strv;
if (!choices)
return NULL;
strv = g_strv_builder_new ();
for (unsigned int i = 0; i < g_list_model_get_n_items (choices); i++)
{
GtkChoice *choice = g_list_model_get_item (choices, i);
char *id;
const char *option;
unsigned int pos;
const char *option_label;
id = g_strdup_printf ("choice %u", i);
option = gtk_file_chooser_get_choice (chooser, id);
pos = (unsigned int) g_ascii_strtoull (option + strlen ("option "), NULL, 10);
option_label = gtk_choice_get_options (choice)[pos];
g_strv_builder_add (strv, option_label);
g_free (id);
g_object_unref (choice);
}
return g_strv_builder_end (strv);
}
/* }}} */
/* {{{ Public API */
/* {{{ Constructor */
/**
* gtk_file_dialog_new:
*
* Creates a new `GtkFileDialog` object.
*
* Returns: the new `GtkFileDialog`
*
* Since: 4.10
*/
GtkFileDialog *
gtk_file_dialog_new (void)
{
return g_object_new (GTK_TYPE_FILE_DIALOG, NULL);
}
/* }}} */
/* {{{ Getters and setters */
/**
* gtk_file_dialog_get_title:
* @self: a `GtkFileDialog`
*
* Returns the title that will be shown on the
* file chooser dialog.
*
* Returns: the title
*
* Since: 4.10
*/
const char *
gtk_file_dialog_get_title (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
return self->title;
}
/**
* gtk_file_dialog_set_title:
* @self: a `GtkFileDialog`
* @title: the new title
*
* Sets the title that will be shown on the
* file chooser dialog.
*
* Since: 4.10
*/
void
gtk_file_dialog_set_title (GtkFileDialog *self,
const char *title)
{
char *new_title;
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (title != NULL);
if (g_strcmp0 (self->title, title) == 0)
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]);
}
/**
* gtk_file_dialog_get_modal:
* @self: a `GtkFileDialog`
*
* Returns whether the file chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Returns: `TRUE` if the file chooser dialog is modal
*
* Since: 4.10
*/
gboolean
gtk_file_dialog_get_modal (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), TRUE);
return self->modal;
}
/**
* gtk_file_dialog_set_modal:
* @self: a `GtkFileDialog`
* @modal: the new value
*
* Sets whether the file chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Since: 4.10
*/
void
gtk_file_dialog_set_modal (GtkFileDialog *self,
gboolean modal)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
if (self->modal == modal)
return;
self->modal = modal;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
}
/**
* gtk_file_dialog_get_select_multiple:
* @self: a `GtkFileDialog`
*
* Returns whether the file chooser dialog
* allows to select multiple files.
*
* Returns: `TRUE` if the file chooser dialog allows multi-selection
*
* Since: 4.10
*/
gboolean
gtk_file_dialog_get_select_multiple (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), FALSE);
return self->select_multiple;
}
/**
* gtk_file_dialog_set_select_multiple:
* @self: a `GtkFileDialog`
* @modal: the new value
*
* Sets whether the file chooser dialog
* allows to select multiple files.
*
* Since: 4.10
*/
void
gtk_file_dialog_set_select_multiple (GtkFileDialog *self,
gboolean select_multiple)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
if (self->select_multiple == select_multiple)
return;
self->select_multiple = select_multiple;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECT_MULTIPLE]);
}
/**
* gtk_file_dialog_get_create_folders:
* @self: a `GtkFileDialog`
*
* Returns whether the file chooser dialog
* allows to create folders.
*
* Returns: `TRUE` if the file chooser dialog allows folder creation
*
* Since: 4.10
*/
gboolean
gtk_file_dialog_get_create_folders (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), FALSE);
return self->create_folders;
}
/**
* gtk_file_dialog_set_create_folders:
* @self: a `GtkFileDialog`
* @modal: the new value
*
* Sets whether the file chooser dialog
* allows to create folders.
*
* Since: 4.10
*/
void
gtk_file_dialog_set_create_folders (GtkFileDialog *self,
gboolean create_folders)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
if (self->create_folders == create_folders)
return;
self->create_folders = create_folders;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CREATE_FOLDERS]);
}
void
gtk_file_dialog_set_filters (GtkFileDialog *self,
GListModel *filters)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (G_IS_LIST_MODEL (filters));
g_return_if_fail (g_list_model_get_item_type (G_LIST_MODEL (filters)) == GTK_TYPE_FILE_FILTER);
if (!g_set_object (&self->filters, filters))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILTERS]);
}
GListModel *
gtk_file_dialog_get_filters (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
return self->filters;
}
void
gtk_file_dialog_set_shortcuts (GtkFileDialog *self,
GListModel *shortcuts)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (G_IS_LIST_MODEL (shortcuts));
g_return_if_fail (g_list_model_get_item_type (G_LIST_MODEL (shortcuts)) == G_TYPE_FILE);
if (!g_set_object (&self->shortcuts, shortcuts))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHORTCUTS]);
}
GListModel *
gtk_file_dialog_get_shortcuts (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
return self->shortcuts;
}
void
gtk_file_dialog_set_choices (GtkFileDialog *self,
GListModel *choices)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (G_IS_LIST_MODEL (choices));
g_return_if_fail (g_list_model_get_item_type (G_LIST_MODEL (choices)) == GTK_TYPE_CHOICE);
if (!g_set_object (&self->choices, choices))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CHOICES]);
}
GListModel *
gtk_file_dialog_get_choices (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
return self->choices;
}
/* }}} */
/* {{{ Async API */
typedef struct
{
GListModel *files;
char **options;
} FileResult;
static void response_cb (GTask *task,
int response);
static void
cancelled_cb (GCancellable *cancellable,
GTask *task)
{
response_cb (task, GTK_RESPONSE_CANCEL);
}
static void
response_cb (GTask *task,
int response)
{
GCancellable *cancellable;
cancellable = g_task_get_cancellable (task);
if (cancellable)
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
if (response == GTK_RESPONSE_OK)
{
GtkFileDialog *self;
GtkFileChooserDialog *window;
FileResult file_result;
self = GTK_FILE_DIALOG (g_task_get_source_object (task));
window = GTK_FILE_CHOOSER_DIALOG (g_task_get_task_data (task));
file_result.files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (window));
file_result.options = file_chooser_get_options (GTK_FILE_CHOOSER (window),
gtk_file_dialog_get_choices (self));
g_task_return_pointer (task, &file_result, NULL);
}
else
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
g_object_unref (task);
}
static void
dialog_response (GtkDialog *dialog,
int response,
GTask *task)
{
response_cb (task, response);
}
static GtkFileChooserDialog *
create_file_chooser_dialog (GtkFileDialog *self,
GtkWindow *parent,
GtkFileChooserAction action)
{
GtkWidget *window;
const char *accept[] = {
N_("_Open"), N_("_Save"), N_("_Select")
};
window = gtk_file_chooser_dialog_new (self->title, parent,
action,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_(accept[action]), GTK_RESPONSE_OK,
NULL);
gtk_window_set_modal (GTK_WINDOW (window), self->modal);
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (window), self->select_multiple);
gtk_file_chooser_set_create_folders (GTK_FILE_CHOOSER (window), self->create_folders);
file_chooser_set_filters (GTK_FILE_CHOOSER (window), self->filters);
file_chooser_set_shortcuts (GTK_FILE_CHOOSER (window), self->shortcuts);
file_chooser_set_choices (GTK_FILE_CHOOSER (window), self->choices);
return GTK_FILE_CHOOSER_DIALOG (window);
}
static gboolean
finish_file_op (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error)
{
FileResult *ret;
ret = g_task_propagate_pointer (G_TASK (result), error);
if (ret)
{
*files = ret->files;
if (options)
*options = ret->options;
else
g_strfreev (ret->options);
return TRUE;
}
return FALSE;
}
/**
* gtk_file_dialog_open:
* @self: a `GtkFileDialog`
* @parent: (nullable): the parent `GtkWindow`
* @initial_file: (nullable): the file to select initially
* @cancellable: (nullable): a `GCancellable` to cancel the operation
* @callback: (scope async): a callback to call when the operation is complete
* @user_data: (closure callback): data to pass to @callback
*
* This function initiates a file selection operation by
* presenting a file chooser dialog to the user.
*
* The @callback will be called when the dialog is dismissed.
* It should call [function@Gtk.FileDialog.open_finish]
* to obtain the result.
*
* Since: 4.10
*/
void
gtk_file_dialog_open (GtkFileDialog *self,
GtkWindow *parent,
GFile *initial_file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkFileChooserDialog *window;
GTask *task;
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
window = create_file_chooser_dialog (self, parent, GTK_FILE_CHOOSER_ACTION_OPEN);
if (initial_file)
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (window), initial_file, NULL);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_file_dialog_open);
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
gtk_window_present (GTK_WINDOW (window));
}
/**
* gtk_file_dialog_open_finish:
* @self: a `GtkFileDialog`
* @result: a `GAsyncResult`
* @files: (out caller-allocates): return location for the selected files
* @options: (out caller-allocates): return location for choices
* @error: return location for an error
*
* Finishes the [function@Gtk.FileDialog.open] call and
* returns the resulting files as a `GListModel` of `GFiles`.
*
* Returns: `TRUE` if a file was selected. Otherwise,
* `FALSE` is returned and @error is set
*
* Since: 4.10
*/
gboolean
gtk_file_dialog_open_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error)
{
return finish_file_op (self, result, files, options, error);
}
void
gtk_file_dialog_select_folder (GtkFileDialog *self,
GtkWindow *parent,
GFile *current_folder,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkFileChooserDialog *window;
GTask *task;
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
window = create_file_chooser_dialog (self, parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
if (current_folder)
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (window), current_folder, NULL);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_file_dialog_select_folder);
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
gtk_window_present (GTK_WINDOW (window));
}
gboolean
gtk_file_dialog_select_folder_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error)
{
return finish_file_op (self, result, files, options, error);
}
void
gtk_file_dialog_save (GtkFileDialog *self,
GtkWindow *parent,
GFile *current_folder,
const char *current_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkFileChooserDialog *window;
GTask *task;
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
window = create_file_chooser_dialog (self, parent, GTK_FILE_CHOOSER_ACTION_SAVE);
if (current_folder)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (window), current_folder, NULL);
if (current_name)
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (window), current_name);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_file_dialog_save);
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
gtk_window_present (GTK_WINDOW (window));
}
gboolean
gtk_file_dialog_save_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error)
{
return finish_file_op (self, result, files, options, error);
}
/* }}} */
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-130
View File
@@ -1,130 +0,0 @@
/* 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_FILE_DIALOG (gtk_file_dialog_get_type ())
GDK_AVAILABLE_IN_4_10
G_DECLARE_FINAL_TYPE (GtkFileDialog, gtk_file_dialog, GTK, FILE_DIALOG, GObject)
GDK_AVAILABLE_IN_4_10
GtkFileDialog * gtk_file_dialog_new (void);
GDK_AVAILABLE_IN_4_10
const char * gtk_file_dialog_get_title (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_title (GtkFileDialog *self,
const char *title);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_get_modal (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_modal (GtkFileDialog *self,
gboolean modal);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_get_select_multiple (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_select_multiple (GtkFileDialog *self,
gboolean select_multiple);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_get_create_folders (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_create_folders (GtkFileDialog *self,
gboolean create_folders);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_filters (GtkFileDialog *self,
GListModel *filters);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_filters (GtkFileDialog *dialog);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_shortcuts (GtkFileDialog *self,
GListModel *filters);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_shortcuts (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_choices (GtkFileDialog *self,
GListModel *filters);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_choices (GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_open (GtkFileDialog *self,
GtkWindow *parent,
GFile *current_file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_open_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_select_folder (GtkFileDialog *self,
GtkWindow *parent,
GFile *current_folder,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_select_folder_finish
(GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***options,
GError **error);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_save (GtkFileDialog *dialog,
GtkWindow *parent,
GFile *current_folder,
const char *current_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_4_10
gboolean gtk_file_dialog_save_finish (GtkFileDialog *self,
GAsyncResult *result,
GListModel **files,
char ***choices,
GError **error);
G_END_DECLS
+1049 -82
View File
File diff suppressed because it is too large Load Diff
+33 -4
View File
@@ -21,6 +21,7 @@
#include <gio/gio.h>
#include <gtk/gtkfilefilter.h>
#include <gtk/deprecated/gtktreemodel.h>
G_BEGIN_DECLS
@@ -32,13 +33,39 @@ typedef struct _GtkFileSystemModel GtkFileSystemModel;
GType _gtk_file_system_model_get_type (void) G_GNUC_CONST;
GtkFileSystemModel *_gtk_file_system_model_new (void);
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile *dir,
const char *attributes);
typedef gboolean (*GtkFileSystemModelGetValue) (GtkFileSystemModel *model,
GFile *file,
GFileInfo *info,
int column,
GValue *value,
gpointer user_data);
GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystemModelGetValue get_func,
gpointer get_data,
guint n_columns,
...);
GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile * dir,
const char * attributes,
GtkFileSystemModelGetValue get_func,
gpointer get_data,
guint n_columns,
...);
GFile * _gtk_file_system_model_get_directory (GtkFileSystemModel *model);
GCancellable * _gtk_file_system_model_get_cancellable (GtkFileSystemModel *model);
GFileInfo * _gtk_file_system_model_get_info_for_file(GtkFileSystemModel *model,
gboolean _gtk_file_system_model_iter_is_visible (GtkFileSystemModel *model,
GtkTreeIter *iter);
gboolean _gtk_file_system_model_iter_is_filtered_out (GtkFileSystemModel *model,
GtkTreeIter *iter);
GFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
GtkTreeIter *iter);
gboolean _gtk_file_system_model_get_iter_for_file(GtkFileSystemModel *model,
GtkTreeIter *iter,
GFile *file);
GFile * _gtk_file_system_model_get_file (GtkFileSystemModel *model,
GtkTreeIter *iter);
const GValue * _gtk_file_system_model_get_value (GtkFileSystemModel *model,
GtkTreeIter * iter,
int column);
void _gtk_file_system_model_add_and_query_file (GtkFileSystemModel *model,
GFile *file,
@@ -61,6 +88,8 @@ void _gtk_file_system_model_set_show_files (GtkFileSystemModel
gboolean show_files);
void _gtk_file_system_model_set_filter_folders (GtkFileSystemModel *model,
gboolean show_folders);
void _gtk_file_system_model_clear_cache (GtkFileSystemModel *model,
int column);
void _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
GtkFileFilter *filter);
-255
View File
@@ -1,255 +0,0 @@
/* gtkfilethumbnail.c
*
* Copyright 2022 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "config.h"
#include "gtkfilethumbnail.h"
#include "gtkbinlayout.h"
#include "gtkfilechooserutils.h"
#include "gtkimage.h"
#include "gtkprivate.h"
#include "gtkwidget.h"
#define ICON_SIZE 16
struct _GtkFileThumbnail
{
GtkWidget parent;
GtkWidget *image;
GCancellable *cancellable;
GFileInfo *info;
};
typedef struct
{
GtkWidgetClass parent;
} GtkFileThumbnailClass;
G_DEFINE_FINAL_TYPE (GtkFileThumbnail, _gtk_file_thumbnail, GTK_TYPE_WIDGET)
enum {
PROP_0,
PROP_INFO,
N_PROPS,
};
static GParamSpec *properties [N_PROPS];
static void
copy_attribute (GFileInfo *to,
GFileInfo *from,
const char *attribute)
{
GFileAttributeType type;
gpointer value;
if (g_file_info_get_attribute_data (from, attribute, &type, &value, NULL))
g_file_info_set_attribute (to, attribute, type, value);
}
static gboolean
update_image (GtkFileThumbnail *self)
{
GtkIconTheme *icon_theme;
GIcon *icon;
int scale;
if (!g_file_info_has_attribute (self->info, G_FILE_ATTRIBUTE_STANDARD_ICON))
return FALSE;
scale = gtk_widget_get_scale_factor (GTK_WIDGET (self));
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (self)));
icon = _gtk_file_info_get_icon (self->info, ICON_SIZE, scale, icon_theme);
gtk_image_set_from_gicon (GTK_IMAGE (self->image), icon);
g_object_unref (icon);
return TRUE;
}
static void
thumbnail_queried_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GtkFileThumbnail *self = user_data; /* might be unreffed if operation was cancelled */
GFile *file = G_FILE (object);
GFileInfo *queried;
queried = g_file_query_info_finish (file, result, NULL);
if (queried == NULL)
return;
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
copy_attribute (self->info, queried, G_FILE_ATTRIBUTE_STANDARD_ICON);
update_image (self);
g_clear_object (&queried);
g_clear_object (&self->cancellable);
}
static void
cancel_thumbnail (GtkFileThumbnail *self)
{
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
}
static void
get_thumbnail (GtkFileThumbnail *self)
{
if (!self->info)
return;
if (!update_image (self))
{
GFile *file;
if (g_file_info_has_attribute (self->info, "filechooser::queried"))
return;
g_assert (self->cancellable == NULL);
self->cancellable = g_cancellable_new ();
file = _gtk_file_info_get_file (self->info);
g_file_info_set_attribute_boolean (self->info, "filechooser::queried", TRUE);
g_file_query_info_async (file,
G_FILE_ATTRIBUTE_THUMBNAIL_PATH ","
G_FILE_ATTRIBUTE_THUMBNAILING_FAILED ","
G_FILE_ATTRIBUTE_STANDARD_ICON,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
self->cancellable,
thumbnail_queried_cb,
self);
}
}
static void
_gtk_file_thumbnail_dispose (GObject *object)
{
GtkFileThumbnail *self = (GtkFileThumbnail *)object;
_gtk_file_thumbnail_set_info (self, NULL);
g_clear_pointer (&self->image, gtk_widget_unparent);
G_OBJECT_CLASS (_gtk_file_thumbnail_parent_class)->dispose (object);
}
static void
_gtk_file_thumbnail_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkFileThumbnail *self = GTK_FILE_THUMBNAIL (object);
switch (prop_id)
{
case PROP_INFO:
g_value_set_object (value, self->info);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
_gtk_file_thumbnail_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFileThumbnail *self = GTK_FILE_THUMBNAIL (object);
switch (prop_id)
{
case PROP_INFO:
_gtk_file_thumbnail_set_info (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
_gtk_file_thumbnail_class_init (GtkFileThumbnailClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = _gtk_file_thumbnail_dispose;
object_class->get_property = _gtk_file_thumbnail_get_property;
object_class->set_property = _gtk_file_thumbnail_set_property;
properties[PROP_INFO] =
g_param_spec_object ("file-info", NULL, NULL,
G_TYPE_FILE_INFO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_css_name (widget_class, I_("filethumbnail"));
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
}
static void
_gtk_file_thumbnail_init (GtkFileThumbnail *self)
{
self->image = gtk_image_new ();
gtk_widget_set_parent (self->image, GTK_WIDGET (self));
}
GFileInfo *
_gtk_file_thumbnail_get_info (GtkFileThumbnail *self)
{
g_assert (GTK_IS_FILE_THUMBNAIL (self));
return self->info;
}
void
_gtk_file_thumbnail_set_info (GtkFileThumbnail *self,
GFileInfo *info)
{
g_assert (GTK_IS_FILE_THUMBNAIL (self));
g_assert (info == NULL || G_IS_FILE_INFO (info));
if (g_set_object (&self->info, info))
{
cancel_thumbnail (self);
get_thumbnail (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INFO]);
}
}
-46
View File
@@ -1,46 +0,0 @@
/* gtkfilethumbnail.h
*
* Copyright 2022 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef __GTK_FILE_THUMBNAIL_H__
#define __GTK_FILE_THUMBNAIL_H__
#include <gio/gio.h>
#include "gtkfilesystemmodel.h"
G_BEGIN_DECLS
#define GTK_TYPE_FILE_THUMBNAIL (_gtk_file_thumbnail_get_type ())
#define GTK_FILE_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_THUMBNAIL, GtkFileThumbnail))
#define GTK_IS_FILE_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_THUMBNAIL))
typedef struct _GtkFileThumbnail GtkFileThumbnail;
GType _gtk_file_thumbnail_get_type (void) G_GNUC_CONST;
GFileInfo *_gtk_file_thumbnail_get_info (GtkFileThumbnail *self);
void _gtk_file_thumbnail_set_info (GtkFileThumbnail *self,
GFileInfo *info);
G_END_DECLS
#endif /* __GTK_FILE_THUMBNAIL_H__ */
+9 -3
View File
@@ -1870,7 +1870,9 @@ find_affected_text (GtkFontChooserWidget *fontchooser,
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
G_GNUC_END_IGNORE_DEPRECATIONS
if (hb_ot_layout_language_find_feature (hb_face,
HB_OT_TAG_GSUB,
@@ -2011,7 +2013,9 @@ update_feature_label (GtkFontChooserWidget *fontchooser,
hb_ot_layout_table_find_script (hb_face, HB_OT_TAG_GSUB, script_tag, &script_index);
hb_ot_layout_script_select_language (hb_face, HB_OT_TAG_GSUB, script_index, 1, &lang_tag, &lang_index);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
hb_ot_layout_script_find_language (hb_face, HB_OT_TAG_GSUB, script_index, lang_tag, &lang_index);
G_GNUC_END_IGNORE_DEPRECATIONS
if (hb_ot_layout_language_find_feature (hb_face, HB_OT_TAG_GSUB, script_index, lang_index, item->tag, &feature_index))
{
@@ -2561,7 +2565,9 @@ gtk_font_chooser_widget_update_font_features (GtkFontChooserWidget *fontchooser)
{
hb_ot_layout_table_find_script (hb_face, table[i], script_tag, &script_index);
hb_ot_layout_script_select_language (hb_face, table[i], script_index, 1, &lang_tag, &lang_index);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
hb_ot_layout_script_find_language (hb_face, table[i], script_index, lang_tag, &lang_index);
G_GNUC_END_IGNORE_DEPRECATIONS
feat = features + n_features;
count = G_N_ELEMENTS (features) - n_features;
-671
View File
@@ -1,671 +0,0 @@
/*
* 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 "gtkfontdialog.h"
#include "gtkfontchooserdialog.h"
#include "gtkbutton.h"
#include "gtktypebuiltins.h"
#include <glib/gi18n-lib.h>
/**
* GtkFontDialog:
*
* A `GtkFontDialog` object collects the arguments that
* are needed to present a font chooser dialog to the
* user, such as a title for the dialog and whether it
* should be modal.
*
* The dialog is shown with the [function@Gtk.FontDialog.choose_font]
* function. This API follows the GIO async pattern, and the
* result can be obtained by calling
* [function@Gtk.FontDialog.choose_font_finish].
*
* See [class@Gtk.FontDialogButton] for a convenient control
* that uses `GtkFontDialog` and presents the results.
*
* `GtkFontDialog was added in GTK 4.10.
*/
/* {{{ GObject implementation */
struct _GtkFontDialog
{
GObject parent_instance;
char *title;
GtkFontChooserLevel level;
PangoLanguage *language;
PangoFontMap *fontmap;
unsigned int modal : 1;
GtkFontFilterFunc filter;
gpointer filter_data;
GDestroyNotify filter_data_destroy;
};
enum
{
PROP_TITLE = 1,
PROP_MODAL,
PROP_LEVEL,
PROP_LANGUAGE,
PROP_FONTMAP,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkFontDialog, gtk_font_dialog, G_TYPE_OBJECT)
#define DEFAULT_LEVEL (GTK_FONT_CHOOSER_LEVEL_FAMILY| \
GTK_FONT_CHOOSER_LEVEL_STYLE| \
GTK_FONT_CHOOSER_LEVEL_SIZE)
static void
gtk_font_dialog_init (GtkFontDialog *self)
{
self->title = g_strdup (_("Pick a Font"));
self->modal = TRUE;
self->level = DEFAULT_LEVEL;
self->language = pango_language_get_default ();
}
static void
gtk_font_dialog_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkFontDialog *self = GTK_FONT_DIALOG (object);
switch (property_id)
{
case PROP_TITLE:
g_value_set_string (value, self->title);
break;
case PROP_MODAL:
g_value_set_boolean (value, self->modal);
break;
case PROP_LEVEL:
g_value_set_flags (value, self->level);
break;
case PROP_LANGUAGE:
g_value_set_boxed (value, self->language);
break;
case PROP_FONTMAP:
g_value_set_object (value, self->fontmap);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_font_dialog_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFontDialog *self = GTK_FONT_DIALOG (object);
switch (property_id)
{
case PROP_TITLE:
gtk_font_dialog_set_title (self, g_value_get_string (value));
break;
case PROP_MODAL:
gtk_font_dialog_set_modal (self, g_value_get_boolean (value));
break;
case PROP_LEVEL:
gtk_font_dialog_set_level (self, g_value_get_flags (value));
break;
case PROP_LANGUAGE:
gtk_font_dialog_set_language (self, g_value_get_boxed (value));
break;
case PROP_FONTMAP:
gtk_font_dialog_set_fontmap (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_font_dialog_finalize (GObject *object)
{
GtkFontDialog *self = GTK_FONT_DIALOG (object);
g_free (self->title);
g_clear_object (&self->fontmap);
g_clear_pointer (&self->filter_data, self->filter_data_destroy);
G_OBJECT_CLASS (gtk_font_dialog_parent_class)->finalize (object);
}
static void
gtk_font_dialog_class_init (GtkFontDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->get_property = gtk_font_dialog_get_property;
object_class->set_property = gtk_font_dialog_set_property;
object_class->finalize = gtk_font_dialog_finalize;
/**
* GtkFontDialog:title: (attributes org.gtk.Property.get=gtk_font_dialog_get_title org.gtk.Property.set=gtk_font_dialog_set_title)
*
* A title that may be shown on the font chooser
* dialog that is presented by [function@Gtk.FontDialog.choose_font].
*
* Since: 4.10
*/
properties[PROP_TITLE] =
g_param_spec_string ("title", NULL, NULL,
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialog:modal: (attributes org.gtk.Property.get=gtk_font_dialog_get_modal org.gtk.Property.set=gtk_font_dialog_set_modal)
*
* Whether the font chooser dialog is modal.
*
* Since: 4.10
*/
properties[PROP_MODAL] =
g_param_spec_boolean ("modal", NULL, NULL,
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialog:level: (attributes org.gtk.Property.get=gtk_font_dialog_get_level org.gtk.Property.set=gtk_font_dialog_set_level)
*
* The level of granularity to offer for selecting fonts.
*
* Since: 4.10
*/
properties[PROP_LEVEL] =
g_param_spec_flags ("level", NULL, NULL,
GTK_TYPE_FONT_CHOOSER_LEVEL,
DEFAULT_LEVEL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialog:language: (attributes org.gtk.Property.get=gtk_font_dialog_get_language org.gtk.Property.set=gtk_font_dialog_set_language)
*
* The language for which the font features are selected.
*
* Since: 4.10
*/
properties[PROP_LANGUAGE] =
g_param_spec_boxed ("language", NULL, NULL,
PANGO_TYPE_LANGUAGE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialog:fontmap: (attributes org.gtk.Property.get=gtk_font_dialog_get_fontmap org.gtk.Property.set=gtk_font_dialog_set_fontmap)
*
* Sets a custom font map to select fonts from.
*
* A custom font map can be used to present application-specific
* fonts instead of or in addition to the normal system fonts.
*
* Since: 4.10
*/
properties[PROP_FONTMAP] =
g_param_spec_object ("fontmap", NULL, NULL,
PANGO_TYPE_FONT_MAP,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
/* }}} */
/* {{{ Constructor */
/**
* gtk_font_dialog_new:
*
* Creates a new `GtkFontDialog` object.
*
* Returns: the new `GtkFontDialog`
*
* Since: 4.10
*/
GtkFontDialog *
gtk_font_dialog_new (void)
{
return g_object_new (GTK_TYPE_FONT_DIALOG, NULL);
}
/* }}} */
/* {{{ Getters and setters */
/**
* gtk_font_dialog_get_title:
* @self: a `GtkFontDialog`
*
* Returns the title that will be shown on the
* font chooser dialog.
*
* Returns: the title
*
* Since: 4.10
*/
const char *
gtk_font_dialog_get_title (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
return self->title;
}
/**
* gtk_font_dialog_set_title:
* @self: a `GtkFontDialog`
* @title: the new title
*
* Sets the title that will be shown on the
* font chooser dialog.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_title (GtkFontDialog *self,
const char *title)
{
char *new_title;
g_return_if_fail (GTK_IS_FONT_DIALOG (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]);
}
/**
* gtk_font_dialog_get_modal:
* @self: a `GtkFontDialog`
*
* Returns whether the font chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Returns: `TRUE` if the font chooser dialog is modal
*
* Since: 4.10
*/
gboolean
gtk_font_dialog_get_modal (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), TRUE);
return self->modal;
}
/**
* gtk_font_dialog_set_modal:
* @self: a `GtkFontDialog`
* @modal: the new value
*
* Sets whether the font chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_modal (GtkFontDialog *self,
gboolean modal)
{
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
if (self->modal == modal)
return;
self->modal = modal;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
}
/**
* gtk_font_dialog_get_level:
* @self: a `GtkFontDialog`
*
* Returns the level of granularity for selecting fonts.
*
* Returns: the level of granularity
*
* Since: 4.10
*/
GtkFontChooserLevel
gtk_font_dialog_get_level (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), DEFAULT_LEVEL);
return self->level;
}
/**
* gtk_font_dialog_set_level:
* @self: a `GtkFontDialog`
* @level: the new value
*
* Sets the level of granularity for selecting fonts.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_level (GtkFontDialog *self,
GtkFontChooserLevel level)
{
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
if (self->level == level)
return;
self->level = level;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LEVEL]);
}
/**
* gtk_font_dialog_get_language:
* @self: a `GtkFontDialog`
*
* Returns the language for which font features are applied.
*
* Returns: (nullable): the language for font features
*
* Since: 4.10
*/
PangoLanguage *
gtk_font_dialog_get_language (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
return self->language;
}
/**
* gtk_font_dialog_set_language:
* @self: a `GtkFontDialog`
* @language: the language for font features
*
* Sets the language for which font features are applied.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_language (GtkFontDialog *self,
PangoLanguage *language)
{
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
if (self->language == language)
return;
self->language = language;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LANGUAGE]);
}
/**
* gtk_font_dialog_get_fontmap
* @self: a `GtkFontDialog`
*
* Returns the fontmap from which fonts are selected,
* or `NULL` for the default fontmap.
*
* Returns: (nullable) (transfer none): the fontmap
*
* Since: 4.10
*/
PangoFontMap *
gtk_font_dialog_get_fontmap (GtkFontDialog *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG (self), NULL);
return self->fontmap;
}
/**
* gtk_font_dialog_set_fontmap:
* @self: a `GtkFontDialog`
* @fontmap: (nullable): the fontmap
*
* Sets the fontmap from which fonts are selected.
*
* If @fontmap is `NULL`, the default fontmap is used.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_fontmap (GtkFontDialog *self,
PangoFontMap *fontmap)
{
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
if (g_set_object (&self->fontmap, fontmap))
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONTMAP]);
}
/**
* gtk_font_dialog_set_filter:
* @self: a `GtkFontDialog`
* @filter: (nullable): a `GtkFontFilterFunc`
* @user_data: (closure): data to pass to @filter
* @destroy: function to call to free @data when it is no longer needed
*
* Adds a filter function that decides which fonts to display
* in the font chooser dialog.
*
* Since: 4.10
*/
void
gtk_font_dialog_set_filter (GtkFontDialog *self,
GtkFontFilterFunc filter,
gpointer filter_data,
GDestroyNotify filter_data_destroy)
{
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
g_clear_pointer (&self->filter_data, self->filter_data_destroy);
self->filter = filter;
self->filter_data = filter_data;
self->filter_data_destroy = filter_data_destroy;
}
/* }}} */
/* {{{ Async API */
static void response_cb (GTask *task,
int response);
static void
cancelled_cb (GCancellable *cancellable,
GTask *task)
{
response_cb (task, GTK_RESPONSE_CANCEL);
}
typedef struct
{
PangoFontDescription *font_desc;
char *font_features;
} FontResult;
static void
response_cb (GTask *task,
int response)
{
GCancellable *cancellable;
cancellable = g_task_get_cancellable (task);
if (cancellable)
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
if (response == GTK_RESPONSE_OK)
{
GtkFontChooserDialog *window;
FontResult font_result;
window = GTK_FONT_CHOOSER_DIALOG (g_task_get_task_data (task));
font_result.font_desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (window));
font_result.font_features = gtk_font_chooser_get_font_features (GTK_FONT_CHOOSER (window));
g_task_return_pointer (task, &font_result, NULL);
}
else
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
g_object_unref (task);
}
static void
dialog_response (GtkDialog *dialog,
int response,
GTask *task)
{
response_cb (task, response);
}
/**
* gtk_font_dialog_choose_font:
* @self: a `GtkFontDialog`
* @parent: (nullable): the parent `GtkWindow`
* @initial_font: (nullable): the font to select initially
* @cancellable: (nullable): a `GCancellable` to cancel the operation
* @callback: (scope async): a callback to call when the operation is complete
* @user_data: (closure callback): data to pass to @callback
*
* This function initiates a font selection operation by
* presenting a font chooser dialog to the user.
*
* The @callback will be called when the dialog is dismissed.
* It should call [function@Gtk.FontDialog.choose_font_finish]
* to obtain the result.
*
* Since: 4.10
*/
void
gtk_font_dialog_choose_font (GtkFontDialog *self,
GtkWindow *parent,
PangoFontDescription *initial_font,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkFontChooserDialog *window;
GTask *task;
g_return_if_fail (GTK_IS_FONT_DIALOG (self));
window = GTK_FONT_CHOOSER_DIALOG (gtk_font_chooser_dialog_new (self->title, parent));
gtk_font_chooser_set_level (GTK_FONT_CHOOSER (window), self->level);
if (self->language)
gtk_font_chooser_set_language (GTK_FONT_CHOOSER (window), pango_language_to_string (self->language));
if (self->fontmap)
gtk_font_chooser_set_font_map (GTK_FONT_CHOOSER (window), self->fontmap);
if (initial_font)
gtk_font_chooser_set_font_desc (GTK_FONT_CHOOSER (window), initial_font);
if (self->filter)
gtk_font_chooser_set_filter_func (GTK_FONT_CHOOSER (window),
self->filter,
self->filter_data,
self->filter_data_destroy);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_font_dialog_choose_font);
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
gtk_window_present (GTK_WINDOW (window));
}
/**
* gtk_font_dialog_choose_font_finish:
* @self: a `GtkFontDialog`
* @result: a `GAsyncResult`
* @font_desc: (out caller-allocates): return location for font description
* @font_features: (out caller-allocates): return location for font features
* @error: return location for an error
*
* Finishes the [function@Gtk.FontDialog.choose_font] call and
* returns the resulting font description and font features.
*
* Returns: `TRUE` if a font was selected. Otherwise,
* `FALSE` is returned and @error is set
*
* Since: 4.10
*/
gboolean
gtk_font_dialog_choose_font_finish (GtkFontDialog *self,
GAsyncResult *result,
PangoFontDescription **font_desc,
char **font_features,
GError **error)
{
FontResult *font_result;
font_result = g_task_propagate_pointer (G_TASK (result), error);
if (font_result)
{
*font_desc = font_result->font_desc;
*font_features = font_result->font_features;
return TRUE;
}
return FALSE;
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-97
View File
@@ -1,97 +0,0 @@
/* 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>
#include <gtk/gtkfontchooser.h>
G_BEGIN_DECLS
#define GTK_TYPE_FONT_DIALOG (gtk_font_dialog_get_type ())
GDK_AVAILABLE_IN_4_10
G_DECLARE_FINAL_TYPE (GtkFontDialog, gtk_font_dialog, GTK, FONT_DIALOG, GObject)
GDK_AVAILABLE_IN_4_10
GtkFontDialog * gtk_font_dialog_new (void);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_title (GtkFontDialog *self,
const char *title);
GDK_AVAILABLE_IN_4_10
gboolean gtk_font_dialog_get_modal (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_modal (GtkFontDialog *self,
gboolean modal);
GDK_AVAILABLE_IN_4_10
const char * gtk_font_dialog_get_title (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_level (GtkFontDialog *self,
GtkFontChooserLevel level);
GDK_AVAILABLE_IN_4_10
GtkFontChooserLevel
gtk_font_dialog_get_level (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_language (GtkFontDialog *self,
PangoLanguage *language);
GDK_AVAILABLE_IN_4_10
PangoLanguage * gtk_font_dialog_get_language (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
PangoFontMap * gtk_font_dialog_get_fontmap (GtkFontDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_fontmap (GtkFontDialog *self,
PangoFontMap *fontmap);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_set_filter (GtkFontDialog *self,
GtkFontFilterFunc filter,
gpointer user_data,
GDestroyNotify destroy);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_choose_font (GtkFontDialog *self,
GtkWindow *parent,
PangoFontDescription *initial_font,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDK_AVAILABLE_IN_4_10
gboolean gtk_font_dialog_choose_font_finish
(GtkFontDialog *self,
GAsyncResult *result,
PangoFontDescription **font_desc,
char **font_features,
GError **error);
G_END_DECLS
-778
View File
@@ -1,778 +0,0 @@
/*
* 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 "gtkfontdialogbutton.h"
#include "gtkbinlayout.h"
#include "gtkbox.h"
#include "gtkseparator.h"
#include "gtkbutton.h"
#include "gtklabel.h"
#include <glib/gi18n-lib.h>
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkwidgetprivate.h"
static void button_clicked (GtkFontDialogButton *self);
/**
* GtkFontDialogButton:
*
* The `GtkFontDialogButton` is wrapped around a [class@Gtk.FontDialog]
* and allows to open a font chooser dialog to change the font.
*
* ![An example GtkFontDialogButton](font-button.png)
*
* It is suitable widget for selecting a font in a preference dialog.
*
* # CSS nodes
*
* ```
* fontbutton
* button.font
* [content]
* ```
*
* `GtkFontDialogButton` has a single CSS node with name fontbutton which
* contains a button node with the .font style class.
*/
/* {{{ GObject implementation */
struct _GtkFontDialogButton
{
GtkWidget parent_instance;
GtkWidget *button;
GtkWidget *font_label;
GtkWidget *size_label;
GtkWidget *font_size_box;
guint use_font : 1;
guint use_size : 1;
GtkFontDialog *dialog;
PangoFontDescription *font_desc;
char *font_features;
PangoFontFamily *font_family;
PangoFontFace *font_face;
};
/* Properties */
enum
{
PROP_DIALOG = 1,
PROP_FONT_DESC,
PROP_FONT_FEATURES,
PROP_USE_FONT,
PROP_USE_SIZE,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkFontDialogButton, gtk_font_dialog_button, GTK_TYPE_WIDGET)
static void
gtk_font_dialog_button_init (GtkFontDialogButton *self)
{
GtkWidget *box;
PangoFontDescription *font_desc;
self->button = gtk_button_new ();
g_signal_connect_swapped (self->button, "clicked", G_CALLBACK (button_clicked), self);
self->font_label = gtk_label_new (_("Font"));
gtk_widget_set_hexpand (self->font_label, TRUE);
self->size_label = gtk_label_new ("14");
self->font_size_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_append (GTK_BOX (box), self->font_label);
gtk_box_append (GTK_BOX (self->font_size_box), gtk_separator_new (GTK_ORIENTATION_VERTICAL));
gtk_box_append (GTK_BOX (self->font_size_box), self->size_label);
gtk_box_append (GTK_BOX (box), self->font_size_box);
gtk_button_set_child (GTK_BUTTON (self->button), box);
gtk_widget_set_parent (self->button, GTK_WIDGET (self));
self->use_font = FALSE;
self->use_size = FALSE;
font_desc = pango_font_description_from_string ("Sans 12");
gtk_font_dialog_button_set_font_desc (self, font_desc);
pango_font_description_free (font_desc);
gtk_widget_add_css_class (self->button, "font");
}
static void
gtk_font_dialog_button_set_property (GObject *object,
unsigned int param_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFontDialogButton *self = GTK_FONT_DIALOG_BUTTON (object);
switch (param_id)
{
case PROP_DIALOG:
gtk_font_dialog_button_set_dialog (self, g_value_get_object (value));
break;
case PROP_FONT_DESC:
gtk_font_dialog_button_set_font_desc (self, g_value_get_boxed (value));
break;
case PROP_FONT_FEATURES:
gtk_font_dialog_button_set_font_features (self, g_value_get_string (value));
break;
case PROP_USE_FONT:
gtk_font_dialog_button_set_use_font (self, g_value_get_boolean (value));
break;
case PROP_USE_SIZE:
gtk_font_dialog_button_set_use_size (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
gtk_font_dialog_button_get_property (GObject *object,
unsigned int param_id,
GValue *value,
GParamSpec *pspec)
{
GtkFontDialogButton *self = GTK_FONT_DIALOG_BUTTON (object);
switch (param_id)
{
case PROP_DIALOG:
g_value_set_object (value, self->dialog);
break;
case PROP_FONT_DESC:
g_value_set_boxed (value, self->font_desc);
break;
case PROP_FONT_FEATURES:
g_value_set_string (value, self->font_features);
break;
case PROP_USE_FONT:
g_value_set_boolean (value, self->use_font);
break;
case PROP_USE_SIZE:
g_value_set_boolean (value, self->use_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
gtk_font_dialog_button_dispose (GObject *object)
{
GtkFontDialogButton *self = GTK_FONT_DIALOG_BUTTON (object);
g_clear_pointer (&self->button, gtk_widget_unparent);
G_OBJECT_CLASS (gtk_font_dialog_button_parent_class)->dispose (object);
}
static void
gtk_font_dialog_button_finalize (GObject *object)
{
GtkFontDialogButton *self = GTK_FONT_DIALOG_BUTTON (object);
g_clear_object (&self->dialog);
pango_font_description_free (self->font_desc);
g_clear_object (&self->font_family);
g_clear_object (&self->font_face);
g_free (self->font_features);
G_OBJECT_CLASS (gtk_font_dialog_button_parent_class)->finalize (object);
}
static void
gtk_font_dialog_button_class_init (GtkFontDialogButtonClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->get_property = gtk_font_dialog_button_get_property;
object_class->set_property = gtk_font_dialog_button_set_property;
object_class->dispose = gtk_font_dialog_button_dispose;
object_class->finalize = gtk_font_dialog_button_finalize;
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->focus = gtk_widget_focus_child;
/**
* GtkFontDialogButton:dialog: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_dialog org.gtk.Property.set=gtk_font_dialog_button_set_dialog)
*
* The `GtkFontDialog` that contains parameters for
* the font chooser dialog.
*
* Since: 4.10
*/
properties[PROP_DIALOG] =
g_param_spec_object ("dialog", NULL, NULL,
GTK_TYPE_FONT_DIALOG,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:font-desc: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_font_desc org.gtk.Property.set=gtk_font_dialog_button_set_font_desc)
*
* The selected font.
*
* This property can be set to give the button its initial
* font, and it will be updated to reflect the users choice
* in the font chooser dialog.
*
* Listen to `notify::font-desc` to get informed about changes
* to the buttons font.
*
* Since: 4.10
*/
properties[PROP_FONT_DESC] =
g_param_spec_boxed ("font-desc", NULL, NULL,
PANGO_TYPE_FONT_DESCRIPTION,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:font-features: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_font_features org.gtk.Property.set=gtk_font_dialog_button_set_font_features)
*
* The selected font features.
*
* This property will be updated to reflect the users choice
* in the font chooser dialog.
*
* Listen to `notify::font-features` to get informed about changes
* to the buttons font features.
*
* Since: 4.10
*/
properties[PROP_FONT_FEATURES] =
g_param_spec_string ("font-features", NULL, NULL,
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:use-font: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_use_font org.gtk.Property.set=gtk_font_dialog_button_set_use_font)
*
* Whether the buttons label will be drawn in the selected font.
*/
properties[PROP_USE_FONT] =
g_param_spec_boolean ("use-font", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFontDialogButton:use-size: (attributes org.gtk.Property.get=gtk_font_dialog_button_get_use_size org.gtk.Property.set=gtk_font_dialog_button_set_use_size)
*
* Whether the buttons label will use the selected font size.
*/
properties[PROP_USE_SIZE] =
g_param_spec_boolean ("use-size", NULL, NULL,
FALSE,
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
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, "fontbutton");
}
/* }}} */
/* {{{ Private API, callbacks */
static void
font_chosen (GObject *source,
GAsyncResult *result,
gpointer data)
{
GtkFontDialogButton *self = data;
PangoFontDescription *desc;
char *features;
GError *error = NULL;
if (gtk_font_dialog_choose_font_finish (self->dialog, result, &desc, &features, &error))
{
gtk_font_dialog_button_set_font_desc (self, desc);
gtk_font_dialog_button_set_font_features (self, features);
}
else
{
g_print ("%s\n", error->message);
g_error_free (error);
}
}
static void
button_clicked (GtkFontDialogButton *self)
{
GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (self));
GtkWindow *parent = NULL;
if (GTK_IS_WINDOW (root))
parent = GTK_WINDOW (root);
gtk_font_dialog_choose_font (self->dialog, parent, self->font_desc,
NULL, font_chosen, self);
}
static gboolean
font_description_style_equal (const PangoFontDescription *a,
const PangoFontDescription *b)
{
return (pango_font_description_get_weight (a) == pango_font_description_get_weight (b) &&
pango_font_description_get_style (a) == pango_font_description_get_style (b) &&
pango_font_description_get_stretch (a) == pango_font_description_get_stretch (b) &&
pango_font_description_get_variant (a) == pango_font_description_get_variant (b));
}
static void
update_font_data (GtkFontDialogButton *self)
{
PangoFontMap *fontmap = NULL;
const char *family_name;
g_assert (self->font_desc != NULL);
g_clear_object (&self->font_family);
g_clear_object (&self->font_face);
family_name = pango_font_description_get_family (self->font_desc);
if (family_name == NULL)
return;
if (self->dialog)
fontmap = gtk_font_dialog_get_fontmap (self->dialog);
if (!fontmap)
fontmap = pango_cairo_font_map_get_default ();
for (unsigned int i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (fontmap)); i++)
{
PangoFontFamily *family = g_list_model_get_item (G_LIST_MODEL (fontmap), i);
const char *name = pango_font_family_get_name (family);
g_object_unref (family);
if (g_ascii_strcasecmp (name, family_name) == 0)
{
g_set_object (&self->font_family, family);
break;
}
}
for (unsigned i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (self->font_family)); i++)
{
PangoFontFace *face = g_list_model_get_item (G_LIST_MODEL (self->font_family), i);
PangoFontDescription *tmp_desc = pango_font_face_describe (face);
g_object_unref (face);
if (font_description_style_equal (tmp_desc, self->font_desc))
{
g_set_object (&self->font_face, face);
pango_font_description_free (tmp_desc);
break;
}
else
pango_font_description_free (tmp_desc);
}
}
static void
update_font_info (GtkFontDialogButton *self)
{
const char *fam_name;
const char *face_name;
char *family_style;
GtkFontChooserLevel level;
if (self->font_family)
fam_name = pango_font_family_get_name (self->font_family);
else
fam_name = C_("font", "None");
if (self->font_face)
face_name = pango_font_face_get_face_name (self->font_face);
else
face_name = "";
if (self->dialog)
level = gtk_font_dialog_get_level (self->dialog);
else
level = GTK_FONT_CHOOSER_LEVEL_STYLE|GTK_FONT_CHOOSER_LEVEL_SIZE;
if ((level & GTK_FONT_CHOOSER_LEVEL_STYLE) != 0)
family_style = g_strconcat (fam_name, " ", face_name, NULL);
else
family_style = g_strdup (fam_name);
gtk_label_set_text (GTK_LABEL (self->font_label), family_style);
g_free (family_style);
if ((level & GTK_FONT_CHOOSER_LEVEL_SIZE) != 0)
{
/* mirror Pango, which doesn't translate this either */
char *size = g_strdup_printf ("%2.4g%s",
pango_font_description_get_size (self->font_desc) / (double)PANGO_SCALE,
pango_font_description_get_size_is_absolute (self->font_desc) ? "px" : "");
gtk_label_set_text (GTK_LABEL (self->size_label), size);
g_free (size);
gtk_widget_show (self->font_size_box);
}
else
gtk_widget_hide (self->font_size_box);
}
static void
apply_use_font (GtkFontDialogButton *self)
{
if (!self->use_font)
gtk_label_set_attributes (GTK_LABEL (self->font_label), NULL);
else
{
PangoFontDescription *desc;
PangoAttrList *attrs;
PangoLanguage *language = NULL;
desc = pango_font_description_copy (self->font_desc);
if (!self->use_size)
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
attrs = pango_attr_list_new ();
/* Prevent font fallback */
pango_attr_list_insert (attrs, pango_attr_fallback_new (FALSE));
/* Force current font and features */
pango_attr_list_insert (attrs, pango_attr_font_desc_new (desc));
if (self->font_features)
pango_attr_list_insert (attrs, pango_attr_font_features_new (self->font_features));
if (self->dialog)
language = gtk_font_dialog_get_language (self->dialog);
if (language)
pango_attr_list_insert (attrs, pango_attr_language_new (language));
gtk_label_set_attributes (GTK_LABEL (self->font_label), attrs);
pango_attr_list_unref (attrs);
pango_font_description_free (desc);
}
}
/* }}} */
/* {{{ Public API */
/* {{{ Constructor */
/**
* gtk_font_dialog_button_new:
* @dialog: (nullable) (transfer full): the `GtkFontDialog` to use
*
* Creates a new `GtkFontDialogButton` with the
* given `GtkFontDialog`.
*
* You can pass `NULL` to this function and set a `GtkFontDialog`
* later. The button will be insensitive until that happens.
*
* Returns: the new `GtkFontDialogButton`
*
* Since: 4.10
*/
GtkWidget *
gtk_font_dialog_button_new (GtkFontDialog *dialog)
{
GtkWidget *self;
g_return_val_if_fail (GTK_IS_FONT_DIALOG (dialog), NULL);
self = g_object_new (GTK_TYPE_FONT_DIALOG_BUTTON,
"dialog", dialog,
NULL);
g_clear_object (&dialog);
return self;
}
/* }}} */
/* {{{ Setters and Getters */
/**
* gtk_font_dialog_button_set_dialog:
* @self: a `GtkFontDialogButton`
* @dialog: the new `GtkFontDialog`
*
* Sets a `GtkFontDialog` object to use for
* creating the font chooser dialog that is
* presented when the user clicks the button.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_dialog (GtkFontDialogButton *self,
GtkFontDialog *dialog)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
g_return_if_fail (dialog == NULL || GTK_IS_FONT_DIALOG (dialog));
if (!g_set_object (&self->dialog, dialog))
return;
gtk_widget_set_sensitive (self->button, dialog != NULL);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DIALOG]);
}
/**
* gtk_font_dialog_button_get_dialog:
* @self: a `GtkFontDialogButton`
*
* Returns the `GtkFontDialog` of @self.
*
* Returns: (nullable) (transfer none): the `GtkFontDialog`
*
* Since: 4.10
*/
GtkFontDialog *
gtk_font_dialog_button_get_dialog (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), NULL);
return self->dialog;
}
/**
* gtk_font_dialog_button_set_font_desc:
* @self: a `GtkFontDialogButton`
* @font_desc: the new font
*
* Sets the font of the button.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_font_desc (GtkFontDialogButton *self,
PangoFontDescription *font_desc)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
g_return_if_fail (font_desc != NULL);
if (self->font_desc == font_desc ||
(self->font_desc && font_desc &&
pango_font_description_equal (self->font_desc, font_desc)))
return;
if (self->font_desc)
pango_font_description_free (self->font_desc);
self->font_desc = pango_font_description_copy (font_desc);
update_font_data (self);
update_font_info (self);
apply_use_font (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONT_DESC]);
}
/**
* gtk_font_dialog_button_get_font_desc:
* @self: a `GtkFontDialogButton`
*
* Returns the font of the button.
*
* This function is what should be used to obtain
* the font that was choosen by the user. To get
* informed about changes, listen to "notify::font-desc".
*
* Returns: (transfer none) (nullable): the font
*
* Since: 4.10
*/
PangoFontDescription *
gtk_font_dialog_button_get_font_desc (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), NULL);
return self->font_desc;
}
/**
* gtk_font_dialog_button_set_font_features:
* @self: a `GtkFontDialogButton`
* @font_features: (nullable): the font features
*
* Sets the font features of the button.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_font_features (GtkFontDialogButton *self,
const char *font_features)
{
char *new_features;
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
if (g_strcmp0 (self->font_features, font_features) == 0)
return;
new_features = g_strdup (font_features);
g_free (self->font_features);
self->font_features = new_features;
apply_use_font (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FONT_FEATURES]);
}
/**
* gtk_font_dialog_button_get_font_features:
* @self: a `GtkFontDialogButton`
*
* Returns the font features of the button.
*
* This function is what should be used to obtain
* the font features that were choosen by the user.
* To get informed about changes, listen to
* "notify::font-features".
*
* Returns: (transfer none) (nullable): the font features
*
* Since: 4.10
*/
const char *
gtk_font_dialog_button_get_font_features (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), NULL);
return self->font_features;
}
/**
* gtk_font_dialog_button_set_use_font:
* @self: a `GtkFontDialogButton`
* @use_font: If `TRUE`, font name will be written using
* the chosen font
*
* If @use_font is `TRUE`, the font name will be written
* using the selected font.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_use_font (GtkFontDialogButton *self,
gboolean use_font)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
if (self->use_font == use_font)
return;
self->use_font = use_font;
apply_use_font (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USE_FONT]);
}
/**
* gtk_font_dialog_button_get_use_font:
* @self: a `GtkFontDialogButton`
*
* Returns whether the selected font is used in the label.
*
* Returns: whether the selected font is used in the label
*
* Since: 4.10
*/
gboolean
gtk_font_dialog_button_get_use_font (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), FALSE);
return self->use_font;
}
/**
* gtk_font_dialog_button_set_use_size:
* @self: a `GtkFontDialogButton`
* @use_size: If `TRUE`, font name will be written using
* the chosen font size
*
* If @use_size is `TRUE`, the font name will be written
* using the selected font size.
*
* Since: 4.10
*/
void
gtk_font_dialog_button_set_use_size (GtkFontDialogButton *self,
gboolean use_size)
{
g_return_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self));
if (self->use_size == use_size)
return;
self->use_size = use_size;
apply_use_font (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_USE_SIZE]);
}
/**
* gtk_font_dialog_button_get_use_size:
* @self: a `GtkFontDialogButton`
*
* Returns whether the selected font size is used in the label.
*
* Returns: whether the selected font size is used in the label
*
* Since: 4.10
*/
gboolean
gtk_font_dialog_button_get_use_size (GtkFontDialogButton *self)
{
g_return_val_if_fail (GTK_IS_FONT_DIALOG_BUTTON (self), FALSE);
return self->use_size;
}
/* }}} */
/* }}} */
/* vim:set foldmethod=marker expandtab: */
-76
View File
@@ -1,76 +0,0 @@
/*
* 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/gtkbutton.h>
#include <gtk/gtkfontdialog.h>
G_BEGIN_DECLS
#define GTK_TYPE_FONT_DIALOG_BUTTON (gtk_font_dialog_button_get_type ())
GDK_AVAILABLE_IN_4_10
G_DECLARE_FINAL_TYPE (GtkFontDialogButton, gtk_font_dialog_button, GTK, FONT_DIALOG_BUTTON, GtkWidget)
GDK_AVAILABLE_IN_4_10
GtkWidget * gtk_font_dialog_button_new (GtkFontDialog *dialog);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_button_set_dialog (GtkFontDialogButton *self,
GtkFontDialog *dialog);
GDK_AVAILABLE_IN_4_10
GtkFontDialog * gtk_font_dialog_button_get_dialog (GtkFontDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_button_set_font_desc (GtkFontDialogButton *self,
PangoFontDescription *font_desc);
GDK_AVAILABLE_IN_4_10
PangoFontDescription *
gtk_font_dialog_button_get_font_desc (GtkFontDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_button_set_font_features
(GtkFontDialogButton *self,
const char *font_features);
GDK_AVAILABLE_IN_4_10
const char * gtk_font_dialog_button_get_font_features (GtkFontDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_button_set_use_font (GtkFontDialogButton *self,
gboolean use_font);
GDK_AVAILABLE_IN_4_10
gboolean gtk_font_dialog_button_get_use_font (GtkFontDialogButton *self);
GDK_AVAILABLE_IN_4_10
void gtk_font_dialog_button_set_use_size (GtkFontDialogButton *self,
gboolean use_size);
GDK_AVAILABLE_IN_4_10
gboolean gtk_font_dialog_button_get_use_size (GtkFontDialogButton *self);
G_END_DECLS
+17 -4
View File
@@ -46,9 +46,8 @@
* `GtkIMContextSimple` reads compose sequences from the first of the
* following files that is found: ~/.config/gtk-4.0/Compose, ~/.XCompose,
* /usr/share/X11/locale/$locale/Compose (for locales that have a nontrivial
* Compose file). A subset of the file syntax described in the Compose(5)
* manual page is supported. Additionally, `include "%L"` loads GTKs built-in
* table of compose sequences rather than the locale-specific one from X11.
* Compose file). The syntax of these files is described in the Compose(5)
* manual page.
*
* If none of these files is found, `GtkIMContextSimple` uses a built-in table
* of compose sequences that is derived from the X11 Compose files.
@@ -181,6 +180,20 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class)
init_compose_table_async (NULL, NULL, NULL);
}
static char *
get_x11_compose_file_dir (void)
{
char * compose_file_dir;
#if defined (X11_DATA_PREFIX)
compose_file_dir = g_strdup (X11_DATA_PREFIX "/share/X11/locale");
#else
compose_file_dir = g_build_filename (_gtk_get_datadir (), "X11", "locale", NULL);
#endif
return compose_file_dir;
}
static int
gtk_compose_table_find (gconstpointer data1,
gconstpointer data2)
@@ -308,7 +321,7 @@ gtk_im_context_simple_init_compose_table (void)
{
if (g_ascii_strncasecmp (*lang, *sys_lang, strlen (*sys_lang)) == 0)
{
char *x11_compose_file_dir = gtk_compose_table_get_x11_compose_file_dir ();
char *x11_compose_file_dir = get_x11_compose_file_dir ();
path = g_build_filename (x11_compose_file_dir, *lang, "Compose", NULL);
g_free (x11_compose_file_dir);
break;
-715
View File
@@ -1,715 +0,0 @@
/*
* 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 "gtkinfodialog.h"
#include "gtkbutton.h"
#include "gtkmessagedialog.h"
#include <glib/gi18n-lib.h>
/**
* GtkInfoDialog:
*
* A `GtkInfoDialog` object collects the arguments that
* are needed to present a info chooser dialog to the
* user, such as a title for the dialog and whether it
* should be modal.
*
* The dialog is shown with the [function@Gtk.InfoDialog.present]
* function. This API follows the GIO async pattern, and the
* result can be obtained by calling
* [function@Gtk.InfoDialog.present_finish].
*
* `GtkInfoDialog was added in GTK 4.10.
*/
/* {{{ GObject implementation */
struct _GtkInfoDialog
{
GObject parent_instance;
char *heading;
char *body;
char **buttons;
unsigned int modal : 1;
unsigned int heading_use_markup: 1;
unsigned int body_use_markup: 1;
};
enum
{
PROP_MODAL = 1,
PROP_HEADING,
PROP_HEADING_USE_MARKUP,
PROP_BODY,
PROP_BODY_USE_MARKUP,
PROP_BUTTONS,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES];
G_DEFINE_TYPE (GtkInfoDialog, gtk_info_dialog, G_TYPE_OBJECT)
static void
gtk_info_dialog_init (GtkInfoDialog *self)
{
self->modal = TRUE;
}
static void
gtk_info_dialog_finalize (GObject *object)
{
GtkInfoDialog *self = GTK_INFO_DIALOG (object);
g_free (self->heading);
g_free (self->body);
g_strfreev (self->buttons);
G_OBJECT_CLASS (gtk_info_dialog_parent_class)->finalize (object);
}
static void
gtk_info_dialog_get_property (GObject *object,
unsigned int property_id,
GValue *value,
GParamSpec *pspec)
{
GtkInfoDialog *self = GTK_INFO_DIALOG (object);
switch (property_id)
{
case PROP_MODAL:
g_value_set_boolean (value, self->modal);
break;
case PROP_HEADING:
g_value_set_string (value, self->heading);
break;
case PROP_HEADING_USE_MARKUP:
g_value_set_boolean (value, self->heading_use_markup);
break;
case PROP_BODY:
g_value_set_string (value, self->body);
break;
case PROP_BODY_USE_MARKUP:
g_value_set_boolean (value, self->body_use_markup);
break;
case PROP_BUTTONS:
g_value_set_boxed (value, self->buttons);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_info_dialog_set_property (GObject *object,
unsigned int prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkInfoDialog *self = GTK_INFO_DIALOG (object);
switch (prop_id)
{
case PROP_MODAL:
gtk_info_dialog_set_modal (self, g_value_get_boolean (value));
break;
case PROP_HEADING:
gtk_info_dialog_set_heading (self, g_value_get_string (value));
break;
case PROP_HEADING_USE_MARKUP:
gtk_info_dialog_set_heading_use_markup (self, g_value_get_boolean (value));
break;
case PROP_BODY:
gtk_info_dialog_set_body (self, g_value_get_string (value));
break;
case PROP_BODY_USE_MARKUP:
gtk_info_dialog_set_body_use_markup (self, g_value_get_boolean (value));
break;
case PROP_BUTTONS:
gtk_info_dialog_set_buttons (self, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_info_dialog_class_init (GtkInfoDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->finalize = gtk_info_dialog_finalize;
object_class->get_property = gtk_info_dialog_get_property;
object_class->set_property = gtk_info_dialog_set_property;
/**
* GtkInfoDialog:modal: (attributes org.gtk.Property.get=gtk_info_dialog_get_modal org.gtk.Property.set=gtk_color_dialog_set_modal)
*
* Whether the info chooser dialog is modal.
*
* Since: 4.10
*/
properties[PROP_MODAL] =
g_param_spec_boolean ("modal", NULL, NULL,
TRUE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkInfoDialog:heading: (attributes org.gtk.Property.get=gtk_info_dialog_get_heading org.gtk.Property.set=gtk_color_dialog_set_heading)
*
* The heading for the dialog that is presented
* by [function@Gtk.InfoDialog.present].
*
* Since: 4.10
*/
properties[PROP_HEADING] =
g_param_spec_string ("heading", NULL, NULL,
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkInfoDialog:heading-use-markup: (attributes org.gtk.Property.get=gtk_info_dialog_get_heading_use_markup org.gtk.Property.set=gtk_color_dialog_set_heading_use_markup)
*
* Whether the heading uses markup.
*
* Since: 4.10
*/
properties[PROP_HEADING_USE_MARKUP] =
g_param_spec_boolean ("heading-use-markup", NULL, NULL,
FALSE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkInfoDialog:body: (attributes org.gtk.Property.get=gtk_info_dialog_get_body org.gtk.Property.set=gtk_color_dialog_set_body)
*
* The body text for the dialog that is presented
* by [function@Gtk.InfoDialog.present].
*
* Since: 4.10
*/
properties[PROP_BODY] =
g_param_spec_string ("body", NULL, NULL,
NULL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkInfoDialog:body-use-markup: (attributes org.gtk.Property.get=gtk_info_dialog_get_body_use_markup org.gtk.Property.set=gtk_color_dialog_set_body_use_markup)
*
* Whether the body text uses markup.
*
* Since: 4.10
*/
properties[PROP_BODY_USE_MARKUP] =
g_param_spec_boolean ("body-use-markup", NULL, NULL,
FALSE,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkInfoDialog:buttons: (attributes org.gtk.Property.get=gtk_info_dialog_get_buttons org.gtk.Property.set=gtk_color_dialog_set_buttons)
*
* The labels for buttons to show in the dialog that is presented
* by [function@Gtk.InfoDialog.present].
*
* The labels should be translated and may contain a _ to indicate
* mnemonic characters.
*
* Since: 4.10
*/
properties[PROP_BUTTONS] =
g_param_spec_boxed ("buttons", NULL, NULL,
G_TYPE_STRV,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
}
/* }}} */
/* {{{ Constructor */
/**
* gtk_info_dialog_new:
*
* Creates a new `GtkInfoDialog` object.
*
* Returns: the new `GtkInfoDialog`
*
* Since: 4.10
*/
GtkInfoDialog *
gtk_info_dialog_new (void)
{
return g_object_new (GTK_TYPE_INFO_DIALOG, NULL);
}
/* }}} */
/* {{{ Getters and setters */
/**
* gtk_info_dialog_get_modal:
* @self: a `GtkInfoDialog`
*
* Returns whether the info chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Returns: `TRUE` if the info chooser dialog is modal
*
* Since: 4.10
*/
gboolean
gtk_info_dialog_get_modal (GtkInfoDialog *self)
{
g_return_val_if_fail (GTK_IS_INFO_DIALOG (self), TRUE);
return self->modal;
}
/**
* gtk_info_dialog_set_modal:
* @self: a `GtkInfoDialog`
* @modal: the new value
*
* Sets whether the info chooser dialog
* blocks interaction with the parent window
* while it is presented.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_modal (GtkInfoDialog *self,
gboolean modal)
{
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
if (self->modal == modal)
return;
self->modal = modal;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODAL]);
}
/**
* gtk_info_dialog_get_heading:
* @self: a `GtkInfoDialog`
*
* Returns the heading that will be shown in the
* info dialog.
*
* Returns: the heading
*
* Since: 4.10
*/
const char *
gtk_info_dialog_get_heading (GtkInfoDialog *self)
{
g_return_val_if_fail (GTK_IS_INFO_DIALOG (self), NULL);
return self->heading;
}
/**
* gtk_info_dialog_set_heading:
* @self: a `GtkInfoDialog`
* @text: the new heading
*
* Sets the heading that will be shown in the
* info dialog.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_heading (GtkInfoDialog *self,
const char *text)
{
char *new_text;
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
g_return_if_fail (text != NULL);
if (g_strcmp0 (self->heading, text) == 0)
return;
new_text = g_strdup (text);
g_free (self->heading);
self->heading = new_text;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADING]);
}
/**
* gtk_info_dialog_get_heading_use_markup:
* @self: a `GtkInfoDialog`
*
* Returns whether the heading uses markup.
*
* Returns: `TRUE` if the heading uses markup
*
* Since: 4.10
*/
gboolean
gtk_info_dialog_get_heading_use_markup (GtkInfoDialog *self)
{
g_return_val_if_fail (GTK_IS_INFO_DIALOG (self), FALSE);
return self->heading_use_markup;
}
/**
* gtk_info_dialog_set_heading_use_markup:
* @self: a `GtkInfoDialog`
* @use_markup: the new value
*
* Sets whether the heading uses markup.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_heading_use_markup (GtkInfoDialog *self,
gboolean use_markup)
{
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
if (self->heading_use_markup == use_markup)
return;
self->heading_use_markup = use_markup;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADING_USE_MARKUP]);
}
/**
* gtk_info_dialog_get_body:
* @self: a `GtkInfoDialog`
*
* Returns the body text that will be shown
* in the info dialog.
*
* Returns: the body text
*
* Since: 4.10
*/
const char *
gtk_info_dialog_get_body (GtkInfoDialog *self)
{
g_return_val_if_fail (GTK_IS_INFO_DIALOG (self), NULL);
return self->body;
}
/**
* gtk_info_dialog_set_body:
* @self: a `GtkInfoDialog`
* @text: the new text
*
* Sets the body text that will be shown
* in the info dialog.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_body (GtkInfoDialog *self,
const char *text)
{
char *new_text;
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
g_return_if_fail (text != NULL);
if (g_strcmp0 (self->body, text) == 0)
return;
new_text = g_strdup (text);
g_free (self->body);
self->body = new_text;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BODY]);
}
/**
* gtk_info_dialog_get_body_use_markup:
* @self: a `GtkInfoDialog`
*
* Returns whether the body text uses markup.
*
* Returns: `TRUE` if body text uses markup
*
* Since: 4.10
*/
gboolean
gtk_info_dialog_get_body_use_markup (GtkInfoDialog *self)
{
g_return_val_if_fail (GTK_IS_INFO_DIALOG (self), FALSE);
return self->body_use_markup;
}
/**
* gtk_info_dialog_set_body_use_markup:
* @self: a `GtkInfoDialog`
* @use_markup: the new value
*
* Sets whether the body text uses markup.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_body_use_markup (GtkInfoDialog *self,
gboolean use_markup)
{
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
if (self->body_use_markup == use_markup)
return;
self->body_use_markup = use_markup;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BODY_USE_MARKUP]);
}
/**
* gtk_info_dialog_get_buttons:
* @self: a `GtkInfoDialog`
*
* Returns the button labels for the info dialog.
*
* Returns: (nullable) (transfer none): the button labels
*
* Since: 4.10
*/
const char * const *
gtk_info_dialog_get_buttons (GtkInfoDialog *self)
{
g_return_val_if_fail (GTK_IS_INFO_DIALOG (self), NULL);
return (const char * const *) self->buttons;
}
/**
* gtk_info_dialog_set_buttons:
* @self: a `GtkInfoDialog`
* @labels: the new button labels
*
* Sets the button labels for the info dialog.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_buttons (GtkInfoDialog *self,
const char * const *labels)
{
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
g_return_if_fail (labels != NULL);
g_strfreev (self->buttons);
self->buttons = g_strdupv ((char **)labels);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_BUTTONS]);
}
/* }}} */
/* {{{ Convenience API */
/**
* gtk_info_dialog_set_heading_markup:
* @self: a `GtkInfoDialog`
* @text: the new heading
*
* Sets the heading that will be shown in the
* info dialog, and marks it as using markup.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_heading_markup (GtkInfoDialog *self,
const char *text)
{
g_object_freeze_notify (G_OBJECT (self));
gtk_info_dialog_set_heading (self, text);
gtk_info_dialog_set_heading_use_markup (self, TRUE);
g_object_thaw_notify (G_OBJECT (self));
}
/**
* gtk_info_dialog_set_body_markup:
* @self: a `GtkInfoDialog`
* @text: the new heading
*
* Sets the body text that will be shown in the
* info dialog, and marks it as using markup.
*
* Since: 4.10
*/
void
gtk_info_dialog_set_body_markup (GtkInfoDialog *self,
const char *text)
{
g_object_freeze_notify (G_OBJECT (self));
gtk_info_dialog_set_body (self, text);
gtk_info_dialog_set_body_use_markup (self, TRUE);
g_object_thaw_notify (G_OBJECT (self));
}
/* }}} */
/* {{{ Async API */
static void response_cb (GTask *task,
int response);
static void
cancelled_cb (GCancellable *cancellable,
GTask *task)
{
response_cb (task, -1);
}
static void
response_cb (GTask *task,
int response)
{
GCancellable *cancellable;
cancellable = g_task_get_cancellable (task);
if (cancellable)
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
if (response >= 0)
g_task_return_int (task, response);
else
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
g_object_unref (task);
}
static void
dialog_response (GtkDialog *dialog,
int response,
GTask *task)
{
response_cb (task, response);
}
/**
* gtk_info_dialog_present:
* @self: a `GtkInfoDialog`
* @parent: (nullable): the parent `GtkWindow`
* @cancellable: (nullable): a `GCancellable` to cancel the operation
* @callback: (scope async): a callback to call when the operation is complete
* @user_data: (closure callback): data to pass to @callback
*
* This function presents an info dialog to the user.
*
* The @callback will be called when the dialog is dismissed.
* It should call [function@Gtk.InfoDialog.present_finish]
* to obtain the result.
*
* Since: 4.10
*/
void
gtk_info_dialog_present (GtkInfoDialog *self,
GtkWindow *parent,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GtkMessageDialog *window;
GTask *task;
g_return_if_fail (GTK_IS_INFO_DIALOG (self));
window = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
"transient-for", parent,
"destroy-with-parent", TRUE,
"modal", self->modal,
"text", self->heading,
"use-markup", self->heading_use_markup,
"secondary-text", self->body,
"secondary-use-markup", self->body_use_markup,
NULL);
if (self->buttons)
{
for (int i = 0; self->buttons[i]; i++)
gtk_dialog_add_button (GTK_DIALOG (window), self->buttons[i], i);
}
else
gtk_dialog_add_button (GTK_DIALOG (window), _("Close"), 0);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_info_dialog_present);
g_task_set_task_data (task, window, (GDestroyNotify) gtk_window_destroy);
if (cancellable)
g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancelled_cb), task);
g_signal_connect (window, "response", G_CALLBACK (dialog_response), task);
gtk_window_present (GTK_WINDOW (window));
}
/**
* gtk_info_dialog_present_finish:
* @self: a `GtkInfoDialog`
* @result: a `GAsyncResult`
* @button: (out caller-allocates): return location for button
* @error: return location for an error
*
* Finishes the [function@Gtk.InfoDialog.present] call
* and returns the button that was clicked.
*
* Returns: `TRUE` if a button was clicked.
* Otherwise, `FALSE` is returned and @error is set
*
* Since: 4.10
*/
gboolean
gtk_info_dialog_present_finish (GtkInfoDialog *self,
GAsyncResult *result,
int *button,
GError **error)
{
*button = (int) g_task_propagate_int (G_TASK (result), error);
return ! (error && *error);
}
/* }}} */
/* vim:set foldmethod=marker expandtab: */

Some files were not shown because too many files have changed in this diff Show More