SF.net SVN: geany: [755] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Tue Aug 22 19:03:53 UTC 2006


Revision: 755
Author:   eht16
Date:     2006-08-22 12:03:38 -0700 (Tue, 22 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=755&view=rev

Log Message:
-----------
Save all VTE settings in an own VTE section in the configuration file instead of using an unhandy string list.
Added new settings: ignore menu bar accelerator and define the shell which is started within the VTE.
(Code not yet complete, might be buggy, GUI stuff is missing)

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keyfile.c
    trunk/src/prefs.c
    trunk/src/utils.c
    trunk/src/vte.c
    trunk/src/vte.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-21 22:28:36 UTC (rev 754)
+++ trunk/ChangeLog	2006-08-22 19:03:38 UTC (rev 755)
@@ -1,3 +1,13 @@
+2006-08-22  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/vte.c, src/prefs.c, src/keyfile.c, src/utils.c:
+   Save all VTE settings in an own VTE section in the configuration
+   file instead of using an unhandy string list.
+   Added new settings: ignore menu bar accelerator and define the shell
+   which is started within the VTE.
+   (Code not yet complete, might be buggy, GUI stuff is missing)
+
+
 2006-08-21  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/images.c, src/notebook.c:

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2006-08-21 22:28:36 UTC (rev 754)
+++ trunk/src/keyfile.c	2006-08-22 19:03:38 UTC (rev 755)
@@ -25,6 +25,12 @@
 
 #include "geany.h"
 
+#ifdef HAVE_VTE
+#include <pwd.h>
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
 #include "support.h"
 #include "keyfile.h"
 #include "utils.h"
@@ -109,12 +115,29 @@
 	g_key_file_set_boolean(config, PACKAGE, "auto_close_xml_tags", app->pref_editor_auto_close_xml_tags);
 	g_key_file_set_boolean(config, PACKAGE, "auto_complete_constructs", app->pref_editor_auto_complete_constructs);
 #ifdef HAVE_VTE
-	g_key_file_set_boolean(config, PACKAGE, "load_vte", vte_info.load_vte);
-	g_key_file_set_comment(config, PACKAGE, "terminal_settings",
-			_(" VTE settings: FONT;FOREGROUND;BACKGROUND;scrollback;type;scroll on keystroke;scroll on output;follow path of file"), NULL);
-	g_key_file_set_string(config, PACKAGE, "terminal_settings", vte_info.terminal_settings);
-	vte_get_working_directory();	// refresh vte_info.dir
-	g_key_file_set_string(config, PACKAGE, "terminal_dir", vte_info.dir);
+	g_key_file_set_boolean(config, "VTE", "load_vte", vte_info.load_vte);
+	if (vte_info.load_vte)
+	{
+		gchar *tmp_string;
+
+		g_key_file_set_string(config, "VTE", "emulation", vc->emulation);
+		g_key_file_set_string(config, "VTE", "font", vc->font);
+		g_key_file_set_boolean(config, "VTE", "scroll_on_key", vc->scroll_on_key);
+		g_key_file_set_boolean(config, "VTE", "scroll_on_out", vc->scroll_on_out);
+		g_key_file_set_boolean(config, "VTE", "ignore_menu_bar_accel", vc->ignore_menu_bar_accel);
+		g_key_file_set_boolean(config, "VTE", "follow_path", vc->follow_path);
+		g_key_file_set_integer(config, "VTE", "scrollback_lines", vc->scrollback_lines);
+		g_key_file_set_string(config, "VTE", "font", vc->font);
+		g_key_file_set_string(config, "VTE", "shell", vc->shell);
+		tmp_string = utils_get_hex_from_color(vc->colour_fore);
+		g_key_file_set_string(config, "VTE", "colour_fore", tmp_string);
+		g_free(tmp_string);
+		tmp_string = utils_get_hex_from_color(vc->colour_back);
+		g_key_file_set_string(config, "VTE", "colour_back", tmp_string);
+		g_free(tmp_string);
+		vte_get_working_directory();	// refresh vte_info.dir
+		g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
+	}
 #endif
 	g_key_file_set_string(config, PACKAGE, "custom_date_format", app->custom_date_format);
 	g_key_file_set_string(config, PACKAGE, "editor_font", app->editor_font);
@@ -324,9 +347,38 @@
 	app->pref_toolbar_show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE);
 	app->pref_toolbar_show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE);
 #ifdef HAVE_VTE
