summaryrefslogtreecommitdiff
path: root/stickynotes
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-07-17 11:52:29 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2020-07-24 18:51:24 +0200
commite1e531145476d424ef7a882447fd411d18a974e8 (patch)
tree100434ca70d0dde03b768eb73bd6658abfe3fd48 /stickynotes
parent7b4863d13487a770738a22afa8cf3c108bc04cf2 (diff)
downloadmate-applets-e1e531145476d424ef7a882447fd411d18a974e8.tar.bz2
mate-applets-e1e531145476d424ef7a882447fd411d18a974e8.tar.xz
stickynotes: Fix -Wformat-nonliteral warning
Diffstat (limited to 'stickynotes')
-rw-r--r--stickynotes/stickynotes.c14
-rw-r--r--stickynotes/util.c22
-rw-r--r--stickynotes/util.h1
3 files changed, 9 insertions, 28 deletions
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 4c7ce215..0b163dc0 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -399,17 +399,21 @@ void stickynote_set_title(StickyNote *note, const gchar *title)
{
/* If title is NULL, use the current date as the title. */
if (!title) {
- gchar *date_title, *tmp;
- gchar *date_format = g_settings_get_string (stickynotes->settings, "date-format");
+ GDateTime *now;
+ gchar *date_title;
+ gchar *date_format;
+
+ date_format = g_settings_get_string (stickynotes->settings, "date-format");
if (!date_format)
date_format = g_strdup ("%x");
- tmp = get_current_date (date_format);
- date_title = g_locale_to_utf8 (tmp, -1, NULL, NULL, NULL);
+
+ now = g_date_time_new_now_local ();
+ date_title = g_date_time_format (now, date_format);
gtk_window_set_title(GTK_WINDOW(note->w_window), date_title);
gtk_label_set_text(GTK_LABEL (note->w_title), date_title);
- g_free (tmp);
+ g_date_time_unref (now);
g_free(date_title);
g_free(date_format);
}
diff --git a/stickynotes/util.c b/stickynotes/util.c
index 929c877f..d8e370c4 100644
--- a/stickynotes/util.c
+++ b/stickynotes/util.c
@@ -20,34 +20,12 @@
#include <config.h>
#include "util.h"
-#include <time.h>
-
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-/* Returns the current date in a customizable form, the default
- * looks like this: "Nov 30, '78" */
-gchar * get_current_date(const gchar *format)
-{
- time_t clock = time(NULL);
- struct tm *current = localtime(&clock);
-
- gint date_length = 10;
- gchar *date = g_new(gchar, date_length);
-
- do
- {
- date_length += 5;
- date = (gchar *) g_renew(gchar, date, date_length);
- }
- while(strftime(date, date_length, format, current) == 0);
-
- return date;
-}
-
static Atom
xstuff_atom_get (const char *atom_name)
{
diff --git a/stickynotes/util.h b/stickynotes/util.h
index 9a8b63a8..61d86c4f 100644
--- a/stickynotes/util.h
+++ b/stickynotes/util.h
@@ -23,7 +23,6 @@
#include <glib.h>
#include <gtk/gtk.h>
-gchar * get_current_date(const gchar *format);
void xstuff_change_workspace (GtkWindow *window,
int new_space);
int xstuff_get_current_workspace (GtkWindow *window);