~fcwu-tw/ubuntu/precise/totem/fix-for-lp-1041032

« back to all changes in this revision

Viewing changes to src/totem-open-location.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-08-12 13:09:09 UTC
  • mfrom: (1.11.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100812130909-hzn8tsoh9z7t3dbx
Tags: 2.31.6-0ubuntu1
* New upstream version:
  - Add support for Web-M to browser, movie player, and YouTube plugin
  Movie Player:
  - Add deinterlacing support, automatically used for interlaced content
  - Do not block when loading playlists
  - Remove libunique dependency
  - Make auto-resize use half-scale or 2x if the player would fit on the 
    screen
  - Make screensaver preference clearer
  - Support running with RGBA (semi-transparent) GTK+ themes
  Plugins:
  - Update for YouTube website changes
  Browser plugin:
  - Fix running browser plugin in non-GTK+ front-ends
  - VLC-compatible browser plugin:
  - Support input.time and input.length property
  - Support togglePause function
  - Support toolbar plugin argument
* debian/control.in:
  - updated the build requirements to match the configure
* debian/patches/80_webm.patch,
  debian/patches/81_mpegts.patch,
  debian/patches/91_git_correct_rgba_use.patch:
  - the changes are in the new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "totem-open-location.h"
41
41
#include "totem-interface.h"
42
42
 
43
 
static void totem_open_location_dispose         (GObject *object);
44
 
 
45
43
struct TotemOpenLocationPrivate
46
44
{
47
 
        GtkBuilder *xml;
 
45
        GtkWidget *uri_container;
48
46
        GtkEntry *uri_entry;
49
47
};
50
48
 
52
50
 
53
51
G_DEFINE_TYPE (TotemOpenLocation, totem_open_location, GTK_TYPE_DIALOG)
54
52
 
 
53
/* GtkBuilder callbacks */
 
54
G_MODULE_EXPORT void uri_entry_changed_cb (GtkEditable *entry, GtkDialog *dialog);
 
55
 
55
56
static void
56
57
totem_open_location_class_init (TotemOpenLocationClass *klass)
57
58
{
58
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
59
 
 
60
59
        g_type_class_add_private (klass, sizeof (TotemOpenLocationPrivate));
61
 
        object_class->dispose = totem_open_location_dispose;
62
60
}
63
61
 
64
62
static void
65
63
totem_open_location_init (TotemOpenLocation *self)
66
64
{
67
 
        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TOTEM_TYPE_OPEN_LOCATION, TotemOpenLocationPrivate);
68
 
 
69
 
        self->priv->xml = totem_interface_load ("uri.ui", FALSE, NULL, self);
70
 
        self->priv->uri_entry = GTK_ENTRY (gtk_builder_get_object (self->priv->xml, "uri"));
71
 
}
72
 
 
73
 
static void
74
 
totem_open_location_dispose (GObject *object)
75
 
{
76
 
        TotemOpenLocationPrivate *priv = TOTEM_OPEN_LOCATION_GET_PRIVATE (object);
77
 
 
78
 
        if (priv->xml != NULL) {
79
 
                g_object_unref (priv->xml);
80
 
                priv->xml = NULL;
81
 
        }
82
 
 
83
 
        G_OBJECT_CLASS (totem_open_location_parent_class)->dispose (object);
 
65
        GtkBuilder *builder;
 
66
 
 
67
        self->priv = TOTEM_OPEN_LOCATION_GET_PRIVATE (self);
 
68
        builder = totem_interface_load ("uri.ui", FALSE, NULL, self);
 
69
 
 
70
        if (builder == NULL)
 
71
                return;
 
72
 
 
73
        self->priv->uri_container = GTK_WIDGET (gtk_builder_get_object (builder, "open_uri_dialog_content"));
 
74
        g_object_ref (self->priv->uri_container);
 
75
 
 
76
        self->priv->uri_entry = GTK_ENTRY (gtk_builder_get_object (builder, "uri"));
 
77
 
 
78
        g_object_unref (builder);
84
79
}
85
80
 