-	vte_info.load_vte = utils_get_setting_boolean(config, PACKAGE, "load_vte", TRUE);
-	vte_info.terminal_settings = utils_get_setting_string(config, PACKAGE, "terminal_settings",	"");
-	vte_info.dir = utils_get_setting_string(config, PACKAGE, "terminal_dir", NULL);
+	vte_info.load_vte = utils_get_setting_boolean(config, "VTE", "load_vte", TRUE);
+	if (vte_info.load_vte)
+	{
+		struct passwd *pw = getpwuid(getuid());
+		gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh";
+
+		vc = g_new0(VteConfig, 1);
+		vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
+		if ((vte_info.dir == NULL || utils_strcmp(vte_info.dir, "")) && pw != NULL)
+			// last dir is not set, fallback to user's home directory
+			vte_info.dir = g_strdup(pw->pw_dir);
+		else if (vte_info.dir == NULL && pw == NULL)
+			// fallback to root
+			vte_info.dir = g_strdup("/");
+
+		vc->emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm");
+		vc->shell = utils_get_setting_string(config, "VTE", "shell", shell);
+		vc->font = utils_get_setting_string(config, "VTE", "font", "Monospace 10");
+		vc->scroll_on_key = utils_get_setting_boolean(config, "VTE", "scroll_on_key", TRUE);
+		vc->scroll_on_out = utils_get_setting_boolean(config, "VTE", "scroll_on_out", TRUE);
+		vc->ignore_menu_bar_accel = utils_get_setting_boolean(config, "VTE", "ignore_menu_bar_accel", FALSE);
+		vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
+		vc->scrollback_lines = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
+		vc->colour_fore = g_new0(GdkColor, 1);
+		vc->colour_back = g_new0(GdkColor, 1);
+		tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff");
+		gdk_color_parse(tmp_string, vc->colour_fore);
+		g_free(tmp_string);
+		tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000");
+		gdk_color_parse(tmp_string, vc->colour_back);
+		g_free(tmp_string);
+	}
 #endif
 	app->pref_template_developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name());
 	app->pref_template_company = utils_get_setting_string(config, PACKAGE, "pref_template_company", "");

Modified: trunk/src/prefs.c
===================================================================
--- trunk/src/prefs.c	2006-08-21 22:28:36 UTC (rev 754)
+++ trunk/src/prefs.c	2006-08-22 19:03:38 UTC (rev 755)
@@ -331,10 +331,10 @@
 		gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), vc->font);
 
 		widget = lookup_widget(app->prefs_dialog, "color_fore");
-		gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), vc->color_fore);
+		gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), vc->colour_fore);
 
 		widget = lookup_widget(app->prefs_dialog, "color_back");
-		gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), vc->color_back);
+		gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), vc->colour_back);
 
 		widget = lookup_widget(app->prefs_dialog, "spin_scrollback");
 		gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), vc->scrollback_lines);
@@ -573,8 +573,6 @@
 		// VTE settings
 		if (vte_info.have_vte)
 		{
-			gchar *hex_color_back, *hex_color_fore;
-
 			widget = lookup_widget(app->prefs_dialog, "spin_scrollback");
 			vc->scrollback_lines = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
 
@@ -591,18 +589,7 @@
 			widget = lookup_widget(app->prefs_dialog, "check_follow_path");
 			vc->follow_path = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 
-			g_free(vte_info.terminal_settings);
-			hex_color_fore = utils_get_hex_from_color(vc->color_fore);
-			hex_color_back = utils_get_hex_from_color(vc->color_back);
-			vte_info.terminal_settings = g_strdup_printf("%s;%s;%s;%d;%s;%s;%s;%s", vc->font,
-					hex_color_fore, hex_color_back,
-					vc->scrollback_lines, vc->emulation,
-					utils_btoa(vc->scroll_on_key), utils_btoa(vc->scroll_on_out),
-					utils_btoa(vc->follow_path));
-
 			vte_apply_user_settings();
-			g_free(hex_color_fore);
-			g_free(hex_color_back);
 		}
 #endif
 
