Revision: 1776
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1776&view=rev
Author:   phantom_sf
Date:     2007-11-12 14:38:00 -0800 (Mon, 12 Nov 2007)

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

  * data/gtkpod.glade
  * src/prefs.c
  * src/prefs_window.c
  
  Preference added for controlling display of delete confirmation
  dialog in display_photo window for removal of a photo album.
  
  * src/display_photo.c
  * src/diaplay_photo.h
  
  Rename action added for renaming a photo album.
  Dialog altered in remove album function so that on clicking
  "Yes Do Not Display Again", the preference is set to stop the
  dialog displaying again.
  
  * src/context_menus.c
  
  Popup menuitem for photo album rename action.

  * data/gphoto_playlist_icon-48.png
  * data/tunes_playlist_icon-48.png
  * data/Makefile.am
  * src/stock_icons.c
  * src/stock_icons.h
  * src/Makefile.am
  * src/misc.c
  
  Stock icons created from image files for use as playlist icons.
  stockid_init() is called from misc.c upon loading of application.
  This finds the correct paths of the specified icon images and loads
  pixbufs of them. These are then added to the default stock factory.
  Stock ids of these images can then be used throughout the application.
  
  * src/display_playlists.c
  
  Uses the new stock ids for the playlist icons.

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog_detailed
    gtkpod/trunk/data/Makefile.am
    gtkpod/trunk/data/gtkpod.glade
    gtkpod/trunk/src/Makefile.am
    gtkpod/trunk/src/context_menus.c
    gtkpod/trunk/src/display_coverart.c
    gtkpod/trunk/src/display_photo.c
    gtkpod/trunk/src/display_photo.h
    gtkpod/trunk/src/display_playlists.c
    gtkpod/trunk/src/misc.c
    gtkpod/trunk/src/prefs.c
    gtkpod/trunk/src/prefs_window.c

Added Paths:
-----------
    gtkpod/trunk/data/gphoto_playlist_icon-48.png
    gtkpod/trunk/data/tunes_playlist_icon-48.png
    gtkpod/trunk/src/stock_icons.c
    gtkpod/trunk/src/stock_icons.h

Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed     2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/ChangeLog_detailed     2007-11-12 22:38:00 UTC (rev 1776)
@@ -1,3 +1,42 @@
+2007-11-12 P.G. Richardson <phantom_sf at users.sourceforge.net>
+
+  * data/gtkpod.glade
+  * src/prefs.c
+  * src/prefs_window.c
+  
+  Preference added for controlling display of delete confirmation
+  dialog in display_photo window for removal of a photo album.
+  
+  * src/display_photo.c
+  * src/diaplay_photo.h
+  
+  Rename action added for renaming a photo album.
+  Dialog altered in remove album function so that on clicking
+  "Yes Do Not Display Again", the preference is set to stop the
+  dialog displaying again.
+  
+  * src/context_menus.c
+  
+  Popup menuitem for photo album rename action.
+
+  * data/gphoto_playlist_icon-48.png
+  * data/tunes_playlist_icon-48.png
+  * data/Makefile.am
+  * src/stock_icons.c
+  * src/stock_icons.h
+  * src/Makefile.am
+  * src/misc.c
+  
+  Stock icons created from image files for use as playlist icons.
+  stockid_init() is called from misc.c upon loading of application.
+  This finds the correct paths of the specified icon images and loads
+  pixbufs of them. These are then added to the default stock factory.
+  Stock ids of these images can then be used throughout the application.
+  
+  * src/display_playlists.c
+  
+  Uses the new stock ids for the playlist icons.
+
 2007-11-07 P.G. Richardson <phantom_sf at users.sourceforge.net>
 
   * data/gphoto*.png

Modified: gtkpod/trunk/data/Makefile.am
===================================================================
--- gtkpod/trunk/data/Makefile.am       2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/data/Makefile.am       2007-11-12 22:38:00 UTC (rev 1776)
@@ -26,7 +26,9 @@
        gphoto_images_menuitem-32.png  \
        gphoto_images_menuitem-48.png  \
        gphoto_tools_menuitem-32.png   \
