Browse Source

Merge branch 'fix' of slaf/libhandy into master

Adrien Plazas 1 month ago
parent
commit
a1c4ee02df

+ 2 - 2
src/hdy-dialer-button.c

@@ -19,12 +19,12 @@
  */
 
 enum {
-  PROP_0 = 0,
+  PROP_0,
   PROP_DIGIT,
   PROP_LETTERS,
   PROP_LAST_PROP,
 };
-static GParamSpec *props[PROP_LAST_PROP] = { NULL, };
+static GParamSpec *props[PROP_LAST_PROP];
 
 typedef struct
 {

+ 2 - 2
src/hdy-dialer-button.h

@@ -24,8 +24,8 @@ struct _HdyDialerButtonClass
   GtkButtonClass parent_class;
 };
 
-GtkWidget      *hdy_dialer_button_new                   (int          digit,
-                                                         const gchar *letters);
+GtkWidget      *hdy_dialer_button_new                   (int              digit,
+                                                         const gchar     *letters);
 gint            hdy_dialer_button_get_digit             (HdyDialerButton *self);
 char           *hdy_dialer_button_get_letters           (HdyDialerButton *self);
 

+ 21 - 21
src/hdy-dialer-cycle-button.c

@@ -33,14 +33,14 @@ typedef struct
 G_DEFINE_TYPE_WITH_PRIVATE (HdyDialerCycleButton, hdy_dialer_cycle_button, HDY_TYPE_DIALER_BUTTON)
 
 enum {
-  PROP_0 = 0,
+  PROP_0,
   PROP_CYCLE_TIMEOUT,
   PROP_LAST_PROP,
 };
-static GParamSpec *props[PROP_LAST_PROP] = { NULL, };
+static GParamSpec *props[PROP_LAST_PROP];
 
 enum {
-  SIGNAL_CYCLE_START = 0,
+  SIGNAL_CYCLE_START,
   SIGNAL_CYCLE_END,
   SIGNAL_LAST_SIGNAL,
 };
