[gnome-network]PATCH: Add "Open Documents Folder" to PWS



Hi,
I've been using the Personal Web Server quite a bit lately.  It's been
really useful for doing simple file sharing to other machines.  Attached
is a patch against CVS that adds a menu item to the notification area
icon, "Open Documents Folder", that will open a new Nautilus window, at
the location that the current document_root is set to.  I've found this
really handy, it makes the PWS even more useful.

Thanks,
Mason Kidd

Index: pws.c
===================================================================
RCS file: /cvs/gnome/gnome-network/pws/pws.c,v
retrieving revision 1.4
diff -u -r1.4 pws.c
--- pws.c	24 Oct 2003 09:17:53 -0000	1.4
+++ pws.c	3 Nov 2003 22:22:22 -0000
@@ -49,6 +49,9 @@
 static void     popup_preferences_cb   (gpointer        callback_data,
 					guint           action,
 					GtkWidget      *widget);
+static void	popup_browse_files_cb  (gpointer	callback_data,
+					guint		action,
+					GtkWidget      *widget);
 static void     popup_exit_cb          (gpointer        callback_data,
 					guint           action,
 					GtkWidget      *widget);
@@ -78,6 +81,7 @@
 
 static GtkItemFactoryEntry popup_items[] = {
 	{ N_("/_Preferences"),  NULL, GIF_CB (popup_preferences_cb), 0, "<StockItem>",  GTK_STOCK_PREFERENCES },
+	{ N_("/_Open Documents Folder"), NULL, GIF_CB (popup_browse_files_cb), 0, "<StockItem>", GTK_STOCK_OPEN }, 
 	{ "/sep1",              NULL, 0,                             0, "<Separator>",  NULL },
 	{ N_("/_Quit"),         NULL, GIF_CB (popup_exit_cb),        0, "<StockItem>",  GTK_STOCK_QUIT }
 };
@@ -212,6 +216,24 @@
 	gtk_widget_show (window);
 }
 
+/* callback to open a nautilus window to the current directory */
+static void
+popup_browse_files_cb (gpointer callback_data, guint action, GtkWidget *widget)
+{
+	GNetworkHttpServerConfig *config;
+	gchar *command_line;
+	GError *error = NULL;
+
+	config = get_config_from_gconf ();
+	command_line = g_strdup_printf ("nautilus %s", config->document_root);
+	g_spawn_command_line_async (command_line, &error);
+
+	if (error != NULL)
+		g_print ("Error opening document root\n");
+
+	g_clear_error (&error);
+}
+
 static void
 popup_exit_cb (gpointer callback_data, guint action, GtkWidget *widget)
 {


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