Exemplo n.º 1
0
static void on_treeview_drag_data_received(G_GNUC_UNUSED GtkWidget *widget,
	GdkDragContext *context, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y,
	GtkSelectionData *selection, G_GNUC_UNUSED guint info, guint t,
	G_GNUC_UNUSED gpointer data)
{
	char **uris = gtk_selection_data_get_uris(selection);
	GSList *list = NULL;

	if (!uris) {
		gtk_drag_finish(context, false, true, t);
		return;
	}

	for (int i = 0; uris[i]; i++)
		list = g_slist_prepend(list, uris[i]);

	list = g_slist_reverse(list);

	gui_add_uris(list, GUI_VIEW_FILE_LIST);

	g_slist_free(list);
	g_strfreev(uris);

	gtk_drag_finish(context, true, true, t);
}
Exemplo n.º 2
0
static void on_toolbutton_add_clicked(void)
{
	GtkFileChooser *chooser = GTK_FILE_CHOOSER(
		gtk_file_chooser_dialog_new(_("Select Files"), gui.window,
			GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
			NULL));
	gtk_file_chooser_set_select_multiple(chooser, true);
	gtk_file_chooser_set_local_only(chooser, false);

	if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
		GSList *uris = gtk_file_chooser_get_uris(chooser);
		gui_add_uris(uris, GUI_VIEW_FILE_LIST);
		g_slist_free_full(uris, g_free);
	}

	gtk_widget_destroy(GTK_WIDGET(chooser));
}
Exemplo n.º 3
0
static void read_opts_postinit(void)
{
    if (opts.files) {
        GSList *uris = NULL;

        for (int i = 0; opts.files[i]; i++)
            uris = g_slist_prepend(uris, filename_arg_to_uri(opts.files[i]));

        uris = g_slist_reverse(uris);

        unsigned int added = gui_add_uris(uris, GUI_VIEW_INVALID);
        if (added == 1)
            gui_set_view(GUI_VIEW_FILE);
        else if (added > 1)
            gui_set_view(GUI_VIEW_FILE_LIST);

        g_slist_free_full(uris, g_free);
    }

    free_opts();
}