cairo-dock-team team mailing list archive
-
cairo-dock-team team
-
Mailing list archive
-
Message #03213
[Merge] lp:~meuarrr/cairo-dock-plug-ins/Disks-space into lp:cairo-dock-plug-ins
Matthieu Baerts has proposed merging lp:~meuarrr/cairo-dock-plug-ins/Disks-space into lp:cairo-dock-plug-ins.
Requested reviews:
Matthieu Baerts (matttbe)
For more details, see:
https://code.launchpad.net/~meuarrr/cairo-dock-plug-ins/Disks-space/+merge/68446
--
https://code.launchpad.net/~meuarrr/cairo-dock-plug-ins/Disks-space/+merge/68446
Your team Cairo-Dock Team is subscribed to branch lp:cairo-dock-plug-ins.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2011-07-18 14:51:58 +0000
+++ CMakeLists.txt 2011-07-19 19:19:33 +0000
@@ -310,7 +310,7 @@
if ("${enable-disks}" STREQUAL "yes")
message (STATUS "> Disks:")
set (GETTEXT_DISKS ${GETTEXT_PLUGINS})
- set (VERSION_DISKS "0.0.2")
+ set (VERSION_DISKS "0.0.3")
set (PACKAGE_DISKS "cd-disks")
set (with_disks "yes")
set (disksdatadir "${pluginsdatadir}/Disks")
=== modified file 'Disks/data/Disks.conf.in'
--- Disks/data/Disks.conf.in 2011-06-13 00:46:35 +0000
+++ Disks/data/Disks.conf.in 2011-07-19 19:19:33 +0000
@@ -43,9 +43,6 @@
#{Depending on your WindowManager, you may be able to resize this with ALT + middle-click or ALT + left-click.}
size = 96;96
-#F[Visibility;gtk-find]
-frame_visi =
-
#l[Normal;Keep above;Keep below;Keep on widget layer;Reserve space] Visibility:
#{for CompizFusion's "widget layer", set behaviour in Compiz to: (class=Cairo-dock & type=utility)}
accessibility=0
@@ -81,9 +78,6 @@
#{Choose 'Custom decorations' to define your own decorations below.}
decorations = default
-#X[Custom decorations;gtk-orientation-portrait]
-frame_custom=
-
#v
sep_deco =
#S Background image:
@@ -97,8 +91,8 @@
#e[0;1] Foreground tansparency:
fg alpha = 1
-#X[Custom margins;gtk-leave-fullscreen]
-frame_offset=
+#v
+sep_offset=
#i[0;256] Left offset:
#{in pixels. Use this to adjust the left position of drawings.}
@@ -163,6 +157,12 @@
#{You need OpenGL for this option. Set it to 0 to disable it, 1 means the transition is continue.}
smooth = .33
+#F[Partitions monitored : Size;gtk-preferences]
+frame_parts =
+
+#U
+#{E.g. sda1, sdb5...}/
+partitions =
#F[Disks monitored : Speed;gtk-preferences]
frame_disks =
@@ -171,13 +171,6 @@
#{E.g. sda, sdb... Up to 5 values allowed}/
disks = sda
-#F[Partitions monitored : Size;gtk-preferences]
-frame_parts =
-
-#U
-#{E.g. sda1, sdb5...}/
-partitions =
-
#F[Preferences;gtk-preferences]
frame_prefs =
=== modified file 'Disks/src/applet-config.c'
--- Disks/src/applet-config.c 2011-01-14 14:17:07 +0000
+++ Disks/src/applet-config.c 2011-07-19 19:19:33 +0000
@@ -23,6 +23,7 @@
#include "applet-struct.h"
#include "applet-config.h"
+#include "applet-disks.h"
CD_APPLET_GET_CONFIG_BEGIN
@@ -49,6 +50,7 @@
///\_________________ Parameters
myConfig.cDisks = CD_CONFIG_GET_STRING_LIST ("Configuration", "disks", &myConfig.iNumberDisks);
+ myConfig.cParts = CD_CONFIG_GET_STRING_LIST ("Configuration", "partitions", &myConfig.iNumberParts);
myConfig.cSystemMonitorCommand = CD_CONFIG_GET_STRING ("Configuration", "sys monitor");
CD_APPLET_GET_CONFIG_END
@@ -72,27 +74,6 @@
g_timer_destroy (myData.pClock);
- reset_disks_list (myApplet);
+ cd_disks_reset_parts_list (myApplet);
+ cd_disks_reset_disks_list (myApplet);
CD_APPLET_RESET_DATA_END
-
-
-void reset_disks_list (CairoDockModuleInstance *myApplet)
-{
- if (myData.iNumberDisks > 0)
- {
- gsize i;
- CDDiskSpeedData *pSpeed;
- for (i = 0; i < myData.iNumberDisks; i++)
- {
- pSpeed = g_list_nth_data (myData.lDisks, i); /// maladroit
- if (pSpeed != NULL)
- {
- if (pSpeed->cName != NULL)
- g_free (pSpeed->cName);
- g_free (pSpeed);
- }
- }
- g_list_free (myData.lDisks);
- myData.lDisks = NULL;
- }
-}
=== modified file 'Disks/src/applet-config.h'
--- Disks/src/applet-config.h 2011-01-14 14:17:07 +0000
+++ Disks/src/applet-config.h 2011-07-19 19:19:33 +0000
@@ -26,6 +26,4 @@
CD_APPLET_CONFIG_H
-void reset_disks_list (CairoDockModuleInstance *myApplet);
-
#endif
=== modified file 'Disks/src/applet-disks.c'
--- Disks/src/applet-disks.c 2010-10-26 13:23:26 +0000
+++ Disks/src/applet-disks.c 2011-07-19 19:19:33 +0000
@@ -24,6 +24,8 @@
#include <glib.h>
#include <glib/gprintf.h>
+#include <sys/statvfs.h>
+
#include "applet-struct.h"
#include "applet-notifications.h"
#include "applet-disks.h"
@@ -88,17 +90,28 @@
void cd_disks_format_value_on_icon (CairoDataRenderer *pRenderer, int iNumValue, gchar *cFormatBuffer, int iBufferLength, CairoDockModuleInstance *myApplet)
{
- static gchar s_upRateFormatted[11];
- double fValue = cairo_data_renderer_get_normalized_current_value_with_latency (pRenderer, iNumValue);
- int i = iNumValue / 2;
- CDDiskSpeedData *pSpeed = g_list_nth_data (myData.lDisks, i);
- fValue *= (iNumValue == i * 2 ? pSpeed->uMaxReadRate : pSpeed->uMaxWriteRate);
-
- _cd_speed_formatRate (fValue, s_upRateFormatted, 11, FALSE);
- snprintf (cFormatBuffer, iBufferLength,
- "%s%s",
- cairo_data_renderer_can_write_values (pRenderer) ? (iNumValue == i * 2 ?"â" : "â") : "",
- s_upRateFormatted);
+ if (iNumValue < (int) myConfig.iNumberParts)
+ {
+ double *pSize;
+ pSize = g_list_nth_data (myData.lParts, iNumValue);
+ snprintf (cFormatBuffer, iBufferLength,
+ "%.f%%",
+ *pSize * 100);
+ }
+ else
+ {
+ static gchar s_upRateFormatted[11];
+ double fValue = cairo_data_renderer_get_normalized_current_value_with_latency (pRenderer, iNumValue);
+ int i = iNumValue / 2;
+ CDDiskSpeedData *pSpeed = g_list_nth_data (myData.lDisks, i);
+ fValue *= (iNumValue == i * 2 ? pSpeed->uMaxReadRate : pSpeed->uMaxWriteRate);
+
+ _cd_speed_formatRate (fValue, s_upRateFormatted, 11, FALSE);
+ snprintf (cFormatBuffer, iBufferLength,
+ "%s%s",
+ cairo_data_renderer_can_write_values (pRenderer) ? (iNumValue == i * 2 ?"â" : "â") : "",
+ s_upRateFormatted);
+ }
}
@@ -107,13 +120,33 @@
static gchar s_readRateFormatted[11], s_writeRateFormatted[11];
static double s_fValues[CD_DISKS_NB_MAX_VALUES];
//~ memset (s_fValues, 0, sizeof (s_fValues));
- CDDiskSpeedData *pSpeed;
GString *sLabel = g_string_new ("");
gsize i;
CD_APPLET_ENTER;
+ if (myConfig.iNumberParts > 0)
+ {
+ double *pSize;
+ for (i = 0; i < myConfig.iNumberParts; i++)
+ {
+ pSize = g_list_nth_data (myData.lParts, i);
+ s_fValues[i] = *pSize;
+ //cd_warning("Partition %d = %s : %.1f%%", i, myConfig.cParts[i], *pSize * 100);
+
+ if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL)
+ {
+ if (i > 0)
+ g_string_append (sLabel, " - ");
+
+ g_string_append_printf (sLabel, "%s : %.1f%%", myConfig.cParts[i], *pSize * 100);
+
+ }
+ }
+ }
+
if (myData.iNumberDisks > 0)
{
+ CDDiskSpeedData *pSpeed;
for (i = 0; i < myData.iNumberDisks; i++)
{
pSpeed = g_list_nth_data (myData.lDisks, i);
@@ -144,14 +177,17 @@
}
}
-
+ }
+
+ if (myConfig.iNumberParts + myData.iNumberDisks > 0)
+ {
/// Display data
CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (s_fValues);
if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_LABEL)
CD_APPLET_SET_NAME_FOR_MY_ICON (sLabel->str);
- g_string_free (sLabel, TRUE);
}
+ g_string_free (sLabel, TRUE);
CD_APPLET_LEAVE (TRUE);
}
@@ -183,82 +219,130 @@
double fTimeElapsed = g_timer_elapsed (myData.pClock, NULL);
g_timer_start (myData.pClock);
- if (!(myData.iNumberDisks > 0))
+ if (!(myConfig.iNumberParts + myData.iNumberDisks > 0))
{
cairo_dock_downgrade_task_frequency (myData.pPeriodicTask);
cd_warning("Disks : No disk defined");
}
- g_return_if_fail ((fTimeElapsed > 0.1) || (myData.iNumberDisks > 0));
+ g_return_if_fail ((fTimeElapsed > 0.1) || (myConfig.iNumberParts + myData.iNumberDisks > 0));
- char disk_name [16];
- //~ int disk_major;
-
- FILE* fd;
- buff[BUFFSIZE-1] = 0;
- fd = fopen (DISKS_SPEED_DATA_PIPE, "rb");
- if (!fd)
- {
- cairo_dock_downgrade_task_frequency (myData.pPeriodicTask);
- cd_warning("Disks : Your kernel doesn't support diskstat. (2.5.70 or above required)");
- }
- else
- {
- //~ cairo_dock_set_normal_task_frequency (myData.pPeriodicTask);
+ if (myConfig.iNumberParts > 0)
+ {
gsize i;
- CDDiskSpeedData* pSpeed;
- long long unsigned uReadBlocks, uWriteBlocks;
- gboolean bFound;
- for (;;)
- {
- if (!fgets(buff,BUFFSIZE-1,fd))
+ struct statvfs buffer;
+ int status;
+ double *pSize;
+ for (i = 0; i < myConfig.iNumberParts; i++)
+ {
+ pSize = g_list_nth_data (myData.lParts, i);
+ status = statvfs(myConfig.cParts[i], &buffer);
+ *pSize = 1. - (double) buffer.f_bfree / (double) buffer.f_blocks;
+ }
+ }
+
+ if (myData.iNumberDisks > 0)
+ {
+ char disk_name [16];
+ //~ int disk_major;
+
+ FILE* fd;
+ buff[BUFFSIZE-1] = 0;
+ fd = fopen (DISKS_SPEED_DATA_PIPE, "rb");
+ if (!fd)
+ {
+ cairo_dock_downgrade_task_frequency (myData.pPeriodicTask);
+ cd_warning("Disks : Your kernel doesn't support diskstat. (2.5.70 or above required)");
+ }
+ else
+ {
+ //~ cairo_dock_set_normal_task_frequency (myData.pPeriodicTask);
+ gsize i;
+ CDDiskSpeedData* pSpeed;
+ long long unsigned uReadBlocks, uWriteBlocks;
+ gboolean bFound;
+ for (;;)
{
- fclose(fd);
- break;
- }
-
- /// Using Linux iostat : http://www.kernel.org/doc/Documentation/iostats.txt
- /// gathering fields 3, 6 and 10
- sscanf(buff, " %*d %*d %15s %*u %*u %llu %*u %*u %*u %llu %*u %*u %*u %*u",
- //&disk_major, // field 1
- disk_name,
- &uReadBlocks,
- &uWriteBlocks
- );
-
- bFound = FALSE;
- if (strlen (disk_name) == 3)
- for (i = 0; i < myData.iNumberDisks; i++)
+ if (!fgets(buff,BUFFSIZE-1,fd))
{
- pSpeed = g_list_nth_data (myData.lDisks, i);
- if (strcmp (pSpeed->cName, disk_name) == 0)
+ fclose(fd);
+ break;
+ }
+
+ /// Using Linux iostat : http://www.kernel.org/doc/Documentation/iostats.txt
+ /// gathering fields 3, 6 and 10
+ sscanf(buff, " %*d %*d %15s %*u %*u %llu %*u %*u %*u %llu %*u %*u %*u %*u",
+ //&disk_major, // field 1
+ disk_name,
+ &uReadBlocks,
+ &uWriteBlocks
+ );
+
+ bFound = FALSE;
+ if (strlen (disk_name) == 3)
+ for (i = 0; i < myData.iNumberDisks; i++)
{
- if (pSpeed->bInitialized) // la 1ere iteration on ne peut pas calculer le debit.
+ pSpeed = g_list_nth_data (myData.lDisks, i);
+ if (strcmp (pSpeed->cName, disk_name) == 0)
{
- pSpeed->uReadSpeed = (uReadBlocks - pSpeed->uReadBlocks) * DISK_BLOCK_SIZE / fTimeElapsed;
- pSpeed->uWriteSpeed = (uWriteBlocks - pSpeed->uWriteBlocks) * DISK_BLOCK_SIZE / fTimeElapsed;
+ if (pSpeed->bInitialized) // la 1ere iteration on ne peut pas calculer le debit.
+ {
+ pSpeed->uReadSpeed = (uReadBlocks - pSpeed->uReadBlocks) * DISK_BLOCK_SIZE / fTimeElapsed;
+ pSpeed->uWriteSpeed = (uWriteBlocks - pSpeed->uWriteBlocks) * DISK_BLOCK_SIZE / fTimeElapsed;
+ }
+ else
+ pSpeed->bInitialized = TRUE;
+
+ pSpeed->uReadBlocks = uReadBlocks;
+ pSpeed->uWriteBlocks = uWriteBlocks;
+ //~ cd_warning("%s %u %u", pSpeed->cName, pSpeed->uReadSpeed, pSpeed->uWriteSpeed);
+
+ pSpeed->bAcquisitionOK = TRUE;
+ bFound = TRUE;
+ break;
}
- else
- pSpeed->bInitialized = TRUE;
-
- pSpeed->uReadBlocks = uReadBlocks;
- pSpeed->uWriteBlocks = uWriteBlocks;
- //~ cd_warning("%s %u %u", pSpeed->cName, pSpeed->uReadSpeed, pSpeed->uWriteSpeed);
-
- pSpeed->bAcquisitionOK = TRUE;
- bFound = TRUE;
- break;
}
- }
- // if (myConfig.bListAll && !bFound) // need monitor
- /// create new
- //~ cd_warning("creation");
- //~ pSpeed = g_new0 (CDDiskSpeedData, 1);
- //~ pSpeed->cName = g_strdup (disk_name);
- //~ myData.lDisks = g_list_append (myData.lDisks, pSpeed);
- // speed_set_data (pDisk, new_reads, new_writes);
- //~ }
+ // if (myConfig.bListAll && !bFound) // need monitor
+ /// create new
+ //~ cd_warning("creation");
+ //~ pSpeed = g_new0 (CDDiskSpeedData, 1);
+ //~ pSpeed->cName = g_strdup (disk_name);
+ //~ myData.lDisks = g_list_append (myData.lDisks, pSpeed);
+ // speed_set_data (pDisk, new_reads, new_writes);
+ //~ }
+ }
}
}
-}
+
+}
+
+
+
+void cd_disks_reset_parts_list (CairoDockModuleInstance *myApplet)
+{
+ if (myConfig.iNumberParts > 0)
+ {
+ g_list_free_full (myData.lParts, g_free);
+ myData.lParts = NULL;
+ }
+}
+
+
+void _reset_one_disk (CDDiskSpeedData *pSpeed)
+{
+ if (pSpeed->cName != NULL)
+ g_free (pSpeed->cName);
+ g_free (pSpeed);
+}
+
+void cd_disks_reset_disks_list (CairoDockModuleInstance *myApplet)
+{
+ if (myData.iNumberDisks > 0)
+ {
+ g_list_foreach (myData.lDisks, (GFunc) _reset_one_disk, NULL);
+ g_list_free (myData.lDisks);
+ myData.lDisks = NULL;
+ }
+}
+
=== modified file 'Disks/src/applet-disks.h'
--- Disks/src/applet-disks.h 2010-10-26 13:23:26 +0000
+++ Disks/src/applet-disks.h 2011-07-19 19:19:33 +0000
@@ -26,4 +26,7 @@
void cd_disks_format_value_on_icon (CairoDataRenderer *pRenderer, int iNumValue, gchar *cFormatBuffer, int iBufferLength, CairoDockModuleInstance *myApplet);
gboolean cd_disks_update_from_data (CairoDockModuleInstance *myApplet);
+void cd_disks_reset_parts_list (CairoDockModuleInstance *myApplet);
+void cd_disks_reset_disks_list (CairoDockModuleInstance *myApplet);
+
#endif
=== modified file 'Disks/src/applet-init.c'
--- Disks/src/applet-init.c 2011-01-14 14:17:07 +0000
+++ Disks/src/applet-init.c 2011-07-19 19:19:33 +0000
@@ -29,14 +29,31 @@
CD_APPLET_DEFINITION (N_("Disks"),
2, 0, 5,
CAIRO_DOCK_CATEGORY_APPLET_SYSTEM,
- N_("<b><i>monitors disks activity</i></b>.\n\n"
- "Initial release, a lot more need to be done :\n"
- " - All disks option\n"
- " - Pop up showing disks info to know what to add in the list\n"
- " - Free space\n"
- " - Find actions : left, middle click, drop and wheel\n"
- " - Fill menu with actions\n"
- " - Editable labels ?\n"
+ N_("<b><i>Monitors disks speed and space</i></b>.\n"
+ "\n"
+ "This applet show your disks informations. You can activate both options at once, but they're better separated in 2 or more instances of the applet.\n"
+ "Using both in the same applet can cause problems with the speed display not scaling down.\n"
+ "\n"
+ "<b>Disk space</b> : Show disk transfer rates. Up to 10 partitions\n"
+ " You need to configure the mount point of each monitored partition like / or /home\n"
+ " Better seen in a gauge, with 30 or 60s refresh rate and really short or no transition delay.\n"
+ "\n"
+ "<b>Disk speed</b> : Show disk transfer rates. Up to 5 disks\n"
+ " You need to configure the name of each monitored disk with his device name like sda or sdb\n"
+ " Better seen in a graph, with 2 or 3s refresh rate and no delay between transitions.\n"
+ "\n"
+ "Second release, a lot more need to be done :\n"
+ " <u>Free space :</u>\n"
+ " - Popup with detailed informations.\n"
+ " - Editable labels ?\n"
+ " <u>Speed :</u>\n"
+ " - All disks option.\n"
+ " - Pop up showing disks info to know what to add in the list.\n"
+ " - Editable labels ?\n"
+ " - Get real block size for disks\n"
+ " <u>Global</u>\n"
+ " - Find actions : left, middle click, drop and wheel.\n"
+ " - Fill menu with actions.\n"
),
"SQP");
@@ -80,6 +97,20 @@
if (pRenderAttr != NULL) // attributs generiques.
{
const gchar *labels[CD_DISKS_NB_MAX_VALUES] = {};
+
+ if (myConfig.iNumberParts > 0)
+ {
+ gsize i;
+ for (i = 0; i < myConfig.iNumberParts; i++)
+ {
+ /// Ca non plus je suppose :)
+ double *pSize;
+ pSize = g_new0 (double, 1);
+ myData.lParts = g_list_append (myData.lParts, pSize);
+ labels[i] = myConfig.cParts[i];
+ }
+ }
+
if (myData.iNumberDisks > 0)
{
gsize i;
@@ -97,8 +128,13 @@
pRenderAttr->cLabels = (gchar **)labels;
pRenderAttr->iLatencyTime = myConfig.iCheckInterval * 1000 * myConfig.fSmoothFactor;
- pRenderAttr->iNbValues = 2 * myData.iNumberDisks;
- pRenderAttr->bUpdateMinMax = TRUE;
+ pRenderAttr->iNbValues = myConfig.iNumberParts + 2 * myData.iNumberDisks;
+
+ /// Problem here : should be FALSE for size and TRUE for speed.
+ /// This version force FALSE when size is monitored, so applets using both monitors
+ /// could have some display problems on speed display.
+ pRenderAttr->bUpdateMinMax = !(myConfig.iNumberParts > 0);
+
if (myConfig.iInfoDisplay == CAIRO_DOCK_INFO_ON_ICON)
{
pRenderAttr->bWriteValues = TRUE;
@@ -155,7 +191,8 @@
CD_APPLET_ALLOW_NO_CLICKABLE_DESKLET;
}
- reset_disks_list (myApplet);
+ cd_disks_reset_parts_list (myApplet);
+ cd_disks_reset_disks_list (myApplet);
_set_data_renderer (myApplet, TRUE);
=== modified file 'Disks/src/applet-struct.h'
--- Disks/src/applet-struct.h 2011-01-08 02:50:22 +0000
+++ Disks/src/applet-struct.h 2011-07-19 19:19:33 +0000
@@ -66,6 +66,9 @@
gchar **cDisks;
gsize iNumberDisks;
+ gchar **cParts;
+ gsize iNumberParts;
+
gchar *cSystemMonitorCommand;
} ;
@@ -74,6 +77,7 @@
// shared memory
gsize iNumberDisks;
GList *lDisks;
+ GList *lParts;
// end of shared memory
CairoDockTask *pPeriodicTask;
Follow ups