SF.net SVN: geany: [2541] branches/custom-filetypes

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Apr 29 11:30:19 UTC 2008


Revision: 2541
          http://geany.svn.sourceforge.net/geany/?rev=2541&view=rev
Author:   ntrel
Date:     2008-04-29 04:30:19 -0700 (Tue, 29 Apr 2008)

Log Message:
-----------
Refactor open_session_file() from configuration_open_files().

Modified Paths:
--------------
    branches/custom-filetypes/ChangeLog
    branches/custom-filetypes/src/keyfile.c
    branches/custom-filetypes/src/keyfile.h
    branches/custom-filetypes/src/main.c

Modified: branches/custom-filetypes/ChangeLog
===================================================================
--- branches/custom-filetypes/ChangeLog	2008-04-28 16:52:20 UTC (rev 2540)
+++ branches/custom-filetypes/ChangeLog	2008-04-29 11:30:19 UTC (rev 2541)
@@ -1,3 +1,9 @@
+2008-04-29  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/keyfile.c, src/keyfile.h, src/main.c:
+   Refactor open_session_file() from configuration_open_files().
+
+
 2008-04-28  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/plugindata.h, src/filetypes.c, src/filetypes.h, src/plugins.c,

Modified: branches/custom-filetypes/src/keyfile.c
===================================================================
--- branches/custom-filetypes/src/keyfile.c	2008-04-28 16:52:20 UTC (rev 2540)
+++ branches/custom-filetypes/src/keyfile.c	2008-04-29 11:30:19 UTC (rev 2541)
@@ -801,14 +801,57 @@
 }
 
 
+static gboolean open_session_file(gchar **tmp)
+{
+	guint pos;
+	gchar *locale_filename;
+	gint ft_uid, enc_idx;
+	gboolean ro, use_tabs, auto_indent, line_wrapping;
+	gboolean ret = FALSE;
+
+	pos = atoi(tmp[0]);
+	ft_uid = atoi(tmp[1]);
+	ro = atoi(tmp[2]);
+	enc_idx = atoi(tmp[3]);
+	use_tabs = atoi(tmp[4]);
+	auto_indent = atoi(tmp[5]);
+	line_wrapping = atoi(tmp[6]);
+	/* try to get the locale equivalent for the filename */
+	locale_filename = utils_get_locale_from_utf8(tmp[7]);
+
+	if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+	{
+		filetype *ft = filetypes_get_from_uid(ft_uid);
+		gint new_idx = document_open_file_full(
+			-1, locale_filename, pos, ro, ft,
+			(enc_idx >= 0 && enc_idx < GEANY_ENCODINGS_MAX) ?
+				encodings[enc_idx].charset : NULL);
+
+		if (DOC_IDX_VALID(new_idx))
+		{
+			document_set_use_tabs(new_idx, use_tabs);
+			document_set_line_wrapping(new_idx, line_wrapping);
+			doc_list[new_idx].auto_indent = auto_indent;
+			ret = TRUE;
+		}
+	}
+	else
+	{
+		geany_debug("Could not find file '%s'.", tmp[7]);
+	}
+
+	g_free(locale_filename);
+	return ret;
+}
+
+
 /* Open session files
  * Note: notebook page switch handler and adding to recent files list is always disabled
  * for all files opened within this function */
-gboolean configuration_open_files(void)
+void configuration_open_files(void)
 {
 	gint i;
-	guint pos;
-	gboolean ret = FALSE, failure = FALSE;
+	gboolean failure = FALSE;
 
 	/* necessary to set it to TRUE for project session support */
 	main_status.opening_session_files = TRUE;
@@ -822,43 +865,8 @@
 
 		if (tmp != NULL && g_strv_length(tmp) == 8)
 		{
-			gchar *locale_filename;
-			gint ft_uid, enc_idx;
-			gboolean ro, use_tabs, auto_indent, line_wrapping;
-
-			pos = atoi(tmp[0]);
-			ft_uid = atoi(tmp[1]);
-			ro = atoi(tmp[2]);
-			enc_idx = atoi(tmp[3]);
-			use_tabs = atoi(tmp[4]);
-			auto_indent = atoi(tmp[5]);
-			line_wrapping = atoi(tmp[6]);
-			/* try to get the locale equivalent for the filename */
-			locale_filename = utils_get_locale_from_utf8(tmp[7]);
-
-			if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
-			{
-				filetype *ft = filetypes_get_from_uid(ft_uid);
-				gint new_idx = document_open_file_full(
-					-1, locale_filename, pos, ro, ft,
-					(enc_idx >= 0 && enc_idx < GEANY_ENCODINGS_MAX) ?
-						encodings[enc_idx].charset : NULL);
-
-				if (DOC_IDX_VALID(new_idx))
-				{
-					document_set_use_tabs(new_idx, use_tabs);
-					document_set_line_wrapping(new_idx, line_wrapping);
-					doc_list[new_idx].auto_indent = auto_indent;
-					ret = TRUE;
-				}
-			}
-			else
-			{
+			if (! open_session_file(tmp))
 				failure = TRUE;
-				geany_debug("Could not find file '%s'.", tmp[7]);
-			}
-
-			g_free(locale_filename);
 		}
 		g_strfreev(tmp);
 
@@ -882,7 +890,7 @@
 		ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
 	else if (session_notebook_page >= 0)
 	{
-		/* exlicitly allow notebook switch page callback to be called for window title,
+		/* explicitly allow notebook switch page callback to be called for window title,
 		 * encoding settings and so other things */
 		main_status.opening_session_files = FALSE;
 		/** TODO if session_notebook_page is equal to the current notebook tab(the last opened)
@@ -890,7 +898,6 @@
 		gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), session_notebook_page);
 	}
 	main_status.opening_session_files = FALSE;
-	return ret;
 }
 
 

Modified: branches/custom-filetypes/src/keyfile.h
===================================================================
--- branches/custom-filetypes/src/keyfile.h	2008-04-28 16:52:20 UTC (rev 2540)
+++ branches/custom-filetypes/src/keyfile.h	2008-04-29 11:30:19 UTC (rev 2541)
@@ -30,7 +30,7 @@
 
 gboolean configuration_load(void);
 
-gboolean configuration_open_files(void);
+void configuration_open_files(void);
 
 void configuration_reload_default_session(void);
 

Modified: branches/custom-filetypes/src/main.c
===================================================================
--- branches/custom-filetypes/src/main.c	2008-04-28 16:52:20 UTC (rev 2540)
+++ branches/custom-filetypes/src/main.c	2008-04-29 11:30:19 UTC (rev 2541)
@@ -870,7 +870,9 @@
 			load_project_file();
 
 			/* load session files into tabs, as they are found in the session_files variable */
-			if (! configuration_open_files())
+			configuration_open_files();
+
+			if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0)
 			{
 				ui_update_popup_copy_items(-1);
 				ui_update_popup_reundo_items(-1);


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