-       gphoto_tools_menuitem-48.png
+       gphoto_tools_menuitem-48.png   \
+       gphoto_playlist_icon-48.png    \
+       tunes_playlist_icon-48.png
 
 EXTRA_DIST =                           \
        $(desktop_in_files)             \

Added: gtkpod/trunk/data/gphoto_playlist_icon-48.png
===================================================================
(Binary files differ)


Property changes on: gtkpod/trunk/data/gphoto_playlist_icon-48.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: gtkpod/trunk/data/gtkpod.glade
===================================================================
--- gtkpod/trunk/data/gtkpod.glade      2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/data/gtkpod.glade      2007-11-12 22:38:00 UTC (rev 1776)
@@ -12255,6 +12255,27 @@
                                      <property name="fill">False</property>
                                    </packing>
                                  </child>
+
+                                 <child>
+                                   <widget class="GtkCheckButton" 
id="photo_library_confirm_delete_toggle">
+                                     <property name="visible">True</property>
+                                     <property name="can_focus">True</property>
+                                     <property name="label" 
translatable="yes">Check before removing photos from a photo album whether
+they should be deleted from the Photo Database.</property>
+                                     <property 
name="use_underline">True</property>
+                                     <property 
name="relief">GTK_RELIEF_NORMAL</property>
+                                     <property 
name="focus_on_click">True</property>
+                                     <property name="active">False</property>
+                                     <property 
name="inconsistent">False</property>
+                                     <property 
name="draw_indicator">True</property>
+                                     <signal name="toggled" 
handler="on_photo_library_confirm_delete_toggled" last_modification_time="Fri, 
09 Nov 2007 01:03:03 GMT"/>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
                                </widget>
                                <packing>
                                  <property name="padding">0</property>

Added: gtkpod/trunk/data/tunes_playlist_icon-48.png
===================================================================
(Binary files differ)


Property changes on: gtkpod/trunk/data/tunes_playlist_icon-48.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: gtkpod/trunk/src/Makefile.am
===================================================================
--- gtkpod/trunk/src/Makefile.am        2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/Makefile.am        2007-11-12 22:38:00 UTC (rev 1776)
@@ -48,6 +48,7 @@
     prefs_window.c prefs_window.h \
     repository.c repository.h \
     sha1.c sha1.h \
+    stock_icons.c stock_icons.h \
     syncdir.c syncdir.h \
     tools.c tools.h \
     wavfile.c wavfile.h

Modified: gtkpod/trunk/src/context_menus.c
===================================================================
--- gtkpod/trunk/src/context_menus.c    2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/context_menus.c    2007-11-12 22:38:00 UTC (rev 1776)
@@ -908,6 +908,16 @@
                        NULL);
 }
 
