brasero r757 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r757 - in trunk: . src
- Date: Tue, 22 Apr 2008 14:56:01 +0100 (BST)
Author: philippr
Date: Tue Apr 22 13:56:01 2008
New Revision: 757
URL: http://svn.gnome.org/viewvc/brasero?rev=757&view=rev
Log:
Add a preview (when enabled) to GtkFileChooserDialog displayed when there isn\'t any sidebar.
* src/brasero-player.c (brasero_player_create_controls_stream),
(brasero_player_create_controls_image),
(brasero_player_size_allocate), (brasero_player_class_init):
* src/brasero-project.c (brasero_project_preview_ready),
(brasero_project_update_preview), (brasero_project_add_uris_cb):
Modified:
trunk/ChangeLog
trunk/src/brasero-player.c
trunk/src/brasero-project.c
Modified: trunk/src/brasero-player.c
==============================================================================
--- trunk/src/brasero-player.c (original)
+++ trunk/src/brasero-player.c Tue Apr 22 13:56:01 2008
@@ -405,14 +405,27 @@
0);
player->priv->size = gtk_label_new (NULL);
- gtk_label_set_justify (GTK_LABEL (player->priv->size), GTK_JUSTIFY_RIGHT);
- gtk_misc_set_alignment (GTK_MISC (player->priv->size), 1.0, 0.0);
- gtk_box_pack_start (GTK_BOX (header_box),
- player->priv->size,
- FALSE,
- FALSE,
- 0);
+ if (GTK_WIDGET (player)->allocation.width > GTK_WIDGET (player)->allocation.height) {
+ gtk_label_set_justify (GTK_LABEL (player->priv->size), GTK_JUSTIFY_RIGHT);
+ gtk_misc_set_alignment (GTK_MISC (player->priv->size), 1.0, 0.0);
+
+ gtk_box_pack_start (GTK_BOX (header_box),
+ player->priv->size,
+ FALSE,
+ FALSE,
+ 0);
+ }
+ else {
+ gtk_label_set_justify (GTK_LABEL (player->priv->size), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment (GTK_MISC (player->priv->size), 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (player->priv->controls),
+ player->priv->size,
+ FALSE,
+ FALSE,
+ 0);
+ }
+
/* second line : play, progress, volume button */
box = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (player->priv->controls),
@@ -440,6 +453,7 @@
player->priv->progress = gtk_hscale_new_with_range (0, 1, 500000000);
gtk_scale_set_digits (GTK_SCALE (player->priv->progress), 0);
gtk_scale_set_draw_value (GTK_SCALE (player->priv->progress), FALSE);
+ gtk_widget_set_size_request (player->priv->progress, 80, -1);
gtk_range_set_update_policy (GTK_RANGE (player->priv->progress), GTK_UPDATE_CONTINUOUS);
gtk_box_pack_start (GTK_BOX (box),
player->priv->progress,
@@ -664,11 +678,18 @@
player->priv->controls = gtk_vbox_new (FALSE, 4);
- gtk_box_pack_end (GTK_BOX (player->priv->hbox),
- player->priv->controls,
- TRUE,
- TRUE,
- 0);
+ if (GTK_WIDGET (player)->allocation.width > GTK_WIDGET (player)->allocation.height)
+ gtk_box_pack_end (GTK_BOX (player->priv->hbox),
+ player->priv->controls,
+ TRUE,
+ TRUE,
+ 0);
+ else
+ gtk_box_pack_end (GTK_BOX (player->priv->vbox),
+ player->priv->controls,
+ TRUE,
+ TRUE,
+ 0);
player->priv->header = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (player->priv->header), 0.0, 0.5);
@@ -1160,6 +1181,55 @@
}
static void
+brasero_player_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ BraseroPlayer *player;
+ GtkWidget *parent;
+
+ player = BRASERO_PLAYER (widget);
+ if (!player->priv->controls) {
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ return;
+ }
+
+ if (!player->priv->pixbuf) {
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ return;
+ }
+
+ parent = gtk_widget_get_parent (player->priv->controls);
+
+ g_object_ref (player->priv->controls);
+
+ if (allocation->width > allocation->height) {
+ if (parent != player->priv->hbox) {
+ gtk_container_remove (GTK_CONTAINER (player->priv->vbox), player->priv->controls);
+ gtk_box_pack_end (GTK_BOX (player->priv->hbox),
+ player->priv->controls,
+ TRUE,
+ TRUE,
+ 0);
+ }
+ }
+ else {
+ if (parent != player->priv->vbox) {
+ gtk_container_remove (GTK_CONTAINER (player->priv->hbox), player->priv->controls);
+ gtk_box_pack_end (GTK_BOX (player->priv->vbox),
+ player->priv->controls,
+ TRUE,
+ TRUE,
+ 0);
+ }
+ }
+
+ g_object_unref (player->priv->controls);
+ gtk_widget_show (player->priv->controls);
+
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+}
+
+static void
brasero_player_destroy (GtkObject *obj)
{
BraseroPlayer *player;
@@ -1240,10 +1310,15 @@
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
+ GtkWidgetClass *gtk_widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = brasero_player_finalize;
+
gtk_object_class->destroy = brasero_player_destroy;
+
+ gtk_widget_class->size_allocate = brasero_player_size_allocate;
+
brasero_player_signals [ERROR_SIGNAL] =
g_signal_new ("error",
G_TYPE_FROM_CLASS (klass),
Modified: trunk/src/brasero-project.c
==============================================================================
--- trunk/src/brasero-project.c (original)
+++ trunk/src/brasero-project.c Tue Apr 22 13:56:01 2008
@@ -59,6 +59,11 @@
#include "burn-debug.h"
#include "burn-session.h"
+
+#ifdef BUILD_PREVIEW
+#include "brasero-player.h"
+#endif
+
#include "brasero-project.h"
#include "brasero-jacket-edit.h"
#include "brasero-project-size.h"
@@ -243,6 +248,8 @@
#define KEY_DEFAULT_AUDIO_BURNING_APP "/desktop/gnome/volume_manager/autoburn_audio_cd_command"
#define KEY_ASK_DEFAULT_BURNING_APP "/apps/brasero/ask_default_app"
+#define BRASERO_KEY_SHOW_PREVIEW "/apps/brasero/display/preview"
+
#define BRASERO_PROJECT_VERSION "0.2"
GType
@@ -1419,6 +1426,26 @@
}
static void
+brasero_project_preview_ready (BraseroPlayer *player,
+ GtkFileChooser *chooser)
+{
+ gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
+}
+
+static void
+brasero_project_update_preview (GtkFileChooser *chooser,
+ BraseroPlayer *player)
+{
+ gchar *uri;
+
+ gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
+
+ uri = gtk_file_chooser_get_preview_uri (chooser);
+ brasero_player_set_uri (player, uri);
+ g_free (uri);
+}
+
+static void
brasero_project_add_uris_cb (GtkAction *action, BraseroProject *project)
{
GtkWidget *toplevel;
@@ -1479,6 +1506,39 @@
gtk_file_filter_set_name (filter, _("Image files only"));
gtk_file_filter_add_mime_type (filter, "image/*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (project->priv->chooser), filter);
+
+#ifdef BUILD_PREVIEW
+
+ GConfClient *client;
+ GtkWidget *player;
+ gboolean res;
+
+ client = gconf_client_get_default ();
+ res = gconf_client_get_bool (client, BRASERO_KEY_SHOW_PREVIEW, NULL);
+ g_object_unref (client);
+
+ if (!res)
+ return;
+
+ /* if preview is activated add it */
+ player = brasero_player_new ();
+
+ gtk_widget_show (player);
+ gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (project->priv->chooser), FALSE);
+ gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (project->priv->chooser), FALSE);
+ gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (project->priv->chooser), player);
+
+ g_signal_connect (project->priv->chooser,
+ "update-preview",
+ G_CALLBACK (brasero_project_update_preview),
+ player);
+
+ g_signal_connect (player,
+ "ready",
+ G_CALLBACK (brasero_project_preview_ready),
+ project->priv->chooser);
+#endif
+
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]