Permalink
Browse files

Changes: Desktop implementation

  • Loading branch information...
1 parent e1aeb8c commit 4e2bf0993ee49c1512bbc7307aa10d3eb1b69dd6 Mohammad Anwari committed Mar 9, 2012
Showing with 139 additions and 0 deletions.
  1. +2 −0 src/Makefile.am
  2. +12 −0 src/panel-button.vala
  3. +57 −0 src/panel-desktop-html.vala
  4. +46 −0 src/panel-desktop.vala
  5. +2 −0 system/desktop.css
  6. +11 −0 system/desktop.html
  7. +9 −0 system/desktop.js
View
2 src/Makefile.am
@@ -30,6 +30,8 @@ blankon_panel_SOURCES = panel-item.vala \
panel-menu-html.vala \
panel-xdg-data.vala \
panel-user.vala \
+ panel-desktop.vala \
+ panel-desktop-html.vala \
$(NULL)
blankon_panel_VALAFLAGS = \
View
12 src/panel-button.vala
@@ -36,6 +36,10 @@ public class PanelButtonWindow : PanelAbstractWindow {
}
});
+ // Desktop
+ var d = new PanelDesktop ();
+ d.show ();
+
// Window
var w = new PanelWindowHost ();
w.show();
@@ -70,6 +74,14 @@ public class PanelButtonWindow : PanelAbstractWindow {
}
});
+ d.button_press_event.connect (() => {
+ stdout.printf("xxx\n");
+ if (menu_box.visible) {
+ menu_box.try_hide ();
+ }
+ return false;
+ });
+
w.windows_visible.connect (() => {
if (menu_box.visible) {
menu_box.try_hide ();
View
57 src/panel-desktop-html.vala
@@ -0,0 +1,57 @@
+using Gtk;
+using WebKit;
+using JSCore;
+
+public class PanelDesktopHTML: WebView {
+ string background_image = "cc";
+ unowned JSCore.GlobalContext context = null;
+ bool lastBgInitialized = false;
+
+ string translate_uri (string old) {
+ var uri = old.replace("http://system", "file://" + Config.SYSTEM_PATH + "/");
+ return uri;
+ }
+
+ public PanelDesktopHTML () {
+ var settings = new WebSettings();
+ settings.enable_file_access_from_file_uris = true;
+ settings.enable_universal_access_from_file_uris = true;
+ set_settings(settings);
+
+
+ resource_request_starting.connect((frame, resource, request, response) => {
+ var uri = translate_uri (resource.uri);
+ request.set_uri(uri);
+ });
+
+ window_object_cleared.connect ((frame, context) => {
+ this.context = (JSCore.GlobalContext) context;
+ set_background(background_image);
+ });
+
+
+ load_uri ("http://system/desktop.html");
+ }
+
+ public void set_background (string? bg) {
+ if (bg == null) {
+ return;
+ }
+ if (context != null) {
+ if (lastBgInitialized == false) {
+ var g = context.get_global_object ();
+ var key = new String.with_utf8_c_string ("lastBg");
+ var value = new String.with_utf8_c_string (bg);
+ var js_value = new JSCore.Value.string (context, value);
+ g.set_property (context, key, js_value, 0, null);
+ lastBgInitialized = true;
+ }
+
+ var s = new String.with_utf8_c_string ("updateBackground('%s');".printf(bg));
+
+ context.evaluate_script (s, null, null, 0, null);
+ }
+ background_image = bg;
+ }
+}
+
View
46 src/panel-desktop.vala
@@ -0,0 +1,46 @@
+using Gtk;
+using Cairo;
+using GMenu;
+
+
+public class PanelDesktop: PanelAbstractWindow {
+
+ const string BG_KEY = "picture-uri";
+ PanelDesktopHTML desktop;
+ GLib.Settings settings = null;
+
+ public PanelDesktop() {
+ settings = new GLib.Settings ("org.gnome.desktop.background");
+ desktop = new PanelDesktopHTML ();
+ desktop.show ();
+ set_type_hint (Gdk.WindowTypeHint.DESKTOP);
+
+ var screen = Gdk.Screen.get_default ();
+ var root = screen.get_root_window ();
+ set_size_request (root.get_width (), root.get_height ());
+ add (desktop);
+
+ move (0, 0);
+ show_all ();
+
+ settings.changed[BG_KEY].connect(() => {
+ set_background ();
+ });
+
+ map_event.connect (() => {
+ set_background ();
+ return true;
+ });
+
+ }
+
+ void set_background () {
+ try {
+ var bg = settings.get_string (BG_KEY);
+ desktop.set_background (bg);
+ } catch (Error e) {
+ }
+
+ }
+}
+
View
2 system/desktop.css
@@ -0,0 +1,2 @@
+body {
+}
View
11 system/desktop.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<link rel="stylesheet" href="desktop.css" />
+
+<script type="text/javascript" src="jq.js"></script>
+<script type="text/javascript" src="desktop.js"></script>
+</head>
+<body>
+</body>
+</html>
View
9 system/desktop.js
@@ -0,0 +1,9 @@
+// lastBg is defined initially in the backend
+
+function updateBackground(bg) {
+ $("body").css("background-image", "url(" + bg + ")");
+ lastBg = bg;
+}
+$(document).ready(function() {
+ updateBackground(lastBg);
+});

0 comments on commit 4e2bf09

Please sign in to comment.