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

« back to all changes in this revision

Viewing changes to src/totem.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:
28
28
 
29
29
#include "config.h"
30
30
 
 
31
#include <glib.h>
31
32
#include <glib-object.h>
32
33
#include <glib/gi18n.h>
33
34
#include <gtk/gtk.h>
57
58
                gtk_main_iteration ();
58
59
}
59
60
 
60
 
static UniqueResponse
61
 
totem_message_received_cb (UniqueApp         *app,
62
 
                           int                command,
63
 
                           UniqueMessageData *message_data,
64
 
                           guint              time_,
65
 
                           Totem             *totem)
 
61
static void
 
62
totem_action_handler (GApplication      *app,
 
63
                      gchar             *name,
 
64
                      GVariant          *platform_data,
 
65
                      gpointer           user_data)
66
66
{
67
 
        char *url;
68
 
 
69
 
        if (message_data != NULL)
70
 
                url = unique_message_data_get_text (message_data);
71
 
        else
72
 
                url = NULL;
73
 
 
74
 
        totem_action_remote (totem, command, url);
75
 
 
 
67
        GEnumClass *klass;
 
68
        GEnumValue *enum_value;
 
69
        char *url = NULL;
 
70
        TotemRemoteCommand command;
 
71
 
 
72
        /* GApplication requires the platform_data to be of type a{sv}. */
 
73
        if (platform_data) {
 
74
                GVariantIter iter;
 
75
                GVariant *value;
 
76
                const char *key;
 
77
 
 
78
                g_variant_iter_init (&iter, platform_data);
 
79
                while (g_variant_iter_next (&iter, "{&sv}", &key, &value)) {
 
80
                        if (g_strcmp0 (key, "url") == 0) {
 
81
                                url = g_variant_dup_string (value, NULL);
 
82
                                g_variant_unref (value);
 
83
                                break;
 
84
                        }
 
85
                        g_variant_unref (value);
 
86
                }
 
87
        }
 
88
 
 
89
        klass = g_type_class_ref (TOTEM_TYPE_REMOTE_COMMAND);
 
90
 
 
91
        enum_value = g_enum_get_value_by_name (klass, name);
 
92
        if (!enum_value)
 
93
                return;
 
94
        command = enum_value->value;
 
95
 
 
96
        g_type_class_unref (klass);
 
97
 
 
98
        totem_action_remote (TOTEM_OBJECT (user_data), command, url);
76
99
        g_free (url);
77
 
 
78
 
        return UNIQUE_RESPONSE_OK;
79
100
}
80
101
 
81
102
static void
130
151
                g_log_default_handler (log_domain, log_level, message, NULL);
131
152
}
132
153
 
 
154
static GVariant *
 
155
variant_from_argv (int    argc,
 
156
                   char **argv)
 
157
{
 
158
        GVariantBuilder builder;
 
159
        int i;
 
160
 
 
161
        g_variant_builder_init (&builder, G_VARIANT_TYPE("aay"));
 
162
 
 
163
        for (i = 1; i < argc; i++) {
 
164
                guint8 *argv_bytes;
 
165
 
 
166
                argv_bytes = (guint8 *) argv[i];
 
167
                g_variant_builder_add_value (&builder,
 
168
                                             g_variant_new_bytestring_array (argv_bytes, -1));
 
169
        }
 
170
 
 
171
        return g_variant_builder_end (&builder);
 
172
}
 
173
 
133
174
int
134
175
main (int argc, char **argv)
135
176
{
181
222
        gtk_about_dialog_set_email_hook (about_email_hook, NULL, NULL);
182
223
 
183
224
        gc = gconf_client_get_default ();
184
 
        if (gc == NULL)
185
 
        {
186
 
                totem_action_error_and_exit (_("Totem could not initialize the configuration engine."), _("Make sure that GNOME is properly installed."), NULL);
 
225
        if (gc == NULL) {
 
226
                totem_action_error_and_exit (_("Totem could not initialize the configuration engine."),
 
227
                                             _("Make sure that GNOME is properly installed."), NULL);
187
228
        }
188
229
 
189
230
        /* Debug log handling */
195
236
 
196
237
        /* IPC stuff */
197
238
        if (optionstate.notconnectexistingsession == FALSE) {
198
 
                totem->app = unique_app_new ("org.gnome.Totem", NULL);
199
 
                totem_options_register_remote_commands (totem);
200
 
                if (unique_app_is_running (totem->app) != FALSE) {
201
 
                        totem_options_process_for_server (totem->app, &optionstate);
 
239
                GError *error = NULL;
 
240
 
 
241
                /* FIXME should be GtkApplication */
 
242
                totem->app = g_initable_new (G_TYPE_APPLICATION,
 
243
                                             NULL,
 
244
                                             &error,
 
245
                                             "application-id", "org.gnome.Totem",
 
246
                                             "argv", variant_from_argv (argc, argv),
 
247
                                             "default-quit", FALSE,
 
248
                                             NULL);
 
249
 
 
250
                if (g_application_is_remote (G_APPLICATION (totem->app))) {
 
251
                        totem_options_process_for_server (G_APPLICATION (totem->app), &optionstate);
202
252
                        gdk_notify_startup_complete ();
203
253
                        totem_action_exit (totem);
204
254
                } else {
 
255
                        totem_options_register_remote_commands (totem);
205
256
                        totem_options_process_early (totem, &optionstate);
206
257
                }
207
258
        } else {
214
265
                totem_action_exit (NULL);
215
266
 
216
267
        totem->win = GTK_WIDGET (gtk_builder_get_object (totem->xml, "totem_main_window"));
 
268
        /* FIXME should be enabled
 
269
        gtk_application_add_window (totem->app, GTK_WINDOW (totem->win)); */
217
270
 
218
271
        /* Menubar */
219
272
        totem_ui_manager_setup (totem);
292
345
                gdk_window_set_cursor (gtk_widget_get_window (totem->win), NULL);
293
346
 
294
347
        if (totem->app != NULL) {
295
 
                g_signal_connect (totem->app, "message-received",
296
 
                                  G_CALLBACK (totem_message_received_cb), totem);
 
348
                g_signal_connect (G_APPLICATION (totem->app), "action-with-data",
 
349
                                  G_CALLBACK (totem_action_handler), totem);
297
350
        }
298
351
 
299
352
        gtk_main ();