diff options
Diffstat (limited to 'src/plugins/fs/search.c')
-rw-r--r-- | src/plugins/fs/search.c | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c index 86c117bd..d1e5676a 100644 --- a/src/plugins/fs/search.c +++ b/src/plugins/fs/search.c | |||
@@ -160,6 +160,87 @@ void fs_search_result_received(SearchList * searchContext, | |||
160 | updateSearchSummary(searchContext); | 160 | updateSearchSummary(searchContext); |
161 | } | 161 | } |
162 | 162 | ||
163 | static int | ||
164 | on_search_copy_uri_activate(void * cls, | ||
165 | GtkWidget * searchEntry) { | ||
166 | SearchList * list = cls; | ||
167 | GtkTreePath *path; | ||
168 | GtkTreeIter iter; | ||
169 | struct ECRS_URI * uri; | ||
170 | char * str; | ||
171 | GtkClipboard * clip; | ||
172 | |||
173 | path = NULL; | ||
174 | if (FALSE == gtk_tree_view_get_path_at_pos(list->treeview, | ||
175 | list->last_x, | ||
176 | list->last_y, | ||
177 | &path, | ||
178 | NULL, | ||
179 | NULL, | ||
180 | NULL)) { | ||
181 | GE_BREAK(NULL, 0); | ||
182 | return FALSE; | ||
183 | } | ||
184 | if (FALSE == gtk_tree_model_get_iter(GTK_TREE_MODEL(list->tree), | ||
185 | &iter, | ||
186 | path)) { | ||
187 | GE_BREAK(NULL, 0); | ||
188 | gtk_tree_path_free(path); | ||
189 | return FALSE; | ||
190 | } | ||
191 | gtk_tree_path_free(path); | ||
192 | uri = NULL; | ||
193 | gtk_tree_model_get(GTK_TREE_MODEL(list->tree), | ||
194 | &iter, | ||
195 | SEARCH_URI, &uri, | ||
196 | -1); | ||
197 | str = ECRS_uriToString(uri); | ||
198 | clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); | ||
199 | gtk_clipboard_set_text(clip, | ||
200 | str, | ||
201 | strlen(str)); | ||
202 | FREE(str); | ||
203 | return FALSE; | ||
204 | } | ||
205 | |||
206 | static gint | ||
207 | search_click_handler(void * cls, | ||
208 | GdkEvent *event) { | ||
209 | SearchList * list = cls; | ||
210 | GtkMenu * menu; | ||
211 | GtkWidget * entry; | ||
212 | GdkEventButton * event_button; | ||
213 | |||
214 | g_return_val_if_fail (event != NULL, FALSE); | ||
215 | |||
216 | if (event->type != GDK_BUTTON_PRESS) | ||
217 | return FALSE; | ||
218 | event_button = (GdkEventButton *) event; | ||
219 | if (event_button->button != 3) | ||
220 | return FALSE; | ||
221 | list->last_x = event_button->x; | ||
222 | list->last_y = event_button->y; | ||
223 | entry = gtk_menu_item_new_with_label(_("_Copy URI to Clipboard")); | ||
224 | g_signal_connect_swapped (entry, | ||
225 | "activate", | ||
226 | G_CALLBACK(on_search_copy_uri_activate), | ||
227 | list); | ||
228 | gtk_label_set_use_underline(GTK_LABEL(gtk_bin_get_child(GTK_BIN(entry))), | ||
229 | TRUE); | ||
230 | gtk_widget_show(entry); | ||
231 | menu = GTK_MENU(gtk_menu_new()); | ||
232 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), | ||
233 | entry); | ||
234 | gtk_menu_popup (menu, | ||
235 | NULL, | ||
236 | NULL, | ||
237 | NULL, | ||
238 | NULL, | ||
239 | event_button->button, | ||
240 | event_button->time); | ||
241 | return TRUE; | ||
242 | } | ||
243 | |||
163 | /** | 244 | /** |
164 | * FSUI event: a search was started; create the | 245 | * FSUI event: a search was started; create the |
165 | * tab and add an entry to the summary. | 246 | * tab and add an entry to the summary. |
@@ -224,7 +305,10 @@ fs_search_started(struct FSUI_SearchList * fsui_list, | |||
224 | /* setup tree view and renderers */ | 305 | /* setup tree view and renderers */ |
225 | list->treeview = GTK_TREE_VIEW(glade_xml_get_widget(list->searchXML, | 306 | list->treeview = GTK_TREE_VIEW(glade_xml_get_widget(list->searchXML, |
226 | "searchResults")); | 307 | "searchResults")); |
227 | 308 | g_signal_connect_swapped (list->treeview, | |
309 | "button-press-event", | ||
310 | G_CALLBACK(search_click_handler), | ||
311 | list); | ||
228 | list->tree = | 312 | list->tree = |
229 | gtk_tree_store_new(SEARCH_NUM, | 313 | gtk_tree_store_new(SEARCH_NUM, |
230 | G_TYPE_STRING, /* name */ | 314 | G_TYPE_STRING, /* name */ |