patch for project-tool.c -- hopefully working this time



Last patch missed real functionality :) Hope this is the right one,
sorry. This shows the recent projects in the 'project' combobutton and
switches to selected project.

-- 
axel c <axel banzais org>
Index: project-tool.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/project-manager/project-tool.c,v
retrieving revision 1.50
diff -u -p -r1.50 project-tool.c
--- project-tool.c	14 Sep 2003 17:32:42 -0000	1.50
+++ project-tool.c	18 Sep 2003 11:50:49 -0000
@@ -439,6 +439,7 @@ recent_project_cb (GdlRecent  *recent,
 		   const char *uri,
 		   gpointer    data)
 {
+	
 	ProjectTool *proj_tool = (ProjectTool *)data;
 
 	set_build (proj_tool, uri);
@@ -1102,6 +1103,46 @@ session_save_cb (ScaffoldShell *shell,
 }
 
 static void
+proj_recent_item_selected (GtkWidget *menuitem, ProjectTool *proj_tool)
+{
+	gchar	*fullpath;
+
+	g_return_if_fail (menuitem != NULL);
+	g_return_if_fail (proj_tool != NULL);
+
+	fullpath = g_object_get_data (G_OBJECT (menuitem), "full_path");
+
+	if (fullpath)
+		set_build (proj_tool, fullpath);
+}
+
+static void
+proj_recent_helper (gchar *element, ProjectTool *proj_tool)
+{
+	GtkMenuShell	*menu;
+	GtkWidget		*item;
+	const gchar		*element_base;
+
+	g_return_if_fail (element != NULL);
+	g_return_if_fail (proj_tool != NULL);
+	g_return_if_fail (GTK_IS_MENU (proj_tool->project_menu));
+
+	menu = GTK_MENU_SHELL (proj_tool->project_menu);
+
+	element_base = g_path_get_basename (element);
+
+	if (element_base)
+	{
+		item = gtk_menu_item_new_with_label (element_base);
+		g_object_set_data_full (G_OBJECT (item), "full_path", g_strdup (element), (GDestroyNotify)g_free);
+		g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (proj_recent_item_selected), proj_tool);
+		gtk_widget_show (item);
+		gtk_menu_shell_append (menu, item);
+	}
+
+}
+	
+static void
 shell_set (ScaffoldTool *tool)
 {
 	ProjectTool *proj_tool;
@@ -1110,6 +1151,8 @@ shell_set (ScaffoldTool *tool)
 	GdkPixbuf *icon;
 	BonoboControl *control;
 
+	GSList		*proj_recent_list = NULL;
+
 	g_return_if_fail (tool != NULL);
 	g_return_if_fail (SCAFFOLD_IS_TOOL (tool));
 
@@ -1136,8 +1179,8 @@ shell_set (ScaffoldTool *tool)
 	proj_tool->project_menu = gtk_menu_new ();
 	gdl_combo_button_set_label (GDL_COMBO_BUTTON (proj_tool->project_combo),
 				    _("Project"));
-	gdl_combo_button_set_menu (GDL_COMBO_BUTTON (proj_tool->project_combo),
-				   GTK_MENU (proj_tool->project_menu));
+	//gdl_combo_button_set_menu (GDL_COMBO_BUTTON (proj_tool->project_combo),
+	//			   GTK_MENU (proj_tool->project_menu));
 	icon = gdk_pixbuf_new_from_file (SCAFFOLD_IMAGES "/scaffold-open-project.png", NULL);
 	gdl_combo_button_set_icon (GDL_COMBO_BUTTON (proj_tool->project_combo), icon);
 	gdk_pixbuf_unref (icon);
@@ -1207,6 +1250,15 @@ shell_set (ScaffoldTool *tool)
 	gdl_recent_set_ui_component (recent, tool->uic);
 
 	proj_tool->recent = recent;
+
+	proj_recent_list = gdl_recent_get_list (recent);
+	if (proj_recent_list)
+	{
+		g_slist_foreach (proj_recent_list, (GFunc)proj_recent_helper, proj_tool);		
+		gdl_combo_button_set_menu (GDL_COMBO_BUTTON (proj_tool->project_combo),
+                   GTK_MENU (proj_tool->project_menu));
+		g_slist_free (proj_recent_list);
+	}
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]