SF.net SVN: geany: [1582] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Mon May 28 15:24:21 UTC 2007


Revision: 1582
          http://svn.sourceforge.net/geany/?rev=1582&view=rev
Author:   ntrel
Date:     2007-05-28 08:24:21 -0700 (Mon, 28 May 2007)

Log Message:
-----------
Show current project name in window title.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/project.c
    trunk/src/ui_utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-05-26 15:35:22 UTC (rev 1581)
+++ trunk/ChangeLog	2007-05-28 15:24:21 UTC (rev 1582)
@@ -1,3 +1,9 @@
+2007-05-28  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/project.c, src/document.c, src/ui_utils.c:
+   Show current project name in window title.
+
+
 2007-05-26  Nick Treleaven  <nick.treleaven at btinternet.com>
 
  * src/treeviews.c, src/filetypes.c, src/filetypes.h, src/document.c:
@@ -2,2 +8,4 @@
    Replace filetype::has_tags member with filetype_has_tags().
+ * HACKING:
+   Add note about Adding a TagManager parser.
 

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2007-05-26 15:35:22 UTC (rev 1581)
+++ trunk/src/document.c	2007-05-28 15:24:21 UTC (rev 1582)
@@ -148,12 +148,16 @@
 gint document_get_cur_idx()
 {
 	gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(app->notebook));
-	ScintillaObject *sci = (ScintillaObject*)gtk_notebook_get_nth_page(GTK_NOTEBOOK(app->notebook), cur_page);
 
 	if (cur_page == -1)
 		return -1;
 	else
+	{
+		ScintillaObject *sci = (ScintillaObject*)
+			gtk_notebook_get_nth_page(GTK_NOTEBOOK(app->notebook), cur_page);
+
 		return document_find_by_sci(sci);
+	}
 }
 
 

Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c	2007-05-26 15:35:22 UTC (rev 1581)
+++ trunk/src/project.c	2007-05-28 15:24:21 UTC (rev 1582)
@@ -277,6 +277,14 @@
 }
 
 
+// Called when opening, closing and updating projects.
+static void update_ui()
+{
+	ui_set_window_title(-1);
+	build_menu_update(-1);
+}
+
+
 void project_close()
 {
 	g_return_if_fail(app->project != NULL);
@@ -295,7 +303,7 @@
 	g_free(app->project);
 	app->project = NULL;
 
-	build_menu_update(-1);
+	update_ui();
 }
 
 
@@ -474,7 +482,7 @@
 		if (! update_config(e))
 			goto retry;
 		// successfully updated properties
-		build_menu_update(-1);
+		update_ui();
 	}
 
 	gtk_widget_destroy(e->dialog);
@@ -807,7 +815,7 @@
 
 	g_key_file_free(config);
 
-	build_menu_update(-1);
+	update_ui();
 	return TRUE;
 }
 

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2007-05-26 15:35:22 UTC (rev 1581)
+++ trunk/src/ui_utils.c	2007-05-28 15:24:21 UTC (rev 1582)
@@ -40,6 +40,7 @@
 #include "images.c"
 #include "treeviews.h"
 #include "win32.h"
+#include "project.h"
 
 
 static gchar *menu_item_get_text(GtkMenuItem *menu_item);
@@ -149,32 +150,42 @@
 /* This sets the window title according to the current filename. */
 void ui_set_window_title(gint idx)
 {
-	gchar *title;
+	GString *str;
+	GeanyProject *project = app->project;
 
+	if (idx < 0)
+		idx = document_get_cur_idx();
+
+	str = g_string_new(NULL);
+
 	if (idx >= 0)
 	{
+		g_string_append(str, doc_list[idx].changed ? "*" : "");
+
 		if (doc_list[idx].file_name == NULL)
-		{
-			title = g_strdup_printf("%s%s - Geany",
-					doc_list[idx].changed ? "*" : "",
-					DOC_FILENAME(idx));
-		}
+			g_string_append(str, DOC_FILENAME(idx));
 		else
 		{
 			gchar *basename = g_path_get_basename(DOC_FILENAME(idx));
 			gchar *dirname = g_path_get_dirname(DOC_FILENAME(idx));
 
-			title = g_strdup_printf("%s%s - %s - Geany",
-					doc_list[idx].changed ? "*" : "",
-					basename, dirname ? dirname : "");
+			g_string_append(str, basename);
+			g_string_append(str, " - ");
+			g_string_append(str, dirname ? dirname : "");
 			g_free(basename);
 			g_free(dirname);
 		}
-		gtk_window_set_title(GTK_WINDOW(app->window), title);
-		g_free(title);
+		g_string_append(str, " - ");
 	}
-	else
-		gtk_window_set_title(GTK_WINDOW(app->window), "Geany");
+	if (project)
+	{
+		g_string_append_c(str, '[');
+		g_string_append(str, project->name);
+		g_string_append(str, "] - ");
+	}
+	g_string_append(str, "Geany");
+	gtk_window_set_title(GTK_WINDOW(app->window), str->str);
+	g_string_free(str, TRUE);
 }
 
 


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