~wongchiachen/ubuntu/precise/totem/hey_about_dialog

« back to all changes in this revision

Viewing changes to src/plugins/screenshot/totem-screenshot-plugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-20 16:38:02 UTC
  • mfrom: (1.11.13 upstream) (2.1.17 experimental)
  • Revision ID: james.westby@ubuntu.com-20110520163802-p3lohdmfvws2jqeo
Tags: 3.0.1-0ubuntu1
* Resynchronize on Debian, remaining diffs:
* debian/control.in:
  - use suggests rather than recommends for universe gstreamer components
  - add totem-plugins-extra for the components which have depends in universe
  - add build-depends on gnome-common, dh-autoreconf, 
    liblaunchpad-intrgration-3.0-dev, hardening-wrapper
  - drop build-depends on libepc-ui-dev, python-feedparser, xulrunner-dev,
    libtracker-sparql-0.10-dev
  - add XB-Npp-Description and XB-Npp-Filename header to the 
    totem-mozilla package to improve ubufox/ubuntu plugin db integration 
  - change refences from Iceweasel to Firefox
  - recommends gnome-icon-theme-symbolic rather than depending on it
  - list firefox as a totem-mozilla recommends before epiphany-browser
  - libtotem replaces totem (<< 3.0.1-1) for ppa upgrades
* debian/totem-common.install:
  - Install apport hook
* debian/totem-plugins-extra.install:
  - Plugins split out ouf totem-plugins
* debian/totem-plugins.install:    
  - Move some plugins to totem-plugins-extra
* debian/totem.preinst:
  - No longer required as Lucid has been released
* debian/patches/01_fake_keypresses.patch:
  - dropped it's an old workaround and should not be required
* debian/patches/02_lpi.patch:
  - Launchpad integration
* debian/patches/03_default_options.patch: 
  - enable the youtube option by default
* debian/patches/70_bbc_plugin.patch:
  - bbc content viewer, needs to be fixed for the new version
* debian/source_totem.py:
  - ubuntu apport debugging
* debian/rules:
  - run autoreconf on build
* debian/watch:
  - Watch for unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <gmodule.h>
32
32
#include <string.h>
33
33
#include <gdk/gdkkeysyms.h>
34
 
#include <gconf/gconf-client.h>
 
34
#include <libpeas/peas-activatable.h>
35
35
 
36
36
#ifdef HAVE_XFREE
37
37
#include <X11/XF86keysym.h>
38
38
#endif
39
39
 
 
40
#include "totem-plugin.h"
40
41
#include "totem-screenshot-plugin.h"
41
42
#include "totem-screenshot.h"
42
43
#include "totem-gallery.h"
43
44
#include "totem-uri.h"
44
45
#include "backend/bacon-video-widget.h"
45
46
 
46
 
struct TotemScreenshotPluginPrivate {
 
47
#define TOTEM_TYPE_SCREENSHOT_PLUGIN            (totem_screenshot_plugin_get_type ())
 
48
#define TOTEM_SCREENSHOT_PLUGIN(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), TOTEM_TYPE_SCREENSHOT_PLUGIN, TotemScreenshotPlugin))
 
49
#define TOTEM_SCREENSHOT_PLUGIN_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), TOTEM_TYPE_SCREENSHOT_PLUGIN, TotemScreenshotPluginClass))
 
50
#define TOTEM_IS_SCREENSHOT_PLUGIN(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), TOTEM_TYPE_SCREENSHOT_PLUGIN))
 
51
#define TOTEM_IS_SCREENSHOT_PLUGIN_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), TOTEM_TYPE_SCREENSHOT_PLUGIN))
 
52
#define TOTEM_SCREENSHOT_PLUGIN_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), TOTEM_TYPE_SCREENSHOT_PLUGIN, TotemScreenshotPluginClass))
 
53
 
 
54
typedef struct {
47
55
        Totem *totem;
48
56
        BaconVideoWidget *bvw;
49
57
 
51
59
        gulong notify_logo_mode_signal;
52
60
        gulong key_press_event_signal;
53
61
 
54
 
        guint gconf_id;
 
62
        GSettings *settings;
55
63
        gboolean save_to_disk;
56
64
 
57
65
        guint ui_merge_id;
58
66
        GtkActionGroup *action_group;
59
 
};
60
 
 
61
 
static gboolean impl_activate                           (TotemPlugin *plugin, TotemObject *totem, GError **error);
62
 
static void impl_deactivate                             (TotemPlugin *plugin, TotemObject *totem);
63
 
 
64
 
TOTEM_PLUGIN_REGISTER (TotemScreenshotPlugin, totem_screenshot_plugin)
65
 
 
66
 
static void
67
 
totem_screenshot_plugin_class_init (TotemScreenshotPluginClass *klass)
68
 
{
69
 
        TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
70
 
 
71
 
        g_type_class_add_private (klass, sizeof (TotemScreenshotPluginPrivate));
72
 
 
73
 
        plugin_class->activate = impl_activate;
74
 
        plugin_class->deactivate = impl_deactivate;
75
 
}
76
 
 
77
 
static void
78
 
totem_screenshot_plugin_init (TotemScreenshotPlugin *plugin)
79
 
{
80
 
        plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, TOTEM_TYPE_SCREENSHOT_PLUGIN, TotemScreenshotPluginPrivate);
81
 
}
 
