40
40
#include "totem-open-location.h"
41
41
#include "totem-interface.h"
43
static void totem_open_location_dispose (GObject *object);
45
43
struct TotemOpenLocationPrivate
45
GtkWidget *uri_container;
48
46
GtkEntry *uri_entry;
53
51
G_DEFINE_TYPE (TotemOpenLocation, totem_open_location, GTK_TYPE_DIALOG)
53
/* GtkBuilder callbacks */
54
G_MODULE_EXPORT void uri_entry_changed_cb (GtkEditable *entry, GtkDialog *dialog);
56
57
totem_open_location_class_init (TotemOpenLocationClass *klass)
58
GObjectClass *object_class = G_OBJECT_CLASS (klass);
60
59
g_type_class_add_private (klass, sizeof (TotemOpenLocationPrivate));
61
object_class->dispose = totem_open_location_dispose;
65
63
totem_open_location_init (TotemOpenLocation *self)
67
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TOTEM_TYPE_OPEN_LOCATION, TotemOpenLocationPrivate);
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"));
74
totem_open_location_dispose (GObject *object)
76
TotemOpenLocationPrivate *priv = TOTEM_OPEN_LOCATION_GET_PRIVATE (object);
78
if (priv->xml != NULL) {
79
g_object_unref (priv->xml);
83
G_OBJECT_CLASS (totem_open_location_parent_class)->dispose (object);
67
self->priv = TOTEM_OPEN_LOCATION_GET_PRIVATE (self);
68
builder = totem_interface_load ("uri.ui", FALSE, NULL, self);
73
self->priv->uri_container = GTK_WIDGET (gtk_builder_get_object (builder, "open_uri_dialog_content"));
74
g_object_ref (self->priv->uri_container);
76
self->priv->uri_entry = GTK_ENTRY (gtk_builder_get_object (builder, "uri"));
78
g_object_unref (builder);
89
84
/* Substring-match key against URI */
87
g_return_val_if_fail (GTK_IS_TREE_MODEL (user_data), FALSE);
88
g_return_val_if_fail (iter != NULL, FALSE);
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);
136
136
GtkClipboard *clipboard;
137
137
gchar *clipboard_content;
139
g_return_val_if_fail (TOTEM_IS_OPEN_LOCATION (open_location), NULL);
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);
155
totem_open_location_new (Totem *totem)
157
uri_entry_changed_cb (GtkEditable *entry, GtkDialog *dialog)
159
gboolean sensitive = (gtk_entry_get_text_length (GTK_ENTRY (entry)) > 0);
160
gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, sensitive);
164
totem_open_location_new (void)
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;
164
172
open_location = TOTEM_OPEN_LOCATION (g_object_new (TOTEM_TYPE_OPEN_LOCATION, NULL));
166
if (open_location->priv->xml == NULL) {
174
if (open_location->priv->uri_container == NULL) {
167
175
g_object_unref (open_location);
174
182
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
175
183
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
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);
180
g_signal_connect (G_OBJECT (open_location), "delete-event",
181
G_CALLBACK (gtk_widget_destroy), open_location);
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);
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))),
239
open_location->priv->uri_container,
236
240
TRUE, /* expand */
238
242
0); /* padding */