Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 2.06 KB | None | 0 0
  1. public class Application : Gtk.Window {
  2.  
  3.     private GtkClutter.Embed embed;
  4.    
  5.     public Application () {
  6.    
  7.    
  8.         //---------------------
  9.         // COMPILE WITH: valac --pkg clutter-gtk-1.0 --pkg gtk+-3.0 test.vala
  10.         //---------------------
  11.         // Problem: I want to see the dark background from the Gtk window through the loaded icon
  12.         //---------------------
  13.        
  14.         //Use dark theme!  
  15.         Gtk.Settings.get_default().gtk_application_prefer_dark_theme = true;
  16.  
  17.         this.window_position = Gtk.WindowPosition.CENTER;
  18.         this.set_default_size (350, 70);
  19.  
  20.         this.destroy.connect (() => {
  21.             Gtk.main_quit ();
  22.         });
  23.  
  24.         embed = new GtkClutter.Embed ();
  25.  
  26.         var stage = embed.get_stage () as Clutter.Stage;
  27.         var color = Clutter.Color().init(255,0,0,100);
  28.         //stage.background_color = color;
  29.         //stage.layout_manager = new Clutter.BinLayout();
  30.        
  31.         Gtk.IconTheme theme = Gtk.IconTheme.get_default();
  32.         Gdk.Pixbuf? pixbuf = theme.load_icon_for_scale("media-optical-cd-audio", 128, 1, 0);
  33.        
  34.         Clutter.Image image = new Clutter.Image();  
  35.         image.set_data(pixbuf.get_pixels(),
  36.                     pixbuf.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888,
  37.                     pixbuf.width, pixbuf.height, pixbuf.rowstride);
  38.        
  39.         var actor = new Clutter.Actor();
  40.         actor.content = image;
  41.         actor.set_size(pixbuf.width, pixbuf.height);
  42.        
  43.         stage.add_child(actor);
  44.         stage.opacity = 122;
  45.        
  46.         embed.opacity = 0.5;
  47.         embed.halign = Gtk.Align.START;
  48.         embed.valign = Gtk.Align.START;
  49.         embed.width_request = 100;
  50.         embed.height_request = 100;
  51.        
  52.         this.add(embed);
  53.        
  54.         stdout.printf("BG %s\n", stage.background_color_set?"Ja" : "NEIN");
  55.     }
  56.  
  57.     public static int main (string[] args) {
  58.         Gtk.init (ref args);
  59.         GtkClutter.init (ref args);
  60.         Application app = new Application ();
  61.         app.show_all ();
  62.         Gtk.main ();
  63.         return 0;
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement