"check-brackets" property of MooTextView
parent
b7051f800c
commit
06c14f5a3e
|
@ -135,6 +135,7 @@ static void moo_pane_view_init (MooPaneView *view)
|
|||
"editable", FALSE,
|
||||
"cursor-visible", FALSE,
|
||||
"current-line-color", "grey",
|
||||
"check-brackets", FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ enum {
|
|||
PROP_BUFFER,
|
||||
PROP_INDENTER,
|
||||
PROP_HIGHLIGHT_CURRENT_LINE,
|
||||
PROP_CHECK_BRACKETS,
|
||||
PROP_CURRENT_LINE_COLOR,
|
||||
PROP_CURRENT_LINE_COLOR_GDK,
|
||||
PROP_SHOW_TABS,
|
||||
|
@ -152,6 +153,14 @@ static void moo_text_view_class_init (MooTextViewClass *klass)
|
|||
TRUE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_CHECK_BRACKETS,
|
||||
g_param_spec_boolean ("check-brackets",
|
||||
"check-brackets",
|
||||
"check-brackets",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_CURRENT_LINE_COLOR_GDK,
|
||||
g_param_spec_boxed ("current-line-color-gdk",
|
||||
|
@ -512,6 +521,11 @@ moo_text_view_set_property (GObject *object,
|
|||
moo_text_view_set_indenter (view, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_CHECK_BRACKETS:
|
||||
g_object_set (get_buffer (view), "check-brackets",
|
||||
g_value_get_boolean (value), NULL);
|
||||
break;
|
||||
|
||||
case PROP_HIGHLIGHT_CURRENT_LINE:
|
||||
moo_text_view_set_highlight_current_line (view, g_value_get_boolean (value));
|
||||
break;
|
||||
|
@ -543,6 +557,7 @@ moo_text_view_get_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
MooTextView *view = MOO_TEXT_VIEW (object);
|
||||
gboolean val;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
|
@ -558,6 +573,11 @@ moo_text_view_get_property (GObject *object,
|
|||
g_value_set_boolean (value, view->priv->highlight_current_line);
|
||||
break;
|
||||
|
||||
case PROP_CHECK_BRACKETS:
|
||||
g_object_get (get_buffer (view), "check-brackets", &val, NULL);
|
||||
g_value_set_boolean (value, val);
|
||||
break;
|
||||
|
||||
case PROP_CURRENT_LINE_COLOR_GDK:
|
||||
g_value_set_boxed (value, &view->priv->current_line_color);
|
||||
break;
|
||||
|
|
|
@ -593,47 +593,39 @@ get_file_list (MooMarkupNode *parent)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
command_free (Command *command)
|
||||
{
|
||||
if (command)
|
||||
{
|
||||
g_free (command->working_dir);
|
||||
g_strfreev (command->argv);
|
||||
g_strfreev (command->envp);
|
||||
g_free (command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Command*
|
||||
char*
|
||||
project_get_command (Project *project,
|
||||
CommandType command_type)
|
||||
{
|
||||
Command *command;
|
||||
GString *command;
|
||||
|
||||
g_return_val_if_fail (project != NULL, NULL);
|
||||
|
||||
command = g_new0 (Command, 1);
|
||||
command = g_string_new ("");
|
||||
|
||||
switch (command_type)
|
||||
{
|
||||
case COMMAND_BUILD_PROJECT:
|
||||
command->argv = g_new0 (char*, 2);
|
||||
command->argv[0] = g_strdup ("make");
|
||||
|
||||
if (g_path_is_absolute (project->active->build_dir))
|
||||
command->working_dir = g_strdup (project->active->build_dir);
|
||||
{
|
||||
g_string_printf (command, "cd '%s' && make",
|
||||
project->active->build_dir);
|
||||
}
|
||||
else
|
||||
command->working_dir = g_build_filename (project->project_dir,
|
||||
project->active->build_dir,
|
||||
NULL);
|
||||
{
|
||||
char *working_dir =
|
||||
g_build_filename (project->project_dir,
|
||||
project->active->build_dir,
|
||||
NULL);
|
||||
g_string_printf (command, "cd '%s' && make",
|
||||
working_dir);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_free (command);
|
||||
g_string_free (command, TRUE);
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
return command;
|
||||
return g_string_free (command, FALSE);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ typedef struct _Configuration Configuration;
|
|||
typedef struct _RunOptions RunOptions;
|
||||
typedef struct _MakeOptions MakeOptions;
|
||||
typedef struct _ConfigureOptions ConfigureOptions;
|
||||
typedef struct _Command Command;
|
||||
|
||||
|
||||
struct _Project
|
||||
|
@ -65,13 +64,6 @@ struct _ConfigureOptions
|
|||
{
|
||||
};
|
||||
|
||||
struct _Command
|
||||
{
|
||||
char *working_dir;
|
||||
char **argv;
|
||||
char **envp;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
COMMAND_BUILD_PROJECT
|
||||
} CommandType;
|
||||
|
@ -88,11 +80,9 @@ Configuration *project_get_configuration (Project *project,
|
|||
const char *name);
|
||||
|
||||
/* must be freed */
|
||||
Command *project_get_command (Project *project,
|
||||
char *project_get_command (Project *project,
|
||||
CommandType command_type);
|
||||
|
||||
void command_free (Command *command);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -289,7 +289,11 @@ cproject_plugin_attach (CProjectPlugin *plugin,
|
|||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
|
||||
GTK_SHADOW_ETCHED_IN);
|
||||
|
||||
widget = moo_pane_view_new ();
|
||||
widget = g_object_new (MOO_TYPE_CMD_VIEW,
|
||||
"wrap-mode", GTK_WRAP_WORD,
|
||||
"highlight-current-line", FALSE,
|
||||
NULL);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (swin), widget);
|
||||
gtk_widget_show_all (swin);
|
||||
|
||||
|
@ -298,7 +302,7 @@ cproject_plugin_attach (CProjectPlugin *plugin,
|
|||
moo_edit_window_add_pane (window, CPROJECT_PLUGIN_ID,
|
||||
swin, label, MOO_PANE_POS_BOTTOM);
|
||||
|
||||
plugin->output = MOO_PANE_VIEW (widget);
|
||||
plugin->output = MOO_CMD_VIEW (widget);
|
||||
}
|
||||
|
||||
|
||||
|
@ -576,167 +580,34 @@ window_close (CProjectPlugin *plugin)
|
|||
|
||||
|
||||
static void
|
||||
command_exit (GPid pid,
|
||||
gint status,
|
||||
CProjectPlugin *plugin)
|
||||
run_command (CProjectPlugin *plugin,
|
||||
char *command)
|
||||
{
|
||||
g_return_if_fail (pid == plugin->command_pid);
|
||||
GtkWidget *pane;
|
||||
|
||||
if (plugin->command_out_watch)
|
||||
g_source_remove (plugin->command_out_watch);
|
||||
if (plugin->command_err_watch)
|
||||
g_source_remove (plugin->command_err_watch);
|
||||
|
||||
command_free (plugin->running);
|
||||
plugin->running = NULL;
|
||||
|
||||
g_spawn_close_pid (pid);
|
||||
|
||||
g_return_if_fail (WIFEXITED (status));
|
||||
|
||||
if (!WEXITSTATUS (status))
|
||||
{
|
||||
moo_pane_view_write_line (plugin->output, "*** Success ***", -1, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *msg = g_strdup_printf ("Command failed with status %d",
|
||||
WEXITSTATUS (status));
|
||||
moo_pane_view_write_line (plugin->output, msg, -1, NULL);
|
||||
g_free (msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
command_out_or_err (GIOChannel *channel,
|
||||
GIOCondition condition,
|
||||
gboolean stdout,
|
||||
CProjectPlugin *plugin)
|
||||
{
|
||||
char *line = NULL;
|
||||
gsize length;
|
||||
GError *error = NULL;
|
||||
|
||||
if (condition & (G_IO_ERR | G_IO_HUP))
|
||||
goto end;
|
||||
|
||||
g_io_channel_read_line (channel, &line, &length,
|
||||
NULL, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error->message);
|
||||
g_error_free (error);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (line)
|
||||
{
|
||||
moo_pane_view_write_line (plugin->output, line, length, NULL);
|
||||
g_free (line);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
end:
|
||||
if (stdout)
|
||||
plugin->command_out_watch = 0;
|
||||
else
|
||||
plugin->command_err_watch = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
command_out (GIOChannel *channel,
|
||||
GIOCondition condition,
|
||||
CProjectPlugin *plugin)
|
||||
{
|
||||
return command_out_or_err (channel, condition, TRUE, plugin);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
command_err (GIOChannel *channel,
|
||||
GIOCondition condition,
|
||||
CProjectPlugin *plugin)
|
||||
{
|
||||
return command_out_or_err (channel, condition, FALSE, plugin);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cproject_run_command (CProjectPlugin *plugin,
|
||||
Command *command)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GIOChannel *command_out_chan, *command_err_chan;
|
||||
|
||||
g_return_if_fail (plugin->output != NULL);
|
||||
g_return_if_fail (plugin->window != NULL);
|
||||
g_return_if_fail (command != NULL);
|
||||
|
||||
if (plugin->running)
|
||||
return;
|
||||
pane = moo_edit_window_get_pane (plugin->window, CPROJECT_PLUGIN_ID);
|
||||
g_return_if_fail (pane != NULL);
|
||||
|
||||
g_spawn_async_with_pipes (command->working_dir,
|
||||
command->argv, command->envp,
|
||||
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
NULL, NULL,
|
||||
&plugin->command_pid,
|
||||
NULL,
|
||||
&plugin->command_stdout,
|
||||
&plugin->command_stderr,
|
||||
&error);
|
||||
moo_pane_view_clear (MOO_PANE_VIEW (plugin->output));
|
||||
moo_big_paned_present_pane (plugin->window->paned, pane);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_warning ("%s: %s", G_STRLOC, error->message);
|
||||
g_error_free (error);
|
||||
command_free (command);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin->running = command;
|
||||
|
||||
plugin->command_watch =
|
||||
g_child_watch_add (plugin->command_pid,
|
||||
(GChildWatchFunc) command_exit,
|
||||
plugin);
|
||||
|
||||
command_out_chan = g_io_channel_unix_new (plugin->command_stdout);
|
||||
g_io_channel_set_encoding (command_out_chan, NULL, NULL);
|
||||
g_io_channel_set_buffered (command_out_chan, TRUE);
|
||||
g_io_channel_set_flags (command_out_chan, G_IO_FLAG_NONBLOCK, NULL);
|
||||
plugin->command_out_watch =
|
||||
g_io_add_watch_full (command_out_chan,
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
G_IO_IN | G_IO_PRI,
|
||||
(GIOFunc) command_out, plugin, NULL);
|
||||
g_io_channel_unref (command_out_chan);
|
||||
|
||||
command_err_chan = g_io_channel_unix_new (plugin->command_stderr);
|
||||
g_io_channel_set_encoding (command_err_chan, NULL, NULL);
|
||||
g_io_channel_set_buffered (command_err_chan, TRUE);
|
||||
g_io_channel_set_flags (command_err_chan, G_IO_FLAG_NONBLOCK, NULL);
|
||||
plugin->command_err_watch =
|
||||
g_io_add_watch_full (command_err_chan,
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
G_IO_IN | G_IO_PRI,
|
||||
(GIOFunc) command_err, plugin, NULL);
|
||||
g_io_channel_unref (command_err_chan);
|
||||
moo_cmd_view_run_command (plugin->output, command);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cproject_build_project (CProjectPlugin *plugin)
|
||||
{
|
||||
Command *command;
|
||||
char *command;
|
||||
|
||||
g_return_if_fail (plugin->project != NULL);
|
||||
g_return_if_fail (plugin->window != NULL);
|
||||
|
||||
command = project_get_command (plugin->project,
|
||||
COMMAND_BUILD_PROJECT);
|
||||
g_return_if_fail (command != NULL);
|
||||
|
||||
cproject_run_command (plugin, command);
|
||||
run_command (plugin, command);
|
||||
g_free (command);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define __C_PROJECT_H__
|
||||
|
||||
#include "mooedit/mooplugin.h"
|
||||
#include "mooedit/moopaneview.h"
|
||||
#include "mooedit/moocmdview.h"
|
||||
#include "cproject-project.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -34,45 +34,34 @@ struct _CProjectPlugin
|
|||
MooEditWindow *window;
|
||||
GtkWidget *build_configuration_menu;
|
||||
MooRecentMgr *recent_mgr;
|
||||
MooPaneView *output;
|
||||
MooCmdView *output;
|
||||
|
||||
Command *running;
|
||||
int command_stdout;
|
||||
int command_stderr;
|
||||
GPid command_pid;
|
||||
guint command_watch;
|
||||
guint command_out_watch;
|
||||
guint command_err_watch;
|
||||
GString *command_out_buf;
|
||||
GString *command_err_buf;
|
||||
char *running;
|
||||
};
|
||||
|
||||
|
||||
GType cproject_plugin_get_type (void);
|
||||
|
||||
gboolean cproject_plugin_init (CProjectPlugin *plugin);
|
||||
void cproject_plugin_deinit (CProjectPlugin *plugin);
|
||||
void cproject_plugin_attach (CProjectPlugin *plugin,
|
||||
MooEditWindow *window);
|
||||
void cproject_plugin_detach (CProjectPlugin *plugin,
|
||||
MooEditWindow *window);
|
||||
gboolean cproject_plugin_init (CProjectPlugin *plugin);
|
||||
void cproject_plugin_deinit (CProjectPlugin *plugin);
|
||||
void cproject_plugin_attach (CProjectPlugin *plugin,
|
||||
MooEditWindow *window);
|
||||
void cproject_plugin_detach (CProjectPlugin *plugin,
|
||||
MooEditWindow *window);
|
||||
|
||||
void cproject_load_prefs (CProjectPlugin *plugin);
|
||||
void cproject_save_prefs (CProjectPlugin *plugin);
|
||||
void cproject_update_project_ui (CProjectPlugin *plugin);
|
||||
void cproject_update_file_ui (CProjectPlugin *plugin);
|
||||
void cproject_load_prefs (CProjectPlugin *plugin);
|
||||
void cproject_save_prefs (CProjectPlugin *plugin);
|
||||
void cproject_update_project_ui (CProjectPlugin *plugin);
|
||||
void cproject_update_file_ui (CProjectPlugin *plugin);
|
||||
|
||||
gboolean cproject_close_project (CProjectPlugin *plugin);
|
||||
void cproject_new_project (CProjectPlugin *plugin);
|
||||
void cproject_open_project (CProjectPlugin *plugin,
|
||||
const char *path);
|
||||
void cproject_project_options (CProjectPlugin *plugin);
|
||||
void cproject_build_project (CProjectPlugin *plugin);
|
||||
void cproject_compile_file (CProjectPlugin *plugin);
|
||||
void cproject_execute (CProjectPlugin *plugin);
|
||||
|
||||
void cproject_run_command (CProjectPlugin *plugin,
|
||||
Command *command);
|
||||
gboolean cproject_close_project (CProjectPlugin *plugin);
|
||||
void cproject_new_project (CProjectPlugin *plugin);
|
||||
void cproject_open_project (CProjectPlugin *plugin,
|
||||
const char *path);
|
||||
void cproject_project_options (CProjectPlugin *plugin);
|
||||
void cproject_build_project (CProjectPlugin *plugin);
|
||||
void cproject_compile_file (CProjectPlugin *plugin);
|
||||
void cproject_execute (CProjectPlugin *plugin);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in New Issue