Commit 9b42f791 authored by Adrien Plazas's avatar Adrien Plazas Committed by Adrien Plazas

dialer: Add the relief property

This allows to set the relief of the dialer buttons.
parent 60ccf2a0
......@@ -4,7 +4,6 @@
<requires lib="gtk+" version="3.20"/>
<template class="HdyDialerButton" parent="GtkButton">
<property name="can_focus">True</property>
<property name="relief">none</property>
<style>
<class name="circular"/>
</style>
......
......@@ -29,6 +29,7 @@ typedef struct
GtkGesture *long_press_del_gesture;
GString *number;
gboolean show_action_buttons;
GtkReliefStyle relief;
} HdyDialerPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (HdyDialer, hdy_dialer, GTK_TYPE_EVENT_BOX)
......@@ -39,6 +40,7 @@ enum {
PROP_SHOW_ACTION_BUTTONS,
PROP_COLUMN_SPACING,
PROP_ROW_SPACING,
PROP_RELIEF,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
......@@ -270,6 +272,10 @@ hdy_dialer_set_property (GObject *object,
(self, g_value_get_boolean (value));
break;
case PROP_RELIEF:
hdy_dialer_set_relief (self, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -302,6 +308,10 @@ hdy_dialer_get_property (GObject *object,
g_value_set_boolean (value, priv->show_action_buttons);
break;
case PROP_RELIEF:
g_value_set_enum (value, hdy_dialer_get_relief (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -418,6 +428,19 @@ hdy_dialer_class_init (HdyDialerClass *klass)
0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* HdyDialer:relief:
*
* The relief style of the edges of the main buttons.
*/
props[PROP_RELIEF] =
g_param_spec_enum ("relief",
_("Main buttons' border relief"),
_("The border relief style of the main buttons"),
GTK_TYPE_RELIEF_STYLE,
GTK_RELIEF_NORMAL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
/**
......@@ -514,6 +537,9 @@ hdy_dialer_init (HdyDialer *self)
HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
g_object_bind_property (self, "relief",
priv->number_btns[0], "relief",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
priv->number = g_string_new (NULL);
priv->cycle_btn = NULL;
......@@ -627,3 +653,51 @@ hdy_dialer_set_show_action_buttons (HdyDialer *self,
g_object_notify_by_pspec
(G_OBJECT (self), props[PROP_SHOW_ACTION_BUTTONS]);
}
/**
* hdy_dialer_set_relief:
* @self: The #HdyDialer whose main buttons you want to set relief styles of
* @relief: The #GtkReliefStyle as described above
*
* Sets the relief style of the edges of the main buttons for the given
* #HdyDialer widget.
* Two styles exist, %GTK_RELIEF_NORMAL and %GTK_RELIEF_NONE.
* The default style is, as one can guess, %GTK_RELIEF_NORMAL.
*/
void
hdy_dialer_set_relief (HdyDialer *self,
GtkReliefStyle relief)
{
HdyDialerPrivate *priv;
g_return_if_fail (HDY_IS_DIALER (self));
priv = hdy_dialer_get_instance_private (self);
if (priv->relief == relief)
return;
priv->relief = relief;
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_RELIEF]);
}
/**
* hdy_dialer_get_relief:
* @self: The #HdyDialer whose main buttons you want the #GtkReliefStyle from
*
* Returns the current relief style of the main buttons for the given
* #HdyDialer.
*
* Returns: The current #GtkReliefStyle
*/
GtkReliefStyle
hdy_dialer_get_relief (HdyDialer *self)
{
HdyDialerPrivate *priv;
g_return_val_if_fail (HDY_IS_DIALER (self), GTK_RELIEF_NORMAL);
priv = hdy_dialer_get_instance_private (self);
return priv->relief;
}
......@@ -44,6 +44,10 @@ gboolean hdy_dialer_get_show_action_buttons (HdyDialer *self);
void hdy_dialer_set_show_action_buttons (HdyDialer *self,
gboolean show);
GtkReliefStyle hdy_dialer_get_relief (HdyDialer *self);
void hdy_dialer_set_relief (HdyDialer *self,
GtkReliefStyle relief);
G_END_DECLS
#endif /* HDY_DIALER_H */
......@@ -21,6 +21,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -33,6 +34,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -45,6 +47,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">2</property>
......@@ -57,6 +60,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -69,6 +73,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -81,6 +86,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">2</property>
......@@ -93,6 +99,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -105,6 +112,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -117,6 +125,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">2</property>
......@@ -129,6 +138,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -153,6 +163,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief" bind-source="btn_0" bind-property="relief" bind-flags="bidirectional|sync-create"/>
</object>
<packing>
<property name="left_attach">2</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