Revision: 1738
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1738&view=rev
Author:   phantom_sf
Date:     2007-10-26 17:03:16 -0700 (Fri, 26 Oct 2007)

Log Message:
-----------
2007-10-27 P.G. Richardson <phantom_sf at users.sourceforge.net>

  * src/display_coverart.c
  * data/gtkpod.glade

  Improved the preview fullsize artwork dialog. Now scales the
  image to respect the size of the desktop, while displaying
  the true resolution in a label below it. Preview dialog now
  constructed in glade file rather than from scratch.

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog_detailed
    gtkpod/trunk/data/gtkpod.glade
    gtkpod/trunk/src/display_coverart.c

Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed     2007-10-25 10:15:20 UTC (rev 1737)
+++ gtkpod/trunk/ChangeLog_detailed     2007-10-27 00:03:16 UTC (rev 1738)
@@ -1,3 +1,13 @@
+2007-10-27 P.G. Richardson <phantom_sf at users.sourceforge.net>
+
+  * src/display_coverart.c
+  * data/gtkpod.glade
+
+  Improved the preview fullsize artwork dialog. Now scales the
+  image to respect the size of the desktop, while displaying
+  the true resolution in a label below it. Preview dialog now
+  constructed in glade file rather than from scratch.
+
 2007-10-21 P.G. Richardson <phantom_sf at users.sourceforge.net>
 
   * src/fetchcover.c

Modified: gtkpod/trunk/data/gtkpod.glade
===================================================================
--- gtkpod/trunk/data/gtkpod.glade      2007-10-25 10:15:20 UTC (rev 1737)
+++ gtkpod/trunk/data/gtkpod.glade      2007-10-27 00:03:16 UTC (rev 1738)
@@ -20446,4 +20446,100 @@
   </child>
 </widget>
 
+<widget class="GtkDialog" id="coverart_preview_dialog">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">Artwork Preview</property>
+  <property name="type">GTK_WINDOW_POPUP</property>
+  <property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
+  <property name="modal">True</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="icon_name">gtk-dialog-info</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="focus_on_map">True</property>
+  <property name="urgency_hint">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox3">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="dialog-action_area3">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+         <child>
+           <widget class="GtkButton" id="okbutton2">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-ok</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">-5</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkVBox" id="coverart_preview_dialog_vbox">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <placeholder/>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="coverart_preview_dialog_res_lbl">
+             <property name="visible">True</property>
+             <property name="label" 
translatable="yes">&lt;b&gt;Resolution:&lt;/b&gt;</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">True</property>
+             <property name="justify">GTK_JUSTIFY_CENTER</property>
+             <property name="wrap">True</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+             <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+             <property name="width_chars">-1</property>
+             <property name="single_line_mode">False</property>
+             <property name="angle">0</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+             <property name="pack_type">GTK_PACK_END</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>

Modified: gtkpod/trunk/src/display_coverart.c
===================================================================
--- gtkpod/trunk/src/display_coverart.c 2007-10-25 10:15:20 UTC (rev 1737)
+++ gtkpod/trunk/src/display_coverart.c 2007-10-27 00:03:16 UTC (rev 1738)
@@ -677,9 +677,7 @@
  */
 void coverart_display_big_artwork ()
 {
-       GtkWidget *dialog;
        Cover_Item *cover;
-       GdkPixbuf *imgbuf = NULL;
        ExtraTrackData *etd;
        
        cover = g_ptr_array_index(cdwidget->cdcovers, IMG_MAIN);
@@ -688,17 +686,31 @@
        if (cover->album == NULL)
                return;
        
+       GladeXML *preview_xml;
+       GtkWidget *dialog;
+       GtkWidget *canvasbox;
+       GtkWidget *res_label;
+       GdkPixbuf *imgbuf = NULL;
+       GdkPixbuf *scaled = NULL;
+       gchar *text;
+       
+       preview_xml = glade_xml_new (xml_file, "coverart_preview_dialog", NULL);
+       
+       dialog = gtkpod_xml_get_widget (preview_xml, "coverart_preview_dialog");
+       canvasbox = gtkpod_xml_get_widget (preview_xml, 
"coverart_preview_dialog_vbox");
+       res_label = gtkpod_xml_get_widget (preview_xml, 
"coverart_preview_dialog_res_lbl");
+       g_return_if_fail (dialog);
+       g_return_if_fail (canvasbox);
+       g_return_if_fail (res_label);
+       
+       /* Set the dialog parent */
+       gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW 
(gtkpod_window));
+       
        /* Set the dialog title */
