… | |
… | |
26 | |
26 | |
27 | ///////////////////////////////////////////////////////////////////////////// |
27 | ///////////////////////////////////////////////////////////////////////////// |
28 | |
28 | |
29 | gchar *gtk_file_chooser_get_filename (GtkFileChooser *chooser) |
29 | gchar *gtk_file_chooser_get_filename (GtkFileChooser *chooser) |
30 | { |
30 | { |
31 | DEBUG ((printf ("gtk_file_chooser_get_filename %s\n", last_path))) |
31 | DEBUG ((printf ("gtk_file_chooser_get_filename<%s>\n", last_path))) |
32 | return g_strdup (last_path ? last_path : "/nonex1st4nt"); |
32 | return g_strdup (last_path ? last_path : "/nonex1st4nt"); |
33 | } |
33 | } |
34 | |
34 | |
35 | gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, const char *filename) |
35 | gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, const char *filename) |
36 | { |
36 | { |
… | |
… | |
118 | } |
118 | } |
119 | |
119 | |
120 | gchar *gtk_file_chooser_get_uri (GtkFileChooser *chooser) |
120 | gchar *gtk_file_chooser_get_uri (GtkFileChooser *chooser) |
121 | { |
121 | { |
122 | gchar *uri = to_uri(gtk_file_chooser_get_filename (chooser)); |
122 | gchar *uri = to_uri(gtk_file_chooser_get_filename (chooser)); |
123 | DEBUG ((printf ("gtk_file_chooser_get_uri %s\n", uri))); |
123 | DEBUG ((printf ("gtk_file_chooser_get_uri<%s>\n", uri))); |
124 | return uri; |
124 | return uri; |
125 | } |
125 | } |
126 | |
126 | |
127 | gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri) |
127 | gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri) |
128 | { |
128 | { |
… | |
… | |
144 | return to_uri (gtk_file_chooser_get_current_folder (chooser)); |
144 | return to_uri (gtk_file_chooser_get_current_folder (chooser)); |
145 | } |
145 | } |
146 | |
146 | |
147 | ///////////////////////////////////////////////////////////////////////////// |
147 | ///////////////////////////////////////////////////////////////////////////// |
148 | |
148 | |
149 | static gboolean activate_cb (gpointer data) |
|
|
150 | { |
|
|
151 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_widget_get_toplevel (data)), 1); |
|
|
152 | gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (data), FALSE); |
|
|
153 | //fprintf (stderr, "ad %d\n", gtk_window_activate_default (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))))); |
|
|
154 | g_signal_emit_by_name (GTK_FILE_CHOOSER (data), "file-activated"); |
|
|
155 | return FALSE; |
|
|
156 | } |
|
|
157 | |
|
|
158 | static gboolean unmap_cb (gpointer data) |
149 | static gboolean disable_cb (gpointer data) |
159 | { |
150 | { |
160 | // set the path again to avoid a race condition |
151 | // set the path again to avoid a race condition |
161 | ((void (*)(void *, const char *)) dlsym (RTLD_NEXT, "gtk_file_chooser_set_filename"))(GTK_FILE_CHOOSER (data), "/tmp/gtkbfc/empty"); |
152 | ((void (*)(void *, const char *)) dlsym (RTLD_NEXT, "gtk_file_chooser_set_filename"))(GTK_FILE_CHOOSER (data), "/tmp/gtkbfc/empty"); |
162 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_widget_get_toplevel (data)), 0); |
153 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_widget_get_toplevel (data)), 0); |
163 | //gtk_widget_unmap (GTK_WIDGET (gtk_widget_get_toplevel (data))); |
154 | //gtk_widget_unmap (GTK_WIDGET (gtk_widget_get_toplevel (data))); |
… | |
… | |
172 | last_path = 0; |
163 | last_path = 0; |
173 | } |
164 | } |
174 | |
165 | |
175 | g_io_channel_read_to_end (source, &last_path, 0, 0); |
166 | g_io_channel_read_to_end (source, &last_path, 0, 0); |
176 | g_io_channel_unref (source); |
167 | g_io_channel_unref (source); |
177 | activate_cb (data); |
|
|
178 | |
168 | |
|
|
169 | gtk_widget_set_sensitive (GTK_WIDGET (gtk_widget_get_toplevel (data)), 1); |
|
|
170 | |
|
|
171 | if (!last_path || *last_path != '/') |
|
|
172 | { |
|
|
173 | DEBUG ((printf ("read_result cancel\n"))) |
|
|
174 | g_free (last_path); |
|
|
175 | last_path = 0; |
|
|
176 | } |
|
|
177 | else |
|
|
178 | { |
179 | DEBUG ((printf ("read_result<%s>\n", last_path))); |
179 | DEBUG ((printf ("read_result<%s>\n", last_path))) |
|
|
180 | gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (data), FALSE); |
|
|
181 | g_signal_emit_by_name (GTK_FILE_CHOOSER (data), "file-activated"); |
|
|
182 | } |
180 | |
183 | |
181 | return FALSE; |
184 | return FALSE; |
182 | } |
185 | } |
183 | |
186 | |
184 | static gboolean show_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) |
187 | static gboolean show_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) |
… | |
… | |
212 | gint stdout_fd = -1; |
215 | gint stdout_fd = -1; |
213 | |
216 | |
214 | if (g_spawn_async_with_pipes (0, argv, 0, 0, 0, 0, 0, 0, &stdout_fd, 0, 0)) |
217 | if (g_spawn_async_with_pipes (0, argv, 0, 0, 0, 0, 0, 0, &stdout_fd, 0, 0)) |
215 | { |
218 | { |
216 | GIOChannel *channel = g_io_channel_unix_new (stdout_fd); |
219 | GIOChannel *channel = g_io_channel_unix_new (stdout_fd); |
217 | //gtk_widget_hide (GTK_WIDGET (gtk_widget_get_toplevel (widget))); |
|
|
218 | g_io_add_watch (channel, G_IO_IN, read_result, widget); |
220 | g_io_add_watch (channel, G_IO_IN | G_IO_ERR | G_IO_HUP, read_result, widget); |
219 | g_idle_add (unmap_cb, widget); |
221 | g_idle_add (disable_cb, widget); |
220 | //g_timeout_add (1, unmap_cb, widget); |
|
|
221 | } |
222 | } |
222 | else |
223 | else |
223 | ;//gtk_widget_show (widget); |
224 | ;//gtk_widget_show (widget); |
224 | } |
225 | } |
225 | |
226 | |