@@ -657,16 +644,16 @@
 #ifdef HAVE_VTE
 		case 2:
 		{
-			g_free(vc->color_fore);
-			vc->color_fore = g_new0(GdkColor, 1);
-			gtk_color_button_get_color(widget, vc->color_fore);
+			g_free(vc->colour_fore);
+			vc->colour_fore = g_new0(GdkColor, 1);
+			gtk_color_button_get_color(widget, vc->colour_fore);
 			break;
 		}
 		case 3:
 		{
-			g_free(vc->color_back);
-			vc->color_back = g_new0(GdkColor, 1);
-			gtk_color_button_get_color(widget, vc->color_back);
+			g_free(vc->colour_back);
+			vc->colour_back = g_new0(GdkColor, 1);
+			gtk_color_button_get_color(widget, vc->colour_back);
 			break;
 		}
 #endif

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-08-21 22:28:36 UTC (rev 754)
+++ trunk/src/utils.c	2006-08-22 19:03:38 UTC (rev 755)
@@ -1944,6 +1944,8 @@
 {
 	gchar *buffer = g_malloc0(9);
 
+	if (color == NULL) return NULL;
+
 	g_snprintf(buffer, 8, "#%02X%02X%02X",
 	      (guint) (utils_scale_round(color->red / 256, 255)),
 	      (guint) (utils_scale_round(color->green / 256, 255)),

Modified: trunk/src/vte.c
===================================================================
--- trunk/src/vte.c	2006-08-21 22:28:36 UTC (rev 754)
+++ trunk/src/vte.c	2006-08-22 19:03:38 UTC (rev 755)
@@ -25,8 +25,6 @@
 #ifdef HAVE_VTE
 
 #include <gdk/gdkkeysyms.h>
-#include <pwd.h>
-#include <unistd.h>
 #include <signal.h>
 #include <string.h>
 
@@ -43,7 +41,7 @@
 extern gchar **environ;
 static pid_t pid;
 static GModule *module = NULL;
-static struct vte_funcs *vf;
+static struct VteFunctions *vf;
 static gboolean popup_menu_created = FALSE;
 
 
@@ -54,7 +52,6 @@
 static gboolean vte_button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer user_data);
 static gboolean vte_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data);
 static void vte_register_symbols(GModule *module);
-static void vte_get_settings(void);
 static void vte_popup_menu_clicked(GtkMenuItem *menuitem, gpointer user_data);
 static GtkWidget *vte_create_popup_menu(void);
 static void vte_char_size_changed(VteTerminal *vteterminal, guint arg1, guint arg2,
@@ -132,8 +129,7 @@
 	else
 	{
 		vte_info.have_vte = TRUE;
-		vf = g_new0(struct vte_funcs, 1);
-		vc = g_new0(struct vte_conf, 1);
+		vf = g_new0(struct VteFunctions, 1);
 		vte_register_symbols(module);
 	}
 
@@ -149,8 +145,6 @@
 	gtk_box_pack_start(GTK_BOX(hbox), vte, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0);
 
-	vte_get_settings();
-
 	vf->vte_terminal_set_size(VTE_TERMINAL(vte), 30, 1);
 	//vf->vte_terminal_set_encoding(VTE_TERMINAL(vte), "UTF-8");
 	vf->vte_terminal_set_mouse_autohide(VTE_TERMINAL(vte), TRUE);
@@ -187,8 +181,8 @@
 	if (popup_menu_created) gtk_widget_destroy(vc->menu);
 	g_free(vc->font);
 	g_free(vc->emulation);
-	g_free(vc->color_back);
-	g_free(vc->color_fore);
+	g_free(vc->colour_back);
+	g_free(vc->colour_fore);
 	g_free(vc);
 	g_module_close(module);
 }
@@ -219,26 +213,11 @@
 static void vte_start(GtkWidget *widget)
 {
 	VteTerminal *vte = VTE_TERMINAL(widget);
-	struct passwd *pw;
-	const gchar *shell;
-	const gchar *dir = NULL;
 	gchar **env;
 
-	pw = getpwuid(getuid());
-	if (pw)
-	{
-		shell = pw->pw_shell;
-		dir = pw->pw_dir;
-	}
-	else
-	{
-		shell = "/bin/sh";
-		dir = "/";
-	}
-
 	env = vte_get_child_environment();
-	pid = vf->vte_terminal_fork_command(VTE_TERMINAL(vte), shell, NULL, env,
-		(vte_info.dir == NULL) ? dir : vte_info.dir, TRUE, TRUE, TRUE);
+	pid = vf->vte_terminal_fork_command(VTE_TERMINAL(vte), vc->shell, NULL, env,
+												vte_info.dir, TRUE, TRUE, TRUE);
 	g_strfreev(env);
 }
 
