~ubuntu-branches/ubuntu/lucid/cheese/lucid-proposed

« back to all changes in this revision

Viewing changes to src/cheese-window.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-07-29 20:42:57 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090729204257-eoi74gsztbt3030m
Tags: 2.27.5-0ubuntu1
* New upstream release: (LP: #405684)
  - add new photo and burst icons, courtesy of Ulisse Perusin
  - remove the label of the photo and video modes
  - support taking a series of photos, fixes bug #581997
    this introduces the burst mode in cheese.
    the burst mode allows to take a series of photos
    with a configurable delay and number of photos
  - Make webcam and resolution settings not sensitive if just 1 option
    is available. If there are no options to choose, make the webcam and
    resolution combo box insensitive, fixes bug #588353
  - Added/Updated Translations
  - Added/Updated Documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
typedef enum
71
71
{
72
72
  WEBCAM_MODE_PHOTO,
73
 
  WEBCAM_MODE_VIDEO
 
73
  WEBCAM_MODE_VIDEO,
 
74
  WEBCAM_MODE_BURST
74
75
} WebcamMode;
75
76
 
76
77
typedef enum
128
129
  GtkWidget *button_effects;
129
130
  GtkWidget *button_photo;
130
131
  GtkWidget *button_video;
 
132
  GtkWidget *button_burst;
131
133
  GtkWidget *button_effects_fullscreen;
132
134
  GtkWidget *button_photo_fullscreen;
133
135
  GtkWidget *button_video_fullscreen;
 
136
  GtkWidget *button_burst_fullscreen;
134
137
  GtkWidget *button_exit_fullscreen;
135
138
 
136
139
  GtkWidget *image_take_photo;
170
173
  GtkActionGroup *actions_photo;
171
174
  GtkActionGroup *actions_toggle;
172
175
  GtkActionGroup *actions_video;
 
176
  GtkActionGroup *actions_burst;
173
177
  GtkActionGroup *actions_fullscreen;
174
178
 
175
179
  GtkUIManager *ui_manager;
178
182
 
179
183
  int audio_play_counter;
180
184
 
 
185
  gint repeat_count;
 
186
 
181
187
  CheeseFlash *flash;
182
188
} CheeseWindow;
183
189
 
436
442
  g_object_unref (cheese_window->actions_preferences);
437
443
  g_object_unref (cheese_window->actions_file);
438
444
  g_object_unref (cheese_window->actions_video);
 
445
  g_object_unref (cheese_window->actions_burst);
439
446
  g_object_unref (cheese_window->actions_fullscreen);
440
447
  g_object_unref (cheese_window->gconf);
441
448
 
1146
1153
    {
1147
1154
      gtk_action_group_set_sensitive (cheese_window->actions_photo, TRUE);
1148
1155
    }
 
1156
    else if (cheese_window->webcam_mode == WEBCAM_MODE_BURST)
 
1157
    {
 
1158
      gtk_action_group_set_sensitive (cheese_window->actions_burst, TRUE);
 
1159
    }
1149
1160
    else
1150
1161
    {
1151
1162
      gtk_action_group_set_sensitive (cheese_window->actions_video, TRUE);
1163
1174
    gtk_widget_set_sensitive (GTK_WIDGET (cheese_window->take_picture_fullscreen), FALSE);
1164
1175
    gtk_action_group_set_sensitive (cheese_window->actions_photo, FALSE);
1165
1176
    gtk_action_group_set_sensitive (cheese_window->actions_video, FALSE);
 
1177
    gtk_action_group_set_sensitive (cheese_window->actions_burst, FALSE);
1166
1178
  }
1167
1179
}
1168
1180
 
1280
1292
  return TRUE;
1281
1293
}
1282
1294
 
 
1295
static gboolean
 
1296
cheese_window_take_burst_photo (gpointer data)
 
