37
37
static void _set_data_renderer (CairoDockModuleInstance *myApplet, gboolean bReload)
39
CairoDataRendererAttribute *pRenderAttr = NULL; // les attributs generiques du data-renderer.
39
if (myConfig.iDisplayType == CD_NETSPEED_BAR)
42
CairoDataRendererAttribute *pRenderAttr = NULL; // attributes for the global data-renderer.
43
CairoGaugeAttribute aGaugeAttr; // gauge attributes.
44
CairoGraphAttribute aGraphAttr; // graph attributes.
40
45
if (myConfig.iDisplayType == CD_NETSPEED_GAUGE)
42
CairoGaugeAttribute attr; // les attributs de la jauge.
43
memset (&attr, 0, sizeof (CairoGaugeAttribute));
44
pRenderAttr = CAIRO_DATA_RENDERER_ATTRIBUTE (&attr);
47
memset (&aGaugeAttr, 0, sizeof (CairoGaugeAttribute));
48
pRenderAttr = CAIRO_DATA_RENDERER_ATTRIBUTE (&aGaugeAttr);
45
49
pRenderAttr->cModelName = "gauge";
46
50
pRenderAttr->iRotateTheme = myConfig.iRotateTheme;
47
attr.cThemePath = myConfig.cGThemePath;
51
aGaugeAttr.cThemePath = myConfig.cGThemePath;
49
53
else if (myConfig.iDisplayType == CD_NETSPEED_GRAPH)
51
CairoGraphAttribute attr; // les attributs du graphe.
52
memset (&attr, 0, sizeof (CairoGraphAttribute));
53
pRenderAttr = CAIRO_DATA_RENDERER_ATTRIBUTE (&attr);
55
memset (&aGraphAttr, 0, sizeof (CairoGraphAttribute));
56
pRenderAttr = CAIRO_DATA_RENDERER_ATTRIBUTE (&aGraphAttr);
54
57
pRenderAttr->cModelName = "graph";
56
59
CD_APPLET_GET_MY_ICON_EXTENT (&w, &h);
57
60
pRenderAttr->iMemorySize = (w > 1 ? w : 32);
58
attr.iType = myConfig.iGraphType;
59
attr.bMixGraphs = myConfig.bMixGraph;
61
aGraphAttr.iType = myConfig.iGraphType;
62
aGraphAttr.bMixGraphs = myConfig.bMixGraph;
60
63
double fHighColor[CD_NETSPEED_NB_MAX_VALUES*3];
61
64
double fLowColor[CD_NETSPEED_NB_MAX_VALUES*3];
66
69
memcpy (&fHighColor[3*i], myConfig.fHigholor, 3*sizeof (double));
67
70
memcpy (&fLowColor[3*i], myConfig.fLowColor, 3*sizeof (double));
68
attr.fHighColor = fHighColor;
69
attr.fLowColor = fLowColor;
70
memcpy (attr.fBackGroundColor, myConfig.fBgColor, 4*sizeof (double));
72
else if (myConfig.iDisplayType == CD_NETSPEED_BAR)
76
if (pRenderAttr != NULL) // attributs generiques.
78
pRenderAttr->iLatencyTime = myConfig.iCheckInterval * 1000 * myConfig.fSmoothFactor;
79
pRenderAttr->iNbValues = 2;
80
pRenderAttr->bUpdateMinMax = TRUE;
81
if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_ICON)
83
pRenderAttr->bWriteValues = TRUE;
84
pRenderAttr->format_value = (CairoDataRendererFormatValueFunc)cd_netspeed_format_value;
85
pRenderAttr->pFormatData = myApplet;
87
const gchar *labels[2] = {"DOWN", "UP"};
88
pRenderAttr->cLabels = (gchar **)labels;
90
CD_APPLET_ADD_DATA_RENDERER_ON_MY_ICON (pRenderAttr);
92
CD_APPLET_RELOAD_MY_DATA_RENDERER (pRenderAttr);
71
aGraphAttr.fHighColor = fHighColor;
72
aGraphAttr.fLowColor = fLowColor;
73
memcpy (aGraphAttr.fBackGroundColor, myConfig.fBgColor, 4*sizeof (double));
76
pRenderAttr->iLatencyTime = myConfig.iCheckInterval * 1000 * myConfig.fSmoothFactor;
77
pRenderAttr->iNbValues = 2;
78
pRenderAttr->bUpdateMinMax = TRUE;
79
if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_ICON)
81
pRenderAttr->bWriteValues = TRUE;
82
pRenderAttr->format_value = (CairoDataRendererFormatValueFunc)cd_netspeed_format_value;
83
pRenderAttr->pFormatData = myApplet;
85
const gchar *labels[2] = {"DOWN", "UP"};
86
pRenderAttr->cLabels = (gchar **)labels;
87
CD_APPLET_ADD_DATA_RENDERER_ON_MY_ICON (pRenderAttr);
96
90
CD_APPLET_INIT_BEGIN
151
145
cairo_dock_relaunch_task_immediately (myData.pPeriodicTask, myConfig.iCheckInterval);
153
147
else { // on redessine juste l'icone.
154
CD_APPLET_RELOAD_MY_DATA_RENDERER (NULL);
148
//CD_APPLET_RELOAD_MY_DATA_RENDERER (NULL);
155
149
if (myConfig.iDisplayType == CD_NETSPEED_GRAPH)
156
150
CD_APPLET_SET_MY_DATA_RENDERER_HISTORY_TO_MAX;
158
if (! cairo_dock_task_is_running (myData.pPeriodicTask))
159
cd_netspeed_update_from_data (myApplet);
152
/**if (! cairo_dock_task_is_running (myData.pPeriodicTask))
153
cd_netspeed_update_from_data (myApplet);*/
161
155
CD_APPLET_RELOAD_END