+GtkWidget *gphoto_menuitem_rename_photoalbum_item(GtkWidget *menu)
+{
+       return hookup_mi (
+                       menu, 
+                       _("Rename Album"),
+                       GTK_STOCK_DELETE, 
+                       G_CALLBACK (gphoto_rename_selected_album), 
+                       NULL);
+}
+
 void create_context_menu (CM_type type)
 {
     static GtkWidget *menu = NULL;
@@ -1082,6 +1092,7 @@
                        break;
        case CM_PH_AV:
                        gphoto_menuitem_remove_album_from_db_item (menu);
+                       gphoto_menuitem_rename_photoalbum_item (menu);
                        break;
        case CM_PH_IV:
                        gphoto_menuitem_remove_photo_from_album_item (menu);

Modified: gtkpod/trunk/src/display_coverart.c
===================================================================
--- gtkpod/trunk/src/display_coverart.c 2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/display_coverart.c 2007-11-12 22:38:00 UTC (rev 1776)
@@ -208,7 +208,8 @@
     
   if(error != NULL)
   {    
-               printf("Error occurred loading file - \nCode: %d\nMessage: 
%s\n", error->code, error->message); 
+               printf("Error occurred loading file - \nCode: %d\nMessage: 
%s\n", error->code, error->message);
+               g_error_free (error);
                g_return_if_fail (image);
        }
 

Modified: gtkpod/trunk/src/display_photo.c
===================================================================
--- gtkpod/trunk/src/display_photo.c    2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/display_photo.c    2007-11-12 22:38:00 UTC (rev 1776)
@@ -39,6 +39,8 @@
 
 #define DEBUG 0
 
+#define PHOTO_YES_DONT_DISPLAY_RESPONSE 1
+
 /* Array recording the current pages of the sorttabs so they can be redisplayed
  * if another playlist is selected.
  */
@@ -172,6 +174,8 @@
        /* Set the reference to the photo database */
        eitdb->photodb = db;
        /*printf ("Reference to photo db successfully set\n");*/
+       
+       /* A photo database is */
 }
 
 /**
@@ -185,13 +189,8 @@
  */
 gboolean gphoto_ipod_supports_photos(iTunesDB *itdb)
 {
-       gboolean status =itdb_device_supports_photo (itdb->device);
-/*
-       if (status)
-               printf ("device supports photos\n");
-       else
-               printf ("photos not supported\n");
-*/
+       gboolean status = itdb_device_supports_photo (itdb->device);
+       
        return status;
 }
 
@@ -862,7 +861,8 @@
        /* Find the selected album. If no selection then returns the Main Album 
*/
        selected_album = itdb_photodb_photoalbum_by_name (photodb, album_name);
        g_return_if_fail (selected_album);
-
+       g_free (album_name);
+       
        if (selected_album->album_type == 0x01)
        {
                gtkpod_warning (_("The Photo Library album cannot be removed"));
@@ -870,36 +870,57 @@
        }
 
        gboolean remove_pics = FALSE;
-       if (g_list_length (selected_album->members) > 0)
+       if (g_list_length (selected_album->members) <= 0)
+               return;
+       
+       if (prefs_get_int("photo_library_confirm_delete") == FALSE)
        {
+               /* User has chosen to assume yes and not display a confirm 
dialog */
+               remove_pics = TRUE;
+       }
+       else
+       {
                /* Display a dialog asking if the user wants the photos removed 
as well */
                gint result;
                GtkWindow *parent = GTK_WINDOW (gtkpod_xml_get_widget 
(main_window_xml, "gtkpod"));
                GtkWidget *dialog = gtk_message_dialog_new (parent,
                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                GTK_MESSAGE_QUESTION,
-                               GTK_BUTTONS_YES_NO,
+                               GTK_BUTTONS_NONE,
                                _("Do you want to remove the album's photos 
too?"));
-
+                       gtk_dialog_add_buttons (
+                               GTK_DIALOG (dialog),
+                               GTK_STOCK_YES, GTK_RESPONSE_YES,
+                               GTK_STOCK_NO, GTK_RESPONSE_NO,
+                               GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+                               _("Yes. Do Not Display Again"), 
PHOTO_YES_DONT_DISPLAY_RESPONSE,
+                               NULL);
+       
                result = gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
 
                switch (result)
                {
+                       case PHOTO_YES_DONT_DISPLAY_RESPONSE:
+                               prefs_set_int("photo_library_confirm_delete", 
FALSE);
                        case GTK_RESPONSE_YES:
                                remove_pics = TRUE;
                                break;
+                               case GTK_RESPONSE_NO:
+                               remove_pics = FALSE;
+                               break;
+                       case GTK_RESPONSE_CANCEL:
+                               return;
                        default:
                                break;
                }
        }
+       
        album_model = gtk_tree_view_get_model (album_view);
        gtk_list_store_remove (GTK_LIST_STORE(album_model), &iter);
 
        itdb_photodb_photoalbum_remove (photodb, selected_album, remove_pics);
 
-       g_free (album_name);
-
        /* Display the default Photo Library */
        gphoto_build_thumbnail_model (NULL);
 
@@ -963,6 +984,70 @@
        signal_data_changed ();
 }
 
+/**
+ * gphoto_rename_selected_album
+ *
+ * Remove the selected image from the album
+ * 
+ */
+void gphoto_rename_selected_album ()
+{
+       gchar *album_name= NULL;
+       PhotoAlbum *selected_album;
+       GtkTreeSelection *selection;
+       /* Get the currently selected album */
+       selection = gtk_tree_view_get_selection (album_view);
+       album_name= gphoto_get_selected_album_name (selection);
+       /* Find the selected album. If no selection then returns the Main Album 
*/
+       selected_album = itdb_photodb_photoalbum_by_name (photodb, album_name);
+       g_return_if_fail (selected_album);
+       
+       if (selected_album->album_type == 0x01)
+       {
+               /* Dont rename the Photo Library */
+               return;
+       }
+       
+       gchar *new_album_name = get_user_string (
+                       _("New Photo Album Name"),
+                       _("Please enter a new name for the photo album"), 
+                       NULL, 
+                       NULL, 
+                       NULL);
+       if (new_album_name == NULL|| strlen (new_album_name) == 0)
+               return;
+       
+       /* Check an album with this name doesnt already exist */
+       PhotoAlbum *curr_album;
+       curr_album = itdb_photodb_photoalbum_by_name (photodb, new_album_name);
+       if (curr_album != NULL)
+       {
+               gtkpod_warning (_("An album with that name already exists."));
+               g_free (new_album_name);
+               return;
+       }
+       
+       /* Rename the album in the database */
+       selected_album->name = g_strdup (new_album_name);
+       
+       /* Update the row in the album view */
+       GtkTreeModel *album_model;
+       GtkTreeIter iter;
+       
+       album_model = gtk_tree_view_get_model (album_view);
+       if (gtk_tree_selection_get_selected (selection, &album_model, &iter) == 
TRUE)
+       {
+               gtk_list_store_set (GTK_LIST_STORE(album_model), &iter, 
COL_ALBUM_NAME, new_album_name, -1);;
+       }
+               
+       g_free (new_album_name);
+       
+       signal_data_changed();
+       
+       /* Using the existing selection, reselect the album so it reloads the 
preview of the first image */
+       gphoto_album_selection_changed (selection, NULL);
+}
+
 /* When right mouse button is pressed on one of the widgets,
  * a popup menu is displayed.
  */
@@ -1165,63 +1250,7 @@
  */
 void on_photodb_rename_album_menuItem_activate (GtkMenuItem *menuItem, 
gpointer user_data)
 {
-       gchar *album_name= NULL;
-       PhotoAlbum *selected_album;
-       GtkTreeSelection *selection;
-
-       /* Get the currently selected album */
-       selection = gtk_tree_view_get_selection (album_view);
-       album_name= gphoto_get_selected_album_name (selection);
-
-       /* Find the selected album. If no selection then returns the Main Album 
*/
-       selected_album = itdb_photodb_photoalbum_by_name (photodb, album_name);
-       g_return_if_fail (selected_album);
-       
-       if (selected_album->album_type == 0x01)
-       {
-               /* Dont rename the Photo Library */
-               return;
-       }
-       
-       gchar *new_album_name = get_user_string (
-                       _("New Photo Album Name"),
-                       _("Please enter a new name for the photo album"), 
-                       NULL, 
-                       NULL, 
-                       NULL);
-
-       if (new_album_name == NULL|| strlen (new_album_name) == 0)
-               return;
-
-       /* Check an album with this name doesnt already exist */
-       PhotoAlbum *curr_album;
-       curr_album = itdb_photodb_photoalbum_by_name (photodb, new_album_name);
-       if (curr_album != NULL)
-       {
-               gtkpod_warning (_("An album with that name already exists."));
-               g_free (new_album_name);
-               return;
-       }
-       
-       /* Rename the album in the database */
-       selected_album->name = g_strdup (new_album_name);
-       
-       /* Update the row in the album view */
-       GtkTreeModel *album_model;
-       GtkTreeIter iter;
-       
-       album_model = gtk_tree_view_get_model (album_view);
-       if (gtk_tree_selection_get_selected (selection, &album_model, &iter) == 
TRUE)
-       {
-               gtk_list_store_set (GTK_LIST_STORE(album_model), &iter, 
COL_ALBUM_NAME, new_album_name, -1);;
-       }
-       
-       g_free (new_album_name);
-       
-       signal_data_changed();
-       
-       /* Using the existing selection, reselect the album so it reloads the 
preview of the first image */
-       gphoto_album_selection_changed (selection, NULL);
+       gphoto_rename_selected_album ();
 }
 
 /* -----------------------------------------------------------*/

Modified: gtkpod/trunk/src/display_photo.h
===================================================================
--- gtkpod/trunk/src/display_photo.h    2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/display_photo.h    2007-11-12 22:38:00 UTC (rev 1776)
@@ -61,6 +61,6 @@
 
 void gphoto_remove_selected_photos_from_album (gboolean show_dialogs);
 void gphoto_remove_album_from_database ();
+void gphoto_rename_selected_album ();
 
-
 #endif /*DISPLAY_PHOTO_H_*/

Modified: gtkpod/trunk/src/display_playlists.c
===================================================================
--- gtkpod/trunk/src/display_playlists.c        2007-11-10 15:25:46 UTC (rev 
1775)
+++ gtkpod/trunk/src/display_playlists.c        2007-11-12 22:38:00 UTC (rev 
1776)
@@ -41,6 +41,7 @@
 #include "info.h"
 #include "context_menus.h"
 #include "display_photo.h"
+#include "stock_icons.h"
 
 /* pointer to the treeview for the playlist display */
 static GtkTreeView *playlist_treeview = NULL;
@@ -1994,14 +1995,14 @@
        }
        else if (!itdb_playlist_is_mpl (playlist))
        {
-           if (gphoto_is_photo_playlist (playlist))
-           {
-               stock_id = GTK_STOCK_SELECT_COLOR;
-           }
-           else
-           {
-               stock_id = GTK_STOCK_JUSTIFY_LEFT;
-           }
+               if (gphoto_is_photo_playlist (playlist))
+               {
+                       stock_id = GPHOTO_PLAYLIST_ICON_STOCK_ID;
+               }
+               else
+               {
+                       stock_id = TUNES_PLAYLIST_ICON_STOCK_ID;
+               }
        }
        else
        {

Modified: gtkpod/trunk/src/misc.c
===================================================================
--- gtkpod/trunk/src/misc.c     2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/misc.c     2007-11-12 22:38:00 UTC (rev 1776)
@@ -46,8 +46,8 @@
 #include "prefs.h"
 #include "misc_track.h"
 #include "display_photo.h"
+#include "stock_icons.h"
 
-
 #define DEBUG_MISC 0
 
 
@@ -1945,6 +1945,7 @@
     prefs_init (argc, argv); 
 
     coverart_init (argv[0]);
+    stockid_init (argv[0]);
 
     file_convert_init ();
 

Modified: gtkpod/trunk/src/prefs.c
===================================================================
--- gtkpod/trunk/src/prefs.c    2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/prefs.c    2007-11-12 22:38:00 UTC (rev 1776)
@@ -173,6 +173,7 @@
     prefs_set_int("show_duplicates", TRUE);
     prefs_set_int("show_non_updated", TRUE);
     prefs_set_int("show_updated", TRUE);
+    prefs_set_int("photo_library_confirm_delete", TRUE);
     prefs_set_int("mserv_report_probs", TRUE);
     prefs_set_int("delete_ipod", TRUE);
     prefs_set_int("delete_file", TRUE);

Modified: gtkpod/trunk/src/prefs_window.c
===================================================================
--- gtkpod/trunk/src/prefs_window.c     2007-11-10 15:25:46 UTC (rev 1775)
+++ gtkpod/trunk/src/prefs_window.c     2007-11-12 22:38:00 UTC (rev 1776)
@@ -757,6 +757,11 @@
     w = gtkpod_xml_get_widget (prefs_window_xml, 
"cfg_track_database_deletion");
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
                                 prefs_get_int("delete_database"));
+    
+    w = gtkpod_xml_get_widget (prefs_window_xml, 
"photo_library_confirm_delete_toggle");
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
+                                prefs_get_int("photo_library_confirm_delete"));
+        
 
 #if 0
     /* last.fm -- disabled, we'll hide the prefs window */
@@ -1407,6 +1412,13 @@
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), active);
 }
 
