Compare commits
8 Commits
applicatio
...
sort-list-
Author | SHA1 | Date | |
---|---|---|---|
|
0b7f7028d9 | ||
|
5dba053ad1 | ||
|
cd8a810d69 | ||
|
8f63a5ab63 | ||
|
eb3381723f | ||
|
7e87ad1887 | ||
|
ef6babf896 | ||
|
7f9570b95b |
@@ -174,28 +174,25 @@ constraint_view_init (ConstraintView *self)
|
||||
manager = gtk_constraint_layout_new ();
|
||||
gtk_widget_set_layout_manager (GTK_WIDGET (self), manager);
|
||||
|
||||
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
|
||||
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
|
||||
guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager));
|
||||
|
||||
all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager));
|
||||
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
|
||||
constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
all_children = gtk_widget_observe_children (GTK_WIDGET (self));
|
||||
filter = gtk_custom_filter_new (omit_internal, NULL, NULL);
|
||||
children = (GListModel *)gtk_filter_list_model_new (all_children, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
g_list_store_append (list, children);
|
||||
g_list_store_append (list, guides);
|
||||
g_list_store_append (list, constraints);
|
||||
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||
g_object_unref (children);
|
||||
g_object_unref (guides);
|
||||
g_object_unref (constraints);
|
||||
g_object_unref (all_children);
|
||||
g_object_unref (all_constraints);
|
||||
g_object_unref (list);
|
||||
|
||||
self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||
|
||||
controller = (GtkEventController *)gtk_gesture_drag_new ();
|
||||
g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self);
|
||||
|
@@ -242,16 +242,11 @@ transform_settings_to_keys (GBinding *binding,
|
||||
g_object_unref (settings);
|
||||
|
||||
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (store),
|
||||
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data)));
|
||||
g_object_unref (store);
|
||||
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (data))));
|
||||
|
||||
filter = gtk_string_filter_new (gtk_property_expression_new (SETTINGS_TYPE_KEY, NULL, "name"));
|
||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
|
||||
g_object_unref (sort_model);
|
||||
|
||||
g_set_object (¤t_filter, filter);
|
||||
|
||||
g_object_unref (filter);
|
||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), filter);
|
||||
|
||||
selection_model = gtk_no_selection_new (G_LIST_MODEL (filter_model));
|
||||
g_object_unref (filter_model);
|
||||
|
@@ -1145,6 +1145,7 @@ activate (GApplication *app)
|
||||
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (treemodel), NULL);
|
||||
filter = gtk_custom_filter_new ((GtkCustomFilterFunc)demo_filter_by_name, filter_model, NULL);
|
||||
gtk_filter_list_model_set_filter (filter_model, filter);
|
||||
g_object_unref (filter);
|
||||
search_entry = GTK_WIDGET (gtk_builder_get_object (builder, "search-entry"));
|
||||
g_signal_connect (search_entry, "search-changed", G_CALLBACK (demo_search_changed_cb), filter);
|
||||
|
||||
|
@@ -76,7 +76,6 @@
|
||||
<xi:include href="xml/gtkmultiselection.xml" />
|
||||
</section>
|
||||
<xi:include href="xml/gtkselectionfiltermodel.xml" />
|
||||
<xi:include href="xml/gtkapplicationlist.xml" />
|
||||
<xi:include href="xml/gtkbookmarklist.xml" />
|
||||
<xi:include href="xml/gtkdirectorylist.xml" />
|
||||
<xi:include href="xml/gtkstringlist.xml" />
|
||||
|
@@ -7639,10 +7639,3 @@ gtk_selection_filter_model_new_for_type
|
||||
gtk_selection_filter_model_set_model
|
||||
gtk_selection_filter_model_get_model
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkapplicationlist</FILE>
|
||||
<TITLE>GtkApplicationList</TITLE>
|
||||
GtkApplicationList
|
||||
gtk_application_list_new
|
||||
</SECTION>
|
||||
|
@@ -13,7 +13,6 @@ gtk_app_chooser_button_get_type
|
||||
gtk_app_chooser_dialog_get_type
|
||||
gtk_app_chooser_widget_get_type
|
||||
gtk_application_get_type
|
||||
gtk_application_list_get_type
|
||||
gtk_application_window_get_type
|
||||
gtk_aspect_frame_get_type
|
||||
gtk_assistant_get_type
|
||||
|
@@ -43,7 +43,6 @@
|
||||
#include <gtk/gtkappchooserwidget.h>
|
||||
#include <gtk/gtkappchooserbutton.h>
|
||||
#include <gtk/gtkapplication.h>
|
||||
#include <gtk/gtkapplicationlist.h>
|
||||
#include <gtk/gtkapplicationwindow.h>
|
||||
#include <gtk/gtkaspectframe.h>
|
||||
#include <gtk/gtkassistant.h>
|
||||
|
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 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 "gtkapplicationlist.h"
|
||||
|
||||
#include "gtksettings.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
/**
|
||||
* SECTION:gtkapplicationlist
|
||||
* @title: GtkApplicationList
|
||||
* @short_description: A list model for applications
|
||||
* @see_also: #GListModel, #GAppInfo
|
||||
*
|
||||
* #GtkApplicationList is a list model that wraps #GAppInfo.
|
||||
* It presents a #GListModel and fills it with the #GAppInfos for
|
||||
* the available applications.
|
||||
*
|
||||
* The #GtkApplicationList is monitoring for changes and emits
|
||||
* #GListModel::items-changed when the list of applications changes.
|
||||
*/
|
||||
|
||||
struct _GtkApplicationList
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GAppInfoMonitor *monitor;
|
||||
|
||||
GSequence *items;
|
||||
};
|
||||
|
||||
struct _GtkApplicationListClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
static GType
|
||||
gtk_application_list_get_item_type (GListModel *list)
|
||||
{
|
||||
return G_TYPE_APP_INFO;
|
||||
}
|
||||
|
||||
static guint
|
||||
gtk_application_list_get_n_items (GListModel *list)
|
||||
{
|
||||
GtkApplicationList *self = GTK_APPLICATION_LIST (list);
|
||||
|
||||
return g_sequence_get_length (self->items);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
gtk_application_list_get_item (GListModel *list,
|
||||
guint position)
|
||||
{
|
||||
GtkApplicationList *self = GTK_APPLICATION_LIST (list);
|
||||
GSequenceIter *iter;
|
||||
|
||||
iter = g_sequence_get_iter_at_pos (self->items, position);
|
||||
|
||||
if (g_sequence_iter_is_end (iter))
|
||||
return NULL;
|
||||
else
|
||||
return g_object_ref (g_sequence_get (iter));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_list_model_init (GListModelInterface *iface)
|
||||
{
|
||||
iface->get_item_type = gtk_application_list_get_item_type;
|
||||
iface->get_n_items = gtk_application_list_get_n_items;
|
||||
iface->get_item = gtk_application_list_get_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkApplicationList, gtk_application_list, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_application_list_model_init))
|
||||
|
||||
static void
|
||||
apps_changed (GAppInfoMonitor *monitor,
|
||||
GtkApplicationList *self)
|
||||
{
|
||||
guint before;
|
||||
guint after;
|
||||
GList *apps, *l;
|
||||
|
||||
before = g_sequence_get_length (self->items);
|
||||
if (before > 0)
|
||||
g_sequence_remove_range (g_sequence_get_begin_iter (self->items),
|
||||
g_sequence_get_end_iter (self->items));
|
||||
|
||||
apps = g_app_info_get_all ();
|
||||
for (l = apps; l; l = l->next)
|
||||
{
|
||||
GAppInfo *info = l->data;
|
||||
g_sequence_append (self->items, g_object_ref (info));
|
||||
}
|
||||
g_list_free_full (apps, g_object_unref);
|
||||
|
||||
after = g_sequence_get_length (self->items);
|
||||
|
||||
g_list_model_items_changed (G_LIST_MODEL (self), 0, before, after);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_list_dispose (GObject *object)
|
||||
{
|
||||
GtkApplicationList *self = GTK_APPLICATION_LIST (object);
|
||||
|
||||
g_clear_pointer (&self->items, g_sequence_free);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (self->monitor, G_CALLBACK (apps_changed), self);
|
||||
g_clear_object (&self->monitor);
|
||||
|
||||
G_OBJECT_CLASS (gtk_application_list_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_list_class_init (GtkApplicationListClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
gobject_class->dispose = gtk_application_list_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_list_init (GtkApplicationList *self)
|
||||
{
|
||||
self->items = g_sequence_new (g_object_unref);
|
||||
self->monitor = g_app_info_monitor_get ();
|
||||
g_signal_connect (self->monitor, "changed", G_CALLBACK (apps_changed), self);
|
||||
apps_changed (self->monitor, self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_application_list_new:
|
||||
*
|
||||
* Creates a new #GtkApplicationList.
|
||||
*
|
||||
* Returns: a new #GtkApplicationList
|
||||
**/
|
||||
GtkApplicationList *
|
||||
gtk_application_list_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_APPLICATION_LIST, NULL);
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 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>
|
||||
*/
|
||||
|
||||
#ifndef __GTK_APPLICATION_LIST_H__
|
||||
#define __GTK_APPLICATION_LIST_H__
|
||||
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gio/gio.h>
|
||||
/* for GDK_AVAILABLE_IN_ALL */
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_APPLICATION_LIST (gtk_application_list_get_type ())
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (GtkApplicationList, gtk_application_list, GTK, APPLICATION_LIST, GObject)
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkApplicationList * gtk_application_list_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_APPLICATION_LIST_H__ */
|
@@ -1500,8 +1500,8 @@ gtk_column_view_get_list_view (GtkColumnView *self)
|
||||
* |[
|
||||
* gtk_column_view_column_set_sorter (column, sorter);
|
||||
* gtk_column_view_append_column (view, column);
|
||||
* model = gtk_sort_list_model_new (store,
|
||||
* gtk_column_view_get_sorter (view));
|
||||
* sorter = g_object_ref (gtk_column_view_get_sorter (view)));
|
||||
* model = gtk_sort_list_model_new (store, sorter);
|
||||
* selection = gtk_no_selection_new (model);
|
||||
* gtk_column_view_set_model (view, selection);
|
||||
* ]|
|
||||
|
@@ -322,12 +322,9 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog)
|
||||
g_object_unref (printer_list);
|
||||
|
||||
full_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (printer_list_list)));
|
||||
g_object_unref (printer_list_list);
|
||||
|
||||
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
|
||||
g_object_unref (full_list);
|
||||
g_object_unref (filter);
|
||||
|
||||
dialog->custom_paper_list = g_list_store_new (GTK_TYPE_PAGE_SETUP);
|
||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||
|
@@ -666,7 +666,7 @@ gtk_drop_down_set_model (GtkDropDown *self,
|
||||
GListModel *filter_model;
|
||||
GListModel *selection;
|
||||
|
||||
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (model, NULL));
|
||||
filter_model = G_LIST_MODEL (gtk_filter_list_model_new (g_object_ref (model), NULL));
|
||||
g_set_object (&self->filter_model, filter_model);
|
||||
g_object_unref (filter_model);
|
||||
|
||||
|
@@ -614,8 +614,8 @@ gtk_filter_list_model_init (GtkFilterListModel *self)
|
||||
|
||||
/**
|
||||
* gtk_filter_list_model_new:
|
||||
* @model: (allow-none): the model to sort
|
||||
* @filter: (allow-none): filter or %NULL to not filter items
|
||||
* @model: (allow-none) (transfer full): the model to sort, or %NULL
|
||||
* @filter: (allow-none) (transfer full): filter or %NULL to not filter items
|
||||
*
|
||||
* Creates a new #GtkFilterListModel that will filter @model using the given
|
||||
* @filter.
|
||||
@@ -636,6 +636,10 @@ gtk_filter_list_model_new (GListModel *model,
|
||||
"filter", filter,
|
||||
NULL);
|
||||
|
||||
/* consume the references */
|
||||
g_clear_object (&model);
|
||||
g_clear_object (&filter);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -425,7 +425,7 @@ gtk_flatten_list_model_init (GtkFlattenListModel *self)
|
||||
|
||||
/**
|
||||
* gtk_flatten_list_model_new:
|
||||
* @model: (nullable) (transfer none): the model to be flattened
|
||||
* @model: (nullable) (transfer full): the model to be flattened
|
||||
*
|
||||
* Creates a new #GtkFlattenListModel that flattens @list.
|
||||
*
|
||||
@@ -442,6 +442,9 @@ gtk_flatten_list_model_new (GListModel *model)
|
||||
"model", model,
|
||||
NULL);
|
||||
|
||||
/* we consume the reference */
|
||||
g_clear_object (&model);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -784,7 +784,7 @@ update_fontlist (GtkFontChooserWidget *self)
|
||||
if ((self->level & GTK_FONT_CHOOSER_LEVEL_STYLE) == 0)
|
||||
model = g_object_ref (G_LIST_MODEL (fontmap));
|
||||
else
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (fontmap)));
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (g_object_ref (fontmap))));
|
||||
gtk_filter_list_model_set_model (self->filter_model, model);
|
||||
g_object_unref (model);
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@ struct _GtkListListModel
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GType item_type;
|
||||
guint n_items;
|
||||
gpointer (* get_first) (gpointer);
|
||||
gpointer (* get_next) (gpointer, gpointer);
|
||||
@@ -55,9 +54,7 @@ struct _GtkListListModelClass
|
||||
static GType
|
||||
gtk_list_list_model_get_item_type (GListModel *list)
|
||||
{
|
||||
GtkListListModel *self = GTK_LIST_LIST_MODEL (list);
|
||||
|
||||
return self->item_type;
|
||||
return G_TYPE_OBJECT;
|
||||
}
|
||||
|
||||
static guint
|
||||
@@ -143,8 +140,7 @@ gtk_list_list_model_init (GtkListListModel *self)
|
||||
}
|
||||
|
||||
GtkListListModel *
|
||||
gtk_list_list_model_new (GType item_type,
|
||||
gpointer (* get_first) (gpointer),
|
||||
gtk_list_list_model_new (gpointer (* get_first) (gpointer),
|
||||
gpointer (* get_next) (gpointer, gpointer),
|
||||
gpointer (* get_previous) (gpointer, gpointer),
|
||||
gpointer (* get_last) (gpointer),
|
||||
@@ -161,8 +157,7 @@ gtk_list_list_model_new (GType item_type,
|
||||
item = get_next (item, data))
|
||||
n_items++;
|
||||
|
||||
return gtk_list_list_model_new_with_size (item_type,
|
||||
n_items,
|
||||
return gtk_list_list_model_new_with_size (n_items,
|
||||
get_first,
|
||||
get_next,
|
||||
get_previous,
|
||||
@@ -173,8 +168,7 @@ gtk_list_list_model_new (GType item_type,
|
||||
}
|
||||
|
||||
GtkListListModel *
|
||||
gtk_list_list_model_new_with_size (GType item_type,
|
||||
guint n_items,
|
||||
gtk_list_list_model_new_with_size (guint n_items,
|
||||
gpointer (* get_first) (gpointer),
|
||||
gpointer (* get_next) (gpointer, gpointer),
|
||||
gpointer (* get_previous) (gpointer, gpointer),
|
||||
@@ -185,7 +179,6 @@ gtk_list_list_model_new_with_size (GType item_type,
|
||||
{
|
||||
GtkListListModel *result;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (item_type, G_TYPE_OBJECT), NULL);
|
||||
g_return_val_if_fail (get_first != NULL, NULL);
|
||||
g_return_val_if_fail (get_next != NULL, NULL);
|
||||
g_return_val_if_fail (get_previous != NULL, NULL);
|
||||
@@ -193,7 +186,6 @@ gtk_list_list_model_new_with_size (GType item_type,
|
||||
|
||||
result = g_object_new (GTK_TYPE_LIST_LIST_MODEL, NULL);
|
||||
|
||||
result->item_type = item_type;
|
||||
result->n_items = n_items;
|
||||
result->get_first = get_first;
|
||||
result->get_next = get_next;
|
||||
|
@@ -37,8 +37,7 @@ typedef struct _GtkListListModelClass GtkListListModelClass;
|
||||
|
||||
GType gtk_list_list_model_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkListListModel * gtk_list_list_model_new (GType item_type,
|
||||
gpointer (* get_first) (gpointer),
|
||||
GtkListListModel * gtk_list_list_model_new (gpointer (* get_first) (gpointer),
|
||||
gpointer (* get_next) (gpointer, gpointer),
|
||||
gpointer (* get_previous) (gpointer, gpointer),
|
||||
gpointer (* get_last) (gpointer),
|
||||
@@ -46,8 +45,7 @@ GtkListListModel * gtk_list_list_model_new (GType
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
GtkListListModel * gtk_list_list_model_new_with_size (GType item_type,
|
||||
guint n_items,
|
||||
GtkListListModel * gtk_list_list_model_new_with_size (guint n_items,
|
||||
gpointer (* get_first) (gpointer),
|
||||
gpointer (* get_next) (gpointer, gpointer),
|
||||
gpointer (* get_previous) (gpointer, gpointer),
|
||||
|
@@ -412,7 +412,7 @@ gtk_map_list_model_augment (GtkRbTree *map,
|
||||
|
||||
/**
|
||||
* gtk_map_list_model_new:
|
||||
* @model: (allow-none): The model to map or %NULL for none
|
||||
* @model: (transfer full) (allow-none): The model to map or %NULL for none
|
||||
* @map_func: (allow-none): map function or %NULL to not map items
|
||||
* @user_data: (closure): user data passed to @map_func
|
||||
* @user_destroy: destroy notifier for @user_data
|
||||
@@ -435,6 +435,9 @@ gtk_map_list_model_new (GListModel *model,
|
||||
"model", model,
|
||||
NULL);
|
||||
|
||||
/* consume the reference */
|
||||
g_clear_object (&model);
|
||||
|
||||
if (map_func)
|
||||
gtk_map_list_model_set_map_func (result, map_func, user_data, user_destroy);
|
||||
|
||||
|
@@ -31,6 +31,20 @@
|
||||
|
||||
#include <graphene-gobject.h>
|
||||
|
||||
|
||||
/**
|
||||
* SECTION:gtkoverlaylayout
|
||||
* @Title: GtkOverlayLayout
|
||||
* @Short_description: Layout manager that places widgets as overlays
|
||||
*
|
||||
* GtkOverlayLayout is the layout manager used by #GtkOverlay.
|
||||
* It places widgets as overlays on top of the main child.
|
||||
*
|
||||
* This is not a reusable layout manager, since it expects its widget
|
||||
* to be a #GtkOverlay. It only listed here so that its layout
|
||||
* properties get documented.
|
||||
*/
|
||||
|
||||
struct _GtkOverlayLayout
|
||||
{
|
||||
GtkLayoutManager parent_instance;
|
||||
|
@@ -308,7 +308,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
||||
g_list_store_append (store, dialog->manage_papers_list);
|
||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
|
||||
g_object_unref (store);
|
||||
g_object_unref (paper_size_list);
|
||||
|
||||
/* Do this in code, we want the translatable strings without the markup */
|
||||
@@ -325,8 +324,6 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog)
|
||||
|
||||
filter = gtk_custom_filter_new (match_func, NULL, NULL);
|
||||
dialog->printer_list = G_LIST_MODEL (gtk_filter_list_model_new (full_list, filter));
|
||||
g_object_unref (full_list);
|
||||
g_object_unref (filter);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_printer_item), dialog);
|
||||
|
@@ -807,14 +807,12 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
g_list_store_append (store, dialog->manage_papers_list);
|
||||
paper_size_list = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (store)));
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (dialog->paper_size_combo), paper_size_list);
|
||||
g_object_unref (store);
|
||||
g_object_unref (paper_size_list);
|
||||
|
||||
/* Load backends */
|
||||
model = load_print_backends (dialog);
|
||||
sorter = gtk_custom_sorter_new (default_printer_list_sort_func, NULL, NULL);
|
||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (model, sorter));
|
||||
g_object_unref (sorter);
|
||||
|
||||
filter = gtk_every_filter_new ();
|
||||
|
||||
@@ -831,7 +829,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
gtk_multi_filter_append (GTK_MULTI_FILTER (filter), filter1);
|
||||
|
||||
filtered = G_LIST_MODEL (gtk_filter_list_model_new (sorted, filter));
|
||||
g_object_unref (filter);
|
||||
|
||||
selection = G_LIST_MODEL (gtk_single_selection_new (filtered));
|
||||
gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (selection), FALSE);
|
||||
@@ -841,7 +838,6 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
|
||||
g_signal_connect_swapped (selection, "notify::selected", G_CALLBACK (selected_printer_changed), dialog);
|
||||
g_object_unref (selection);
|
||||
g_object_unref (filtered);
|
||||
g_object_unref (model);
|
||||
|
||||
gtk_print_load_custom_papers (dialog->custom_paper_list);
|
||||
|
||||
@@ -1037,7 +1033,6 @@ load_print_backends (GtkPrintUnixDialog *dialog)
|
||||
{
|
||||
GList *node;
|
||||
GListStore *lists;
|
||||
GListModel *model;
|
||||
|
||||
lists = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
|
||||
@@ -1053,11 +1048,7 @@ load_print_backends (GtkPrintUnixDialog *dialog)
|
||||
g_list_store_append (lists, gtk_print_backend_get_printers (backend));
|
||||
}
|
||||
|
||||
model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
|
||||
|
||||
g_object_unref (lists);
|
||||
|
||||
return model;
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (lists)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -44,21 +44,16 @@ G_DEFINE_INTERFACE (GtkShortcutManager, gtk_shortcut_manager, G_TYPE_OBJECT)
|
||||
void
|
||||
gtk_shortcut_manager_create_controllers (GtkWidget *widget)
|
||||
{
|
||||
GListStore *store;
|
||||
GtkFlattenListModel *model;
|
||||
GtkEventController *controller;
|
||||
|
||||
store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
|
||||
model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
||||
g_object_unref (store);
|
||||
model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
|
||||
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-bubble", model, g_object_unref);
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
|
||||
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-bubble");
|
||||
gtk_widget_add_controller (widget, controller);
|
||||
|
||||
store = g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER);
|
||||
model = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
||||
g_object_unref (store);
|
||||
model = gtk_flatten_list_model_new (G_LIST_MODEL (g_list_store_new (GTK_TYPE_SHORTCUT_CONTROLLER)));
|
||||
g_object_set_data_full (G_OBJECT (widget), "gtk-shortcut-manager-capture", model, g_object_unref);
|
||||
controller = gtk_shortcut_controller_new_for_model (G_LIST_MODEL (model));
|
||||
gtk_event_controller_set_name (controller, "gtk-shortcut-manager-capture");
|
||||
|
@@ -30,11 +30,12 @@
|
||||
* @short_description: A list model that presents a slice out of a larger list
|
||||
* @see_also: #GListModel
|
||||
*
|
||||
* #GtkSliceListModel is a list model that takes a list model and presents a slice of
|
||||
* that model.
|
||||
* #GtkSliceListModel is a list model that takes a list model and presents a
|
||||
* slice of that model.
|
||||
*
|
||||
* This is useful when implementing paging by setting the size to the number of elements
|
||||
* per page and updating the offset whenever a different page is opened.
|
||||
* This is useful when implementing paging by setting the size to the number
|
||||
* of elements per page and updating the offset whenever a different page is
|
||||
* opened.
|
||||
*/
|
||||
|
||||
#define DEFAULT_SIZE 10
|
||||
@@ -300,7 +301,7 @@ gtk_slice_list_model_init (GtkSliceListModel *self)
|
||||
|
||||
/**
|
||||
* gtk_slice_list_model_new:
|
||||
* @model: (transfer none) (allow-none): The model to use
|
||||
* @model: (transfer full) (allow-none): The model to use, or %NULL
|
||||
* @offset: the offset of the slice
|
||||
* @size: maximum size of the slice
|
||||
*
|
||||
@@ -314,13 +315,20 @@ gtk_slice_list_model_new (GListModel *model,
|
||||
guint offset,
|
||||
guint size)
|
||||
{
|
||||
GtkSliceListModel *self;
|
||||
|
||||
g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_SLICE_LIST_MODEL,
|
||||
self = g_object_new (GTK_TYPE_SLICE_LIST_MODEL,
|
||||
"model", model,
|
||||
"offset", offset,
|
||||
"size", size,
|
||||
NULL);
|
||||
|
||||
/* consume the reference */
|
||||
g_clear_object (&model);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -828,8 +828,8 @@ gtk_sort_list_model_init (GtkSortListModel *self)
|
||||
|
||||
/**
|
||||
* gtk_sort_list_model_new:
|
||||
* @model: (allow-none): the model to sort
|
||||
* @sorter: (allow-none): the #GtkSorter to sort @model with
|
||||
* @model: (allow-none) (transfer full): the model to sort, or %NULL
|
||||
* @sorter: (allow-none) (transfer full): the #GtkSorter to sort @model with, or %NULL
|
||||
*
|
||||
* Creates a new sort list model that uses the @sorter to sort @model.
|
||||
*
|
||||
@@ -849,6 +849,10 @@ gtk_sort_list_model_new (GListModel *model,
|
||||
"sorter", sorter,
|
||||
NULL);
|
||||
|
||||
/* consume the references */
|
||||
g_clear_object (&model);
|
||||
g_clear_object (&sorter);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -11535,8 +11535,7 @@ gtk_widget_observe_children (GtkWidget *widget)
|
||||
if (priv->children_observer)
|
||||
return g_object_ref (G_LIST_MODEL (priv->children_observer));
|
||||
|
||||
priv->children_observer = gtk_list_list_model_new (GTK_TYPE_WIDGET,
|
||||
(gpointer) gtk_widget_get_first_child,
|
||||
priv->children_observer = gtk_list_list_model_new ((gpointer) gtk_widget_get_first_child,
|
||||
(gpointer) gtk_widget_get_next_sibling,
|
||||
(gpointer) gtk_widget_get_prev_sibling,
|
||||
(gpointer) gtk_widget_get_last_child,
|
||||
@@ -11622,14 +11621,13 @@ gtk_widget_observe_controllers (GtkWidget *widget)
|
||||
if (priv->controller_observer)
|
||||
return g_object_ref (G_LIST_MODEL (priv->controller_observer));
|
||||
|
||||
priv->controller_observer = gtk_list_list_model_new (GTK_TYPE_EVENT_CONTROLLER,
|
||||
gtk_widget_controller_list_get_first,
|
||||
gtk_widget_controller_list_get_next,
|
||||
gtk_widget_controller_list_get_prev,
|
||||
NULL,
|
||||
(gpointer) g_object_ref,
|
||||
widget,
|
||||
gtk_widget_controller_observer_destroyed);
|
||||
priv->controller_observer = gtk_list_list_model_new (gtk_widget_controller_list_get_first,
|
||||
gtk_widget_controller_list_get_next,
|
||||
gtk_widget_controller_list_get_prev,
|
||||
NULL,
|
||||
(gpointer) g_object_ref,
|
||||
widget,
|
||||
gtk_widget_controller_observer_destroyed);
|
||||
|
||||
return G_LIST_MODEL (priv->controller_observer);
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ struct _GtkInspectorActions
|
||||
|
||||
GObject *object;
|
||||
|
||||
GListModel *actions;
|
||||
GListStore *actions;
|
||||
GtkColumnViewColumn *name;
|
||||
};
|
||||
|
||||
@@ -79,7 +79,7 @@ action_added (GObject *owner,
|
||||
GtkInspectorActions *sl)
|
||||
{
|
||||
ActionHolder *holder = action_holder_new (owner, action_name);
|
||||
g_list_store_append (G_LIST_STORE (sl->actions), holder);
|
||||
g_list_store_append (sl->actions, holder);
|
||||
g_object_unref (holder);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ add_muxer (GtkInspectorActions *sl,
|
||||
static gboolean
|
||||
reload (GtkInspectorActions *sl)
|
||||
{
|
||||
g_list_store_remove_all (G_LIST_STORE (sl->actions));
|
||||
g_list_store_remove_all (sl->actions);
|
||||
|
||||
if (GTK_IS_APPLICATION (sl->object))
|
||||
{
|
||||
@@ -395,9 +395,9 @@ constructed (GObject *object)
|
||||
gtk_column_view_column_set_sorter (sl->name, sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
sl->actions = G_LIST_MODEL (g_list_store_new (ACTION_TYPE_HOLDER));
|
||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (sl->actions,
|
||||
gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list))));
|
||||
sl->actions = g_list_store_new (ACTION_TYPE_HOLDER);
|
||||
sorted = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (sl->actions)),
|
||||
g_object_ref (gtk_column_view_get_sorter (GTK_COLUMN_VIEW (sl->list)))));
|
||||
model = G_LIST_MODEL (gtk_no_selection_new (sorted));
|
||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (sl->list), model);
|
||||
g_object_unref (sorted);
|
||||
|
@@ -244,13 +244,11 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
|
||||
gtk_property_lookup_list_model_set_object (self->model, object);
|
||||
|
||||
map_model = gtk_map_list_model_new (G_LIST_MODEL (self->model), map_to_controllers, NULL, NULL);
|
||||
g_object_unref (self->model);
|
||||
|
||||
flatten_model = gtk_flatten_list_model_new (G_LIST_MODEL (map_model));
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare_controllers, NULL, NULL);
|
||||
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (flatten_model), sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
gtk_list_box_bind_model (GTK_LIST_BOX (self->listbox),
|
||||
G_LIST_MODEL (sort_model),
|
||||
@@ -259,8 +257,6 @@ gtk_inspector_controllers_set_object (GtkInspectorControllers *self,
|
||||
NULL);
|
||||
|
||||
g_object_unref (sort_model);
|
||||
g_object_unref (flatten_model);
|
||||
g_object_unref (map_model);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -116,7 +116,6 @@ static GListModel *
|
||||
object_tree_widget_get_children (GObject *object)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (object);
|
||||
GtkFlattenListModel *flatten;
|
||||
GListStore *list;
|
||||
GListModel *sublist;
|
||||
|
||||
@@ -130,10 +129,7 @@ object_tree_widget_get_children (GObject *object)
|
||||
g_list_store_append (list, sublist);
|
||||
g_object_unref (sublist);
|
||||
|
||||
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
|
||||
g_object_unref (list);
|
||||
|
||||
return G_LIST_MODEL (flatten);
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
@@ -211,7 +207,6 @@ list_model_for_properties (GObject *object,
|
||||
const char **props)
|
||||
{
|
||||
GListStore *concat;
|
||||
GListModel *result;
|
||||
guint i;
|
||||
|
||||
if (props[1] == NULL)
|
||||
@@ -225,9 +220,7 @@ list_model_for_properties (GObject *object,
|
||||
g_object_unref (tmp);
|
||||
}
|
||||
|
||||
result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
|
||||
g_object_unref (concat);
|
||||
return result;
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (concat)));
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
@@ -310,7 +303,6 @@ object_tree_tree_view_get_children (GObject *object)
|
||||
GtkTreeView *treeview = GTK_TREE_VIEW (object);
|
||||
GListStore *columns, *selection, *result_list;
|
||||
GListModel *props;
|
||||
GtkFlattenListModel *result;
|
||||
guint i;
|
||||
|
||||
props = list_model_for_properties (object, (const char *[2]) { "model", NULL });
|
||||
@@ -330,10 +322,8 @@ object_tree_tree_view_get_children (GObject *object)
|
||||
g_object_unref (selection);
|
||||
g_list_store_append (result_list, columns);
|
||||
g_object_unref (columns);
|
||||
result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
|
||||
g_object_unref (result_list);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
@@ -341,7 +331,6 @@ object_tree_column_view_get_children (GObject *object)
|
||||
{
|
||||
GtkColumnView *view = GTK_COLUMN_VIEW (object);
|
||||
GListStore *result_list;
|
||||
GtkFlattenListModel *result;
|
||||
GListModel *columns, *sublist;
|
||||
|
||||
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
@@ -353,10 +342,7 @@ object_tree_column_view_get_children (GObject *object)
|
||||
g_list_store_append (result_list, sublist);
|
||||
g_object_unref (sublist);
|
||||
|
||||
result = gtk_flatten_list_model_new (G_LIST_MODEL (result_list));
|
||||
g_object_unref (result_list);
|
||||
|
||||
return G_LIST_MODEL (result);
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
@@ -602,12 +588,11 @@ static GListModel *
|
||||
object_get_children (GObject *object)
|
||||
{
|
||||
GType object_type;
|
||||
GListModel *result, *children;
|
||||
GListModel *children;
|
||||
GListStore *result_list;
|
||||
guint i;
|
||||
|
||||
object_type = G_OBJECT_TYPE (object);
|
||||
result = NULL;
|
||||
result_list = NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (object_tree_class_funcs); i++)
|
||||
@@ -619,32 +604,17 @@ object_get_children (GObject *object)
|
||||
if (children == NULL)
|
||||
continue;
|
||||
|
||||
if (result_list)
|
||||
{
|
||||
g_list_store_append (result_list, children);
|
||||
g_object_unref (children);
|
||||
}
|
||||
else if (result == NULL)
|
||||
{
|
||||
result = children;
|
||||
}
|
||||
else
|
||||
{
|
||||
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
g_list_store_append (result_list, result);
|
||||
g_object_unref (result);
|
||||
g_list_store_append (result_list, children);
|
||||
g_object_unref (children);
|
||||
}
|
||||
if (!result_list)
|
||||
result_list = g_list_store_new (G_TYPE_LIST_MODEL);
|
||||
|
||||
g_list_store_append (result_list, children);
|
||||
g_object_unref (children);
|
||||
}
|
||||
|
||||
if (result_list)
|
||||
{
|
||||
result = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
||||
g_object_unref (result_list);
|
||||
}
|
||||
|
||||
return result;
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (result_list)));
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -1167,7 +1137,6 @@ create_root_model (GdkDisplay *display)
|
||||
{
|
||||
GtkFilter *custom_filter;
|
||||
GtkFilterListModel *filter;
|
||||
GtkFlattenListModel *flatten;
|
||||
GListStore *list, *special;
|
||||
gpointer item;
|
||||
|
||||
@@ -1182,16 +1151,13 @@ create_root_model (GdkDisplay *display)
|
||||
g_object_unref (special);
|
||||
|
||||
filter = gtk_filter_list_model_new (NULL, NULL);
|
||||
custom_filter = gtk_custom_filter_new (toplevel_filter_func,
|
||||
display, NULL);
|
||||
custom_filter = gtk_custom_filter_new (toplevel_filter_func, display, NULL);
|
||||
gtk_filter_list_model_set_filter (filter, custom_filter);
|
||||
gtk_filter_list_model_set_model (filter, gtk_window_get_toplevels ());
|
||||
g_list_store_append (list, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
flatten = gtk_flatten_list_model_new (G_LIST_MODEL (list));
|
||||
g_object_unref (list);
|
||||
return G_LIST_MODEL (flatten);
|
||||
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -622,7 +622,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
||||
if (GTK_IS_WIDGET (object))
|
||||
g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object), pl, G_CONNECT_SWAPPED);
|
||||
|
||||
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), pl->priv->filter));
|
||||
filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), g_object_ref (pl->priv->filter)));
|
||||
sorted = gtk_sort_list_model_new (filtered, NULL);
|
||||
list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
|
||||
|
||||
@@ -634,8 +634,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
|
||||
|
||||
g_object_unref (list);
|
||||
g_object_unref (sorted);
|
||||
g_object_unref (filtered);
|
||||
g_object_unref (store);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -712,11 +712,10 @@ constructed (GObject *object)
|
||||
|
||||
column_sorter = gtk_column_view_get_sorter (GTK_COLUMN_VIEW (rl->list));
|
||||
sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
|
||||
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (rl->tree_model), sorter));
|
||||
sort_model = G_LIST_MODEL (gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (rl->tree_model)), sorter));
|
||||
rl->selection = gtk_single_selection_new (sort_model);
|
||||
g_object_unref (root_model);
|
||||
g_object_unref (sort_model);
|
||||
g_object_unref (sorter);
|
||||
|
||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (rl->list), G_LIST_MODEL (rl->selection));
|
||||
|
||||
|
@@ -159,7 +159,6 @@ gtk_public_sources = files([
|
||||
'gtkappchooserdialog.c',
|
||||
'gtkappchooserwidget.c',
|
||||
'gtkapplication.c',
|
||||
'gtkapplicationlist.c',
|
||||
'gtkapplicationwindow.c',
|
||||
'gtkaspectframe.c',
|
||||
'gtkassistant.c',
|
||||
@@ -447,7 +446,6 @@ gtk_public_headers = files([
|
||||
'gtkappchooserdialog.h',
|
||||
'gtkappchooserwidget.h',
|
||||
'gtkapplication.h',
|
||||
'gtkapplicationlist.h',
|
||||
'gtkapplicationwindow.h',
|
||||
'gtkaspectframe.h',
|
||||
'gtkassistant.h',
|
||||
|
@@ -759,7 +759,6 @@ main (int argc, char *argv[])
|
||||
custom_filter = gtk_custom_filter_new (match_file, g_object_ref (search_entry), g_object_unref);
|
||||
filter = gtk_filter_list_model_new (G_LIST_MODEL (sort), custom_filter);
|
||||
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
|
||||
g_object_unref (custom_filter);
|
||||
|
||||
gtk_column_view_set_model (GTK_COLUMN_VIEW (view), G_LIST_MODEL (filter));
|
||||
|
||||
@@ -771,8 +770,6 @@ main (int argc, char *argv[])
|
||||
gtk_box_append (GTK_BOX (vbox), statusbar);
|
||||
|
||||
g_object_unref (filter);
|
||||
g_object_unref (sort);
|
||||
g_object_unref (tree);
|
||||
|
||||
list = gtk_list_view_new_with_factory (
|
||||
gtk_builder_list_item_factory_new_from_bytes (scope, g_bytes_new_static (factory_ui, strlen (factory_ui))));
|
||||
|
@@ -431,45 +431,6 @@ selected_changed2 (GtkDropDown *dropdown,
|
||||
g_object_unref (pair);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_app_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *icon;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
|
||||
|
||||
icon = gtk_image_new ();
|
||||
gtk_box_append (GTK_BOX (box), icon);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_label_set_xalign (GTK_LABEL (label), 0);
|
||||
gtk_box_append (GTK_BOX (box), label);
|
||||
|
||||
gtk_list_item_set_child (item, box);
|
||||
}
|
||||
|
||||
static void
|
||||
bind_app_item (GtkSignalListItemFactory *factory,
|
||||
GtkListItem *item)
|
||||
{
|
||||
GAppInfo *info;
|
||||
GtkWidget *box;
|
||||
GtkWidget *label;
|
||||
GtkWidget *icon;
|
||||
|
||||
info = gtk_list_item_get_item (item);
|
||||
box = gtk_list_item_get_child (item);
|
||||
|
||||
icon = gtk_widget_get_first_child (box);
|
||||
label = gtk_widget_get_next_sibling (icon);
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (icon), g_app_info_get_icon (info));
|
||||
gtk_label_set_label (GTK_LABEL (label), g_app_info_get_display_name (info));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -493,7 +454,6 @@ main (int argc, char *argv[])
|
||||
GtkListItemFactory *factory;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *hbox;
|
||||
GtkApplicationList *apps;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
@@ -600,20 +560,6 @@ main (int argc, char *argv[])
|
||||
|
||||
g_object_unref (store);
|
||||
|
||||
button = gtk_drop_down_new ();
|
||||
|
||||
apps = gtk_application_list_new ();
|
||||
gtk_drop_down_set_model (GTK_DROP_DOWN (button), G_LIST_MODEL (apps));
|
||||
g_object_unref (apps);
|
||||
|
||||
factory = gtk_signal_list_item_factory_new ();
|
||||
g_signal_connect (factory, "setup", G_CALLBACK (setup_app_item), NULL);
|
||||
g_signal_connect (factory, "bind", G_CALLBACK (bind_app_item), NULL);
|
||||
gtk_drop_down_set_factory (GTK_DROP_DOWN (button), factory);
|
||||
g_object_unref (factory);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
while (!quit)
|
||||
|
@@ -127,7 +127,6 @@ main (int argc,
|
||||
add (store);
|
||||
sorter = gtk_numeric_sorter_new (gtk_cclosure_expression_new (G_TYPE_UINT, NULL, 0, NULL, (GCallback)get_number, NULL, NULL));
|
||||
sort = gtk_sort_list_model_new (G_LIST_MODEL (store), sorter);
|
||||
g_object_unref (sorter);
|
||||
|
||||
win = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
|
||||
@@ -182,7 +181,5 @@ main (int argc,
|
||||
while (g_list_model_get_n_items (toplevels))
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
g_object_unref (store);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -318,7 +318,6 @@ get_file_path (GFileInfo *info)
|
||||
static GListModel *
|
||||
create_list_model_for_directory (gpointer file)
|
||||
{
|
||||
GtkSortListModel *sort;
|
||||
GtkDirectoryList *dir;
|
||||
GtkSorter *sorter;
|
||||
|
||||
@@ -327,12 +326,8 @@ create_list_model_for_directory (gpointer file)
|
||||
|
||||
dir = create_directory_list (file);
|
||||
sorter = gtk_string_sorter_new (gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback) get_file_path, NULL, NULL));
|
||||
sort = gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter);
|
||||
|
||||
g_object_unref (sorter);
|
||||
g_object_unref (dir);
|
||||
|
||||
return G_LIST_MODEL (sort);
|
||||
return G_LIST_MODEL (gtk_sort_list_model_new (G_LIST_MODEL (dir), sorter));
|
||||
}
|
||||
|
||||
typedef struct _RowData RowData;
|
||||
@@ -640,7 +635,6 @@ main (int argc, char *argv[])
|
||||
custom_filter = gtk_custom_filter_new (match_file, search_entry, NULL);
|
||||
filter = gtk_filter_list_model_new (G_LIST_MODEL (tree), custom_filter);
|
||||
g_signal_connect (search_entry, "search-changed", G_CALLBACK (search_changed_cb), custom_filter);
|
||||
g_object_unref (custom_filter);
|
||||
|
||||
selectionmodel = file_info_selection_new (G_LIST_MODEL (filter));
|
||||
g_object_unref (filter);
|
||||
@@ -654,7 +648,6 @@ main (int argc, char *argv[])
|
||||
update_statusbar (GTK_STATUSBAR (statusbar));
|
||||
gtk_box_append (GTK_BOX (vbox), statusbar);
|
||||
|
||||
g_object_unref (tree);
|
||||
g_object_unref (selectionmodel);
|
||||
|
||||
gtk_widget_show (win);
|
||||
|
@@ -262,8 +262,6 @@ test_nested (void)
|
||||
g_assert_cmpint (counter, ==, 0);
|
||||
|
||||
g_object_unref (filtered);
|
||||
g_object_unref (list);
|
||||
g_object_unref (filter);
|
||||
gtk_expression_unref (expr);
|
||||
}
|
||||
|
||||
|
@@ -189,7 +189,7 @@ new_model (guint size,
|
||||
{
|
||||
GtkFilterListModel *result;
|
||||
|
||||
result = gtk_filter_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), filter);
|
||||
result = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (new_store (1, size, 1))), g_object_ref (filter));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -135,6 +135,10 @@ filter_list_model_new (GListModel *source,
|
||||
GListStore *check;
|
||||
guint i;
|
||||
|
||||
if (source)
|
||||
g_object_ref (source);
|
||||
if (filter)
|
||||
g_object_ref (filter);
|
||||
model = gtk_filter_list_model_new (source, filter);
|
||||
check = g_list_store_new (G_TYPE_OBJECT);
|
||||
for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model)); i++)
|
||||
@@ -443,8 +447,6 @@ test_model_changes (gconstpointer model_id)
|
||||
g_object_unref (model2);
|
||||
g_object_unref (flatten2);
|
||||
g_object_unref (flatten1);
|
||||
g_object_unref (store2);
|
||||
g_object_unref (store1);
|
||||
g_object_unref (multi);
|
||||
}
|
||||
|
||||
|
@@ -167,8 +167,7 @@ new_model (guint size,
|
||||
filter = gtk_custom_filter_new (filter_func, data, NULL);
|
||||
else
|
||||
filter = NULL;
|
||||
result = gtk_filter_list_model_new (G_LIST_MODEL (new_store (1, size, 1)), filter);
|
||||
g_clear_object (&filter);
|
||||
result = gtk_filter_list_model_new (g_object_ref (G_LIST_MODEL (new_store (1, size, 1))), filter);
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
|
@@ -210,7 +210,7 @@ new_model (GListStore *store)
|
||||
GtkFlattenListModel *result;
|
||||
GString *changes;
|
||||
|
||||
result = gtk_flatten_list_model_new (G_LIST_MODEL (store));
|
||||
result = gtk_flatten_list_model_new (g_object_ref (G_LIST_MODEL (store)));
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
|
@@ -196,7 +196,7 @@ new_model (GListStore *store)
|
||||
GtkMapListModel *result;
|
||||
GString *changes;
|
||||
|
||||
result = gtk_map_list_model_new (G_LIST_MODEL (store), map_multiply, GUINT_TO_POINTER (2), NULL);
|
||||
result = gtk_map_list_model_new (g_object_ref (G_LIST_MODEL (store)), map_multiply, GUINT_TO_POINTER (2), NULL);
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
g_signal_connect (result, "items-changed", G_CALLBACK (items_changed), changes);
|
||||
|
@@ -627,7 +627,7 @@ test_set_model (void)
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
m1 = G_LIST_MODEL (store);
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (m1, 0, 3));
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
|
||||
selection = new_model (store);
|
||||
assert_selection (selection, "");
|
||||
assert_selection_changes (selection, "");
|
||||
|
@@ -653,7 +653,7 @@ test_set_model (void)
|
||||
|
||||
store = new_store (1, 5, 1);
|
||||
m1 = G_LIST_MODEL (store);
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (m1, 0, 3));
|
||||
m2 = G_LIST_MODEL (gtk_slice_list_model_new (g_object_ref (m1), 0, 3));
|
||||
selection = new_model (store, TRUE, TRUE);
|
||||
assert_selection (selection, "1");
|
||||
assert_selection_changes (selection, "");
|
||||
|
@@ -191,7 +191,7 @@ new_model (GListStore *store, guint offset, guint size)
|
||||
GtkSliceListModel *result;
|
||||
GString *changes;
|
||||
|
||||
result = gtk_slice_list_model_new (G_LIST_MODEL (store), offset, size);
|
||||
result = gtk_slice_list_model_new (g_object_ref (G_LIST_MODEL (store)), offset, size);
|
||||
|
||||
changes = g_string_new ("");
|
||||
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);
|
||||
|
@@ -247,7 +247,7 @@ new_model (guint size,
|
||||
{
|
||||
GtkSortListModel *result;
|
||||
|
||||
result = gtk_sort_list_model_new (G_LIST_MODEL (fisher_yates_shuffle (new_store (1, size, 1))), sorter);
|
||||
result = gtk_sort_list_model_new (G_LIST_MODEL (fisher_yates_shuffle (new_store (1, size, 1))), g_object_ref (sorter));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -630,8 +630,8 @@ test_stable (void)
|
||||
gtk_multi_sorter_append (GTK_MULTI_SORTER (multi), b);
|
||||
model1 = new_model (20, multi);
|
||||
g_object_unref (multi);
|
||||
model2b = gtk_sort_list_model_new (gtk_sort_list_model_get_model (model1), b);
|
||||
model2 = gtk_sort_list_model_new (G_LIST_MODEL (model2b), a);
|
||||
model2b = gtk_sort_list_model_new (g_object_ref (gtk_sort_list_model_get_model (model1)), b);
|
||||
model2 = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (model2b)), a);
|
||||
assert_model_equal (model1, model2);
|
||||
|
||||
modify_sorter (a);
|
||||
|
@@ -200,9 +200,9 @@ create_sort_list_model (gconstpointer model_id,
|
||||
guint id = GPOINTER_TO_UINT (model_id);
|
||||
|
||||
if (track_changes)
|
||||
model = sort_list_model_new (id & 1 ? NULL : source, id & 2 ? NULL : sorter);
|
||||
model = sort_list_model_new (id & 1 ? NULL : g_object_ref (source), id & 2 ? NULL : g_object_ref (sorter));
|
||||
else
|
||||
model = gtk_sort_list_model_new (id & 1 ? NULL : source, id & 2 ? NULL : sorter);
|
||||
model = gtk_sort_list_model_new (id & 1 ? NULL : g_object_ref (source), id & 2 ? NULL : g_object_ref (sorter));
|
||||
|
||||
switch (id >> 2)
|
||||
{
|
||||
@@ -433,7 +433,6 @@ test_stability (gconstpointer model_id)
|
||||
g_object_unref (sort2);
|
||||
g_object_unref (sort1);
|
||||
g_object_unref (flatten);
|
||||
g_object_unref (store);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -220,8 +220,7 @@ new_model (gpointer model)
|
||||
GtkSorter *sorter;
|
||||
|
||||
sorter = gtk_custom_sorter_new (compare, NULL, NULL);
|
||||
result = gtk_sort_list_model_new (model, sorter);
|
||||
g_object_unref (sorter);
|
||||
result = gtk_sort_list_model_new (g_object_ref (model), sorter);
|
||||
}
|
||||
else
|
||||
result = gtk_sort_list_model_new (NULL, NULL);
|
||||
|
@@ -179,9 +179,7 @@ test_simple (void)
|
||||
sort = gtk_sort_list_model_new (model, sorter);
|
||||
assert_model (sort, "1 2 21 3 31 32 321");
|
||||
|
||||
g_object_unref (sorter);
|
||||
g_object_unref (sort);
|
||||
g_object_unref (model);
|
||||
}
|
||||
|
||||
static GtkSorter *
|
||||
|
Reference in New Issue
Block a user