summaryrefslogtreecommitdiff
path: root/command
diff options
context:
space:
mode:
authorWu Xiaotian <[email protected]>2018-11-26 09:48:57 +0800
committerraveit65 <[email protected]>2019-07-08 14:31:05 +0200
commit1c197aa881092efcdb2d9013e73d0004d58ccdf3 (patch)
tree508bd8aa3b071c159cf3b7ba10f0fd03f8afc955 /command
parent18cf1e9710b8a308b8f8f9c6c0019b3a9c2b3cda (diff)
downloadmate-applets-1c197aa881092efcdb2d9013e73d0004d58ccdf3.tar.bz2
mate-applets-1c197aa881092efcdb2d9013e73d0004d58ccdf3.tar.xz
for pr review
Diffstat (limited to 'command')
-rw-r--r--command/command.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/command/command.c b/command/command.c
index a0523b17..2cd3c00c 100644
--- a/command/command.c
+++ b/command/command.c
@@ -97,7 +97,7 @@ command_applet_destroy (MatePanelApplet *applet_widget, CommandApplet *command_a
command_applet->command = NULL;
}
- if (command_applet->child_pid != (GPid) 0)
+ if (command_applet->child_pid != 0)
{
g_spawn_close_pid (command_applet->child_pid);
command_applet->child_pid = 0;
@@ -219,8 +219,7 @@ settings_width_changed (GSettings *settings, gchar *key, CommandApplet *command_
width = g_settings_get_int (command_applet->settings, WIDTH_KEY);
- if (command_applet->width != width)
- command_applet->width = width;
+ command_applet->width = width;
/* execute command to start new timer */
command_execute (command_applet);
@@ -343,7 +342,7 @@ on_child_exit (GPid child_pid, gint status, gpointer data)
command_applet->child_pid = 0;
}
-static GIOChannel *
+static void
set_up_io_channel (gint fd, GIOCondition cond, GIOFunc func, gpointer data)
{
GIOChannel *ioc;
@@ -357,15 +356,12 @@ set_up_io_channel (gint fd, GIOCondition cond, GIOFunc func, gpointer data)
g_io_add_watch (ioc, cond, func, data);
g_io_channel_unref (ioc);
-
- return ioc;
}
static gboolean
command_execute (CommandApplet *command_applet)
{
GError *error = NULL;
- gint argc;
gchar **argv;
gint stdout_fd;
@@ -375,24 +371,23 @@ command_execute (CommandApplet *command_applet)
return TRUE;
}
- if (!g_shell_parse_argv (command_applet->command, &argc, &argv, &error))
+ /* command running, wait for next timer execution */
+ if (command_applet->child_pid != 0)
{
- gtk_label_set_text (command_applet->label, ERROR_OUTPUT);
- g_clear_error (&error);
- return FALSE;
+ return TRUE;
}
- /* command running, wait for next timer execution */
- if (command_applet->child_pid != (GPid) 0)
+ if (!g_shell_parse_argv (command_applet->command, NULL, &argv, &error))
{
- g_strfreev (argv);
- return TRUE;
+ gtk_label_set_text (command_applet->label, ERROR_OUTPUT);
+ g_clear_error (&error);
+ return FALSE;
}
if (!g_spawn_async_with_pipes (NULL,
argv,
NULL,
- (GSpawnFlags) G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
NULL,
NULL,
&command_applet->child_pid,
@@ -406,9 +401,7 @@ command_execute (CommandApplet *command_applet)
return TRUE;
}
- if (command_applet->buffer != NULL) {
- g_free(command_applet->buffer);
- }
+ g_free(command_applet->buffer);
command_applet->buffer = g_new0(gchar, command_applet->width+1);
set_up_io_channel (stdout_fd, G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL,