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#include <eel/eel-stock-dialogs.h>
5556};
5657enum
5758{
58- COLUMN_AUTORUN_PIXBUF ,
59+ COLUMN_AUTORUN_SURFACE ,
5960 COLUMN_AUTORUN_NAME ,
6061 COLUMN_AUTORUN_APP_INFO ,
6162 COLUMN_AUTORUN_X_CONTENT_TYPE ,
@@ -468,7 +469,7 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
468469 GAppInfo * default_app_info ;
469470 GtkListStore * list_store ;
470471 GtkTreeIter iter ;
471- GdkPixbuf * pixbuf ;
472+ cairo_surface_t * surface ;
472473 int icon_size , icon_scale ;
473474 int set_active ;
474475 int n ;
@@ -496,7 +497,7 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
496497 num_apps = g_list_length (app_info_list );
497498
498499 list_store = gtk_list_store_new (5 ,
499- GDK_TYPE_PIXBUF ,
500+ CAIRO_GOBJECT_TYPE_SURFACE ,
500501 G_TYPE_STRING ,
501502 G_TYPE_APP_INFO ,
502503 G_TYPE_STRING ,
@@ -506,76 +507,84 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
506507 if (num_apps == 0 )
507508 {
508509 gtk_list_store_append (list_store , & iter );
509- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
510- "dialog-error" ,
511- icon_size ,
512- 0 ,
513- NULL );
510+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
511+ "dialog-error" ,
512+ icon_size ,
513+ icon_scale ,
514+ NULL ,
515+ 0 ,
516+ NULL );
514517
515518 /* TODO: integrate with PackageKit-mate to find applications */
516519
517520 gtk_list_store_set (list_store , & iter ,
518- COLUMN_AUTORUN_PIXBUF , pixbuf ,
521+ COLUMN_AUTORUN_SURFACE , surface ,
519522 COLUMN_AUTORUN_NAME , _ ("No applications found" ),
520523 COLUMN_AUTORUN_APP_INFO , NULL ,
521524 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
522525 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_ASK ,
523526 -1 );
524- g_object_unref ( pixbuf );
527+ cairo_surface_destroy ( surface );
525528 }
526529 else
527530 {
528531 if (include_ask )
529532 {
530533 gtk_list_store_append (list_store , & iter );
531- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
532- "dialog-question" ,
533- icon_size ,
534- 0 ,
535- NULL );
534+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
535+ "dialog-question" ,
536+ icon_size ,
537+ icon_scale ,
538+ NULL ,
539+ 0 ,
540+ NULL );
536541 gtk_list_store_set (list_store , & iter ,
537- COLUMN_AUTORUN_PIXBUF , pixbuf ,
542+ COLUMN_AUTORUN_SURFACE , surface ,
538543 COLUMN_AUTORUN_NAME , _ ("Ask what to do" ),
539544 COLUMN_AUTORUN_APP_INFO , NULL ,
540545 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
541546 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_ASK ,
542547 -1 );
543- g_object_unref ( pixbuf );
548+ cairo_surface_destroy ( surface );
544549 }
545550
546551 gtk_list_store_append (list_store , & iter );
547- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
548- "window-close" ,
549- icon_size ,
550- 0 ,
551- NULL );
552+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
553+ "window-close" ,
554+ icon_size ,
555+ icon_scale ,
556+ NULL ,
557+ 0 ,
558+ NULL );
552559 gtk_list_store_set (list_store , & iter ,
553- COLUMN_AUTORUN_PIXBUF , pixbuf ,
560+ COLUMN_AUTORUN_SURFACE , surface ,
554561 COLUMN_AUTORUN_NAME , _ ("Do Nothing" ),
555562 COLUMN_AUTORUN_APP_INFO , NULL ,
556563 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
557564 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_IGNORE ,
558565 -1 );
559- g_object_unref ( pixbuf );
566+ cairo_surface_destroy ( surface );
560567
561568 gtk_list_store_append (list_store , & iter );
562- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
563- "folder-open" ,
564- icon_size ,
565- 0 ,
566- NULL );
569+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
570+ "folder-open" ,
571+ icon_size ,
572+ icon_scale ,
573+ NULL ,
574+ 0 ,
575+ NULL );
567576 gtk_list_store_set (list_store , & iter ,
568- COLUMN_AUTORUN_PIXBUF , pixbuf ,
577+ COLUMN_AUTORUN_SURFACE , surface ,
569578 COLUMN_AUTORUN_NAME , _ ("Open Folder" ),
570579 COLUMN_AUTORUN_APP_INFO , NULL ,
571580 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
572581 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_OPEN_FOLDER ,
573582 -1 );
574- g_object_unref ( pixbuf );
583+ cairo_surface_destroy ( surface );
575584
576585 gtk_list_store_append (list_store , & iter );
577586 gtk_list_store_set (list_store , & iter ,
578- COLUMN_AUTORUN_PIXBUF , NULL ,
587+ COLUMN_AUTORUN_SURFACE , NULL ,
579588 COLUMN_AUTORUN_NAME , NULL ,
580589 COLUMN_AUTORUN_APP_INFO , NULL ,
581590 COLUMN_AUTORUN_X_CONTENT_TYPE , NULL ,
@@ -596,22 +605,22 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
596605
597606 icon = g_app_info_get_icon (app_info );
598607 icon_info = caja_icon_info_lookup (icon , icon_size , icon_scale );
599- pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info , icon_size );
608+ surface = caja_icon_info_get_surface_at_size (icon_info , icon_size );
600609 g_object_unref (icon_info );
601610
602611 open_string = g_strdup_printf (_ ("Open %s" ), g_app_info_get_display_name (app_info ));
603612
604613 gtk_list_store_append (list_store , & iter );
605614 gtk_list_store_set (list_store , & iter ,
606- COLUMN_AUTORUN_PIXBUF , pixbuf ,
615+ COLUMN_AUTORUN_SURFACE , surface ,
607616 COLUMN_AUTORUN_NAME , open_string ,
608617 COLUMN_AUTORUN_APP_INFO , app_info ,
609618 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
610619 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_APP ,
611620 -1 );
612- if (pixbuf != NULL )
621+ if (surface != NULL )
613622 {
614- g_object_unref ( pixbuf );
623+ cairo_surface_destroy ( surface );
615624 }
616625 g_free (open_string );
617626
@@ -626,27 +635,29 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
626635 {
627636 gtk_list_store_append (list_store , & iter );
628637 gtk_list_store_set (list_store , & iter ,
629- COLUMN_AUTORUN_PIXBUF , NULL ,
638+ COLUMN_AUTORUN_SURFACE , NULL ,
630639 COLUMN_AUTORUN_NAME , NULL ,
631640 COLUMN_AUTORUN_APP_INFO , NULL ,
632641 COLUMN_AUTORUN_X_CONTENT_TYPE , NULL ,
633642 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_SEP ,
634643 -1 );
635644
636645 gtk_list_store_append (list_store , & iter );
637- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
638- "application-x-executable" ,
639- icon_size ,
640- 0 ,
641- NULL );
646+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
647+ "application-x-executable" ,
648+ icon_size ,
649+ icon_scale ,
650+ NULL ,
651+ 0 ,
652+ NULL );
642653 gtk_list_store_set (list_store , & iter ,
643- COLUMN_AUTORUN_PIXBUF , pixbuf ,
654+ COLUMN_AUTORUN_SURFACE , surface ,
644655 COLUMN_AUTORUN_NAME , _ ("Open with other Application..." ),
645656 COLUMN_AUTORUN_APP_INFO , NULL ,
646657 COLUMN_AUTORUN_X_CONTENT_TYPE , x_content_type ,
647658 COLUMN_AUTORUN_ITEM_TYPE , AUTORUN_OTHER_APP ,
648659 -1 );
649- g_object_unref ( pixbuf );
660+ cairo_surface_destroy ( surface );
650661 }
651662
652663 if (default_app_info != NULL )
@@ -663,7 +674,7 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box,
663674 renderer = gtk_cell_renderer_pixbuf_new ();
664675 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box ), renderer , FALSE);
665676 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box ), renderer ,
666- "pixbuf " , COLUMN_AUTORUN_PIXBUF ,
677+ "surface " , COLUMN_AUTORUN_SURFACE ,
667678 NULL );
668679 renderer = gtk_cell_renderer_text_new ();
669680 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box ), renderer , TRUE);
@@ -935,6 +946,7 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
935946 char * mount_name ;
936947 GIcon * icon ;
937948 GdkPixbuf * pixbuf ;
949+ cairo_surface_t * surface ;
938950 CajaIconInfo * icon_info ;
939951 int icon_size , icon_scale ;
940952 gboolean user_forced_dialog ;
@@ -1003,9 +1015,10 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
10031015 icon_scale = gtk_widget_get_scale_factor (dialog );
10041016 icon_info = caja_icon_info_lookup (icon , icon_size , icon_scale );
10051017 pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info , icon_size );
1018+ surface = caja_icon_info_get_surface_at_size (icon_info , icon_size );
10061019 g_object_unref (icon_info );
10071020 g_object_unref (icon );
1008- image = gtk_image_new_from_pixbuf ( pixbuf );
1021+ image = gtk_image_new_from_surface ( surface );
10091022 gtk_widget_set_halign (image , GTK_ALIGN_CENTER );
10101023 gtk_widget_set_valign (image , GTK_ALIGN_START );
10111024 gtk_box_pack_start (GTK_BOX (hbox ), image , TRUE, TRUE, 0 );
@@ -1014,6 +1027,7 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
10141027 gtk_window_set_icon (GTK_WINDOW (dialog ), pixbuf );
10151028 gtk_window_set_position (GTK_WINDOW (dialog ), GTK_WIN_POS_CENTER );
10161029 g_object_unref (pixbuf );
1030+ cairo_surface_destroy (surface );
10171031
10181032 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL , 12 );
10191033 gtk_box_pack_start (GTK_BOX (hbox ), vbox , TRUE, TRUE, 0 );
@@ -1145,13 +1159,15 @@ do_autorun_for_content_type (GMount *mount, const char *x_content_type, CajaAuto
11451159 {
11461160 GtkWidget * eject_image ;
11471161 eject_button = gtk_button_new_with_mnemonic (_ ("_Eject" ));
1148- pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
1149- "media-eject" ,
1150- caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON ),
1151- 0 ,
1152- NULL );
1153- eject_image = gtk_image_new_from_pixbuf (pixbuf );
1154- g_object_unref (pixbuf );
1162+ surface = gtk_icon_theme_load_surface (gtk_icon_theme_get_default (),
1163+ "media-eject" ,
1164+ caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON ),
1165+ icon_scale ,
1166+ NULL ,
1167+ 0 ,
1168+ NULL );
1169+ eject_image = gtk_image_new_from_surface (surface );
1170+ cairo_surface_destroy (surface );
11551171 gtk_button_set_image (GTK_BUTTON (eject_button ), eject_image );
11561172 data -> should_eject = TRUE;
11571173 }
0 commit comments