Commit 2938fc6d authored by Adrien Plazas's avatar Adrien Plazas

dialer: Add column-spacing and row-spacing props

This allows the users to control the spacing of the dialer's grid.
parent 2d3c1b6c
......@@ -22,6 +22,7 @@
typedef struct
{
GtkGrid *grid;
HdyDialerButton *number_btns[10];
HdyDialerCycleButton *btn_hash, *btn_star, *cycle_btn;
GtkButton *btn_submit, *btn_del;
......@@ -35,6 +36,8 @@ enum {
PROP_0,
PROP_NUMBER,
PROP_SHOW_ACTION_BUTTONS,
PROP_COLUMN_SPACING,
PROP_ROW_SPACING,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
......@@ -235,11 +238,19 @@ hdy_dialer_set_property (GObject *object,
HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
switch (property_id) {
case PROP_COLUMN_SPACING:
gtk_grid_set_column_spacing (priv->grid, g_value_get_uint (value));
break;
case PROP_NUMBER:
g_string_assign (priv->number, g_value_get_string (value));
g_object_notify_by_pspec (object, pspec);
break;
case PROP_ROW_SPACING:
gtk_grid_set_row_spacing (priv->grid, g_value_get_uint (value));
break;
case PROP_SHOW_ACTION_BUTTONS:
hdy_dialer_set_show_action_buttons
(self, g_value_get_boolean (value));
......@@ -261,10 +272,18 @@ hdy_dialer_get_property (GObject *object,
HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
switch (property_id) {
case PROP_COLUMN_SPACING:
g_value_set_uint (value, gtk_grid_get_column_spacing (priv->grid));
break;
case PROP_NUMBER:
g_value_set_string (value, priv->number->str);
break;
case PROP_ROW_SPACING:
g_value_set_uint (value, gtk_grid_get_row_spacing (priv->grid));
break;
case PROP_SHOW_ACTION_BUTTONS:
g_value_set_boolean (value, priv->show_action_buttons);
break;
......@@ -368,6 +387,20 @@ hdy_dialer_class_init (HdyDialerClass *klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
props[PROP_COLUMN_SPACING] =
g_param_spec_uint ("column-spacing",
_("Column spacing"),
_("The amount of space between two consecutive columns"),
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
props[PROP_ROW_SPACING] =
g_param_spec_uint ("row-spacing",
_("Row spacing"),
_("The amount of space between two consecutive rows"),
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
/**
......@@ -436,6 +469,7 @@ hdy_dialer_class_init (HdyDialerClass *klass)
FALSE,
G_PRIVATE_OFFSET(HdyDialer, number_btns[i]));
}
gtk_widget_class_bind_template_child_private (widget_class, HdyDialer, grid);
gtk_widget_class_bind_template_child_private (widget_class, HdyDialer, btn_hash);
gtk_widget_class_bind_template_child_private (widget_class, HdyDialer, btn_star);
gtk_widget_class_bind_template_child_private (widget_class, HdyDialer, btn_submit);
......
......@@ -7,7 +7,7 @@
<property name="visible_window">False</property>
<property name="above_child">False</property>
<child>
<object class="GtkGrid">
<object class="GtkGrid" id="grid">
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment