summaryrefslogtreecommitdiff
path: root/src/modules/itray/e_mod_config.c
blob: 1c41ddf2fc589e906a9e62f1e7bc4de74bf742b6 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "e.h"
#include "e_mod_main.h"
#include "e_mod_config.h"
#include "config.h"

typedef struct _cfdata CFData;
typedef struct _Cfg_File_Data Cfg_File_Data;

struct _cfdata
{
   int rowsize;
};

struct _Cfg_File_Data
{
   E_Config_Dialog *cfd;
   char *file;
};

/* Protos */
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, CFData *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
static int _basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata);
static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata);
static int _advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata);

void 
_config_itray_module(E_Container *con, ITray *itray)
{
   E_Config_Dialog *cfd;
   E_Config_Dialog_View *v;

   v = E_NEW(E_Config_Dialog_View, 1);
   
   /* Dialog Methods */
   v->create_cfdata = _create_data;
   v->free_cfdata = _free_data;
   v->basic.apply_cfdata = _basic_apply_data;
   v->basic.create_widgets = _basic_create_widgets;
   v->advanced.apply_cfdata = _advanced_apply_data;
   v->advanced.create_widgets = _advanced_create_widgets;

   /* Create The Dialog */
   cfd = e_config_dialog_new(con, _("ITray Configuration"), NULL, 0, v, itray);
   itray->config_dialog = cfd;
}

static void 
_fill_data(ITray *ib, CFData *cfdata)
{
   cfdata->rowsize = ib->conf->rowsize;
}

static void *
_create_data(E_Config_Dialog *cfd)
{
   CFData *cfdata;
   ITray *ib;
   
   ib = cfd->data;
   cfdata = E_NEW(CFData, 1);
   _fill_data(ib, cfdata);
   return cfdata;
}

static void 
_free_data(E_Config_Dialog *cfd, CFData *cfdata)
{
   ITray *ib;
   
   ib = cfd->data;
   ib->config_dialog = NULL;
   free(cfdata);
}

static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
{
   Evas_Object *o, *ob, *of;

   o = e_widget_list_add(evas, 0, 0);
   
   return o;
}

static int 
_basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata)
{
   ITray *ib;
   
   ib = cfd->data;
   e_config_save_queue();

   _itray_box_cb_config_updated(ib);
   return 1;
}

static Evas_Object *
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata)
{
   Evas_Object *o, *of, *ob;

   o = e_widget_list_add(evas, 0, 0);
   
   of = e_widget_framelist_add(evas, _("Number of Rows"), 0);
   ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 1.0, 6.0, 1.0, 0,  NULL, &(cfdata->rowsize), 200);
   e_widget_framelist_object_append(of, ob);
   e_widget_list_object_append(o, of, 1, 1, 0.5);
   
   return o;
}

static int 
_advanced_apply_data(E_Config_Dialog *cfd, CFData *cfdata)
{
   ITray *ib;
   
   ib = cfd->data;
   e_border_button_bindings_ungrab_all();
   if (cfdata->rowsize != ib->conf->rowsize) 
     ib->conf->rowsize = cfdata->rowsize;
   e_border_button_bindings_grab_all();
   e_config_save_queue();

   _itray_box_cb_config_updated(ib);
   return 1;
}