Verified Commit bc581d6f authored by Pellegrino Prevete's avatar Pellegrino Prevete

Merge branch 'master' of https://source.puri.sm/Librem5/libhandy into mingw64

parents 1772c4ef b54ede7e
Pipeline #3859 passed with stage
in 3 minutes and 55 seconds
......@@ -20,7 +20,7 @@ build-debian-gcc:
- ninja -C _build
- ninja -C _build meson-libhandy-doc 2>&1 | tee _build/doc/buildlog
- if grep -qs 'warning' _build/doc/buildlog; then exit 1; fi
- xvfb-run ninja -C _build test
- xvfb-run -s -noreset ninja -C _build test
- ninja -C _build coverage
coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
artifacts:
......@@ -37,7 +37,7 @@ build-debian-gcc-static:
- meson . _build -Dintrospection=disabled -Dstatic=true -Dgtk_doc=false --werror
- ninja -C _build
- test -f _build/src/libhandy-0.0.a
- xvfb-run ninja -C _build test
- xvfb-run -s -noreset ninja -C _build test
build-debian-clang:
image: debian:buster
......
%global _vpath_srcdir %{name}
Name: libhandy
Version: 0.0.6
Version: 0.0.7
Release: 1%{?dist}
Summary: A library full of GTK+ widgets for mobile phones
......
libhandy (0.0.7) experimental; urgency=medium
[ Adrien Plazas ]
* glade: Add row widgets to the widget classes. They are missing and don't
appear in Glade.
* glade: Add that HdySearchBar. It's in libhandy since 0.0.6
* action-row: Handle show_all()
This avoids an empty image, an empty subtitle and an empty prefixes box
to be visible when calling show_all(), as they are handled by the row
itself.
* action-row: Add the Since annotation to properties
* example: Make the row with no action non-activatable
* tests: Init libhandy.
This ensures we run the test the same way applications are expected to
run libhandy.
* docs: Add section for new symbols in 0.0.7
* action-row: Add the activatable-widget property.
This allows to bind the activation of the row by a click or a mnemonic
to the activation of a widget.
* action-row: Chain up the parent dispose method
* combo-row: Release the model on dispose.
This avoids errors when trying to disconnect signals on finalization.
* combo-box: Rename selected_position to selecxted_index.
This will better match the name for its accessors which will be added in
the next commit.
* combo-row: Add the selected-index property.
This allows to access the selected item.
* main: Explicitely load the resources in hdy_init()
This is mandatory to use resources of a static version of libhandy, and
is hence mandatory to allow to build libhandy as a static library.
* meson: Bump Meson to 0.47.0.
This is required to use the feature option type in the next commit.
* meson: Make introspection and the Glade catalog features.
This avoids having to disable them when their dependencies aren't
available and it will allow to disable them properly when libhandy will
be allowed to be built as a static library in the next commit.
* meson: Allow to build as a static library.
This also disables the Glade catalog as it doesn't work with a static
libhandy.
* action-row: Drop pointers to internals on destruction.
This avoids crashes when trying to access pointers to already dropped
widgets.
Fixes https://source.puri.sm/Librem5/libhandy/issues/69
* expander-row: Drop pointers to internals on destruction.
This avoids crashes when trying to access pointers to already dropped
widgets.
Fixes https://source.puri.sm/Librem5/libhandy/issues/69
* examples: Make the Dialog section look nicer.
This improves the spacing, adds and icon and adds a description to the
Dialog section.
* dialog: Close when pressing the back button.
Close the dialog instead of destroying it when clicking the back button.
This is the same behavior as when pressing escape or clicking the close
button and allows the dialog to be reused as some applications like to
do.
Fixes https://source.puri.sm/Librem5/libhandy/issues/70
[ louib ]
* Add GNOME Contacts as example
[ Guido Günther ]
* HdyComboRow: Don't use g_autoptr for GEnumClass
g_autoptr for GEnumClass was added post 2.56, so using it makes it
harder for people to package for distros. Not using g_autoptr there
doesn't make the code much less readable.
* HdyDialer: Don't use class method slot for 'delete'
We used the one of 'submit' so far due to a c'n'p error. (Closes: #67)
* HdyComboRow: hdy_combo_row_get_model: Add missing scope annotation
* gitlab-ci: Build static library.
The library build is sufficiently different that we want to run the
build and tests.
* Release libhandy 0.0.7
[ David Cordero ]
* Update documentation regarding build dependencies
[ Zander Brown ]
* Implement HdyDialog, an adaptive GtkDialog
https://source.puri.sm/Librem5/libhandy/issues/52
* example: Add to example application.
Silly simple demo of HdyDialog.
[ Benjamin Berg ]
* combo-row: Rework selected-index property setting and notification.
The notify::selected-index signal was not selected in most cases. Rework
the selection handling to ensure that it is always emited when it changes
or if the module is replaced.
Also fixed are a few checks on whether the selection index is valid.
-- Guido Günther <agx@sigxcpu.org> Fri, 18 Jan 2019 14:38:30 +0100
libhandy (0.0.6) experimental; urgency=medium
[ Adrien Plazas ]
......
......@@ -3,12 +3,14 @@ libhandy-0.0.so.0 libhandy-0.0-0 #MINVER#
hdy_action_row_activate@LIBHANDY_0_0_0 0.0.6
hdy_action_row_add_action@LIBHANDY_0_0_0 0.0.6
hdy_action_row_add_prefix@LIBHANDY_0_0_0 0.0.6
hdy_action_row_get_activatable_widget@LIBHANDY_0_0_0 0.0.7
hdy_action_row_get_icon_name@LIBHANDY_0_0_0 0.0.6
hdy_action_row_get_subtitle@LIBHANDY_0_0_0 0.0.6
hdy_action_row_get_title@LIBHANDY_0_0_0 0.0.6
hdy_action_row_get_type@LIBHANDY_0_0_0 0.0.6
hdy_action_row_get_use_underline@LIBHANDY_0_0_0 0.0.6
hdy_action_row_new@LIBHANDY_0_0_0 0.0.6
hdy_action_row_set_activatable_widget@LIBHANDY_0_0_0 0.0.7
hdy_action_row_set_icon_name@LIBHANDY_0_0_0 0.0.6
hdy_action_row_set_subtitle@LIBHANDY_0_0_0 0.0.6
hdy_action_row_set_title@LIBHANDY_0_0_0 0.0.6
......@@ -32,9 +34,11 @@ libhandy-0.0.so.0 libhandy-0.0-0 #MINVER#
hdy_combo_row_bind_model@LIBHANDY_0_0_0 0.0.6
hdy_combo_row_bind_name_model@LIBHANDY_0_0_0 0.0.6
hdy_combo_row_get_model@LIBHANDY_0_0_0 0.0.6
hdy_combo_row_get_selected_index@LIBHANDY_0_0_0 0.0.7
hdy_combo_row_get_type@LIBHANDY_0_0_0 0.0.6
hdy_combo_row_new@LIBHANDY_0_0_0 0.0.6
hdy_combo_row_set_for_enum@LIBHANDY_0_0_0 0.0.6
hdy_combo_row_set_selected_index@LIBHANDY_0_0_0 0.0.7
hdy_dialer_button_get_digit@LIBHANDY_0_0_0 0.0~git20180429
#MISSING: 0.0.3# hdy_dialer_button_get_letters@LIBHANDY_0_0_0 0.0.4~
hdy_dialer_button_get_symbols@LIBHANDY_0_0_0 0.0.3
......@@ -56,6 +60,8 @@ libhandy-0.0.so.0 libhandy-0.0-0 #MINVER#
hdy_dialer_set_number@LIBHANDY_0_0_0 0.0~git20180429
hdy_dialer_set_relief@LIBHANDY_0_0_0 0.0.3
hdy_dialer_set_show_action_buttons@LIBHANDY_0_0_0 0.0~git20180429
hdy_dialog_get_type@LIBHANDY_0_0_0 0.0.7
hdy_dialog_new@LIBHANDY_0_0_0 0.0.7
hdy_enum_value_object_get_name@LIBHANDY_0_0_0 0.0.6
hdy_enum_value_object_get_nick@LIBHANDY_0_0_0 0.0.6
hdy_enum_value_object_get_type@LIBHANDY_0_0_0 0.0.6
......
......@@ -9,7 +9,7 @@ override_dh_auto_configure:
dh_auto_configure -- -Dgtk_doc=true
override_dh_auto_test:
xvfb-run dh_auto_test
xvfb-run -s -noreset dh_auto_test
override_dh_makeshlibs:
dh_makeshlibs -VUpstream-Version
......
......@@ -50,6 +50,7 @@
<xi:include href="xml/hdy-leaflet.xml"/>
<xi:include href="xml/hdy-search-bar.xml"/>
<xi:include href="xml/hdy-title-bar.xml"/>
<xi:include href="xml/hdy-value-object.xml"/>
</chapter>
<chapter id="helpers">
......@@ -86,6 +87,11 @@
<xi:include href="xml/api-index-0.0.7.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-0-0-8" role="0.0.8">
<title>Index of new symbols in 0.0.8</title>
<xi:include href="xml/api-index-0.0.8.xml"><xi:fallback /></xi:include>
</index>
<index id="annotations-glossary">
<title>Annotations glossary</title>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
......
#include "example-window.h"
#include <glib/gi18n.h>
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
......@@ -18,6 +20,8 @@ struct _ExampleWindow
GtkWidget *arrows;
HdySearchBar *search_bar;
GtkEntry *search_entry;
GtkListBox *arrows_listbox;
HdyComboRow *arrows_direction_row;
GtkListBox *column_listbox;
GtkListBox *lists_listbox;
HdyComboRow *combo_row;
......@@ -152,50 +156,38 @@ stack_visible_child_notify_cb (ExampleWindow *self,
}
static void
btn_arrows_up_toggled_cb (GtkToggleButton *btn,
ExampleWindow *self)
static gchar *
arrows_direction_name (HdyEnumValueObject *value,
gpointer user_data)
{
g_assert (GTK_IS_TOGGLE_BUTTON (btn));
g_assert (EXAMPLE_IS_WINDOW (self));
hdy_arrows_set_direction (HDY_ARROWS (self->arrows), HDY_ARROWS_DIRECTION_UP);
hdy_arrows_animate (HDY_ARROWS (self->arrows));
g_return_val_if_fail (HDY_IS_ENUM_VALUE_OBJECT (value), NULL);
switch (hdy_enum_value_object_get_value (value)) {
case HDY_ARROWS_DIRECTION_UP:
return g_strdup (_("Up"));
case HDY_ARROWS_DIRECTION_DOWN:
return g_strdup (_("Down"));
case HDY_ARROWS_DIRECTION_LEFT:
return g_strdup (_("Left"));
case HDY_ARROWS_DIRECTION_RIGHT:
return g_strdup (_("Right"));
default:
return NULL;
}
}
static void
btn_arrows_down_toggled_cb (GtkToggleButton *btn,
ExampleWindow *self)
notify_arrows_direction_cb (GObject *sender,
GParamSpec *pspec,
ExampleWindow *self)
{
g_assert (GTK_IS_TOGGLE_BUTTON (btn));
g_assert (EXAMPLE_IS_WINDOW (self));
hdy_arrows_set_direction (HDY_ARROWS (self->arrows), HDY_ARROWS_DIRECTION_DOWN);
hdy_arrows_animate (HDY_ARROWS (self->arrows));
}
HdyComboRow *row = HDY_COMBO_ROW (sender);
static void
btn_arrows_left_toggled_cb (GtkToggleButton *btn,
ExampleWindow *self)
{
g_assert (GTK_IS_TOGGLE_BUTTON (btn));
g_assert (HDY_IS_COMBO_ROW (row));
g_assert (EXAMPLE_IS_WINDOW (self));
hdy_arrows_set_direction (HDY_ARROWS (self->arrows), HDY_ARROWS_DIRECTION_LEFT);
hdy_arrows_animate (HDY_ARROWS (self->arrows));
}
static void
btn_arrows_right_toggled_cb (GtkToggleButton *btn,
ExampleWindow *self)
{
g_assert (GTK_IS_TOGGLE_BUTTON (btn));
g_assert (EXAMPLE_IS_WINDOW (self));
hdy_arrows_set_direction (HDY_ARROWS (self->arrows), HDY_ARROWS_DIRECTION_RIGHT);
hdy_arrows_set_direction (HDY_ARROWS (self->arrows), hdy_combo_row_get_selected_index (row));
hdy_arrows_animate (HDY_ARROWS (self->arrows));
}
......@@ -245,6 +237,7 @@ dialog_clicked_cb (GtkButton *btn,
dlg = hdy_dialog_new (GTK_WINDOW (self));
gtk_window_set_title (GTK_WINDOW (dlg), "HdyDialog");
lbl = gtk_label_new ("Hello, World!");
g_object_set (lbl, "margin", 12, NULL);
gtk_widget_set_vexpand (lbl, TRUE);
gtk_widget_set_valign (lbl, GTK_ALIGN_CENTER);
gtk_widget_set_halign (lbl, GTK_ALIGN_CENTER);
......@@ -271,6 +264,7 @@ dialog_action_clicked_cb (GtkButton *btn,
gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_ACCEPT);
g_signal_connect (G_OBJECT (dlg), "response", G_CALLBACK (dialog_close_cb), NULL);
lbl = gtk_label_new ("Hello, World!");
g_object_set (lbl, "margin", 12, NULL);
gtk_widget_set_vexpand (lbl, TRUE);
gtk_widget_set_valign (lbl, GTK_ALIGN_CENTER);
gtk_widget_set_halign (lbl, GTK_ALIGN_CENTER);
......@@ -334,6 +328,8 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, arrows);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, search_bar);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, search_entry);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, arrows_listbox);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, arrows_direction_row);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, column_listbox);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, lists_listbox);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, combo_row);
......@@ -349,66 +345,36 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_bind_template_callback_full (widget_class, "submitted_cb", G_CALLBACK(example_window_submitted_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "symbol_clicked_cb", G_CALLBACK(symbol_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "deleted_cb", G_CALLBACK(deleted_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "btn_arrows_up_toggled_cb", G_CALLBACK(btn_arrows_up_toggled_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "btn_arrows_down_toggled_cb", G_CALLBACK(btn_arrows_down_toggled_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "btn_arrows_left_toggled_cb", G_CALLBACK(btn_arrows_left_toggled_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "btn_arrows_right_toggled_cb", G_CALLBACK(btn_arrows_right_toggled_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "notify_arrows_direction_cb", G_CALLBACK(notify_arrows_direction_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "adj_arrows_count_value_changed_cb", G_CALLBACK(adj_arrows_count_value_changed_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "adj_arrows_duration_value_changed_cb", G_CALLBACK(adj_arrows_duration_value_changed_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "dialog_clicked_cb", G_CALLBACK(dialog_clicked_cb));
gtk_widget_class_bind_template_callback_full (widget_class, "dialog_action_clicked_cb", G_CALLBACK(dialog_action_clicked_cb));
}
static gchar *
combo_get_name (gpointer item,
gpointer user_data)
{
return g_strdup (gtk_label_get_text (GTK_LABEL (item)));
}
static void
lists_page_init (ExampleWindow *self)
{
GListStore *list_store;
HdyValueObject *obj;
gtk_list_box_set_header_func (self->lists_listbox, hdy_list_box_separator_header, NULL, NULL);
list_store = g_list_store_new (GTK_TYPE_LABEL);
g_list_store_insert (list_store, 0,
g_object_new (GTK_TYPE_LABEL,
"ellipsize", PANGO_ELLIPSIZE_END,
"label", "Foo",
"margin", 12,
"max-width-chars", 20,
"visible", TRUE,
"width-chars", 20,
"xalign", 0.0,
NULL));
g_list_store_insert (list_store, 1,
g_object_new (GTK_TYPE_LABEL,
"ellipsize", PANGO_ELLIPSIZE_END,
"label", "Bar",
"margin", 12,
"max-width-chars", 20,
"visible", TRUE,
"width-chars", 20,
"xalign", 0.0,
NULL));
g_list_store_insert (list_store, 2,
g_object_new (GTK_TYPE_LABEL,
"ellipsize", PANGO_ELLIPSIZE_END,
"label", "Baz",
"margin", 12,
"max-width-chars", 20,
"visible", TRUE,
"width-chars", 20,
"xalign", 0.0,
NULL));
hdy_combo_row_bind_name_model (self->combo_row, G_LIST_MODEL (list_store), combo_get_name, NULL, NULL);
list_store = g_list_store_new (HDY_TYPE_VALUE_OBJECT);
obj = hdy_value_object_new_string ("Foo");
g_list_store_insert (list_store, 0, obj);
g_clear_object (&obj);
obj = hdy_value_object_new_string ("Bar");
g_list_store_insert (list_store, 1, obj);
g_clear_object (&obj);
obj = hdy_value_object_new_string ("Baz");
g_list_store_insert (list_store, 2, obj);
g_clear_object (&obj);
hdy_combo_row_bind_name_model (self->combo_row, G_LIST_MODEL (list_store), (HdyComboRowGetNameFunc) hdy_value_object_dup_string, NULL, NULL);
hdy_combo_row_set_for_enum (self->enum_combo_row, GTK_TYPE_LICENSE, hdy_enum_value_row_name, NULL, NULL);
}
......@@ -419,6 +385,9 @@ example_window_init (ExampleWindow *self)
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_set_header_func (self->column_listbox, hdy_list_box_separator_header, NULL, NULL);
gtk_list_box_set_header_func (self->arrows_listbox, hdy_list_box_separator_header, NULL, NULL);
hdy_combo_row_set_for_enum (self->arrows_direction_row, HDY_TYPE_ARROWS_DIRECTION, arrows_direction_name, NULL, NULL);
lists_page_init (self);
hdy_leaflet_set_visible_child_name (self->content_box, "content");
......
This diff is collapsed.
project('libhandy', 'c',
version: '0.0.6',
version: '0.0.7',
license: 'LGPL-2.1+',
meson_version: '>= 0.47.0',
default_options: [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11' ],
......
......@@ -4,6 +4,7 @@ ABS_BUILDDIR='@ABS_BUILDDIR@'
ABS_SRCDIR='@ABS_SRCDIR@'
export GLADE_CATALOG_SEARCH_PATH="${ABS_SRCDIR}/glade/:${GLADE_CATALOG_SEARCH_PATH}"
export GLADE_MODULE_SEARCH_PATH="${ABS_BUILDDIR}/glade:${GLADE_MODULE_SEARCH_PATH}"
export GI_TYPELIB_PATH="${ABS_BUILDDIR}/src:$GI_TYPELIB_PATH"
export LD_LIBRARY_PATH="${ABS_BUILDDIR}/src:${ABS_BUILDDIR}/glade:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="${ABS_BUILDDIR}/src:$PKG_CONFIG_PATH"
......
......@@ -43,6 +43,7 @@ G_BEGIN_DECLS
#include "hdy-search-bar.h"
#include "hdy-string-utf8.h"
#include "hdy-title-bar.h"
#include "hdy-value-object.h"
#undef _HANDY_INSIDE
......
......@@ -198,9 +198,14 @@ static void
hdy_action_row_destroy (GtkWidget *widget)
{
HdyActionRow *self = HDY_ACTION_ROW (widget);
HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
hdy_action_row_set_activatable_widget (self, NULL);
priv->prefixes = NULL;
priv->header = NULL;
priv->box = NULL;
GTK_WIDGET_CLASS (hdy_action_row_parent_class)->destroy (widget);
}
......@@ -260,9 +265,12 @@ hdy_action_row_forall (GtkContainer *container,
data.callback = callback;
data.callback_data = callback_data;
GTK_CONTAINER_GET_CLASS (priv->prefixes)->forall (GTK_CONTAINER (priv->prefixes), include_internals, for_non_internal_child, &data);
GTK_CONTAINER_GET_CLASS (priv->header)->forall (GTK_CONTAINER (priv->header), include_internals, for_non_internal_child, &data);
GTK_CONTAINER_GET_CLASS (priv->box)->forall (GTK_CONTAINER (priv->box), include_internals, for_non_internal_child, &data);
if (priv->prefixes)
GTK_CONTAINER_GET_CLASS (priv->prefixes)->forall (GTK_CONTAINER (priv->prefixes), include_internals, for_non_internal_child, &data);
if (priv->header)
GTK_CONTAINER_GET_CLASS (priv->header)->forall (GTK_CONTAINER (priv->header), include_internals, for_non_internal_child, &data);
if (priv->box)
GTK_CONTAINER_GET_CLASS (priv->box)->forall (GTK_CONTAINER (priv->box), include_internals, for_non_internal_child, &data);
}
static void
......
......@@ -14,6 +14,9 @@
<property name="spacing">12</property>
<property name="valign">center</property>
<property name="visible">True</property>
<style>
<class name="row-header"/>
</style>
<child>
<object class="GtkBox" id="prefixes">
<property name="can_focus">False</property>
......
......@@ -118,20 +118,19 @@ static void
update (HdyComboRow *self)
{
HdyComboRowPrivate *priv = hdy_combo_row_get_instance_private (self);
gpointer item;
g_autoptr(GObject) item = NULL;
GtkWidget *widget;
gtk_container_foreach (GTK_CONTAINER (priv->current), (GtkCallback) gtk_widget_destroy, NULL);
if (priv->bound_model == NULL || g_list_model_get_n_items (priv->bound_model) == 0) {
gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
priv->selected_index = -1;
g_assert (priv->selected_index == -1);
return;
}
if (priv->selected_index == -1)
priv->selected_index = 0;
g_assert (priv->selected_index >= 0 && priv->selected_index <= g_list_model_get_n_items (priv->bound_model));
gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE);
......@@ -147,31 +146,34 @@ bound_model_changed (GListModel *list,
guint added,
gpointer user_data)
{
gint new_idx;
HdyComboRow *self = HDY_COMBO_ROW (user_data);
HdyComboRowPrivate *priv = hdy_combo_row_get_instance_private (self);
if (priv->selected_index < index)
/* Selection is in front of insertion/removal point, nothing to do */
if (priv->selected_index > 0 && priv->selected_index < index)
return;
if (priv->selected_index < index + removed) {
priv->selected_index = -1;
return;
/* The item selected item was removed (or none is selected) */
new_idx = -1;
} else {
/* The item selected item was behind the insertion/removal */
new_idx = priv->selected_index + added - removed;
}
priv->selected_index += added;
/* Select the first item if none is selected. */
if (new_idx == -1 && g_list_model_get_n_items (list) > 0)
new_idx = 0;
update (self);
hdy_combo_row_set_selected_index (self, new_idx);
}
static void
row_activated_cb (HdyComboRow *self,
GtkListBoxRow *row)
{
HdyComboRowPrivate *priv = hdy_combo_row_get_instance_private (self);
priv->selected_index = gtk_list_box_row_get_index (row);
update (self);
hdy_combo_row_set_selected_index (self, gtk_list_box_row_get_index (row));
}
static void
......@@ -447,6 +449,7 @@ hdy_combo_row_bind_model (HdyComboRow *self,
if (model == NULL) {
update (self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SELECTED_INDEX]);
return;
}
......@@ -460,7 +463,12 @@ hdy_combo_row_bind_model (HdyComboRow *self,
g_signal_connect (priv->bound_model, "items-changed", G_CALLBACK (bound_model_changed), self);
if (g_list_model_get_n_items (priv->bound_model) > 0)
priv->selected_index = 0;
update (self);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_SELECTED_INDEX]);
}
/**
......@@ -547,7 +555,11 @@ hdy_combo_row_set_for_enum (HdyComboRow *self,
enum_class = g_type_class_ref (enum_type);
for (i = 0; i < enum_class->n_values; i++)
g_list_store_append (store, hdy_enum_value_object_new (&enum_class->values[i]));
{
g_autoptr(HdyEnumValueObject) obj = hdy_enum_value_object_new (&enum_class->values[i]);
g_list_store_append (store, obj);
}
hdy_combo_row_bind_name_model (self, G_LIST_MODEL (store), (HdyComboRowGetNameFunc) get_name_func, user_data, user_data_free_func);
g_type_class_unref (enum_class);
......@@ -595,8 +607,8 @@ hdy_combo_row_set_selected_index (HdyComboRow *self,
priv = hdy_combo_row_get_instance_private (self);
g_return_if_fail ((priv->bound_model == NULL && selected_index == -1) || (priv->bound_model != NULL && selected_index != -1));
g_return_if_fail (selected_index < g_list_model_get_n_items (priv->bound_model));
g_return_if_fail (selected_index >= 0 || priv->bound_model == NULL || g_list_model_get_n_items (priv->bound_model) == 0);
g_return_if_fail (selected_index == -1 || (priv->bound_model != NULL && selected_index < g_list_model_get_n_items (priv->bound_model)));
if (priv->selected_index == selected_index)
return;
......
......@@ -312,8 +312,7 @@ back_clicked_cb (GtkButton *back,
{
HdyDialog *self = HDY_DIALOG (user_data);
/* Close ourself */
gtk_widget_destroy (GTK_WIDGET (self));
g_signal_emit_by_name (self, "close", NULL);
}
static void
......
......@@ -96,6 +96,17 @@ hdy_expander_row_set_property (GObject *object,
}
}
static void
hdy_expander_row_destroy (GtkWidget *widget)
{
HdyExpanderRow *self = HDY_EXPANDER_ROW (widget);
HdyExpanderRowPrivate *priv = hdy_expander_row_get_instance_private (self);
priv->box = NULL;
GTK_WIDGET_CLASS (hdy_expander_row_parent_class)->destroy (widget);
}
static void
hdy_expander_row_add (GtkContainer *container,
GtkWidget *child)
......@@ -153,7 +164,8 @@ hdy_expander_row_forall (GtkContainer *container,
data.callback_data = callback_data;
GTK_CONTAINER_CLASS (hdy_expander_row_parent_class)->forall (GTK_CONTAINER (self), include_internals, for_non_internal_child, &data);
GTK_CONTAINER_GET_CLASS (priv->box)->forall (GTK_CONTAINER (priv->box), include_internals, callback, callback_data);
if (priv->box)
GTK_CONTAINER_GET_CLASS (priv->box)->forall (GTK_CONTAINER (priv->box), include_internals, callback, callback_data);
}
static void
......@@ -178,6 +190,8 @@ hdy_expander_row_class_init (HdyExpanderRowClass *klass)
object_class->get_property = hdy_expander_row_get_property;
object_class->set_property = hdy_expander_row_set_property;
widget_class->destroy = hdy_expander_row_destroy;
container_class->add = hdy_expander_row_add;
container_class->forall = hdy_expander_row_forall;
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="HdyExpanderRow" parent="HdyActionRow">
<style>
<class name="expander"/>
</style>
<child type="action">
<object class="GtkSwitch" id="enable_switch">
<property name="can_focus">True</property>
......
/*
* Copyright (C) 2019 Red Hat Inc.
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include <glib/gi18n.h>
#include <gobject/gvaluecollector.h>
#include "hdy-value-object.h"
/**
* SECTION:hdy-value-object
* @short_description: An object representing a #GValue.
* @Title: HdyValueObject
*
* The #HdyValueObject object represents a #GValue, allowing it to be
* used with #GListModel.
*
* Since: 0.0.8
*/
struct _HdyValueObject
{
GObject parent_instance;
GValue value;
};
G_DEFINE_TYPE (HdyValueObject, hdy_value_object, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_VALUE,
N_PROPS
};
static GParamSpec *props [N_PROPS];
/**
* hdy_value_object_new:
* @value: the #GValue to store
*
* Create a new #HdyValueObject.
*
* Returns: a new #HdyValueObject
* Since: 0.0.8
*/
HdyValueObject *
hdy_value_object_new (const GValue *value)
{
return g_object_new (HDY_TYPE_VALUE_OBJECT,
"value", value,
NULL);
}
/**
* hdy_value_object_new_collect: (skip)
* @type: the #GType of the value
* @...: the value to store
*
* Creates a new #HdyValueObject. This is a convenience method which uses
* the G_VALUE_COLLECT() macro internally.
*
* Returns: a new #HdyValueObject
* Since: 0.0.8
*/
HdyValueObject*
hdy_value_object_new_collect (GType type, ...)
{
g_auto(GValue) value = G_VALUE_INIT;
g_autofree gchar *error = NULL;
va_list var_args;
va_start (var_args, type);
G_VALUE_COLLECT_INIT (&value, type, var_args, 0, &error);
va_end (var_args);
if (error)
g_critical ("%s: %s", G_STRFUNC, error);
return g_object_new (HDY_TYPE_VALUE_OBJECT,
"value", &value,
NULL);
}
/**
* hdy_value_object_new_string: (skip)
* @string: (transfer none): the string to store
*
* Creates a new #HdyValueObject. This is a convenience method to create a
* #HdyValueObject that stores a string.
*
* Returns: a new #HdyValueObject
* Since: 0.0.8
*/
HdyValueObject*