~ubuntu-branches/ubuntu/utopic/gxine/utopic-proposed

« back to all changes in this revision

Viewing changes to .pc/debian-changes/src/open_mrl.c

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2014-05-07 21:34:55 UTC
  • mfrom: (2.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20140507213455-qnu5diwyyj8bkaap
Tags: 0.5.907-3ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/rules, debian/control: use dh-autoreconf at build time.
  - debian/control: Add Xb-Npp-xxx, Xb-Npp-Description and Xb-Npp-File
    fields.
  - src/script_engine.c: fix a remaining memory leak issue associated with
    using JS_EncodeString(), which somehow didn't get fixed upstream
  - debian/gxineplugin.links: Add a link to xulrunner-addons/plugins
    directory.
  - mime.default: Add dvd, vcd, svcd tags.
* Dropped changes, no longer needed:
  - debian/gxine.install: no need to diverge from Debian since we no longer
    ship a wrapper
* All other changes dropped, as they have been included upstream or in
  Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2003-2006 the xine project
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
17
 
 *
18
 
 * open mrl dialog (plus file browser)
19
 
 */
20
 
 
21
 
#include "globals.h"
22
 
 
23
 
#include <string.h>
24
 
#include <stdlib.h>
25
 
#include <ctype.h>
26
 
#include <gtk/gtk.h>
27
 
 
28
 
#include "open_mrl.h"
29
 
#include "playlist.h"
30
 
#include "ui.h"
31
 
#include "utils.h"
32
 
#include "script_engine.h"
33
 
#include "history.h"
34
 
 
35
 
static GtkWidget      *mrl_dialog;
36
 
static gboolean        mrl_visible;
37
 
static GtkWidget      *mrl_entry;
38
 
 
39
 
void file_dialog_show(void)
40
 
{
41
 
  playlist_add_list
42
 
    (modal_multi_file_dialog (_("Select files to add to playlist"),
43
 
                              FALSE, NULL, app),
44
 
     TRUE);
45
 
}
46
 
 
47
 
void file_dialog_init (void)
48
 
{
49
 
  /* nothing to do */
50
 
}
51
 
 
52
 
static gboolean responding = FALSE;
53
 
 
54
 
static void
55
 
open_mrl_activate_cb (GtkWidget *w, char *cmrl)
56
 
{
57
 
  while (isspace (*cmrl))
58
 
    ++cmrl;
59
 
  if (*cmrl)
60
 
  {
61
 
    int item = playlist_add_mrl (cmrl, -1);
62
 
    playlist_play (item);
63
 
  }
64
 
  if (!responding)
65
 
  {
66
 
    mrl_visible = FALSE;
67
 
    gtk_widget_hide (mrl_dialog);
68
 
  }
69
 
}
70
 
 
71
 
static void open_mrl_response_cb (GtkDialog *dbox, int response, gpointer data)
72
 
{
73
 
  switch (response)
74
 
  {
75
 
  case 1:
76
 
    get_mrl_from_filesystem ((GtkWindow *)mrl_dialog,
77
 
                             (GtkEntry *)history_combo_box_get_entry (mrl_entry));
78
 
    break;
79
 
 
80
 
  case GTK_RESPONSE_OK:
81
 
    responding = TRUE;
82
 
    history_combo_box_activate (mrl_entry);
83
 
    responding = FALSE;
84
 
 
85
 
  default:
86
 
    mrl_visible = FALSE;
87
 
    gtk_widget_hide (mrl_dialog);
88
 
  }
89
 
}
90
 
 
91
 
static JSBool js_open_show (JSContext *cx, JSObject *obj, uintN argc,
92
 
                            jsval *argv, jsval *rval)
93
 
{
94
 
  /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */
95
 
  se_log_fncall_checkinit ("open_show");
96
 
  file_dialog_show ();
97
 
  return JS_TRUE;
98
 
}
99
 
 
100
 
static JSBool js_open_mrl_show (JSContext *cx, JSObject *obj, uintN argc,
101
 
                                jsval *argv, jsval *rval)
102
 
{
103
 
  /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */
104
 
  se_log_fncall_checkinit ("open_mrl_show");
105
 
  open_mrl_show ();
106
 
  return JS_TRUE;
107
 
}
108
 
 
109
 
void open_mrl_init (void)
110
 
{
111
 
  GtkWidget *hbox;
112
 
 
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...")),
117
 
                                1);
118
 
  gtk_dialog_add_buttons (GTK_DIALOG(mrl_dialog),
119
 
                          GTK_STOCK_CANCEL, GTK_RESPONSE_DELETE_EVENT,
120
 
                          GTK_STOCK_OK, GTK_RESPONSE_OK,
121
 
                          NULL);
122
 
 
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);
129
 
 
130
 
  hbox = gtk_hbox_new (0, 2);
131
 
  gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (mrl_dialog)->vbox), hbox);
132
 
 
133
 
  mrl_entry = history_combo_box_new (open_mrl_activate_cb);
134
 
  gtk_box_pack_start (GTK_BOX(hbox), mrl_entry, TRUE, TRUE, 2);
135
 
 
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);
140
 
 
141
 
  mrl_visible = 0;
142
 
 
143
 
  {
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 },
147
 
      { NULL }
148
 
    };
149
 
    se_defuns (gse, NULL, defs);
150
 
  }
151
 
}
152
 
 
153
 
void open_mrl_show (void)
154
 
{
155
 
  if (mrl_visible)
156
 
  {
157
 
    mrl_visible = FALSE;
158
 
    gtk_widget_hide (mrl_dialog);
159
 
  }
160
 
  else
161
 
  {
162
 
    mrl_visible = TRUE;
163
 
    window_show (mrl_dialog, NULL);
164
 
    gtk_widget_grab_focus (mrl_entry);
165
 
  }
166
 
}