summaryrefslogtreecommitdiff
path: root/command
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-26 23:33:41 +0100
committerStefano Karapetsas <[email protected]>2014-01-26 23:33:41 +0100
commite772427432694eda21c6da5a84898555479301c5 (patch)
tree87f72f1bcd9d03d0b64364e9829455bdb55d0d53 /command
parent0f6a8d6027e662868c5888021160cbb9786fd63d (diff)
downloadmate-applets-e772427432694eda21c6da5a84898555479301c5.tar.bz2
mate-applets-e772427432694eda21c6da5a84898555479301c5.tar.xz
command: Define max lenght for output of the command
Diffstat (limited to 'command')
-rw-r--r--command/command.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/command/command.c b/command/command.c
index 8ba6c2c9..e505fcb6 100644
--- a/command/command.c
+++ b/command/command.c
@@ -36,6 +36,8 @@
#define INTERVAL_KEY "interval"
#define SHOW_ICON_KEY "show-icon"
+#define MAX_OUTPUT_LENGHT 30
+
typedef struct
{
MatePanelApplet *applet;
@@ -211,9 +213,19 @@ command_execute (CommandApplet *command_applet)
{
if ((output != NULL) && (output[0] != 0))
{
- if (g_str_has_suffix (output, "\n")) {
+ if (strlen(output) > MAX_OUTPUT_LENGHT)
+ {
+ GString *strip_output;
+ strip_output = g_string_new_len (output, MAX_OUTPUT_LENGHT);
+ g_free (output);
+ output = strip_output->str;
+ g_string_free (strip_output, FALSE);
+ }
+ if (g_str_has_suffix (output, "\n"))
+ {
output[strlen(output) - 1] = 0;
}
+
gtk_label_set_text (command_applet->label, output);
}
else