Commit 5d9faee7 authored by Christian Persch's avatar Christian Persch

all: Rename API

Add _sync suffix and GCancellable argument to synchronous functions.

Conflicts:
	doc/reference/vte-sections.txt
	src/vte.c
parent 163446f4
......@@ -84,10 +84,10 @@ vte_get_default_emulation
vte_get_user_shell
<SUBSECTION>
vte_terminal_fork_command_full
vte_terminal_fork_command_sync
vte_terminal_get_pty
vte_terminal_pty_new
vte_terminal_set_pty
vte_terminal_pty_new_sync
vte_terminal_watch_child
<SUBSECTION Standard>
......@@ -129,8 +129,8 @@ VteTerminalClassPrivate
VtePtyFlags
VtePtyError
VtePty
vte_pty_new
vte_pty_new_foreign
vte_pty_new_sync
vte_pty_new_foreign_sync
vte_pty_close
vte_pty_child_setup
vte_pty_get_fd
......
......@@ -1695,8 +1695,9 @@ vte_pty_error_quark(void)
}
/**
* vte_pty_new:
* vte_pty_new_sync:
* @flags: flags from #VtePtyFlags
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Allocates a new pseudo-terminal.
......@@ -1732,19 +1733,21 @@ vte_pty_error_quark(void)
* Since: 0.26
*/
VtePty *
vte_pty_new (VtePtyFlags flags,
GError **error)
vte_pty_new_sync (VtePtyFlags flags,
GCancellable *cancellable,
GError **error)
{
return g_initable_new (VTE_TYPE_PTY,
NULL /* cancellable */,
cancellable,
error,
"flags", flags,
NULL);
}
/**
* vte_pty_new_foreign:
* vte_pty_new_foreign_sync:
* @fd: (transfer full): a file descriptor to the PTY
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Creates a new #VtePty for the PTY master @fd.
......@@ -1759,13 +1762,14 @@ vte_pty_new (VtePtyFlags flags,
* Since: 0.26
*/
VtePty *
vte_pty_new_foreign (int fd,
GError **error)
vte_pty_new_foreign_sync (int fd,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail(fd >= 0, NULL);
return g_initable_new (VTE_TYPE_PTY,
NULL /* cancellable */,
cancellable,
error,
"fd", fd,
NULL);
......
......@@ -3358,9 +3358,10 @@ _vte_terminal_disconnect_pty_write(VteTerminal *terminal)
}
/**
* vte_terminal_pty_new:
* vte_terminal_pty_new_sync:
* @terminal: a #VteTerminal
* @flags: flags from #VtePtyFlags
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Creates a new #VtePty, and sets the emulation property
......@@ -3369,18 +3370,20 @@ _vte_terminal_disconnect_pty_write(VteTerminal *terminal)
* See vte_pty_new() for more information.
*
* Returns: (transfer full): a new #VtePty
* Since: 0.26
*
* Since: 0.30
*/
VtePty *
vte_terminal_pty_new(VteTerminal *terminal,
VtePtyFlags flags,
GError **error)
vte_terminal_pty_new_sync(VteTerminal *terminal,
VtePtyFlags flags,
GCancellable *cancellable,
GError **error)
{
VtePty *pty;
g_return_val_if_fail(VTE_IS_TERMINAL(terminal), NULL);
pty = vte_pty_new(flags, error);
pty = vte_pty_new_sync(flags, cancellable, error);
if (pty == NULL)
return NULL;
......@@ -3471,7 +3474,7 @@ vte_get_user_shell (void)
}
/**
* vte_terminal_fork_command_full:
* vte_terminal_fork_command_sync:
* @terminal: a #VteTerminal
* @pty_flags: flags from #VtePtyFlags
* @working_directory: (allow-none): the name of a directory the command should start
......@@ -3483,6 +3486,7 @@ vte_get_user_shell (void)
* @child_setup: (allow-none) (scope call): an extra child setup function to run in the child just before exec(), or %NULL
* @child_setup_data: user data for @child_setup
* @child_pid: (out) (allow-none) (transfer full): a location to store the child PID, or %NULL
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: (allow-none): return location for a #GError, or %NULL
*
* Starts the specified command under a newly-allocated controlling
......@@ -3501,10 +3505,10 @@ vte_get_user_shell (void)
*
* Returns: %TRUE on success, or %FALSE on error with @error filled in
*
* Since: 0.26
* Since: 0.30
*/
gboolean
vte_terminal_fork_command_full(VteTerminal *terminal,
vte_terminal_fork_command_sync(VteTerminal *terminal,
VtePtyFlags pty_flags,
const char *working_directory,
char **argv,
......@@ -3513,6 +3517,7 @@ vte_terminal_fork_command_full(VteTerminal *terminal,
GSpawnChildSetupFunc child_setup,
gpointer child_setup_data,
GPid *child_pid /* out */,
GCancellable *cancellable,
GError **error)
{
VtePty *pty;
......@@ -3523,7 +3528,7 @@ vte_terminal_fork_command_full(VteTerminal *terminal,
g_return_val_if_fail(child_setup_data == NULL || child_setup, FALSE);
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
pty = vte_pty_new(pty_flags, error);
pty = vte_terminal_pty_new_sync(terminal, pty_flags, cancellable, error);
if (pty == NULL)
return FALSE;
......
......@@ -179,14 +179,15 @@ GType vte_terminal_get_type(void);
GtkWidget *vte_terminal_new(void);
VtePty *vte_terminal_pty_new (VteTerminal *terminal,
VtePtyFlags flags,
GError **error);
VtePty *vte_terminal_pty_new_sync (VteTerminal *terminal,
VtePtyFlags flags,
GCancellable *cancellable,
GError **error);
void vte_terminal_watch_child (VteTerminal *terminal,
GPid child_pid);
gboolean vte_terminal_fork_command_full(VteTerminal *terminal,
gboolean vte_terminal_fork_command_sync(VteTerminal *terminal,
VtePtyFlags pty_flags,
const char *working_directory,
char **argv,
......@@ -195,6 +196,7 @@ gboolean vte_terminal_fork_command_full(VteTerminal *terminal,
GSpawnChildSetupFunc child_setup,
gpointer child_setup_data,
GPid *child_pid /* out */,
GCancellable *cancellable,
GError **error);
/* Send data to the terminal to display, or to the terminal's forked command
......
......@@ -1052,7 +1052,7 @@ main(int argc, char **argv)
command = "/bin/sh";
if (!g_shell_parse_argv(command, &command_argc, &command_argv, &err) ||
!vte_terminal_fork_command_full(terminal,
!vte_terminal_fork_command_sync(terminal,
pty_flags,
NULL,
command_argv,
......@@ -1060,6 +1060,7 @@ main(int argc, char **argv)
G_SPAWN_SEARCH_PATH,
NULL, NULL,
&pid,
NULL /* cancellable */,
&err)) {
g_warning("Failed to fork: %s\n", err->message);
g_error_free(err);
......@@ -1077,18 +1078,25 @@ main(int argc, char **argv)
#endif
} else {
#ifdef HAVE_FORK
GError *err = NULL;
VtePty *pty;
pid_t pid;
int i;
pty = vte_pty_new(VTE_PTY_DEFAULT, NULL);
pty = vte_pty_new_sync(VTE_PTY_DEFAULT, NULL, &err);
if (pty == NULL) {
g_printerr ("Failed to create PTY: %s\n", err->message);
g_error_free(err);
return 1;
}
pid = fork();
switch (pid) {
case -1:
g_object_unref(pty);
/* abnormal */
g_warning("Error in vte_terminal_forkpty(): %s",
strerror(errno));
g_strerror(errno));
break;
case 0:
/* child */
......
......@@ -23,7 +23,7 @@
#ifndef VTE_PTY_H
#define VTE_PTY_H
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
......@@ -89,11 +89,13 @@ typedef struct _VtePtyClass VtePtyClass;
GType vte_pty_get_type (void);
VtePty *vte_pty_new (VtePtyFlags flags,
GError **error);
VtePty *vte_pty_new_sync (VtePtyFlags flags,
GCancellable *cancellable,
GError **error);
VtePty *vte_pty_new_foreign (int fd,
GError **error);
VtePty *vte_pty_new_foreign_sync (int fd,
GCancellable *cancellable,
GError **error);
int vte_pty_get_fd (VtePty *pty);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment