From 03f3e5b060977c9566bd66bc8e4eaac14c4ee781 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 04:56:26 +0000 Subject: [PATCH] Update Update. Patch from Lucas Rocha to implement save and directory 2004-09-13 Glynn Foster * THANKS: Update * src/about.c: Update. * src/fileselection.c, src/main.c, src/zenity.h: Patch from Lucas Rocha to implement save and directory selection in the file selection dialog. Fixes #138342. --- ChangeLog | 9 +++++++++ THANKS | 11 ++++++++++- src/about.c | 11 ++++++++++- src/fileselection.c | 13 ++++++++++++- src/main.c | 34 ++++++++++++++++++++++++++++++++++ src/zenity.h | 2 ++ 6 files changed, 77 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48942d2..3801b06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-09-13 Glynn Foster + + * THANKS: Update + * src/about.c: Update. + * src/fileselection.c, src/main.c, src/zenity.h: + Patch from Lucas Rocha to implement save and + directory selection in the file selection dialog. + Fixes #138342. + 2004-09-13 Glynn Foster * configure.in: Post release bump, for unstable diff --git a/THANKS b/THANKS index 0f347c8..637ebc4 100644 --- a/THANKS +++ b/THANKS @@ -22,6 +22,7 @@ "Tomasz Koczko ", "Jordi Mallach ", "Kjartan Maraas ", + "Breda McColgan ", "Baptiste Mille-Mathias ", "Buhan Milne ", "Christian Monneckes ", @@ -30,6 +31,7 @@ "Jan Arne Petersen ", "Kevin C Krinke ", "Kristian Rietveld ", + "Lucas Rocha ", "Christian Rose ", "Jakub Steiner ", "Luke Suchocki ", @@ -44,6 +46,7 @@ "Taneem Ahmed ", "Takeshi Aihana ", "Amanpreet Singh Alam ", + "Metin Amiroff ", "Sanlig Badral ", "John C Barstow ", "Aygimantas Beruka ", @@ -56,7 +59,8 @@ "Fatih Demir ", "Laurent Dhima ", "Paul Duffy ", - " Laszlo Dvornik ", + "Laszlo Dvornik ", + "Maxim Dziumanenko ", "Francisco Javier Fernandez ", "Artur Flinta ", "Alessio Frusciante ", @@ -64,7 +68,9 @@ "Pablo Gonzalo del Campo ", "Dhurba Gnawali ", "Sammi Gunnarsson ", + "Martin Willemoes Hansen ", "Dafydd Harries ", + "Raphael Higino ", "Wang Jian ", "Guntupalli Karunakar ", "Tomas Kuliavas ", @@ -72,6 +78,7 @@ "Iaki Larraaga ", "Ole Laursen ", "Toivo Leedjrv ", + "David Lodge ", "Duarte Loreto ", "Johanna Makkonen ", "Jordi Mallach ", @@ -88,10 +95,12 @@ "Metin Omirov ", "Gareth Owen ", "Kostas Papadimas ", + "Ankit Patel ", "Sami Pesonen ", "Roozbeh Pournader ", "Jarkko Ranta ", "Rostislav Raykov ", + "Hendrik Richter ", "Christian Rose ", "Changwoo Ryu ", "Pablo Saratxaga ", diff --git a/src/about.c b/src/about.c index d9be6d4..60cb570 100644 --- a/src/about.c +++ b/src/about.c @@ -70,6 +70,7 @@ static const gchar *author_credits[] = { "Tomasz Koczko ", "Jordi Mallach ", "Kjartan Maraas ", + "Breda McColgan ", "Baptiste Mille-Mathias ", "Buhan Milne ", "Christian Monneckes ", @@ -78,6 +79,7 @@ static const gchar *author_credits[] = { "Jan Arne Petersen ", "Kevin C Krinke ", "Kristian Rietveld ", + "Lucas Rocha ", "Christian Rose ", "Jakub Steiner ", "Luke Suchocki ", @@ -92,6 +94,7 @@ static const gchar *author_credits[] = { "Taneem Ahmed ", "Takeshi Aihana ", "Amanpreet Singh Alam ", + "Metin Amiroff ", "Sanlig Badral ", "John C Barstow ", "Aygimantas Beruka ", @@ -104,7 +107,8 @@ static const gchar *author_credits[] = { "Fatih Demir ", "Laurent Dhima ", "Paul Duffy ", - " Laszlo Dvornik ", + "Laszlo Dvornik ", + "Maxim Dziumanenko ", "Francisco Javier Fernandez ", "Artur Flinta ", "Alessio Frusciante ", @@ -112,7 +116,9 @@ static const gchar *author_credits[] = { "Pablo Gonzalo del Campo ", "Dhurba Gnawali ", "Sammi Gunnarsson ", + "Martin Willemoes Hansen ", "Dafydd Harries ", + "Raphael Higino ", "Wang Jian ", "Guntupalli Karunakar ", "Tomas Kuliavas ", @@ -120,6 +126,7 @@ static const gchar *author_credits[] = { "Iaki Larraaga ", "Ole Laursen ", "Toivo Leedjrv ", + "David Lodge ", "Duarte Loreto ", "Johanna Makkonen ", "Jordi Mallach ", @@ -136,10 +143,12 @@ static const gchar *author_credits[] = { "Metin Omirov ", "Gareth Owen ", "Kostas Papadimas ", + "Ankit Patel ", "Sami Pesonen ", "Roozbeh Pournader ", "Jarkko Ranta ", "Rostislav Raykov ", + "Hendrik Richter ", "Christian Rose ", "Changwoo Ryu ", "Pablo Saratxaga ", diff --git a/src/fileselection.c b/src/fileselection.c index 995ba03..fdd40fd 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -34,11 +34,22 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GtkWidget *dialog; gchar *dir; gchar *basename; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; zen_data = data; + if (file_data->directory) { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + else + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + } else { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_SAVE; + } + dialog = gtk_file_chooser_dialog_new (NULL, NULL, - GTK_FILE_CHOOSER_ACTION_OPEN, + action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); diff --git a/src/main.c b/src/main.c index 02a67f3..09b1519 100644 --- a/src/main.c +++ b/src/main.c @@ -94,6 +94,8 @@ enum { OPTION_INFOTEXT, OPTION_FILENAME, OPTION_MULTIFILE, + OPTION_DIR, + OPTION_SAVE, OPTION_TEXTFILENAME, OPTION_LISTTEXT, OPTION_COLUMN, @@ -440,6 +442,24 @@ struct poptOption file_selection_options[] = { N_("Allow multiple files to be selected"), NULL }, + { + "directory", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_DIR, + N_("Activate directory-only selection"), + NULL + }, + { + "save", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_SAVE, + N_("Activate save mode"), + NULL + }, { "separator", '\0', @@ -971,6 +991,8 @@ zenity_init_parsing_options (void) { results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; results->file_data->multi = FALSE; + results->file_data->directory = FALSE; + results->file_data->save = FALSE; results->file_data->separator = g_strdup ("|"); results->text_data->editable = FALSE; results->tree_data->separator = g_strdup ("|"); @@ -1409,6 +1431,18 @@ zenity_parse_options_callback (poptContext ctx, results->file_data->multi = TRUE; break; + case OPTION_DIR: + if (results->mode != MODE_FILE) + zenity_error ("--directory", ERROR_SUPPORT); + + results->file_data->directory = TRUE; + break; + case OPTION_SAVE: + if (results->mode != MODE_FILE) + zenity_error ("--save", ERROR_SUPPORT); + + results->file_data->save = TRUE; + break; case OPTION_COLUMN: if (results->mode != MODE_LIST) zenity_error ("--column", ERROR_SUPPORT); diff --git a/src/zenity.h b/src/zenity.h index 36cf52e..d9aff43 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -62,6 +62,8 @@ typedef struct { typedef struct { gchar *uri; gboolean multi; + gboolean directory; + gboolean save; gchar *separator; } ZenityFileData;