2
* Copyright (C) 2003-2006 the xine project
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
* open mrl dialog (plus file browser)
32
#include "script_engine.h"
35
static GtkWidget *mrl_dialog;
36
static gboolean mrl_visible;
37
static GtkWidget *mrl_entry;
39
void file_dialog_show(void)
42
(modal_multi_file_dialog (_("Select files to add to playlist"),
47
void file_dialog_init (void)
52
static gboolean responding = FALSE;
55
open_mrl_activate_cb (GtkWidget *w, char *cmrl)
57
while (isspace (*cmrl))
61
int item = playlist_add_mrl (cmrl, -1);
67
gtk_widget_hide (mrl_dialog);
71
static void open_mrl_response_cb (GtkDialog *dbox, int response, gpointer data)
76
get_mrl_from_filesystem ((GtkWindow *)mrl_dialog,
77
(GtkEntry *)history_combo_box_get_entry (mrl_entry));
82
history_combo_box_activate (mrl_entry);
87
gtk_widget_hide (mrl_dialog);
91
static JSBool js_open_show (JSContext *cx, JSObject *obj, uintN argc,
92
jsval *argv, jsval *rval)
94
/* se_t *se = (se_t *) JS_GetContextPrivate(cx); */
95
se_log_fncall_checkinit ("open_show");
100
static JSBool js_open_mrl_show (JSContext *cx, JSObject *obj, uintN argc,
101
jsval *argv, jsval *rval)
103
/* se_t *se = (se_t *) JS_GetContextPrivate(cx); */
104
se_log_fncall_checkinit ("open_mrl_show");
109
void open_mrl_init (void)
113
mrl_dialog = gtk_dialog_new_with_buttons (_("Open MRL..."), NULL, 0, NULL);
114
gtk_dialog_add_action_widget (GTK_DIALOG(mrl_dialog),
115
ui_button_new_stock_mnemonic
116
(GTK_STOCK_OPEN, _("_File...")),
118
gtk_dialog_add_buttons (GTK_DIALOG(mrl_dialog),
119
GTK_STOCK_CANCEL, GTK_RESPONSE_DELETE_EVENT,
120
GTK_STOCK_OK, GTK_RESPONSE_OK,
123
gtk_window_set_default_size (GTK_WINDOW (mrl_dialog), 400, -1);
124
gtk_window_set_position (GTK_WINDOW (mrl_dialog), GTK_WIN_POS_CENTER);
125
hide_on_delete (mrl_dialog, &mrl_visible);
126
g_signal_connect (G_OBJECT (mrl_dialog), "response",
127
G_CALLBACK (open_mrl_response_cb), NULL);
128
gtk_dialog_set_default_response (GTK_DIALOG(mrl_dialog), GTK_RESPONSE_OK);
130
hbox = gtk_hbox_new (0, 2);
131
gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (mrl_dialog)->vbox), hbox);
133
mrl_entry = history_combo_box_new (open_mrl_activate_cb);
134
gtk_box_pack_start (GTK_BOX(hbox), mrl_entry, TRUE, TRUE, 2);
136
GtkWidget *b = ui_button_new_stock_mnemonic (GTK_STOCK_CLEAR, _("_Flush"));
137
gtk_box_pack_start (GTK_BOX (hbox), b, FALSE, FALSE, 0);
138
g_signal_connect_swapped (b, "clicked",
139
G_CALLBACK (history_combo_box_clear), mrl_entry);
144
static const se_f_def_t defs[] = {
145
{ "open_show", js_open_show, 0, 0, SE_GROUP_FILE, NULL, NULL },
146
{ "open_mrl_show", js_open_mrl_show, 0, 0, SE_GROUP_FILE, NULL, NULL },
149
se_defuns (gse, NULL, defs);
153
void open_mrl_show (void)
158
gtk_widget_hide (mrl_dialog);
163
window_show (mrl_dialog, NULL);
164
gtk_widget_grab_focus (mrl_entry);