diff --git a/ChangeLog b/ChangeLog index 525d1fd4..bb8c23af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,15 @@ +2007-05-28 Nick Treleaven + + * src/project.c, src/document.c, src/ui_utils.c: + Show current project name in window title. + + 2007-05-26 Nick Treleaven * src/treeviews.c, src/filetypes.c, src/filetypes.h, src/document.c: Replace filetype::has_tags member with filetype_has_tags(). + * HACKING: + Add note about Adding a TagManager parser. 2007-05-26 Enrico Tröger diff --git a/src/document.c b/src/document.c index a2ed797a..ba765c65 100644 --- a/src/document.c +++ b/src/document.c @@ -148,12 +148,16 @@ gint document_get_n_idx(guint page_num) 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); + } } diff --git a/src/project.c b/src/project.c index 776b5345..c072449f 100644 --- a/src/project.c +++ b/src/project.c @@ -277,6 +277,14 @@ void project_open() } +// 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 @@ void project_close() g_free(app->project); app->project = NULL; - build_menu_update(-1); + update_ui(); } @@ -474,7 +482,7 @@ void project_properties() if (! update_config(e)) goto retry; // successfully updated properties - build_menu_update(-1); + update_ui(); } gtk_widget_destroy(e->dialog); @@ -807,7 +815,7 @@ static gboolean load_config(const gchar *filename) g_key_file_free(config); - build_menu_update(-1); + update_ui(); return TRUE; } diff --git a/src/ui_utils.c b/src/ui_utils.c index 26b367a0..5c334ea1 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -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 @@ void ui_update_statusbar(gint idx, gint pos) /* 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); }