From 502d5b4a7539ddb75c8ae2b124d9fac64083fcc3 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 25 Jun 2015 23:38:11 +0100 Subject: [PATCH] linux: Implement note feature --- SparkleShare/Linux/SparkleNote.cs | 74 +++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/SparkleShare/Linux/SparkleNote.cs b/SparkleShare/Linux/SparkleNote.cs index dd57b993..410998b5 100755 --- a/SparkleShare/Linux/SparkleNote.cs +++ b/SparkleShare/Linux/SparkleNote.cs @@ -25,15 +25,16 @@ namespace SparkleShare { public SparkleNoteController Controller = new SparkleNoteController (); - public SparkleNote () : base ("Sync") + public SparkleNote () : base ("Add Note") { SetWmclass ("SparkleShare", "SparkleShare"); IconName = "sparkleshare"; Resizable = false; WindowPosition = WindowPosition.Center; + BorderWidth = 16; - SetSizeRequest (480, 240); + SetSizeRequest (480, 120); DeleteEvent += delegate (object o, DeleteEventArgs args) { @@ -61,13 +62,80 @@ namespace SparkleShare { }); }; + Controller.UpdateTitleEvent += delegate (string title) { + Application.Invoke (delegate { Title = title; }); + }; + CreateNote (); } private void CreateNote () { - // TODO + Image user_image = new Image (Controller.AvatarFilePath); + + /* TODO: Style the entry neatly, multiple lines, and add placeholder text + string balloon_image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", "text-balloon.png" }.Combine (); + Image balloon_image = new Image (balloon_image_path); + CssProvider balloon_css_provider = new CssProvider (); + + balloon_css_provider.LoadFromData ("GtkEntry {" + + "background-image: url('" + balloon_image_path + "');" + + "background-repeat: no-repeat;" + + "background-position: left top;" + + "}"); + + balloon.StyleContext.AddProvider (balloon_css_provider, 800); + */ + + Label balloon_label = new Label ("Anything to add?") { + Xalign = 0, + UseMarkup = true + }; + + Entry balloon = new Entry () { MaxLength = 144 }; + + + Button cancel_button = new Button ("Cancel"); + Button sync_button = new Button ("Sync"); // TODO: Make default button + + cancel_button.Clicked += delegate { Controller.CancelClicked (); }; + sync_button.Clicked += delegate { Controller.SyncClicked (balloon.Buffer.Text); }; + + + VBox layout_vertical = new VBox (false, 16); + HBox layout_horizontal = new HBox (false, 16); + + HBox buttons = new HBox () { + Homogeneous = false, + Spacing = 6 + }; + + Label user_label = new Label () { + Markup = "" + Program.Controller.CurrentUser.Name + "\n" + + "" + Program.Controller.CurrentUser.Email + + "" + }; + + + layout_horizontal.PackStart (user_image, false, false, 0); + layout_horizontal.PackStart (user_label, false, false, 0); + + buttons.PackStart (new Label (""), true, true, 0); + buttons.PackStart (cancel_button, false, false, 0); + buttons.PackStart (sync_button, false, false, 0); + + layout_vertical.PackStart (layout_horizontal, false, false, 0); + layout_vertical.PackStart (balloon_label, false, false, 0); + layout_vertical.PackStart (balloon, false, false, 0); + layout_vertical.PackStart (buttons, false, false, 0); + + // FIXME: Doesn't work + CanDefault = true; + Default = sync_button; + + Add (layout_vertical); } } } +