1297
{
 
1298
  gboolean      countdown;
 
1299
  CheeseWindow *cheese_window = (CheeseWindow *) data;
 
1300
 
 
1301
  g_object_get (cheese_window->gconf, "gconf_prop_countdown", &countdown, NULL);
 
1302
  if (countdown)
 
1303
  {
 
1304
    if (cheese_window->isFullscreen)
 
1305
    {
 
1306
      cheese_countdown_start ((CheeseCountdown *) cheese_window->countdown_fullscreen,
 
1307
                              cheese_window_countdown_picture_cb,
 
1308
                              cheese_window_countdown_hide_cb,
 
1309
                              (gpointer) cheese_window);
 
1310
      gtk_notebook_set_current_page (GTK_NOTEBOOK (cheese_window->fullscreen_bar), 1);
 
1311
 
 
1312
      /* show bar, start timeout
 
1313
       * ATTENTION: if the countdown is longer than FULLSCREEN_TIMEOUT,
 
1314
       * the bar will disapear before the countdown ends
 
1315
       */
 
1316
      cheese_window_fullscreen_show_bar (cheese_window);
 
1317
      cheese_window_fullscreen_set_timeout (cheese_window);
 
1318
    }
 
1319
    else
 
1320
    {
 
1321
      cheese_countdown_start ((CheeseCountdown *) cheese_window->countdown,
 
1322
                              cheese_window_countdown_picture_cb,
 
1323
                              cheese_window_countdown_hide_cb,
 
1324
                              (gpointer) cheese_window);
 
1325
      gtk_notebook_set_current_page (GTK_NOTEBOOK (cheese_window->notebook_bar), 1);
 
1326
    }
 
1327
  }
 
1328
  else
 
1329
  {
 
1330
    cheese_window_countdown_picture_cb (cheese_window);
 
1331
  }
 
1332
 
 
1333
  gtk_widget_set_sensitive (cheese_window->take_picture, FALSE);
 
1334
  gtk_widget_set_sensitive (cheese_window->take_picture_fullscreen, FALSE);
 
1335
 
 
1336
  cheese_window->repeat_count--;
 
1337
  if (cheese_window->repeat_count <= 0)
 
1338
  {
 
1339
    return FALSE;
 
1340
  }
 
1341
  return TRUE;
 
1342
}
 
1343
 
