From 6249035608dab35dae1331e8b8a7471461106250 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 12 Mar 2005 21:08:59 +0000 Subject: [PATCH] r3839: Add 'Customise Menu...' to New submenu (suggested by Jesse Wagner). --- ROX-Filer/Help/Changes | 5 +++-- ROX-Filer/src/menu.c | 57 +++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 9d5c826a..f441b59a 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -6,10 +6,11 @@ ~~~~~~~~~~~ When building the SendTo menu, allow nested subdirectories more than one level deep (Jonatan Liljedahl). +Add 'Customise Menu...' to New submenu (suggested by Jesse Wagner). Can specify panel item arguments and short cut when adding via SOAP call (m0n5t3r). -Also for pinboard items (and fixed bugs related to -pinboard_add_with_args) (Stephen Watson). +Also for pinboard items (and fixed bugs related to pinboard_add_with_args) +(Stephen Watson). 28-Feb-2005 ~~~~~~~~~~~ diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 38150f34..e4818bb9 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -142,6 +142,7 @@ static void clear_selection(gpointer data, guint action, GtkWidget *widget); static void invert_selection(gpointer data, guint action, GtkWidget *widget); static void new_directory(gpointer data, guint action, GtkWidget *widget); static void new_file(gpointer data, guint action, GtkWidget *widget); +static void customise_new(gpointer data); static void xterm_here(gpointer data, guint action, GtkWidget *widget); static void open_parent_same(gpointer data, guint action, GtkWidget *widget); @@ -230,6 +231,7 @@ static GtkItemFactoryEntry filer_menu_def[] = { {N_("New"), NULL, NULL, 0, ""}, {">" N_("Directory"), NULL, new_directory, 0, NULL}, {">" N_("Blank file"), NULL, new_file, 0, "", GTK_STOCK_NEW}, +{">" N_("Customise Menu..."), NULL, customise_new, 0, NULL}, {N_("Window"), NULL, NULL, 0, ""}, {">" N_("Parent, New Window"), NULL, open_parent, 0, "", GTK_STOCK_GO_UP}, {">" N_("Parent, Same Window"), NULL, open_parent_same, 0, NULL}, @@ -485,18 +487,19 @@ static GList *menu_from_dir(GtkWidget *menu, const gchar *dir_name, if (!names) goto out; - if (separator) - { - item = gtk_menu_item_new(); - widgets = g_list_append(widgets, item); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - } - for (i = 0; i < names->len; i++) { char *leaf = names->pdata[i]; gchar *fname; + if (separator) + { + item = gtk_menu_item_new(); + widgets = g_list_append(widgets, item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + separator = FALSE; + } + fname = g_strconcat(dname, "/", leaf, NULL); /* Strip off extension, if any */ @@ -1500,6 +1503,46 @@ static void customise_send_to(gpointer data) filer_opendir(save, NULL, NULL); } +static void customise_new(gpointer data) +{ + GPtrArray *path; + guchar *save; + GString *dirs; + int i; + + dirs = g_string_new(NULL); + + path = choices_list_dirs(""); + for (i = 0; i < path->len; i++) + { + guchar *old = (guchar *) path->pdata[i]; + + g_string_append(dirs, old); + g_string_append(dirs, "Templates\n"); + } + choices_free_list(path); + + save = choices_find_path_save("", "Templates", TRUE); + if (save) + mkdir(save, 0777); + + info_message( + _("Any files placed in your Templates directories will " + "appear on the `New' menu. Choosing one of them will make " + "a copy of it as the new file.\n\n" + "The following directories contain templates:\n\n%s\n%s\n"), + dirs->str, + save ? _("I'll show you your Templates directory now; you " + "should place any template files you want inside it.") + : _("Your CHOICESPATH variable setting prevents " + "customisations - sorry.")); + + g_string_free(dirs, TRUE); + + if (save) + filer_opendir(save, NULL, NULL); +} + /* Add everything in the directory /SendTo/[.type[_subtype]] * to the menu. */ -- 2.11.4.GIT