Continuing inter-app communication stuff

This commit is contained in:
Yevgen Muntyan 2005-10-31 21:41:20 +00:00
parent 391a77c8d1
commit 3b8ec37af2
5 changed files with 91 additions and 11 deletions

View File

@ -17,3 +17,10 @@ App
========
1. Command line options
Misc
========
1. Make MooNotebook subclass GtkContainer; apparently dogtail doesn't like it to be
a GtkNotebook.

View File

@ -22,6 +22,7 @@
#include "mooapp/moopython.h"
#endif
#define WANT_MOO_APP_CMD_CHARS
#include "mooapp/mooapp-private.h"
#include "mooapp/mooappinput.h"
#include "mooapp/mooappoutput.h"
@ -33,6 +34,7 @@
#include "mooutils/moocompat.h"
#include "mooutils/moodialogs.h"
#include "mooutils/moostock.h"
#include "mooutils/moowin.h"
#ifdef VERSION
@ -1546,35 +1548,68 @@ moo_app_open_file (MooApp *app,
}
static void
moo_app_present (MooApp *app)
{
gpointer window = app->priv->term_window;
if (!window && app->priv->editor)
window = moo_editor_get_active_window (app->priv->editor);
g_return_if_fail (window != NULL);
moo_window_present (window);
}
static MooAppCmdCode get_cmd_code (char cmd)
{
guint i;
for (i = 1; i < MOO_APP_CMD_LAST; ++i)
if (cmd == moo_app_cmd_chars[i])
return i;
return MOO_APP_CMD_ZERO;
}
static void
moo_app_exec_cmd_real (MooApp *app,
char cmd,
const char *data,
G_GNUC_UNUSED guint len)
{
MooAppCmdCode code;
g_return_if_fail (MOO_IS_APP (app));
switch (cmd)
code = get_cmd_code (cmd);
switch (code)
{
#ifdef MOO_USE_PYTHON
case MOO_APP_PYTHON_STRING:
case MOO_APP_CMD_PYTHON_STRING:
moo_app_python_run_string (app, data);
break;
case MOO_APP_PYTHON_FILE:
case MOO_APP_CMD_PYTHON_FILE:
moo_app_python_run_file (app, data);
break;
#endif
case MOO_APP_OPEN_FILE:
case MOO_APP_CMD_OPEN_FILE:
moo_app_open_file (app, data);
break;
case MOO_APP_QUIT:
case MOO_APP_CMD_QUIT:
moo_app_quit (app);
break;
case MOO_APP_DIE:
case MOO_APP_CMD_DIE:
MOO_APP_GET_CLASS(app)->quit (app);
break;
case MOO_APP_CMD_PRESENT:
moo_app_present (app);
break;
default:
g_warning ("%s: got unknown command %d", G_STRLOC, cmd);
}

View File

@ -23,11 +23,40 @@
G_BEGIN_DECLS
#define MOO_APP_PYTHON_STRING 's'
#define MOO_APP_PYTHON_FILE 'p'
#define MOO_APP_OPEN_FILE 'f'
#define MOO_APP_QUIT 'q'
#define MOO_APP_DIE 'd'
typedef enum
{
MOO_APP_CMD_ZERO = 0,
MOO_APP_CMD_PYTHON_STRING,
MOO_APP_CMD_PYTHON_FILE,
MOO_APP_CMD_OPEN_FILE,
MOO_APP_CMD_QUIT,
MOO_APP_CMD_DIE,
MOO_APP_CMD_PRESENT,
MOO_APP_CMD_LAST
} MooAppCmdCode;
#ifdef WANT_MOO_APP_CMD_CHARS
#define CMD_ZERO "\0"
#define CMD_PYTHON_STRING "s"
#define CMD_PYTHON_FILE "p"
#define CMD_OPEN_FILE "f"
#define CMD_QUIT "q"
#define CMD_DIE "d"
#define CMD_PRESENT "r"
static const char *moo_app_cmd_chars =
CMD_ZERO
CMD_PYTHON_STRING
CMD_PYTHON_FILE
CMD_OPEN_FILE
CMD_QUIT
CMD_DIE
CMD_PRESENT
;
#endif /* WANT_MOO_APP_CMD_CHARS */
typedef struct _MooAppInput MooAppInput;

View File

@ -276,6 +276,14 @@ GtkWindow *moo_get_top_window (GSList *windows)
#endif
/* TODO use gtk_window_present_with_time(), use Xlib? */
void
moo_window_present (GtkWindow *window)
{
g_return_if_fail (GTK_IS_WINDOW (window));
gtk_window_present (window);
}
gboolean moo_window_set_icon_from_stock (GtkWindow *window,
const char *stock_id)

View File

@ -20,6 +20,7 @@ G_BEGIN_DECLS
gboolean moo_window_is_hidden (GtkWindow *window);
void moo_window_present (GtkWindow *window);
GtkWindow *moo_get_top_window (GSList *windows);
GtkWindow *moo_get_toplevel_window (void);