-       gchar *text = g_strconcat (cover->album->artist, ": ", 
cover->album->albumname, NULL);
-       dialog = gtk_dialog_new_with_buttons (  text,
-                                                                               
                                                                                
                                                                                
                        GTK_WINDOW (gtkpod_xml_get_widget (main_window_xml, 
"gtkpod")),
-                                                                               
                                                                                
                                                                                
                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                                               
                                                                                
                                                                                
                        GTK_STOCK_CLOSE,
-                                                                               
                                                                                
                                                                                
                        GTK_RESPONSE_CLOSE,
-                                                                               
                                                                                
                                                                                
                        NULL);
-       
+       text = g_strconcat (cover->album->artist, ": ", 
cover->album->albumname, NULL);
+       gtk_window_set_title (GTK_WINDOW(dialog), text);
        g_free (text);
-       
+               
        Track *track;
        track = g_list_nth_data (cover->album->tracks, 0);
        etd = track->userdata;
@@ -708,9 +720,6 @@
                imgbuf = gdk_pixbuf_new_from_file (etd->thumb_path_locale, 
&error);
                if (error != NULL)
                {
-                       /*
-                       printf("Error occurred loading the image file - \nCode: 
%d\nMessage: %s\n", error->code, error->message);
-                       */
                        g_error_free (error);
                }
        }
@@ -728,8 +737,29 @@
        gint pixheight = gdk_pixbuf_get_height (imgbuf);
        gint pixwidth = gdk_pixbuf_get_width (imgbuf);
        
-       gtk_window_resize ( GTK_WINDOW(dialog), pixwidth, pixheight + 40);
+       /* Set the resolution in the label */
+       gchar *resvalues = (gchar *) g_malloc (sizeof(gint) + (sizeof(gchar) * 
3) + sizeof(gint));
+       g_sprintf (resvalues, "%d x %d", pixwidth, pixheight);
+       text = g_markup_printf_escaped ("<b>Image Dimensions: %s</b>", 
resvalues);
+       gtk_label_set_markup (GTK_LABEL (res_label), text);
+       g_free (text);
        
+       gint scrheight = gdk_screen_height() - 100;
+       gint scrwidth = gdk_screen_width() - 100;
+       
+       gdouble ratio = (gdouble) pixwidth / (gdouble) pixheight;
+       if (pixwidth > scrwidth)
+       {
+               pixwidth = scrwidth;
+               pixheight = pixwidth / ratio;
+       }
+       
+       if (pixheight > scrheight)
+       {
+               pixheight = scrheight;
+               pixwidth = pixheight * ratio;
+       }
+       
        GnomeCanvas *canvas;
        canvas = GNOME_CANVAS (gnome_canvas_new());
        gtk_widget_set_size_request ( GTK_WIDGET(canvas),
@@ -743,11 +773,13 @@
        canvasitem = gnome_canvas_item_new(     gnome_canvas_root(canvas),
                                                                                
                                                                                
                                                                                
                                GNOME_TYPE_CANVAS_PIXBUF, NULL);
        
+       scaled = gdk_pixbuf_scale_simple (imgbuf, pixwidth, pixheight, 
GDK_INTERP_NEAREST);
+       
        /* Apply the image to the canvas */
        gnome_canvas_item_set ( canvasitem,
-                                                                               
                                                                                
                "pixbuf", imgbuf);
+                                                                               
                                                                                
                "pixbuf", scaled);
 
-       gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), 
GTK_WIDGET(canvas));
+       gtk_box_pack_start_defaults (GTK_BOX(canvasbox), GTK_WIDGET (canvas));
        
        /* Unreference pixbuf if it is not pointing to
         * the album's artwork
@@ -762,6 +794,7 @@
        gtk_dialog_run (GTK_DIALOG(dialog));
        
        /* Destroy the dialog as no longer required */
+       gdk_pixbuf_unref (scaled);
        gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to