[geany/geany] 8da955: Make the currently open project insensitive in the recent menu

Colomban Wendling git-noreply at xxxxx
Sat Nov 29 21:51:00 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 11 Nov 2014 16:46:31 UTC
Commit:      8da955ec949b3d60a68402847703c2a16f617f70
             https://github.com/geany/geany/commit/8da955ec949b3d60a68402847703c2a16f617f70

Log Message:
-----------
Make the currently open project insensitive in the recent menu


Modified Paths:
--------------
    src/project.c
    src/ui_utils.c
    src/ui_utils.h

Modified: src/project.c
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -381,6 +381,7 @@ static void update_ui(void)
 	build_menu_update(NULL);
 	// update project name
 	sidebar_openfiles_update_all();
+	ui_update_recent_project_menu();
 }
 
 


Modified: src/ui_utils.c
29 lines changed, 29 insertions(+), 0 deletions(-)
===================================================================
@@ -1279,6 +1279,29 @@ static gint find_recent_file_item(gconstpointer list_data, gconstpointer user_da
 }
 
 
+/* update the project menu item's sensitivity */
+void ui_update_recent_project_menu(void)
+{
+	GeanyRecentFiles *grf = recent_get_recent_projects();
+	GList *children, *item;
+
+	/* only need to update the menubar menu, the project doesn't have a toolbar item */
+	children = gtk_container_get_children(GTK_CONTAINER(grf->menubar));
+	for (item = children; item; item = item->next)
+	{
+		gboolean sensitive = TRUE;
+
+		if (app->project)
+		{
+			const gchar *filename = gtk_menu_item_get_label(item->data);
+			sensitive = g_strcmp0(app->project->file_name, filename) != 0;
+		}
+		gtk_widget_set_sensitive(item->data, sensitive);
+	}
+	g_list_free(children);
+}
+
+
 static void add_recent_file_menu_item(const gchar *utf8_filename, GeanyRecentFiles *grf, GtkWidget *menu)
 {
 	GtkWidget *child = gtk_menu_item_new_with_label(utf8_filename);
@@ -1327,6 +1350,9 @@ static void recent_file_loaded(const gchar *utf8_filename, GeanyRecentFiles *grf
 			add_recent_file_menu_item(utf8_filename, grf, parents[i]);
 		g_list_free(children);
 	}
+
+	if (grf->type == RECENT_FILE_PROJECT)
+		ui_update_recent_project_menu();
 }
 
 
@@ -1362,6 +1388,9 @@ static void update_recent_menu(GeanyRecentFiles *grf)
 		/* create the new item */
 		add_recent_file_menu_item(filename, grf, parents[i]);
 	}
+
+	if (grf->type == RECENT_FILE_PROJECT)
+		ui_update_recent_project_menu();
 }
 
 


Modified: src/ui_utils.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -321,6 +321,8 @@ void ui_add_recent_document(GeanyDocument *doc);
 
 void ui_add_recent_project_file(const gchar *utf8_filename);
 
+void ui_update_recent_project_menu(void);
+
 
 void ui_update_tab_status(GeanyDocument *doc);
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list