1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Engrampa
*
* Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include <string.h>
#include <gtk/gtk.h>
#include "file-utils.h"
#include "glib-utils.h"
#include "gtk-utils.h"
#include "fr-init.h"
#include "fr-window.h"
#include "dlg-open-with.h"
typedef struct {
FrWindow *window;
GList *file_list;
} OpenData;
static void
open_data_free (OpenData *o_data)
{
path_list_free (o_data->file_list);
g_free (o_data);
}
static void
app_chooser_response_cb (GtkDialog *dialog,
int response_id,
gpointer user_data)
{
OpenData *o_data = user_data;
GAppInfo *app_info;
switch (response_id) {
case GTK_RESPONSE_OK:
app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog));
if (app_info != NULL) {
fr_window_open_files_with_application (o_data->window, o_data->file_list, app_info);
g_object_unref (app_info);
}
open_data_free (o_data);
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_DELETE_EVENT:
open_data_free (o_data);
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
default:
break;
}
}
void
dlg_open_with (FrWindow *window,
GList *file_list)
{
OpenData *o_data;
GtkWidget *app_chooser;
GFile *first_file;
o_data = g_new0 (OpenData, 1);
o_data->window = window;
o_data->file_list = file_list;
first_file = g_file_new_for_path (file_list->data);
app_chooser = gtk_app_chooser_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL,
first_file);
g_signal_connect (app_chooser,
"response",
G_CALLBACK (app_chooser_response_cb),
o_data);
gtk_widget_show (app_chooser);
}
void
open_with_cb (GtkWidget *widget,
void *callback_data)
{
FrWindow *window = callback_data;
GList *file_list;
file_list = fr_window_get_file_list_selection (window, FALSE, NULL);
if (file_list == NULL)
return;
fr_window_open_files (window, file_list, TRUE);
path_list_free (file_list);
}
|