Expose output pane to scripts

This commit is contained in:
Yevgen Muntyan 2013-12-05 13:36:57 -08:00
parent 43b8539458
commit 554dcd93a6
6 changed files with 69 additions and 13 deletions

View File

@ -406,7 +406,7 @@ class Module(object):
else: else:
raise RuntimeError("in %s: invalid annotation '%s'" % (pfunc.name, a,)) raise RuntimeError("in %s: invalid annotation '%s'" % (pfunc.name, a,))
if param.type is None: if param.type is None:
raise RuntimeError('in %s: param type missing' % pfunc.name) raise RuntimeError('in %s: type of param "%s" is missing' % (pfunc.name, param.name))
return param return param
def __add_vmethod(self, pfunc): def __add_vmethod(self, pfunc):

View File

@ -120,6 +120,9 @@ class Writer(object):
elif isinstance(sym, Type): elif isinstance(sym, Type):
return '<constant><link linkend="%(mode)s.%(symbol)s">%(name)s</link></constant>' % \ return '<constant><link linkend="%(mode)s.%(symbol)s">%(name)s</link></constant>' % \
dict(symbol=name, mode=self.mode, name=self.__make_class_name(sym)) dict(symbol=name, mode=self.mode, name=self.__make_class_name(sym))
elif isinstance(sym, Method):
return '<constant><link linkend="%(mode)s.%(symbol)s">%(Class)s.%(method)s()</link></constant>' % \
dict(symbol=name, mode=self.mode, Class=self.__make_class_name(sym.cls), method=sym.name)
else: else:
oops(name) oops(name)
if self.mode == 'python': if self.mode == 'python':

View File

@ -14,7 +14,7 @@
*/ */
/** /**
* class:MooCmdView: (parent MooLineView) (constructable) (moo.private 1) * class:MooCmdView: (parent MooLineView) (constructable)
**/ **/
#include "moocmdview.h" #include "moocmdview.h"
@ -256,7 +256,7 @@ moo_cmd_view_set_filter (MooCmdView *view,
} }
/** /**
* moo_cmd_view_set_filter_by_id: (moo.lua 0) * moo_cmd_view_set_filter_by_id:
* *
* @view: * @view:
* @id: (type const-utf8) * @id: (type const-utf8)
@ -335,11 +335,11 @@ stderr_line_cb (MooCmd *cmd,
/** /**
* moo_cmd_view_run_command: (moo.lua 0) * moo_cmd_view_run_command:
* *
* @view: * @view:
* @cmd: (type filename) * @cmd: (type const-filename)
* @working_dir: (type filename) (allow-none) (default NULL) * @working_dir: (type const-filename) (allow-none) (default NULL)
* @job_name: (type const-utf8) (allow-none) (default NULL) * @job_name: (type const-utf8) (allow-none) (default NULL)
*/ */
gboolean gboolean
@ -569,6 +569,35 @@ moo_cmd_view_abort (MooCmdView *view)
} }
/**
* moo_cmd_view_write_with_filter:
*
* @view:
* @text: (type const-utf8)
* @error: (allow-none) (default FALSE)
*/
void
moo_cmd_view_write_with_filter (MooCmdView *view,
const char *text,
gboolean error)
{
char **lines;
char **p;
lines = moo_splitlines (text);
for (p = lines; p && *p; ++p)
{
if (error)
moo_cmd_view_stderr_line (view, *p);
else
moo_cmd_view_stdout_line (view, *p);
}
g_strfreev (lines);
}
static gboolean static gboolean
moo_cmd_view_stdout_line (MooCmdView *view, moo_cmd_view_stdout_line (MooCmdView *view,
const char *line) const char *line)

View File

