[Pkg-xfce-commits] [Git][xfce-team/goodies/xfce4-sensors-plugin][debian/master] 4 commits: New upstream version 1.4.3.

Unit 193 (@unit193) gitlab at salsa.debian.org
Tue Feb 15 19:33:53 GMT 2022



Unit 193   pushed to branch debian/master at xfce / goodies / xfce4-sensors-plugin


Commits:
7e3125e7 by Unit 193 at 2022-02-15T14:28:56-05:00
New upstream version 1.4.3.
- - - - -
684337dd by Unit 193 at 2022-02-15T14:29:01-05:00
Update upstream source from tag 'upstream/1.4.3'

Update to upstream version '1.4.3'
with Debian dir 45d7c9855e8b3cbdbe86506fb243459fed99b861
- - - - -
c35c166a by Unit 193 at 2022-02-15T14:29:42-05:00
d/README.Debian: Drop, no longer useful.

- - - - -
66fcd6c0 by Unit 193 at 2022-02-15T14:32:46-05:00
Update changelog for release.

- - - - -


15 changed files:

- NEWS
- configure
- configure.ac
- − debian/README.Debian
- debian/changelog
- lib/configuration.cc
- po/sv.po
- xfce4++/util/fixes.h
- xfce4++/util/gtk.cc
- xfce4++/util/gtk.h
- xfce4++/util/memory.h
- xfce4++/util/rc.cc
- xfce4++/util/rc.h
- xfce4++/util/string-utils.cc
- xfce4++/util/string-utils.h


Changes:

=====================================
NEWS
=====================================
@@ -1,3 +1,10 @@
+1.4.3 (2022-02-02)
+=====
+- Fix translations not showing in the GUI
+- Use locale-independent floats in configuration files
+- Translation Updates:
+  Swedish
+
 1.4.2 (2021-11-15)
 =====
 - Prevent overlap of tachometer titles and improve standalone app layout


=====================================
configure
=====================================
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for xfce4-sensors-plugin 1.4.2.
+# Generated by GNU Autoconf 2.69 for xfce4-sensors-plugin 1.4.3.
 #
 # Report bugs to <https://gitlab.xfce.org/panel-plugins/xfce4-sensors-plugin/>.
 #
@@ -591,8 +591,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='xfce4-sensors-plugin'
 PACKAGE_TARNAME='xfce4-sensors-plugin'
-PACKAGE_VERSION='1.4.2'
-PACKAGE_STRING='xfce4-sensors-plugin 1.4.2'
+PACKAGE_VERSION='1.4.3'
+PACKAGE_STRING='xfce4-sensors-plugin 1.4.3'
 PACKAGE_BUGREPORT='https://gitlab.xfce.org/panel-plugins/xfce4-sensors-plugin/'
 PACKAGE_URL=''
 
