aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Durner <durner@gnunet.org>2005-06-20 20:33:26 +0000
committerNils Durner <durner@gnunet.org>2005-06-20 20:33:26 +0000
commitf958572ca76379c49e1c2e7fa75d5c91c2561650 (patch)
tree0a09df5f0b757676c502be718ef69bfe0231f110
parent7cb7ccf6b1b35f959ba1f49bd451ed4714b015ed (diff)
downloadgnunet-gtk-f958572ca76379c49e1c2e7fa75d5c91c2561650.tar.gz
gnunet-gtk-f958572ca76379c49e1c2e7fa75d5c91c2561650.zip
Use native Windows dialog to choose file or directory
-rw-r--r--src/plibc.h47
-rw-r--r--src/upload.c43
2 files changed, 36 insertions, 54 deletions
diff --git a/src/plibc.h b/src/plibc.h
index f91516ba..f06e5c6c 100644
--- a/src/plibc.h
+++ b/src/plibc.h
@@ -22,7 +22,7 @@
22 * @brief PlibC header 22 * @brief PlibC header
23 * @attention This file is usually not installed under Unix, 23 * @attention This file is usually not installed under Unix,
24 * so ship it with your application 24 * so ship it with your application
25 * @version $Revision: 1.17 $ 25 * @version $Revision: 1.19 $
26 */ 26 */
27 27
28#ifndef _PLIBC_H_ 28#ifndef _PLIBC_H_
@@ -68,48 +68,6 @@ extern "C" {
68#define int32_t long 68#define int32_t long
69 69
70/* Thanks to the Cygwin project */ 70/* Thanks to the Cygwin project */
71#define EPERM 1 /* Not super-user */
72#define ENOENT 2 /* No such file or directory */
73#define ESRCH 3 /* No such process */
74#define EINTR 4 /* Interrupted system call */
75#define EIO 5 /* I/O error */
76#define ENXIO 6 /* No such device or address */
77#define E2BIG 7 /* Arg list too long */
78#define ENOEXEC 8 /* Exec format error */
79#define EBADF 9 /* Bad file number */
80#define ECHILD 10 /* No children */
81#define EAGAIN 11 /* Resource unavailable or operation would block, try again */
82#define ENOMEM 12 /* Not enough memory */
83#define EACCES 13 /* Permission denied */
84#define EFAULT 14 /* Bad address */
85#define ENOTBLK 15 /* Block device required */
86#define EBUSY 16 /* Mount device busy */
87#define EEXIST 17 /* File exists */
88#define EXDEV 18 /* Cross-device link */
89#define ENODEV 19 /* No such device */
90#define ENOTDIR 20 /* Not a directory */
91#define EISDIR 21 /* Is a directory */
92#define EINVAL 22 /* Invalid argument */
93#define ENFILE 23 /* Too many open files in system */
94#define EMFILE 24 /* Too many open files */
95#define ENOTTY 25 /* Not a typewriter */
96#define ETXTBSY 26 /* Text file busy */
97#define EFBIG 27 /* File too large */
98#define ENOSPC 28 /* No space left on device */
99#define ESPIPE 29 /* Illegal seek */
100#define EROFS 30 /* Read only file system */
101#define EMLINK 31 /* Too many links */
102#define EPIPE 32 /* Broken pipe */
103#define EDOM 33 /* Math arg out of domain of func */
104#define ERANGE 34 /* Math result not representable */
105#define ENOMSG 35 /* No message of desired type */
106#define EIDRM 36 /* Identifier removed */
107#define ECHRNG 37 /* Channel number out of range */
108#define EL2NSYNC 38 /* Level 2 not synchronized */
109#define L3HLT 39 /* Level 3 halted */
110#define EL3RST 40 /* Level 3 reset */
111#define ELNRNG 41 /* Link number out of range */
112#define EUNATCH 42 /* Protocol driver not attached */
113#define ENOCSI 43 /* No CSI structure available */ 71#define ENOCSI 43 /* No CSI structure available */
114#define EL2HLT 44 /* Level 2 halted */ 72#define EL2HLT 44 /* Level 2 halted */
115#ifndef EDEADLK 73#ifndef EDEADLK
@@ -125,7 +83,7 @@ extern "C" {
125#define EBADRQC 54 /* Invalid request code */ 83#define EBADRQC 54 /* Invalid request code */
126#define EBADSLT 55 /* Invalid slot */ 84#define EBADSLT 55 /* Invalid slot */
127#ifndef EDEADLOCK 85#ifndef EDEADLOCK
128 #define EDEADLOCK 56 /* File locking deadlock error */ 86 #define EDEADLOCK EDEADLK /* File locking deadlock error */
129#endif 87#endif
130#define EBFONT 57 /* Bad font file fmt */ 88#define EBFONT 57 /* Bad font file fmt */
131#define ENOSTR 60 /* Device not a stream */ 89#define ENOSTR 60 /* Device not a stream */
@@ -319,6 +277,7 @@ typedef struct
319 277
320BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest); 278BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
321BOOL _plibc_DereferenceShortcut(char *pszShortcut); 279BOOL _plibc_DereferenceShortcut(char *pszShortcut);
280char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags);
322long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey, 281long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
323 char *pszBuffer, long *pdLength); 282 char *pszBuffer, long *pdLength);
324 283
diff --git a/src/upload.c b/src/upload.c
index 18ac7c73..f14aa502 100644
--- a/src/upload.c
+++ b/src/upload.c
@@ -30,6 +30,12 @@
30#include "main.h" 30#include "main.h"
31#include <extractor.h> 31#include <extractor.h>
32 32
33#ifdef MINGW
34 #ifndef BIF_NONEWFOLDERBUTTON
35 #define BIF_NONEWFOLDERBUTTON 0x200
36 #endif
37#endif
38
33 39
34static GtkTreeStore * summary; 40static GtkTreeStore * summary;
35 41
@@ -663,15 +669,12 @@ void on_fsinsertuploadbutton_clicked(gpointer dummy,
663 metaXML = NULL; 669 metaXML = NULL;
664} 670}
665 671
666void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton, 672char *selectFile() {
667 gpointer dummy) { 673#ifndef MINGW
668 GtkWidget *dialog; 674 GtkWidget *dialog;
669 GladeXML * uploadXML; 675 GladeXML * uploadXML;
670 GtkWidget * uploadLine;
671 GtkWidget * entry;
672 GtkWidget * recBut; 676 GtkWidget * recBut;
673 GtkListStore * model; 677 char *ret;
674 GtkTreeIter iter;
675 678
676 uploadXML 679 uploadXML
677 = glade_xml_new(gladeFile, 680 = glade_xml_new(gladeFile,
@@ -683,7 +686,6 @@ void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
683 686
684 recBut = glade_xml_get_widget(mainXML, 687 recBut = glade_xml_get_widget(mainXML,
685 "scopeRecursiveButton"); 688 "scopeRecursiveButton");
686
687 689
688 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(recBut))) 690 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(recBut)))
689 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog), 691 gtk_file_chooser_set_action(GTK_FILE_CHOOSER(dialog),
@@ -693,6 +695,29 @@ void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
693 char * filename; 695 char * filename;
694 696
695 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); 697 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
698 ret = strdup(filename);
699 g_free(filename);
700 }
701 else
702 ret = NULL;
703
704 gtk_widget_destroy (dialog);
705 UNREF(uploadXML);
706#else /* MINGW */
707 return plibc_ChooseDir(_("Choose the file or directory you want to publish."),
708 BIF_BROWSEINCLUDEFILES | BIF_USENEWUI | BIF_SHAREABLE | BIF_NONEWFOLDERBUTTON);
709#endif /* MINGW */
710}
711
712void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
713 gpointer dummy) {
714 char *filename;
715 GtkWidget * uploadLine;
716 GtkWidget * entry;
717 GtkListStore * model;
718 GtkTreeIter iter;
719
720 if ((filename = selectFile())) {
696 uploadLine = glade_xml_get_widget(mainXML, 721 uploadLine = glade_xml_get_widget(mainXML,
697 "uploadFilenameComboBoxEntry"); 722 "uploadFilenameComboBoxEntry");
698 entry = gtk_bin_get_child(GTK_BIN(uploadLine)); 723 entry = gtk_bin_get_child(GTK_BIN(uploadLine));
@@ -706,10 +731,8 @@ void on_mainFileSharingInsertBrowseButton_clicked(GtkWidget * browseButton,
706 0, 731 0,
707 filename, 732 filename,
708 -1); 733 -1);
709 g_free(filename); 734 free(filename);
710 } 735 }
711 gtk_widget_destroy (dialog);
712 UNREF(uploadXML);
713} 736}
714 737
715 738