@ -75,6 +75,10 @@ void moo_cmd_view_set_filter_by_id (MooCmdView *view,
void moo_cmd_view_add_filter_dirs (MooCmdView *view, void moo_cmd_view_add_filter_dirs (MooCmdView *view,
char **dirs); char **dirs);
void moo_cmd_view_write_with_filter (MooCmdView *view,
const char *text,
gboolean error);
gboolean moo_cmd_view_run_command (MooCmdView *view, gboolean moo_cmd_view_run_command (MooCmdView *view,
const char *cmd, const char *cmd,
const char *working_dir, const char *working_dir,

View File

@ -3,6 +3,20 @@
#include "mooutils/moostock.h" #include "mooutils/moostock.h"
#include "mooutils/mooi18n.h" #include "mooutils/mooi18n.h"
#define MOO_EDIT_WINDOW_OUTPUT "moo-edit-window-output"
#define MOO_OUTPUT "moo-output"
/**
* moo_edit_window_get_output:
*
* @window:
*
* Returns: an output pane, as #MooCmdView object.
*
* Get the output pane, create it if necessary. This function
* does not open the pane, use #moo_edit_window_present_output
* for that.
*/
GtkWidget * GtkWidget *
moo_edit_window_get_output (MooEditWindow *window) moo_edit_window_get_output (MooEditWindow *window)
{ {
@ -12,7 +26,7 @@ moo_edit_window_get_output (MooEditWindow *window)
g_return_val_if_fail (MOO_IS_EDIT_WINDOW (window), NULL); g_return_val_if_fail (MOO_IS_EDIT_WINDOW (window), NULL);
scrolled_window = moo_edit_window_get_pane (window, "moo-edit-window-output"); scrolled_window = moo_edit_window_get_pane (window, MOO_EDIT_WINDOW_OUTPUT);
if (!scrolled_window) if (!scrolled_window)
{ {
@ -26,14 +40,14 @@ moo_edit_window_get_output (MooEditWindow *window)
moo_text_view_set_font_from_string (MOO_TEXT_VIEW (cmd_view), "Monospace"); moo_text_view_set_font_from_string (MOO_TEXT_VIEW (cmd_view), "Monospace");
gtk_container_add (GTK_CONTAINER (scrolled_window), cmd_view); gtk_container_add (GTK_CONTAINER (scrolled_window), cmd_view);
gtk_widget_show_all (scrolled_window); gtk_widget_show_all (scrolled_window);
g_object_set_data (G_OBJECT (scrolled_window), "moo-output", cmd_view); g_object_set_data (G_OBJECT (scrolled_window), MOO_OUTPUT, cmd_view);
label = moo_pane_label_new (MOO_STOCK_TERMINAL, NULL, label = moo_pane_label_new (MOO_STOCK_TERMINAL, NULL,
/* label of Output window pane */ /* label of Output window pane */
C_("window-pane", "Output"), C_("window-pane", "Output"),
C_("window-pane", "Output")); C_("window-pane", "Output"));
if (!moo_edit_window_add_pane (window, "moo-edit-window-output", if (!moo_edit_window_add_pane (window, MOO_EDIT_WINDOW_OUTPUT,
scrolled_window, label, MOO_PANE_POS_BOTTOM)) scrolled_window, label, MOO_PANE_POS_BOTTOM))
{ {
g_critical ("oops"); g_critical ("oops");
@ -47,18 +61,25 @@ moo_edit_window_get_output (MooEditWindow *window)
return cmd_view; return cmd_view;
} }
return g_object_get_data (G_OBJECT (scrolled_window), "moo-output"); return g_object_get_data (G_OBJECT (scrolled_window), MOO_OUTPUT);
} }
GtkWidget * static GtkWidget *
moo_edit_window_get_output_pane (MooEditWindow *window) moo_edit_window_get_output_pane (MooEditWindow *window)
{ {
g_return_val_if_fail (MOO_IS_EDIT_WINDOW (window), NULL); g_return_val_if_fail (MOO_IS_EDIT_WINDOW (window), NULL);
return moo_edit_window_get_pane (window, "moo-edit-window-output"); return moo_edit_window_get_pane (window, MOO_EDIT_WINDOW_OUTPUT);
} }
/**
* moo_edit_window_present_output:
*
* @window:
*
* Open the output pane.
*/
void void
moo_edit_window_present_output (MooEditWindow *window) moo_edit_window_present_output (MooEditWindow *window)
{ {

View File

@ -7,7 +7,6 @@ G_BEGIN_DECLS
void moo_edit_window_present_output (MooEditWindow *window); void moo_edit_window_present_output (MooEditWindow *window);
GtkWidget *moo_edit_window_get_output (MooEditWindow *window); GtkWidget *moo_edit_window_get_output (MooEditWindow *window);
GtkWidget *moo_edit_window_get_output_pane (MooEditWindow *window);
G_END_DECLS G_END_DECLS