Example #1
0
        public void UpdateEventLog()
        {
            if (HTML == null)
            {
                LayoutVertical.Remove(ScrolledWindow);
                Spinner = new SparkleSpinner(22);
                LayoutVertical.PackStart(Spinner, true, true, 0);
            }

            Thread thread = new Thread(new ThreadStart(delegate {
                GenerateHTML();
                AddHTML();
            }));

            thread.Start();
        }
Example #2
0
        public void UpdateEventLog()
        {
            if (HTML == null)               // TODO: there may be a race condition here

            {
                LogContent.Remove(LogContent.Child);
                Spinner = new SparkleSpinner(22);
                LogContent.Add(Spinner);
                LogContent.ShowAll();
            }

            Thread thread = new Thread(new ThreadStart(delegate {
                GenerateHTML();
                AddHTML();
            }));

            thread.Start();
        }
        public SparkleEventLog()
            : base("")
        {
            SetSizeRequest (480, (int) (Gdk.Screen.Default.Height * 0.8));

            int x = (int) (Gdk.Screen.Default.Width * 0.61);
            int y = (int) (Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5));

            Move (x, y);

            Resizable   = true;
            BorderWidth = 0;

            Title = "Recent Changes";
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            KeyPressEvent += delegate (object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) {

                    Controller.WindowClosed ();
                }
            };

            this.size_label = new Label () {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label () {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox (false, 12);
            layout_sizes.Add (this.size_label);
            layout_sizes.Add (this.history_label);

            VBox layout_vertical = new VBox (false, 0);
            this.spinner         = new SparkleSpinner (22);
            this.content_wrapper = new EventBox ();
            this.scrolled_window = new ScrolledWindow ();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse ("white", ref white);

            this.content_wrapper.ModifyBg (StateType.Normal, white);

            this.web_view = new WebView () {
                Editable = false
            };

            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add (this.web_view);
            this.content_wrapper.Add (this.spinner);

            this.spinner.Start ();

            this.layout_horizontal = new HBox (true, 0);
            this.layout_horizontal.PackStart (layout_sizes, true, true, 12);

            layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart (this.content_wrapper, true, true, 0);

            Add (layout_vertical);

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                    HideAll ();

                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                    ShowAll ();
                    Present ();
                });
            };

            Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
                Application.Invoke (delegate {
                    FileChooserDialog dialog = new FileChooserDialog ("Restore from History",
                        this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok);

                    dialog.CurrentName = file_name;
                    dialog.DoOverwriteConfirmation = true;
                    dialog.SetCurrentFolder (target_folder_path);

                    if (dialog.Run () == (int) ResponseType.Ok)
                        Controller.SaveDialogCompleted (dialog.Filename);
                    else
                        Controller.SaveDialogCancelled ();

                    dialog.Destroy ();
                });
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Application.Invoke (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
                Application.Invoke (delegate {
                    this.combo_box.Sensitive = enabled;
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                 Application.Invoke (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke (delegate {
                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);

                    this.content_wrapper.Add (this.spinner);
                    this.spinner.Start ();
                    this.content_wrapper.ShowAll ();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                Application.Invoke (delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll ();
                    this.history_label.ShowAll ();
                });
            };
        }
Example #4
0
        public SparkleEventLog()
        {
            Title                 = "Recent Changes";
            Height                = 640;
            Width                 = 480;
            ResizeMode            = ResizeMode.NoResize;
            Background            = new SolidColorBrush (Color.FromRgb (240, 240, 240));
            AllowsTransparency    = false;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            WriteOutImages ();

            Label size_label = new Label () {
                Content    = "Size:",
                FontWeight = FontWeights.Bold
            };

            this.size_label_value = new Label () {
                Content = Controller.Size
            };

            size_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
            Rect size_label_rect = new Rect (size_label.DesiredSize);

            Label history_label = new Label () {
                Content    = "History:",
                FontWeight = FontWeights.Bold
            };

            this.history_label_value = new Label () {
                Content = Controller.HistorySize,
            };

            history_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
            Rect history_label_rect = new Rect (history_label.DesiredSize);

            Shapes.Rectangle line = new Shapes.Rectangle () {
                Width  = Width,
                Height = 1,
                Fill   = new SolidColorBrush (Color.FromRgb (223, 223, 223))
            };

            Shapes.Rectangle background = new Shapes.Rectangle () {
                Width  = Width,
                Height = Height,
                Fill   = new SolidColorBrush (Color.FromRgb (250, 250, 250))
            };

            this.web_browser = new WebBrowser () {
                Width  = Width - 6,
                Height = Height - 36 - 11
            };

            this.web_browser.ObjectForScripting = new SparkleScriptingObject ();

            spinner = new SparkleSpinner (22);

            // Disable annoying IE clicking sound
            CoInternetSetFeatureEnabled (21, 0x00000002, true);

            this.canvas = new Canvas ();
            Content     = this.canvas;

            this.canvas.Children.Add (size_label);
            Canvas.SetLeft (size_label, 24);
            Canvas.SetTop (size_label, 4);

            this.canvas.Children.Add (this.size_label_value);
            Canvas.SetLeft (this.size_label_value, 22 + size_label_rect.Width);
            Canvas.SetTop (this.size_label_value, 4);

            this.canvas.Children.Add (history_label);
            Canvas.SetLeft (history_label, 130);
            Canvas.SetTop (history_label, 4);

            this.canvas.Children.Add (this.history_label_value);
            Canvas.SetLeft (this.history_label_value, 130 + history_label_rect.Width);
            Canvas.SetTop (this.history_label_value, 4);

            this.canvas.Children.Add (background);
            Canvas.SetLeft (background, 0);
            Canvas.SetTop (background, 36);

            this.canvas.Children.Add (spinner);
            Canvas.SetLeft (spinner, (Width / 2) - 15);
            Canvas.SetTop (spinner, (Height / 2) - 22);

            this.canvas.Children.Add (line);
            Canvas.SetLeft (line, 0);
            Canvas.SetTop (line, 35);

            Closing += Close;

            Controller.ShowWindowEvent += delegate {
               Dispatcher.Invoke ((Action) delegate {
                    Show ();
                    Activate ();
                    BringIntoView ();

                    UpdateContent (null);
                    UpdateChooser (null);
                });
            };

            Controller.HideWindowEvent += delegate {
                Dispatcher.Invoke ((Action) delegate {
                    Hide ();

                    if (this.canvas.Children.Contains (this.web_browser))
                        this.canvas.Children.Remove (this.web_browser);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                Dispatcher.Invoke ((Action) delegate {
                    this.size_label_value.Content = size;
                    this.size_label_value.UpdateLayout ();

                    this.history_label_value.Content = history_size;
                    this.history_label_value.UpdateLayout ();
                });
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Dispatcher.Invoke ((Action) delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                Dispatcher.Invoke ((Action) delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                this.spinner.Start ();

                if (this.canvas.Children.Contains (this.web_browser))
                    this.canvas.Children.Remove (this.web_browser);
            };
        }
Example #5
0
        public SparkleEventLog()
            : base("")
        {
            SetSizeRequest (480, 640);

            // TODO: right side of screen like on Mac
            SetPosition (WindowPosition.Center);

            Resizable   = true;
            BorderWidth = 0;

            Title = _("Recent Changes");
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            this.size_label = new Label () {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label () {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox (false, 12);
            layout_sizes.Add (this.size_label);
            layout_sizes.Add (this.history_label);

            VBox layout_vertical = new VBox (false, 0);
            this.spinner         = new SparkleSpinner (22);
            this.content_wrapper = new EventBox ();
            this.scrolled_window = new ScrolledWindow ();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse ("white", ref white);

            this.content_wrapper.ModifyBg (StateType.Normal, white);

            this.web_view = new WebView () {
                Editable = false
            };

            this.web_view.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) {
                this.link_status = args.Link;
            };

            this.web_view.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) {
                if (args.Request.Uri == this.link_status)
                    Controller.LinkClicked (args.Request.Uri);

                // Don't follow HREFs (as this would cause a page refresh)
                if (!args.Request.Uri.Equals ("file:"))
                    args.RetVal = 1;
            };

            this.scrolled_window.Add (this.web_view);
            this.content_wrapper.Add (this.spinner);

            this.spinner.Start ();

            this.layout_horizontal = new HBox (true, 0);
            this.layout_horizontal.PackStart (layout_sizes, true, true, 12);

            layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
            layout_vertical.PackStart (this.content_wrapper, true, true, 0);

            Add (layout_vertical);

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                    HideAll ();

                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                    ShowAll ();
                    Present ();
                });
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Application.Invoke (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                 Application.Invoke (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke (delegate {
                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);

                    this.content_wrapper.Add (this.spinner);
                    this.spinner.Start ();
                    this.content_wrapper.ShowAll ();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                Application.Invoke (delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll ();
                    this.history_label.ShowAll ();
                });
            };
        }
Example #6
0
        public void UpdateEventLog()
        {
            if (HTML == null) { // TODO: there may be a race condition here
                LogContent.Remove (LogContent.Child);
                Spinner = new SparkleSpinner (22);
                LogContent.Add (Spinner);
                LogContent.ShowAll ();
            }

            Thread thread = new Thread (new ThreadStart (delegate {
                GenerateHTML ();
                AddHTML ();
            }));

            thread.Start ();
        }
Example #7
0
        public SparkleEventLog()
            : base("")
        {
            SetSizeRequest (480, 640);

            int x = (int) (Gdk.Screen.Default.Width * 0.61);
            int y = (int) (Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5));

            Move (x, y);

            Resizable   = true;
            BorderWidth = 0;

            Title = _("Recent Changes");
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate (object o, DeleteEventArgs args) {
                Controller.WindowClosed ();
                args.RetVal = true;
            };

            this.size_label = new Label () {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label () {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox (false, 12);
            layout_sizes.Add (this.size_label);
            layout_sizes.Add (this.history_label);

            VBox layout_vertical = new VBox (false, 0);
            this.spinner         = new SparkleSpinner (22);
            this.content_wrapper = new EventBox ();
            this.scrolled_window = new ScrolledWindow ();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse ("white", ref white);

            this.content_wrapper.ModifyBg (StateType.Normal, white);

            this.web_view = new WebView () {
                Editable = false
            };

            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add (this.web_view);
            this.content_wrapper.Add (this.spinner);

            this.spinner.Start ();

            this.layout_horizontal = new HBox (true, 0);
            this.layout_horizontal.PackStart (layout_sizes, true, true, 12);

            layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
            layout_vertical.PackStart (this.content_wrapper, true, true, 0);

            Add (layout_vertical);

            Controller.HideWindowEvent += delegate {
                Application.Invoke (delegate {
                    HideAll ();

                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke (delegate {
                    ShowAll ();
                    Present ();
                });
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Application.Invoke (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                 Application.Invoke (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke (delegate {
                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);

                    this.content_wrapper.Add (this.spinner);
                    this.spinner.Start ();
                    this.content_wrapper.ShowAll ();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                Application.Invoke (delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll ();
                    this.history_label.ShowAll ();
                });
            };
        }
Example #8
0
        public void UpdateEventLog()
        {
            if (HTML == null) {

                LayoutVertical.Remove (ScrolledWindow);
                Spinner = new SparkleSpinner (22);
                LayoutVertical.PackStart (Spinner, true, true, 0);

            }

            Thread thread = new Thread (new ThreadStart (delegate {

                GenerateHTML ();
                AddHTML ();

            }));

            thread.Start ();
        }
Example #9
0
        public SparkleEventLog()
        {
            Title              = "Recent Changes";
            Height             = 640;
            Width              = 480;
            ResizeMode         = ResizeMode.NoResize; // TODO
            Background         = new SolidColorBrush(Color.FromRgb(240, 240, 240));
            AllowsTransparency = false;
            Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico");

            int x = (int)(SystemParameters.PrimaryScreenWidth * 0.61);
            int y = (int)(SystemParameters.PrimaryScreenHeight * 0.5 - (Height * 0.5));

            WindowStartupLocation = WindowStartupLocation.Manual;
            Left = x;
            Top  = y;

            WriteOutImages();

            Label size_label = new Label()
            {
                Content    = "Size:",
                FontWeight = FontWeights.Bold
            };

            this.size_label_value = new Label()
            {
                Content = Controller.Size
            };

            size_label.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            Rect size_label_rect = new Rect(size_label.DesiredSize);

            Label history_label = new Label()
            {
                Content    = "History:",
                FontWeight = FontWeights.Bold
            };

            this.history_label_value = new Label()
            {
                Content = Controller.HistorySize,
            };

            history_label.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            Rect history_label_rect = new Rect(history_label.DesiredSize);

            Shapes.Rectangle line = new Shapes.Rectangle()
            {
                Width  = Width,
                Height = 1,
                Fill   = new SolidColorBrush(Color.FromRgb(223, 223, 223))
            };

            Shapes.Rectangle background = new Shapes.Rectangle()
            {
                Width  = Width,
                Height = Height,
                Fill   = new SolidColorBrush(Color.FromRgb(250, 250, 250))
            };

            this.web_browser = new WebBrowser()
            {
                Width  = Width - 6,
                Height = Height - 36 - 11
            };

            this.web_browser.ObjectForScripting = new SparkleScriptingObject();

            spinner = new SparkleSpinner(22);

            // Disable annoying IE clicking sound
            CoInternetSetFeatureEnabled(21, 0x00000002, true);


            this.canvas = new Canvas();
            Content     = this.canvas;

            this.canvas.Children.Add(size_label);
            Canvas.SetLeft(size_label, 24);
            Canvas.SetTop(size_label, 4);

            this.canvas.Children.Add(this.size_label_value);
            Canvas.SetLeft(this.size_label_value, 22 + size_label_rect.Width);
            Canvas.SetTop(this.size_label_value, 4);

            this.canvas.Children.Add(history_label);
            Canvas.SetLeft(history_label, 130);
            Canvas.SetTop(history_label, 4);

            this.canvas.Children.Add(this.history_label_value);
            Canvas.SetLeft(this.history_label_value, 130 + history_label_rect.Width);
            Canvas.SetTop(this.history_label_value, 4);

            this.canvas.Children.Add(background);
            Canvas.SetLeft(background, 0);
            Canvas.SetTop(background, 36);

            this.canvas.Children.Add(spinner);
            Canvas.SetLeft(spinner, (Width / 2) - 15);
            Canvas.SetTop(spinner, (Height / 2) - 22);

            this.canvas.Children.Add(line);
            Canvas.SetLeft(line, 0);
            Canvas.SetTop(line, 35);


            Closing += Close;

            Controller.ShowWindowEvent += delegate {
                Dispatcher.BeginInvoke((Action) delegate {
                    Show();
                    Activate();
                    BringIntoView();
                });
            };

            Controller.HideWindowEvent += delegate {
                Dispatcher.BeginInvoke((Action) delegate {
                    Hide();

                    if (this.canvas.Children.Contains(this.web_browser))
                    {
                        this.canvas.Children.Remove(this.web_browser);
                    }
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Dispatcher.BeginInvoke((Action) delegate {
                    this.size_label_value.Content = size;
                    this.size_label_value.UpdateLayout();

                    this.history_label_value.Content = history_size;
                    this.history_label_value.UpdateLayout();
                });
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Dispatcher.BeginInvoke((Action) delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Dispatcher.BeginInvoke((Action) delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Dispatcher.BeginInvoke((Action) delegate {
                    this.spinner.Start();

                    if (this.canvas.Children.Contains(this.web_browser))
                    {
                        this.canvas.Children.Remove(this.web_browser);
                    }
                });
            };
        }
        public void UpdateEvents(bool silent)
        {
            if (!silent) {
                LogContent.Remove (LogContent.Child);
                Spinner = new SparkleSpinner (22);
                LogContent.Add (Spinner);
                LogContent.ShowAll ();
            }

            Thread thread = new Thread (new ThreadStart (delegate {
                Stopwatch watch = new Stopwatch ();
                watch.Start ();
                this.change_sets = SparkleShare.Controller.GetLog (this.selected_log);
                GenerateHTML ();
                watch.Stop ();

                // A short delay is less annoying than
                // a flashing window
                if (watch.ElapsedMilliseconds < 500 && !silent)
                    Thread.Sleep (500 - (int) watch.ElapsedMilliseconds);

                AddHTML ();
            }));

            thread.Start ();
        }
Example #11
0
        public SparkleEventLog() : base("")
        {
            SetSizeRequest(480, (int)(Gdk.Screen.Default.Height * 0.8));

            int x = (int)(Gdk.Screen.Default.Width * 0.61);
            int y = (int)(Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5));

            Move(x, y);

            Resizable   = true;
            BorderWidth = 0;

            Title    = "Recent Changes";
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask) &&
                    args.Event.Key == Gdk.Key.w)
                {
                    Controller.WindowClosed();
                }
            };

            this.size_label = new Label()
            {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label()
            {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox(false, 12);

            layout_sizes.Add(this.size_label);
            layout_sizes.Add(this.history_label);

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new SparkleSpinner(22);
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse("white", ref white);

            this.content_wrapper.ModifyBg(StateType.Normal, white);

            this.web_view = new WebView()
            {
                Editable = false
            };


            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add(this.web_view);
            this.content_wrapper.Add(this.spinner);

            this.spinner.Start();

            this.layout_horizontal = new HBox(true, 0);
            this.layout_horizontal.PackStart(layout_sizes, true, true, 12);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);


            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();

                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Application.Invoke(delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Application.Invoke(delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner);
                    this.spinner.Start();
                    this.content_wrapper.ShowAll();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll();
                    this.history_label.ShowAll();
                });
            };
        }
        public SparkleEventLog ()
        {
            Title              = "Recent Changes";
            Height             = 640;
            Width              = 480;
            ResizeMode         = ResizeMode.NoResize; // TODO
            Background         = new SolidColorBrush (Color.FromRgb (240, 240, 240));    
            AllowsTransparency = false;
            Icon               = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico");

            int x = (int) (SystemParameters.PrimaryScreenWidth * 0.61);
            int y = (int) (SystemParameters.PrimaryScreenHeight * 0.5 - (Height * 0.5));

            WindowStartupLocation = WindowStartupLocation.Manual;
            Left = x;
            Top = y;

            WriteOutImages ();
                        
            Label size_label = new Label () {
                Content    = "Size:",
                FontWeight = FontWeights.Bold
            };
            
            this.size_label_value = new Label () {
                Content = Controller.Size
            };
            
            size_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
            Rect size_label_rect = new Rect (size_label.DesiredSize);
            
            Label history_label = new Label () {
                Content    = "History:",
                FontWeight = FontWeights.Bold
            };
            
            this.history_label_value = new Label () {
                Content = Controller.HistorySize,
            };
            
            history_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
            Rect history_label_rect = new Rect (history_label.DesiredSize);
            
            Shapes.Rectangle line = new Shapes.Rectangle () {
                Width  = Width,
                Height = 1,
                Fill   = new SolidColorBrush (Color.FromRgb (223, 223, 223))    
            };
            
            Shapes.Rectangle background = new Shapes.Rectangle () {
                Width  = Width,
                Height = Height,
                Fill   = new SolidColorBrush (Color.FromRgb (250, 250, 250))    
            };
                        
            this.web_browser = new WebBrowser () {
                Width  = Width - 6,
                Height = Height - 64
            };

            this.web_browser.ObjectForScripting = new SparkleScriptingObject ();
                    

            spinner = new SparkleSpinner (22);
            
            // Disable annoying IE clicking sound
            CoInternetSetFeatureEnabled (21, 0x00000002, true);

            
            this.canvas = new Canvas ();
            Content     = this.canvas;

            this.canvas.Children.Add (size_label);
            Canvas.SetLeft (size_label, 24);
            Canvas.SetTop (size_label, 4);

            this.canvas.Children.Add (this.size_label_value);
            Canvas.SetLeft (this.size_label_value, 22 + size_label_rect.Width);
            Canvas.SetTop (this.size_label_value, 4);
            
            this.canvas.Children.Add (history_label);
            Canvas.SetLeft (history_label, 130);
            Canvas.SetTop (history_label, 4);
            
            this.canvas.Children.Add (this.history_label_value);
            Canvas.SetLeft (this.history_label_value, 130 + history_label_rect.Width);
            Canvas.SetTop (this.history_label_value, 4);
            
            this.canvas.Children.Add (background);
            Canvas.SetLeft (background, 0);
            Canvas.SetTop (background, 36);
            
            this.canvas.Children.Add (spinner);
            Canvas.SetLeft (spinner, (Width / 2) - 15);
            Canvas.SetTop (spinner, (Height / 2) - 22);
            
            this.canvas.Children.Add (line);
            Canvas.SetLeft (line, 0);
            Canvas.SetTop (line, 35);
            

            Closing += Close;
            
            Controller.ShowWindowEvent += delegate {
               Dispatcher.BeginInvoke ((Action) delegate {
                    Show ();
                    Activate ();
                    BringIntoView ();
                });
            };

            Controller.HideWindowEvent += delegate {
                Dispatcher.BeginInvoke ((Action) delegate {
                    Hide ();
                    
                    if (this.canvas.Children.Contains (this.web_browser))
                        this.canvas.Children.Remove (this.web_browser);
                });
            };
            
            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                Dispatcher.BeginInvoke ((Action) delegate {
                    this.size_label_value.Content = size;
                    this.size_label_value.UpdateLayout ();
                    
                    this.history_label_value.Content = history_size;
                    this.history_label_value.UpdateLayout ();
                });
            };
            
            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Dispatcher.BeginInvoke ((Action) delegate {
                    UpdateChooser (folders);
                });    
            };

            Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
                Dispatcher.BeginInvoke ((Action) delegate {
					this.combo_box.IsEnabled = enabled;
                });    
            };

            Controller.UpdateContentEvent += delegate (string html) {
                Dispatcher.BeginInvoke ((Action) delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
				Dispatcher.BeginInvoke ((Action) delegate {
	                this.spinner.Start ();
	                
	                if (this.canvas.Children.Contains (this.web_browser))
	                    this.canvas.Children.Remove (this.web_browser);
				});
            };

            Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
				Dispatcher.BeginInvoke ((Action) delegate {
	                SaveFileDialog dialog = new SaveFileDialog () {
						FileName         = file_name,
						InitialDirectory = target_folder_path,
						Title            = "Restore from History",
						DefaultExt       = "." + Path.GetExtension (file_name),
						Filter           = "All Files|*.*"
					};

					Nullable<bool> result = dialog.ShowDialog (this);

					if (result == true)
						Controller.SaveDialogCompleted (dialog.FileName);
					else
						Controller.SaveDialogCancelled ();
				});
            };
        }
Example #13
0
        public SparkleEventLog()
            : base("")
        {
            SetSizeRequest (480, 640);
            SetPosition (WindowPosition.Center);

            Resizable   = true;
            BorderWidth = 0;

            Title = _("Recent Events");
            IconName = "folder-sparkleshare";

            DeleteEvent += Close;

            VBox layout_vertical = new VBox (false, 0);
            this.spinner         = new SparkleSpinner (22);
            this.content_wrapper = new EventBox ();
            this.scrolled_window = new ScrolledWindow ();

                this.web_view = new WebView () {
                    Editable = false
                };

                    this.web_view.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) {
                        this.link_status = args.Link;
                    };

                    this.web_view.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) {
                        if (args.Request.Uri == this.link_status) {
                    // TODO: controller
                            Process process = new Process ();
                            process.StartInfo.FileName = "xdg-open";
                            process.StartInfo.Arguments = args.Request.Uri.Replace (" ", "\\ "); // Escape space-characters
                            process.Start ();

                        } else {
                    //TODO: controller
                            Regex regex = new Regex (@"(.+)~(.+)~(.+)");
                            Match match = regex.Match (args.Request.Uri);

                            if (match.Success) {
                                string folder_name = match.Groups [1].Value;
                                string revision    = match.Groups [2].Value;
                                string note        = match.Groups [3].Value;

                                Thread thread = new Thread (new ThreadStart (delegate {
                                    SparkleShare.Controller.AddNoteToFolder (folder_name, revision, note);
                                }));

                                thread.Start ();
                            }
                        }

                        // Don't follow HREFs (as this would cause a page refresh)
                        if (!args.Request.Uri.Equals ("file:"))
                            args.RetVal = 1;
                    };

            this.scrolled_window.Add (this.web_view);
            this.content_wrapper.Add (this.spinner);

            this.spinner.Start ();

            this.layout_horizontal = new HBox (true, 0);
            this.layout_horizontal.PackStart (new Label (""), true, true, 0);
            this.layout_horizontal.PackStart (new Label (""), true, true, 0);

            layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
            layout_vertical.PackStart (this.content_wrapper, true, true, 0);

            Add (layout_vertical);
            ShowAll ();

            UpdateChooser (null);
            UpdateContent (null);

            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Application.Invoke (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                 Application.Invoke (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke (delegate {
                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);

                    this.content_wrapper.Add (this.spinner);
                    this.spinner.Start ();
                    this.content_wrapper.ShowAll ();
                });
            };
        }
Example #14
0
        public SparkleEventLog() : base("")
        {
            SetSizeRequest(480, 640);
            SetPosition(WindowPosition.Center);

            Resizable   = true;
            BorderWidth = 0;

            Title    = _("Recent Events");
            IconName = "folder-sparkleshare";

            DeleteEvent += Close;

            this.size_label = new Label()
            {
                Markup = "<b>Size:</b> " + Controller.Size + "   " +
                         "<b>History:</b> " + Controller.HistorySize
            };

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new SparkleSpinner(22);
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            this.web_view = new WebView()
            {
                Editable = false
            };

            this.web_view.HoveringOverLink += delegate(object o, WebKit.HoveringOverLinkArgs args) {
                this.link_status = args.Link;
            };

            this.web_view.NavigationRequested += delegate(object o, WebKit.NavigationRequestedArgs args) {
                if (args.Request.Uri == this.link_status)
                {
                    SparkleEventLogController.LinkClicked(args.Request.Uri);
                }

                // Don't follow HREFs (as this would cause a page refresh)
                if (!args.Request.Uri.Equals("file:"))
                {
                    args.RetVal = 1;
                }
            };

            this.scrolled_window.Add(this.web_view);
            this.content_wrapper.Add(this.spinner);

            this.spinner.Start();

            this.layout_horizontal = new HBox(false, 0);
            this.layout_horizontal.PackStart(this.size_label, true, true, 0);
            this.layout_horizontal.PackStart(new Label("  "), false, false, 0);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(CreateShortcutsBar(), false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);
            ShowAll();

            UpdateChooser(null);
            UpdateContent(null);


            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Application.Invoke(delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Application.Invoke(delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner);
                    this.spinner.Start();
                    this.content_wrapper.ShowAll();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup = "<b>Size:</b> " + size + "   " +
                                             "<b>History:</b> " + history_size;

                    this.size_label.ShowAll();
                });
            };
        }
Example #15
0
        // The page shown whilst syncing
        private void ShowSyncingPage(string name)
        {
            Reset ();

                ProgressBar = new ProgressBar () {
                    Fraction = 0
                };

                VBox layout_vertical = new VBox (false, 0);

                    Label header = new Label ("<span size='x-large'><b>" +
                                                    String.Format (_("Syncing folder ‘{0}’…"), name) +
                                                    "</b></span>") {
                        UseMarkup = true,
                        Xalign    = 0,
                        Wrap      = true
                    };

                    Label information = new Label (_("This may take a while.\n") +
                                                   _("Are you sure it’s not coffee o'clock?")) {
                        UseMarkup = true,
                        Xalign = 0
                    };

                        Button button = new Button () {
                            Sensitive = false,
                            Label = _("Finish")
                        };

                        button.Clicked += delegate {
                            Destroy ();
                        };

                    AddButton (button);

                    SparkleSpinner spinner = new SparkleSpinner (22);

                Table table = new Table (3, 2, false) {
                    RowSpacing    = 12,
                    ColumnSpacing = 9
                };

                HBox box = new HBox (false, 0);

                table.Attach (spinner,      0, 1, 0, 1);
                table.Attach (header, 1, 2, 0, 1);
                table.Attach (information,  1, 2, 1, 2);
                table.Attach (ProgressBar,  2, 3, 0, 2);

                box.PackStart (table, false, false, 0);

                layout_vertical.PackStart (box, false, false, 0);

            Add (layout_vertical);

            ShowAll ();
        }
        public SparkleEventLog()
            : base("")
        {
            SetSizeRequest (480, 640);
            SetPosition (WindowPosition.Center);

            Resizable   = true;
            BorderWidth = 0;

            Title = _("Recent Events");
            IconName = "folder-sparkleshare";

            DeleteEvent += Close;

            this.size_label = new Label () {
                Markup = "<b>Size:</b> …   <b>History:</b> …"
            };

            VBox layout_vertical = new VBox (false, 0);
            this.spinner         = new SparkleSpinner (22);
            this.content_wrapper = new EventBox ();
            this.scrolled_window = new ScrolledWindow ();

            this.web_view = new WebView () {
                Editable = false
            };

            this.web_view.HoveringOverLink += delegate (object o, WebKit.HoveringOverLinkArgs args) {
                this.link_status = args.Link;
            };

            this.web_view.NavigationRequested += delegate (object o, WebKit.NavigationRequestedArgs args) {
                if (args.Request.Uri == this.link_status)
                    SparkleEventLogController.LinkClicked (args.Request.Uri);

                // Don't follow HREFs (as this would cause a page refresh)
                if (!args.Request.Uri.Equals ("file:"))
                    args.RetVal = 1;
            };

            this.scrolled_window.Add (this.web_view);
            this.content_wrapper.Add (this.spinner);

            this.spinner.Start ();

            this.layout_horizontal = new HBox (false, 0);
            this.layout_horizontal.PackStart (this.size_label, true, true, 0);
            this.layout_horizontal.PackStart (new Label ("  "), false, false, 0);

            layout_vertical.PackStart (this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart (CreateShortcutsBar (), false, false, 0);
            layout_vertical.PackStart (this.content_wrapper, true, true, 0);

            Add (layout_vertical);
            ShowAll ();

            UpdateChooser (null);
            UpdateContent (null);

            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate (string [] folders) {
                Application.Invoke (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                 Application.Invoke (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke (delegate {
                    if (this.content_wrapper.Child != null)
                        this.content_wrapper.Remove (this.content_wrapper.Child);

                    this.content_wrapper.Add (this.spinner);
                    this.spinner.Start ();
                    this.content_wrapper.ShowAll ();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                Application.Invoke (delegate {
                    this.size_label.Markup = "<b>Size:</b> " + size + "   " +
                                             "<b>History:</b> " + history_size;

                    this.size_label.ShowAll ();
                });
            };
        }
Example #17
0
        public SparkleEventLog() : base("")
        {
            SetSizeRequest(480, (int)(Gdk.Screen.Default.Height * 0.8));

            int x = (int)(Gdk.Screen.Default.Width * 0.61);
            int y = (int)(Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5));

            Move(x, y);

            Resizable   = true;
            BorderWidth = 0;

            Title    = "Recent Changes";
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w))
                {
                    Controller.WindowClosed();
                }
            };

            this.size_label = new Label()
            {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label()
            {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox(false, 12);

            layout_sizes.Add(this.size_label);
            layout_sizes.Add(this.history_label);

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new SparkleSpinner(22);
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse("white", ref white);

            this.content_wrapper.ModifyBg(StateType.Normal, white);

            this.web_view = new WebView()
            {
                Editable = false
            };


            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add(this.web_view);
            this.content_wrapper.Add(this.spinner);

            this.spinner.Start();

            this.layout_horizontal = new HBox(true, 0);
            this.layout_horizontal.PackStart(layout_sizes, true, true, 12);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);


            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();

                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

            Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) {
                Application.Invoke(delegate {
                    FileChooserDialog dialog = new FileChooserDialog("Restore from History",
                                                                     this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok);

                    dialog.CurrentName             = file_name;
                    dialog.DoOverwriteConfirmation = true;
                    dialog.SetCurrentFolder(target_folder_path);

                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        Controller.SaveDialogCompleted(dialog.Filename);
                    }
                    else
                    {
                        Controller.SaveDialogCancelled();
                    }

                    dialog.Destroy();
                });
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Application.Invoke(delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateChooserEnablementEvent += delegate(bool enabled) {
                Application.Invoke(delegate {
                    this.combo_box.Sensitive = enabled;
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Application.Invoke(delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner);
                    this.spinner.Start();
                    this.content_wrapper.ShowAll();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll();
                    this.history_label.ShowAll();
                });
            };
        }