1283
1344
static void
1284
1345
cheese_window_action_button_clicked_cb (GtkWidget *widget, CheeseWindow *cheese_window)
1285
1346
{
1287
1348
 
1288
1349
  if (cheese_window->webcam_mode == WEBCAM_MODE_PHOTO)
1289
1350
  {
 
1351
    cheese_window->repeat_count = 1;
 
1352
    cheese_window_take_burst_photo (cheese_window);
 
1353
 
 
1354
    /* FIXME: set menu inactive */
 
1355
  }
 
1356
  else if (cheese_window->webcam_mode == WEBCAM_MODE_BURST)
 
1357
  {
 
1358
    guint    repeat_delay = 1000;
1290
1359
    gboolean countdown;
 
1360
 
 
1361
    g_object_get (cheese_window->gconf, "gconf_prop_burst_delay", &repeat_delay, NULL);
 
1362
    g_object_get (cheese_window->gconf, "gconf_prop_burst_repeat", &cheese_window->repeat_count, NULL);
1291
1363
    g_object_get (cheese_window->gconf, "gconf_prop_countdown", &countdown, NULL);
1292
 
    if (countdown)
1293
 
    {
1294
 
      if (cheese_window->isFullscreen)
1295
 
      {
1296
 
        cheese_countdown_start ((CheeseCountdown *) cheese_window->countdown_fullscreen,
1297
 
                                cheese_window_countdown_picture_cb,
1298
 
                                cheese_window_countdown_hide_cb,
1299
 
                                (gpointer) cheese_window);
1300
 
        gtk_notebook_set_current_page (GTK_NOTEBOOK (cheese_window->fullscreen_bar), 1);
1301
 
 
1302
 
        /* show bar, start timeout
1303
 
         * ATTENTION: if the countdown is longer than FULLSCREEN_TIMEOUT,
1304
 
         * the bar will disapear before the countdown ends
1305
 
         */
1306
 
        cheese_window_fullscreen_show_bar (cheese_window);
1307
 
        cheese_window_fullscreen_set_timeout (cheese_window);
1308
 
      }
1309
 
      else
1310
 
      {
1311
 
        cheese_countdown_start ((CheeseCountdown *) cheese_window->countdown,
1312
 
                                cheese_window_countdown_picture_cb,
1313
 
                                cheese_window_countdown_hide_cb,
1314
 
                                (gpointer) cheese_window);
1315
 
        gtk_notebook_set_current_page (GTK_NOTEBOOK (cheese_window->notebook_bar), 1);
1316
 
      }
1317
 
    }
1318
 
    else
1319
 
    {
1320
 
      cheese_window_countdown_picture_cb (cheese_window);
1321
 
    }
1322
 
 
1323
 
    gtk_widget_set_sensitive (cheese_window->take_picture, FALSE);
1324
 
    gtk_widget_set_sensitive (cheese_window->take_picture_fullscreen, FALSE);
1325
 
 
1326
 
    /* FIXME: set menu inactive */
 
1364
 
 
1365
    if (countdown && repeat_delay < 5000)
 
1366
    {
 
1367
      /* A countdown takes 4 seconds, leave some headroom before repeating it.
 
1368
       * Magic number chosen via expiriment on Netbook */
 
1369
      repeat_delay = 5000;
 
1370
    }
 
1371
 
 
1372
    g_timeout_add (repeat_delay, &cheese_window_take_burst_photo, cheese_window);
1327
1373
  }
1328
1374
  else if (cheese_window->webcam_mode == WEBCAM_MODE_VIDEO)
1329
1375
  {
1395
1441
static const GtkRadioActionEntry action_entries_toggle[] = {
1396
1442
  {"Photo", NULL, N_("_Photo"), NULL, NULL, 0},
1397
1443
  {"Video", NULL, N_("_Video"), NULL, NULL, 1},
 
1444
  {"Burst", NULL, N_("_Burst"), NULL, NULL, 2},
1398
1445
};
1399
1446
 
1400
1447
static const GtkActionEntry action_entries_file[] = {
1409
1456
};
1410
1457
 
1411
1458
static const GtkActionEntry action_entries_photo[] = {
1412
 
  {"TakePhoto", NULL, N_("_Take a photo"), "space", NULL, G_CALLBACK (cheese_window_action_button_clicked_cb)},
 
1459
  {"TakePhoto", NULL, N_("_Take a Photo"), "space", NULL, G_CALLBACK (cheese_window_action_button_clicked_cb)},
1413
1460
};
1414
1461
 
1415
1462
static const GtkToggleActionEntry action_entries_video[] = {
1416
1463
  {"TakeVideo", NULL, N_("_Recording"), "space", NULL, G_CALLBACK (cheese_window_action_button_clicked_cb), FALSE},
1417
1464
};
1418
1465
 
 
1466
static const GtkActionEntry action_entries_burst[] = {
 
1467
  {"TakeBurst", NULL, N_("_Take multiple Photos"), "space", NULL, G_CALLBACK (cheese_window_action_button_clicked_cb)},
 
1468
};
 
1469
 
1419
1470
static const GtkActionEntry action_entries_account_photo[] = {
1420
1471
  {"SetAsAccountPhoto", NULL, N_("_Set As Account Photo"), NULL, NULL, G_CALLBACK (cheese_window_cmd_set_about_me_photo)},
1421
1472
};
1452
1503
    gtk_label_set_use_markup (GTK_LABEL (cheese_window->label_take_photo_fullscreen), TRUE);
1453
1504
    gtk_action_group_set_sensitive (cheese_window->actions_photo, TRUE);
1454
1505
    gtk_action_group_set_sensitive (cheese_window->actions_video, FALSE);
 
1506
    gtk_action_group_set_sensitive (cheese_window->actions_burst, FALSE);
 
1507
  }
 
1508
  else if (strcmp (gtk_action_get_name (GTK_ACTION (current)), "Burst") == 0)
 
1509
  {
 
1510
    cheese_window->webcam_mode = WEBCAM_MODE_BURST;
 
1511
 
 
1512
    str = g_strconcat ("<b>", _("_Take multiple Photos"), "</b>", NULL);
 
1513
    gtk_label_set_text_with_mnemonic (GTK_LABEL (cheese_window->label_take_photo), g_strdup (str));
 
1514
    gtk_label_set_use_markup (GTK_LABEL (cheese_window->label_take_photo), TRUE);
 
1515
    gtk_label_set_text_with_mnemonic (GTK_LABEL (cheese_window->label_take_photo_fullscreen), g_strdup (str));
 
1516
    gtk_label_set_use_markup (GTK_LABEL (cheese_window->label_take_photo_fullscreen), TRUE);
 
1517
    gtk_action_group_set_sensitive (cheese_window->actions_burst, TRUE);
 
1518
    gtk_action_group_set_sensitive (cheese_window->actions_video, FALSE);
 
1519
    gtk_action_group_set_sensitive (cheese_window->actions_photo, FALSE);
1455
1520
  }
1456
1521
  else
1457
1522
  {
1464
1529
    gtk_label_set_use_markup (GTK_LABEL (cheese_window->label_take_photo_fullscreen), TRUE);
1465
1530
    gtk_action_group_set_sensitive (cheese_window->actions_photo, FALSE);
1466
1531
    gtk_action_group_set_sensitive (cheese_window->actions_video, TRUE);
 
1532
    gtk_action_group_set_sensitive (cheese_window->actions_burst, FALSE);
1467
1533
  }
1468
1534
  g_free (str);
1469
1535
}
1517
1583
 