86
81
static gboolean
89
84
        /* Substring-match key against URI */
90
85
        char *uri, *match;
91
86
 
 
87
        g_return_val_if_fail (GTK_IS_TREE_MODEL (user_data), FALSE);
 
88
        g_return_val_if_fail (iter != NULL, FALSE);
 
89
 
92
90
        g_return_val_if_fail (key != NULL, FALSE);
93
91
        gtk_tree_model_get (user_data, iter, 0, &uri, -1);
94
92
        g_return_val_if_fail (uri != NULL, FALSE);
114
112
{
115
113
        char *uri;
116
114
 
 
115
        g_return_val_if_fail (TOTEM_IS_OPEN_LOCATION (open_location), NULL);
 
116
 
117
117
        uri = g_strdup (gtk_entry_get_text (open_location->priv->uri_entry));
118
118
 
119
119
        if (strcmp (uri, "") == 0)
136
136
        GtkClipboard *clipboard;
137
137
        gchar *clipboard_content;
138
138
 
 
139
        g_return_val_if_fail (TOTEM_IS_OPEN_LOCATION (open_location), NULL);
 
140
 
139
141
        /* Initialize the clipboard and get its content */
140
142
        clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (open_location)), GDK_SELECTION_CLIPBOARD);
141
143
        clipboard_content = gtk_clipboard_wait_for_text (clipboard);
151
153
        return NULL;
152
154
}
153
155
 
154
 
GtkWidget*
155
 
totem_open_location_new (Totem *totem)
 
156
void
 
157
uri_entry_changed_cb (GtkEditable *entry, GtkDialog *dialog)
 
158
{
 
159
        gboolean sensitive = (gtk_entry_get_text_length (GTK_ENTRY (entry)) > 0);
 
160
        gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
 
161
}
 
162
 
 
163
GtkWidget *
 
164
totem_open_location_new (void)
156
165
{
157
166
        TotemOpenLocation *open_location;
158
167
        char *clipboard_location;
159
168
        GtkEntryCompletion *completion;
160
169
        GtkTreeModel *model;
161
170
        GList *recent_items, *streams_recent_items = NULL;
162
 
        GtkWidget *container;
163
171
 
164
172
        open_location = TOTEM_OPEN_LOCATION (g_object_new (TOTEM_TYPE_OPEN_LOCATION, NULL));
165
173
 
166
 
        if (open_location->priv->xml == NULL) {
 
174
        if (open_location->priv->uri_container == NULL) {
167
175
                g_object_unref (open_location);
168
176
                return NULL;
169
177
        }
174
182
                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
175
183
                        GTK_STOCK_OPEN, GTK_RESPONSE_OK,
176
184
                        NULL);
 
185
        gtk_dialog_set_response_sensitive (GTK_DIALOG (open_location), GTK_RESPONSE_OK, FALSE);
177
186
        gtk_container_set_border_width (GTK_CONTAINER (open_location), 5);
178
187
        gtk_dialog_set_default_response (GTK_DIALOG (open_location), GTK_RESPONSE_OK);
179
188
 
180
 
        g_signal_connect (G_OBJECT (open_location), "delete-event",
181
 
                        G_CALLBACK (gtk_widget_destroy), open_location);
182
 
 
183
189
        /* Get item from clipboard to fill GtkEntry */
184
190
        clipboard_location = totem_open_location_set_from_clipboard (open_location);
185
191
        if (clipboard_location != NULL && strcmp (clipboard_location, "") != 0)
229
235
        gtk_entry_completion_set_text_column (completion, 0);
230
236
        gtk_entry_completion_set_match_func (completion, (GtkEntryCompletionMatchFunc) totem_open_location_match, model, NULL);
231
237
 
232
 
        container = GTK_WIDGET (gtk_builder_get_object (open_location->priv->xml,
233
 
                                "open_uri_dialog_content"));
234
238
        gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (open_location))),
235
 
                                container,
 
239
                                open_location->priv->uri_container,
236
240
                                TRUE,       /* expand */
237
241
                                TRUE,       /* fill */
238
242
                                0);         /* padding */