67
} TotemScreenshotPluginPrivate;
 
68
 
 
69
TOTEM_PLUGIN_REGISTER(TOTEM_TYPE_SCREENSHOT_PLUGIN,
 
70
                      TotemScreenshotPlugin,
 
71
                      totem_screenshot_plugin)
82
72
 
83
73
static void
84
74
take_screenshot_action_cb (GtkAction *action, TotemScreenshotPlugin *self)
95
85
                if (err == NULL)
96
86
                        return;
97
87
 
98
 
                totem_action_error (_("Totem could not get a screenshot of the video."), err->message, priv->totem);
 
88
                totem_action_error (priv->totem, _("Totem could not get a screenshot of the video."), err->message);
99
89
                g_error_free (err);
100
90
                return;
101
91
        }
102
92
 
103
93
        pixbuf = bacon_video_widget_get_current_frame (priv->bvw);
104
94
        if (pixbuf == NULL) {
105
 
                totem_action_error (_("Totem could not get a screenshot of the video."), _("This is not supposed to happen; please file a bug report."), priv->totem);
 
95
                totem_action_error (priv->totem, _("Totem could not get a screenshot of the video."), _("This is not supposed to happen; please file a bug report."));
106
96
                return;
107
97
        }
108
98
 
109
 
        dialog = totem_screenshot_new (priv->totem, TOTEM_PLUGIN (self), pixbuf);
 
99
        dialog = totem_screenshot_new (priv->totem, pixbuf);
110
100
 
111
101
        gtk_dialog_run (GTK_DIALOG (dialog));
112
102
        gtk_widget_destroy (dialog);
131
121
        if (bacon_video_widget_get_logo_mode (self->priv->bvw) != FALSE)
132
122
                return;
133
123
 
134
 
        dialog = GTK_DIALOG (totem_gallery_new (totem, TOTEM_PLUGIN (self)));
 
124
        dialog = GTK_DIALOG (totem_gallery_new (totem));
135
125
 
136
126
        g_signal_connect (dialog, "response",
137
127
                          G_CALLBACK (take_gallery_response_cb), self);
147
137
                take_screenshot_action_cb (NULL, self);
148
138
                break;
149
139
#endif /* HAVE_XFREE */
150
 
        case GDK_s:
151
 
        case GDK_S:
 
140
        case GDK_KEY_s:
 
141
        case GDK_KEY_S:
152
142
                if (event->state & GDK_CONTROL_MASK)
153
143
                        take_screenshot_action_cb (NULL, self);
154
144
                else
191
181
}
192
182
 
193
183
static void
194
 
disable_save_to_disk_changed_cb (GConfClient *client, guint connection_id, GConfEntry *entry, TotemScreenshotPlugin *self)
 
184
disable_save_to_disk_changed_cb (GSettings *settings, const gchar *key, TotemScreenshotPlugin *self)
195
185
{
196
 
        self->priv->save_to_disk = !gconf_client_get_bool (client, "/desktop/gnome/lockdown/disable_save_to_disk", NULL);
 
186
        self->priv->save_to_disk = !g_settings_get_boolean (settings, "disable-save-to-disk");
197
187
}
198
188
 
199
 
static gboolean
200
 
impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
 
189
static void
 
190
impl_activate (PeasActivatable *plugin)
201
191
{
202
192
        GtkWindow *window;
203
193
        GtkUIManager *manager;
204
 
        GConfClient *client;
205
194
        TotemScreenshotPlugin *self = TOTEM_SCREENSHOT_PLUGIN (plugin);
206
195
        TotemScreenshotPluginPrivate *priv = self->priv;
207
196
        const GtkActionEntry menu_entries[] = {
209
198
                { "take-gallery", NULL, N_("Create Screenshot _Gallery..."), NULL, N_("Create a gallery of screenshots"), G_CALLBACK (take_gallery_action_cb) }
210
199
        };
211
200
 
212
 
        priv->totem = totem;
213
 
        priv->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (totem));
 
201
        priv->totem = g_object_get_data (G_OBJECT (plugin), "object");
 
202
        priv->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (priv->totem));
214
203
        priv->got_metadata_signal = g_signal_connect (G_OBJECT (priv->bvw),
215
204
                                                      "got-metadata",
216
205
                                                      G_CALLBACK (got_metadata_cb),
221
210
                                                          self);
222
211
 
223
212
        /* Key press handler */
224
 
        window = totem_get_main_window (totem);
 
213
        window = totem_get_main_window (priv->totem);
225
214
        priv->key_press_event_signal = g_signal_connect (G_OBJECT (window),
226
215
                                                         "key-press-event", 
227
216
                                                         G_CALLBACK (window_key_press_event_cb),
234
223
        gtk_action_group_add_actions (priv->action_group, menu_entries,
235
224
                                      G_N_ELEMENTS (menu_entries), self);
236
225
 
237
 
        manager = totem_get_ui_manager (totem);
 
226
        manager = totem_get_ui_manager (priv->totem);
238
227
 
239
228
        gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
240
229
        g_object_unref (priv->action_group);
250
239
                               "/ui/tmw-menubar/edit/repeat-mode", NULL,
251
240
                               NULL, GTK_UI_MANAGER_SEPARATOR, TRUE);
252
241
 
253
 
        /* Set up a GConf watch for lockdown keys */
254
 
        client = gconf_client_get_default ();
255
 
        priv->gconf_id = gconf_client_notify_add (client, "/desktop/gnome/lockdown/disable_save_to_disk",
256
 
                                                  (GConfClientNotifyFunc) disable_save_to_disk_changed_cb,
257
 
                                                  self, NULL, NULL);
258
 
        disable_save_to_disk_changed_cb (client, priv->gconf_id, NULL, self);
259
 
        g_object_unref (client);
 
242
        /* Set up a GSettings watch for lockdown keys */
 
243
        priv->settings = g_settings_new ("org.gnome.desktop.lockdown");
 
244
        g_signal_connect (priv->settings, "changed::disable-save-to-disk", (GCallback) disable_save_to_disk_changed_cb, self);
 
245
        disable_save_to_disk_changed_cb (priv->settings, "disable-save-to-disk", self);
260
246
 
261
247
        /* Update the menu entries' states */
262
248
        update_state (self);
263
 
 
264
 
        return TRUE;
265
249
}
266
250
 
267
251
static void
268
 
impl_deactivate (TotemPlugin *plugin, TotemObject *totem)
 
252
impl_deactivate (PeasActivatable *plugin)
269
253
{
270
254
        TotemScreenshotPluginPrivate *priv = TOTEM_SCREENSHOT_PLUGIN (plugin)->priv;
271
255
        GtkWindow *window;
272
256
        GtkUIManager *manager;
273
 
        GConfClient *client;
274
257
 
275
258
        /* Disconnect signal handlers */
276
259
        g_signal_handler_disconnect (G_OBJECT (priv->bvw), priv->got_metadata_signal);
277
260
        g_signal_handler_disconnect (G_OBJECT (priv->bvw), priv->notify_logo_mode_signal);
278
261
 
279
 
        window = totem_get_main_window (totem);
 
262
        window = totem_get_main_window (priv->totem);
280
263
        g_signal_handler_disconnect (G_OBJECT (window), priv->key_press_event_signal);
281
264
        g_object_unref (window);
282
265
 
283
 
        /* Disconnect from GConf */
284
 
        client = gconf_client_get_default ();
285
 
        gconf_client_notify_remove (client, priv->gconf_id);
286
 
        g_object_unref (client);
 
266
        /* Disconnect from GSettings */
 
267
        g_object_unref (priv->settings);
287
268
 
288
269
        /* Remove the menu */
289
 
        manager = totem_get_ui_manager (totem);
 
270
        manager = totem_get_ui_manager (priv->totem);
290
271
        gtk_ui_manager_remove_ui (manager, priv->ui_merge_id);
291
272
        gtk_ui_manager_remove_action_group (manager, priv->action_group);
292
273
 
319
300
gchar *
320
301
totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const char *movie_title)
321
302
{
322
 
        GConfClient *client;
 
303
        GSettings *settings;
323
304
        char *path, *filename, *full, *uri;
324
305
        GFile *file;
325
306
 
326
307
        /* Set the default path */
327
 
        client = gconf_client_get_default ();
328
 
        path = gconf_client_get_string (client, "/apps/totem/screenshot_save_path", NULL);
329
 
        g_object_unref (client);
 
308
        settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
 
309
        path = g_settings_get_string (settings, "screenshot-save-uri");
 
310
        g_object_unref (settings);
330
311
 
331
312
        /* Default to the Pictures directory */
332
 
        if (path == NULL || path[0] == '\0') {
 
313
        if (*path == '\0') {
333
314
                g_free (path);
334
315
                path = totem_pictures_dir ();
335
316
                /* No pictures dir, then it's the home dir */
355
336
void
356
337
totem_screenshot_plugin_update_file_chooser (const char *uri)
357
338
{
358
 
        GConfClient *client;
 
339
        GSettings *settings;
359
340
        char *dir;
360
341
        GFile *file, *parent;
361
342
 
366
347
        dir = g_file_get_path (parent);
367
348
        g_object_unref (parent);
368
349
 
369
 
        client = gconf_client_get_default ();
370
 
        gconf_client_set_string (client,
371
 
                                 "/apps/totem/screenshot_save_path",
372
 
                                 dir, NULL);
 
350
        settings = g_settings_new (TOTEM_GSETTINGS_SCHEMA);
 
351
        g_settings_set_string (settings, "screenshot-save-uri", dir);
 
352
        g_object_unref (settings);
373
353
        g_free (dir);
374
354
}
 
355