@@ -307,37 +286,12 @@
 	vf->vte_terminal_set_scroll_on_output(VTE_TERMINAL(vc->vte), vc->scroll_on_out);
 	vf->vte_terminal_set_emulation(VTE_TERMINAL(vc->vte), vc->emulation);
 	vf->vte_terminal_set_font_from_string(VTE_TERMINAL(vc->vte), vc->font);
-	vf->vte_terminal_set_color_foreground(VTE_TERMINAL(vc->vte), vc->color_fore);
-	vf->vte_terminal_set_color_background(VTE_TERMINAL(vc->vte), vc->color_back);
-}
+	vf->vte_terminal_set_color_foreground(VTE_TERMINAL(vc->vte), vc->colour_fore);
+	vf->vte_terminal_set_color_background(VTE_TERMINAL(vc->vte), vc->colour_back);
 
-
-static void vte_get_settings(void)
-{
-	gchar **values = g_strsplit(vte_info.terminal_settings, ";", 8);
-
-	if (g_strv_length(values) != 8)
-	{
-		vte_info.terminal_settings =
-			g_strdup_printf("Monospace 10;#FFFFFF;#000000;500;xterm;true;true;false");
-		values = g_strsplit(vte_info.terminal_settings, ";", 8);
-	}
-	vc->font = g_strdup(values[0]);
-	vc->color_fore = g_new0(GdkColor, 1);
-	vc->color_back = g_new0(GdkColor, 1);
-	gdk_color_parse(values[1], vc->color_fore);
-	gdk_color_parse(values[2], vc->color_back);
-
-	vc->scrollback_lines = strtod(values[3], NULL);
-	if ((vc->scrollback_lines < 0) || (vc->scrollback_lines > 5000)) vc->scrollback_lines = 500;
-
-	vc->emulation = g_strdup(values[4]);
-
-	vc->scroll_on_key = utils_atob(values[5]);
-	vc->scroll_on_out = utils_atob(values[6]);
-	vc->follow_path = utils_atob(values[7]);
-
-	g_strfreev(values);
+	if (vc->ignore_menu_bar_accel)
+			gtk_settings_set_string_property(gtk_settings_get_default(), "gtk-menu-bar-accel",
+				"<Shift><Control><Mod1><Mod2><Mod3><Mod4><Mod5>F10", "Geany");
 }
 
 
@@ -488,4 +442,5 @@
 }
 */
 
+
 #endif

Modified: trunk/src/vte.h
===================================================================
--- trunk/src/vte.h	2006-08-21 22:28:36 UTC (rev 754)
+++ trunk/src/vte.h	2006-08-22 19:03:38 UTC (rev 755)
@@ -31,16 +31,34 @@
 
 
 #ifdef HAVE_VTE
-typedef struct 
+typedef struct
 {
 	gboolean load_vte;
 	gboolean have_vte;
 	gchar	*lib_vte;
-	gchar	*terminal_settings;
 	gchar	*dir;
 } VteInfo;
 
 extern VteInfo vte_info;
+
+
+typedef struct
+{
+	GtkWidget *vte;
+	GtkWidget *menu;
+	GtkWidget *im_submenu;
+	gboolean scroll_on_key;
+	gboolean scroll_on_out;
+	gboolean ignore_menu_bar_accel;
+	gboolean follow_path;
+	gint scrollback_lines;
+	gchar *emulation;
+	gchar *shell;
+	gchar *font;
+	GdkColor *colour_fore;
+	GdkColor *colour_back;
+} VteConfig;
+VteConfig *vc;
 #endif
 
 
@@ -80,26 +98,9 @@
 };
 
 
-struct vte_conf
-{
-	GtkWidget *vte;
-	GtkWidget *menu;
-	GtkWidget *im_submenu;
-	gboolean scroll_on_key;
-	gboolean scroll_on_out;
-	gboolean follow_path;
-	gint scrollback_lines;
-	gchar *emulation;
-	gchar *font;
-	GdkColor *color_fore;
-	GdkColor *color_back;
-};
-struct vte_conf *vc;
-
-
 /* store function pointers in a struct to avoid a strange segfault if they are stored directly
  * if accessed directly, gdb says the segfault arrives at old_tab_width(prefs.c), don't ask me */
-struct vte_funcs
+struct VteFunctions
 {
 	GtkWidget* (*vte_terminal_new) (void);
 	pid_t (*vte_terminal_fork_command) (VteTerminal *terminal, const char *command, char **argv,


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list