File: settings.c

package info (click to toggle)
hintview 2.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,804 kB
  • sloc: ansic: 18,037; xml: 126; makefile: 121
file content (81 lines) | stat: -rw-r--r-- 2,095 bytes parent folder | download
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
#include <gtk/gtk.h>
#include "basetypes.h"
#include "main.h"
#include "gui.h"
#include "error.h"

#define SR_BOOL(VAL) VAL=g_settings_get_boolean(settings,#VAL) 
#define SR_DOUBLE(VAL) VAL=g_settings_get_double(settings,#VAL) 
#define SR_INT(VAL) VAL=g_settings_get_int(settings,#VAL) 

void read_settings(GSettings *settings)
{ SR_BOOL(autoreload); 
  SR_BOOL(dark);
  SR_BOOL(home);
  SR_DOUBLE(gcorrection); 
  SR_DOUBLE(scale);
  SR_DOUBLE(rpxthreshold);
  SR_BOOL(rpx);
  SR_INT(buttonvisibility);
  position=g_settings_get_uint64(settings,"position");
  document=g_settings_get_string(settings,"document");
  LOG("Reading buttons=%x\n", buttonvisibility);
}

#define SW_BOOL(VAL) fail|=! g_settings_set_boolean (settings,#VAL,VAL)
#define SW_DOUBLE(VAL) fail|=! g_settings_set_double (settings,#VAL,VAL)
#define SW_INT(VAL) fail|=! g_settings_set_int (settings,#VAL,VAL)

void write_settings(GSettings *settings)
{ gboolean fail=FALSE;
  
  SW_BOOL(autoreload);
  SW_BOOL(dark);
  SW_BOOL(home);
  SW_DOUBLE(gcorrection);
  SW_DOUBLE(scale);
  SW_BOOL(rpx);
  SW_DOUBLE(rpxthreshold);
  SW_INT(buttonvisibility);
  LOG("Writing buttons=%x\n", buttonvisibility);

  fail|=! g_settings_set_uint64 (settings,"position",position);
  fail|=! g_settings_set_string (settings,"document",document);
  if (fail)
    LOG("Failing to write all settings\n");
}


#if 0
void do_settings(void)
{
  GSettings *settings = g_settings_new("edu.hm.cs.hintview");
  if (settings!=NULL)
    LOG("Settings created\n");
  read_settings(settings);
  //LOG("autoreload=%d\n",autoreload);
  gcorrection=gcorrection+0.01;
  autoreload=!autoreload;
  LOG("Position=0x%lx\n",position);
  position+=0x100000001;
  write_settings(settings);
}

int
main(int argc, char **argv)
{
    GtkWidget *window;

    gtk_init(&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);

    do_settings();
    
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    gtk_widget_show_all (window);

    gtk_main();
    return 0;
}
#endif