3131#include <gio/gdesktopappinfo.h>
3232#include <X11/XKBlib.h>
3333#include <gdk/gdkkeysyms.h>
34+ #include <cairo-gobject.h>
3435
3536#include <eel/eel-glib-extensions.h>
3637
5455};
5556enum
5657{
57- COLUMN_AUTORUN_PIXBUF ,
58+ COLUMN_AUTORUN_SURFACE ,
5859 COLUMN_AUTORUN_NAME ,
5960 COLUMN_AUTORUN_APP_INFO ,
6061 COLUMN_AUTORUN_X_CONTENT_TYPE ,
@@ -467,7 +468,7 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
467468 GAppInfo * default_app_info ;
468469 GtkListStore * list_store ;
469470 GtkTreeIter iter ;
470- GdkPixbuf * pixbuf ;
471+ cairo_surface_t * surface ;
471472 int icon_size , icon_scale ;
472473 int set_active ;
473474 int n ;
@@ -495,7 +496,7 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
495496 num_apps = g_list_length (app_info_list );
496497
497498 list_store = gtk_list_store_new (5 ,
498- GDK_TYPE_PIXBUF ,
499+ CAIRO_GOBJECT_TYPE_SURFACE ,
499500 G_TYPE_STRING ,
500501 G_TYPE_APP_INFO ,
501502 G_TYPE_STRING ,
@@ -505,76 +506,84 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
505506 if (num_apps == 0 )
506507 {
507508 gtk_list_store_append (list_store , & iter );
508- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
509- "dialog-error" ,
510- icon_size ,
511- 0 ,
512- NULL );
509+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
510+ "dialog-error" ,
511+ icon_size ,
512+ icon_scale ,
513+ NULL ,
514+ 0 ,
515+ NULL );
513516
514517 /* TODO: integrate with PackageKit-mate to find applications */
515518
516519 gtk_list_store_set (list_store , & iter ,
517- COLUMN_AUTORUN_PIXBUF , pixbuf ,
520+ COLUMN_AUTORUN_SURFACE , surface ,
518521 COLUMN_AUTORUN_NAME , _ ("No applications found" ),
519522 COLUMN_AUTORUN_APP_INFO , NULL ,
520523 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
521524 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_ASK ,
522525 -1 );
523- g_object_unref ( pixbuf );
526+ cairo_surface_destroy ( surface );
524527 }
525528 else
526529 {
527530 if (include_ask )
528531 {
529532 gtk_list_store_append (list_store , & iter );
530- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
531- "dialog-question" ,
532- icon_size ,
533- 0 ,
534- NULL );
533+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
534+ "dialog-question" ,
535+ icon_size ,
536+ icon_scale ,
537+ NULL ,
538+ 0 ,
539+ NULL );
535540 gtk_list_store_set (list_store , & iter ,
536- COLUMN_AUTORUN_PIXBUF , pixbuf ,
541+ COLUMN_AUTORUN_SURFACE , surface ,
537542 COLUMN_AUTORUN_NAME , _ ("Ask what to do" ),
538543 COLUMN_AUTORUN_APP_INFO , NULL ,
539544 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
540545 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_ASK ,
541546 -1 );
542- g_object_unref ( pixbuf );
547+ cairo_surface_destroy ( surface );
543548 }
544549
545550 gtk_list_store_append (list_store , & iter );
546- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
547- "window-close" ,
548- icon_size ,
549- 0 ,
550- NULL );
551+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
552+ "window-close" ,
553+ icon_size ,
554+ icon_scale ,
555+ NULL ,
556+ 0 ,
557+ NULL );
551558 gtk_list_store_set (list_store , & iter ,
552- COLUMN_AUTORUN_PIXBUF , pixbuf ,
559+ COLUMN_AUTORUN_SURFACE , surface ,
553560 COLUMN_AUTORUN_NAME , _ ("Do Nothing" ),
554561 COLUMN_AUTORUN_APP_INFO , NULL ,
555562 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
556563 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_IGNORE ,
557564 -1 );
558- g_object_unref ( pixbuf );
565+ cairo_surface_destroy ( surface );
559566
560567 gtk_list_store_append (list_store , & iter );
561- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
562- "folder-open" ,
563- icon_size ,
564- 0 ,
565- NULL );
568+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
569+ "folder-open" ,
570+ icon_size ,
571+ icon_scale ,
572+ NULL ,
573+ 0 ,
574+ NULL );
566575 gtk_list_store_set (list_store , & iter ,
567- COLUMN_AUTORUN_PIXBUF , pixbuf ,
576+ COLUMN_AUTORUN_SURFACE , surface ,
568577 COLUMN_AUTORUN_NAME , _ ("Open Folder" ),
569578 COLUMN_AUTORUN_APP_INFO , NULL ,
570579 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
571580 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_OPEN_FOLDER ,
572581 -1 );
573- g_object_unref ( pixbuf );
582+ cairo_surface_destroy ( surface );
574583
575584 gtk_list_store_append (list_store , & iter );
576585 gtk_list_store_set (list_store , & iter ,
577- COLUMN_AUTORUN_PIXBUF , NULL ,
586+ COLUMN_AUTORUN_SURFACE , NULL ,
578587 COLUMN_AUTORUN_NAME , NULL ,
579588 COLUMN_AUTORUN_APP_INFO , NULL ,
580589 COLUMN_AUTORUN_X_CONTENT_TYPE , NULL ,
@@ -595,22 +604,22 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
595604
596605 icon = g_app_info_get_icon (app_info );
597606 icon_info = caja_icon_info_lookup (icon , icon_size , icon_scale );
598- pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info , icon_size );
607+ surface = caja_icon_info_get_surface_at_size (icon_info , icon_size );
599608 g_object_unref (icon_info );
600609
601610 open_string = g_strdup_printf (_ ("Open %s" ), g_app_info_get_display_name (app_info ));
602611
603612 gtk_list_store_append (list_store , & iter );
604613 gtk_list_store_set (list_store , & iter ,
605- COLUMN_AUTORUN_PIXBUF , pixbuf ,
614+ COLUMN_AUTORUN_SURFACE , surface ,
606615 COLUMN_AUTORUN_NAME , open_string ,
607616 COLUMN_AUTORUN_APP_INFO , app_info ,
608617 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
609618 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_APP ,
610619 -1 );
611- if (pixbuf != NULL )
620+ if (surface != NULL )
612621 {
613- g_object_unref ( pixbuf );
622+ cairo_surface_destroy ( surface );
614623 }
615624 g_free (open_string );
616625
@@ -625,27 +634,29 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
625634 {
626635 gtk_list_store_append (list_store , & iter );
627636 gtk_list_store_set (list_store , & iter ,
628- COLUMN_AUTORUN_PIXBUF , NULL ,
637+ COLUMN_AUTORUN_SURFACE , NULL ,
629638 COLUMN_AUTORUN_NAME , NULL ,
630639 COLUMN_AUTORUN_APP_INFO , NULL ,
631640 COLUMN_AUTORUN_X_CONTENT_TYPE , NULL ,
632641 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_SEP ,
633642 -1 );
634643
635644 gtk_list_store_append (list_store , & iter );
636- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
637- "application-x-executable" ,
638- icon_size ,
639- 0 ,
640- NULL );
645+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
646+ "application-x-executable" ,
647+ icon_size ,
648+ icon_scale ,
649+ NULL ,
650+ 0 ,
651+ NULL );
641652 gtk_list_store_set (list_store , & iter ,
642- COLUMN_AUTORUN_PIXBUF , pixbuf ,
653+ COLUMN_AUTORUN_SURFACE , surface ,
643654 COLUMN_AUTORUN_NAME , _ ("Open with other Application..." ),
644655 COLUMN_AUTORUN_APP_INFO , NULL ,
645656 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
646657 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_OTHER_APP ,
647658 -1 );
648- g_object_unref ( pixbuf );
659+ cairo_surface_destroy ( surface );
649660 }
650661
651662 if (default_app_info != NULL )
@@ -662,7 +673,7 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
662673 renderer = gtk_cell_renderer_pixbuf_new ();
663674 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box ), renderer , FALSE);
664675 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box ), renderer ,
665- "pixbuf " , COLUMN_AUTORUN_PIXBUF ,
676+ "surface " , COLUMN_AUTORUN_SURFACE ,
666677 NULL );
667678 renderer = gtk_cell_renderer_text_new ();
668679 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box ), renderer , TRUE);
@@ -934,6 +945,7 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
934945 char * mount_name ;
935946 GIcon * icon ;
936947 GdkPixbuf * pixbuf ;
948+ cairo_surface_t * surface ;
937949 CajaIconInfo * icon_info ;
938950 int icon_size , icon_scale ;
939951 gboolean user_forced_dialog ;
@@ -1002,9 +1014,10 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
10021014 icon_scale = gtk_widget_get_scale_factor (dialog );
10031015 icon_info = caja_icon_info_lookup (icon , icon_size , icon_scale );
10041016 pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info , icon_size );
1017+ surface = caja_icon_info_get_surface_at_size (icon_info , icon_size );
10051018 g_object_unref (icon_info );
10061019 g_object_unref (icon );
1007- image = gtk_image_new_from_pixbuf ( pixbuf );
1020+ image = gtk_image_new_from_surface ( surface );
10081021 gtk_widget_set_halign (image , GTK_ALIGN_CENTER );
10091022 gtk_widget_set_valign (image , GTK_ALIGN_START );
10101023 gtk_box_pack_start (GTK_BOX (hbox ), image , TRUE, TRUE, 0 );
@@ -1013,6 +1026,7 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
10131026 gtk_window_set_icon (GTK_WINDOW (dialog ), pixbuf );
10141027 gtk_window_set_position (GTK_WINDOW (dialog ), GTK_WIN_POS_CENTER );
10151028 g_object_unref (pixbuf );
1029+ cairo_surface_destroy (surface );
10161030
10171031 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL , 12 );
10181032 gtk_box_pack_start (GTK_BOX (hbox ), vbox , TRUE, TRUE, 0 );
@@ -1138,13 +1152,15 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
11381152 {
11391153 GtkWidget * eject_image ;
11401154 eject_button = gtk_button_new_with_mnemonic (_ ("_Eject" ));
1141- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
1142- "media-eject" ,
1143- caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON ),
1144- 0 ,
1145- NULL );
1146- eject_image = gtk_image_new_from_pixbuf (pixbuf );
1147- g_object_unref (pixbuf );
1155+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
1156+ "media-eject" ,
1157+ caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON ),
1158+ icon_scale ,
1159+ NULL ,
1160+ 0 ,
1161+ NULL );
1162+ eject_image = gtk_image_new_from_surface (surface );
1163+ cairo_surface_destroy (surface );
11481164 gtk_button_set_image (GTK_BUTTON (eject_button ), eject_image );
11491165 data -> should_eject = TRUE;
11501166 }
0 commit comments