@@ -75,10 +75,10 @@ button_clicked_cb (HdyDialerCycleButton *self,
   g_return_val_if_fail (HDY_IS_DIALER_CYCLE_BUTTON (self), FALSE);
 
   /* Only cycle if we have more than one symbol */
-  if (strlen(hdy_dialer_button_get_letters (HDY_DIALER_BUTTON (self))) < 2)
+  if (strlen (hdy_dialer_button_get_letters (HDY_DIALER_BUTTON (self))) < 2)
     return FALSE;
 
-  if (hdy_dialer_cycle_button_is_cycling(self)) {
+  if (hdy_dialer_cycle_button_is_cycling (self)) {
     g_source_remove (priv->source_id);
     priv->num++;
   } else {
@@ -98,7 +98,7 @@ hdy_dialer_cycle_button_set_property (GObject      *object,
                                       GParamSpec   *pspec)
 {
   HdyDialerCycleButton *self = HDY_DIALER_CYCLE_BUTTON (object);
-  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private(self);
+  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private (self);
 
   switch (property_id) {
 
@@ -119,7 +119,7 @@ hdy_dialer_cycle_button_get_property (GObject    *object,
                                       GParamSpec *pspec)
 {
   HdyDialerCycleButton *self = HDY_DIALER_CYCLE_BUTTON (object);
-  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private(self);
+  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private (self);
 
   switch (property_id) {
   case PROP_CYCLE_TIMEOUT:
@@ -136,16 +136,14 @@ static void
 hdy_dialer_cycle_button_dispose (GObject *object)
 {
   HdyDialerCycleButton *self = HDY_DIALER_CYCLE_BUTTON (object);
-  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private(self);
-  GObjectClass *parent_class = G_OBJECT_CLASS (hdy_dialer_cycle_button_parent_class);
+  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private (self);
 
   if (priv->source_id) {
     g_source_remove (priv->source_id);
     priv->source_id = 0;
   }
 
-  if (parent_class)
-    parent_class->dispose (object);
+  G_OBJECT_CLASS (hdy_dialer_cycle_button_parent_class)->dispose (object);
 }
 
 static void
@@ -221,7 +219,7 @@ GtkWidget *hdy_dialer_cycle_button_new (const gchar* symbols)
 static void
 hdy_dialer_cycle_button_init (HdyDialerCycleButton *self)
 {
-  g_signal_connect(self, "clicked", G_CALLBACK (button_clicked_cb), NULL);
+  g_signal_connect (self, "clicked", G_CALLBACK (button_clicked_cb), NULL);
 
   end_cycle (self);
 }
@@ -238,11 +236,11 @@ hdy_dialer_cycle_button_init (HdyDialerCycleButton *self)
 gunichar
 hdy_dialer_cycle_button_get_current_symbol (HdyDialerCycleButton *self)
 {
-  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private(self);
+  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private (self);
   const gchar *symbols = hdy_dialer_button_get_letters (HDY_DIALER_BUTTON (self));
-  gint off = priv->num % g_utf8_strlen(symbols, -1);
+  gint off = priv->num % g_utf8_strlen (symbols, -1);
 
-  return g_utf8_get_char(g_utf8_offset_to_pointer(symbols, off));
+  return g_utf8_get_char (g_utf8_offset_to_pointer (symbols, off));
 }
 
 /**
@@ -257,13 +255,13 @@ hdy_dialer_cycle_button_get_current_symbol (HdyDialerCycleButton *self)
 gboolean
 hdy_dialer_cycle_button_is_cycling (HdyDialerCycleButton *self)
 {
-  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private(self);
+  HdyDialerCycleButtonPrivate *priv = hdy_dialer_cycle_button_get_instance_private (self);
 
   return !!priv->source_id;
 }
 
 /**
- * hdy_dialer_cycle_button_stop_cycle
+ * hdy_dialer_cycle_button_stop_cycle:
  * @self: a #HdyDialerCycleButton
  *
  * Stop the cycling mode.
@@ -276,14 +274,16 @@ hdy_dialer_cycle_button_stop_cycle (HdyDialerCycleButton *self)
 
   g_return_if_fail (HDY_IS_DIALER_CYCLE_BUTTON (self));
 
-  if (priv->source_id)
-    g_source_remove (priv->source_id);
+  if (priv->source_id) {
+      g_source_remove (priv->source_id);
+      priv->source_id = 0;
+    }
 
   end_cycle(self);
 }
 
 /**
- * hdy_dialer_cycle_button_get_cycle_timeout
+ * hdy_dialer_cycle_button_get_cycle_timeout:
  * @self: a #HdyDialerCycleButton
  *
  * Get the cycle timeout in milliseconds.
@@ -299,7 +299,7 @@ hdy_dialer_cycle_button_get_cycle_timeout (HdyDialerCycleButton *self)
 }
 
 /**
- * hdy_dialer_cycle_button_set_cycle_timeout
+ * hdy_dialer_cycle_button_set_cycle_timeout:
  * @self: a #HdyDialerCycleButton
  *
  * Set the cycle timeout in milliseconds.

+ 2 - 2
src/hdy-dialer-cycle-button.h

@@ -20,7 +20,7 @@ G_BEGIN_DECLS
 G_DECLARE_DERIVABLE_TYPE (HdyDialerCycleButton, hdy_dialer_cycle_button, HDY, DIALER_CYCLE_BUTTON, HdyDialerButton)
 
 /**
- * HdyDialerCycleButtonClass
+ * HdyDialerCycleButtonClass:
  * @parent_class: The parent classqn
  * @cycle_start: Class handler for the #HdyDialerCycleButton::cycle-start signal
  * @cycle_end: Class handler for the #HdyDialerCycleButton::cycle-end signal
@@ -34,7 +34,7 @@ struct _HdyDialerCycleButtonClass
   void (*cycle_end)     (HdyDialerCycleButton    *self);
 };
 
-GtkWidget     *hdy_dialer_cycle_button_new                   (const gchar *symbols);
+GtkWidget     *hdy_dialer_cycle_button_new                   (const gchar          *symbols);
 gunichar       hdy_dialer_cycle_button_get_current_symbol    (HdyDialerCycleButton *self);
 gboolean       hdy_dialer_cycle_button_is_cycling            (HdyDialerCycleButton *self);
 void           hdy_dialer_cycle_button_stop_cycle            (HdyDialerCycleButton *self);

+ 18 - 19
src/hdy-dialer.c

@@ -31,14 +31,14 @@ typedef struct
 G_DEFINE_TYPE_WITH_PRIVATE (HdyDialer, hdy_dialer, GTK_TYPE_GRID)
 
 enum {
-  PROP_0 = 0,
+  PROP_0,
   PROP_NUMBER,
   PROP_LAST_PROP,
 };
-static GParamSpec *props[PROP_LAST_PROP] = { NULL, };
+static GParamSpec *props[PROP_LAST_PROP];
 
 enum {
-  SIGNAL_DIALED = 0,
+  SIGNAL_DIALED,
   SIGNAL_LAST_SIGNAL,
 };
 static guint signals [SIGNAL_LAST_SIGNAL];
@@ -66,8 +66,8 @@ digit_button_clicked (HdyDialer       *self,
 
   stop_cycle_mode (self);
 
-  d = hdy_dialer_button_get_digit(btn);
-  g_string_append_printf(priv->number, "%d", d);
+  d = hdy_dialer_button_get_digit (btn);
+  g_string_append_printf (priv->number, "%d", d);
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NUMBER]);
 }
 
@@ -126,7 +126,7 @@ dial_button_clicked (HdyDialer *self,
 
   stop_cycle_mode (self);
 
-  number = gtk_label_get_label(priv->display);
+  number = gtk_label_get_label (priv->display);
   g_signal_emit (self, signals[SIGNAL_DIALED], 0, number);
 }
 
@@ -162,13 +162,11 @@ update_label (HdyDialer *self,
 static void
 hdy_dialer_finalize (GObject *object)
 {
-  HdyDialerPrivate *priv = hdy_dialer_get_instance_private (HDY_DIALER(object));
-  GObjectClass *parent_class = G_OBJECT_CLASS (hdy_dialer_parent_class);
+  HdyDialerPrivate *priv = hdy_dialer_get_instance_private (HDY_DIALER (object));
 
   g_string_free (priv->number, TRUE);
 
-  if (parent_class->finalize != NULL)
-    parent_class->finalize (object);
+  G_OBJECT_CLASS (hdy_dialer_parent_class)->finalize (object);
 }
 
 static void
@@ -178,11 +176,11 @@ hdy_dialer_set_property (GObject      *object,
                          GParamSpec   *pspec)
 {
   HdyDialer *self = HDY_DIALER (object);
-  HdyDialerPrivate *priv = hdy_dialer_get_instance_private(self);
+  HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
 
   switch (property_id) {
   case PROP_NUMBER:
-    g_string_overwrite(priv->number, 0, g_value_get_string(value));
+    g_string_overwrite (priv->number, 0, g_value_get_string (value));
     break;
 
   default:
@@ -198,7 +196,7 @@ hdy_dialer_get_property (GObject    *object,
                          GParamSpec *pspec)
 {
   HdyDialer *self = HDY_DIALER (object);
-  HdyDialerPrivate *priv = hdy_dialer_get_instance_private(self);
+  HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
 
   switch (property_id) {
   case PROP_NUMBER:
@@ -369,15 +367,15 @@ hdy_dialer_init (HdyDialer *self)
   /* In GTK+4 we can just use the icon-name property */
   image = gtk_image_new_from_icon_name ("edit-clear-symbolic",
                                         GTK_ICON_SIZE_BUTTON);
-  gtk_button_set_image(priv->btn_del, image);
+  gtk_button_set_image (priv->btn_del, image);
 
   gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (),
                                     "/sm/puri/handy/icons");
   image = gtk_image_new_from_icon_name ("phone-dial-symbolic",
                                         GTK_ICON_SIZE_BUTTON * 1.3);
-  gtk_button_set_image(priv->btn_dial, image);
+  gtk_button_set_image (priv->btn_dial, image);
 
-  priv->number = g_string_new(NULL);
+  priv->number = g_string_new (NULL);
   priv->cycle_btn = NULL;
 }
 
@@ -390,7 +388,7 @@ hdy_dialer_init (HdyDialer *self)
  * Returns: (transfer none): the current number in the display
  */
 const char*
-hdy_dialer_get_number(HdyDialer *self)
+hdy_dialer_get_number (HdyDialer *self)
 {
   HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
   return priv->number->str;
@@ -405,10 +403,11 @@ hdy_dialer_get_number(HdyDialer *self)
  *
  */
 void
-hdy_dialer_set_number(HdyDialer *self, const char *newnumber)
+hdy_dialer_set_number (HdyDialer  *self,
+                       const char *newnumber)
 {
   HdyDialerPrivate *priv = hdy_dialer_get_instance_private (self);
 
-  g_string_overwrite(priv->number, 0, newnumber);
+  g_string_overwrite (priv->number, 0, newnumber);
   g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NUMBER]);
 }

+ 2 - 2
src/hdy-dialer.h

@@ -20,7 +20,7 @@ G_BEGIN_DECLS
 G_DECLARE_DERIVABLE_TYPE (HdyDialer, hdy_dialer, HDY, DIALER, GtkGrid)
 
 /**
- * HdyDialerClass
+ * HdyDialerClass:
  * @parent_class: The parent class
  * @dialed: Class handler for the #HdyDialer::dialed signal
  */
@@ -35,7 +35,7 @@ struct _HdyDialerClass
 };
 
 GtkWidget       *hdy_dialer_new                   (void);
-const char      *hdy_dialer_get_number            (HdyDialer *self);
+const char      *hdy_dialer_get_number            (HdyDialer  *self);
 void             hdy_dialer_set_number            (HdyDialer  *self,
                                                    const char *newnumber);
 

+ 6 - 5
src/hdy-string-utf8.c

@@ -16,7 +16,7 @@
  */
 
 /**
- * hdy_string_utf8_truncate
+ * hdy_string_utf8_truncate:
  * @string: a #GString
  * @len: the new size of the string
  *
@@ -25,21 +25,22 @@
  * Returns: (transfer none): @string
  */
 GString *
-hdy_string_utf8_truncate (GString *string, gsize len)
+hdy_string_utf8_truncate (GString *string,
+                          gsize    len)
 {
-  gint cutoff = MIN (len, g_utf8_strlen(string->str, -1));
+  gint cutoff;
   gchar *off;
 
   g_return_val_if_fail (string != NULL, NULL);
 
+  cutoff = MIN (len, g_utf8_strlen (string->str, -1));
   off = g_utf8_offset_to_pointer (string->str, cutoff);
   g_string_truncate (string, off - string->str);
   return string;
 }
 
-
 /**
- * hdy_string_utf8_len
+ * hdy_string_utf8_len:
  * @string: a #GString
  *
  * Computes the length of the string in utf-8 characters. See #g_utf8_strlen.

+ 0 - 2
src/hdy-string-utf8.h

@@ -11,8 +11,6 @@
 #error "Only <handy.h> can be included directly."
 #endif
 
-#include "hdy-dialer-button.h"
-
 G_BEGIN_DECLS
 
 GString*     hdy_string_utf8_truncate   (GString         *string,