+void
+on_photo_library_confirm_delete_toggled (GtkToggleButton *togglebutton,
+    gpointer         user_data)
+{
+       temp_prefs_set_int(temp_prefs, "photo_library_confirm_delete",
+                            gtk_toggle_button_get_active(togglebutton));
+}
 
 void
 on_charset_combo_entry_changed          (GtkEditable     *editable,

Added: gtkpod/trunk/src/stock_icons.c
===================================================================
--- gtkpod/trunk/src/stock_icons.c                              (rev 0)
+++ gtkpod/trunk/src/stock_icons.c      2007-11-12 22:38:00 UTC (rev 1776)
@@ -0,0 +1,144 @@
+/*
+ |Copyright (C) 2007 P.G. Richardson <phantom_sf at users.sourceforge.net>
+ |Part of the gtkpod project.
+ | 
+ |URL: http://www.gtkpod.org/
+ |URL: http://gtkpod.sourceforge.net/
+ |
+ |This program is free software; you can redistribute it and/or modify
+ |it under the terms of the GNU General Public License as published by
+ |the Free Software Foundation; either version 2 of the License, or
+ |(at your option) any later version.
+ |
+ |This program is distributed in the hope that it will be useful,
+ |but WITHOUT ANY WARRANTY; without even the implied warranty of
+ |MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
+ |GNU General Public License for more details.
+ |
+ |You should have received a copy of the GNU General Public License
+ |along with this program; if not, write to the Free Software
+ |Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ |
+ |iTunes and iPod are trademarks of Apple
+ |
+ |This product is not supported/written/published by Apple!
+ |
+ */
+
+#include "stock_icons.h"
+
+static void register_stock_icon (gchar *path, int stockid);
+
+/**
+ * stockid_init
+ *
+ * Initialises paths used for gtkpod specific icons.
+ * This needs to be loaded early as it uses the path
+ * of the binary to determine where to load the file from, in the
+ * same way as main() determines where to load the glade file
+ * from.
+ *
+ * @progpath: path of the gtkpod binary being loaded.
+ *  
+ */
+void stockid_init (gchar *progpath)
+{
+       gchar *progname;
+       
+       progname = g_find_program_in_path (progpath);
+
+       if (progname)
+       {
+               static const gchar *SEPsrcSEPgtkpod = G_DIR_SEPARATOR_S "src" 
G_DIR_SEPARATOR_S "gtkpod";
+               
+               if (!g_path_is_absolute (progname))
+               {
+                       gchar *cur_dir = g_get_current_dir ();
+                       gchar *prog_absolute;
+
+                       if (g_str_has_prefix (progname, "." G_DIR_SEPARATOR_S))
+                               prog_absolute = g_build_filename (cur_dir, 
progname+2, NULL);
+                       else
+                               prog_absolute = g_build_filename (cur_dir, 
progname, NULL);
+                       
+                       g_free (progname);
+                       g_free (cur_dir);
+                       progname = prog_absolute;
+               }
+               
+               if (g_str_has_suffix (progname, SEPsrcSEPgtkpod))
+               {
+                       gchar *suffix = g_strrstr (progname, SEPsrcSEPgtkpod);
+                       
+                       if (suffix)
+                       {
+                               *suffix = 0;
+                               GPHOTO_PLAYLIST_ICON_PATH = g_build_filename 
(progname, "data", "gphoto_playlist_icon-48.png", NULL);
+                               TUNE_PLAYLIST_ICON_PATH = g_build_filename 
(progname, "data", "tunes_playlist_icon-48.png", NULL);
+                       }
+               }
+               
+               g_free (progname);
+               
+               /* Photo playlist icon */
+               if (GPHOTO_PLAYLIST_ICON_PATH && !g_file_test 
(GPHOTO_PLAYLIST_ICON_PATH, G_FILE_TEST_EXISTS))
+               {
+                       g_free (GPHOTO_PLAYLIST_ICON_PATH);
+                       GPHOTO_PLAYLIST_ICON_PATH = NULL;
+               }
+                               
+               if (!GPHOTO_PLAYLIST_ICON_PATH)
+               {
+                       GPHOTO_PLAYLIST_ICON_PATH = g_build_filename 
(PACKAGE_DATA_DIR, PACKAGE, "data", "gphoto_playlist_icon.png", NULL);
+               }
+               
+               /* Normal Playlist icon */
+               if (TUNE_PLAYLIST_ICON_PATH && !g_file_test 
(TUNE_PLAYLIST_ICON_PATH, G_FILE_TEST_EXISTS))
+               {
+                       g_free (TUNE_PLAYLIST_ICON_PATH);
+                       TUNE_PLAYLIST_ICON_PATH = NULL;
+               }
+                                               
+               if (!TUNE_PLAYLIST_ICON_PATH)
+               {
+                       TUNE_PLAYLIST_ICON_PATH = g_build_filename 
(PACKAGE_DATA_DIR, PACKAGE, "data", "tunes_playlist_icon-48.png", NULL);
+               }
+               
+               register_stock_icon (GPHOTO_PLAYLIST_ICON_PATH, 
GPHOTO_PLAYLIST_ICON_STOCK_ID);
+               register_stock_icon (TUNE_PLAYLIST_ICON_PATH, 
TUNES_PLAYLIST_ICON_STOCK_ID);
+       }
+}
+
+/**
+ * register_stock_icons
+ *
+ * Add pixbuf images to the default icon factory for use
+ * as stock items should they be required.
+ *  
+ */
+static void register_stock_icon (gchar *path, int stockid)
+{
+        GError *error = NULL;
+        GdkPixbuf *image;
+               
+        g_return_if_fail (path);
+        
+        image = gdk_pixbuf_new_from_file (path, &error);
+         
+        if(error != NULL)
+        {      
+                printf("Error occurred loading photo icon - \nCode: 
%d\nMessage: %s\n", error->code, error->message); 
+                g_error_free (error);
+                g_return_if_fail (image);
+        }
+        
+        GtkIconSet *pl_iconset = gtk_icon_set_new_from_pixbuf (image);
+        GtkIconFactory *factory = gtk_icon_factory_new ();
+        gtk_icon_factory_add (
+                        factory, 
+                        stockid,
+                        pl_iconset);
+        gtk_icon_factory_add_default (factory);
+        
+        gdk_pixbuf_unref (image);
+}

Added: gtkpod/trunk/src/stock_icons.h
===================================================================
--- gtkpod/trunk/src/stock_icons.h                              (rev 0)
+++ gtkpod/trunk/src/stock_icons.h      2007-11-12 22:38:00 UTC (rev 1776)
@@ -0,0 +1,47 @@
+/*
+|  Copyright (C) 2007 P.G. Richardson <phantom_sf at users.sourceforge.net>
+|  Part of the gtkpod project.
+| 
+|  URL: http://www.gtkpod.org/
+|  URL: http://gtkpod.sourceforge.net/
+| 
+|  This program is free software; you can redistribute it and/or modify
+|  it under the terms of the GNU General Public License as published by
+|  the Free Software Foundation; either version 2 of the License, or
+|  (at your option) any later version.
+| 
+|  This program is distributed in the hope that it will be useful,
+|  but WITHOUT ANY WARRANTY; without even the implied warranty of
+|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+|  GNU General Public License for more details.
+| 
+|  You should have received a copy of the GNU General Public License
+|  along with this program; if not, write to the Free Software
+|  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+| 
+|  iTunes and iPod are trademarks of Apple
+| 
+|  This product is not supported/written/published by Apple!
+|
+*/
+
+#ifndef STOCK_ICONS_H_
+#define STOCK_ICONS_H_
+
+#ifdef HAVE_CONFIG_H
+       #include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/* Stock IDs */
+#define GPHOTO_PLAYLIST_ICON_STOCK_ID "gtkpod-gphoto-playlist-icon"
+#define TUNES_PLAYLIST_ICON_STOCK_ID "gtkpod-tunes-playlist-icon"
+
+/* Icon File Paths */
+gchar *GPHOTO_PLAYLIST_ICON_PATH;
+gchar *TUNE_PLAYLIST_ICON_PATH;
+
+void stockid_init (gchar *progpath);
+
+#endif /*STOCK_ICONS_H_*/


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