ui: Port all the things to GTK+3
This commit is contained in:
parent
32aa9f909e
commit
c94b5d57c9
|
@ -32,25 +32,25 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleAbout () : base ("")
|
||||
{
|
||||
DefaultSize = new Gdk.Size (600, 260);
|
||||
SetSizeRequest (600, 260);
|
||||
Resizable = false;
|
||||
BorderWidth = 0;
|
||||
IconName = "folder-sparkleshare";
|
||||
WindowPosition = WindowPosition.Center;
|
||||
Title = "About SparkleShare";
|
||||
AppPaintable = true;
|
||||
|
||||
string image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", "about.png" }.Combine ();
|
||||
CssProvider css_provider = new CssProvider ();
|
||||
string image_path = new string [] { SparkleUI.AssetsPath, "pixmaps", "about.png" }.Combine ();
|
||||
css_provider.LoadFromData ("GtkWindow {" +
|
||||
"background-image: url('" + image_path + "');" +
|
||||
"background-repeat: no-repeat;" +
|
||||
"background-position: left bottom;" +
|
||||
"}");
|
||||
|
||||
Realize ();
|
||||
Gdk.Pixbuf buf = new Gdk.Pixbuf (image_path);
|
||||
Gdk.Pixmap map, map2;
|
||||
buf.RenderPixmapAndMask (out map, out map2, 255);
|
||||
GdkWindow.SetBackPixmap (map, false);
|
||||
StyleContext.AddProvider (css_provider, 800);
|
||||
|
||||
CreateAbout ();
|
||||
|
||||
|
||||
DeleteEvent += delegate (object o, DeleteEventArgs args) {
|
||||
Controller.WindowClosed ();
|
||||
args.RetVal = true;
|
||||
|
@ -65,9 +65,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Application.Invoke (delegate {
|
||||
HideAll ();
|
||||
});
|
||||
Application.Invoke (delegate { Hide (); });
|
||||
};
|
||||
|
||||
Controller.ShowWindowEvent += delegate {
|
||||
|
@ -92,13 +90,13 @@ namespace SparkleShare {
|
|||
Markup = string.Format ("<span font_size='small' fgcolor='white'>version {0}</span>",
|
||||
Controller.RunningVersion),
|
||||
Xalign = 0,
|
||||
Xpad = 300
|
||||
Xpad = 0
|
||||
};
|
||||
|
||||
this.updates = new Label () {
|
||||
Markup = "<span font_size='small' fgcolor='#729fcf'>Checking for updates...</span>",
|
||||
Markup = "<span font_size='small' fgcolor='#a8bbcf'>Checking for updates...</span>",
|
||||
Xalign = 0,
|
||||
Xpad = 300
|
||||
Xpad = 0
|
||||
};
|
||||
|
||||
Label copyright = new Label () {
|
||||
|
@ -107,7 +105,7 @@ namespace SparkleShare {
|
|||
"Hylke Bons and others." +
|
||||
"</span>",
|
||||
Xalign = 0,
|
||||
Xpad = 300
|
||||
Xpad = 0
|
||||
};
|
||||
|
||||
Label license = new Label () {
|
||||
|
@ -117,66 +115,54 @@ namespace SparkleShare {
|
|||
"SparkleShare is Open Source software. You are free to use, modify, " +
|
||||
"and redistribute it under the GNU General Public License version 3 or later." +
|
||||
"</span>",
|
||||
WidthRequest = 330,
|
||||
Wrap = true,
|
||||
Xalign = 0,
|
||||
Xpad = 300,
|
||||
Xalign = 0
|
||||
};
|
||||
|
||||
VBox layout_vertical = new VBox (false, 0) {
|
||||
BorderWidth = 0,
|
||||
HeightRequest = 260,
|
||||
WidthRequest = 640
|
||||
};
|
||||
VBox layout_vertical = new VBox (false, 0);
|
||||
HBox links_layout = new HBox (false, 16);
|
||||
|
||||
HBox links_layout = new HBox (false, 6);
|
||||
|
||||
SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress);
|
||||
SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress);
|
||||
SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress);
|
||||
SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress);
|
||||
SparkleLink report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress);
|
||||
SparkleLink debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress);
|
||||
|
||||
links_layout.PackStart (new Label (""), false, false, 143);
|
||||
links_layout.PackStart (website_link, false, false, 9);
|
||||
links_layout.PackStart (credits_link, false, false, 9);
|
||||
links_layout.PackStart (report_problem_link, false, false, 9);
|
||||
links_layout.PackStart (debug_log_link, false, false, 9);
|
||||
links_layout.PackStart (website_link, false, false, 0);
|
||||
links_layout.PackStart (credits_link, false, false, 0);
|
||||
links_layout.PackStart (report_problem_link, false, false, 0);
|
||||
links_layout.PackStart (debug_log_link, false, false, 0);
|
||||
|
||||
layout_vertical.PackStart (new Label (""), false, false, 42);
|
||||
layout_vertical.PackStart (new Label (""), true, true, 0);
|
||||
layout_vertical.PackStart (version, false, false, 0);
|
||||
layout_vertical.PackStart (this.updates, false, false, 0);
|
||||
layout_vertical.PackStart (copyright, false, false, 9);
|
||||
layout_vertical.PackStart (license, false, false, 0);
|
||||
layout_vertical.PackStart (links_layout, false, false, 12);
|
||||
layout_vertical.PackStart (copyright, false, false, 6);
|
||||
layout_vertical.PackStart (license, false, false, 6);
|
||||
layout_vertical.PackStart (links_layout, false, false, 16);
|
||||
|
||||
Add (layout_vertical);
|
||||
HBox layout_horizontal = new HBox (false, 0);
|
||||
layout_horizontal.PackStart (new Label (""), false, false, 149);
|
||||
layout_horizontal.PackStart (layout_vertical, false, false, 0);
|
||||
|
||||
Add (layout_horizontal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SparkleLink : EventBox {
|
||||
public class SparkleLink : EventBox {
|
||||
|
||||
public SparkleLink (string text, string url)
|
||||
{
|
||||
VisibleWindow = false;
|
||||
public SparkleLink (string text, string url)
|
||||
{
|
||||
VisibleWindow = false;
|
||||
|
||||
Label label = new Label () {
|
||||
Markup = "<span size='small' fgcolor='#729fcf' underline='single'>" + text + "</span>"
|
||||
};
|
||||
Label label = new Label () {
|
||||
Markup = "<span size='small' fgcolor='#729fcf' underline='single'>" + text + "</span>"
|
||||
};
|
||||
|
||||
EnterNotifyEvent += delegate {
|
||||
GdkWindow.Cursor = new Gdk.Cursor (Gdk.CursorType.Hand1);
|
||||
};
|
||||
EnterNotifyEvent += delegate { Window.Cursor = new Gdk.Cursor (Gdk.CursorType.Hand1); };
|
||||
LeaveNotifyEvent += delegate { Window.Cursor = new Gdk.Cursor (Gdk.CursorType.Arrow); };
|
||||
ButtonPressEvent += delegate { Program.Controller.OpenWebsite (url); };
|
||||
|
||||
LeaveNotifyEvent += delegate {
|
||||
GdkWindow.Cursor = new Gdk.Cursor (Gdk.CursorType.Arrow);
|
||||
};
|
||||
|
||||
ButtonPressEvent += delegate {
|
||||
Program.Controller.OpenWebsite (url);
|
||||
};
|
||||
|
||||
Add (label);
|
||||
}
|
||||
}
|
||||
Add (label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
using System;
|
||||
|
||||
using Gtk;
|
||||
using Notifications;
|
||||
//using Notifications;
|
||||
using SparkleLib;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
@ -29,22 +29,12 @@ namespace SparkleShare {
|
|||
|
||||
|
||||
public SparkleBubbles ()
|
||||
{
|
||||
{/*
|
||||
Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) {
|
||||
if (!Program.Controller.NotificationsEnabled)
|
||||
return;
|
||||
|
||||
try {
|
||||
// Debug information for https://github.com/hbons/SparkleShare/issues/1362
|
||||
if (title.Length > 255) {
|
||||
SparkleLogger.LogInfo ("Notification", "Long string detected, truncating 'title'");
|
||||
title = title.Substring (0, 255) + "...";
|
||||
|
||||
} else if (subtext.Length > 255) {
|
||||
SparkleLogger.LogInfo ("Notification", "Long string detected, truncating 'subtext'");
|
||||
title = title.Substring (0, 255) + "...";
|
||||
}
|
||||
|
||||
Notification notification = new Notification () {
|
||||
Summary = title,
|
||||
Body = subtext,
|
||||
|
@ -67,7 +57,7 @@ namespace SparkleShare {
|
|||
} catch (Exception e) {
|
||||
SparkleLogger.LogInfo ("Notification", "Error showing notification: ", e);
|
||||
}
|
||||
};
|
||||
};*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ using System.Threading;
|
|||
|
||||
using Gtk;
|
||||
using Mono.Unix;
|
||||
using WebKit;
|
||||
// using WebKit;
|
||||
|
||||
using IO = System.IO;
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace SparkleShare {
|
|||
private HBox combo_box_wrapper;
|
||||
private EventBox content_wrapper;
|
||||
private ScrolledWindow scrolled_window;
|
||||
private WebView web_view;
|
||||
// private WebView web_view;
|
||||
private SparkleSpinner spinner;
|
||||
|
||||
|
||||
|
@ -90,19 +90,20 @@ namespace SparkleShare {
|
|||
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);
|
||||
// TODO: check
|
||||
CssProvider css_provider= new CssProvider ();
|
||||
css_provider.LoadFromData ("GtkWindow { background-color: #ffffff; }");
|
||||
StyleContext.AddProvider (css_provider, 800);
|
||||
|
||||
/*
|
||||
this.web_view = new WebView () {
|
||||
Editable = false
|
||||
};
|
||||
|
||||
|
||||
this.web_view.NavigationRequested += WebViewNavigationRequested;
|
||||
|
||||
this.scrolled_window.Add (this.web_view);
|
||||
*/
|
||||
this.scrolled_window.Add (new Button ("WebView"));
|
||||
this.content_wrapper.Add (this.spinner);
|
||||
|
||||
this.spinner.Start ();
|
||||
|
@ -118,7 +119,7 @@ namespace SparkleShare {
|
|||
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Application.Invoke (delegate {
|
||||
HideAll ();
|
||||
Hide ();
|
||||
|
||||
if (this.content_wrapper.Child != null)
|
||||
this.content_wrapper.Remove (this.content_wrapper.Child);
|
||||
|
@ -190,7 +191,7 @@ namespace SparkleShare {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
private void WebViewNavigationRequested (object o, WebKit.NavigationRequestedArgs args) {
|
||||
Controller.LinkClicked (args.Request.Uri);
|
||||
|
||||
|
@ -198,7 +199,7 @@ namespace SparkleShare {
|
|||
if (!args.Request.Uri.Equals ("file:"))
|
||||
args.RetVal = 1;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public void UpdateChooser (string [] folders)
|
||||
{
|
||||
|
@ -235,7 +236,7 @@ namespace SparkleShare {
|
|||
row++;
|
||||
}
|
||||
|
||||
this.combo_box.RowSeparatorFunc = delegate (TreeModel model, TreeIter iter) {
|
||||
this.combo_box.RowSeparatorFunc = delegate (ITreeModel model, TreeIter iter) {
|
||||
string item = (string) this.combo_box.Model.GetValue (iter, 0);
|
||||
return (item == "---");
|
||||
};
|
||||
|
@ -266,16 +267,16 @@ namespace SparkleShare {
|
|||
string pixmaps_path = IO.Path.Combine (SparkleUI.AssetsPath, "pixmaps");
|
||||
string icons_path = new string [] {SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status"}.Combine ();
|
||||
|
||||
html = html.Replace ("<!-- $body-font-size -->", (double) (Style.FontDescription.Size / 1024 + 3) + "px");
|
||||
html = html.Replace ("<!-- $day-entry-header-font-size -->", (Style.FontDescription.Size / 1024 + 3) + "px");
|
||||
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
||||
html = html.Replace ("<!-- $a-hover-color -->", "#009ff8");
|
||||
html = html.Replace ("<!-- $body-font-family -->", "\"" + Style.FontDescription.Family + "\"");
|
||||
html = html.Replace ("<!-- $body-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Normal)));
|
||||
html = html.Replace ("<!-- $body-background-color -->", SparkleUIHelpers.GdkColorToHex (new TreeView ().Style.Base (StateType.Normal)));
|
||||
html = html.Replace ("<!-- $day-entry-header-background-color -->", SparkleUIHelpers.GdkColorToHex (Style.Background (StateType.Normal)));
|
||||
html = html.Replace ("<!-- $secondary-font-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
|
||||
html = html.Replace ("<!-- $small-color -->", SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive)));
|
||||
html = html.Replace ("<!-- $a-color -->", "#0085cf");
|
||||
html = html.Replace ("<!-- $body-background-color -->", SparkleUIHelpers.RGBAToHex (new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Normal)));
|
||||
html = html.Replace ("<!-- $body-color -->", SparkleUIHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Normal)));
|
||||
html = html.Replace ("<!-- $body-font-family -->", "\"" + StyleContext.GetFont (StateFlags.Normal).Family + "\"");
|
||||
html = html.Replace ("<!-- $body-font-size -->", (double) (StyleContext.GetFont (StateFlags.Normal).Size / 1024 + 3) + "px");
|
||||
html = html.Replace ("<!-- $day-entry-header-font-size -->", (StyleContext.GetFont (StateFlags.Normal).Size / 1024 + 3) + "px");
|
||||
html = html.Replace ("<!-- $day-entry-header-background-color -->", SparkleUIHelpers.RGBAToHex (StyleContext.GetBackgroundColor (StateFlags.Normal)));
|
||||
html = html.Replace ("<!-- $secondary-font-color -->", SparkleUIHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Insensitive)));
|
||||
html = html.Replace ("<!-- $small-color -->", SparkleUIHelpers.RGBAToHex (StyleContext.GetColor (StateFlags.Insensitive)));
|
||||
html = html.Replace ("<!-- $small-font-size -->", "85%");
|
||||
html = html.Replace ("<!-- $pixmaps-path -->", pixmaps_path);
|
||||
html = html.Replace ("<!-- $document-added-background-image -->", "file://" + IO.Path.Combine (icons_path, "document-added.png"));
|
||||
|
@ -284,11 +285,11 @@ namespace SparkleShare {
|
|||
html = html.Replace ("<!-- $document-moved-background-image -->", "file://" + IO.Path.Combine (icons_path, "document-moved.png"));
|
||||
|
||||
this.spinner.Stop ();
|
||||
|
||||
/*
|
||||
this.web_view.NavigationRequested -= WebViewNavigationRequested;
|
||||
this.web_view.LoadHtmlString (html, "file://");
|
||||
this.web_view.NavigationRequested += WebViewNavigationRequested;
|
||||
|
||||
*/
|
||||
this.content_wrapper.Remove (this.content_wrapper.Child);
|
||||
this.content_wrapper.Add (this.scrolled_window);
|
||||
this.content_wrapper.ShowAll ();
|
||||
|
|
|
@ -29,9 +29,10 @@ namespace SparkleShare {
|
|||
|
||||
|
||||
public SparkleSetup () : base ()
|
||||
{
|
||||
{var about = new SparkleAbout ();
|
||||
about.ShowAll();
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Application.Invoke (delegate { HideAll (); });
|
||||
Application.Invoke (delegate { Hide (); });
|
||||
};
|
||||
|
||||
Controller.ShowWindowEvent += delegate {
|
||||
|
@ -55,7 +56,7 @@ namespace SparkleShare {
|
|||
{
|
||||
if (type == PageType.Setup) {
|
||||
Header = "Welcome to SparkleShare!";
|
||||
Description = "First off, what’s your name and email?\n(Visible only to team members)";
|
||||
Description = "First off, what’s your name and email?\n(visible only to team members)";
|
||||
|
||||
Table table = new Table (2, 3, true) {
|
||||
RowSpacing = 6,
|
||||
|
@ -216,7 +217,7 @@ namespace SparkleShare {
|
|||
// TODO: Scroll to selected row when using arrow keys
|
||||
};
|
||||
|
||||
tree.Model.Foreach (new TreeModelForeachFunc (delegate (TreeModel model,
|
||||
tree.Model.Foreach (new TreeModelForeachFunc (delegate (ITreeModel model,
|
||||
TreePath path, TreeIter iter) {
|
||||
|
||||
string address;
|
||||
|
@ -272,8 +273,8 @@ namespace SparkleShare {
|
|||
layout_path.PackStart (path_entry, false, false, 0);
|
||||
layout_path.PackStart (path_example, false, false, 0);
|
||||
|
||||
layout_fields.PackStart (layout_address);
|
||||
layout_fields.PackStart (layout_path);
|
||||
layout_fields.PackStart (layout_address, false, false, 0);
|
||||
layout_fields.PackStart (layout_path, false, false, 0);
|
||||
|
||||
layout_vertical.PackStart (new Label (""), false, false, 0);
|
||||
layout_vertical.PackStart (scrolled_window, true, true, 0);
|
||||
|
@ -679,7 +680,7 @@ namespace SparkleShare {
|
|||
|
||||
|
||||
private void RenderServiceColumn (TreeViewColumn column, CellRenderer cell,
|
||||
TreeModel model, TreeIter iter)
|
||||
ITreeModel model, TreeIter iter)
|
||||
{
|
||||
string markup = (string) model.GetValue (iter, 1);
|
||||
TreeSelection selection = (column.TreeView as TreeView).Selection;
|
||||
|
@ -704,7 +705,7 @@ namespace SparkleShare {
|
|||
{
|
||||
get {
|
||||
TreeIter iter;
|
||||
TreeModel model;
|
||||
ITreeModel model;
|
||||
|
||||
Selection.GetSelected (out model, out iter);
|
||||
return int.Parse (model.GetPath (iter).ToString ());
|
||||
|
|
|
@ -57,13 +57,14 @@ namespace SparkleShare {
|
|||
args.RetVal = true;
|
||||
};
|
||||
|
||||
SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
|
||||
Gdk.Color color = SparkleUIHelpers.RGBAToColor (StyleContext.GetColor (StateFlags.Insensitive));
|
||||
SecondaryTextColor = SparkleUIHelpers.ColorToHex (color);
|
||||
|
||||
SecondaryTextColorSelected =
|
||||
SparkleUIHelpers.GdkColorToHex (
|
||||
SparkleUIHelpers.ColorToHex (
|
||||
MixColors (
|
||||
new TreeView ().Style.Foreground (StateType.Selected),
|
||||
new TreeView ().Style.Background (StateType.Selected),
|
||||
new TreeView ().StyleContext.GetColor (StateFlags.Selected),
|
||||
new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected),
|
||||
0.15
|
||||
)
|
||||
);
|
||||
|
@ -95,17 +96,10 @@ namespace SparkleShare {
|
|||
VBox.PackStart (Wrapper, true, true, 0);
|
||||
VBox.PackStart (layout_horizontal, false, false, 15);
|
||||
|
||||
EventBox box = new EventBox ();
|
||||
Gdk.Color bg_color = new Gdk.Color ();
|
||||
Gdk.Color.Parse ("#000", ref bg_color);
|
||||
box.ModifyBg (StateType.Normal, bg_color);
|
||||
|
||||
Image side_splash = SparkleUIHelpers.GetImage ("side-splash.png");
|
||||
side_splash.Yalign = 1;
|
||||
|
||||
box.Add (side_splash);
|
||||
|
||||
HBox.PackStart (box, false, false, 0);
|
||||
HBox.PackStart (side_splash, false, false, 0);
|
||||
HBox.PackStart (VBox, true, true, 30);
|
||||
|
||||
base.Add (HBox);
|
||||
|
@ -197,7 +191,7 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
private Gdk.Color MixColors (Gdk.Color first_color, Gdk.Color second_color, double ratio)
|
||||
private Gdk.Color MixColors (Gdk.RGBA first_color, Gdk.RGBA second_color, double ratio)
|
||||
{
|
||||
return new Gdk.Color (
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) +
|
||||
|
|
|
@ -60,12 +60,27 @@ namespace SparkleShare {
|
|||
|
||||
// Converts a Gdk RGB color to a hex value.
|
||||
// Example: from "rgb:0,0,0" to "#000000"
|
||||
public static string GdkColorToHex (Gdk.Color color)
|
||||
public static string ColorToHex (Gdk.Color color)
|
||||
{
|
||||
return String.Format ("#{0:X2}{1:X2}{2:X2}",
|
||||
(int) Math.Truncate (color.Red / 256.00),
|
||||
(int) Math.Truncate (color.Green / 256.00),
|
||||
(int) Math.Truncate (color.Blue / 256.00));
|
||||
}
|
||||
|
||||
|
||||
public static string RGBAToHex (Gdk.RGBA rgba)
|
||||
{
|
||||
return ColorToHex (RGBAToColor (rgba));
|
||||
}
|
||||
|
||||
|
||||
public static Gdk.Color RGBAToColor (Gdk.RGBA rgba) {
|
||||
return new Gdk.Color () {
|
||||
Red = (ushort) (rgba.Red * 65535),
|
||||
Green = (ushort) (rgba.Green * 65535),
|
||||
Blue = (ushort)(rgba.Blue * 65535)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue