1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
Hop this is felling better now ... Michael Weber
--- gtk-sunlight-0.2.1/callbacks.c
+++ gtk-sunlight-0.2.1callbacks.c
@@ -19,6 +19,9 @@
#include "support.h"
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <stdlib.h>
void button_sensitive (ChData *data, gboolean sensitive);
void change_wallpaper (ChData *data);
@@ -94,21 +97,21 @@
void cmd_ok_clicked ( GtkButton *button, ChData *data)
{
- FILE *file;
int time_out;
- gchar *contents;
+ gchar *contents = g_malloc(1002);
gchar *fname = g_strconcat(g_get_home_dir(), DIR_PROJECT, "/sunlight_options", NULL);
gtk_widget_hide(data->main_window);
/*Saving gi_rd1 and gi_rd2 to a file under DIR_PROJECT*/
- sprintf(contents, "%d %d", data->gi_rd1, data->gi_rd2);
+ snprintf(contents, 1000, "%d %d", data->gi_rd1, data->gi_rd2);
g_file_set_contents(fname, contents, -1, NULL);
change_wallpaper (data);
time_out = gtk_timeout_add(1800000, (GtkFunction) change_wallpaper, data);
+ g_free(contents);
g_free(fname);
}
@@ -118,7 +121,6 @@
void
change_wallpaper (ChData *data)
{
- FILE *file;
gchar *text1, *text2, *image_address, *set_wallpaper;
gchar *dir_wallpapers = g_strconcat(g_get_home_dir(), DIR_WALLPAPERS, NULL);
gchar *dir_project = g_strconcat(g_get_home_dir(), DIR_PROJECT, NULL);
@@ -183,7 +185,6 @@
void
chk_startup_toggled_cb (GtkToggleButton *togglebutton, ChData *data)
{
- FILE *file;
gchar *contents = "[Desktop Entry]\nEncoding=UTF-8\nIcon=/usr/share/icons/hicolor/48x48/apps/gtk-sunlight.png\nName=Real-time Sunlight Wallpaper\nComment=World sunlight map every 30 minutes\nExec=gtk-sunlight --nodisplay\nTerminal=false\nType=Application\nCategories=Utility;\nStartupNotify=false\nHidden=false\nNoDisplay=false";
gchar *path_startup = g_strconcat(g_get_home_dir(), "/.config/autostart/", NULL);
--- gtk-sunlight-0.2.1/sunlight.c
+++ gtk-sunlight-0.2.1/sunlight.c
@@ -20,9 +20,15 @@
#include "support.h"
#include "errno.h"
//#include "time.h"
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <stdlib.h>
+#include <ctype.h>
#define UI_FILE "/usr/share/sunlight/sunlight.glade"
+void change_wallpaper (ChData *data);
+
gboolean
make_dir(gchar *trail)
{
@@ -78,7 +84,7 @@
GError *error = NULL;
gchar *option_file = g_strconcat(g_get_home_dir(), DIR_PROJECT, "/sunlight_options", NULL);
gchar *contents;
- gint length;
+ gsize length;
int time_out;
GOptionContext *context;
@@ -111,8 +117,8 @@
data = g_slice_new( ChData );
/* create project directories if necessary */
- if (!make_dir(DIR_PROJECT)) return;
- if (!make_dir(DIR_WALLPAPERS)) return;
+ if (!make_dir(DIR_PROJECT)) return 1;
+ if (!make_dir(DIR_WALLPAPERS)) return 1;
/* Check for sunlight_options file and getting gi_rd1 and gi_rd2*/
if (g_file_test(option_file, G_FILE_TEST_EXISTS)){
|