* gnoemoe/gm-world.c: set world name from path when options
couldn't be succesfully loaded * gnoemoe/gm-editor.c: allways write \n (also on last line) * gnoemoe/gm-options.c: set file path even if it couldn't be loaded so that when there is no options file it will be saved correctly. return false when loading fails * gnoemoe/widgets/gm-external-view.c: use default gnome terminal when terminal is needed * gnoemoe/widgets/gm-world-tab.c: fix tab close button
This commit is contained in:
parent
4084be6076
commit
e7bf115295
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2006-12-08 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
|
* gnoemoe/gm-world.c: set world name from path when options
|
||||||
|
couldn't be succesfully loaded
|
||||||
|
* gnoemoe/gm-editor.c: allways write \n (also on last line)
|
||||||
|
* gnoemoe/gm-options.c: set file path even if it couldn't be
|
||||||
|
loaded so that when there is no options file it will be
|
||||||
|
saved correctly. return false when loading fails
|
||||||
|
* gnoemoe/widgets/gm-external-view.c: use default gnome
|
||||||
|
terminal when terminal is needed
|
||||||
|
* gnoemoe/widgets/gm-world-tab.c: fix tab close buttons
|
||||||
|
|
||||||
|
2006-12-08 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
|
* gnoemoe/gm-support.c: fixed the tab close button
|
||||||
|
* gnoemoe/gm-pixbuf.c: fixed warning on creating save close button
|
||||||
|
|
||||||
2006-18-06 Jesse van den Kieboom <jesse@icecrew.nl>
|
2006-18-06 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
* gnoemoe/gm-world.c: added static to functions, added flushing history
|
* gnoemoe/gm-world.c: added static to functions, added flushing history
|
||||||
to disk
|
to disk
|
||||||
|
|
|
@ -254,11 +254,9 @@ gm_editor_write_lines(GmEditor *editor) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line->next) {
|
if (write(fd, "\n", 1) == -1) {
|
||||||
if (write(fd, "\n", 1) == -1) {
|
gm_debug_msg(DEBUG_ALWAYS, "Writing failed");
|
||||||
gm_debug_msg(DEBUG_ALWAYS, "Writing failed");
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ gm_options_save_as(GmOptions *options, gchar const *filename) {
|
||||||
gm_options_save(options);
|
gm_options_save(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
gm_options_load(GmOptions *options, gchar const *filename) {
|
gm_options_load(GmOptions *options, gchar const *filename) {
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr root;
|
xmlNodePtr root;
|
||||||
|
@ -222,9 +222,12 @@ gm_options_load(GmOptions *options, gchar const *filename) {
|
||||||
gm_debug_msg(DEBUG_DEFAULT, "GmOptions.load: loading options (%s)!",
|
gm_debug_msg(DEBUG_DEFAULT, "GmOptions.load: loading options (%s)!",
|
||||||
filename);
|
filename);
|
||||||
|
|
||||||
|
g_free(options->priv->filepath);
|
||||||
|
options->priv->filepath = g_strdup(filename);
|
||||||
|
|
||||||
if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
|
if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
|
||||||
gm_debug_msg(DEBUG_DEFAULT, "GmOptions.load: file does not exist");
|
gm_debug_msg(DEBUG_DEFAULT, "GmOptions.load: file does not exist");
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = xmlParseFile(filename);
|
doc = xmlParseFile(filename);
|
||||||
|
@ -232,20 +235,20 @@ gm_options_load(GmOptions *options, gchar const *filename) {
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
gm_debug_msg(DEBUG_DEFAULT,
|
gm_debug_msg(DEBUG_DEFAULT,
|
||||||
"GmOptions.load: error on parsing options file");
|
"GmOptions.load: error on parsing options file");
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
root = xmlDocGetRootElement(doc);
|
root = xmlDocGetRootElement(doc);
|
||||||
|
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmlStrcmp(root->name, (const xmlChar *)(XML_ROOT_NAME))) {
|
if (xmlStrcmp(root->name, (const xmlChar *)(XML_ROOT_NAME))) {
|
||||||
gm_debug_msg(DEBUG_DEFAULT, "GmOptions.load: invalid root node");
|
gm_debug_msg(DEBUG_DEFAULT, "GmOptions.load: invalid root node");
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (root = root->xmlChildrenNode; root; root = root->next) {
|
for (root = root->xmlChildrenNode; root; root = root->next) {
|
||||||
|
@ -255,9 +258,7 @@ gm_options_load(GmOptions *options, gchar const *filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
return TRUE;
|
||||||
g_free(options->priv->filepath);
|
|
||||||
options->priv->filepath = g_strdup(filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -402,7 +402,7 @@ gm_world_load_input_history(GmWorld *world) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_free(str, TRUE);
|
g_string_free(str, TRUE);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else {
|
} else {
|
||||||
gm_debug_msg(DEBUG_DEFAULT, "GmWorld.LoadInputHistory: could not "
|
gm_debug_msg(DEBUG_DEFAULT, "GmWorld.LoadInputHistory: could not "
|
||||||
|
@ -519,6 +519,7 @@ GmWorld *
|
||||||
gm_world_new(gchar *path) {
|
gm_world_new(gchar *path) {
|
||||||
GmWorld *world = GM_WORLD(g_object_new(GM_TYPE_WORLD, NULL));
|
GmWorld *world = GM_WORLD(g_object_new(GM_TYPE_WORLD, NULL));
|
||||||
gchar *options_path;
|
gchar *options_path;
|
||||||
|
gchar *basename;
|
||||||
|
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
options_path = g_strconcat(path, G_DIR_SEPARATOR_S, "settings.xml", NULL);
|
options_path = g_strconcat(path, G_DIR_SEPARATOR_S, "settings.xml", NULL);
|
||||||
|
@ -531,7 +532,13 @@ gm_world_new(gchar *path) {
|
||||||
"settings for %s", path);
|
"settings for %s", path);
|
||||||
|
|
||||||
_gm_options_check_old_options(options_path);
|
_gm_options_check_old_options(options_path);
|
||||||
gm_options_load(world->priv->options, options_path);
|
|
||||||
|
if (!gm_options_load(world->priv->options, options_path)) {
|
||||||
|
/* Set the name then */
|
||||||
|
basename = g_path_get_basename(path);
|
||||||
|
gm_options_set(world->priv->options, "name", basename);
|
||||||
|
g_free(basename);
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(gm_options_get(world->priv->options, "charset")) == 0) {
|
if (strlen(gm_options_get(world->priv->options, "charset")) == 0) {
|
||||||
gm_options_set(world->priv->options, "charset",
|
gm_options_set(world->priv->options, "charset",
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libgnome/libgnome.h>
|
#include <libgnome/libgnome.h>
|
||||||
|
#include <gconf/gconf-client.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "gm-external-view.h"
|
#include "gm-external-view.h"
|
||||||
#include "gm-debug.h"
|
#include "gm-debug.h"
|
||||||
|
@ -65,13 +67,143 @@ gm_external_view_spawn(GmExternalView *view, gchar **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
gchar const *terminal;
|
||||||
|
gchar const *arguments;
|
||||||
|
} Terminal;
|
||||||
|
|
||||||
|
static Terminal terminals[] = {
|
||||||
|
{"gnome-terminal", "--disable-factory"},
|
||||||
|
{"gnome-terminal.wrapper", "--disable-factory"},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
resolve_file(gchar const *file) {
|
||||||
|
GSList *paths = NULL;
|
||||||
|
GSList *item;
|
||||||
|
|
||||||
|
gchar *resolve;
|
||||||
|
gchar *prog;
|
||||||
|
|
||||||
|
prog = g_find_program_in_path(file);
|
||||||
|
|
||||||
|
while (prog && g_file_test(prog, G_FILE_TEST_IS_SYMLINK)) {
|
||||||
|
paths = g_slist_prepend(paths, prog);
|
||||||
|
|
||||||
|
resolve = g_file_read_link(prog, NULL);
|
||||||
|
|
||||||
|
if (g_slist_find_custom(paths, resolve, (GCompareFunc)strcmp)) {
|
||||||
|
prog = NULL;
|
||||||
|
g_free(resolve);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
prog = resolve;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (item = paths; item; item = item->next)
|
||||||
|
if (item->data != prog)
|
||||||
|
g_free(item->data);
|
||||||
|
|
||||||
|
g_slist_free(paths);
|
||||||
|
return prog;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Terminal *
|
||||||
|
find_terminal(gchar const *term) {
|
||||||
|
gchar *prog;
|
||||||
|
gchar *basename;
|
||||||
|
Terminal *terminal;
|
||||||
|
|
||||||
|
prog = resolve_file(term);
|
||||||
|
|
||||||
|
if (prog) {
|
||||||
|
basename = g_path_get_basename(prog);
|
||||||
|
g_message("%s", basename);
|
||||||
|
|
||||||
|
for (terminal = terminals; terminal->terminal != NULL; ++terminal)
|
||||||
|
if (strcmp(terminal->terminal, basename) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
g_free(basename);
|
||||||
|
g_free(prog);
|
||||||
|
|
||||||
|
if (terminal->terminal)
|
||||||
|
return terminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar **
|
||||||
|
build_terminal_command(gchar const *editor_command) {
|
||||||
|
GConfClient *client;
|
||||||
|
gchar *term;
|
||||||
|
gchar *term_extra_args = NULL;
|
||||||
|
gchar *term_args = NULL;
|
||||||
|
gchar **spawn_command = NULL;
|
||||||
|
Terminal *terminal;
|
||||||
|
gchar **argv;
|
||||||
|
gint argc;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
client = gconf_client_get_default();
|
||||||
|
term = gconf_client_get_string(client,
|
||||||
|
"/desktop/gnome/applications/terminal/exec", NULL);
|
||||||
|
|
||||||
|
if (term != NULL)
|
||||||
|
term_extra_args = gconf_client_get_string(client,
|
||||||
|
"/desktop/gnome/applications/terminal/exec_arg", NULL);
|
||||||
|
else {
|
||||||
|
term = g_strdup(getenv("TERM"));
|
||||||
|
|
||||||
|
if (term == NULL)
|
||||||
|
term = g_strdup("xterm");
|
||||||
|
|
||||||
|
term_extra_args = g_strdup("-e");
|
||||||
|
}
|
||||||
|
|
||||||
|
terminal = find_terminal(term);
|
||||||
|
|
||||||
|
if (terminal)
|
||||||
|
term_args = (gchar *)(terminal->arguments);
|
||||||
|
|
||||||
|
if (term_args || (term_extra_args && *term_extra_args != '\0')) {
|
||||||
|
term_args = g_strdup_printf("%s %s %s", term_args ? term_args : "",
|
||||||
|
term_extra_args ? term_extra_args : "", editor_command);
|
||||||
|
|
||||||
|
if (g_shell_parse_argv(term_args, &argc, &argv, NULL)) {
|
||||||
|
spawn_command = g_new0(gchar *, argc + 2);
|
||||||
|
spawn_command[0] = term;
|
||||||
|
|
||||||
|
for (i = 0; i < argc; ++i)
|
||||||
|
spawn_command[i + 1] = argv[i];
|
||||||
|
|
||||||
|
g_free(argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(term_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(term_extra_args);
|
||||||
|
g_object_unref(client);
|
||||||
|
|
||||||
|
for (i = 0; spawn_command[i]; ++i)
|
||||||
|
printf("'%s' ", spawn_command[i]);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
return spawn_command;
|
||||||
|
}
|
||||||
|
|
||||||
GmExternalView *
|
GmExternalView *
|
||||||
gm_external_view_new(GmWorld *world, GmEditor *editor) {
|
gm_external_view_new(GmWorld *world, GmEditor *editor) {
|
||||||
GmExternalView *obj = g_new0(GmExternalView, 1);
|
GmExternalView *obj = g_new0(GmExternalView, 1);
|
||||||
gchar *spawn_command[4] = {NULL, NULL, NULL, NULL};
|
gchar **spawn_command = NULL;
|
||||||
gchar **av, *command;
|
gchar *filename;
|
||||||
gint an;
|
gchar *command;
|
||||||
|
gint argc;
|
||||||
GmOptions *options = gm_app_options(gm_app_instance());
|
GmOptions *options = gm_app_options(gm_app_instance());
|
||||||
|
|
||||||
obj->world = world;
|
obj->world = world;
|
||||||
|
@ -84,26 +216,21 @@ gm_external_view_new(GmWorld *world, GmEditor *editor) {
|
||||||
GNOME_VFS_MONITOR_FILE,
|
GNOME_VFS_MONITOR_FILE,
|
||||||
(GnomeVFSMonitorCallback)on_gm_external_view_file_changed, obj);
|
(GnomeVFSMonitorCallback)on_gm_external_view_file_changed, obj);
|
||||||
|
|
||||||
|
filename = g_shell_quote(obj->filename);
|
||||||
command = g_strconcat(gm_options_get(options, "editor_alternative"),
|
command = g_strconcat(gm_options_get(options, "editor_alternative"),
|
||||||
" ", obj->filename, NULL);
|
" ", filename, NULL);
|
||||||
|
g_free(filename);
|
||||||
|
|
||||||
if (gm_options_get_int(options, "editor_needs_terminal")) {
|
if (gm_options_get_int(options, "editor_needs_terminal")) {
|
||||||
spawn_command[0] = getenv("TERM");
|
spawn_command = build_terminal_command(command);
|
||||||
|
|
||||||
if (spawn_command[0] == NULL) {
|
|
||||||
spawn_command[0] = "xterm";
|
|
||||||
}
|
|
||||||
|
|
||||||
spawn_command[1] = "-e";
|
|
||||||
spawn_command[2] = command;
|
|
||||||
|
|
||||||
gm_external_view_spawn(obj, spawn_command);
|
|
||||||
} else {
|
} else {
|
||||||
g_shell_parse_argv(command, &an, &av, NULL);
|
g_shell_parse_argv(command, &argc, &spawn_command, NULL);
|
||||||
gm_external_view_spawn(obj, av);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gm_external_view_spawn(obj, spawn_command);
|
||||||
|
g_strfreev(spawn_command);
|
||||||
g_free(command);
|
g_free(command);
|
||||||
|
|
||||||
obj->child_watch = g_child_watch_add(obj->pid,
|
obj->child_watch = g_child_watch_add(obj->pid,
|
||||||
(GChildWatchFunc)on_gm_external_view_exited, obj);
|
(GChildWatchFunc)on_gm_external_view_exited, obj);
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@ gm_world_tab_create_interface(GmWorldTab *obj) {
|
||||||
GtkWidget *image, *label, *button, *image_button;
|
GtkWidget *image, *label, *button, *image_button;
|
||||||
GtkSettings *settings;
|
GtkSettings *settings;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
|
GtkRcStyle *rcstyle;
|
||||||
|
|
||||||
image = gtk_image_new();
|
image = gtk_image_new();
|
||||||
label = gtk_label_new("");
|
label = gtk_label_new("");
|
||||||
|
@ -98,13 +99,18 @@ gm_world_tab_create_interface(GmWorldTab *obj) {
|
||||||
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
|
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
|
||||||
gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
|
gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
|
||||||
|
|
||||||
|
rcstyle = gtk_rc_style_new();
|
||||||
|
rcstyle->xthickness = rcstyle->ythickness = 0;
|
||||||
|
gtk_widget_modify_style(button, rcstyle);
|
||||||
|
gtk_rc_style_unref(rcstyle);
|
||||||
|
|
||||||
gtk_container_add(GTK_CONTAINER(button), image_button);
|
gtk_container_add(GTK_CONTAINER(button), image_button);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(obj), image, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(obj), image, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_start(GTK_BOX(obj), label, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(obj), label, FALSE, FALSE, 0);
|
||||||
gtk_box_pack_end(GTK_BOX(obj), button, FALSE, FALSE, 0);
|
gtk_box_pack_end(GTK_BOX(obj), button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
gtk_box_set_spacing(GTK_BOX(obj), 6);
|
gtk_box_set_spacing(GTK_BOX(obj), 3);
|
||||||
|
|
||||||
obj->priv->image = GTK_IMAGE(image);
|
obj->priv->image = GTK_IMAGE(image);
|
||||||
obj->priv->label = GTK_LABEL(label);
|
obj->priv->label = GTK_LABEL(label);
|
||||||
|
|
Reference in New Issue