[gnome-software] New egg-list-box sources
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] New egg-list-box sources
- Date: Tue, 22 Jan 2013 12:19:09 +0000 (UTC)
commit ea09e27373c205adadf9778916ec4639299fb5d8
Author: Richard Hughes <richard hughsie com>
Date: Mon Jan 21 15:37:17 2013 +0000
New egg-list-box sources
src/egg-list-box.c | 5639 +++++++++++++++++-----------------------------------
src/egg-list-box.h | 76 +-
2 files changed, 1823 insertions(+), 3892 deletions(-)
---
diff --git a/src/egg-list-box.c b/src/egg-list-box.c
index 7f52e5c..5108597 100644
--- a/src/egg-list-box.c
+++ b/src/egg-list-box.c
@@ -1,22 +1,18 @@
-/* egg-list-box.c generated by valac 0.17.1.22-cd59, the Vala compiler
- * generated from egg-list-box.vala, do not modify */
-
-/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
/*
- * Copyright (C) 2011 Alexander Larsson <alexl redhat com>
+ * Copyright (C) 2012 Alexander Larsson <alexl redhat com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
@@ -29,4002 +25,1921 @@
#include <string.h>
#include <gobject/gvaluecollector.h>
+#include "egg-list-box.h"
+
+/* This already exists in gtk as _gtk_marshal_VOID__ENUM_INT, inline it here for now
+ to avoid separate marshallers file */
+static void
+_egg_marshal_VOID__ENUM_INT (GClosure * closure,
+ GValue * return_value,
+ guint n_param_values,
+ const GValue * param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__ENUM_INT) (gpointer data1, gint arg_1, gint arg_2, gpointer data2);
+ register GMarshalFunc_VOID__ENUM_INT callback;
+ register GCClosure * cc;
+ register gpointer data1;
+ register gpointer data2;
+ cc = (GCClosure *) closure;
+ g_return_if_fail (n_param_values == 3);
+ if (G_CCLOSURE_SWAP_DATA (closure)) {
+ data1 = closure->data;
+ data2 = param_values->data[0].v_pointer;
+ } else {
+ data1 = param_values->data[0].v_pointer;
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__ENUM_INT) (marshal_data ? marshal_data : cc->callback);
+ callback (data1, g_value_get_enum (param_values + 1), g_value_get_int (param_values + 2), data2);
+}
-#define EGG_TYPE_LIST_BOX (egg_list_box_get_type ())
-#define EGG_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_LIST_BOX, EggListBox))
-#define EGG_LIST_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_LIST_BOX, EggListBoxClass))
-#define EGG_IS_LIST_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_LIST_BOX))
-#define EGG_IS_LIST_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_LIST_BOX))
-#define EGG_LIST_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_LIST_BOX, EggListBoxClass))
+typedef struct _EggListBoxChildInfo EggListBoxChildInfo;
-typedef struct _EggListBox EggListBox;
-typedef struct _EggListBoxClass EggListBoxClass;
-typedef struct _EggListBoxPrivate EggListBoxPrivate;
+struct _EggListBoxPrivate
+{
+ GSequence *children;
+ GHashTable *child_hash;
+ GHashTable *separator_hash;
-#define EGG_LIST_BOX_TYPE_CHILD_INFO (egg_list_box_child_info_get_type ())
-#define EGG_LIST_BOX_CHILD_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_LIST_BOX_TYPE_CHILD_INFO, EggListBoxChildInfo))
-#define EGG_LIST_BOX_CHILD_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_LIST_BOX_TYPE_CHILD_INFO, EggListBoxChildInfoClass))
-#define EGG_LIST_BOX_IS_CHILD_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_LIST_BOX_TYPE_CHILD_INFO))
-#define EGG_LIST_BOX_IS_CHILD_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_LIST_BOX_TYPE_CHILD_INFO))
-#define EGG_LIST_BOX_CHILD_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_LIST_BOX_TYPE_CHILD_INFO, EggListBoxChildInfoClass))
+ GCompareDataFunc sort_func;
+ gpointer sort_func_target;
+ GDestroyNotify sort_func_target_destroy_notify;
-typedef struct _EggListBoxChildInfo EggListBoxChildInfo;
-typedef struct _EggListBoxChildInfoClass EggListBoxChildInfoClass;
-#define _g_sequence_free0(var) ((var == NULL) ? NULL : (var = (g_sequence_free (var), NULL)))
-#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
-#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-typedef struct _EggListBoxChildInfoPrivate EggListBoxChildInfoPrivate;
-
-#define EGG_LIST_BOX_TYPE_CHILD_FLAGS (egg_list_box_child_flags_get_type ())
-typedef struct _EggListBoxChildFlags EggListBoxChildFlags;
-#define _egg_list_box_child_info_unref0(var) ((var == NULL) ? NULL : (var = (egg_list_box_child_info_unref (var), NULL)))
-typedef struct _EggListBoxParamSpecChildInfo EggListBoxParamSpecChildInfo;
-
-struct _EggListBox {
- GtkContainer parent_instance;
- EggListBoxPrivate * priv;
-};
+ EggListBoxFilterFunc filter_func;
+ gpointer filter_func_target;
+ GDestroyNotify filter_func_target_destroy_notify;
-struct _EggListBoxClass {
- GtkContainerClass parent_class;
- void (*child_selected) (EggListBox* self, GtkWidget* child);
- void (*child_activated) (EggListBox* self, GtkWidget* child);
- void (*activate_cursor_child) (EggListBox* self);
- void (*toggle_cursor_child) (EggListBox* self);
- void (*move_cursor) (EggListBox* self, GtkMovementStep step, gint count);
-};
+ EggListBoxUpdateSeparatorFunc update_separator_func;
+ gpointer update_separator_func_target;
+ GDestroyNotify update_separator_func_target_destroy_notify;
-typedef gboolean (*EggListBoxFilterFunc) (GtkWidget* child, void* user_data);
-typedef void (*EggListBoxUpdateSeparatorFunc) (GtkWidget** separator, GtkWidget* child, GtkWidget* before, void* user_data);
-struct _EggListBoxPrivate {
- GSequence* children;
- GHashTable* child_hash;
- GHashTable* separator_hash;
- GCompareDataFunc sort_func;
- gpointer sort_func_target;
- GDestroyNotify sort_func_target_destroy_notify;
- EggListBoxFilterFunc filter_func;
- gpointer filter_func_target;
- GDestroyNotify filter_func_target_destroy_notify;
- EggListBoxUpdateSeparatorFunc update_separator_func;
- gpointer update_separator_func_target;
- GDestroyNotify update_separator_func_target_destroy_notify;
- EggListBoxChildInfo* selected_child;
- EggListBoxChildInfo* prelight_child;
- EggListBoxChildInfo* cursor_child;
- gboolean active_child_active;
- EggListBoxChildInfo* active_child;
- GtkSelectionMode selection_mode;
- GtkAdjustment* adjustment;
- gboolean activate_single_click;
-};
+ EggListBoxChildInfo *selected_child;
+ EggListBoxChildInfo *prelight_child;
+ EggListBoxChildInfo *cursor_child;
-struct _EggListBoxChildInfo {
- GTypeInstance parent_instance;
- volatile int ref_count;
- EggListBoxChildInfoPrivate * priv;
- GtkWidget* widget;
- GtkWidget* separator;
- GSequenceIter* iter;
- gint y;
- gint height;
-};
+ gboolean active_child_active;
+ EggListBoxChildInfo *active_child;
-struct _EggListBoxChildInfoClass {
- GTypeClass parent_class;
- void (*finalize) (EggListBoxChildInfo *self);
-};
+ GtkSelectionMode selection_mode;
-struct _EggListBoxChildFlags {
- EggListBoxChildInfo* child;
- GtkStateFlags state;
-};
+ GtkAdjustment *adjustment;
+ gboolean activate_single_click;
-struct _EggListBoxParamSpecChildInfo {
- GParamSpec parent_instance;
+ /* DnD */
+ GtkWidget *drag_highlighted_widget;
+ guint auto_scroll_timeout_id;
};
+struct _EggListBoxChildInfo
+{
+ GSequenceIter *iter;
+ GtkWidget *widget;
+ GtkWidget *separator;
+ gint y;
+ gint height;
+};
-static gpointer egg_list_box_parent_class = NULL;
-static void* klass;
-static gpointer egg_list_box_child_info_parent_class = NULL;
-
-GType egg_list_box_get_type (void) G_GNUC_CONST;
-static gpointer egg_list_box_child_info_ref (gpointer instance);
-static void egg_list_box_child_info_unref (gpointer instance);
-static GParamSpec* egg_list_box_param_spec_child_info (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) G_GNUC_UNUSED;
-static void egg_list_box_value_set_child_info (GValue* value, gpointer v_object) G_GNUC_UNUSED;
-static void egg_list_box_value_take_child_info (GValue* value, gpointer v_object) G_GNUC_UNUSED;
-static gpointer egg_list_box_value_get_child_info (const GValue* value) G_GNUC_UNUSED;
-static GType egg_list_box_child_info_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
-#define EGG_LIST_BOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_LIST_BOX, EggListBoxPrivate))
-enum {
- EGG_LIST_BOX_DUMMY_PROPERTY
+enum {
+ CHILD_SELECTED,
+ CHILD_ACTIVATED,
+ ACTIVATE_CURSOR_CHILD,
+ TOGGLE_CURSOR_CHILD,
+ MOVE_CURSOR,
+ LAST_SIGNAL
};
-GtkWidget* egg_list_box_get_selected_child (EggListBox* self);
-GtkWidget* egg_list_box_get_child_at_y (EggListBox* self, gint y);
-static EggListBoxChildInfo* egg_list_box_find_child_at_y (EggListBox* self, gint y);
-void egg_list_box_select_child (EggListBox* self, GtkWidget* child);
-static EggListBoxChildInfo* egg_list_box_lookup_info (EggListBox* self, GtkWidget* widget);
-static void egg_list_box_update_selected (EggListBox* self, EggListBoxChildInfo* child);
-void egg_list_box_set_adjustment (EggListBox* self, GtkAdjustment* adjustment);
-void egg_list_box_add_to_scrolled (EggListBox* self, GtkScrolledWindow* scrolled);
-void egg_list_box_set_selection_mode (EggListBox* self, GtkSelectionMode mode);
-void egg_list_box_set_filter_func (EggListBox* self, EggListBoxFilterFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
-void egg_list_box_refilter (EggListBox* self);
-void egg_list_box_set_separator_funcs (EggListBox* self, EggListBoxUpdateSeparatorFunc update_separator, void* update_separator_target, GDestroyNotify update_separator_target_destroy_notify);
-void egg_list_box_reseparate (EggListBox* self);
-static void egg_list_box_apply_filter_all (EggListBox* self);
-void egg_list_box_resort (EggListBox* self);
-static gint egg_list_box_do_sort (EggListBox* self, EggListBoxChildInfo* a, EggListBoxChildInfo* b);
-static gint _egg_list_box_do_sort_gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self);
-static void egg_list_box_update_separator (EggListBox* self, GSequenceIter* iter);
-void egg_list_box_set_sort_func (EggListBox* self, GCompareDataFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
-void egg_list_box_child_changed (EggListBox* self, GtkWidget* widget);
-static GSequenceIter* egg_list_box_get_next_visible (EggListBox* self, GSequenceIter* _iter);
-static void egg_list_box_apply_filter (EggListBox* self, GtkWidget* child);
-void egg_list_box_set_activate_on_single_click (EggListBox* self, gboolean single);
-static void egg_list_box_add_move_binding (GtkBindingSet* binding_set, guint keyval, GdkModifierType modmask, GtkMovementStep step, gint count);
-static void egg_list_box_update_cursor (EggListBox* self, EggListBoxChildInfo* child);
-static void egg_list_box_select_and_activate (EggListBox* self, EggListBoxChildInfo* child);
-static void egg_list_box_update_prelight (EggListBox* self, EggListBoxChildInfo* child);
-static void egg_list_box_update_active (EggListBox* self, EggListBoxChildInfo* child);
-static gboolean egg_list_box_real_enter_notify_event (GtkWidget* base, GdkEventCrossing* event);
-static gboolean egg_list_box_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event);
-static gboolean egg_list_box_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
-static gboolean egg_list_box_real_button_press_event (GtkWidget* base, GdkEventButton* event);
-static gboolean egg_list_box_real_button_release_event (GtkWidget* base, GdkEventButton* event);
-static void egg_list_box_real_show (GtkWidget* base);
-static gboolean egg_list_box_real_focus (GtkWidget* base, GtkDirectionType direction);
-static GSequenceIter* egg_list_box_get_previous_visible (EggListBox* self, GSequenceIter* _iter);
-static EggListBoxChildInfo* egg_list_box_get_first_visible (EggListBox* self);
-static EggListBoxChildInfo* egg_list_box_get_last_visible (EggListBox* self);
-static gboolean egg_list_box_real_draw (GtkWidget* base, cairo_t* cr);
-static GType egg_list_box_child_flags_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
-static EggListBoxChildFlags* egg_list_box_child_flags_dup (const EggListBoxChildFlags* self);
-static void egg_list_box_child_flags_free (EggListBoxChildFlags* self);
-static EggListBoxChildFlags* egg_list_box_child_flags_find_or_add (EggListBoxChildFlags** array, int* array_length1, EggListBoxChildInfo* to_find);
-static void egg_list_box_real_realize (GtkWidget* base);
-static void egg_list_box_real_add (GtkContainer* base, GtkWidget* widget);
-static EggListBoxChildInfo* egg_list_box_child_info_new (GtkWidget* widget);
-static EggListBoxChildInfo* egg_list_box_child_info_construct (GType object_type, GtkWidget* widget);
-static void egg_list_box_child_visibility_changed (EggListBox* self, GObject* object, GParamSpec* pspec);
-static void _egg_list_box_child_visibility_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
-static void egg_list_box_real_remove (GtkContainer* base, GtkWidget* widget);
-static void egg_list_box_real_forall_internal (GtkContainer* base, gboolean include_internals, GtkCallback callback, void* callback_target);
-static void egg_list_box_real_compute_expand_internal (GtkWidget* base, gboolean* hexpand, gboolean* vexpand);
-static GType egg_list_box_real_child_type (GtkContainer* base);
-static GtkSizeRequestMode egg_list_box_real_get_request_mode (GtkWidget* base);
-static void egg_list_box_real_get_preferred_height (GtkWidget* base, gint* minimum_height, gint* natural_height);
-static void egg_list_box_real_get_preferred_height_for_width (GtkWidget* base, gint width, gint* minimum_height, gint* natural_height);
-static void egg_list_box_real_get_preferred_width (GtkWidget* base, gint* minimum_width, gint* natural_width);
-static void egg_list_box_real_get_preferred_width_for_height (GtkWidget* base, gint height, gint* minimum_width, gint* natural_width);
-static void egg_list_box_real_size_allocate (GtkWidget* base, GtkAllocation* allocation);
-EggListBox* egg_list_box_new (void);
-EggListBox* egg_list_box_construct (GType object_type);
-static void egg_list_box_real_child_selected (EggListBox* self, GtkWidget* child);
-static void egg_list_box_real_child_activated (EggListBox* self, GtkWidget* child);
-static void egg_list_box_real_activate_cursor_child (EggListBox* self);
-static void egg_list_box_real_toggle_cursor_child (EggListBox* self);
-static void egg_list_box_real_move_cursor (EggListBox* self, GtkMovementStep step, gint count);
-static void g_cclosure_user_marshal_VOID__ENUM_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
-static GObject * egg_list_box_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
-static void _egg_list_box_child_info_unref0_ (gpointer var);
+
enum {
- EGG_LIST_BOX_CHILD_INFO_DUMMY_PROPERTY
+ PROP_0
};
-static void egg_list_box_child_info_finalize (EggListBoxChildInfo* obj);
-static void egg_list_box_finalize (GObject* obj);
-
-
-GtkWidget* egg_list_box_get_selected_child (EggListBox* self) {
- GtkWidget* result = NULL;
- EggListBoxChildInfo* _tmp0_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = self->priv->selected_child;
- if (_tmp0_ != NULL) {
- EggListBoxChildInfo* _tmp1_;
- GtkWidget* _tmp2_;
- _tmp1_ = self->priv->selected_child;
- _tmp2_ = _tmp1_->widget;
- result = _tmp2_;
- return result;
- }
- result = NULL;
- return result;
-}
-
-
-GtkWidget* egg_list_box_get_child_at_y (EggListBox* self, gint y) {
- GtkWidget* result = NULL;
- gint _tmp0_;
- EggListBoxChildInfo* _tmp1_ = NULL;
- EggListBoxChildInfo* child;
- EggListBoxChildInfo* _tmp2_;
- EggListBoxChildInfo* _tmp3_;
- GtkWidget* _tmp4_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = y;
- _tmp1_ = egg_list_box_find_child_at_y (self, _tmp0_);
- child = _tmp1_;
- _tmp2_ = child;
- if (_tmp2_ == NULL) {
- result = NULL;
- return result;
- }
- _tmp3_ = child;
- _tmp4_ = _tmp3_->widget;
- result = _tmp4_;
- return result;
-}
-
-
-void egg_list_box_select_child (EggListBox* self, GtkWidget* child) {
- EggListBoxChildInfo* info;
- GtkWidget* _tmp0_;
- EggListBoxChildInfo* _tmp3_;
- g_return_if_fail (self != NULL);
- info = NULL;
- _tmp0_ = child;
- if (_tmp0_ != NULL) {
- GtkWidget* _tmp1_;
- EggListBoxChildInfo* _tmp2_ = NULL;
- _tmp1_ = child;
- _tmp2_ = egg_list_box_lookup_info (self, _tmp1_);
- info = _tmp2_;
- }
- _tmp3_ = info;
- egg_list_box_update_selected (self, _tmp3_);
-}
-
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
-}
+G_DEFINE_TYPE (EggListBox, egg_list_box, GTK_TYPE_CONTAINER)
+
+static EggListBoxChildInfo *egg_list_box_find_child_at_y (EggListBox *list_box,
+ gint y);
+static EggListBoxChildInfo *egg_list_box_lookup_info (EggListBox *list_box,
+ GtkWidget *widget);
+static void egg_list_box_update_selected (EggListBox *list_box,
+ EggListBoxChildInfo *child);
+static void egg_list_box_apply_filter_all (EggListBox *list_box);
+static void egg_list_box_update_separator (EggListBox *list_box,
+ GSequenceIter *iter);
+static GSequenceIter * egg_list_box_get_next_visible (EggListBox *list_box,
+ GSequenceIter *_iter);
+static void egg_list_box_apply_filter (EggListBox *list_box,
+ GtkWidget *child);
+static void egg_list_box_add_move_binding (GtkBindingSet *binding_set,
+ guint keyval,
+ GdkModifierType modmask,
+ GtkMovementStep step,
+ gint count);
+static void egg_list_box_update_cursor (EggListBox *list_box,
+ EggListBoxChildInfo *child);
+static void egg_list_box_select_and_activate (EggListBox *list_box,
+ EggListBoxChildInfo *child);
+static void egg_list_box_update_prelight (EggListBox *list_box,
+ EggListBoxChildInfo *child);
+static void egg_list_box_update_active (EggListBox *list_box,
+ EggListBoxChildInfo *child);
+static gboolean egg_list_box_real_enter_notify_event (GtkWidget *widget,
+ GdkEventCrossing *event);
+static gboolean egg_list_box_real_leave_notify_event (GtkWidget *widget,
+ GdkEventCrossing *event);
+static gboolean egg_list_box_real_motion_notify_event (GtkWidget *widget,
+ GdkEventMotion *event);
+static gboolean egg_list_box_real_button_press_event (GtkWidget *widget,
+ GdkEventButton *event);
+static gboolean egg_list_box_real_button_release_event (GtkWidget *widget,
+ GdkEventButton *event);
+static void egg_list_box_real_show (GtkWidget *widget);
+static gboolean egg_list_box_real_focus (GtkWidget *widget,
+ GtkDirectionType direction);
+static GSequenceIter* egg_list_box_get_previous_visible (EggListBox *list_box,
+ GSequenceIter *_iter);
+static EggListBoxChildInfo *egg_list_box_get_first_visible (EggListBox *list_box);
+static EggListBoxChildInfo *egg_list_box_get_last_visible (EggListBox *list_box);
+static gboolean egg_list_box_real_draw (GtkWidget *widget,
+ cairo_t *cr);
+static void egg_list_box_real_realize (GtkWidget *widget);
+static void egg_list_box_real_add (GtkContainer *container,
+ GtkWidget *widget);
+static void egg_list_box_real_remove (GtkContainer *container,
+ GtkWidget *widget);
+static void egg_list_box_real_forall_internal (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ void *callback_target);
+static void egg_list_box_real_compute_expand_internal (GtkWidget *widget,
+ gboolean *hexpand,
+ gboolean *vexpand);
+static GType egg_list_box_real_child_type (GtkContainer *container);
+static GtkSizeRequestMode egg_list_box_real_get_request_mode (GtkWidget *widget);
+static void egg_list_box_real_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static void egg_list_box_real_drag_leave (GtkWidget *widget,
+ GdkDragContext *context,
+ guint time_);
+static gboolean egg_list_box_real_drag_motion (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint time_);
+static void egg_list_box_real_activate_cursor_child (EggListBox *list_box);
+static void egg_list_box_real_toggle_cursor_child (EggListBox *list_box);
+static void egg_list_box_real_move_cursor (EggListBox *list_box,
+ GtkMovementStep step,
+ gint count);
+static void egg_list_box_finalize (GObject *obj);
+
+
+static void egg_list_box_real_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+static void egg_list_box_real_get_preferred_height_for_width (GtkWidget *widget,
+ gint width,
+ gint *minimum_height,
+ gint *natural_height);
+static void egg_list_box_real_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void egg_list_box_real_get_preferred_width_for_height (GtkWidget *widget,
+ gint height,
+ gint *minimum_width,
+ gint *natural_width);
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static EggListBoxChildInfo*
+egg_list_box_child_info_new (GtkWidget *widget)
+{
+ EggListBoxChildInfo *info;
+
+ info = g_new0 (EggListBoxChildInfo, 1);
+ info->widget = g_object_ref (widget);
+ return info;
+}
+
+static void
+egg_list_box_child_info_free (EggListBoxChildInfo *info)
+{
+ g_clear_object (&info->widget);
+ g_clear_object (&info->separator);
+ g_free (info);
+}
+
+EggListBox*
+egg_list_box_new (void)
+{
+ return g_object_new (EGG_TYPE_LIST_BOX, NULL);
+}
+
+static void
+egg_list_box_init (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv;
+
+ list_box->priv = priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (list_box, EGG_TYPE_LIST_BOX, EggListBoxPrivate);
+
+ gtk_widget_set_can_focus (GTK_WIDGET (list_box), TRUE);
+ gtk_widget_set_has_window (GTK_WIDGET (list_box), TRUE);
+ gtk_widget_set_redraw_on_allocate (GTK_WIDGET (list_box), TRUE);
+ priv->selection_mode = GTK_SELECTION_SINGLE;
+ priv->activate_single_click = TRUE;
+
+ priv->children = g_sequence_new ((GDestroyNotify)egg_list_box_child_info_free);
+ priv->child_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
+ priv->separator_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, NULL);
+}
+
+static void
+egg_list_box_finalize (GObject *obj)
+{
+ EggListBox *list_box = EGG_LIST_BOX (obj);
+ EggListBoxPrivate *priv = list_box->priv;
+
+ if (priv->auto_scroll_timeout_id != ((guint) 0))
+ g_source_remove (priv->auto_scroll_timeout_id);
+
+ if (priv->sort_func_target_destroy_notify != NULL)
+ priv->sort_func_target_destroy_notify (priv->sort_func_target);
+ if (priv->filter_func_target_destroy_notify != NULL)
+ priv->filter_func_target_destroy_notify (priv->filter_func_target);
+ if (priv->update_separator_func_target_destroy_notify != NULL)
+ priv->update_separator_func_target_destroy_notify (priv->update_separator_func_target);
+
+ g_clear_object (&priv->adjustment);
+ g_clear_object (&priv->drag_highlighted_widget);
+
+ g_sequence_free (priv->children);
+ g_hash_table_unref (priv->child_hash);
+ g_hash_table_unref (priv->separator_hash);
+
+ G_OBJECT_CLASS (egg_list_box_parent_class)->finalize (obj);
+}
+
+static void
+egg_list_box_class_init (EggListBoxClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+ GtkBindingSet *binding_set;
+
+ egg_list_box_parent_class = g_type_class_peek_parent (klass);
+
+ g_type_class_add_private (klass, sizeof (EggListBoxPrivate));
+
+ object_class->finalize = egg_list_box_finalize;
+ widget_class->enter_notify_event = egg_list_box_real_enter_notify_event;
+ widget_class->leave_notify_event = egg_list_box_real_leave_notify_event;
+ widget_class->motion_notify_event = egg_list_box_real_motion_notify_event;
+ widget_class->button_press_event = egg_list_box_real_button_press_event;
+ widget_class->button_release_event = egg_list_box_real_button_release_event;
+ widget_class->show = egg_list_box_real_show;
+ widget_class->focus = egg_list_box_real_focus;
+ widget_class->draw = egg_list_box_real_draw;
+ widget_class->realize = egg_list_box_real_realize;
+ widget_class->compute_expand = egg_list_box_real_compute_expand_internal;
+ widget_class->get_request_mode = egg_list_box_real_get_request_mode;
+ widget_class->get_preferred_height = egg_list_box_real_get_preferred_height;
+ widget_class->get_preferred_height_for_width = egg_list_box_real_get_preferred_height_for_width;
+ widget_class->get_preferred_width = egg_list_box_real_get_preferred_width;
+ widget_class->get_preferred_width_for_height = egg_list_box_real_get_preferred_width_for_height;
+ widget_class->size_allocate = egg_list_box_real_size_allocate;
+ widget_class->drag_leave = egg_list_box_real_drag_leave;
+ widget_class->drag_motion = egg_list_box_real_drag_motion;
+ container_class->add = egg_list_box_real_add;
+ container_class->remove = egg_list_box_real_remove;
+ container_class->forall = egg_list_box_real_forall_internal;
+ container_class->child_type = egg_list_box_real_child_type;
+ klass->activate_cursor_child = egg_list_box_real_activate_cursor_child;
+ klass->toggle_cursor_child = egg_list_box_real_toggle_cursor_child;
+ klass->move_cursor = egg_list_box_real_move_cursor;
+
+ signals[CHILD_SELECTED] =
+ g_signal_new ("child-selected",
+ EGG_TYPE_LIST_BOX,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggListBoxClass, child_selected),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_WIDGET);
+ signals[CHILD_ACTIVATED] =
+ g_signal_new ("child-activated",
+ EGG_TYPE_LIST_BOX,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggListBoxClass, child_activated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_WIDGET);
+ signals[ACTIVATE_CURSOR_CHILD] =
+ g_signal_new ("activate-cursor-child",
+ EGG_TYPE_LIST_BOX,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EggListBoxClass, activate_cursor_child),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ signals[TOGGLE_CURSOR_CHILD] =
+ g_signal_new ("toggle-cursor-child",
+ EGG_TYPE_LIST_BOX,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EggListBoxClass, toggle_cursor_child),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ signals[MOVE_CURSOR] =
+ g_signal_new ("move-cursor",
+ EGG_TYPE_LIST_BOX,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EggListBoxClass, move_cursor),
+ NULL, NULL,
+ _egg_marshal_VOID__ENUM_INT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT);
+
+ widget_class->activate_signal = signals[ACTIVATE_CURSOR_CHILD];
+
+ binding_set = gtk_binding_set_by_class (klass);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_Home, 0,
+ GTK_MOVEMENT_BUFFER_ENDS, -1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_KP_Home, 0,
+ GTK_MOVEMENT_BUFFER_ENDS, -1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_End, 0,
+ GTK_MOVEMENT_BUFFER_ENDS, 1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_KP_End, 0,
+ GTK_MOVEMENT_BUFFER_ENDS, 1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_DISPLAY_LINES, -1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_KP_Up, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_DISPLAY_LINES, -1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_DISPLAY_LINES, 1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_KP_Down, GDK_CONTROL_MASK,
+ GTK_MOVEMENT_DISPLAY_LINES, 1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_Page_Up, 0,
+ GTK_MOVEMENT_PAGES, -1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
+ GTK_MOVEMENT_PAGES, -1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_Page_Down, 0,
+ GTK_MOVEMENT_PAGES, 1);
+ egg_list_box_add_move_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
+ GTK_MOVEMENT_PAGES, 1);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_space, GDK_CONTROL_MASK,
+ "toggle-cursor-child", 0, NULL);
+}
+
+GtkWidget *
+egg_list_box_get_selected_child (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+
+ g_return_val_if_fail (list_box != NULL, NULL);
+
+ if (priv->selected_child != NULL)
+ return priv->selected_child->widget;
+
+ return NULL;
+}
+
+GtkWidget *
+egg_list_box_get_child_at_y (EggListBox *list_box, gint y)
+{
+ EggListBoxChildInfo *child;
+
+ g_return_val_if_fail (list_box != NULL, NULL);
+
+ child = egg_list_box_find_child_at_y (list_box, y);
+ if (child == NULL)
+ return NULL;
+
+ return child->widget;
+}
+
+
+void
+egg_list_box_select_child (EggListBox *list_box, GtkWidget *child)
+{
+ EggListBoxChildInfo *info = NULL;
+
+ g_return_if_fail (list_box != NULL);
+
+ if (child != NULL)
+ info = egg_list_box_lookup_info (list_box, child);
+
+ egg_list_box_update_selected (list_box, info);
+}
+
+void
+egg_list_box_set_adjustment (EggListBox *list_box,
+ GtkAdjustment *adjustment)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ g_return_if_fail (list_box != NULL);
-void egg_list_box_set_adjustment (EggListBox* self, GtkAdjustment* adjustment) {
- GtkAdjustment* _tmp0_;
- GtkAdjustment* _tmp1_;
- GtkAdjustment* _tmp2_;
- g_return_if_fail (self != NULL);
- _tmp0_ = adjustment;
- _tmp1_ = _g_object_ref0 (_tmp0_);
- _g_object_unref0 (self->priv->adjustment);
- self->priv->adjustment = _tmp1_;
- _tmp2_ = adjustment;
- gtk_container_set_focus_vadjustment ((GtkContainer*) self, _tmp2_);
+ g_object_ref (adjustment);
+ if (priv->adjustment)
+ g_object_unref (priv->adjustment);
+ priv->adjustment = adjustment;
+ gtk_container_set_focus_vadjustment (GTK_CONTAINER (list_box),
+ adjustment);
}
+void
+egg_list_box_add_to_scrolled (EggListBox *list_box,
+ GtkScrolledWindow *scrolled)
+{
+ g_return_if_fail (list_box != NULL);
+ g_return_if_fail (scrolled != NULL);
-void egg_list_box_add_to_scrolled (EggListBox* self, GtkScrolledWindow* scrolled) {
- GtkScrolledWindow* _tmp0_;
- GtkScrolledWindow* _tmp1_;
- GtkAdjustment* _tmp2_ = NULL;
- g_return_if_fail (self != NULL);
- g_return_if_fail (scrolled != NULL);
- _tmp0_ = scrolled;
- gtk_scrolled_window_add_with_viewport (_tmp0_, (GtkWidget*) self);
- _tmp1_ = scrolled;
- _tmp2_ = gtk_scrolled_window_get_vadjustment (_tmp1_);
- egg_list_box_set_adjustment (self, _tmp2_);
+ gtk_scrolled_window_add_with_viewport (scrolled,
+ GTK_WIDGET (list_box));
+ egg_list_box_set_adjustment (list_box,
+ gtk_scrolled_window_get_vadjustment (scrolled));
}
-void egg_list_box_set_selection_mode (EggListBox* self, GtkSelectionMode mode) {
- GtkSelectionMode _tmp0_;
- GtkSelectionMode _tmp1_;
- GtkSelectionMode _tmp2_;
- g_return_if_fail (self != NULL);
- _tmp0_ = mode;
- if (_tmp0_ == GTK_SELECTION_MULTIPLE) {
- g_warning ("egg-list-box.vala:106: Multiple selections not supported");
- return;
- }
- _tmp1_ = mode;
- self->priv->selection_mode = _tmp1_;
- _tmp2_ = mode;
- if (_tmp2_ == GTK_SELECTION_NONE) {
- egg_list_box_update_selected (self, NULL);
- }
-}
+void
+egg_list_box_set_selection_mode (EggListBox *list_box, GtkSelectionMode mode)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ g_return_if_fail (list_box != NULL);
-void egg_list_box_set_filter_func (EggListBox* self, EggListBoxFilterFunc f, void* f_target, GDestroyNotify f_target_destroy_notify) {
- EggListBoxFilterFunc _tmp0_;
- void* _tmp0__target;
- GDestroyNotify _tmp0__target_destroy_notify;
- g_return_if_fail (self != NULL);
- _tmp0_ = f;
- _tmp0__target = f_target;
- _tmp0__target_destroy_notify = f_target_destroy_notify;
- f_target_destroy_notify = NULL;
- (self->priv->filter_func_target_destroy_notify == NULL) ? NULL : (self->priv->filter_func_target_destroy_notify (self->priv->filter_func_target), NULL);
- self->priv->filter_func = NULL;
- self->priv->filter_func_target = NULL;
- self->priv->filter_func_target_destroy_notify = NULL;
- self->priv->filter_func = _tmp0_;
- self->priv->filter_func_target = _tmp0__target;
- self->priv->filter_func_target_destroy_notify = _tmp0__target_destroy_notify;
- egg_list_box_refilter (self);
- (f_target_destroy_notify == NULL) ? NULL : (f_target_destroy_notify (f_target), NULL);
- f = NULL;
- f_target = NULL;
- f_target_destroy_notify = NULL;
-}
-
-
-void egg_list_box_set_separator_funcs (EggListBox* self, EggListBoxUpdateSeparatorFunc update_separator, void* update_separator_target, GDestroyNotify update_separator_target_destroy_notify) {
- EggListBoxUpdateSeparatorFunc _tmp0_;
- void* _tmp0__target;
- GDestroyNotify _tmp0__target_destroy_notify;
- g_return_if_fail (self != NULL);
- _tmp0_ = update_separator;
- _tmp0__target = update_separator_target;
- _tmp0__target_destroy_notify = update_separator_target_destroy_notify;
- update_separator_target_destroy_notify = NULL;
- (self->priv->update_separator_func_target_destroy_notify == NULL) ? NULL : (self->priv->update_separator_func_target_destroy_notify (self->priv->update_separator_func_target), NULL);
- self->priv->update_separator_func = NULL;
- self->priv->update_separator_func_target = NULL;
- self->priv->update_separator_func_target_destroy_notify = NULL;
- self->priv->update_separator_func = _tmp0_;
- self->priv->update_separator_func_target = _tmp0__target;
- self->priv->update_separator_func_target_destroy_notify = _tmp0__target_destroy_notify;
- egg_list_box_reseparate (self);
- (update_separator_target_destroy_notify == NULL) ? NULL : (update_separator_target_destroy_notify (update_separator_target), NULL);
- update_separator = NULL;
- update_separator_target = NULL;
- update_separator_target_destroy_notify = NULL;
-}
-
-
-void egg_list_box_refilter (EggListBox* self) {
- g_return_if_fail (self != NULL);
- egg_list_box_apply_filter_all (self);
- egg_list_box_reseparate (self);
- gtk_widget_queue_resize ((GtkWidget*) self);
-}
-
-
-static gint _egg_list_box_do_sort_gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self) {
- gint result;
- result = egg_list_box_do_sort (self, a, b);
- return result;
-}
-
-
-void egg_list_box_resort (EggListBox* self) {
- GSequence* _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = self->priv->children;
- g_sequence_sort (_tmp0_, _egg_list_box_do_sort_gcompare_data_func, self);
- egg_list_box_reseparate (self);
- gtk_widget_queue_resize ((GtkWidget*) self);
-}
-
-
-void egg_list_box_reseparate (EggListBox* self) {
- g_return_if_fail (self != NULL);
- {
- GSequence* _tmp0_;
- GSequenceIter* _tmp1_ = NULL;
- GSequenceIter* iter;
- _tmp0_ = self->priv->children;
- _tmp1_ = g_sequence_get_begin_iter (_tmp0_);
- iter = _tmp1_;
- {
- gboolean _tmp2_;
- _tmp2_ = TRUE;
- while (TRUE) {
- gboolean _tmp3_;
- GSequenceIter* _tmp6_;
- gboolean _tmp7_ = FALSE;
- GSequenceIter* _tmp8_;
- _tmp3_ = _tmp2_;
- if (!_tmp3_) {
- GSequenceIter* _tmp4_;
- GSequenceIter* _tmp5_ = NULL;
- _tmp4_ = iter;
- _tmp5_ = g_sequence_iter_next (_tmp4_);
- iter = _tmp5_;
- }
- _tmp2_ = FALSE;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_is_end (_tmp6_);
- if (!(!_tmp7_)) {
- break;
- }
- _tmp8_ = iter;
- egg_list_box_update_separator (self, _tmp8_);
- }
- }
- }
- gtk_widget_queue_resize ((GtkWidget*) self);
-}
-
-
-void egg_list_box_set_sort_func (EggListBox* self, GCompareDataFunc f, void* f_target, GDestroyNotify f_target_destroy_notify) {
- GCompareDataFunc _tmp0_;
- void* _tmp0__target;
- GDestroyNotify _tmp0__target_destroy_notify;
- g_return_if_fail (self != NULL);
- _tmp0_ = f;
- _tmp0__target = f_target;
- _tmp0__target_destroy_notify = f_target_destroy_notify;
- f_target_destroy_notify = NULL;
- (self->priv->sort_func_target_destroy_notify == NULL) ? NULL : (self->priv->sort_func_target_destroy_notify (self->priv->sort_func_target), NULL);
- self->priv->sort_func = NULL;
- self->priv->sort_func_target = NULL;
- self->priv->sort_func_target_destroy_notify = NULL;
- self->priv->sort_func = _tmp0_;
- self->priv->sort_func_target = _tmp0__target;
- self->priv->sort_func_target_destroy_notify = _tmp0__target_destroy_notify;
- egg_list_box_resort (self);
- (f_target_destroy_notify == NULL) ? NULL : (f_target_destroy_notify (f_target), NULL);
- f = NULL;
- f_target = NULL;
- f_target_destroy_notify = NULL;
-}
-
-
-void egg_list_box_child_changed (EggListBox* self, GtkWidget* widget) {
- GtkWidget* _tmp0_;
- EggListBoxChildInfo* _tmp1_ = NULL;
- EggListBoxChildInfo* info;
- EggListBoxChildInfo* _tmp2_;
- EggListBoxChildInfo* _tmp3_;
- GSequenceIter* _tmp4_;
- GSequenceIter* _tmp5_ = NULL;
- GSequenceIter* prev_next;
- GCompareDataFunc _tmp6_;
- void* _tmp6__target;
- EggListBoxChildInfo* _tmp10_;
- GtkWidget* _tmp11_;
- gboolean _tmp12_ = FALSE;
- g_return_if_fail (self != NULL);
- g_return_if_fail (widget != NULL);
- _tmp0_ = widget;
- _tmp1_ = egg_list_box_lookup_info (self, _tmp0_);
- info = _tmp1_;
- _tmp2_ = info;
- if (_tmp2_ == NULL) {
- return;
- }
- _tmp3_ = info;
- _tmp4_ = _tmp3_->iter;
- _tmp5_ = egg_list_box_get_next_visible (self, _tmp4_);
- prev_next = _tmp5_;
- _tmp6_ = self->priv->sort_func;
- _tmp6__target = self->priv->sort_func_target;
- if (_tmp6_ != NULL) {
- GSequence* _tmp7_;
- EggListBoxChildInfo* _tmp8_;
- GSequenceIter* _tmp9_;
- _tmp7_ = self->priv->children;
- _tmp8_ = info;
- _tmp9_ = _tmp8_->iter;
- g_sequence_sort_changed (_tmp9_, _egg_list_box_do_sort_gcompare_data_func, self);
- gtk_widget_queue_resize ((GtkWidget*) self);
- }
- _tmp10_ = info;
- _tmp11_ = _tmp10_->widget;
- egg_list_box_apply_filter (self, _tmp11_);
- _tmp12_ = gtk_widget_get_visible ((GtkWidget*) self);
- if (_tmp12_) {
- EggListBoxChildInfo* _tmp13_;
- GSequenceIter* _tmp14_;
- EggListBoxChildInfo* _tmp15_;
- GSequenceIter* _tmp16_;
- GSequenceIter* _tmp17_ = NULL;
- GSequenceIter* _tmp18_;
- _tmp13_ = info;
- _tmp14_ = _tmp13_->iter;
- egg_list_box_update_separator (self, _tmp14_);
- _tmp15_ = info;
- _tmp16_ = _tmp15_->iter;
- _tmp17_ = egg_list_box_get_next_visible (self, _tmp16_);
- egg_list_box_update_separator (self, _tmp17_);
- _tmp18_ = prev_next;
- egg_list_box_update_separator (self, _tmp18_);
- }
-}
-
+ if (mode == GTK_SELECTION_MULTIPLE)
+ {
+ g_warning ("egg-list-box.vala:115: Multiple selections not supported");
+ return;
+ }
-void egg_list_box_set_activate_on_single_click (EggListBox* self, gboolean single) {
- gboolean _tmp0_;
- g_return_if_fail (self != NULL);
- _tmp0_ = single;
- self->priv->activate_single_click = _tmp0_;
-}
-
-
-/****** Implementation ***********/
-static gint egg_list_box_do_sort (EggListBox* self, EggListBoxChildInfo* a, EggListBoxChildInfo* b) {
- gint result = 0;
- GCompareDataFunc _tmp0_;
- void* _tmp0__target;
- EggListBoxChildInfo* _tmp1_;
- GtkWidget* _tmp2_;
- EggListBoxChildInfo* _tmp3_;
- GtkWidget* _tmp4_;
- gint _tmp5_ = 0;
- g_return_val_if_fail (self != NULL, 0);
- g_return_val_if_fail (a != NULL, 0);
- g_return_val_if_fail (b != NULL, 0);
- _tmp0_ = self->priv->sort_func;
- _tmp0__target = self->priv->sort_func_target;
- _tmp1_ = a;
- _tmp2_ = _tmp1_->widget;
- _tmp3_ = b;
- _tmp4_ = _tmp3_->widget;
- _tmp5_ = _tmp0_ (_tmp2_, _tmp4_, _tmp0__target);
- result = _tmp5_;
- return result;
-}
-
-
-static void egg_list_box_add_move_binding (GtkBindingSet* binding_set, guint keyval, GdkModifierType modmask, GtkMovementStep step, gint count) {
- GtkBindingSet* _tmp0_;
- guint _tmp1_;
- GdkModifierType _tmp2_;
- GtkMovementStep _tmp3_;
- gint _tmp4_;
- GdkModifierType _tmp5_;
- GtkBindingSet* _tmp6_;
- guint _tmp7_;
- GtkMovementStep _tmp8_;
- gint _tmp9_;
- g_return_if_fail (binding_set != NULL);
- _tmp0_ = binding_set;
- _tmp1_ = keyval;
- _tmp2_ = modmask;
- _tmp3_ = step;
- _tmp4_ = count;
- gtk_binding_entry_add_signal (_tmp0_, _tmp1_, _tmp2_, "move-cursor", (guint) 2, GTK_TYPE_MOVEMENT_STEP, _tmp3_, G_TYPE_INT, _tmp4_, NULL);
- _tmp5_ = modmask;
- if ((_tmp5_ & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) {
- return;
- }
- _tmp6_ = binding_set;
- _tmp7_ = keyval;
- _tmp8_ = step;
- _tmp9_ = count;
- gtk_binding_entry_add_signal (_tmp6_, _tmp7_, GDK_CONTROL_MASK, "move-cursor", (guint) 2, GTK_TYPE_MOVEMENT_STEP, _tmp8_, G_TYPE_INT, _tmp9_, NULL);
+ priv->selection_mode = mode;
+ if (mode == GTK_SELECTION_NONE)
+ egg_list_box_update_selected (list_box, NULL);
}
-static EggListBoxChildInfo* egg_list_box_find_child_at_y (EggListBox* self, gint y) {
- EggListBoxChildInfo* result = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp21_;
- g_return_val_if_fail (self != NULL, NULL);
- child_info = NULL;
- {
- GSequence* _tmp0_;
- GSequenceIter* _tmp1_ = NULL;
- GSequenceIter* iter;
- _tmp0_ = self->priv->children;
- _tmp1_ = g_sequence_get_begin_iter (_tmp0_);
- iter = _tmp1_;
- {
- gboolean _tmp2_;
- _tmp2_ = TRUE;
- while (TRUE) {
- gboolean _tmp3_;
- GSequenceIter* _tmp6_;
- gboolean _tmp7_ = FALSE;
- GSequenceIter* _tmp8_;
- gconstpointer _tmp9_ = NULL;
- EggListBoxChildInfo* info;
- gboolean _tmp10_ = FALSE;
- gint _tmp11_;
- EggListBoxChildInfo* _tmp12_;
- gint _tmp13_;
- gboolean _tmp19_;
- _tmp3_ = _tmp2_;
- if (!_tmp3_) {
- GSequenceIter* _tmp4_;
- GSequenceIter* _tmp5_ = NULL;
- _tmp4_ = iter;
- _tmp5_ = g_sequence_iter_next (_tmp4_);
- iter = _tmp5_;
- }
- _tmp2_ = FALSE;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_is_end (_tmp6_);
- if (!(!_tmp7_)) {
- break;
- }
- _tmp8_ = iter;
- _tmp9_ = g_sequence_get (_tmp8_);
- info = (EggListBoxChildInfo*) _tmp9_;
- _tmp11_ = y;
- _tmp12_ = info;
- _tmp13_ = _tmp12_->y;
- if (_tmp11_ >= _tmp13_) {
- gint _tmp14_;
- EggListBoxChildInfo* _tmp15_;
- gint _tmp16_;
- EggListBoxChildInfo* _tmp17_;
- gint _tmp18_;
- _tmp14_ = y;
- _tmp15_ = info;
- _tmp16_ = _tmp15_->y;
- _tmp17_ = info;
- _tmp18_ = _tmp17_->height;
- _tmp10_ = _tmp14_ < (_tmp16_ + _tmp18_);
- } else {
- _tmp10_ = FALSE;
- }
- _tmp19_ = _tmp10_;
- if (_tmp19_) {
- EggListBoxChildInfo* _tmp20_;
- _tmp20_ = info;
- child_info = _tmp20_;
- break;
- }
- }
- }
- }
- _tmp21_ = child_info;
- result = _tmp21_;
- return result;
-}
-
-
-static void egg_list_box_update_cursor (EggListBox* self, EggListBoxChildInfo* child) {
- EggListBoxChildInfo* _tmp0_;
- gboolean _tmp1_ = FALSE;
- EggListBoxChildInfo* _tmp2_;
- gboolean _tmp4_;
- g_return_if_fail (self != NULL);
- _tmp0_ = child;
- self->priv->cursor_child = _tmp0_;
- gtk_widget_grab_focus ((GtkWidget*) self);
- gtk_widget_queue_draw ((GtkWidget*) self);
- _tmp2_ = child;
- if (_tmp2_ != NULL) {
- GtkAdjustment* _tmp3_;
- _tmp3_ = self->priv->adjustment;
- _tmp1_ = _tmp3_ != NULL;
- } else {
- _tmp1_ = FALSE;
- }
- _tmp4_ = _tmp1_;
- if (_tmp4_) {
- GtkAllocation allocation = {0};
- GtkAllocation _tmp5_ = {0};
- GtkAdjustment* _tmp6_;
- EggListBoxChildInfo* _tmp7_;
- gint _tmp8_;
- GtkAllocation _tmp9_;
- gint _tmp10_;
- EggListBoxChildInfo* _tmp11_;
- gint _tmp12_;
- GtkAllocation _tmp13_;
- gint _tmp14_;
- EggListBoxChildInfo* _tmp15_;
- gint _tmp16_;
- gtk_widget_get_allocation ((GtkWidget*) self, &_tmp5_);
- allocation = _tmp5_;
- _tmp6_ = self->priv->adjustment;
- _tmp7_ = self->priv->cursor_child;
- _tmp8_ = _tmp7_->y;
- _tmp9_ = allocation;
- _tmp10_ = _tmp9_.y;
- _tmp11_ = self->priv->cursor_child;
- _tmp12_ = _tmp11_->y;
- _tmp13_ = allocation;
- _tmp14_ = _tmp13_.y;
- _tmp15_ = self->priv->cursor_child;
- _tmp16_ = _tmp15_->height;
- gtk_adjustment_clamp_page (_tmp6_, (gdouble) (_tmp8_ + _tmp10_), (gdouble) ((_tmp12_ + _tmp14_) + _tmp16_));
- }
-}
+void
+egg_list_box_set_filter_func (EggListBox *list_box,
+ EggListBoxFilterFunc f,
+ void *f_target,
+ GDestroyNotify f_target_destroy_notify)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ g_return_if_fail (list_box != NULL);
-static void egg_list_box_update_selected (EggListBox* self, EggListBoxChildInfo* child) {
- gboolean _tmp0_ = FALSE;
- EggListBoxChildInfo* _tmp1_;
- EggListBoxChildInfo* _tmp2_;
- gboolean _tmp7_;
- EggListBoxChildInfo* _tmp14_;
- g_return_if_fail (self != NULL);
- _tmp1_ = child;
- _tmp2_ = self->priv->selected_child;
- if (_tmp1_ != _tmp2_) {
- gboolean _tmp3_ = FALSE;
- EggListBoxChildInfo* _tmp4_;
- gboolean _tmp6_;
- _tmp4_ = child;
- if (_tmp4_ == NULL) {
- _tmp3_ = TRUE;
- } else {
- GtkSelectionMode _tmp5_;
- _tmp5_ = self->priv->selection_mode;
- _tmp3_ = _tmp5_ != GTK_SELECTION_NONE;
- }
- _tmp6_ = _tmp3_;
- _tmp0_ = _tmp6_;
- } else {
- _tmp0_ = FALSE;
- }
- _tmp7_ = _tmp0_;
- if (_tmp7_) {
- EggListBoxChildInfo* _tmp8_;
- GtkWidget* _tmp9_ = NULL;
- EggListBoxChildInfo* _tmp10_;
- GtkWidget* _tmp13_;
- _tmp8_ = child;
- self->priv->selected_child = _tmp8_;
- _tmp10_ = self->priv->selected_child;
- if (_tmp10_ != NULL) {
- EggListBoxChildInfo* _tmp11_;
- GtkWidget* _tmp12_;
- _tmp11_ = self->priv->selected_child;
- _tmp12_ = _tmp11_->widget;
- _tmp9_ = _tmp12_;
- } else {
- _tmp9_ = NULL;
- }
- _tmp13_ = _tmp9_;
- g_signal_emit_by_name (self, "child-selected", _tmp13_);
- gtk_widget_queue_draw ((GtkWidget*) self);
- }
- _tmp14_ = child;
- if (_tmp14_ != NULL) {
- EggListBoxChildInfo* _tmp15_;
- _tmp15_ = child;
- egg_list_box_update_cursor (self, _tmp15_);
- }
-}
+ if (priv->filter_func_target_destroy_notify != NULL)
+ priv->filter_func_target_destroy_notify (priv->filter_func_target);
+ priv->filter_func = f;
+ priv->filter_func_target = f_target;
+ priv->filter_func_target_destroy_notify = f_target_destroy_notify;
-static void egg_list_box_select_and_activate (EggListBox* self, EggListBoxChildInfo* child) {
- GtkWidget* w;
- EggListBoxChildInfo* _tmp0_;
- EggListBoxChildInfo* _tmp3_;
- GtkWidget* _tmp4_;
- g_return_if_fail (self != NULL);
- w = NULL;
- _tmp0_ = child;
- if (_tmp0_ != NULL) {
- EggListBoxChildInfo* _tmp1_;
- GtkWidget* _tmp2_;
- _tmp1_ = child;
- _tmp2_ = _tmp1_->widget;
- w = _tmp2_;
- }
- _tmp3_ = child;
- egg_list_box_update_selected (self, _tmp3_);
- _tmp4_ = w;
- if (_tmp4_ != NULL) {
- GtkWidget* _tmp5_;
- _tmp5_ = w;
- g_signal_emit_by_name (self, "child-activated", _tmp5_);
- }
+ egg_list_box_refilter (list_box);
}
+void
+egg_list_box_set_separator_funcs (EggListBox *list_box,
+ EggListBoxUpdateSeparatorFunc update_separator,
+ void *update_separator_target,
+ GDestroyNotify update_separator_target_destroy_notify)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_update_prelight (EggListBox* self, EggListBoxChildInfo* child) {
- EggListBoxChildInfo* _tmp0_;
- EggListBoxChildInfo* _tmp1_;
- g_return_if_fail (self != NULL);
- _tmp0_ = child;
- _tmp1_ = self->priv->prelight_child;
- if (_tmp0_ != _tmp1_) {
- EggListBoxChildInfo* _tmp2_;
- _tmp2_ = child;
- self->priv->prelight_child = _tmp2_;
- gtk_widget_queue_draw ((GtkWidget*) self);
- }
-}
+ g_return_if_fail (list_box != NULL);
+ if (priv->update_separator_func_target_destroy_notify != NULL)
+ priv->update_separator_func_target_destroy_notify (priv->update_separator_func_target);
-static void egg_list_box_update_active (EggListBox* self, EggListBoxChildInfo* child) {
- EggListBoxChildInfo* _tmp0_;
- EggListBoxChildInfo* _tmp1_;
- gboolean val;
- gboolean _tmp2_ = FALSE;
- EggListBoxChildInfo* _tmp3_;
- gboolean _tmp6_;
- g_return_if_fail (self != NULL);
- _tmp0_ = self->priv->active_child;
- _tmp1_ = child;
- val = _tmp0_ == _tmp1_;
- _tmp3_ = self->priv->active_child;
- if (_tmp3_ != NULL) {
- gboolean _tmp4_;
- gboolean _tmp5_;
- _tmp4_ = val;
- _tmp5_ = self->priv->active_child_active;
- _tmp2_ = _tmp4_ != _tmp5_;
- } else {
- _tmp2_ = FALSE;
- }
- _tmp6_ = _tmp2_;
- if (_tmp6_) {
- gboolean _tmp7_;
- _tmp7_ = val;
- self->priv->active_child_active = _tmp7_;
- gtk_widget_queue_draw ((GtkWidget*) self);
- }
+ priv->update_separator_func = update_separator;
+ priv->update_separator_func_target = update_separator_target;
+ priv->update_separator_func_target_destroy_notify = update_separator_target_destroy_notify;
+ egg_list_box_reseparate (list_box);
}
-
-static gboolean egg_list_box_real_enter_notify_event (GtkWidget* base, GdkEventCrossing* event) {
- EggListBox * self;
- gboolean result = FALSE;
- GdkEventCrossing _tmp0_;
- GdkWindow* _tmp1_;
- GdkWindow* _tmp2_ = NULL;
- GdkEventCrossing _tmp3_;
- gdouble _tmp4_;
- EggListBoxChildInfo* _tmp5_ = NULL;
- EggListBoxChildInfo* child;
- EggListBoxChildInfo* _tmp6_;
- EggListBoxChildInfo* _tmp7_;
- self = (EggListBox*) base;
- g_return_val_if_fail (event != NULL, FALSE);
- _tmp0_ = *event;
- _tmp1_ = _tmp0_.window;
- _tmp2_ = gtk_widget_get_window ((GtkWidget*) self);
- if (_tmp1_ != _tmp2_) {
- result = FALSE;
- return result;
- }
- _tmp3_ = *event;
- _tmp4_ = _tmp3_.y;
- _tmp5_ = egg_list_box_find_child_at_y (self, (gint) _tmp4_);
- child = _tmp5_;
- _tmp6_ = child;
- egg_list_box_update_prelight (self, _tmp6_);
- _tmp7_ = child;
- egg_list_box_update_active (self, _tmp7_);
- result = FALSE;
- return result;
-}
-
-
-static gboolean egg_list_box_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event) {
- EggListBox * self;
- gboolean result = FALSE;
- GdkEventCrossing _tmp0_;
- GdkWindow* _tmp1_;
- GdkWindow* _tmp2_ = NULL;
- EggListBoxChildInfo* child = NULL;
- GdkEventCrossing _tmp3_;
- GdkNotifyType _tmp4_;
- EggListBoxChildInfo* _tmp8_;
- EggListBoxChildInfo* _tmp9_;
- self = (EggListBox*) base;
- g_return_val_if_fail (event != NULL, FALSE);
- _tmp0_ = *event;
- _tmp1_ = _tmp0_.window;
- _tmp2_ = gtk_widget_get_window ((GtkWidget*) self);
- if (_tmp1_ != _tmp2_) {
- result = FALSE;
- return result;
- }
- _tmp3_ = *event;
- _tmp4_ = _tmp3_.detail;
- if (_tmp4_ != GDK_NOTIFY_INFERIOR) {
- child = NULL;
- } else {
- GdkEventCrossing _tmp5_;
- gdouble _tmp6_;
- EggListBoxChildInfo* _tmp7_ = NULL;
- _tmp5_ = *event;
- _tmp6_ = _tmp5_.y;
- _tmp7_ = egg_list_box_find_child_at_y (self, (gint) _tmp6_);
- child = _tmp7_;
- }
- _tmp8_ = child;
- egg_list_box_update_prelight (self, _tmp8_);
- _tmp9_ = child;
- egg_list_box_update_active (self, _tmp9_);
- result = FALSE;
- return result;
-}
-
-
-static gboolean egg_list_box_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
- EggListBox * self;
- gboolean result = FALSE;
- GdkEventMotion _tmp0_;
- gdouble _tmp1_;
- EggListBoxChildInfo* _tmp2_ = NULL;
- EggListBoxChildInfo* child;
- self = (EggListBox*) base;
- g_return_val_if_fail (event != NULL, FALSE);
- _tmp0_ = *event;
- _tmp1_ = _tmp0_.y;
- _tmp2_ = egg_list_box_find_child_at_y (self, (gint) _tmp1_);
- child = _tmp2_;
- egg_list_box_update_prelight (self, child);
- egg_list_box_update_active (self, child);
- result = FALSE;
- return result;
-}
-
-
-static gboolean egg_list_box_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
- EggListBox * self;
- gboolean result = FALSE;
- GdkEventButton _tmp0_;
- guint _tmp1_;
- self = (EggListBox*) base;
- g_return_val_if_fail (event != NULL, FALSE);
- _tmp0_ = *event;
- _tmp1_ = _tmp0_.button;
- if (_tmp1_ == ((guint) 1)) {
- GdkEventButton _tmp2_;
- gdouble _tmp3_;
- EggListBoxChildInfo* _tmp4_ = NULL;
- EggListBoxChildInfo* child;
- EggListBoxChildInfo* _tmp5_;
- _tmp2_ = *event;
- _tmp3_ = _tmp2_.y;
- _tmp4_ = egg_list_box_find_child_at_y (self, (gint) _tmp3_);
- child = _tmp4_;
- _tmp5_ = child;
- if (_tmp5_ != NULL) {
- EggListBoxChildInfo* _tmp6_;
- gboolean _tmp7_ = FALSE;
- gboolean _tmp8_ = FALSE;
- GdkEventButton _tmp9_;
- GdkEventType _tmp10_;
- gboolean _tmp12_;
- gboolean _tmp15_;
- _tmp6_ = child;
- self->priv->active_child = _tmp6_;
- self->priv->active_child_active = TRUE;
- gtk_widget_queue_draw ((GtkWidget*) self);
- _tmp9_ = *event;
- _tmp10_ = _tmp9_.type;
- if (_tmp10_ == GDK_2BUTTON_PRESS) {
- gboolean _tmp11_;
- _tmp11_ = self->priv->activate_single_click;
- _tmp8_ = !_tmp11_;
- } else {
- _tmp8_ = FALSE;
- }
- _tmp12_ = _tmp8_;
- if (_tmp12_) {
- EggListBoxChildInfo* _tmp13_;
- GtkWidget* _tmp14_;
- _tmp13_ = child;
- _tmp14_ = _tmp13_->widget;
- _tmp7_ = _tmp14_ != NULL;
- } else {
- _tmp7_ = FALSE;
- }
- _tmp15_ = _tmp7_;
- if (_tmp15_) {
- EggListBoxChildInfo* _tmp16_;
- GtkWidget* _tmp17_;
- _tmp16_ = child;
- _tmp17_ = _tmp16_->widget;
- g_signal_emit_by_name (self, "child-activated", _tmp17_);
- }
- }
- }
- result = FALSE;
- return result;
-}
-
-
-static gboolean egg_list_box_real_button_release_event (GtkWidget* base, GdkEventButton* event) {
- EggListBox * self;
- gboolean result = FALSE;
- GdkEventButton _tmp0_;
- guint _tmp1_;
- self = (EggListBox*) base;
- g_return_val_if_fail (event != NULL, FALSE);
- _tmp0_ = *event;
- _tmp1_ = _tmp0_.button;
- if (_tmp1_ == ((guint) 1)) {
- gboolean _tmp2_ = FALSE;
- EggListBoxChildInfo* _tmp3_;
- gboolean _tmp5_;
- _tmp3_ = self->priv->active_child;
- if (_tmp3_ != NULL) {
- gboolean _tmp4_;
- _tmp4_ = self->priv->active_child_active;
- _tmp2_ = _tmp4_;
- } else {
- _tmp2_ = FALSE;
- }
- _tmp5_ = _tmp2_;
- if (_tmp5_) {
- gboolean _tmp6_;
- _tmp6_ = self->priv->activate_single_click;
- if (_tmp6_) {
- EggListBoxChildInfo* _tmp7_;
- _tmp7_ = self->priv->active_child;
- egg_list_box_select_and_activate (self, _tmp7_);
- } else {
- EggListBoxChildInfo* _tmp8_;
- _tmp8_ = self->priv->active_child;
- egg_list_box_update_selected (self, _tmp8_);
- }
- }
- self->priv->active_child = NULL;
- self->priv->active_child_active = FALSE;
- gtk_widget_queue_draw ((GtkWidget*) self);
- }
- result = FALSE;
- return result;
-}
-
-
-static void egg_list_box_real_show (GtkWidget* base) {
- EggListBox * self;
- self = (EggListBox*) base;
- egg_list_box_reseparate (self);
- GTK_WIDGET_CLASS (egg_list_box_parent_class)->show ((GtkWidget*) GTK_CONTAINER (self));
-}
-
-
-static gboolean egg_list_box_real_focus (GtkWidget* base, GtkDirectionType direction) {
- EggListBox * self;
- gboolean result = FALSE;
- gboolean had_focus = FALSE;
- gboolean focus_into = FALSE;
- GtkWidget* recurse_into;
- gboolean _tmp0_ = FALSE;
- gboolean _tmp1_;
- EggListBoxChildInfo* current_focus_child;
- EggListBoxChildInfo* next_focus_child;
- gboolean _tmp2_;
- GtkWidget* _tmp35_;
- gboolean _tmp39_;
- EggListBoxChildInfo* _tmp40_;
- EggListBoxChildInfo* _tmp62_;
- gboolean modify_selection_pressed;
- GdkModifierType state = 0;
- GdkModifierType _tmp67_ = 0;
- gboolean _tmp68_ = FALSE;
- EggListBoxChildInfo* _tmp73_;
- gboolean _tmp74_;
- self = (EggListBox*) base;
- recurse_into = NULL;
- focus_into = TRUE;
- g_object_get ((GtkWidget*) self, "has-focus", &_tmp0_, NULL);
- _tmp1_ = _tmp0_;
- had_focus = _tmp1_;
- current_focus_child = NULL;
- next_focus_child = NULL;
- _tmp2_ = had_focus;
- if (_tmp2_) {
- gboolean _tmp3_ = FALSE;
- GtkDirectionType _tmp4_;
- gboolean _tmp6_;
- EggListBoxChildInfo* _tmp10_;
- gboolean _tmp11_ = FALSE;
- GtkDirectionType _tmp12_;
- gboolean _tmp14_;
- _tmp4_ = direction;
- if (_tmp4_ == GTK_DIR_RIGHT) {
- _tmp3_ = TRUE;
- } else {
- GtkDirectionType _tmp5_;
- _tmp5_ = direction;
- _tmp3_ = _tmp5_ == GTK_DIR_TAB_FORWARD;
- }
- _tmp6_ = _tmp3_;
- if (_tmp6_) {
- EggListBoxChildInfo* _tmp7_;
- _tmp7_ = self->priv->cursor_child;
- if (_tmp7_ != NULL) {
- EggListBoxChildInfo* _tmp8_;
- GtkWidget* _tmp9_;
- _tmp8_ = self->priv->cursor_child;
- _tmp9_ = _tmp8_->widget;
- recurse_into = _tmp9_;
- }
- }
- _tmp10_ = self->priv->cursor_child;
- current_focus_child = _tmp10_;
- _tmp12_ = direction;
- if (_tmp12_ != GTK_DIR_UP) {
- GtkDirectionType _tmp13_;
- _tmp13_ = direction;
- _tmp11_ = _tmp13_ != GTK_DIR_DOWN;
- } else {
- _tmp11_ = FALSE;
- }
- _tmp14_ = _tmp11_;
- if (_tmp14_) {
- focus_into = FALSE;
- }
- } else {
- GtkWidget* _tmp15_ = NULL;
- _tmp15_ = gtk_container_get_focus_child ((GtkContainer*) self);
- if (_tmp15_ != NULL) {
- GtkWidget* _tmp16_ = NULL;
- GtkWidget* _tmp17_;
- EggListBoxChildInfo* _tmp18_ = NULL;
- gboolean _tmp19_ = FALSE;
- GtkDirectionType _tmp20_;
- gboolean _tmp22_;
- gboolean _tmp23_ = FALSE;
- GtkDirectionType _tmp24_;
- gboolean _tmp26_;
- _tmp16_ = gtk_container_get_focus_child ((GtkContainer*) self);
- recurse_into = _tmp16_;
- _tmp17_ = recurse_into;
- _tmp18_ = egg_list_box_lookup_info (self, _tmp17_);
- current_focus_child = _tmp18_;
- _tmp20_ = direction;
- if (_tmp20_ == GTK_DIR_RIGHT) {
- _tmp19_ = TRUE;
- } else {
- GtkDirectionType _tmp21_;
- _tmp21_ = direction;
- _tmp19_ = _tmp21_ == GTK_DIR_TAB_FORWARD;
- }
- _tmp22_ = _tmp19_;
- if (_tmp22_) {
- focus_into = FALSE;
- }
- _tmp24_ = direction;
- if (_tmp24_ == GTK_DIR_LEFT) {
- _tmp23_ = TRUE;
- } else {
- GtkDirectionType _tmp25_;
- _tmp25_ = direction;
- _tmp23_ = _tmp25_ == GTK_DIR_TAB_BACKWARD;
- }
- _tmp26_ = _tmp23_;
- if (_tmp26_) {
- EggListBoxChildInfo* _tmp27_;
- _tmp27_ = current_focus_child;
- next_focus_child = _tmp27_;
- }
- } else {
- gboolean _tmp28_ = FALSE;
- GtkDirectionType _tmp29_;
- gboolean _tmp31_;
- _tmp29_ = direction;
- if (_tmp29_ == GTK_DIR_LEFT) {
- _tmp28_ = TRUE;
- } else {
- GtkDirectionType _tmp30_;
- _tmp30_ = direction;
- _tmp28_ = _tmp30_ == GTK_DIR_TAB_BACKWARD;
- }
- _tmp31_ = _tmp28_;
- if (_tmp31_) {
- EggListBoxChildInfo* _tmp32_;
- _tmp32_ = self->priv->selected_child;
- if (_tmp32_ != NULL) {
- EggListBoxChildInfo* _tmp33_;
- GtkWidget* _tmp34_;
- _tmp33_ = self->priv->selected_child;
- _tmp34_ = _tmp33_->widget;
- recurse_into = _tmp34_;
- }
- }
- }
- }
- _tmp35_ = recurse_into;
- if (_tmp35_ != NULL) {
- GtkWidget* _tmp36_;
- GtkDirectionType _tmp37_;
- gboolean _tmp38_ = FALSE;
- _tmp36_ = recurse_into;
- _tmp37_ = direction;
- _tmp38_ = gtk_widget_child_focus (_tmp36_, _tmp37_);
- if (_tmp38_) {
- result = TRUE;
- return result;
- }
- }
- _tmp39_ = focus_into;
- if (!_tmp39_) {
- result = FALSE;
- return result;
- }
- _tmp40_ = next_focus_child;
- if (_tmp40_ == NULL) {
- EggListBoxChildInfo* _tmp41_;
- _tmp41_ = current_focus_child;
- if (_tmp41_ != NULL) {
- GtkDirectionType _tmp42_;
- _tmp42_ = direction;
- if (_tmp42_ == GTK_DIR_UP) {
- EggListBoxChildInfo* _tmp43_;
- GSequenceIter* _tmp44_;
- GSequenceIter* _tmp45_ = NULL;
- GSequenceIter* i;
- GSequenceIter* _tmp46_;
- _tmp43_ = current_focus_child;
- _tmp44_ = _tmp43_->iter;
- _tmp45_ = egg_list_box_get_previous_visible (self, _tmp44_);
- i = _tmp45_;
- _tmp46_ = i;
- if (_tmp46_ != NULL) {
- GSequenceIter* _tmp47_;
- gconstpointer _tmp48_ = NULL;
- _tmp47_ = i;
- _tmp48_ = g_sequence_get (_tmp47_);
- next_focus_child = (EggListBoxChildInfo*) _tmp48_;
- }
- } else {
- EggListBoxChildInfo* _tmp49_;
- GSequenceIter* _tmp50_;
- GSequenceIter* _tmp51_ = NULL;
- GSequenceIter* i;
- GSequenceIter* _tmp52_;
- gboolean _tmp53_ = FALSE;
- _tmp49_ = current_focus_child;
- _tmp50_ = _tmp49_->iter;
- _tmp51_ = egg_list_box_get_next_visible (self, _tmp50_);
- i = _tmp51_;
- _tmp52_ = i;
- _tmp53_ = g_sequence_iter_is_end (_tmp52_);
- if (!_tmp53_) {
- GSequenceIter* _tmp54_;
- gconstpointer _tmp55_ = NULL;
- _tmp54_ = i;
- _tmp55_ = g_sequence_get (_tmp54_);
- next_focus_child = (EggListBoxChildInfo*) _tmp55_;
- }
- }
- } else {
- GtkDirectionType _tmp56_;
- _tmp56_ = direction;
- switch (_tmp56_) {
- case GTK_DIR_DOWN:
- case GTK_DIR_TAB_FORWARD:
- {
- EggListBoxChildInfo* _tmp57_ = NULL;
- _tmp57_ = egg_list_box_get_first_visible (self);
- next_focus_child = _tmp57_;
- break;
- }
- case GTK_DIR_UP:
- case GTK_DIR_TAB_BACKWARD:
- {
- EggListBoxChildInfo* _tmp58_ = NULL;
- _tmp58_ = egg_list_box_get_last_visible (self);
- next_focus_child = _tmp58_;
- break;
- }
- default:
- {
- EggListBoxChildInfo* _tmp59_;
- EggListBoxChildInfo* _tmp60_;
- _tmp59_ = self->priv->selected_child;
- next_focus_child = _tmp59_;
- _tmp60_ = next_focus_child;
- if (_tmp60_ == NULL) {
- EggListBoxChildInfo* _tmp61_ = NULL;
- _tmp61_ = egg_list_box_get_first_visible (self);
- next_focus_child = _tmp61_;
- }
- break;
- }
- }
- }
- }
- _tmp62_ = next_focus_child;
- if (_tmp62_ == NULL) {
- gboolean _tmp63_ = FALSE;
- GtkDirectionType _tmp64_;
- gboolean _tmp66_;
- _tmp64_ = direction;
- if (_tmp64_ == GTK_DIR_UP) {
- _tmp63_ = TRUE;
- } else {
- GtkDirectionType _tmp65_;
- _tmp65_ = direction;
- _tmp63_ = _tmp65_ == GTK_DIR_DOWN;
- }
- _tmp66_ = _tmp63_;
- if (_tmp66_) {
- gtk_widget_error_bell ((GtkWidget*) self);
- result = TRUE;
- return result;
- }
- result = FALSE;
- return result;
- }
- modify_selection_pressed = FALSE;
- _tmp68_ = gtk_get_current_event_state (&_tmp67_);
- state = _tmp67_;
- if (_tmp68_) {
- GdkModifierType _tmp69_ = 0;
- GdkModifierType modify_mod_mask;
- GdkModifierType _tmp70_;
- GdkModifierType _tmp71_;
- GdkModifierType _tmp72_;
- _tmp69_ = gtk_widget_get_modifier_mask ((GtkWidget*) self, GDK_MODIFIER_INTENT_MODIFY_SELECTION);
- modify_mod_mask = _tmp69_;
- _tmp70_ = state;
- _tmp71_ = modify_mod_mask;
- _tmp72_ = modify_mod_mask;
- if ((_tmp70_ & _tmp71_) == _tmp72_) {
- modify_selection_pressed = TRUE;
- }
- }
- _tmp73_ = next_focus_child;
- egg_list_box_update_cursor (self, _tmp73_);
- _tmp74_ = modify_selection_pressed;
- if (!_tmp74_) {
- EggListBoxChildInfo* _tmp75_;
- _tmp75_ = next_focus_child;
- egg_list_box_update_selected (self, _tmp75_);
- }
- result = TRUE;
- return result;
-}
-
-
-static gboolean egg_list_box_real_draw (GtkWidget* base, cairo_t* cr) {
- EggListBox * self;
- gboolean result = FALSE;
- GtkAllocation allocation = {0};
- GtkAllocation _tmp0_ = {0};
- GtkStyleContext* _tmp1_ = NULL;
- GtkStyleContext* context;
- GtkStyleContext* _tmp2_;
- cairo_t* _tmp3_;
- GtkAllocation _tmp4_;
- gint _tmp5_;
- GtkAllocation _tmp6_;
- gint _tmp7_;
- EggListBoxChildFlags* _tmp8_ = NULL;
- EggListBoxChildFlags* flags;
- gint flags_length1;
- gint _flags_size_;
- EggListBoxChildInfo* _tmp9_;
- EggListBoxChildInfo* _tmp15_;
- gboolean _tmp21_ = FALSE;
- EggListBoxChildInfo* _tmp22_;
- gboolean _tmp24_;
- EggListBoxChildFlags* _tmp30_;
- gint _tmp30__length1;
- gboolean _tmp46_ = FALSE;
- gboolean _tmp47_ = FALSE;
- gboolean _tmp49_;
- cairo_t* _tmp58_;
- self = (EggListBox*) base;
- g_return_val_if_fail (cr != NULL, FALSE);
- gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
- allocation = _tmp0_;
- _tmp1_ = gtk_widget_get_style_context ((GtkWidget*) self);
- context = _tmp1_;
- _tmp2_ = context;
- _tmp3_ = cr;
- _tmp4_ = allocation;
- _tmp5_ = _tmp4_.width;
- _tmp6_ = allocation;
- _tmp7_ = _tmp6_.height;
- gtk_render_background (_tmp2_, _tmp3_, (gdouble) 0, (gdouble) 0, (gdouble) _tmp5_, (gdouble) _tmp7_);
- _tmp8_ = g_new0 (EggListBoxChildFlags, 0);
- flags = _tmp8_;
- flags_length1 = 0;
- _flags_size_ = flags_length1;
- _tmp9_ = self->priv->selected_child;
- if (_tmp9_ != NULL) {
- EggListBoxChildInfo* _tmp10_;
- EggListBoxChildFlags* _tmp11_ = NULL;
- EggListBoxChildFlags* found;
- EggListBoxChildFlags* _tmp12_;
- EggListBoxChildFlags* _tmp13_;
- GtkStateFlags _tmp14_;
- _tmp10_ = self->priv->selected_child;
- _tmp11_ = egg_list_box_child_flags_find_or_add (&flags, &flags_length1, _tmp10_);
- found = _tmp11_;
- _tmp12_ = found;
- _tmp13_ = found;
- _tmp14_ = (*_tmp13_).state;
- (*_tmp13_).state = _tmp14_ | GTK_STATE_FLAG_SELECTED;
- }
- _tmp15_ = self->priv->prelight_child;
- if (_tmp15_ != NULL) {
- EggListBoxChildInfo* _tmp16_;
- EggListBoxChildFlags* _tmp17_ = NULL;
- EggListBoxChildFlags* found;
- EggListBoxChildFlags* _tmp18_;
- EggListBoxChildFlags* _tmp19_;
- GtkStateFlags _tmp20_;
- _tmp16_ = self->priv->prelight_child;
- _tmp17_ = egg_list_box_child_flags_find_or_add (&flags, &flags_length1, _tmp16_);
- found = _tmp17_;
- _tmp18_ = found;
- _tmp19_ = found;
- _tmp20_ = (*_tmp19_).state;
- (*_tmp19_).state = _tmp20_ | GTK_STATE_FLAG_PRELIGHT;
- }
- _tmp22_ = self->priv->active_child;
- if (_tmp22_ != NULL) {
- gboolean _tmp23_;
- _tmp23_ = self->priv->active_child_active;
- _tmp21_ = _tmp23_;
- } else {
- _tmp21_ = FALSE;
- }
- _tmp24_ = _tmp21_;
- if (_tmp24_) {
- EggListBoxChildInfo* _tmp25_;
- EggListBoxChildFlags* _tmp26_ = NULL;
- EggListBoxChildFlags* found;
- EggListBoxChildFlags* _tmp27_;
- EggListBoxChildFlags* _tmp28_;
- GtkStateFlags _tmp29_;
- _tmp25_ = self->priv->active_child;
- _tmp26_ = egg_list_box_child_flags_find_or_add (&flags, &flags_length1, _tmp25_);
- found = _tmp26_;
- _tmp27_ = found;
- _tmp28_ = found;
- _tmp29_ = (*_tmp28_).state;
- (*_tmp28_).state = _tmp29_ | GTK_STATE_FLAG_ACTIVE;
- }
- _tmp30_ = flags;
- _tmp30__length1 = flags_length1;
- {
- EggListBoxChildFlags* flag_collection = NULL;
- gint flag_collection_length1 = 0;
- gint _flag_collection_size_ = 0;
- gint flag_it = 0;
- flag_collection = _tmp30_;
- flag_collection_length1 = _tmp30__length1;
- for (flag_it = 0; flag_it < _tmp30__length1; flag_it = flag_it + 1) {
- EggListBoxChildFlags* flag = NULL;
- flag = &flag_collection[flag_it];
- {
- GtkStyleContext* _tmp31_;
- GtkStyleContext* _tmp32_;
- EggListBoxChildFlags* _tmp33_;
- GtkStateFlags _tmp34_;
- GtkStyleContext* _tmp35_;
- cairo_t* _tmp36_;
- EggListBoxChildFlags* _tmp37_;
- EggListBoxChildInfo* _tmp38_;
- gint _tmp39_;
- GtkAllocation _tmp40_;
- gint _tmp41_;
- EggListBoxChildFlags* _tmp42_;
- EggListBoxChildInfo* _tmp43_;
- gint _tmp44_;
- GtkStyleContext* _tmp45_;
- _tmp31_ = context;
- gtk_style_context_save (_tmp31_);
- _tmp32_ = context;
- _tmp33_ = flag;
- _tmp34_ = (*_tmp33_).state;
- gtk_style_context_set_state (_tmp32_, _tmp34_);
- _tmp35_ = context;
- _tmp36_ = cr;
- _tmp37_ = flag;
- _tmp38_ = (*_tmp37_).child;
- _tmp39_ = _tmp38_->y;
- _tmp40_ = allocation;
- _tmp41_ = _tmp40_.width;
- _tmp42_ = flag;
- _tmp43_ = (*_tmp42_).child;
- _tmp44_ = _tmp43_->height;
- gtk_render_background (_tmp35_, _tmp36_, (gdouble) 0, (gdouble) _tmp39_, (gdouble) _tmp41_, (gdouble) _tmp44_);
- _tmp45_ = context;
- gtk_style_context_restore (_tmp45_);
- }
- }
- }
- _tmp47_ = gtk_widget_has_visible_focus ((GtkWidget*) self);
- if (_tmp47_) {
- EggListBoxChildInfo* _tmp48_;
- _tmp48_ = self->priv->cursor_child;
- _tmp46_ = _tmp48_ != NULL;
- } else {
- _tmp46_ = FALSE;
- }
- _tmp49_ = _tmp46_;
- if (_tmp49_) {
- GtkStyleContext* _tmp50_;
- cairo_t* _tmp51_;
- EggListBoxChildInfo* _tmp52_;
- gint _tmp53_;
- GtkAllocation _tmp54_;
- gint _tmp55_;
- EggListBoxChildInfo* _tmp56_;
- gint _tmp57_;
- _tmp50_ = context;
- _tmp51_ = cr;
- _tmp52_ = self->priv->cursor_child;
- _tmp53_ = _tmp52_->y;
- _tmp54_ = allocation;
- _tmp55_ = _tmp54_.width;
- _tmp56_ = self->priv->cursor_child;
- _tmp57_ = _tmp56_->height;
- gtk_render_focus (_tmp50_, _tmp51_, (gdouble) 0, (gdouble) _tmp53_, (gdouble) _tmp55_, (gdouble) _tmp57_);
- }
- _tmp58_ = cr;
- GTK_WIDGET_CLASS (egg_list_box_parent_class)->draw ((GtkWidget*) GTK_CONTAINER (self), _tmp58_);
- result = TRUE;
- flags = (g_free (flags), NULL);
- return result;
-}
-
-
-static void egg_list_box_real_realize (GtkWidget* base) {
- EggListBox * self;
- GtkAllocation allocation = {0};
- GtkAllocation _tmp0_ = {0};
- GdkWindowAttr _tmp1_ = {0};
- GdkWindowAttr attributes;
- GtkAllocation _tmp2_;
- gint _tmp3_;
- GtkAllocation _tmp4_;
- gint _tmp5_;
- GtkAllocation _tmp6_;
- gint _tmp7_;
- GtkAllocation _tmp8_;
- gint _tmp9_;
- gint _tmp10_ = 0;
- GdkWindow* _tmp11_ = NULL;
- GdkWindowAttr _tmp12_;
- GdkWindow* _tmp13_;
- GdkWindow* window;
- GtkStyleContext* _tmp14_ = NULL;
- GdkWindow* _tmp15_;
- self = (EggListBox*) base;
- gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
- allocation = _tmp0_;
- gtk_widget_set_realized ((GtkWidget*) self, TRUE);
- attributes = _tmp1_;
- _tmp2_ = allocation;
- _tmp3_ = _tmp2_.x;
- attributes.x = _tmp3_;
- _tmp4_ = allocation;
- _tmp5_ = _tmp4_.y;
- attributes.y = _tmp5_;
- _tmp6_ = allocation;
- _tmp7_ = _tmp6_.width;
- attributes.width = _tmp7_;
- _tmp8_ = allocation;
- _tmp9_ = _tmp8_.height;
- attributes.height = _tmp9_;
- attributes.window_type = GDK_WINDOW_CHILD;
- _tmp10_ = gtk_widget_get_events ((GtkWidget*) self);
- attributes.event_mask = (((((_tmp10_ | GDK_ENTER_NOTIFY_MASK) | GDK_LEAVE_NOTIFY_MASK) | GDK_POINTER_MOTION_MASK) | GDK_EXPOSURE_MASK) | GDK_BUTTON_PRESS_MASK) | GDK_BUTTON_RELEASE_MASK;
- attributes.wclass = GDK_INPUT_OUTPUT;
- _tmp11_ = gtk_widget_get_parent_window ((GtkWidget*) self);
- _tmp12_ = attributes;
- _tmp13_ = gdk_window_new (_tmp11_, &_tmp12_, (gint) (GDK_WA_X | GDK_WA_Y));
- window = _tmp13_;
- _tmp14_ = gtk_widget_get_style_context ((GtkWidget*) self);
- gtk_style_context_set_background (_tmp14_, window);
- gdk_window_set_user_data (window, (GObject*) self);
- _tmp15_ = _g_object_ref0 (window);
- gtk_widget_set_window ((GtkWidget*) self, _tmp15_);
- _g_object_unref0 (window);
-}
-
-
-static void egg_list_box_apply_filter (EggListBox* self, GtkWidget* child) {
- gboolean do_show;
- EggListBoxFilterFunc _tmp0_;
- void* _tmp0__target;
- GtkWidget* _tmp4_;
- gboolean _tmp5_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (child != NULL);
- do_show = TRUE;
- _tmp0_ = self->priv->filter_func;
- _tmp0__target = self->priv->filter_func_target;
- if (_tmp0_ != NULL) {
- EggListBoxFilterFunc _tmp1_;
- void* _tmp1__target;
- GtkWidget* _tmp2_;
- gboolean _tmp3_ = FALSE;
- _tmp1_ = self->priv->filter_func;
- _tmp1__target = self->priv->filter_func_target;
- _tmp2_ = child;
- _tmp3_ = _tmp1_ (_tmp2_, _tmp1__target);
- do_show = _tmp3_;
- }
- _tmp4_ = child;
- _tmp5_ = do_show;
- gtk_widget_set_child_visible (_tmp4_, _tmp5_);
-}
+void
+egg_list_box_refilter (EggListBox *list_box)
+{
+ g_return_if_fail (list_box != NULL);
-static void egg_list_box_apply_filter_all (EggListBox* self) {
- g_return_if_fail (self != NULL);
- {
- GSequence* _tmp0_;
- GSequenceIter* _tmp1_ = NULL;
- GSequenceIter* iter;
- _tmp0_ = self->priv->children;
- _tmp1_ = g_sequence_get_begin_iter (_tmp0_);
- iter = _tmp1_;
- {
- gboolean _tmp2_;
- _tmp2_ = TRUE;
- while (TRUE) {
- gboolean _tmp3_;
- GSequenceIter* _tmp6_;
- gboolean _tmp7_ = FALSE;
- GSequenceIter* _tmp8_;
- gconstpointer _tmp9_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp10_;
- GtkWidget* _tmp11_;
- _tmp3_ = _tmp2_;
- if (!_tmp3_) {
- GSequenceIter* _tmp4_;
- GSequenceIter* _tmp5_ = NULL;
- _tmp4_ = iter;
- _tmp5_ = g_sequence_iter_next (_tmp4_);
- iter = _tmp5_;
- }
- _tmp2_ = FALSE;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_is_end (_tmp6_);
- if (!(!_tmp7_)) {
- break;
- }
- _tmp8_ = iter;
- _tmp9_ = g_sequence_get (_tmp8_);
- child_info = (EggListBoxChildInfo*) _tmp9_;
- _tmp10_ = child_info;
- _tmp11_ = _tmp10_->widget;
- egg_list_box_apply_filter (self, _tmp11_);
- }
- }
- }
+ egg_list_box_apply_filter_all (list_box);
+ egg_list_box_reseparate (list_box);
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
}
+static gint
+do_sort (EggListBoxChildInfo *a,
+ EggListBoxChildInfo *b,
+ EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static EggListBoxChildInfo* egg_list_box_get_first_visible (EggListBox* self) {
- EggListBoxChildInfo* result = NULL;
- g_return_val_if_fail (self != NULL, NULL);
- {
- GSequence* _tmp0_;
- GSequenceIter* _tmp1_ = NULL;
- GSequenceIter* iter;
- _tmp0_ = self->priv->children;
- _tmp1_ = g_sequence_get_begin_iter (_tmp0_);
- iter = _tmp1_;
- {
- gboolean _tmp2_;
- _tmp2_ = TRUE;
- while (TRUE) {
- gboolean _tmp3_;
- GSequenceIter* _tmp6_;
- gboolean _tmp7_ = FALSE;
- GSequenceIter* _tmp8_;
- gconstpointer _tmp9_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp10_;
- GtkWidget* _tmp11_;
- GtkWidget* widget;
- gboolean _tmp12_ = FALSE;
- GtkWidget* _tmp13_;
- gboolean _tmp14_ = FALSE;
- gboolean _tmp17_;
- _tmp3_ = _tmp2_;
- if (!_tmp3_) {
- GSequenceIter* _tmp4_;
- GSequenceIter* _tmp5_ = NULL;
- _tmp4_ = iter;
- _tmp5_ = g_sequence_iter_next (_tmp4_);
- iter = _tmp5_;
- }
- _tmp2_ = FALSE;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_is_end (_tmp6_);
- if (!(!_tmp7_)) {
- break;
- }
- _tmp8_ = iter;
- _tmp9_ = g_sequence_get (_tmp8_);
- child_info = (EggListBoxChildInfo*) _tmp9_;
- _tmp10_ = child_info;
- _tmp11_ = _tmp10_->widget;
- widget = _tmp11_;
- _tmp13_ = widget;
- _tmp14_ = gtk_widget_get_visible (_tmp13_);
- if (_tmp14_) {
- GtkWidget* _tmp15_;
- gboolean _tmp16_ = FALSE;
- _tmp15_ = widget;
- _tmp16_ = gtk_widget_get_child_visible (_tmp15_);
- _tmp12_ = _tmp16_;
- } else {
- _tmp12_ = FALSE;
- }
- _tmp17_ = _tmp12_;
- if (_tmp17_) {
- EggListBoxChildInfo* _tmp18_;
- _tmp18_ = child_info;
- result = _tmp18_;
- return result;
- }
- }
- }
- }
- result = NULL;
- return result;
-}
-
-
-static EggListBoxChildInfo* egg_list_box_get_last_visible (EggListBox* self) {
- EggListBoxChildInfo* result = NULL;
- GSequence* _tmp0_;
- GSequenceIter* _tmp1_ = NULL;
- GSequenceIter* iter;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = self->priv->children;
- _tmp1_ = g_sequence_get_end_iter (_tmp0_);
- iter = _tmp1_;
- while (TRUE) {
- GSequenceIter* _tmp2_;
- gboolean _tmp3_ = FALSE;
- GSequenceIter* _tmp4_;
- GSequenceIter* _tmp5_ = NULL;
- GSequenceIter* _tmp6_;
- gconstpointer _tmp7_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp8_;
- GtkWidget* _tmp9_;
- GtkWidget* widget;
- gboolean _tmp10_ = FALSE;
- GtkWidget* _tmp11_;
- gboolean _tmp12_ = FALSE;
- gboolean _tmp15_;
- _tmp2_ = iter;
- _tmp3_ = g_sequence_iter_is_begin (_tmp2_);
- if (!(!_tmp3_)) {
- break;
- }
- _tmp4_ = iter;
- _tmp5_ = g_sequence_iter_prev (_tmp4_);
- iter = _tmp5_;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_get (_tmp6_);
- child_info = (EggListBoxChildInfo*) _tmp7_;
- _tmp8_ = child_info;
- _tmp9_ = _tmp8_->widget;
- widget = _tmp9_;
- _tmp11_ = widget;
- _tmp12_ = gtk_widget_get_visible (_tmp11_);
- if (_tmp12_) {
- GtkWidget* _tmp13_;
- gboolean _tmp14_ = FALSE;
- _tmp13_ = widget;
- _tmp14_ = gtk_widget_get_child_visible (_tmp13_);
- _tmp10_ = _tmp14_;
- } else {
- _tmp10_ = FALSE;
- }
- _tmp15_ = _tmp10_;
- if (_tmp15_) {
- EggListBoxChildInfo* _tmp16_;
- _tmp16_ = child_info;
- result = _tmp16_;
- return result;
- }
- }
- result = NULL;
- return result;
-}
-
-
-static GSequenceIter* egg_list_box_get_previous_visible (EggListBox* self, GSequenceIter* _iter) {
- GSequenceIter* result = NULL;
- GSequenceIter* _tmp0_;
- gboolean _tmp1_ = FALSE;
- GSequenceIter* _tmp2_;
- GSequenceIter* iter;
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (_iter != NULL, NULL);
- _tmp0_ = _iter;
- _tmp1_ = g_sequence_iter_is_begin (_tmp0_);
- if (_tmp1_) {
- result = NULL;
- return result;
- }
- _tmp2_ = _iter;
- iter = _tmp2_;
- {
- gboolean _tmp3_;
- _tmp3_ = TRUE;
- while (TRUE) {
- gboolean _tmp4_;
- GSequenceIter* _tmp7_;
- GSequenceIter* _tmp8_ = NULL;
- GSequenceIter* _tmp9_;
- gconstpointer _tmp10_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp11_;
- GtkWidget* _tmp12_;
- GtkWidget* widget;
- gboolean _tmp13_ = FALSE;
- GtkWidget* _tmp14_;
- gboolean _tmp15_ = FALSE;
- gboolean _tmp18_;
- _tmp4_ = _tmp3_;
- if (!_tmp4_) {
- GSequenceIter* _tmp5_;
- gboolean _tmp6_ = FALSE;
- _tmp5_ = iter;
- _tmp6_ = g_sequence_iter_is_begin (_tmp5_);
- if (!(!_tmp6_)) {
- break;
- }
- }
- _tmp3_ = FALSE;
- _tmp7_ = iter;
- _tmp8_ = g_sequence_iter_prev (_tmp7_);
- iter = _tmp8_;
- _tmp9_ = iter;
- _tmp10_ = g_sequence_get (_tmp9_);
- child_info = (EggListBoxChildInfo*) _tmp10_;
- _tmp11_ = child_info;
- _tmp12_ = _tmp11_->widget;
- widget = _tmp12_;
- _tmp14_ = widget;
- _tmp15_ = gtk_widget_get_visible (_tmp14_);
- if (_tmp15_) {
- GtkWidget* _tmp16_;
- gboolean _tmp17_ = FALSE;
- _tmp16_ = widget;
- _tmp17_ = gtk_widget_get_child_visible (_tmp16_);
- _tmp13_ = _tmp17_;
- } else {
- _tmp13_ = FALSE;
- }
- _tmp18_ = _tmp13_;
- if (_tmp18_) {
- result = iter;
- return result;
- }
- }
- }
- result = NULL;
- return result;
-}
-
-
-static GSequenceIter* egg_list_box_get_next_visible (EggListBox* self, GSequenceIter* _iter) {
- GSequenceIter* result = NULL;
- GSequenceIter* _tmp0_;
- gboolean _tmp1_ = FALSE;
- GSequenceIter* _tmp3_;
- GSequenceIter* iter;
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (_iter != NULL, NULL);
- _tmp0_ = _iter;
- _tmp1_ = g_sequence_iter_is_end (_tmp0_);
- if (_tmp1_) {
- GSequenceIter* _tmp2_;
- _tmp2_ = _iter;
- result = _tmp2_;
- return result;
- }
- _tmp3_ = _iter;
- iter = _tmp3_;
- {
- gboolean _tmp4_;
- _tmp4_ = TRUE;
- while (TRUE) {
- gboolean _tmp5_;
- GSequenceIter* _tmp8_;
- GSequenceIter* _tmp9_ = NULL;
- GSequenceIter* _tmp10_;
- gboolean _tmp11_ = FALSE;
- _tmp5_ = _tmp4_;
- if (!_tmp5_) {
- GSequenceIter* _tmp6_;
- gboolean _tmp7_ = FALSE;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_is_end (_tmp6_);
- if (!(!_tmp7_)) {
- break;
- }
- }
- _tmp4_ = FALSE;
- _tmp8_ = iter;
- _tmp9_ = g_sequence_iter_next (_tmp8_);
- iter = _tmp9_;
- _tmp10_ = iter;
- _tmp11_ = g_sequence_iter_is_end (_tmp10_);
- if (!_tmp11_) {
- GSequenceIter* _tmp12_;
- gconstpointer _tmp13_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp14_;
- GtkWidget* _tmp15_;
- GtkWidget* widget;
- gboolean _tmp16_ = FALSE;
- GtkWidget* _tmp17_;
- gboolean _tmp18_ = FALSE;
- gboolean _tmp21_;
- _tmp12_ = iter;
- _tmp13_ = g_sequence_get (_tmp12_);
- child_info = (EggListBoxChildInfo*) _tmp13_;
- _tmp14_ = child_info;
- _tmp15_ = _tmp14_->widget;
- widget = _tmp15_;
- _tmp17_ = widget;
- _tmp18_ = gtk_widget_get_visible (_tmp17_);
- if (_tmp18_) {
- GtkWidget* _tmp19_;
- gboolean _tmp20_ = FALSE;
- _tmp19_ = widget;
- _tmp20_ = gtk_widget_get_child_visible (_tmp19_);
- _tmp16_ = _tmp20_;
- } else {
- _tmp16_ = FALSE;
- }
- _tmp21_ = _tmp16_;
- if (_tmp21_) {
- result = iter;
- return result;
- }
- }
- }
- }
- result = iter;
- return result;
-}
-
-
-static void egg_list_box_update_separator (EggListBox* self, GSequenceIter* iter) {
- gboolean _tmp0_ = FALSE;
- GSequenceIter* _tmp1_;
- gboolean _tmp4_;
- GSequenceIter* _tmp5_;
- gconstpointer _tmp6_ = NULL;
- EggListBoxChildInfo* info;
- GSequenceIter* _tmp7_;
- GSequenceIter* _tmp8_ = NULL;
- GSequenceIter* before_iter;
- EggListBoxChildInfo* _tmp9_;
- GtkWidget* _tmp10_;
- GtkWidget* _tmp11_;
- GtkWidget* widget;
- GtkWidget* before_widget;
- GSequenceIter* _tmp12_;
- gboolean _tmp18_ = FALSE;
- gboolean _tmp19_ = FALSE;
- EggListBoxUpdateSeparatorFunc _tmp20_;
- void* _tmp20__target;
- gboolean _tmp23_;
- gboolean _tmp26_;
- g_return_if_fail (self != NULL);
- _tmp1_ = iter;
- if (_tmp1_ == NULL) {
- _tmp0_ = TRUE;
- } else {
- GSequenceIter* _tmp2_;
- gboolean _tmp3_ = FALSE;
- _tmp2_ = iter;
- _tmp3_ = g_sequence_iter_is_end (_tmp2_);
- _tmp0_ = _tmp3_;
- }
- _tmp4_ = _tmp0_;
- if (_tmp4_) {
- return;
- }
- _tmp5_ = iter;
- _tmp6_ = g_sequence_get (_tmp5_);
- info = (EggListBoxChildInfo*) _tmp6_;
- _tmp7_ = iter;
- _tmp8_ = egg_list_box_get_previous_visible (self, _tmp7_);
- before_iter = _tmp8_;
- _tmp9_ = info;
- _tmp10_ = _tmp9_->widget;
- _tmp11_ = _g_object_ref0 (_tmp10_);
- widget = _tmp11_;
- before_widget = NULL;
- _tmp12_ = before_iter;
- if (_tmp12_ != NULL) {
- GSequenceIter* _tmp13_;
- gconstpointer _tmp14_ = NULL;
- EggListBoxChildInfo* before_info;
- EggListBoxChildInfo* _tmp15_;
- GtkWidget* _tmp16_;
- GtkWidget* _tmp17_;
- _tmp13_ = before_iter;
- _tmp14_ = g_sequence_get (_tmp13_);
- before_info = (EggListBoxChildInfo*) _tmp14_;
- _tmp15_ = before_info;
- _tmp16_ = _tmp15_->widget;
- _tmp17_ = _g_object_ref0 (_tmp16_);
- _g_object_unref0 (before_widget);
- before_widget = _tmp17_;
- }
- _tmp20_ = self->priv->update_separator_func;
- _tmp20__target = self->priv->update_separator_func_target;
- if (_tmp20_ != NULL) {
- GtkWidget* _tmp21_;
- gboolean _tmp22_ = FALSE;
- _tmp21_ = widget;
- _tmp22_ = gtk_widget_get_visible (_tmp21_);
- _tmp19_ = _tmp22_;
- } else {
- _tmp19_ = FALSE;
- }
- _tmp23_ = _tmp19_;
- if (_tmp23_) {
- GtkWidget* _tmp24_;
- gboolean _tmp25_ = FALSE;
- _tmp24_ = widget;
- _tmp25_ = gtk_widget_get_child_visible (_tmp24_);
- _tmp18_ = _tmp25_;
- } else {
- _tmp18_ = FALSE;
- }
- _tmp26_ = _tmp18_;
- if (_tmp26_) {
- EggListBoxChildInfo* _tmp27_;
- GtkWidget* _tmp28_;
- GtkWidget* _tmp29_;
- GtkWidget* old_separator;
- EggListBoxUpdateSeparatorFunc _tmp30_;
- void* _tmp30__target;
- EggListBoxChildInfo* _tmp31_;
- GtkWidget* _tmp32_;
- GtkWidget* _tmp33_;
- GtkWidget* _tmp34_;
- EggListBoxChildInfo* _tmp35_;
- GtkWidget* _tmp36_;
- _tmp27_ = info;
- _tmp28_ = _tmp27_->separator;
- _tmp29_ = _g_object_ref0 (_tmp28_);
- old_separator = _tmp29_;
- _tmp30_ = self->priv->update_separator_func;
- _tmp30__target = self->priv->update_separator_func_target;
- _tmp31_ = info;
- _tmp32_ = widget;
- _tmp33_ = before_widget;
- _tmp30_ (&_tmp31_->separator, _tmp32_, _tmp33_, _tmp30__target);
- _tmp34_ = old_separator;
- _tmp35_ = info;
- _tmp36_ = _tmp35_->separator;
- if (_tmp34_ != _tmp36_) {
- GtkWidget* _tmp37_;
- EggListBoxChildInfo* _tmp41_;
- GtkWidget* _tmp42_;
- _tmp37_ = old_separator;
- if (_tmp37_ != NULL) {
- GtkWidget* _tmp38_;
- GHashTable* _tmp39_;
- GtkWidget* _tmp40_;
- _tmp38_ = old_separator;
- gtk_widget_unparent (_tmp38_);
- _tmp39_ = self->priv->separator_hash;
- _tmp40_ = old_separator;
- g_hash_table_remove (_tmp39_, _tmp40_);
- }
- _tmp41_ = info;
- _tmp42_ = _tmp41_->separator;
- if (_tmp42_ != NULL) {
- GHashTable* _tmp43_;
- EggListBoxChildInfo* _tmp44_;
- GtkWidget* _tmp45_;
- EggListBoxChildInfo* _tmp46_;
- EggListBoxChildInfo* _tmp47_;
- GtkWidget* _tmp48_;
- EggListBoxChildInfo* _tmp49_;
- GtkWidget* _tmp50_;
- _tmp43_ = self->priv->separator_hash;
- _tmp44_ = info;
- _tmp45_ = _tmp44_->separator;
- _tmp46_ = info;
- g_hash_table_insert (_tmp43_, _tmp45_, _tmp46_);
- _tmp47_ = info;
- _tmp48_ = _tmp47_->separator;
- gtk_widget_set_parent (_tmp48_, (GtkWidget*) self);
- _tmp49_ = info;
- _tmp50_ = _tmp49_->separator;
- gtk_widget_show (_tmp50_);
- }
- gtk_widget_queue_resize ((GtkWidget*) self);
- }
- _g_object_unref0 (old_separator);
- } else {
- EggListBoxChildInfo* _tmp51_;
- GtkWidget* _tmp52_;
- _tmp51_ = info;
- _tmp52_ = _tmp51_->separator;
- if (_tmp52_ != NULL) {
- GHashTable* _tmp53_;
- EggListBoxChildInfo* _tmp54_;
- GtkWidget* _tmp55_;
- EggListBoxChildInfo* _tmp56_;
- GtkWidget* _tmp57_;
- EggListBoxChildInfo* _tmp58_;
- _tmp53_ = self->priv->separator_hash;
- _tmp54_ = info;
- _tmp55_ = _tmp54_->separator;
- g_hash_table_remove (_tmp53_, _tmp55_);
- _tmp56_ = info;
- _tmp57_ = _tmp56_->separator;
- gtk_widget_unparent (_tmp57_);
- _tmp58_ = info;
- _g_object_unref0 (_tmp58_->separator);
- _tmp58_->separator = NULL;
- gtk_widget_queue_resize ((GtkWidget*) self);
- }
- }
- _g_object_unref0 (before_widget);
- _g_object_unref0 (widget);
-}
-
-
-static EggListBoxChildInfo* egg_list_box_lookup_info (EggListBox* self, GtkWidget* widget) {
- EggListBoxChildInfo* result = NULL;
- GHashTable* _tmp0_;
- GtkWidget* _tmp1_;
- gconstpointer _tmp2_ = NULL;
- g_return_val_if_fail (self != NULL, NULL);
- g_return_val_if_fail (widget != NULL, NULL);
- _tmp0_ = self->priv->child_hash;
- _tmp1_ = widget;
- _tmp2_ = g_hash_table_lookup (_tmp0_, _tmp1_);
- result = (EggListBoxChildInfo*) _tmp2_;
- return result;
-}
-
-
-static gpointer _egg_list_box_child_info_ref0 (gpointer self) {
- return self ? egg_list_box_child_info_ref (self) : NULL;
-}
-
-
-static void _egg_list_box_child_visibility_changed_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
- egg_list_box_child_visibility_changed (self, _sender, pspec);
-}
-
-
-static void egg_list_box_real_add (GtkContainer* base, GtkWidget* widget) {
- EggListBox * self;
- GtkWidget* _tmp0_;
- EggListBoxChildInfo* _tmp1_;
- EggListBoxChildInfo* info;
- GSequenceIter* iter = NULL;
- GHashTable* _tmp2_;
- GtkWidget* _tmp3_;
- EggListBoxChildInfo* _tmp4_;
- GCompareDataFunc _tmp5_;
- void* _tmp5__target;
- EggListBoxChildInfo* _tmp14_;
- GSequenceIter* _tmp15_;
- GtkWidget* _tmp16_;
- GtkWidget* _tmp17_;
- gboolean _tmp18_ = FALSE;
- GtkWidget* _tmp22_;
- self = (EggListBox*) base;
- g_return_if_fail (widget != NULL);
- _tmp0_ = widget;
- _tmp1_ = egg_list_box_child_info_new (_tmp0_);
- info = _tmp1_;
- _tmp2_ = self->priv->child_hash;
- _tmp3_ = widget;
- _tmp4_ = info;
- g_hash_table_insert (_tmp2_, _tmp3_, _tmp4_);
- _tmp5_ = self->priv->sort_func;
- _tmp5__target = self->priv->sort_func_target;
- if (_tmp5_ != NULL) {
- GSequence* _tmp6_;
- EggListBoxChildInfo* _tmp7_;
- EggListBoxChildInfo* _tmp8_;
- GSequenceIter* _tmp9_ = NULL;
- _tmp6_ = self->priv->children;
- _tmp7_ = info;
- _tmp8_ = _egg_list_box_child_info_ref0 (_tmp7_);
- _tmp9_ = g_sequence_insert_sorted (_tmp6_, _tmp8_, _egg_list_box_do_sort_gcompare_data_func, self);
- iter = _tmp9_;
- } else {
- GSequence* _tmp10_;
- EggListBoxChildInfo* _tmp11_;
- EggListBoxChildInfo* _tmp12_;
- GSequenceIter* _tmp13_ = NULL;
- _tmp10_ = self->priv->children;
- _tmp11_ = info;
- _tmp12_ = _egg_list_box_child_info_ref0 (_tmp11_);
- _tmp13_ = g_sequence_append (_tmp10_, _tmp12_);
- iter = _tmp13_;
- }
- _tmp14_ = info;
- _tmp15_ = iter;
- _tmp14_->iter = _tmp15_;
- _tmp16_ = widget;
- gtk_widget_set_parent (_tmp16_, (GtkWidget*) self);
- _tmp17_ = widget;
- egg_list_box_apply_filter (self, _tmp17_);
- _tmp18_ = gtk_widget_get_visible ((GtkWidget*) self);
- if (_tmp18_) {
- GSequenceIter* _tmp19_;
- GSequenceIter* _tmp20_;
- GSequenceIter* _tmp21_ = NULL;
- _tmp19_ = iter;
- egg_list_box_update_separator (self, _tmp19_);
- _tmp20_ = iter;
- _tmp21_ = egg_list_box_get_next_visible (self, _tmp20_);
- egg_list_box_update_separator (self, _tmp21_);
- }
- _tmp22_ = widget;
- g_signal_connect_object ((GObject*) _tmp22_, "notify::visible", (GCallback) _egg_list_box_child_visibility_changed_g_object_notify, self, 0);
- _egg_list_box_child_info_unref0 (info);
-}
-
-
-static void egg_list_box_child_visibility_changed (EggListBox* self, GObject* object, GParamSpec* pspec) {
- gboolean _tmp0_ = FALSE;
- g_return_if_fail (self != NULL);
- g_return_if_fail (object != NULL);
- g_return_if_fail (pspec != NULL);
- _tmp0_ = gtk_widget_get_visible ((GtkWidget*) self);
- if (_tmp0_) {
- GObject* _tmp1_;
- EggListBoxChildInfo* _tmp2_ = NULL;
- EggListBoxChildInfo* info;
- EggListBoxChildInfo* _tmp3_;
- _tmp1_ = object;
- _tmp2_ = egg_list_box_lookup_info (self, GTK_IS_WIDGET (_tmp1_) ? ((GtkWidget*) _tmp1_) : NULL);
- info = _tmp2_;
- _tmp3_ = info;
- if (_tmp3_ != NULL) {
- EggListBoxChildInfo* _tmp4_;
- GSequenceIter* _tmp5_;
- EggListBoxChildInfo* _tmp6_;
- GSequenceIter* _tmp7_;
- GSequenceIter* _tmp8_ = NULL;
- _tmp4_ = info;
- _tmp5_ = _tmp4_->iter;
- egg_list_box_update_separator (self, _tmp5_);
- _tmp6_ = info;
- _tmp7_ = _tmp6_->iter;
- _tmp8_ = egg_list_box_get_next_visible (self, _tmp7_);
- egg_list_box_update_separator (self, _tmp8_);
- }
- }
+ return priv->sort_func (a->widget, b->widget,
+ priv->sort_func_target);
}
+void
+egg_list_box_resort (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_real_remove (GtkContainer* base, GtkWidget* widget) {
- EggListBox * self;
- GtkWidget* _tmp0_;
- gboolean _tmp1_ = FALSE;
- gboolean was_visible;
- GtkWidget* _tmp2_;
- guint _tmp3_ = 0U;
- GQuark _tmp4_ = 0U;
- GtkWidget* _tmp5_;
- EggListBoxChildInfo* _tmp6_ = NULL;
- EggListBoxChildInfo* info;
- EggListBoxChildInfo* _tmp7_;
- EggListBoxChildInfo* _tmp21_;
- GtkWidget* _tmp22_;
- EggListBoxChildInfo* _tmp29_;
- EggListBoxChildInfo* _tmp30_;
- EggListBoxChildInfo* _tmp31_;
- EggListBoxChildInfo* _tmp32_;
- EggListBoxChildInfo* _tmp33_;
- EggListBoxChildInfo* _tmp34_;
- EggListBoxChildInfo* _tmp35_;
- EggListBoxChildInfo* _tmp36_;
- EggListBoxChildInfo* _tmp37_;
- GSequenceIter* _tmp38_;
- GSequenceIter* _tmp39_ = NULL;
- GSequenceIter* next;
- GtkWidget* _tmp40_;
- GHashTable* _tmp41_;
- GtkWidget* _tmp42_;
- GSequence* _tmp43_;
- EggListBoxChildInfo* _tmp44_;
- GSequenceIter* _tmp45_;
- gboolean _tmp46_ = FALSE;
- gboolean _tmp48_ = FALSE;
- gboolean _tmp49_;
- gboolean _tmp51_;
- self = (EggListBox*) base;
- g_return_if_fail (widget != NULL);
- _tmp0_ = widget;
- _tmp1_ = gtk_widget_get_visible (_tmp0_);
- was_visible = _tmp1_;
- _tmp2_ = widget;
- g_signal_parse_name ("notify::visible", G_TYPE_OBJECT, &_tmp3_, &_tmp4_, TRUE);
- g_signal_handlers_disconnect_matched ((GObject*) _tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, _tmp4_, NULL, (GCallback) _egg_list_box_child_visibility_changed_g_object_notify, self);
- _tmp5_ = widget;
- _tmp6_ = egg_list_box_lookup_info (self, _tmp5_);
- info = _tmp6_;
- _tmp7_ = info;
- if (_tmp7_ == NULL) {
- GHashTable* _tmp8_;
- GtkWidget* _tmp9_;
- gconstpointer _tmp10_ = NULL;
- EggListBoxChildInfo* _tmp11_;
- _tmp8_ = self->priv->separator_hash;
- _tmp9_ = widget;
- _tmp10_ = g_hash_table_lookup (_tmp8_, _tmp9_);
- info = (EggListBoxChildInfo*) _tmp10_;
- _tmp11_ = info;
- if (_tmp11_ != NULL) {
- GHashTable* _tmp12_;
- GtkWidget* _tmp13_;
- EggListBoxChildInfo* _tmp14_;
- GtkWidget* _tmp15_;
- gboolean _tmp16_ = FALSE;
- gboolean _tmp17_;
- gboolean _tmp19_;
- _tmp12_ = self->priv->separator_hash;
- _tmp13_ = widget;
- g_hash_table_remove (_tmp12_, _tmp13_);
- _tmp14_ = info;
- _g_object_unref0 (_tmp14_->separator);
- _tmp14_->separator = NULL;
- _tmp15_ = widget;
- gtk_widget_unparent (_tmp15_);
- _tmp17_ = was_visible;
- if (_tmp17_) {
- gboolean _tmp18_ = FALSE;
- _tmp18_ = gtk_widget_get_visible ((GtkWidget*) self);
- _tmp16_ = _tmp18_;
- } else {
- _tmp16_ = FALSE;
- }
- _tmp19_ = _tmp16_;
- if (_tmp19_) {
- gtk_widget_queue_resize ((GtkWidget*) self);
- }
- } else {
- GtkWidget* _tmp20_;
- _tmp20_ = widget;
- g_warning ("egg-list-box.vala:837: Tried to remove non-child %p\n", _tmp20_);
- }
- return;
- }
- _tmp21_ = info;
- _tmp22_ = _tmp21_->separator;
- if (_tmp22_ != NULL) {
- GHashTable* _tmp23_;
- EggListBoxChildInfo* _tmp24_;
- GtkWidget* _tmp25_;
- EggListBoxChildInfo* _tmp26_;
- GtkWidget* _tmp27_;
- EggListBoxChildInfo* _tmp28_;
- _tmp23_ = self->priv->separator_hash;
- _tmp24_ = info;
- _tmp25_ = _tmp24_->separator;
- g_hash_table_remove (_tmp23_, _tmp25_);
- _tmp26_ = info;
- _tmp27_ = _tmp26_->separator;
- gtk_widget_unparent (_tmp27_);
- _tmp28_ = info;
- _g_object_unref0 (_tmp28_->separator);
- _tmp28_->separator = NULL;
- }
- _tmp29_ = info;
- _tmp30_ = self->priv->selected_child;
- if (_tmp29_ == _tmp30_) {
- egg_list_box_update_selected (self, NULL);
- }
- _tmp31_ = info;
- _tmp32_ = self->priv->prelight_child;
- if (_tmp31_ == _tmp32_) {
- self->priv->prelight_child = NULL;
- }
- _tmp33_ = info;
- _tmp34_ = self->priv->cursor_child;
- if (_tmp33_ == _tmp34_) {
- self->priv->cursor_child = NULL;
- }
- _tmp35_ = info;
- _tmp36_ = self->priv->active_child;
- if (_tmp35_ == _tmp36_) {
- self->priv->active_child = NULL;
- }
- _tmp37_ = info;
- _tmp38_ = _tmp37_->iter;
- _tmp39_ = egg_list_box_get_next_visible (self, _tmp38_);
- next = _tmp39_;
- _tmp40_ = widget;
- gtk_widget_unparent (_tmp40_);
- _tmp41_ = self->priv->child_hash;
- _tmp42_ = widget;
- g_hash_table_remove (_tmp41_, _tmp42_);
- _tmp43_ = self->priv->children;
- _tmp44_ = info;
- _tmp45_ = _tmp44_->iter;
- g_sequence_remove (_tmp45_);
- _tmp46_ = gtk_widget_get_visible ((GtkWidget*) self);
- if (_tmp46_) {
- GSequenceIter* _tmp47_;
- _tmp47_ = next;
- egg_list_box_update_separator (self, _tmp47_);
- }
- _tmp49_ = was_visible;
- if (_tmp49_) {
- gboolean _tmp50_ = FALSE;
- _tmp50_ = gtk_widget_get_visible ((GtkWidget*) self);
- _tmp48_ = _tmp50_;
- } else {
- _tmp48_ = FALSE;
- }
- _tmp51_ = _tmp48_;
- if (_tmp51_) {
- gtk_widget_queue_resize ((GtkWidget*) self);
- }
-}
-
+ g_return_if_fail (list_box != NULL);
-static void egg_list_box_real_forall_internal (GtkContainer* base, gboolean include_internals, GtkCallback callback, void* callback_target) {
- EggListBox * self;
- GSequence* _tmp0_;
- GSequenceIter* _tmp1_ = NULL;
- GSequenceIter* iter;
- self = (EggListBox*) base;
- _tmp0_ = self->priv->children;
- _tmp1_ = g_sequence_get_begin_iter (_tmp0_);
- iter = _tmp1_;
- while (TRUE) {
- GSequenceIter* _tmp2_;
- gboolean _tmp3_ = FALSE;
- GSequenceIter* _tmp4_;
- gconstpointer _tmp5_ = NULL;
- EggListBoxChildInfo* child_info;
- GSequenceIter* _tmp6_;
- GSequenceIter* _tmp7_ = NULL;
- gboolean _tmp8_ = FALSE;
- EggListBoxChildInfo* _tmp9_;
- GtkWidget* _tmp10_;
- gboolean _tmp12_;
- GtkCallback _tmp16_;
- void* _tmp16__target;
- EggListBoxChildInfo* _tmp17_;
- GtkWidget* _tmp18_;
- _tmp2_ = iter;
- _tmp3_ = g_sequence_iter_is_end (_tmp2_);
- if (!(!_tmp3_)) {
- break;
- }
- _tmp4_ = iter;
- _tmp5_ = g_sequence_get (_tmp4_);
- child_info = (EggListBoxChildInfo*) _tmp5_;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_next (_tmp6_);
- iter = _tmp7_;
- _tmp9_ = child_info;
- _tmp10_ = _tmp9_->separator;
- if (_tmp10_ != NULL) {
- gboolean _tmp11_;
- _tmp11_ = include_internals;
- _tmp8_ = _tmp11_;
- } else {
- _tmp8_ = FALSE;
- }
- _tmp12_ = _tmp8_;
- if (_tmp12_) {
- GtkCallback _tmp13_;
- void* _tmp13__target;
- EggListBoxChildInfo* _tmp14_;
- GtkWidget* _tmp15_;
- _tmp13_ = callback;
- _tmp13__target = callback_target;
- _tmp14_ = child_info;
- _tmp15_ = _tmp14_->separator;
- _tmp13_ (_tmp15_, _tmp13__target);
- }
- _tmp16_ = callback;
- _tmp16__target = callback_target;
- _tmp17_ = child_info;
- _tmp18_ = _tmp17_->widget;
- _tmp16_ (_tmp18_, _tmp16__target);
- }
+ g_sequence_sort (priv->children,
+ (GCompareDataFunc)do_sort, list_box);
+ egg_list_box_reseparate (list_box);
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
}
+void
+egg_list_box_reseparate (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ GSequenceIter *iter;
-static void egg_list_box_real_compute_expand_internal (GtkWidget* base, gboolean* hexpand, gboolean* vexpand) {
- EggListBox * self;
- gboolean _vala_hexpand = FALSE;
- gboolean _vala_vexpand = FALSE;
- gboolean _tmp0_ = FALSE;
- gboolean _tmp1_ = FALSE;
- self = (EggListBox*) base;
- GTK_WIDGET_CLASS (egg_list_box_parent_class)->compute_expand ((GtkWidget*) GTK_CONTAINER (self), &_tmp0_, &_tmp1_);
- _vala_hexpand = _tmp0_;
- _vala_vexpand = _tmp1_;
- _vala_vexpand = FALSE;
- if (hexpand) {
- *hexpand = _vala_hexpand;
- }
- if (vexpand) {
- *vexpand = _vala_vexpand;
- }
-}
+ g_return_if_fail (list_box != NULL);
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ egg_list_box_update_separator (list_box, iter);
-static GType egg_list_box_real_child_type (GtkContainer* base) {
- EggListBox * self;
- GType result = 0UL;
- self = (EggListBox*) base;
- result = GTK_TYPE_WIDGET;
- return result;
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
}
+void
+egg_list_box_set_sort_func (EggListBox *list_box,
+ GCompareDataFunc f,
+ void *f_target,
+ GDestroyNotify f_target_destroy_notify)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static GtkSizeRequestMode egg_list_box_real_get_request_mode (GtkWidget* base) {
- EggListBox * self;
- GtkSizeRequestMode result = 0;
- self = (EggListBox*) base;
- result = GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
- return result;
-}
+ g_return_if_fail (list_box != NULL);
+ if (priv->sort_func_target_destroy_notify != NULL)
+ priv->sort_func_target_destroy_notify (priv->sort_func_target);
-static void egg_list_box_real_get_preferred_height (GtkWidget* base, gint* minimum_height, gint* natural_height) {
- EggListBox * self;
- gint _vala_minimum_height = 0;
- gint _vala_natural_height = 0;
- gint natural_width = 0;
- gint _tmp0_ = 0;
- gint _tmp1_ = 0;
- gint _tmp2_ = 0;
- self = (EggListBox*) base;
- GTK_WIDGET_GET_CLASS ((GtkWidget*) self)->get_preferred_width ((GtkWidget*) self, NULL, &_tmp0_);
- natural_width = _tmp0_;
- GTK_WIDGET_GET_CLASS ((GtkWidget*) self)->get_preferred_height_for_width ((GtkWidget*) self, natural_width, &_tmp1_, &_tmp2_);
- _vala_minimum_height = _tmp1_;
- _vala_natural_height = _tmp2_;
- if (minimum_height) {
- *minimum_height = _vala_minimum_height;
- }
- if (natural_height) {
- *natural_height = _vala_natural_height;
- }
+ priv->sort_func = f;
+ priv->sort_func_target = f_target;
+ priv->sort_func_target_destroy_notify = f_target_destroy_notify;
+ egg_list_box_resort (list_box);
}
+void
+egg_list_box_child_changed (EggListBox *list_box, GtkWidget *widget)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *info;
+ GSequenceIter *prev_next, *next;
-static void egg_list_box_real_get_preferred_height_for_width (GtkWidget* base, gint width, gint* minimum_height, gint* natural_height) {
- EggListBox * self;
- gint _vala_minimum_height = 0;
- gint _vala_natural_height = 0;
- GtkStyleContext* _tmp0_ = NULL;
- GtkStyleContext* context;
- gint focus_width = 0;
- gint focus_pad = 0;
- GtkStyleContext* _tmp1_;
- gint _tmp37_;
- self = (EggListBox*) base;
- _vala_minimum_height = 0;
- _tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
- context = _tmp0_;
- _tmp1_ = context;
- gtk_style_context_get_style (_tmp1_, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL);
- {
- GSequence* _tmp2_;
- GSequenceIter* _tmp3_ = NULL;
- GSequenceIter* iter;
- _tmp2_ = self->priv->children;
- _tmp3_ = g_sequence_get_begin_iter (_tmp2_);
- iter = _tmp3_;
- {
- gboolean _tmp4_;
- _tmp4_ = TRUE;
- while (TRUE) {
- gboolean _tmp5_;
- GSequenceIter* _tmp8_;
- gboolean _tmp9_ = FALSE;
- GSequenceIter* _tmp10_;
- gconstpointer _tmp11_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp12_;
- GtkWidget* _tmp13_;
- GtkWidget* widget;
- gint child_min = 0;
- gboolean _tmp14_ = FALSE;
- GtkWidget* _tmp15_;
- gboolean _tmp16_ = FALSE;
- gboolean _tmp19_;
- EggListBoxChildInfo* _tmp20_;
- GtkWidget* _tmp21_;
- GtkWidget* _tmp28_;
- gint _tmp29_;
- gint _tmp30_;
- gint _tmp31_;
- gint _tmp32_ = 0;
- gint _tmp33_;
- gint _tmp34_;
- gint _tmp35_;
- gint _tmp36_;
- _tmp5_ = _tmp4_;
- if (!_tmp5_) {
- GSequenceIter* _tmp6_;
- GSequenceIter* _tmp7_ = NULL;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_next (_tmp6_);
- iter = _tmp7_;
- }
- _tmp4_ = FALSE;
- _tmp8_ = iter;
- _tmp9_ = g_sequence_iter_is_end (_tmp8_);
- if (!(!_tmp9_)) {
- break;
- }
- _tmp10_ = iter;
- _tmp11_ = g_sequence_get (_tmp10_);
- child_info = (EggListBoxChildInfo*) _tmp11_;
- _tmp12_ = child_info;
- _tmp13_ = _tmp12_->widget;
- widget = _tmp13_;
- _tmp15_ = widget;
- _tmp16_ = gtk_widget_get_visible (_tmp15_);
- if (!_tmp16_) {
- _tmp14_ = TRUE;
- } else {
- GtkWidget* _tmp17_;
- gboolean _tmp18_ = FALSE;
- _tmp17_ = widget;
- _tmp18_ = gtk_widget_get_child_visible (_tmp17_);
- _tmp14_ = !_tmp18_;
- }
- _tmp19_ = _tmp14_;
- if (_tmp19_) {
- continue;
- }
- _tmp20_ = child_info;
- _tmp21_ = _tmp20_->separator;
- if (_tmp21_ != NULL) {
- EggListBoxChildInfo* _tmp22_;
- GtkWidget* _tmp23_;
- gint _tmp24_;
- gint _tmp25_ = 0;
- gint _tmp26_;
- gint _tmp27_;
- _tmp22_ = child_info;
- _tmp23_ = _tmp22_->separator;
- _tmp24_ = width;
- gtk_widget_get_preferred_height_for_width (_tmp23_, _tmp24_, &_tmp25_, NULL);
- child_min = _tmp25_;
- _tmp26_ = _vala_minimum_height;
- _tmp27_ = child_min;
- _vala_minimum_height = _tmp26_ + _tmp27_;
- }
- _tmp28_ = widget;
- _tmp29_ = width;
- _tmp30_ = focus_width;
- _tmp31_ = focus_pad;
- gtk_widget_get_preferred_height_for_width (_tmp28_, _tmp29_ - (2 * (_tmp30_ + _tmp31_)), &_tmp32_, NULL);
- child_min = _tmp32_;
- _tmp33_ = _vala_minimum_height;
- _tmp34_ = child_min;
- _tmp35_ = focus_width;
- _tmp36_ = focus_pad;
- _vala_minimum_height = _tmp33_ + (_tmp34_ + (2 * (_tmp35_ + _tmp36_)));
- }
- }
- }
- _tmp37_ = _vala_minimum_height;
- _vala_natural_height = _tmp37_;
- if (minimum_height) {
- *minimum_height = _vala_minimum_height;
- }
- if (natural_height) {
- *natural_height = _vala_natural_height;
- }
-}
+ g_return_if_fail (list_box != NULL);
+ g_return_if_fail (widget != NULL);
+ info = egg_list_box_lookup_info (list_box, widget);
+ if (info == NULL)
+ return;
-static void egg_list_box_real_get_preferred_width (GtkWidget* base, gint* minimum_width, gint* natural_width) {
- EggListBox * self;
- gint _vala_minimum_width = 0;
- gint _vala_natural_width = 0;
- GtkStyleContext* _tmp0_ = NULL;
- GtkStyleContext* context;
- gint focus_width = 0;
- gint focus_pad = 0;
- GtkStyleContext* _tmp1_;
- self = (EggListBox*) base;
- _tmp0_ = gtk_widget_get_style_context ((GtkWidget*) self);
- context = _tmp0_;
- _tmp1_ = context;
- gtk_style_context_get_style (_tmp1_, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL);
- _vala_minimum_width = 0;
- _vala_natural_width = 0;
+ prev_next = egg_list_box_get_next_visible (list_box, info->iter);
+ if (priv->sort_func != NULL)
+ {
+ g_sequence_sort_changed (info->iter,
+ (GCompareDataFunc)do_sort,
+ list_box);
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
+ }
+ egg_list_box_apply_filter (list_box, info->widget);
+ if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
+ {
+ next = egg_list_box_get_next_visible (list_box, info->iter);
+ egg_list_box_update_separator (list_box, info->iter);
+ egg_list_box_update_separator (list_box, next);
+ egg_list_box_update_separator (list_box, prev_next);
+ }
+}
+
+void
+egg_list_box_set_activate_on_single_click (EggListBox *list_box,
+ gboolean single)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+
+ g_return_if_fail (list_box != NULL);
+
+ priv->activate_single_click = single;
+}
+
+static void
+egg_list_box_add_move_binding (GtkBindingSet *binding_set,
+ guint keyval,
+ GdkModifierType modmask,
+ GtkMovementStep step,
+ gint count)
+{
+ gtk_binding_entry_add_signal (binding_set, keyval, modmask,
+ "move-cursor", (guint) 2, GTK_TYPE_MOVEMENT_STEP, step, G_TYPE_INT, count, NULL);
+
+ if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
+ return;
+
+ gtk_binding_entry_add_signal (binding_set, keyval, GDK_CONTROL_MASK,
+ "move-cursor", (guint) 2, GTK_TYPE_MOVEMENT_STEP, step, G_TYPE_INT, count, NULL);
+}
+
+static EggListBoxChildInfo*
+egg_list_box_find_child_at_y (EggListBox *list_box, gint y)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *child_info;
+ GSequenceIter *iter;
+ EggListBoxChildInfo *info;
+
+ child_info = NULL;
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ {
+ info = (EggListBoxChildInfo*) g_sequence_get (iter);
+ if (y >= info->y && y < (info->y + info->height))
{
- GSequence* _tmp2_;
- GSequenceIter* _tmp3_ = NULL;
- GSequenceIter* iter;
- _tmp2_ = self->priv->children;
- _tmp3_ = g_sequence_get_begin_iter (_tmp2_);
- iter = _tmp3_;
- {
- gboolean _tmp4_;
- _tmp4_ = TRUE;
- while (TRUE) {
- gboolean _tmp5_;
- GSequenceIter* _tmp8_;
- gboolean _tmp9_ = FALSE;
- GSequenceIter* _tmp10_;
- gconstpointer _tmp11_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp12_;
- GtkWidget* _tmp13_;
- GtkWidget* widget;
- gint child_min = 0;
- gint child_nat = 0;
- gboolean _tmp14_ = FALSE;
- GtkWidget* _tmp15_;
- gboolean _tmp16_ = FALSE;
- gboolean _tmp19_;
- GtkWidget* _tmp20_;
- gint _tmp21_ = 0;
- gint _tmp22_ = 0;
- gint _tmp23_;
- gint _tmp24_;
- gint _tmp25_;
- gint _tmp26_;
- gint _tmp27_ = 0;
- gint _tmp28_;
- gint _tmp29_;
- gint _tmp30_;
- gint _tmp31_;
- gint _tmp32_ = 0;
- EggListBoxChildInfo* _tmp33_;
- GtkWidget* _tmp34_;
- _tmp5_ = _tmp4_;
- if (!_tmp5_) {
- GSequenceIter* _tmp6_;
- GSequenceIter* _tmp7_ = NULL;
- _tmp6_ = iter;
- _tmp7_ = g_sequence_iter_next (_tmp6_);
- iter = _tmp7_;
- }
- _tmp4_ = FALSE;
- _tmp8_ = iter;
- _tmp9_ = g_sequence_iter_is_end (_tmp8_);
- if (!(!_tmp9_)) {
- break;
- }
- _tmp10_ = iter;
- _tmp11_ = g_sequence_get (_tmp10_);
- child_info = (EggListBoxChildInfo*) _tmp11_;
- _tmp12_ = child_info;
- _tmp13_ = _tmp12_->widget;
- widget = _tmp13_;
- _tmp15_ = widget;
- _tmp16_ = gtk_widget_get_visible (_tmp15_);
- if (!_tmp16_) {
- _tmp14_ = TRUE;
- } else {
- GtkWidget* _tmp17_;
- gboolean _tmp18_ = FALSE;
- _tmp17_ = widget;
- _tmp18_ = gtk_widget_get_child_visible (_tmp17_);
- _tmp14_ = !_tmp18_;
- }
- _tmp19_ = _tmp14_;
- if (_tmp19_) {
- continue;
- }
- _tmp20_ = widget;
- gtk_widget_get_preferred_width (_tmp20_, &_tmp21_, &_tmp22_);
- child_min = _tmp21_;
- child_nat = _tmp22_;
- _tmp23_ = _vala_minimum_width;
- _tmp24_ = child_min;
- _tmp25_ = focus_width;
- _tmp26_ = focus_pad;
- _tmp27_ = MAX (_tmp23_, _tmp24_ + (2 * (_tmp25_ + _tmp26_)));
- _vala_minimum_width = _tmp27_;
- _tmp28_ = _vala_natural_width;
- _tmp29_ = child_nat;
- _tmp30_ = focus_width;
- _tmp31_ = focus_pad;
- _tmp32_ = MAX (_tmp28_, _tmp29_ + (2 * (_tmp30_ + _tmp31_)));
- _vala_natural_width = _tmp32_;
- _tmp33_ = child_info;
- _tmp34_ = _tmp33_->separator;
- if (_tmp34_ != NULL) {
- EggListBoxChildInfo* _tmp35_;
- GtkWidget* _tmp36_;
- gint _tmp37_ = 0;
- gint _tmp38_ = 0;
- gint _tmp39_;
- gint _tmp40_;
- gint _tmp41_ = 0;
- gint _tmp42_;
- gint _tmp43_;
- gint _tmp44_ = 0;
- _tmp35_ = child_info;
- _tmp36_ = _tmp35_->separator;
- gtk_widget_get_preferred_width (_tmp36_, &_tmp37_, &_tmp38_);
- child_min = _tmp37_;
- child_nat = _tmp38_;
- _tmp39_ = _vala_minimum_width;
- _tmp40_ = child_min;
- _tmp41_ = MAX (_tmp39_, _tmp40_);
- _vala_minimum_width = _tmp41_;
- _tmp42_ = _vala_natural_width;
- _tmp43_ = child_nat;
- _tmp44_ = MAX (_tmp42_, _tmp43_);
- _vala_natural_width = _tmp44_;
- }
- }
- }
- }
- if (minimum_width) {
- *minimum_width = _vala_minimum_width;
- }
- if (natural_width) {
- *natural_width = _vala_natural_width;
+ child_info = info;
+ break;
}
+ }
+
+ return child_info;
}
+static void
+egg_list_box_update_cursor (EggListBox *list_box,
+ EggListBoxChildInfo *child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_real_get_preferred_width_for_height (GtkWidget* base, gint height, gint* minimum_width, gint* natural_width) {
- EggListBox * self;
- gint _vala_minimum_width = 0;
- gint _vala_natural_width = 0;
- gint _tmp0_ = 0;
- gint _tmp1_ = 0;
- self = (EggListBox*) base;
- GTK_WIDGET_GET_CLASS ((GtkWidget*) self)->get_preferred_width ((GtkWidget*) self, &_tmp0_, &_tmp1_);
- _vala_minimum_width = _tmp0_;
- _vala_natural_width = _tmp1_;
- if (minimum_width) {
- *minimum_width = _vala_minimum_width;
- }
- if (natural_width) {
- *natural_width = _vala_natural_width;
- }
+ priv->cursor_child = child;
+ gtk_widget_grab_focus (GTK_WIDGET (list_box));
+ gtk_widget_queue_draw (GTK_WIDGET (list_box));
+ if (child != NULL && priv->adjustment != NULL)
+ {
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (list_box), &allocation);
+ gtk_adjustment_clamp_page (priv->adjustment,
+ priv->cursor_child->y + allocation.y,
+ priv->cursor_child->y + allocation.y + priv->cursor_child->height);
+ }
}
+static void
+egg_list_box_update_selected (EggListBox *list_box,
+ EggListBoxChildInfo *child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_real_size_allocate (GtkWidget* base, GtkAllocation* allocation) {
- EggListBox * self;
- GtkAllocation _tmp0_ = {0};
- GtkAllocation child_allocation;
- GtkAllocation _tmp1_ = {0};
- GtkAllocation separator_allocation;
- GtkAllocation _tmp2_;
- GdkWindow* _tmp3_ = NULL;
- GdkWindow* _tmp4_;
- GdkWindow* window;
- GdkWindow* _tmp5_;
- GtkStyleContext* _tmp15_ = NULL;
- GtkStyleContext* _tmp16_;
- GtkStyleContext* context;
- gint focus_width = 0;
- gint focus_pad = 0;
- GtkStyleContext* _tmp17_;
- gint _tmp18_;
- gint _tmp19_;
- GtkAllocation _tmp20_;
- gint _tmp21_;
- gint _tmp22_;
- gint _tmp23_;
- GtkAllocation _tmp24_;
- gint _tmp25_;
- self = (EggListBox*) base;
- g_return_if_fail (allocation != NULL);
- _tmp0_.x = 0;
- _tmp0_.y = 0;
- _tmp0_.width = 0;
- _tmp0_.height = 0;
- child_allocation = _tmp0_;
- _tmp1_.x = 0;
- _tmp1_.y = 0;
- _tmp1_.width = 0;
- _tmp1_.height = 0;
- separator_allocation = _tmp1_;
- _tmp2_ = *allocation;
- gtk_widget_set_allocation ((GtkWidget*) self, &_tmp2_);
- _tmp3_ = gtk_widget_get_window ((GtkWidget*) self);
- _tmp4_ = _g_object_ref0 (_tmp3_);
- window = _tmp4_;
- _tmp5_ = window;
- if (_tmp5_ != NULL) {
- GdkWindow* _tmp6_;
- GtkAllocation _tmp7_;
- gint _tmp8_;
- GtkAllocation _tmp9_;
- gint _tmp10_;
- GtkAllocation _tmp11_;
- gint _tmp12_;
- GtkAllocation _tmp13_;
- gint _tmp14_;
- _tmp6_ = window;
- _tmp7_ = *allocation;
- _tmp8_ = _tmp7_.x;
- _tmp9_ = *allocation;
- _tmp10_ = _tmp9_.y;
- _tmp11_ = *allocation;
- _tmp12_ = _tmp11_.width;
- _tmp13_ = *allocation;
- _tmp14_ = _tmp13_.height;
- gdk_window_move_resize (_tmp6_, _tmp8_, _tmp10_, _tmp12_, _tmp14_);
- }
- _tmp15_ = gtk_widget_get_style_context ((GtkWidget*) self);
- _tmp16_ = _g_object_ref0 (_tmp15_);
- context = _tmp16_;
- _tmp17_ = context;
- gtk_style_context_get_style (_tmp17_, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL);
- _tmp18_ = focus_width;
- _tmp19_ = focus_pad;
- child_allocation.x = (0 + _tmp18_) + _tmp19_;
- child_allocation.y = 0;
- _tmp20_ = *allocation;
- _tmp21_ = _tmp20_.width;
- _tmp22_ = focus_width;
- _tmp23_ = focus_pad;
- child_allocation.width = _tmp21_ - (2 * (_tmp22_ + _tmp23_));
- separator_allocation.x = 0;
- _tmp24_ = *allocation;
- _tmp25_ = _tmp24_.width;
- separator_allocation.width = _tmp25_;
- {
- GSequence* _tmp26_;
- GSequenceIter* _tmp27_ = NULL;
- GSequenceIter* iter;
- _tmp26_ = self->priv->children;
- _tmp27_ = g_sequence_get_begin_iter (_tmp26_);
- iter = _tmp27_;
- {
- gboolean _tmp28_;
- _tmp28_ = TRUE;
- while (TRUE) {
- gboolean _tmp29_;
- GSequenceIter* _tmp32_;
- gboolean _tmp33_ = FALSE;
- GSequenceIter* _tmp34_;
- gconstpointer _tmp35_ = NULL;
- EggListBoxChildInfo* child_info;
- EggListBoxChildInfo* _tmp36_;
- GtkWidget* _tmp37_;
- GtkWidget* widget;
- gint child_min = 0;
- gboolean _tmp38_ = FALSE;
- GtkWidget* _tmp39_;
- gboolean _tmp40_ = FALSE;
- gboolean _tmp43_;
- EggListBoxChildInfo* _tmp48_;
- GtkWidget* _tmp49_;
- EggListBoxChildInfo* _tmp63_;
- GtkAllocation _tmp64_;
- gint _tmp65_;
- gint _tmp66_;
- gint _tmp67_;
- gint _tmp68_;
- GtkWidget* _tmp69_;
- GtkAllocation _tmp70_;
- gint _tmp71_;
- gint _tmp72_ = 0;
- gint _tmp73_;
- EggListBoxChildInfo* _tmp74_;
- GtkAllocation _tmp75_;
- gint _tmp76_;
- gint _tmp77_;
- gint _tmp78_;
- GtkWidget* _tmp79_;
- GtkAllocation _tmp80_;
- gint _tmp81_;
- gint _tmp82_;
- gint _tmp83_;
- gint _tmp84_;
- _tmp29_ = _tmp28_;
- if (!_tmp29_) {
- GSequenceIter* _tmp30_;
- GSequenceIter* _tmp31_ = NULL;
- _tmp30_ = iter;
- _tmp31_ = g_sequence_iter_next (_tmp30_);
- iter = _tmp31_;
- }
- _tmp28_ = FALSE;
- _tmp32_ = iter;
- _tmp33_ = g_sequence_iter_is_end (_tmp32_);
- if (!(!_tmp33_)) {
- break;
- }
- _tmp34_ = iter;
- _tmp35_ = g_sequence_get (_tmp34_);
- child_info = (EggListBoxChildInfo*) _tmp35_;
- _tmp36_ = child_info;
- _tmp37_ = _tmp36_->widget;
- widget = _tmp37_;
- _tmp39_ = widget;
- _tmp40_ = gtk_widget_get_visible (_tmp39_);
- if (!_tmp40_) {
- _tmp38_ = TRUE;
- } else {
- GtkWidget* _tmp41_;
- gboolean _tmp42_ = FALSE;
- _tmp41_ = widget;
- _tmp42_ = gtk_widget_get_child_visible (_tmp41_);
- _tmp38_ = !_tmp42_;
- }
- _tmp43_ = _tmp38_;
- if (_tmp43_) {
- EggListBoxChildInfo* _tmp44_;
- GtkAllocation _tmp45_;
- gint _tmp46_;
- EggListBoxChildInfo* _tmp47_;
- _tmp44_ = child_info;
- _tmp45_ = child_allocation;
- _tmp46_ = _tmp45_.y;
- _tmp44_->y = _tmp46_;
- _tmp47_ = child_info;
- _tmp47_->height = 0;
- continue;
- }
- _tmp48_ = child_info;
- _tmp49_ = _tmp48_->separator;
- if (_tmp49_ != NULL) {
- EggListBoxChildInfo* _tmp50_;
- GtkWidget* _tmp51_;
- GtkAllocation _tmp52_;
- gint _tmp53_;
- gint _tmp54_ = 0;
- gint _tmp55_;
- GtkAllocation _tmp56_;
- gint _tmp57_;
- EggListBoxChildInfo* _tmp58_;
- GtkWidget* _tmp59_;
- GtkAllocation _tmp60_;
- gint _tmp61_;
- gint _tmp62_;
- _tmp50_ = child_info;
- _tmp51_ = _tmp50_->separator;
- _tmp52_ = *allocation;
- _tmp53_ = _tmp52_.width;
- gtk_widget_get_preferred_height_for_width (_tmp51_, _tmp53_, &_tmp54_, NULL);
- child_min = _tmp54_;
- _tmp55_ = child_min;
- separator_allocation.height = _tmp55_;
- _tmp56_ = child_allocation;
- _tmp57_ = _tmp56_.y;
- separator_allocation.y = _tmp57_;
- _tmp58_ = child_info;
- _tmp59_ = _tmp58_->separator;
- _tmp60_ = separator_allocation;
- gtk_widget_size_allocate (_tmp59_, &_tmp60_);
- _tmp61_ = child_allocation.y;
- _tmp62_ = child_min;
- child_allocation.y = _tmp61_ + _tmp62_;
- }
- _tmp63_ = child_info;
- _tmp64_ = child_allocation;
- _tmp65_ = _tmp64_.y;
- _tmp63_->y = _tmp65_;
- _tmp66_ = child_allocation.y;
- _tmp67_ = focus_width;
- _tmp68_ = focus_pad;
- child_allocation.y = _tmp66_ + (_tmp67_ + _tmp68_);
- _tmp69_ = widget;
- _tmp70_ = child_allocation;
- _tmp71_ = _tmp70_.width;
- gtk_widget_get_preferred_height_for_width (_tmp69_, _tmp71_, &_tmp72_, NULL);
- child_min = _tmp72_;
- _tmp73_ = child_min;
- child_allocation.height = _tmp73_;
- _tmp74_ = child_info;
- _tmp75_ = child_allocation;
- _tmp76_ = _tmp75_.height;
- _tmp77_ = focus_width;
- _tmp78_ = focus_pad;
- _tmp74_->height = _tmp76_ + (2 * (_tmp77_ + _tmp78_));
- _tmp79_ = widget;
- _tmp80_ = child_allocation;
- gtk_widget_size_allocate (_tmp79_, &_tmp80_);
- _tmp81_ = child_allocation.y;
- _tmp82_ = child_min;
- _tmp83_ = focus_width;
- _tmp84_ = focus_pad;
- child_allocation.y = _tmp81_ + ((_tmp82_ + _tmp83_) + _tmp84_);
- }
- }
- }
- _g_object_unref0 (context);
- _g_object_unref0 (window);
+ if (child != priv->selected_child &&
+ (child == NULL || priv->selection_mode != GTK_SELECTION_NONE))
+ {
+ priv->selected_child = child;
+ g_signal_emit (list_box, signals[CHILD_SELECTED], 0,
+ (priv->selected_child != NULL) ? priv->selected_child->widget : NULL);
+ gtk_widget_queue_draw (GTK_WIDGET (list_box));
+ }
+ if (child != NULL)
+ egg_list_box_update_cursor (list_box, child);
}
+static void
+egg_list_box_select_and_activate (EggListBox *list_box, EggListBoxChildInfo *child)
+{
+ GtkWidget *w = NULL;
-EggListBox* egg_list_box_construct (GType object_type) {
- EggListBox * self = NULL;
- self = (EggListBox*) g_object_new (object_type, NULL);
- return self;
-}
+ if (child != NULL)
+ w = child->widget;
+ egg_list_box_update_selected (list_box, child);
-EggListBox* egg_list_box_new (void) {
- return egg_list_box_construct (EGG_TYPE_LIST_BOX);
+ if (w != NULL)
+ g_signal_emit (list_box, signals[CHILD_ACTIVATED], 0, w);
}
+static void
+egg_list_box_update_prelight (EggListBox *list_box, EggListBoxChildInfo *child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_real_child_selected (EggListBox* self, GtkWidget* child) {
+ if (child != priv->prelight_child)
+ {
+ priv->prelight_child = child;
+ gtk_widget_queue_draw (GTK_WIDGET (list_box));
+ }
}
+static void
+egg_list_box_update_active (EggListBox *list_box, EggListBoxChildInfo *child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ gboolean val;
-static void egg_list_box_real_child_activated (EggListBox* self, GtkWidget* child) {
+ val = priv->active_child == child;
+ if (priv->active_child != NULL &&
+ val != priv->active_child_active)
+ {
+ priv->active_child_active = val;
+ gtk_widget_queue_draw (GTK_WIDGET (list_box));
+ }
}
+static gboolean
+egg_list_box_real_enter_notify_event (GtkWidget *widget,
+ GdkEventCrossing *event)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxChildInfo *child;
-static void egg_list_box_real_activate_cursor_child (EggListBox* self) {
- EggListBoxChildInfo* _tmp0_;
- _tmp0_ = self->priv->cursor_child;
- egg_list_box_select_and_activate (self, _tmp0_);
-}
+ if (event->window != gtk_widget_get_window (GTK_WIDGET (list_box)))
+ return FALSE;
-static void egg_list_box_real_toggle_cursor_child (EggListBox* self) {
- EggListBoxChildInfo* _tmp0_;
- gboolean _tmp1_ = FALSE;
- GtkSelectionMode _tmp2_;
- gboolean _tmp5_;
- _tmp0_ = self->priv->cursor_child;
- if (_tmp0_ == NULL) {
- return;
- }
- _tmp2_ = self->priv->selection_mode;
- if (_tmp2_ == GTK_SELECTION_SINGLE) {
- EggListBoxChildInfo* _tmp3_;
- EggListBoxChildInfo* _tmp4_;
- _tmp3_ = self->priv->selected_child;
- _tmp4_ = self->priv->cursor_child;
- _tmp1_ = _tmp3_ == _tmp4_;
- } else {
- _tmp1_ = FALSE;
- }
- _tmp5_ = _tmp1_;
- if (_tmp5_) {
- egg_list_box_update_selected (self, NULL);
- } else {
- EggListBoxChildInfo* _tmp6_;
- _tmp6_ = self->priv->cursor_child;
- egg_list_box_select_and_activate (self, _tmp6_);
- }
+ child = egg_list_box_find_child_at_y (list_box, event->y);
+ egg_list_box_update_prelight (list_box, child);
+ egg_list_box_update_active (list_box, child);
+
+ return FALSE;
}
+static gboolean
+egg_list_box_real_leave_notify_event (GtkWidget *widget,
+ GdkEventCrossing *event)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxChildInfo *child = NULL;
-static void egg_list_box_real_move_cursor (EggListBox* self, GtkMovementStep step, gint count) {
- GdkModifierType state = 0;
- gboolean modify_selection_pressed;
- GdkModifierType _tmp0_ = 0;
- gboolean _tmp1_ = FALSE;
- EggListBoxChildInfo* child;
- GtkMovementStep _tmp6_;
- EggListBoxChildInfo* _tmp97_;
- EggListBoxChildInfo* _tmp98_;
- gboolean _tmp99_;
- modify_selection_pressed = FALSE;
- _tmp1_ = gtk_get_current_event_state (&_tmp0_);
- state = _tmp0_;
- if (_tmp1_) {
- GdkModifierType _tmp2_ = 0;
- GdkModifierType modify_mod_mask;
- GdkModifierType _tmp3_;
- GdkModifierType _tmp4_;
- GdkModifierType _tmp5_;
- _tmp2_ = gtk_widget_get_modifier_mask ((GtkWidget*) self, GDK_MODIFIER_INTENT_MODIFY_SELECTION);
- modify_mod_mask = _tmp2_;
- _tmp3_ = state;
- _tmp4_ = modify_mod_mask;
- _tmp5_ = modify_mod_mask;
- if ((_tmp3_ & _tmp4_) == _tmp5_) {
- modify_selection_pressed = TRUE;
- }
- }
- child = NULL;
- _tmp6_ = step;
- switch (_tmp6_) {
- case GTK_MOVEMENT_BUFFER_ENDS:
- {
- gint _tmp7_;
- _tmp7_ = count;
- if (_tmp7_ < 0) {
- EggListBoxChildInfo* _tmp8_ = NULL;
- EggListBoxChildInfo* _tmp9_;
- _tmp8_ = egg_list_box_get_first_visible (self);
- _tmp9_ = _egg_list_box_child_info_ref0 (_tmp8_);
- _egg_list_box_child_info_unref0 (child);
- child = _tmp9_;
- } else {
- EggListBoxChildInfo* _tmp10_ = NULL;
- EggListBoxChildInfo* _tmp11_;
- _tmp10_ = egg_list_box_get_last_visible (self);
- _tmp11_ = _egg_list_box_child_info_ref0 (_tmp10_);
- _egg_list_box_child_info_unref0 (child);
- child = _tmp11_;
- }
- break;
- }
- case GTK_MOVEMENT_DISPLAY_LINES:
- {
- EggListBoxChildInfo* _tmp12_;
- _tmp12_ = self->priv->cursor_child;
- if (_tmp12_ != NULL) {
- EggListBoxChildInfo* _tmp13_;
- GSequenceIter* _tmp14_;
- GSequenceIter* iter;
- gboolean _tmp29_ = FALSE;
- GSequenceIter* _tmp30_;
- gboolean _tmp33_;
- _tmp13_ = self->priv->cursor_child;
- _tmp14_ = _tmp13_->iter;
- iter = _tmp14_;
- while (TRUE) {
- gboolean _tmp15_ = FALSE;
- gint _tmp16_;
- gboolean _tmp18_;
- GSequenceIter* _tmp19_;
- GSequenceIter* _tmp20_ = NULL;
- gint _tmp21_;
- _tmp16_ = count;
- if (_tmp16_ < 0) {
- GSequenceIter* _tmp17_;
- _tmp17_ = iter;
- _tmp15_ = _tmp17_ != NULL;
- } else {
- _tmp15_ = FALSE;
- }
- _tmp18_ = _tmp15_;
- if (!_tmp18_) {
- break;
- }
- _tmp19_ = iter;
- _tmp20_ = egg_list_box_get_previous_visible (self, _tmp19_);
- iter = _tmp20_;
- _tmp21_ = count;
- count = _tmp21_ + 1;
- }
- while (TRUE) {
- gboolean _tmp22_ = FALSE;
- gint _tmp23_;
- gboolean _tmp25_;
- GSequenceIter* _tmp26_;
- GSequenceIter* _tmp27_ = NULL;
- gint _tmp28_;
- _tmp23_ = count;
- if (_tmp23_ > 0) {
- GSequenceIter* _tmp24_;
- _tmp24_ = iter;
- _tmp22_ = _tmp24_ != NULL;
- } else {
- _tmp22_ = FALSE;
- }
- _tmp25_ = _tmp22_;
- if (!_tmp25_) {
- break;
- }
- _tmp26_ = iter;
- _tmp27_ = egg_list_box_get_next_visible (self, _tmp26_);
- iter = _tmp27_;
- _tmp28_ = count;
- count = _tmp28_ - 1;
- }
- _tmp30_ = iter;
- if (_tmp30_ != NULL) {
- GSequenceIter* _tmp31_;
- gboolean _tmp32_ = FALSE;
- _tmp31_ = iter;
- _tmp32_ = g_sequence_iter_is_end (_tmp31_);
- _tmp29_ = !_tmp32_;
- } else {
- _tmp29_ = FALSE;
- }
- _tmp33_ = _tmp29_;
- if (_tmp33_) {
- GSequenceIter* _tmp34_;
- gconstpointer _tmp35_ = NULL;
- EggListBoxChildInfo* _tmp36_;
- _tmp34_ = iter;
- _tmp35_ = g_sequence_get (_tmp34_);
- _tmp36_ = _egg_list_box_child_info_ref0 ((EggListBoxChildInfo*) _tmp35_);
- _egg_list_box_child_info_unref0 (child);
- child = _tmp36_;
- }
- }
- break;
- }
- case GTK_MOVEMENT_PAGES:
- {
- gint page_size;
- GtkAdjustment* _tmp37_;
- EggListBoxChildInfo* _tmp40_;
- page_size = 100;
- _tmp37_ = self->priv->adjustment;
- if (_tmp37_ != NULL) {
- GtkAdjustment* _tmp38_;
- gdouble _tmp39_ = 0.0;
- _tmp38_ = self->priv->adjustment;
- _tmp39_ = gtk_adjustment_get_page_increment (_tmp38_);
- page_size = (gint) _tmp39_;
- }
- _tmp40_ = self->priv->cursor_child;
- if (_tmp40_ != NULL) {
- EggListBoxChildInfo* _tmp41_;
- gint _tmp42_;
- gint start_y;
- gint _tmp43_;
- gint end_y;
- EggListBoxChildInfo* _tmp44_;
- GSequenceIter* _tmp45_;
- GSequenceIter* iter;
- EggListBoxChildInfo* _tmp46_;
- EggListBoxChildInfo* _tmp47_;
- gint _tmp48_;
- EggListBoxChildInfo* _tmp84_;
- gint _tmp85_;
- gboolean _tmp86_ = FALSE;
- gint _tmp87_;
- gint _tmp88_;
- gboolean _tmp90_;
- _tmp41_ = self->priv->cursor_child;
- _tmp42_ = _tmp41_->y;
- start_y = _tmp42_;
- _tmp43_ = start_y;
- end_y = _tmp43_;
- _tmp44_ = self->priv->cursor_child;
- _tmp45_ = _tmp44_->iter;
- iter = _tmp45_;
- _tmp46_ = self->priv->cursor_child;
- _tmp47_ = _egg_list_box_child_info_ref0 (_tmp46_);
- _egg_list_box_child_info_unref0 (child);
- child = _tmp47_;
- _tmp48_ = count;
- if (_tmp48_ < 0) {
- while (TRUE) {
- gboolean _tmp49_ = FALSE;
- GSequenceIter* _tmp50_;
- gboolean _tmp53_;
- GSequenceIter* _tmp54_;
- GSequenceIter* _tmp55_ = NULL;
- GSequenceIter* _tmp56_;
- GSequenceIter* _tmp57_;
- gconstpointer _tmp58_ = NULL;
- EggListBoxChildInfo* _tmp59_;
- EggListBoxChildInfo* prev;
- EggListBoxChildInfo* _tmp60_;
- gint _tmp61_;
- gint _tmp62_;
- gint _tmp63_;
- EggListBoxChildInfo* _tmp64_;
- EggListBoxChildInfo* _tmp65_;
- _tmp50_ = iter;
- if (_tmp50_ != NULL) {
- GSequenceIter* _tmp51_;
- gboolean _tmp52_ = FALSE;
- _tmp51_ = iter;
- _tmp52_ = g_sequence_iter_is_begin (_tmp51_);
- _tmp49_ = !_tmp52_;
- } else {
- _tmp49_ = FALSE;
- }
- _tmp53_ = _tmp49_;
- if (!_tmp53_) {
- break;
- }
- _tmp54_ = iter;
- _tmp55_ = egg_list_box_get_previous_visible (self, _tmp54_);
- iter = _tmp55_;
- _tmp56_ = iter;
- if (_tmp56_ == NULL) {
- break;
- }
- _tmp57_ = iter;
- _tmp58_ = g_sequence_get (_tmp57_);
- _tmp59_ = _egg_list_box_child_info_ref0 ((EggListBoxChildInfo*) _tmp58_);
- prev = _tmp59_;
- _tmp60_ = prev;
- _tmp61_ = _tmp60_->y;
- _tmp62_ = start_y;
- _tmp63_ = page_size;
- if (_tmp61_ < (_tmp62_ - _tmp63_)) {
- _egg_list_box_child_info_unref0 (prev);
- break;
- }
- _tmp64_ = prev;
- _tmp65_ = _egg_list_box_child_info_ref0 (_tmp64_);
- _egg_list_box_child_info_unref0 (child);
- child = _tmp65_;
- _egg_list_box_child_info_unref0 (prev);
- }
- } else {
- while (TRUE) {
- gboolean _tmp66_ = FALSE;
- GSequenceIter* _tmp67_;
- gboolean _tmp70_;
- GSequenceIter* _tmp71_;
- GSequenceIter* _tmp72_ = NULL;
- GSequenceIter* _tmp73_;
- gboolean _tmp74_ = FALSE;
- GSequenceIter* _tmp75_;
- gconstpointer _tmp76_ = NULL;
- EggListBoxChildInfo* _tmp77_;
- EggListBoxChildInfo* next;
- EggListBoxChildInfo* _tmp78_;
- gint _tmp79_;
- gint _tmp80_;
- gint _tmp81_;
- EggListBoxChildInfo* _tmp82_;
- EggListBoxChildInfo* _tmp83_;
- _tmp67_ = iter;
- if (_tmp67_ != NULL) {
- GSequenceIter* _tmp68_;
- gboolean _tmp69_ = FALSE;
- _tmp68_ = iter;
- _tmp69_ = g_sequence_iter_is_end (_tmp68_);
- _tmp66_ = !_tmp69_;
- } else {
- _tmp66_ = FALSE;
- }
- _tmp70_ = _tmp66_;
- if (!_tmp70_) {
- break;
- }
- _tmp71_ = iter;
- _tmp72_ = egg_list_box_get_next_visible (self, _tmp71_);
- iter = _tmp72_;
- _tmp73_ = iter;
- _tmp74_ = g_sequence_iter_is_end (_tmp73_);
- if (_tmp74_) {
- break;
- }
- _tmp75_ = iter;
- _tmp76_ = g_sequence_get (_tmp75_);
- _tmp77_ = _egg_list_box_child_info_ref0 ((EggListBoxChildInfo*) _tmp76_);
- next = _tmp77_;
- _tmp78_ = next;
- _tmp79_ = _tmp78_->y;
- _tmp80_ = start_y;
- _tmp81_ = page_size;
- if (_tmp79_ > (_tmp80_ + _tmp81_)) {
- _egg_list_box_child_info_unref0 (next);
- break;
- }
- _tmp82_ = next;
- _tmp83_ = _egg_list_box_child_info_ref0 (_tmp82_);
- _egg_list_box_child_info_unref0 (child);
- child = _tmp83_;
- _egg_list_box_child_info_unref0 (next);
- }
- }
- _tmp84_ = child;
- _tmp85_ = _tmp84_->y;
- end_y = _tmp85_;
- _tmp87_ = end_y;
- _tmp88_ = start_y;
- if (_tmp87_ != _tmp88_) {
- GtkAdjustment* _tmp89_;
- _tmp89_ = self->priv->adjustment;
- _tmp86_ = _tmp89_ != NULL;
- } else {
- _tmp86_ = FALSE;
- }
- _tmp90_ = _tmp86_;
- if (_tmp90_) {
- GtkAdjustment* _tmp91_;
- GtkAdjustment* _tmp92_;
- gdouble _tmp93_;
- gdouble _tmp94_;
- gint _tmp95_;
- gint _tmp96_;
- _tmp91_ = self->priv->adjustment;
- _tmp92_ = self->priv->adjustment;
- _tmp93_ = gtk_adjustment_get_value (_tmp92_);
- _tmp94_ = _tmp93_;
- _tmp95_ = end_y;
- _tmp96_ = start_y;
- gtk_adjustment_set_value (_tmp92_, _tmp94_ + (_tmp95_ - _tmp96_));
- }
- }
- break;
- }
- default:
- {
- _egg_list_box_child_info_unref0 (child);
- return;
- }
- }
- _tmp97_ = child;
- if (_tmp97_ == NULL) {
- gtk_widget_error_bell ((GtkWidget*) self);
- _egg_list_box_child_info_unref0 (child);
- return;
- }
- _tmp98_ = child;
- egg_list_box_update_cursor (self, _tmp98_);
- _tmp99_ = modify_selection_pressed;
- if (!_tmp99_) {
- EggListBoxChildInfo* _tmp100_;
- _tmp100_ = child;
- egg_list_box_update_selected (self, _tmp100_);
- }
- _egg_list_box_child_info_unref0 (child);
-}
-
-
-static void g_cclosure_user_marshal_VOID__ENUM_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
- typedef void (*GMarshalFunc_VOID__ENUM_INT) (gpointer data1, gint arg_1, gint arg_2, gpointer data2);
- register GMarshalFunc_VOID__ENUM_INT callback;
- register GCClosure * cc;
- register gpointer data1;
- register gpointer data2;
- cc = (GCClosure *) closure;
- g_return_if_fail (n_param_values == 3);
- if (G_CCLOSURE_SWAP_DATA (closure)) {
- data1 = closure->data;
- data2 = param_values->data[0].v_pointer;
- } else {
- data1 = param_values->data[0].v_pointer;
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__ENUM_INT) (marshal_data ? marshal_data : cc->callback);
- callback (data1, g_value_get_enum (param_values + 1), g_value_get_int (param_values + 2), data2);
-}
+ if (event->window != gtk_widget_get_window (GTK_WIDGET (list_box)))
+ return FALSE;
+ if (event->detail != GDK_NOTIFY_INFERIOR)
+ child = NULL;
+ else
+ child = egg_list_box_find_child_at_y (list_box, event->y);
-static void _egg_list_box_child_info_unref0_ (gpointer var) {
- (var == NULL) ? NULL : (var = (egg_list_box_child_info_unref (var), NULL));
+ egg_list_box_update_prelight (list_box, child);
+ egg_list_box_update_active (list_box, child);
+
+ return FALSE;
}
+static gboolean
+egg_list_box_real_motion_notify_event (GtkWidget *widget,
+ GdkEventMotion *event)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxChildInfo *child;
-static GObject * egg_list_box_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
- GObject * obj;
- GObjectClass * parent_class;
- EggListBox * self;
- GSequence* _tmp0_;
- GHashFunc _tmp1_;
- GEqualFunc _tmp2_;
- GHashTable* _tmp3_;
- GHashFunc _tmp4_;
- GEqualFunc _tmp5_;
- GHashTable* _tmp6_;
- parent_class = G_OBJECT_CLASS (egg_list_box_parent_class);
- obj = parent_class->constructor (type, n_construct_properties, construct_properties);
- self = EGG_LIST_BOX (obj);
- gtk_widget_set_can_focus ((GtkWidget*) self, TRUE);
- gtk_widget_set_has_window ((GtkWidget*) self, TRUE);
- gtk_widget_set_redraw_on_allocate ((GtkWidget*) self, TRUE);
- self->priv->selection_mode = GTK_SELECTION_SINGLE;
- self->priv->activate_single_click = TRUE;
- _tmp0_ = g_sequence_new (_egg_list_box_child_info_unref0_);
- _g_sequence_free0 (self->priv->children);
- self->priv->children = _tmp0_;
- _tmp1_ = g_direct_hash;
- _tmp2_ = g_direct_equal;
- _tmp3_ = g_hash_table_new_full (_tmp1_, _tmp2_, NULL, NULL);
- _g_hash_table_unref0 (self->priv->child_hash);
- self->priv->child_hash = _tmp3_;
- _tmp4_ = g_direct_hash;
- _tmp5_ = g_direct_equal;
- _tmp6_ = g_hash_table_new_full (_tmp4_, _tmp5_, NULL, NULL);
- _g_hash_table_unref0 (self->priv->separator_hash);
- self->priv->separator_hash = _tmp6_;
- return obj;
-}
+ child = egg_list_box_find_child_at_y (list_box, event->y);
+ egg_list_box_update_prelight (list_box, child);
+ egg_list_box_update_active (list_box, child);
-static EggListBoxChildInfo* egg_list_box_child_info_construct (GType object_type, GtkWidget* widget) {
- EggListBoxChildInfo* self = NULL;
- GtkWidget* _tmp0_;
- GtkWidget* _tmp1_;
- g_return_val_if_fail (widget != NULL, NULL);
- self = (EggListBoxChildInfo*) g_type_create_instance (object_type);
- _tmp0_ = widget;
- _tmp1_ = _g_object_ref0 (_tmp0_);
- _g_object_unref0 (self->widget);
- self->widget = _tmp1_;
- return self;
+ return FALSE;
}
+static gboolean
+egg_list_box_real_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
-static EggListBoxChildInfo* egg_list_box_child_info_new (GtkWidget* widget) {
- return egg_list_box_child_info_construct (EGG_LIST_BOX_TYPE_CHILD_INFO, widget);
-}
+ if (event->button == 1)
+ {
+ EggListBoxChildInfo *child;
+ child = egg_list_box_find_child_at_y (list_box, event->y);
+ if (child != NULL)
+ {
+ priv->active_child = child;
+ priv->active_child_active = TRUE;
+ gtk_widget_queue_draw (GTK_WIDGET (list_box));
+ if (event->type == GDK_2BUTTON_PRESS &&
+ !priv->activate_single_click &&
+ child->widget != NULL)
+ g_signal_emit (list_box, signals[CHILD_ACTIVATED], 0,
+ child->widget);
+
+ }
+ /* TODO:
+ Should mark as active while down,
+ and handle grab breaks */
+ }
+
+ return FALSE;
+}
+
+static gboolean
+egg_list_box_real_button_release_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+
+ if (event->button == 1)
+ {
+ if (priv->active_child != NULL &&
+ priv->active_child_active)
+ {
+ if (priv->activate_single_click)
+ egg_list_box_select_and_activate (list_box, priv->active_child);
+ else
+ egg_list_box_update_selected (list_box, priv->active_child);
+ }
+ priv->active_child = NULL;
+ priv->active_child_active = FALSE;
+ gtk_widget_queue_draw (GTK_WIDGET (list_box));
+ }
+
+ return FALSE;
+}
+
+static void
+egg_list_box_real_show (GtkWidget *widget)
+{
+ EggListBox * list_box = EGG_LIST_BOX (widget);
+
+ egg_list_box_reseparate (list_box);
+
+ GTK_WIDGET_CLASS (egg_list_box_parent_class)->show ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (list_box, GTK_TYPE_CONTAINER, GtkContainer));
+}
+
+
+static gboolean
+egg_list_box_real_focus (GtkWidget* widget, GtkDirectionType direction)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+ gboolean had_focus = FALSE;
+ gboolean focus_into = FALSE;
+ GtkWidget* recurse_into;
+ EggListBoxChildInfo *current_focus_child;
+ EggListBoxChildInfo *next_focus_child;
+ gboolean modify_selection_pressed;
+ GdkModifierType state = 0;
+
+ recurse_into = NULL;
+ focus_into = TRUE;
+
+ g_object_get (GTK_WIDGET (list_box), "has-focus", &had_focus, NULL);
+ current_focus_child = NULL;
+ next_focus_child = NULL;
+ if (had_focus)
+ {
+ /* If on row, going right, enter into possible container */
+ if (direction == GTK_DIR_RIGHT || direction == GTK_DIR_TAB_FORWARD)
+ {
+ if (priv->cursor_child != NULL)
+ recurse_into = priv->cursor_child->widget;
+ }
+ current_focus_child = priv->cursor_child;
+ /* Unless we're going up/down we're always leaving
+ the container */
+ if (direction != GTK_DIR_UP && direction != GTK_DIR_DOWN)
+ focus_into = FALSE;
+ }
+ else if (gtk_container_get_focus_child ((GtkContainer*) list_box) != NULL)
+ {
+ /* There is a focus child, always navigat inside it first */
+ recurse_into = gtk_container_get_focus_child ((GtkContainer*) list_box);
+ current_focus_child = egg_list_box_lookup_info (list_box, recurse_into);
+
+ /* If exiting child container to the right, exit row */
+ if (direction == GTK_DIR_RIGHT || direction == GTK_DIR_TAB_FORWARD)
+ focus_into = FALSE;
+
+ /* If exiting child container to the left, select row or out */
+ if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
+ next_focus_child = current_focus_child;
+ }
+ else
+ {
+ /* If coming from the left, enter into possible container */
+ if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
+ {
+ if (priv->selected_child != NULL)
+ recurse_into = priv->selected_child->widget;
+ }
+ }
+ if (recurse_into != NULL)
+ {
+ if (gtk_widget_child_focus (recurse_into, direction))
+ return TRUE;
+ }
-static void egg_list_box_value_child_info_init (GValue* value) {
- value->data[0].v_pointer = NULL;
-}
+ if (!focus_into)
+ return FALSE; /* Focus is leaving us */
+ /* TODO: This doesn't handle up/down going into a focusable separator */
-static void egg_list_box_value_child_info_free_value (GValue* value) {
- if (value->data[0].v_pointer) {
- egg_list_box_child_info_unref (value->data[0].v_pointer);
- }
-}
+ if (next_focus_child == NULL)
+ {
+ if (current_focus_child != NULL)
+ {
+ GSequenceIter* i;
+ if (direction == GTK_DIR_UP)
+ {
+ i = egg_list_box_get_previous_visible (list_box, current_focus_child->iter);
+ if (i != NULL)
+ next_focus_child = g_sequence_get (i);
+
+ }
+ else
+ {
+ i = egg_list_box_get_next_visible (list_box, current_focus_child->iter);
+ if (!g_sequence_iter_is_end (i))
+ next_focus_child = g_sequence_get (i);
+
+ }
+ }
+ else
+ {
+ switch (direction)
+ {
+ case GTK_DIR_DOWN:
+ case GTK_DIR_TAB_FORWARD:
+ next_focus_child = egg_list_box_get_first_visible (list_box);
+ break;
+ case GTK_DIR_UP:
+ case GTK_DIR_TAB_BACKWARD:
+ next_focus_child = egg_list_box_get_last_visible (list_box);
+ break;
+ default:
+ next_focus_child = priv->selected_child;
+ if (next_focus_child == NULL)
+ next_focus_child =
+ egg_list_box_get_first_visible (list_box);
+ break;
+ }
+ }
+ }
+
+ if (next_focus_child == NULL)
+ {
+ if (direction == GTK_DIR_UP || direction == GTK_DIR_DOWN)
+ {
+ gtk_widget_error_bell (GTK_WIDGET (list_box));
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ modify_selection_pressed = FALSE;
+ if (gtk_get_current_event_state (&state))
+ {
+ GdkModifierType modify_mod_mask;
+ modify_mod_mask =
+ gtk_widget_get_modifier_mask (GTK_WIDGET (list_box),
+ GDK_MODIFIER_INTENT_MODIFY_SELECTION);
+ if ((state & modify_mod_mask) == modify_mod_mask)
+ modify_selection_pressed = TRUE;
+ }
+
+ egg_list_box_update_cursor (list_box, next_focus_child);
+ if (!modify_selection_pressed)
+ egg_list_box_update_selected (list_box, next_focus_child);
+
+ return TRUE;
+}
+
+typedef struct {
+ EggListBoxChildInfo *child;
+ GtkStateFlags state;
+} ChildFlags;
+
+static ChildFlags*
+child_flags_find_or_add (ChildFlags *array,
+ int *array_length,
+ EggListBoxChildInfo *to_find)
+{
+ gint i;
+
+ for (i = 0; i < *array_length; i++)
+ {
+ if (array[i].child == to_find)
+ return &array[i];
+ }
+
+ *array_length = *array_length + 1;
+ array[*array_length - 1].child = to_find;
+ array[*array_length - 1].state = 0;
+ return &array[*array_length - 1];
+}
+
+static gboolean
+egg_list_box_real_draw (GtkWidget* widget, cairo_t* cr)
+{
+ EggListBox * list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+ GtkAllocation allocation = {0};
+ GtkStyleContext* context;
+ ChildFlags flags[3], *found;
+ gint flags_length;
+ int i;
+
+ gtk_widget_get_allocation (GTK_WIDGET (list_box), &allocation);
+ context = gtk_widget_get_style_context (GTK_WIDGET (list_box));
+ gtk_render_background (context, cr, (gdouble) 0, (gdouble) 0, (gdouble) allocation.width, (gdouble) allocation.height);
+ flags_length = 0;
+
+ if (priv->selected_child != NULL)
+ {
+ found = child_flags_find_or_add (flags, &flags_length, priv->selected_child);
+ found->state |= GTK_STATE_FLAG_SELECTED;
+ }
+
+ if (priv->prelight_child != NULL)
+ {
+ found = child_flags_find_or_add (flags, &flags_length, priv->prelight_child);
+ found->state |= GTK_STATE_FLAG_PRELIGHT;
+ }
+
+ if (priv->active_child != NULL && priv->active_child_active)
+ {
+ found = child_flags_find_or_add (flags, &flags_length, priv->active_child);
+ found->state |= GTK_STATE_FLAG_ACTIVE;
+ }
+
+ for (i = 0; i < flags_length; i++)
+ {
+ ChildFlags *flag = &flags[i];
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, flag->state);
+ gtk_render_background (context, cr, 0, flag->child->y, allocation.width, flag->child->height);
+ gtk_style_context_restore (context);
+ }
+
+ if (gtk_widget_has_visible_focus (GTK_WIDGET (list_box)) && priv->cursor_child != NULL)
+ gtk_render_focus (context, cr, 0, priv->cursor_child->y, allocation.width, priv->cursor_child->height);
+
+ GTK_WIDGET_CLASS (egg_list_box_parent_class)->draw ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (list_box, GTK_TYPE_CONTAINER, GtkContainer), cr);
+
+ return TRUE;
+}
+
+
+static void
+egg_list_box_real_realize (GtkWidget* widget)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ GtkAllocation allocation;
+ GdkWindowAttr attributes = {0};
+ GdkWindow *window;
+
+ gtk_widget_get_allocation (GTK_WIDGET (list_box), &allocation);
+ gtk_widget_set_realized (GTK_WIDGET (list_box), TRUE);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.event_mask = gtk_widget_get_events (GTK_WIDGET (list_box)) |
+ GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK |
+ GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+
+ window = gdk_window_new (gtk_widget_get_parent_window (GTK_WIDGET (list_box)),
+ &attributes, GDK_WA_X | GDK_WA_Y);
+ gtk_style_context_set_background (gtk_widget_get_style_context (GTK_WIDGET (list_box)), window);
+ gdk_window_set_user_data (window, (GObject*) list_box);
+ gtk_widget_set_window (GTK_WIDGET (list_box), window); /* Passes ownership */
+}
+
+
+static void
+egg_list_box_apply_filter (EggListBox *list_box, GtkWidget *child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ gboolean do_show;
+
+ do_show = TRUE;
+ if (priv->filter_func != NULL)
+ do_show = priv->filter_func (child, priv->filter_func_target);
+
+ gtk_widget_set_child_visible (child, do_show);
+}
+
+static void
+egg_list_box_apply_filter_all (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *child_info;
+ GSequenceIter *iter;
+
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ {
+ child_info = g_sequence_get (iter);
+ egg_list_box_apply_filter (list_box, child_info->widget);
+ }
+}
+
+/* Children are visible if they are shown by the app (visible)
+ and not filtered out (child_visible) by the listbox */
+static gboolean
+child_is_visible (GtkWidget *child)
+{
+ return gtk_widget_get_visible (child) && gtk_widget_get_child_visible (child);
+}
+
+static EggListBoxChildInfo*
+egg_list_box_get_first_visible (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *child_info;
+ GSequenceIter *iter;
+
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ {
+ child_info = g_sequence_get (iter);
+ if (child_is_visible (child_info->widget))
+ return child_info;
+ }
+
+ return NULL;
+}
+
+
+static EggListBoxChildInfo*
+egg_list_box_get_last_visible (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *child_info;
+ GSequenceIter *iter;
+ iter = g_sequence_get_end_iter (priv->children);
+ while (!g_sequence_iter_is_begin (iter))
+ {
+ iter = g_sequence_iter_prev (iter);
+ child_info = g_sequence_get (iter);
+ if (child_is_visible (child_info->widget))
+ return child_info;
+ }
+
+ return NULL;
+}
+
+static GSequenceIter*
+egg_list_box_get_previous_visible (EggListBox *list_box,
+ GSequenceIter* iter)
+{
+ EggListBoxChildInfo *child_info;
+
+ if (g_sequence_iter_is_begin (iter))
+ return NULL;
+
+ do
+ {
+ iter = g_sequence_iter_prev (iter);
+ child_info = g_sequence_get (iter);
+ if (child_is_visible (child_info->widget))
+ return iter;
+ }
+ while (!g_sequence_iter_is_begin (iter));
+
+ return NULL;
+}
-static void egg_list_box_value_child_info_copy_value (const GValue* src_value, GValue* dest_value) {
- if (src_value->data[0].v_pointer) {
- dest_value->data[0].v_pointer = egg_list_box_child_info_ref (src_value->data[0].v_pointer);
- } else {
- dest_value->data[0].v_pointer = NULL;
+static GSequenceIter*
+egg_list_box_get_next_visible (EggListBox *list_box, GSequenceIter* iter)
+{
+ EggListBoxChildInfo *child_info;
+
+ if (g_sequence_iter_is_end (iter))
+ return iter;
+
+ do
+ {
+ iter = g_sequence_iter_next (iter);
+ if (!g_sequence_iter_is_end (iter))
+ {
+ child_info = g_sequence_get (iter);
+ if (child_is_visible (child_info->widget))
+ return iter;
+ }
+ }
+ while (!g_sequence_iter_is_end (iter));
+
+ return iter;
+}
+
+
+static void
+egg_list_box_update_separator (EggListBox *list_box, GSequenceIter* iter)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *info;
+ GSequenceIter *before_iter;
+ GtkWidget *child;
+ GtkWidget *before_child;
+ EggListBoxChildInfo *before_info;
+ GtkWidget *old_separator;
+
+ if (iter == NULL || g_sequence_iter_is_end (iter))
+ return;
+
+ info = g_sequence_get (iter);
+ before_iter = egg_list_box_get_previous_visible (list_box, iter);
+ child = info->widget;
+ if (child)
+ g_object_ref (child);
+ before_child = NULL;
+ if (before_iter != NULL)
+ {
+ before_info = g_sequence_get (before_iter);
+ before_child = before_info->widget;
+ if (before_child)
+ g_object_ref (before_child);
+ }
+
+ if (priv->update_separator_func != NULL &&
+ child_is_visible (child))
+ {
+ old_separator = info->separator;
+ if (old_separator)
+ g_object_ref (old_separator);
+ priv->update_separator_func (&info->separator,
+ child,
+ before_child,
+ priv->update_separator_func_target);
+ if (old_separator != info->separator)
+ {
+ if (old_separator != NULL)
+ {
+ gtk_widget_unparent (old_separator);
+ g_hash_table_remove (priv->separator_hash, old_separator);
+ }
+ if (info->separator != NULL)
+ {
+ g_hash_table_insert (priv->separator_hash, info->separator, info);
+ gtk_widget_set_parent (info->separator, GTK_WIDGET (list_box));
+ gtk_widget_show (info->separator);
+ }
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
+ }
+ if (old_separator)
+ g_object_unref (old_separator);
+ }
+ else
+ {
+ if (info->separator != NULL)
+ {
+ g_hash_table_remove (priv->separator_hash, info->separator);
+ gtk_widget_unparent (info->separator);
+ g_clear_object (&info->separator);
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
}
+ }
+ if (before_child)
+ g_object_unref (before_child);
+ if (child)
+ g_object_unref (child);
}
+static EggListBoxChildInfo*
+egg_list_box_lookup_info (EggListBox *list_box, GtkWidget* child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static gpointer egg_list_box_value_child_info_peek_pointer (const GValue* value) {
- return value->data[0].v_pointer;
+ return g_hash_table_lookup (priv->child_hash, child);
}
+static void
+child_visibility_changed (GObject* object, GParamSpec* pspec, EggListBox *list_box)
+{
+ EggListBoxChildInfo *info;
-static gchar* egg_list_box_value_child_info_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
- if (collect_values[0].v_pointer) {
- EggListBoxChildInfo* object;
- object = collect_values[0].v_pointer;
- if (object->parent_instance.g_class == NULL) {
- return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
- } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
- return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
- }
- value->data[0].v_pointer = egg_list_box_child_info_ref (object);
- } else {
- value->data[0].v_pointer = NULL;
+ if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
+ {
+ info = egg_list_box_lookup_info (list_box, GTK_WIDGET (object));
+ if (info != NULL)
+ {
+ egg_list_box_update_separator (list_box, info->iter);
+ egg_list_box_update_separator (list_box,
+ egg_list_box_get_next_visible (list_box, info->iter));
+ }
+ }
+}
+
+static void
+egg_list_box_real_add (GtkContainer* container, GtkWidget* child)
+{
+ EggListBox *list_box = EGG_LIST_BOX (container);
+ EggListBoxPrivate *priv = list_box->priv;
+ EggListBoxChildInfo *info;
+ GSequenceIter* iter = NULL;
+ info = egg_list_box_child_info_new (child);
+ g_hash_table_insert (priv->child_hash, child, info);
+ if (priv->sort_func != NULL)
+ iter = g_sequence_insert_sorted (priv->children, info,
+ (GCompareDataFunc)do_sort, list_box);
+ else
+ iter = g_sequence_append (priv->children, info);
+
+ info->iter = iter;
+ gtk_widget_set_parent (child, GTK_WIDGET (list_box));
+ egg_list_box_apply_filter (list_box, child);
+ if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
+ {
+ egg_list_box_update_separator (list_box, iter);
+ egg_list_box_update_separator (list_box, egg_list_box_get_next_visible (list_box, iter));
+ }
+ g_signal_connect_object (child, "notify::visible",
+ (GCallback) child_visibility_changed, list_box, 0);
+}
+
+static void
+egg_list_box_real_remove (GtkContainer* container, GtkWidget* child)
+{
+ EggListBox *list_box = EGG_LIST_BOX (container);
+ EggListBoxPrivate *priv = list_box->priv;
+ gboolean was_visible;
+ EggListBoxChildInfo *info;
+ GSequenceIter *next;
+
+ g_return_if_fail (child != NULL);
+ was_visible = gtk_widget_get_visible (child);
+
+ g_signal_handlers_disconnect_by_func (child, (GCallback) child_visibility_changed, list_box);
+
+ info = egg_list_box_lookup_info (list_box, child);
+ if (info == NULL)
+ {
+ info = g_hash_table_lookup (priv->separator_hash, child);
+ if (info != NULL)
+ {
+ g_hash_table_remove (priv->separator_hash, child);
+ g_clear_object (&info->separator);
+ gtk_widget_unparent (child);
+ if (was_visible && gtk_widget_get_visible (GTK_WIDGET (list_box)))
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
}
- return NULL;
-}
-
-
-static gchar* egg_list_box_value_child_info_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
- EggListBoxChildInfo** object_p;
- object_p = collect_values[0].v_pointer;
- if (!object_p) {
- return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
+ else
+ {
+ g_warning ("egg-list-box.vala:846: Tried to remove non-child %p\n", child);
+ }
+ return;
+ }
+
+ if (info->separator != NULL)
+ {
+ g_hash_table_remove (priv->separator_hash, info->separator);
+ gtk_widget_unparent (info->separator);
+ g_clear_object (&info->separator);
+ }
+
+ if (info == priv->selected_child)
+ egg_list_box_update_selected (list_box, NULL);
+ if (info == priv->prelight_child)
+ priv->prelight_child = NULL;
+ if (info == priv->cursor_child)
+ priv->cursor_child = NULL;
+ if (info == priv->active_child)
+ priv->active_child = NULL;
+
+ next = egg_list_box_get_next_visible (list_box, info->iter);
+ gtk_widget_unparent (child);
+ g_hash_table_remove (priv->child_hash, child);
+ g_sequence_remove (info->iter);
+ if (gtk_widget_get_visible (GTK_WIDGET (list_box)))
+ egg_list_box_update_separator (list_box, next);
+
+ if (was_visible && gtk_widget_get_visible (GTK_WIDGET (list_box)))
+ gtk_widget_queue_resize (GTK_WIDGET (list_box));
+}
+
+
+static void
+egg_list_box_real_forall_internal (GtkContainer* container,
+ gboolean include_internals,
+ GtkCallback callback,
+ void* callback_target)
+{
+ EggListBox *list_box = EGG_LIST_BOX (container);
+ EggListBoxPrivate *priv = list_box->priv;
+ GSequenceIter *iter;
+ EggListBoxChildInfo *child_info;
+
+ iter = g_sequence_get_begin_iter (priv->children);
+ while (!g_sequence_iter_is_end (iter))
+ {
+ child_info = g_sequence_get (iter);
+ iter = g_sequence_iter_next (iter);
+ if (child_info->separator != NULL && include_internals)
+ callback (child_info->separator, callback_target);
+ callback (child_info->widget, callback_target);
+ }
+}
+
+static void
+egg_list_box_real_compute_expand_internal (GtkWidget* widget,
+ gboolean* hexpand,
+ gboolean* vexpand)
+{
+ GTK_WIDGET_CLASS (egg_list_box_parent_class)->compute_expand (widget,
+ hexpand, vexpand);
+
+ /* We don't expand vertically beyound the minimum size */
+ if (vexpand)
+ *vexpand = FALSE;
+}
+
+static GType
+egg_list_box_real_child_type (GtkContainer* container)
+{
+ return GTK_TYPE_WIDGET;
+}
+
+static GtkSizeRequestMode
+egg_list_box_real_get_request_mode (GtkWidget* widget)
+{
+ return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
+}
+
+static void
+egg_list_box_real_get_preferred_height (GtkWidget* widget,
+ gint* minimum_height,
+ gint* natural_height)
+{
+ gint natural_width;
+ egg_list_box_real_get_preferred_width (widget, NULL, &natural_width);
+ egg_list_box_real_get_preferred_height_for_width (widget, natural_width,
+ minimum_height, natural_height);
+}
+
+static void
+egg_list_box_real_get_preferred_height_for_width (GtkWidget* widget, gint width,
+ gint* minimum_height_out, gint* natural_height_out)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+ GSequenceIter *iter;
+ gint minimum_height;
+ gint natural_height;
+ GtkStyleContext *context;
+ gint focus_width;
+ gint focus_pad;
+
+ minimum_height = 0;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (list_box));
+ gtk_style_context_get_style (context,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad, NULL);
+
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ {
+ EggListBoxChildInfo *child_info;
+ GtkWidget *child;
+ gint child_min = 0;
+ child_info = g_sequence_get (iter);
+ child = child_info->widget;
+
+ if (!child_is_visible (child))
+ continue;
+
+ if (child_info->separator != NULL)
+ {
+ gtk_widget_get_preferred_height_for_width (child_info->separator, width, &child_min, NULL);
+ minimum_height += child_min;
+ }
+ gtk_widget_get_preferred_height_for_width (child, width - 2 * (focus_width + focus_pad),
+ &child_min, NULL);
+ minimum_height += child_min + 2 * (focus_width + focus_pad);
+ }
+
+ /* We always allocate the minimum height, since handling
+ expanding rows is way too costly, and unlikely to
+ be used, as lists are generally put inside a scrolling window
+ anyway.
+ */
+ natural_height = minimum_height;
+ if (minimum_height_out)
+ *minimum_height_out = minimum_height;
+ if (natural_height_out)
+ *natural_height_out = natural_height;
+}
+
+static void
+egg_list_box_real_get_preferred_width (GtkWidget* widget, gint* minimum_width_out, gint* natural_width_out)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+ gint minimum_width;
+ gint natural_width;
+ GtkStyleContext *context;
+ gint focus_width;
+ gint focus_pad;
+ GSequenceIter *iter;
+ EggListBoxChildInfo *child_info;
+ GtkWidget *child;
+ gint child_min;
+ gint child_nat;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (list_box));
+ gtk_style_context_get_style (context, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL);
+
+ minimum_width = 0;
+ natural_width = 0;
+
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ {
+ child_info = g_sequence_get (iter);
+ child = child_info->widget;
+ if (!child_is_visible (child))
+ continue;
+
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+ minimum_width = MAX (minimum_width, child_min + 2 * (focus_width + focus_pad));
+ natural_width = MAX (natural_width, child_nat + 2 * (focus_width + focus_pad));
+
+ if (child_info->separator != NULL)
+ {
+ gtk_widget_get_preferred_width (child_info->separator, &child_min, &child_nat);
+ minimum_width = MAX (minimum_width, child_min);
+ natural_width = MAX (natural_width, child_nat);
+ }
+ }
+
+ if (minimum_width_out)
+ *minimum_width_out = minimum_width;
+ if (natural_width_out)
+ *natural_width_out = natural_width;
+}
+
+static void
+egg_list_box_real_get_preferred_width_for_height (GtkWidget *widget, gint height,
+ gint *minimum_width, gint *natural_width)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ egg_list_box_real_get_preferred_width (GTK_WIDGET (list_box), minimum_width, natural_width);
+}
+
+static void
+egg_list_box_real_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+ GtkAllocation child_allocation;
+ GtkAllocation separator_allocation;
+ EggListBoxChildInfo *child_info;
+ GdkWindow *window;
+ GtkWidget *child;
+ GSequenceIter *iter;
+ GtkStyleContext *context;
+ gint focus_width;
+ gint focus_pad;
+ int child_min;
+
+
+ child_allocation.x = 0;
+ child_allocation.y = 0;
+ child_allocation.width = 0;
+ child_allocation.height = 0;
+
+ separator_allocation.x = 0;
+ separator_allocation.y = 0;
+ separator_allocation.width = 0;
+ separator_allocation.height = 0;
+
+ gtk_widget_set_allocation (GTK_WIDGET (list_box), allocation);
+ window = gtk_widget_get_window (GTK_WIDGET (list_box));
+ if (window != NULL)
+ gdk_window_move_resize (window,
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (list_box));
+ gtk_style_context_get_style (context,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
+ child_allocation.x = 0 + focus_width + focus_pad;
+ child_allocation.y = 0;
+ child_allocation.width = allocation->width - 2 * (focus_width + focus_pad);
+ separator_allocation.x = 0;
+ separator_allocation.width = allocation->width;
+
+ for (iter = g_sequence_get_begin_iter (priv->children);
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
+ {
+ child_info = g_sequence_get (iter);
+ child = child_info->widget;
+ if (!child_is_visible (child))
+ {
+ child_info->y = child_allocation.y;
+ child_info->height = 0;
+ continue;
}
- if (!value->data[0].v_pointer) {
- *object_p = NULL;
- } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
- *object_p = value->data[0].v_pointer;
- } else {
- *object_p = egg_list_box_child_info_ref (value->data[0].v_pointer);
+
+ if (child_info->separator != NULL)
+ {
+ gtk_widget_get_preferred_height_for_width (child_info->separator,
+ allocation->width, &child_min, NULL);
+ separator_allocation.height = child_min;
+ separator_allocation.y = child_allocation.y;
+ gtk_widget_size_allocate (child_info->separator,
+ &separator_allocation);
+ child_allocation.y += child_min;
}
- return NULL;
-}
+ child_info->y = child_allocation.y;
+ child_allocation.y += focus_width + focus_pad;
-static GParamSpec* egg_list_box_param_spec_child_info (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
- EggListBoxParamSpecChildInfo* spec;
- g_return_val_if_fail (g_type_is_a (object_type, EGG_LIST_BOX_TYPE_CHILD_INFO), NULL);
- spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
- G_PARAM_SPEC (spec)->value_type = object_type;
- return G_PARAM_SPEC (spec);
-}
+ gtk_widget_get_preferred_height_for_width (child, child_allocation.width, &child_min, NULL);
+ child_allocation.height = child_min;
+ child_info->height = child_allocation.height + 2 * (focus_width + focus_pad);
+ gtk_widget_size_allocate (child, &child_allocation);
-static gpointer egg_list_box_value_get_child_info (const GValue* value) {
- g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EGG_LIST_BOX_TYPE_CHILD_INFO), NULL);
- return value->data[0].v_pointer;
+ child_allocation.y += child_min + focus_width + focus_pad;
+ }
}
+void
+egg_list_box_drag_unhighlight_widget (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_value_set_child_info (GValue* value, gpointer v_object) {
- EggListBoxChildInfo* old;
- g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EGG_LIST_BOX_TYPE_CHILD_INFO));
- old = value->data[0].v_pointer;
- if (v_object) {
- g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EGG_LIST_BOX_TYPE_CHILD_INFO));
- g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
- value->data[0].v_pointer = v_object;
- egg_list_box_child_info_ref (value->data[0].v_pointer);
- } else {
- value->data[0].v_pointer = NULL;
- }
- if (old) {
- egg_list_box_child_info_unref (old);
- }
-}
+ g_return_if_fail (list_box != NULL);
+ if (priv->drag_highlighted_widget == NULL)
+ return;
-static void egg_list_box_value_take_child_info (GValue* value, gpointer v_object) {
- EggListBoxChildInfo* old;
- g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, EGG_LIST_BOX_TYPE_CHILD_INFO));
- old = value->data[0].v_pointer;
- if (v_object) {
- g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, EGG_LIST_BOX_TYPE_CHILD_INFO));
- g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
- value->data[0].v_pointer = v_object;
- } else {
- value->data[0].v_pointer = NULL;
- }
- if (old) {
- egg_list_box_child_info_unref (old);
- }
+ gtk_drag_unhighlight (priv->drag_highlighted_widget);
+ g_clear_object (&priv->drag_highlighted_widget);
}
-static void egg_list_box_child_info_class_init (EggListBoxChildInfoClass * klass) {
- egg_list_box_child_info_parent_class = g_type_class_peek_parent (klass);
- EGG_LIST_BOX_CHILD_INFO_CLASS (klass)->finalize = egg_list_box_child_info_finalize;
-}
+void
+egg_list_box_drag_highlight_widget (EggListBox *list_box, GtkWidget *child)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ GtkWidget *old_highlight;
+ g_return_if_fail (list_box != NULL);
+ g_return_if_fail (child != NULL);
-static void egg_list_box_child_info_instance_init (EggListBoxChildInfo * self) {
- self->ref_count = 1;
-}
+ if (priv->drag_highlighted_widget == child)
+ return;
+ egg_list_box_drag_unhighlight_widget (list_box);
+ gtk_drag_highlight (child);
-static void egg_list_box_child_info_finalize (EggListBoxChildInfo* obj) {
- EggListBoxChildInfo * self;
- self = EGG_LIST_BOX_CHILD_INFO (obj);
- _g_object_unref0 (self->widget);
- _g_object_unref0 (self->separator);
+ old_highlight = priv->drag_highlighted_widget;
+ priv->drag_highlighted_widget = g_object_ref (child);
+ if (old_highlight)
+ g_object_unref (old_highlight);
}
+static void
+egg_list_box_real_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time_)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
-static GType egg_list_box_child_info_get_type (void) {
- static volatile gsize egg_list_box_child_info_type_id__volatile = 0;
- if (g_once_init_enter (&egg_list_box_child_info_type_id__volatile)) {
- static const GTypeValueTable g_define_type_value_table = { egg_list_box_value_child_info_init, egg_list_box_value_child_info_free_value, egg_list_box_value_child_info_copy_value, egg_list_box_value_child_info_peek_pointer, "p", egg_list_box_value_child_info_collect_value, "p", egg_list_box_value_child_info_lcopy_value };
- static const GTypeInfo g_define_type_info = { sizeof (EggListBoxChildInfoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) egg_list_box_child_info_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EggListBoxChildInfo), 0, (GInstanceInitFunc) egg_list_box_child_info_instance_init, &g_define_type_value_table };
- static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
- GType egg_list_box_child_info_type_id;
- egg_list_box_child_info_type_id = g_type_register_fundamental (g_type_fundamental_next (), "EggListBoxChildInfo", &g_define_type_info, &g_define_type_fundamental_info, 0);
- g_once_init_leave (&egg_list_box_child_info_type_id__volatile, egg_list_box_child_info_type_id);
- }
- return egg_list_box_child_info_type_id__volatile;
+ egg_list_box_drag_unhighlight_widget (list_box);
+ if (priv->auto_scroll_timeout_id != 0) {
+ g_source_remove (priv->auto_scroll_timeout_id);
+ priv->auto_scroll_timeout_id = 0;
+ }
}
+typedef struct
+{
+ EggListBox *list_box;
+ gint move;
+} MoveData;
-static gpointer egg_list_box_child_info_ref (gpointer instance) {
- EggListBoxChildInfo* self;
- self = instance;
- g_atomic_int_inc (&self->ref_count);
- return instance;
+static void
+move_data_free (MoveData *data)
+{
+ g_slice_free (MoveData, data);
}
+static gboolean
+drag_motion_timeout (MoveData *data)
+{
+ EggListBox *list_box = data->list_box;
+ EggListBoxPrivate *priv = list_box->priv;
-static void egg_list_box_child_info_unref (gpointer instance) {
- EggListBoxChildInfo* self;
- self = instance;
- if (g_atomic_int_dec_and_test (&self->ref_count)) {
- EGG_LIST_BOX_CHILD_INFO_GET_CLASS (self)->finalize (self);
- g_type_free_instance ((GTypeInstance *) self);
- }
+ gtk_adjustment_set_value (priv->adjustment,
+ gtk_adjustment_get_value (priv->adjustment) +
+ gtk_adjustment_get_step_increment (priv->adjustment) * data->move);
+ return TRUE;
}
-
-static EggListBoxChildFlags* egg_list_box_child_flags_find_or_add (EggListBoxChildFlags** array, int* array_length1, EggListBoxChildInfo* to_find) {
- EggListBoxChildFlags* result = NULL;
- EggListBoxChildFlags* _tmp12_;
- gint _tmp12__length1;
- gint _tmp13_ = 0;
- EggListBoxChildFlags* _tmp14_;
- gint _tmp14__length1;
- EggListBoxChildFlags* _tmp15_;
- gint _tmp15__length1;
- EggListBoxChildInfo* _tmp16_;
- EggListBoxChildFlags* _tmp17_;
- gint _tmp17__length1;
- EggListBoxChildFlags* _tmp18_;
- gint _tmp18__length1;
- EggListBoxChildFlags* _tmp19_;
- gint _tmp19__length1;
- EggListBoxChildFlags* _tmp20_;
- gint _tmp20__length1;
- g_return_val_if_fail (to_find != NULL, NULL);
+static gboolean
+egg_list_box_real_drag_motion (GtkWidget *widget, GdkDragContext *context,
+ gint x, gint y, guint time_)
+{
+ EggListBox *list_box = EGG_LIST_BOX (widget);
+ EggListBoxPrivate *priv = list_box->priv;
+ int move;
+ MoveData *data;
+ gdouble size;
+
+ /* Auto-scroll during Dnd if cursor is moving into the top/bottom portion of the
+ * box. */
+ if (priv->auto_scroll_timeout_id != 0)
+ {
+ g_source_remove (priv->auto_scroll_timeout_id);
+ priv->auto_scroll_timeout_id = 0;
+ }
+
+ if (priv->adjustment == NULL)
+ return FALSE;
+
+ /* Part of the view triggering auto-scroll */
+ size = 30;
+ move = 0;
+
+ if (y < (gtk_adjustment_get_value (priv->adjustment) + size))
+ {
+ /* Scroll up */
+ move = -1;
+ }
+ else if (y > ((gtk_adjustment_get_value (priv->adjustment) + gtk_adjustment_get_page_size (priv->adjustment)) - size))
+ {
+ /* Scroll down */
+ move = 1;
+ }
+
+ if (move == 0)
+ return FALSE;
+
+ data = g_slice_new0 (MoveData);
+ data->list_box = list_box;
+
+ priv->auto_scroll_timeout_id =
+ g_timeout_add_full (G_PRIORITY_DEFAULT, 150, (GSourceFunc)drag_motion_timeout,
+ data, (GDestroyNotify) move_data_free);
+
+ return FALSE;
+}
+
+static void
+egg_list_box_real_activate_cursor_child (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+
+ egg_list_box_select_and_activate (list_box, priv->cursor_child);
+}
+
+static void
+egg_list_box_real_toggle_cursor_child (EggListBox *list_box)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+
+ if (priv->cursor_child == NULL)
+ return;
+
+ if (priv->selection_mode == GTK_SELECTION_SINGLE &&
+ priv->selected_child == priv->cursor_child)
+ egg_list_box_update_selected (list_box, NULL);
+ else
+ egg_list_box_select_and_activate (list_box, priv->cursor_child);
+}
+
+static void
+egg_list_box_real_move_cursor (EggListBox *list_box,
+ GtkMovementStep step,
+ gint count)
+{
+ EggListBoxPrivate *priv = list_box->priv;
+ GdkModifierType state;
+ gboolean modify_selection_pressed;
+ EggListBoxChildInfo *child;
+ GdkModifierType modify_mod_mask;
+ EggListBoxChildInfo *prev;
+ EggListBoxChildInfo *next;
+ gint page_size;
+ GSequenceIter *iter;
+ gint start_y;
+ gint end_y;
+
+ modify_selection_pressed = FALSE;
+
+ if (gtk_get_current_event_state (&state))
+ {
+ modify_mod_mask = gtk_widget_get_modifier_mask (GTK_WIDGET (list_box),
+ GDK_MODIFIER_INTENT_MODIFY_SELECTION);
+ if ((state & modify_mod_mask) == modify_mod_mask)
+ modify_selection_pressed = TRUE;
+ }
+
+ child = NULL;
+ switch (step)
+ {
+ case GTK_MOVEMENT_BUFFER_ENDS:
+ if (count < 0)
+ child = egg_list_box_get_first_visible (list_box);
+ else
+ child = egg_list_box_get_last_visible (list_box);
+ break;
+ case GTK_MOVEMENT_DISPLAY_LINES:
+ if (priv->cursor_child != NULL)
+ {
+ iter = priv->cursor_child->iter;
+
+ while (count < 0 && iter != NULL)
+ {
+ iter = egg_list_box_get_previous_visible (list_box, iter);
+ count = count + 1;
+ }
+ while (count > 0 && iter != NULL)
+ {
+ iter = egg_list_box_get_next_visible (list_box, iter);
+ count = count - 1;
+ }
+
+ if (iter != NULL && !g_sequence_iter_is_end (iter))
+ child = g_sequence_get (iter);
+ }
+ break;
+ case GTK_MOVEMENT_PAGES:
+ page_size = 100;
+ if (priv->adjustment != NULL)
+ page_size = gtk_adjustment_get_page_increment (priv->adjustment);
+
+ if (priv->cursor_child != NULL)
{
- gint i;
- i = 0;
+ start_y = priv->cursor_child->y;
+ end_y = start_y;
+ iter = priv->cursor_child->iter;
+
+ child = priv->cursor_child;
+ if (count < 0)
+ {
+ /* Up */
+ while (iter != NULL && !g_sequence_iter_is_begin (iter))
{
- gboolean _tmp0_;
- _tmp0_ = TRUE;
- while (TRUE) {
- gboolean _tmp1_;
- gint _tmp3_;
- EggListBoxChildFlags* _tmp4_;
- gint _tmp4__length1;
- EggListBoxChildFlags* _tmp5_;
- gint _tmp5__length1;
- gint _tmp6_;
- EggListBoxChildFlags _tmp7_;
- EggListBoxChildInfo* _tmp8_;
- EggListBoxChildInfo* _tmp9_;
- _tmp1_ = _tmp0_;
- if (!_tmp1_) {
- gint _tmp2_;
- _tmp2_ = i;
- i = _tmp2_ + 1;
- }
- _tmp0_ = FALSE;
- _tmp3_ = i;
- _tmp4_ = *array;
- _tmp4__length1 = *array_length1;
- if (!(_tmp3_ < _tmp4__length1)) {
- break;
- }
- _tmp5_ = *array;
- _tmp5__length1 = *array_length1;
- _tmp6_ = i;
- _tmp7_ = _tmp5_[_tmp6_];
- _tmp8_ = _tmp7_.child;
- _tmp9_ = to_find;
- if (_tmp8_ == _tmp9_) {
- EggListBoxChildFlags* _tmp10_;
- gint _tmp10__length1;
- gint _tmp11_;
- _tmp10_ = *array;
- _tmp10__length1 = *array_length1;
- _tmp11_ = i;
- result = &_tmp10_[_tmp11_];
- return result;
- }
- }
- }
- }
- _tmp12_ = *array;
- _tmp12__length1 = *array_length1;
- _tmp13_ = _tmp12__length1 + 1;
- *array = g_renew (EggListBoxChildFlags, *array, _tmp12__length1 + 1);
- (_tmp13_ > (*array_length1)) ? memset ((*array) + (*array_length1), 0, sizeof (EggListBoxChildFlags) * (_tmp13_ - (*array_length1))) : NULL;
- *array_length1 = _tmp13_;
- _tmp14_ = *array;
- _tmp14__length1 = *array_length1;
- _tmp15_ = *array;
- _tmp15__length1 = *array_length1;
- _tmp16_ = to_find;
- _tmp14_[_tmp15__length1 - 1].child = _tmp16_;
- _tmp17_ = *array;
- _tmp17__length1 = *array_length1;
- _tmp18_ = *array;
- _tmp18__length1 = *array_length1;
- _tmp17_[_tmp18__length1 - 1].state = 0;
- _tmp19_ = *array;
- _tmp19__length1 = *array_length1;
- _tmp20_ = *array;
- _tmp20__length1 = *array_length1;
- result = &_tmp19_[_tmp20__length1 - 1];
- return result;
-}
-
-
-static EggListBoxChildFlags* egg_list_box_child_flags_dup (const EggListBoxChildFlags* self) {
- EggListBoxChildFlags* dup;
- dup = g_new0 (EggListBoxChildFlags, 1);
- memcpy (dup, self, sizeof (EggListBoxChildFlags));
- return dup;
-}
-
-
-static void egg_list_box_child_flags_free (EggListBoxChildFlags* self) {
- g_free (self);
-}
-
-
-static GType egg_list_box_child_flags_get_type (void) {
- static volatile gsize egg_list_box_child_flags_type_id__volatile = 0;
- if (g_once_init_enter (&egg_list_box_child_flags_type_id__volatile)) {
- GType egg_list_box_child_flags_type_id;
- egg_list_box_child_flags_type_id = g_boxed_type_register_static ("EggListBoxChildFlags", (GBoxedCopyFunc) egg_list_box_child_flags_dup, (GBoxedFreeFunc) egg_list_box_child_flags_free);
- g_once_init_leave (&egg_list_box_child_flags_type_id__volatile, egg_list_box_child_flags_type_id);
- }
- return egg_list_box_child_flags_type_id__volatile;
-}
-
-
-static void egg_list_box_class_init (EggListBoxClass * klass) {
- void* _tmp0_;
- GtkBindingSet* _tmp1_ = NULL;
- GtkBindingSet* binding_set;
- GtkBindingSet* _tmp2_;
- GtkBindingSet* _tmp3_;
- GtkBindingSet* _tmp4_;
- GtkBindingSet* _tmp5_;
- GtkBindingSet* _tmp6_;
- GtkBindingSet* _tmp7_;
- GtkBindingSet* _tmp8_;
- GtkBindingSet* _tmp9_;
- GtkBindingSet* _tmp10_;
- GtkBindingSet* _tmp11_;
- GtkBindingSet* _tmp12_;
- GtkBindingSet* _tmp13_;
- GtkBindingSet* _tmp14_;
- guint _tmp15_ = 0U;
- egg_list_box_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EggListBoxPrivate));
- GTK_WIDGET_CLASS (klass)->enter_notify_event = egg_list_box_real_enter_notify_event;
- GTK_WIDGET_CLASS (klass)->leave_notify_event = egg_list_box_real_leave_notify_event;
- GTK_WIDGET_CLASS (klass)->motion_notify_event = egg_list_box_real_motion_notify_event;
- GTK_WIDGET_CLASS (klass)->button_press_event = egg_list_box_real_button_press_event;
- GTK_WIDGET_CLASS (klass)->button_release_event = egg_list_box_real_button_release_event;
- GTK_WIDGET_CLASS (klass)->show = egg_list_box_real_show;
- GTK_WIDGET_CLASS (klass)->focus = egg_list_box_real_focus;
- GTK_WIDGET_CLASS (klass)->draw = egg_list_box_real_draw;
- GTK_WIDGET_CLASS (klass)->realize = egg_list_box_real_realize;
- GTK_CONTAINER_CLASS (klass)->add = egg_list_box_real_add;
- GTK_CONTAINER_CLASS (klass)->remove = egg_list_box_real_remove;
- GTK_CONTAINER_CLASS (klass)->forall = egg_list_box_real_forall_internal;
- GTK_WIDGET_CLASS (klass)->compute_expand = egg_list_box_real_compute_expand_internal;
- GTK_CONTAINER_CLASS (klass)->child_type = egg_list_box_real_child_type;
- GTK_WIDGET_CLASS (klass)->get_request_mode = egg_list_box_real_get_request_mode;
- GTK_WIDGET_CLASS (klass)->get_preferred_height = egg_list_box_real_get_preferred_height;
- GTK_WIDGET_CLASS (klass)->get_preferred_height_for_width = egg_list_box_real_get_preferred_height_for_width;
- GTK_WIDGET_CLASS (klass)->get_preferred_width = egg_list_box_real_get_preferred_width;
- GTK_WIDGET_CLASS (klass)->get_preferred_width_for_height = egg_list_box_real_get_preferred_width_for_height;
- GTK_WIDGET_CLASS (klass)->size_allocate = egg_list_box_real_size_allocate;
- EGG_LIST_BOX_CLASS (klass)->child_selected = egg_list_box_real_child_selected;
- EGG_LIST_BOX_CLASS (klass)->child_activated = egg_list_box_real_child_activated;
- EGG_LIST_BOX_CLASS (klass)->activate_cursor_child = egg_list_box_real_activate_cursor_child;
- EGG_LIST_BOX_CLASS (klass)->toggle_cursor_child = egg_list_box_real_toggle_cursor_child;
- EGG_LIST_BOX_CLASS (klass)->move_cursor = egg_list_box_real_move_cursor;
- G_OBJECT_CLASS (klass)->constructor = egg_list_box_constructor;
- G_OBJECT_CLASS (klass)->finalize = egg_list_box_finalize;
- g_signal_new ("child_selected", EGG_TYPE_LIST_BOX, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EggListBoxClass, child_selected), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
- g_signal_new ("child_activated", EGG_TYPE_LIST_BOX, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EggListBoxClass, child_activated), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
- g_signal_new ("activate_cursor_child", EGG_TYPE_LIST_BOX, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EggListBoxClass, activate_cursor_child), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
- g_signal_new ("toggle_cursor_child", EGG_TYPE_LIST_BOX, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EggListBoxClass, toggle_cursor_child), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
- g_signal_new ("move_cursor", EGG_TYPE_LIST_BOX, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EggListBoxClass, move_cursor), NULL, NULL, g_cclosure_user_marshal_VOID__ENUM_INT, G_TYPE_NONE, 2, GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT);
- _tmp0_ = klass;
- _tmp1_ = gtk_binding_set_by_class (_tmp0_);
- binding_set = _tmp1_;
- _tmp2_ = binding_set;
- egg_list_box_add_move_binding (_tmp2_, (guint) GDK_KEY_Home, 0, GTK_MOVEMENT_BUFFER_ENDS, -1);
- _tmp3_ = binding_set;
- egg_list_box_add_move_binding (_tmp3_, (guint) GDK_KEY_KP_Home, 0, GTK_MOVEMENT_BUFFER_ENDS, -1);
- _tmp4_ = binding_set;
- egg_list_box_add_move_binding (_tmp4_, (guint) GDK_KEY_End, 0, GTK_MOVEMENT_BUFFER_ENDS, 1);
- _tmp5_ = binding_set;
- egg_list_box_add_move_binding (_tmp5_, (guint) GDK_KEY_KP_End, 0, GTK_MOVEMENT_BUFFER_ENDS, 1);
- _tmp6_ = binding_set;
- egg_list_box_add_move_binding (_tmp6_, (guint) GDK_KEY_Up, GDK_CONTROL_MASK, GTK_MOVEMENT_DISPLAY_LINES, -1);
- _tmp7_ = binding_set;
- egg_list_box_add_move_binding (_tmp7_, (guint) GDK_KEY_KP_Up, GDK_CONTROL_MASK, GTK_MOVEMENT_DISPLAY_LINES, -1);
- _tmp8_ = binding_set;
- egg_list_box_add_move_binding (_tmp8_, (guint) GDK_KEY_Down, GDK_CONTROL_MASK, GTK_MOVEMENT_DISPLAY_LINES, 1);
- _tmp9_ = binding_set;
- egg_list_box_add_move_binding (_tmp9_, (guint) GDK_KEY_KP_Down, GDK_CONTROL_MASK, GTK_MOVEMENT_DISPLAY_LINES, 1);
- _tmp10_ = binding_set;
- egg_list_box_add_move_binding (_tmp10_, (guint) GDK_KEY_Page_Up, 0, GTK_MOVEMENT_PAGES, -1);
- _tmp11_ = binding_set;
- egg_list_box_add_move_binding (_tmp11_, (guint) GDK_KEY_KP_Page_Up, 0, GTK_MOVEMENT_PAGES, -1);
- _tmp12_ = binding_set;
- egg_list_box_add_move_binding (_tmp12_, (guint) GDK_KEY_Page_Down, 0, GTK_MOVEMENT_PAGES, 1);
- _tmp13_ = binding_set;
- egg_list_box_add_move_binding (_tmp13_, (guint) GDK_KEY_KP_Page_Down, 0, GTK_MOVEMENT_PAGES, 1);
- _tmp14_ = binding_set;
- gtk_binding_entry_add_signal (_tmp14_, (guint) GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-child", (guint) 0, NULL);
- _tmp15_ = g_signal_lookup ("activate-cursor-child", EGG_TYPE_LIST_BOX);
- GTK_WIDGET_CLASS (klass)->activate_signal = _tmp15_;
-}
-
-
-static void egg_list_box_instance_init (EggListBox * self) {
- self->priv = EGG_LIST_BOX_GET_PRIVATE (self);
-}
-
-
-static void egg_list_box_finalize (GObject* obj) {
- EggListBox * self;
- self = EGG_LIST_BOX (obj);
- _g_sequence_free0 (self->priv->children);
- _g_hash_table_unref0 (self->priv->child_hash);
- _g_hash_table_unref0 (self->priv->separator_hash);
- (self->priv->sort_func_target_destroy_notify == NULL) ? NULL : (self->priv->sort_func_target_destroy_notify (self->priv->sort_func_target), NULL);
- self->priv->sort_func = NULL;
- self->priv->sort_func_target = NULL;
- self->priv->sort_func_target_destroy_notify = NULL;
- (self->priv->filter_func_target_destroy_notify == NULL) ? NULL : (self->priv->filter_func_target_destroy_notify (self->priv->filter_func_target), NULL);
- self->priv->filter_func = NULL;
- self->priv->filter_func_target = NULL;
- self->priv->filter_func_target_destroy_notify = NULL;
- (self->priv->update_separator_func_target_destroy_notify == NULL) ? NULL : (self->priv->update_separator_func_target_destroy_notify (self->priv->update_separator_func_target), NULL);
- self->priv->update_separator_func = NULL;
- self->priv->update_separator_func_target = NULL;
- self->priv->update_separator_func_target_destroy_notify = NULL;
- _g_object_unref0 (self->priv->adjustment);
- G_OBJECT_CLASS (egg_list_box_parent_class)->finalize (obj);
-}
-
-
-GType egg_list_box_get_type (void) {
- static volatile gsize egg_list_box_type_id__volatile = 0;
- if (g_once_init_enter (&egg_list_box_type_id__volatile)) {
- static const GTypeInfo g_define_type_info = { sizeof (EggListBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) egg_list_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EggListBox), 0, (GInstanceInitFunc) egg_list_box_instance_init, NULL };
- GType egg_list_box_type_id;
- egg_list_box_type_id = g_type_register_static (GTK_TYPE_CONTAINER, "EggListBox", &g_define_type_info, 0);
- g_once_init_leave (&egg_list_box_type_id__volatile, egg_list_box_type_id);
- }
- return egg_list_box_type_id__volatile;
-}
+ iter = egg_list_box_get_previous_visible (list_box, iter);
+ if (iter == NULL)
+ break;
+ prev = g_sequence_get (iter);
+ if (prev->y < start_y - page_size)
+ break;
+ child = prev;
+ }
+ }
+ else
+ {
+ /* Down */
+ while (iter != NULL && !g_sequence_iter_is_end (iter))
+ {
+ iter = egg_list_box_get_next_visible (list_box, iter);
+ if (g_sequence_iter_is_end (iter))
+ break;
+ next = g_sequence_get (iter);
+ if (next->y > start_y + page_size)
+ break;
+
+ child = next;
+ }
+ }
+ end_y = child->y;
+ if (end_y != start_y && priv->adjustment != NULL)
+ gtk_adjustment_set_value (priv->adjustment,
+ gtk_adjustment_get_value (priv->adjustment) +
+ end_y - start_y);
+ }
+ break;
+ default:
+ return;
+ }
+
+ if (child == NULL)
+ {
+ gtk_widget_error_bell (GTK_WIDGET (list_box));
+ return;
+ }
+
+ egg_list_box_update_cursor (list_box, child);
+ if (!modify_selection_pressed)
+ egg_list_box_update_selected (list_box, child);
+}
diff --git a/src/egg-list-box.h b/src/egg-list-box.h
index 56edcfc..c816a14 100644
--- a/src/egg-list-box.h
+++ b/src/egg-list-box.h
@@ -1,6 +1,3 @@
-/* egg-list-box.h generated by valac 0.17.1.22-cd59, the Vala compiler, do not modify */
-
-
#ifndef __EGG_LIST_BOX_H__
#define __EGG_LIST_BOX_H__
@@ -21,41 +18,60 @@ typedef struct _EggListBox EggListBox;
typedef struct _EggListBoxClass EggListBoxClass;
typedef struct _EggListBoxPrivate EggListBoxPrivate;
-struct _EggListBox {
- GtkContainer parent_instance;
- EggListBoxPrivate * priv;
+struct _EggListBox
+{
+ GtkContainer parent_instance;
+ EggListBoxPrivate * priv;
};
-struct _EggListBoxClass {
- GtkContainerClass parent_class;
- void (*child_selected) (EggListBox* self, GtkWidget* child);
- void (*child_activated) (EggListBox* self, GtkWidget* child);
- void (*activate_cursor_child) (EggListBox* self);
- void (*toggle_cursor_child) (EggListBox* self);
- void (*move_cursor) (EggListBox* self, GtkMovementStep step, gint count);
+struct _EggListBoxClass
+{
+ GtkContainerClass parent_class;
+ void (*child_selected) (EggListBox* self, GtkWidget* child);
+ void (*child_activated) (EggListBox* self, GtkWidget* child);
+ void (*activate_cursor_child) (EggListBox* self);
+ void (*toggle_cursor_child) (EggListBox* self);
+ void (*move_cursor) (EggListBox* self, GtkMovementStep step, gint count);
};
typedef gboolean (*EggListBoxFilterFunc) (GtkWidget* child, void* user_data);
typedef void (*EggListBoxUpdateSeparatorFunc) (GtkWidget** separator, GtkWidget* child, GtkWidget* before, void* user_data);
GType egg_list_box_get_type (void) G_GNUC_CONST;
-GtkWidget* egg_list_box_get_selected_child (EggListBox* self);
-GtkWidget* egg_list_box_get_child_at_y (EggListBox* self, gint y);
-void egg_list_box_select_child (EggListBox* self, GtkWidget* child);
-void egg_list_box_set_adjustment (EggListBox* self, GtkAdjustment* adjustment);
-void egg_list_box_add_to_scrolled (EggListBox* self, GtkScrolledWindow* scrolled);
-void egg_list_box_set_selection_mode (EggListBox* self, GtkSelectionMode mode);
-void egg_list_box_set_filter_func (EggListBox* self, EggListBoxFilterFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
-void egg_list_box_set_separator_funcs (EggListBox* self, EggListBoxUpdateSeparatorFunc update_separator, void* update_separator_target, GDestroyNotify update_separator_target_destroy_notify);
-void egg_list_box_refilter (EggListBox* self);
-void egg_list_box_resort (EggListBox* self);
-void egg_list_box_reseparate (EggListBox* self);
-void egg_list_box_set_sort_func (EggListBox* self, GCompareDataFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
-void egg_list_box_child_changed (EggListBox* self, GtkWidget* widget);
-void egg_list_box_set_activate_on_single_click (EggListBox* self, gboolean single);
-EggListBox* egg_list_box_new (void);
-EggListBox* egg_list_box_construct (GType object_type);
-
+GtkWidget* egg_list_box_get_selected_child (EggListBox *self);
+GtkWidget* egg_list_box_get_child_at_y (EggListBox *self,
+ gint y);
+void egg_list_box_select_child (EggListBox *self,
+ GtkWidget *child);
+void egg_list_box_set_adjustment (EggListBox *self,
+ GtkAdjustment *adjustment);
+void egg_list_box_add_to_scrolled (EggListBox *self,
+ GtkScrolledWindow *scrolled);
+void egg_list_box_set_selection_mode (EggListBox *self,
+ GtkSelectionMode mode);
+void egg_list_box_set_filter_func (EggListBox *self,
+ EggListBoxFilterFunc f,
+ void *f_target,
+ GDestroyNotify f_target_destroy_notify);
+void egg_list_box_set_separator_funcs (EggListBox *self,
+ EggListBoxUpdateSeparatorFunc update_separator,
+ void *update_separator_target,
+ GDestroyNotify update_separator_target_destroy_notify);
+void egg_list_box_refilter (EggListBox *self);
+void egg_list_box_resort (EggListBox *self);
+void egg_list_box_reseparate (EggListBox *self);
+void egg_list_box_set_sort_func (EggListBox *self,
+ GCompareDataFunc f,
+ void *f_target,
+ GDestroyNotify f_target_destroy_notify);
+void egg_list_box_child_changed (EggListBox *self,
+ GtkWidget *widget);
+void egg_list_box_set_activate_on_single_click (EggListBox *self,
+ gboolean single);
+void egg_list_box_drag_unhighlight_widget (EggListBox *self);
+void egg_list_box_drag_highlight_widget (EggListBox *self,
+ GtkWidget *widget);
+EggListBox* egg_list_box_new (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]