@@ -1448,7 +1448,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures xfce4-sensors-plugin 1.4.2 to adapt to many kinds of systems.
+\`configure' configures xfce4-sensors-plugin 1.4.3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1520,7 +1520,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of xfce4-sensors-plugin 1.4.2:";;
+     short | recursive ) echo "Configuration of xfce4-sensors-plugin 1.4.3:";;
    esac
   cat <<\_ACEOF
 
@@ -1669,7 +1669,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-xfce4-sensors-plugin configure 1.4.2
+xfce4-sensors-plugin configure 1.4.3
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2159,7 +2159,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by xfce4-sensors-plugin $as_me 1.4.2, which was
+It was created by xfce4-sensors-plugin $as_me 1.4.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3027,7 +3027,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='xfce4-sensors-plugin'
- VERSION='1.4.2'
+ VERSION='1.4.3'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -19455,7 +19455,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by xfce4-sensors-plugin $as_me 1.4.2, which was
+This file was extended by xfce4-sensors-plugin $as_me 1.4.3, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -19521,7 +19521,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-xfce4-sensors-plugin config.status 1.4.2
+xfce4-sensors-plugin config.status 1.4.3
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 


=====================================
configure.ac
=====================================
@@ -16,8 +16,8 @@ dnl Version information
 AC_CONFIG_MACRO_DIRS([m4])
 m4_define([sensors_version_major], [1])
 m4_define([sensors_version_minor], [4])
-m4_define([sensors_version_micro], [2])
-m4_define([sensors_version_build], [096efe3])
+m4_define([sensors_version_micro], [3])
+m4_define([sensors_version_build], [d417165])
 m4_define([sensors_version_tag], [])
 m4_define([sensors_version], [sensors_version_major().sensors_version_minor().sensors_version_micro()ifelse(sensors_version_tag(), [git], [sensors_version_tag()-sensors_version_build()], [sensors_version_tag()])])
 


=====================================
debian/README.Debian deleted
=====================================
@@ -1,3 +0,0 @@
-In order to monitor the temperature of hard disks hddtemp must be installed
-with the SUID bit set. If you did not choose this at installation time, you
-can run dpkg-reconfigure hddtemp and change it.


=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+xfce4-sensors-plugin (1.4.3-1) unstable; urgency=medium
+
+  * Team upload.
+  * New upstream version 1.4.3.
+  * d/README.Debian: Drop, no longer useful.
+
+ -- Unit 193 <unit193 at debian.org>  Tue, 15 Feb 2022 14:29:53 -0500
+
 xfce4-sensors-plugin (1.4.2-2) unstable; urgency=medium
 
   * Team upload.


=====================================
lib/configuration.cc
=====================================
@@ -134,8 +134,8 @@ sensors_write_config (XfcePanelPlugin *plugin, const Ptr<const t_sensors> &senso
 
                         rc->write_bool_entry ("Show", feature->show);
 
-                        rc->write_entry ("Min", xfce4::sprintf ("%.2f", feature->min_value));
-                        rc->write_entry ("Max", xfce4::sprintf ("%.2f", feature->max_value));
+                        rc->write_float_entry ("Min", feature->min_value);
+                        rc->write_float_entry ("Max", feature->max_value);
                     }
                 }
             }
@@ -309,11 +309,8 @@ sensors_read_config (XfcePanelPlugin *plugin, const Ptr<t_sensors> &sensors)
 
                                 feature->show = rc->read_bool_entry ("Show", FALSE);
 
-                                if ((str_value = rc->read_entry ("Min", NULL)) && !str_value->empty())
-                                    feature->min_value = atof (str_value->c_str());
-
-                                if ((str_value = rc->read_entry ("Max", NULL)) && !str_value->empty())
-                                    feature->max_value = atof (str_value->c_str());
+                                feature->min_value = rc->read_float_entry ("Min", feature->min_value);
+                                feature->max_value = rc->read_float_entry ("Max", feature->max_value);
                             }
                         }
                     }


=====================================
po/sv.po
=====================================
@@ -3,6 +3,7 @@
 # This file is distributed under the same license as the PACKAGE package..
 # 
 # Translators:
+# Arve Eriksson <031299870 at telia.com>, 2021
 # Daniel Nylander <po at danielnylander.se>, 2008
 # Luna Jernberg <bittin at cafe8bitar.se>, 2020-2021
 # Påvel Nicklasson<pavel at frimix.se>, 2015
@@ -11,8 +12,8 @@ msgstr ""
 "Project-Id-Version: Xfce Panel Plugins\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2021-07-22 00:48+0200\n"
-"PO-Revision-Date: 2021-07-21 22:48+0000\n"
-"Last-Translator: Xfce Bot <transifex at xfce.org>\n"
+"PO-Revision-Date: 2021-11-21 08:04+0000\n"
+"Last-Translator: Arve Eriksson <031299870 at telia.com>\n"
 "Language-Team: Swedish (http://www.transifex.com/xfce/xfce-panel-plugins/language/sv/)\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
@@ -62,7 +63,7 @@ msgstr "Visa _etiketter"
 
 #: ../panel-plugin/sensors-plugin.c:1779
 msgid "_Automatic bar colors"
-msgstr ""
+msgstr "_Automatiska fältfärger"
 
 #: ../panel-plugin/sensors-plugin.c:1781
 msgid ""
@@ -70,7 +71,7 @@ msgid ""
 "If disabled, bars use the user-defined sensor colors.\n"
 "If a particular user-defined sensor color is unspecified,\n"
 "the bar color is derived from the current UI style."
-msgstr ""
+msgstr "Om det aktiveras kommer fältfärger att bero på deras värden (normal, hög, mycket hög).\nOm det avaktiveras kommer fält att använda de användardefinierade sensorfärgerna.\nOm en viss användardefinierad sensorfärg lämnas ospecificerad\nkommer fältfärgen att hämtas från aktuell UI-stil."
 
 #: ../panel-plugin/sensors-plugin.c:1808
 msgid "_Show title"


=====================================
xfce4++/util/fixes.h
=====================================
@@ -37,7 +37,23 @@ extern "C" {
     #if LIBXFCE4UTIL_CHECK_VERSION(4, 17, 0)
         #include <libxfce4util/xfce-gio-extensions.h>
     #endif
-    #include <libxfce4util/xfce-i18n.h>
+
+    /*
+     * Define the macro GETTEXT_PACKAGE in order to avoid getting
+     * an invalid ngettext() definition from <libxfce4util/xfce-i18n.h>.
+     *
+     * See also: https://gitlab.xfce.org/xfce/libxfce4util/-/issues/7
+     */
+    #ifdef GETTEXT_PACKAGE
+        #include <libxfce4util/xfce-i18n.h>
+    #else
+        /* Note: The symbol __UNDEFINED__GETTEXT_PACKAGE__... is meant not to be defined anywhere.
+         *       The numeric suffix is a random 64-bit number. The random number makes it improbable
+         *       for any 3rd-party source code to define such a symbol. */
+        #define GETTEXT_PACKAGE __UNDEFINED__GETTEXT_PACKAGE__RND_11148334482592236430__
+        #include <libxfce4util/xfce-i18n.h>
+        #undef GETTEXT_PACKAGE
+    #endif
 }
 #undef LIBXFCE4UTIL_INSIDE_LIBXFCE4UTIL_H
 


=====================================
xfce4++/util/gtk.cc
=====================================
@@ -131,6 +131,16 @@ void connect_check_resize(GtkContainer *widget, const std::function<CheckResizeH
     _connect<void>(widget, "check-resize", handler);
 }
 
+/* http://docs.gtk.org/gtk3/signal.Button.clicked.html */
+void connect_clicked(GtkButton *widget, const std::function<ClickHandler> &handler) {
+    _connect<void>(widget, "clicked", handler);
+}
+
+/* http://docs.gtk.org/gtk3/signal.ColorButton.color-set.html */
+void connect_color_set(GtkColorButton *widget, const std::function<ColorSetHandler> &handler) {
+    _connect<void>(widget, "color-set", handler);
+}
+
 /* http://docs.gtk.org/gtk3/signal.Widget.destroy.html */
 void connect_destroy(GtkWidget *widget, const std::function<DestroyHandler> &handler) {
     _connect<void>(widget, "destroy", handler);
@@ -151,11 +161,29 @@ void connect_edited(GtkCellRendererText *object, const std::function<EditedHandl
     _connect<void>(object, "edited", handler);
 }
 
+/* http://docs.gtk.org/gtk3/signal.Widget.enter-notify-event.html
+ *
+ * Note: GTK+ documentation contains an error.
+ *       The event actually passed to the handler is a pointer to GdkEventCrossing.
+ */
+void connect_enter_notify(GtkWidget *widget, const std::function<EnterNotifyHandler> &handler) {
+    _connect<gboolean>(widget, "enter-notify-event", handler);
+}
+
 /* http://docs.gtk.org/gtk3/signal.FontButton.font-set.html */
  void connect_font_set(GtkFontButton *widget, const std::function<FontSetHandler> &handler) {
     _connect<void>(widget, "font-set", handler);
 }
 
+/* http://docs.gtk.org/gtk3/signal.Widget.leave-notify-event.html
+ *
+ * Note: GTK+ documentation contains an error.
+ *       The event actually passed to the handler is a pointer to GdkEventCrossing.
+ */
+void connect_leave_notify(GtkWidget *widget, const std::function<LeaveNotifyHandler> &handler) {
+    _connect<gboolean>(widget, "leave-notify-event", handler);
+}
+
 /* http://docs.gtk.org/gtk3/signal.Widget.query-tooltip.html */
 void connect_query_tooltip(GtkWidget *widget, const std::function<TooltipHandler> &handler) {
     _connect<gboolean>(widget, "query-tooltip", handler);
@@ -215,7 +243,7 @@ void connect_mode_changed(XfcePanelPlugin *plugin, const std::function<ModeChang
     _connect<void>(plugin, "mode-changed", handler);
 }
 
-void connect_save(XfcePanelPlugin *plugin, const std::function<PluginHandler>     &handler) {
+void connect_save(XfcePanelPlugin *plugin, const std::function<PluginHandler> &handler) {
     _connect<void>(plugin, "save", handler);
 }
 
@@ -225,6 +253,15 @@ void connect_size_changed(XfcePanelPlugin *plugin, const std::function<SizeChang
 
 
 
+void invoke_later(const std::function<void()> &task) {
+    timeout_add(0, [task]() {
+        task();
+        return TIMEOUT_REMOVE;
+    });
+}
+
+
+
 struct TimeoutHandlerData {
     static const uint32_t MAGIC = 0x99F67650;
     const uint32_t magic = MAGIC;


=====================================
xfce4++/util/gtk.h
=====================================
@@ -90,11 +90,15 @@ typedef Propagation ButtonHandler                    (GtkWidget *widget, GdkEven
 typedef void        ChangedHandler_ComboBox          (GtkComboBox *widget);
 typedef Propagation ChangeValueHandler_Range         (GtkRange *widget, GtkScrollType *scroll, gdouble value);
 typedef void        CheckResizeHandler               (GtkContainer *widget);
+typedef void        ClickHandler                     (GtkButton *widget);
+typedef void        ColorSetHandler                  (GtkColorButton *widget);
 typedef void        DestroyHandler                   (GtkWidget *widget);
 typedef Propagation DrawHandler1                     (cairo_t *cr);
 typedef Propagation DrawHandler2                     (GtkWidget *widget, cairo_t *cr);
 typedef void        EditedHandler                    (GtkCellRendererText *object, gchar *path, gchar *new_text);
+typedef Propagation EnterNotifyHandler               (GtkWidget *widget, GdkEventCrossing *event);
 typedef void        FontSetHandler                   (GtkFontButton *widget);
+typedef Propagation LeaveNotifyHandler               (GtkWidget *widget, GdkEventCrossing *event);
 typedef void        ResponseHandler                  (GtkDialog *widget, gint response);
 typedef void        ToggledHandler_CellRendererToggle(GtkCellRendererToggle *object, gchar *path);
 typedef void        ToggledHandler_ToggleButton      (GtkToggleButton *widget);
@@ -108,11 +112,15 @@ void connect_button_press (GtkWidget             *widget, const std::function<Bu
 void connect_changed      (GtkComboBox           *widget, const std::function<ChangedHandler_ComboBox>           &handler);
 void connect_change_value (GtkRange              *widget, const std::function<ChangeValueHandler_Range>          &handler);
 void connect_check_resize (GtkContainer          *widget, const std::function<CheckResizeHandler>                &handler);
+void connect_clicked      (GtkButton             *widget, const std::function<ClickHandler>                      &handler);
+void connect_color_set    (GtkColorButton        *widget, const std::function<ColorSetHandler>                   &handler);
 void connect_destroy      (GtkWidget             *widget, const std::function<DestroyHandler>                    &handler);
 void connect_draw         (GtkWidget             *widget, const std::function<DrawHandler1>                      &handler);
 void connect_draw         (GtkWidget             *widget, const std::function<DrawHandler2>                      &handler);
 void connect_edited       (GtkCellRendererText   *object, const std::function<EditedHandler>                     &handler);
+void connect_enter_notify (GtkWidget             *widget, const std::function<EnterNotifyHandler>                &handler);
 void connect_font_set     (GtkFontButton         *widget, const std::function<FontSetHandler>                    &handler);
+void connect_leave_notify (GtkWidget             *widget, const std::function<LeaveNotifyHandler>                &handler);
 void connect_query_tooltip(GtkWidget             *widget, const std::function<TooltipHandler>                    &handler);
 void connect_response     (GtkDialog             *widget, const std::function<ResponseHandler>                   &handler);
 void connect_toggled      (GtkCellRendererToggle *object, const std::function<ToggledHandler_CellRendererToggle> &handler);
@@ -131,6 +139,8 @@ void connect_mode_changed    (XfcePanelPlugin *plugin, const std::function<ModeC
 void connect_save            (XfcePanelPlugin *plugin, const std::function<PluginHandler>     &handler);
 void connect_size_changed    (XfcePanelPlugin *plugin, const std::function<SizeChangeHandler> &handler);
 
+void invoke_later(const std::function<void()> &task);
+
 typedef TimeoutResponse TimeoutHandler();
 
 guint timeout_add(guint interval_ms, const std::function<TimeoutHandler> &handler);


=====================================
xfce4++/util/memory.h
=====================================
@@ -43,6 +43,7 @@ struct Ptr final {
     template<typename U> Ptr(const Ptr<U> &p) : ptr(p.ptr) {}
 
     T* operator->() const { return ptr.get(); }
+    T& operator*() const { return *ptr; }
 
     template<typename U> bool operator<(const Ptr<U> &p) const { return ptr < p.ptr; }
 


=====================================
xfce4++/util/rc.cc
=====================================
@@ -21,6 +21,7 @@
 /* The fixes file has to be included before any other #include directives */
 #include "xfce4++/util/fixes.h"
 
+#include <errno.h>
 #include "rc.h"
 #include "string-utils.h"
 
@@ -43,59 +44,75 @@ void Rc::delete_entry(const char *key, bool global) {
     xfce_rc_delete_entry(rc, key, global);
 }
 
-void Rc::delete_entry(const std::string &key, bool global) { delete_entry(key.c_str(), global); }
+void Rc::delete_entry(const string &key, bool global) { delete_entry(key.c_str(), global); }
 
 bool Rc::has_group(const char *group) const {
     return xfce_rc_has_group(rc, group);
 }
 
-bool Rc::has_group(const std::string &group) const { return has_group(group.c_str()); }
+bool Rc::has_group(const string &group) const { return has_group(group.c_str()); }
 
 bool Rc::read_bool_entry(const char *key, bool fallback) const {
     return xfce_rc_read_bool_entry(rc, key, fallback);
 }
 
-bool Rc::read_bool_entry(const std::string &key, bool fallback) const { return read_bool_entry(key.c_str(), fallback); }
+bool Rc::read_bool_entry(const string &key, bool fallback) const { return read_bool_entry(key.c_str(), fallback); }
 
 Ptr0<std::string> Rc::read_entry(const char *key, const char *fallback_orNull) const {
     const gchar *e = xfce_rc_read_entry(rc, key, fallback_orNull);
     if(e)
-        return make<std::string>(e);
+        return make<string>(e);
     else if(fallback_orNull)
-        return make<std::string>(fallback_orNull);
+        return make<string>(fallback_orNull);
     else
         return nullptr;
 }
 
-Ptr0<std::string> Rc::read_entry(const std::string &key, const char *fallback_orNull) const {
+Ptr0<std::string> Rc::read_entry(const string &key, const char *fallback_orNull) const {
     return read_entry(key.c_str(), fallback_orNull);
 }
 
+std::string Rc::read_entry(const char *key, const string &fallback) const {
+    const gchar *e = xfce_rc_read_entry(rc, key, fallback.c_str());
+    if(e)
+        return e;
+    else
+        return fallback;
+}
+
+std::string Rc::read_entry(const string &key, const string &fallback) const {
+    return read_entry(key.c_str(), fallback);
+}
+
 float Rc::read_float_entry(const char *key, float fallback) const {
-    Ptr0<std::string> e = read_entry(key, nullptr);
+    Ptr0<string> e = read_entry(key, nullptr);
     if(e) {
-        Optional<float> value = parse_float(*e);
-        if(value.has_value())
-            return value.value();
+        const std::string s = trim(*e.toPtr());
+        gchar *endptr = NULL;
+        errno = 0;
+        gdouble value = g_ascii_strtod(s.c_str(), &endptr);
+        if(errno == 0 && endptr == s.c_str() + s.size()) {
+            return value;
+        }
     }
     return fallback;
 }
 
-float Rc::read_float_entry(const std::string &key, float fallback) const { return read_float_entry(key.c_str(), fallback); }
+float Rc::read_float_entry(const string &key, float fallback) const { return read_float_entry(key.c_str(), fallback); }
 
 gint Rc::read_int_entry(const char *key, gint fallback) const {
     return xfce_rc_read_int_entry(rc, key, fallback);
 }
 
-gint Rc::read_int_entry(const std::string &key, gint fallback) const { return read_int_entry(key.c_str(), fallback); }
+gint Rc::read_int_entry(const string &key, gint fallback) const { return read_int_entry(key.c_str(), fallback); }
 
 void Rc::set_group(const char *group) {
     xfce_rc_set_group(rc, group);
 }
 
-void Rc::set_group(const std::string &group) { set_group(group.c_str()); }
+void Rc::set_group(const string &group) { set_group(group.c_str()); }
 
-Ptr0<Rc> Rc::simple_open(const std::string &filename, bool readonly) {
+Ptr0<Rc> Rc::simple_open(const string &filename, bool readonly) {
     XfceRc *rc = xfce_rc_simple_open(filename.c_str(), readonly);
     if(rc)
         return make<Rc>(rc);
@@ -103,19 +120,25 @@ Ptr0<Rc> Rc::simple_open(const std::string &filename, bool readonly) {
         return nullptr;
 }
 
-void Rc::write_bool_entry(const char        *key, bool value) { xfce_rc_write_bool_entry(rc, key        , value); }
-void Rc::write_bool_entry(const std::string &key, bool value) { xfce_rc_write_bool_entry(rc, key.c_str(), value); }
+void Rc::write_bool_entry(const char   *key, bool value) { xfce_rc_write_bool_entry(rc, key        , value); }
+void Rc::write_bool_entry(const string &key, bool value) { xfce_rc_write_bool_entry(rc, key.c_str(), value); }
 
-void Rc::write_entry(const char        *key, const char        *value) { xfce_rc_write_entry(rc, key        , value        ); }
-void Rc::write_entry(const char        *key, const std::string &value) { xfce_rc_write_entry(rc, key        , value.c_str()); }
-void Rc::write_entry(const std::string &key, const char        *value) { xfce_rc_write_entry(rc, key.c_str(), value        ); }
-void Rc::write_entry(const std::string &key, const std::string &value) { xfce_rc_write_entry(rc, key.c_str(), value.c_str()); }
+void Rc::write_entry(const char   *key, const char   *value) { xfce_rc_write_entry(rc, key        , value        ); }
+void Rc::write_entry(const char   *key, const string &value) { xfce_rc_write_entry(rc, key        , value.c_str()); }
+void Rc::write_entry(const string &key, const char   *value) { xfce_rc_write_entry(rc, key.c_str(), value        ); }
+void Rc::write_entry(const string &key, const string &value) { xfce_rc_write_entry(rc, key.c_str(), value.c_str()); }
+
+void Rc::write_float_entry(const char *key, float value) {
+    gchar buf[G_ASCII_DTOSTR_BUF_SIZE+1];
+    g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value);
+    buf[G_ASCII_DTOSTR_BUF_SIZE] = '\0';
+    write_entry(key, buf);
+}
 
-void Rc::write_float_entry(const char        *key, float value) { write_entry(key, xfce4::sprintf("%g", value)); }
-void Rc::write_float_entry(const std::string &key, float value) { write_entry(key, xfce4::sprintf("%g", value)); }
+void Rc::write_float_entry(const string &key, float value) { write_float_entry(key.c_str(), value); }
 
-void Rc::write_int_entry(const char        *key, gint value) { xfce_rc_write_int_entry(rc, key        , value); }
-void Rc::write_int_entry(const std::string &key, gint value) { xfce_rc_write_int_entry(rc, key.c_str(), value); }
+void Rc::write_int_entry(const char   *key, gint value) { xfce_rc_write_int_entry(rc, key        , value); }
+void Rc::write_int_entry(const string &key, gint value) { xfce_rc_write_int_entry(rc, key.c_str(), value); }
 
 void Rc::write_default_bool_entry(const char *key, bool value, bool default_value) {
     if(value == default_value)
@@ -124,7 +147,7 @@ void Rc::write_default_bool_entry(const char *key, bool value, bool default_valu
         write_bool_entry(key, value);
 }
 
-void Rc::write_default_bool_entry(const std::string &key, bool value, bool default_value) {
+void Rc::write_default_bool_entry(const string &key, bool value, bool default_value) {
     if(value == default_value)
         delete_entry(key, false);
     else
@@ -138,21 +161,21 @@ void Rc::write_default_entry(const char *key, const char *value, const char *def
         write_entry(key, value);
 }
 
-void Rc::write_default_entry(const char *key, const std::string &value, const std::string &default_value) {
+void Rc::write_default_entry(const char *key, const string &value, const string &default_value) {
     if(value == default_value)
         delete_entry(key, false);
     else
         write_entry(key, value);
 }
 
-void Rc::write_default_entry(const std::string &key, const char *value, const char *default_value) {
+void Rc::write_default_entry(const string &key, const char *value, const char *default_value) {
     if(value && default_value && strcmp(value, default_value) == 0)
         delete_entry(key, false);
     else
         write_entry(key, value);
 }
 
-void Rc::write_default_entry(const std::string &key, const std::string &value, const std::string &default_value) {
+void Rc::write_default_entry(const string &key, const string &value, const string &default_value) {
     if(value == default_value)
         delete_entry(key, false);
     else
@@ -166,7 +189,7 @@ void Rc::write_default_float_entry(const char *key, float value, float default_v
         write_float_entry(key, value);
 }
 
-void Rc::write_default_float_entry(const std::string &key, float value, float default_value, float epsilon) {
+void Rc::write_default_float_entry(const string &key, float value, float default_value, float epsilon) {
     if(value == default_value)
         delete_entry(key, false);
     else
@@ -180,7 +203,7 @@ void Rc::write_default_int_entry(const char *key, gint value, gint default_value
         write_int_entry(key, value);
 }
 
-void Rc::write_default_int_entry(const std::string &key, gint value, gint default_value) {
+void Rc::write_default_int_entry(const string &key, gint value, gint default_value) {
     if(value == default_value)
         delete_entry(key, false);
     else


=====================================
xfce4++/util/rc.h
=====================================
@@ -33,55 +33,59 @@
 namespace xfce4 {
 
 struct Rc final {
+    typedef std::string string;
+
     XfceRc *rc;
 
-    static Ptr0<Rc> simple_open(const std::string &filename, bool readonly);
+    static Ptr0<Rc> simple_open(const string &filename, bool readonly);
 
     Rc(XfceRc *rc);
     ~Rc();
 
     void close();
 
-    void delete_entry(const char        *key, bool global);
-    void delete_entry(const std::string &key, bool global);
-
-    bool              read_bool_entry (const char        *key, bool        fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
-    bool              read_bool_entry (const std::string &key, bool        fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
-    Ptr0<std::string> read_entry      (const char        *key, const char *fallback_orNull) const G_GNUC_WARN_UNUSED_RESULT;
-    Ptr0<std::string> read_entry      (const std::string &key, const char *fallback_orNull) const G_GNUC_WARN_UNUSED_RESULT;
-    float             read_float_entry(const char        *key, float       fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
-    float             read_float_entry(const std::string &key, float       fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
-    gint              read_int_entry  (const char        *key, gint        fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
-    gint              read_int_entry  (const std::string &key, gint        fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
-
-    bool has_group(const char        *group) const;
-    bool has_group(const std::string &group) const;
-    void set_group(const char        *group);
-    void set_group(const std::string &group);
-
-    void write_bool_entry (const char        *key, bool               value);
-    void write_bool_entry (const std::string &key, bool               value);
-    void write_entry      (const char        *key, const char        *value);
-    void write_entry      (const char        *key, const std::string &value);
-    void write_entry      (const std::string &key, const char        *value);
-    void write_entry      (const std::string &key, const std::string &value);
-    void write_float_entry(const char        *key, float              value);
-    void write_float_entry(const std::string &key, float              value);
-    void write_int_entry  (const char        *key, gint               value);
-    void write_int_entry  (const std::string &key, gint               value);
+    void delete_entry(const char   *key, bool global);
+    void delete_entry(const string &key, bool global);
+
+    bool         read_bool_entry (const char   *key, bool          fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    bool         read_bool_entry (const string &key, bool          fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    Ptr0<string> read_entry      (const char   *key, const char   *fallback_orNull) const G_GNUC_WARN_UNUSED_RESULT;
+    Ptr0<string> read_entry      (const string &key, const char   *fallback_orNull) const G_GNUC_WARN_UNUSED_RESULT;
+    string       read_entry      (const char   *key, const string &fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    string       read_entry      (const string &key, const string &fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    float        read_float_entry(const char   *key, float         fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    float        read_float_entry(const string &key, float         fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    gint         read_int_entry  (const char   *key, gint          fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+    gint         read_int_entry  (const string &key, gint          fallback       ) const G_GNUC_WARN_UNUSED_RESULT;
+
+    bool has_group(const char   *group) const;
+    bool has_group(const string &group) const;
+    void set_group(const char   *group);
+    void set_group(const string &group);
+
+    void write_bool_entry (const char   *key, bool          value);
+    void write_bool_entry (const string &key, bool          value);
+    void write_entry      (const char   *key, const char   *value);
+    void write_entry      (const char   *key, const string &value);
+    void write_entry      (const string &key, const char   *value);
+    void write_entry      (const string &key, const string &value);
+    void write_float_entry(const char   *key, float         value);
+    void write_float_entry(const string &key, float         value);
+    void write_int_entry  (const char   *key, gint          value);
+    void write_int_entry  (const string &key, gint          value);
 
     /* Write an entry if it differs from the default value.
      * Delete an entry if it equals to the default value. */
-    void write_default_bool_entry (const char        *key, bool               value, bool               default_value);
-    void write_default_bool_entry (const std::string &key, bool               value, bool               default_value);
-    void write_default_entry      (const char        *key, const char        *value, const char        *default_value);
-    void write_default_entry      (const char        *key, const std::string &value, const std::string &default_value);
-    void write_default_entry      (const std::string &key, const char        *value, const char        *default_value);
-    void write_default_entry      (const std::string &key, const std::string &value, const std::string &default_value);
-    void write_default_float_entry(const char        *key, float              value, float              default_value, float epsilon);
-    void write_default_float_entry(const std::string &key, float              value, float              default_value, float epsilon);
-    void write_default_int_entry  (const char        *key, gint               value, gint               default_value);
-    void write_default_int_entry  (const std::string &key, gint               value, gint               default_value);
+    void write_default_bool_entry (const char   *key, bool          value, bool          default_value);
+    void write_default_bool_entry (const string &key, bool          value, bool          default_value);
+    void write_default_entry      (const char   *key, const char   *value, const char   *default_value);
+    void write_default_entry      (const char   *key, const string &value, const string &default_value);
+    void write_default_entry      (const string &key, const char   *value, const char   *default_value);
+    void write_default_entry      (const string &key, const string &value, const string &default_value);
+    void write_default_float_entry(const char   *key, float         value, float         default_value, float epsilon);
+    void write_default_float_entry(const string &key, float         value, float         default_value, float epsilon);
+    void write_default_int_entry  (const char   *key, gint          value, gint          default_value);
+    void write_default_int_entry  (const string &key, gint          value, gint          default_value);
 };
 
 } /* namespace xfce4 */


=====================================
xfce4++/util/string-utils.cc
=====================================
@@ -48,6 +48,29 @@ bool ends_with(const std::string &s, const std::string &suffix) {
     }
 }
 
+std::string join(const std::vector<std::string> &strings, const char *separator) {
+    return join(strings, std::string(separator));
+}
+
+std::string join(const std::vector<std::string> &strings, const std::string &separator) {
+    size_t size = 0;
+    for (size_t i = 0; i < strings.size(); i++) {
+        if(i) {
+            size += separator.size();
+        }
+        size += strings[i].size();
+    }
+    std::string s;
+    s.reserve(size);
+    for (size_t i = 0; i < strings.size(); i++) {
+        if(i) {
+            s.append(separator);
+        }
+        s.append(strings[i]);
+    }
+    return s;
+}
+
 template<typename T, typename fT>
 static T parse_number(gchar **s, unsigned base, bool *error, fT (*f)(const gchar*, gchar**, guint)) {
     gchar *end;


=====================================
xfce4++/util/string-utils.h
=====================================
@@ -23,6 +23,7 @@
 
 #include <glib.h>
 #include <string>
+#include <vector>
 #include "optional.h"
 
 namespace xfce4 {
@@ -49,6 +50,8 @@ gulong parse_ulong(gchar **s, unsigned base = 0, bool *error = nullptr);
 
 bool        ends_with  (const std::string &s, const char        *suffix);
 bool        ends_with  (const std::string &s, const std::string &suffix);
+std::string join       (const std::vector<std::string> &strings, const char        *separator);
+std::string join       (const std::vector<std::string> &strings, const std::string &separator);
 std::string sprintf    (const char *fmt, ...) G_GNUC_PRINTF(1, 2);
 bool        starts_with(const std::string &s, const char        *prefix);
 bool        starts_with(const std::string &s, const std::string &prefix);



View it on GitLab: https://salsa.debian.org/xfce-team/goodies/xfce4-sensors-plugin/-/compare/6621ed4cdd5b0f6a127cfed7e22c2f8a0ad76518...66fcd6c0e5baf98ecd22191a63786b8fb6dc70aa

-- 
View it on GitLab: https://salsa.debian.org/xfce-team/goodies/xfce4-sensors-plugin/-/compare/6621ed4cdd5b0f6a127cfed7e22c2f8a0ad76518...66fcd6c0e5baf98ecd22191a63786b8fb6dc70aa
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-xfce-commits/attachments/20220215/74de9ad2/attachment-0001.htm>


More information about the Pkg-xfce-commits mailing list