1518
1584
static void
1519
1585
cheese_window_set_info_bar (CheeseWindow *cheese_window,
1520
 
                                GtkWidget    *info_bar)
 
1586
                            GtkWidget    *info_bar)
1521
1587
{
1522
1588
  if (cheese_window->info_bar == info_bar)
1523
1589
    return;
1565
1631
  cheese_window->button_effects              = GTK_WIDGET (gtk_builder_get_object (builder, "button_effects"));
1566
1632
  cheese_window->button_photo                = GTK_WIDGET (gtk_builder_get_object (builder, "button_photo"));
1567
1633
  cheese_window->button_video                = GTK_WIDGET (gtk_builder_get_object (builder, "button_video"));
 
1634
  cheese_window->button_burst                = GTK_WIDGET (gtk_builder_get_object (builder, "button_burst"));
1568
1635
  cheese_window->image_take_photo            = GTK_WIDGET (gtk_builder_get_object (builder, "image_take_photo"));
1569
1636
  cheese_window->label_effects               = GTK_WIDGET (gtk_builder_get_object (builder, "label_effects"));
1570
1637
  cheese_window->label_photo                 = GTK_WIDGET (gtk_builder_get_object (builder, "label_photo"));
1587
1654
  cheese_window->button_effects_fullscreen   = GTK_WIDGET (gtk_builder_get_object (builder, "button_effects_fullscreen"));
1588
1655
  cheese_window->button_photo_fullscreen     = GTK_WIDGET (gtk_builder_get_object (builder, "button_photo_fullscreen"));
1589
1656
  cheese_window->button_video_fullscreen     = GTK_WIDGET (gtk_builder_get_object (builder, "button_video_fullscreen"));
 
1657
  cheese_window->button_burst_fullscreen     = GTK_WIDGET (gtk_builder_get_object (builder, "button_burst_fullscreen"));
1590
1658
  cheese_window->take_picture_fullscreen     = GTK_WIDGET (gtk_builder_get_object (builder, "take_picture_fullscreen"));
1591
1659
  cheese_window->label_take_photo_fullscreen =
1592
1660
    GTK_WIDGET (gtk_builder_get_object (builder, "label_take_photo_fullscreen"));
1674
1742
 
1675
1743
  gtk_widget_realize (cheese_window->screen);
1676
1744
  GdkWindow *win = gtk_widget_get_window (cheese_window->screen);
1677
 
  if (!gdk_window_ensure_native (win)) {
 
1745
  if (!gdk_window_ensure_native (win))
 
1746
  {
1678
1747
    /* FIXME: this breaks offscreen stuff, we should really find
1679
1748
     * another way to embed video that doesn't require an XID */
 
1749
 
1680
1750
    /* abort: no native window, no xoverlay, no cheese. */
1681
1751
    g_error ("Could not create a native X11 window for the drawing area");
1682
1752
  }
1726
1796
                                                                        action_entries_video,
1727
1797
                                                                        G_N_ELEMENTS (action_entries_video));
1728
1798
  gtk_action_group_set_sensitive (cheese_window->actions_video, FALSE);
 
1799
  cheese_window->actions_burst = cheese_window_action_group_new (cheese_window,
 
1800
                                                                 "ActionsBurst",
 
1801
                                                                 action_entries_burst,
 
1802
                                                                 G_N_ELEMENTS (action_entries_burst));
 
1803
  gtk_action_group_set_sensitive (cheese_window->actions_burst, FALSE);
1729
1804
  cheese_window->actions_account_photo = cheese_window_action_group_new (cheese_window,
1730
1805
                                                                         "ActionsAccountPhoto",
1731
1806
                                                                         action_entries_account_photo,
1837
1912
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (cheese_window->button_video), action);
1838
1913
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (cheese_window->button_video_fullscreen), action);
1839
1914
 
 
1915
  action = gtk_ui_manager_get_action (cheese_window->ui_manager, "/MainMenu/Cheese/Burst");
 
1916
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (cheese_window->button_burst), action);
 
1917
  gtk_activatable_set_related_action (GTK_ACTIVATABLE (cheese_window->button_burst_fullscreen), action);
 
1918
 
1840
1919
 
1841
1920
  /* Default handlers for closing the application */
1842
1921
  g_signal_connect (cheese_window->window, "destroy",