… | |
… | |
10 | #include <unistd.h> |
10 | #include <unistd.h> |
11 | #include <sys/types.h> |
11 | #include <sys/types.h> |
12 | #include <sys/stat.h> |
12 | #include <sys/stat.h> |
13 | #include <fcntl.h> |
13 | #include <fcntl.h> |
14 | |
14 | |
15 | static const char version[] = "gtkbfc version 0.0"; |
15 | static const char gtkbfc_version_string[] = "gtkbfc version 0.0"; |
16 | |
16 | |
17 | static char *helper = "/etc/gtkbfc-helper"; |
17 | static char *helper = "/etc/gtkbfc-helper"; |
18 | |
18 | |
19 | static GObject *(*old_constructor) (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties); |
19 | static GObject *(*old_constructor) (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties); |
20 | |
20 | |
… | |
… | |
75 | static const gchar * |
75 | static const gchar * |
76 | from_uri (const gchar *uri) |
76 | from_uri (const gchar *uri) |
77 | { |
77 | { |
78 | const gchar *rv = uri; |
78 | const gchar *rv = uri; |
79 | |
79 | |
80 | if (uri && uri == strstr (uri, "file:///")) |
80 | if (!strncmp (uri, "file:///", sizeof ("file:///") - 1)) |
81 | rv = uri + 7; |
81 | rv += sizeof ("file:///") - 1; |
82 | |
82 | |
83 | return rv; |
83 | return rv; |
84 | } |
84 | } |
85 | |
85 | |
86 | static gchar * |
86 | static gchar * |
… | |
… | |
89 | gchar *rv = NULL; |
89 | gchar *rv = NULL; |
90 | |
90 | |
91 | if (file) |
91 | if (file) |
92 | { |
92 | { |
93 | GString *str = g_string_new ("file://"); |
93 | GString *str = g_string_new ("file://"); |
94 | |
|
|
95 | str = g_string_append (str, file); |
94 | str = g_string_append (str, file); |
96 | rv = g_strdup (str->str); |
95 | rv = g_strdup (str->str); |
97 | g_string_free (str, TRUE); |
96 | g_string_free (str, TRUE); |
98 | g_free (file); |
97 | g_free (file); |
99 | } |
98 | } |
… | |
… | |
120 | } |
119 | } |
121 | |
120 | |
122 | gchar *gtk_file_chooser_get_uri (GtkFileChooser *chooser) |
121 | gchar *gtk_file_chooser_get_uri (GtkFileChooser *chooser) |
123 | { |
122 | { |
124 | gchar *uri = to_uri(gtk_file_chooser_get_filename (chooser)); |
123 | gchar *uri = to_uri(gtk_file_chooser_get_filename (chooser)); |
125 | DEBUG ((printf ("gtk_file_chooser_get_uri<%s>\n", uri))); |
124 | DEBUG ((printf ("gtk_file_chooser_get_uri<%s>\n", uri))) |
126 | return uri; |
125 | return uri; |
127 | } |
126 | } |
128 | |
127 | |
129 | gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri) |
128 | gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri) |
130 | { |
129 | { |
… | |
… | |
154 | |
153 | |
155 | GtkWidget *toplevel = gtk_widget_get_toplevel (data); |
154 | GtkWidget *toplevel = gtk_widget_get_toplevel (data); |
156 | if (toplevel) gtk_widget_set_sensitive (toplevel, 0); |
155 | if (toplevel) gtk_widget_set_sensitive (toplevel, 0); |
157 | |
156 | |
158 | gtk_widget_unref (data); |
157 | gtk_widget_unref (data); |
159 | |
|
|
160 | return FALSE; |
158 | return FALSE; |
161 | } |
159 | } |
162 | |
160 | |
163 | static gboolean read_result (GIOChannel *source, GIOCondition condition, gpointer data) |
161 | static gboolean read_result (GIOChannel *source, GIOCondition condition, gpointer data) |
164 | { |
162 | { |
… | |
… | |
192 | gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (data), FALSE); |
190 | gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (data), FALSE); |
193 | g_signal_emit_by_name (GTK_FILE_CHOOSER (data), "file-activated"); |
191 | g_signal_emit_by_name (GTK_FILE_CHOOSER (data), "file-activated"); |
194 | } |
192 | } |
195 | |
193 | |
196 | gtk_widget_unref (data); |
194 | gtk_widget_unref (data); |
197 | |
|
|
198 | return FALSE; |
195 | return FALSE; |
199 | } |
196 | } |
200 | |
197 | |
201 | static gboolean map_cb (GtkWidget *widget, gpointer user_data) |
198 | static gboolean map_cb (GtkWidget *widget, gpointer user_data) |
202 | { |
199 | { |