Various theme fixes

This commit is contained in:
Hylke Bons 2013-10-09 18:05:48 +02:00
parent c026eefdda
commit e9b88bb8a7
4 changed files with 41 additions and 43 deletions

View file

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

View file

@ -129,13 +129,13 @@ namespace SparkleShare {
ListStore store = new ListStore (typeof (Gdk.Pixbuf), typeof (string), typeof (SparklePlugin)); ListStore store = new ListStore (typeof (Gdk.Pixbuf), typeof (string), typeof (SparklePlugin));
SparkleTreeView tree = new SparkleTreeView (store) { HeadersVisible = false }; SparkleTreeView tree_view = new SparkleTreeView (store) { HeadersVisible = false };
ScrolledWindow scrolled_window = new ScrolledWindow () { ShadowType = ShadowType.In }; ScrolledWindow scrolled_window = new ScrolledWindow () { ShadowType = ShadowType.In };
scrolled_window.AddWithViewport (tree); scrolled_window.SetPolicy (PolicyType.Never, PolicyType.Automatic);
// Icon column // Icon column
tree.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0); tree_view.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0);
tree.Columns [0].Cells [0].Xpad = 6; tree_view.Columns [0].Cells [0].Xpad = 6;
// Service column // Service column
TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" }; TreeViewColumn service_column = new TreeViewColumn () { Title = "Service" };
@ -146,12 +146,12 @@ namespace SparkleShare {
foreach (SparklePlugin plugin in Controller.Plugins) { foreach (SparklePlugin plugin in Controller.Plugins) {
store.AppendValues (new Gdk.Pixbuf (plugin.ImagePath), store.AppendValues (new Gdk.Pixbuf (plugin.ImagePath),
"<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span size=\"small\"><b>" + plugin.Name + "</b>\n" +
"<span fgcolor=\"" + SecondaryTextColorSelected + "\">" + "<span fgcolor=\"" + SecondaryTextColor + "\">" + plugin.Description + "</span>" +
plugin.Description + "</span>" +
"</span>", plugin); "</span>", plugin);
} }
tree.AppendColumn (service_column); tree_view.AppendColumn (service_column);
scrolled_window.AddWithViewport (tree_view);
Entry address_entry = new Entry () { Entry address_entry = new Entry () {
Text = Controller.PreviousAddress, Text = Controller.PreviousAddress,
@ -181,7 +181,7 @@ namespace SparkleShare {
// Select the first plugin by default // Select the first plugin by default
TreeSelection default_selection = tree.Selection; TreeSelection default_selection = tree_view.Selection;
TreePath default_path = new TreePath ("0"); TreePath default_path = new TreePath ("0");
default_selection.SelectPath (default_path); default_selection.SelectPath (default_path);
Controller.SelectedPluginChanged (0); Controller.SelectedPluginChanged (0);
@ -211,12 +211,12 @@ namespace SparkleShare {
Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1); Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
// Update the address field text when the selection changes // Update the address field text when the selection changes
tree.CursorChanged += delegate (object sender, EventArgs e) { tree_view.CursorChanged += delegate (object sender, EventArgs e) {
Controller.SelectedPluginChanged (tree.SelectedRow); Controller.SelectedPluginChanged (tree_view.SelectedRow);
// TODO: Scroll to selected row when using arrow keys // TODO: Scroll to selected row when using arrow keys
}; };
tree.Model.Foreach (new TreeModelForeachFunc (delegate (ITreeModel model, tree_view.Model.Foreach (new TreeModelForeachFunc (delegate (ITreeModel model,
TreePath path, TreeIter iter) { TreePath path, TreeIter iter) {
string address; string address;
@ -231,7 +231,7 @@ namespace SparkleShare {
if (!string.IsNullOrEmpty (address) && if (!string.IsNullOrEmpty (address) &&
address.Equals (Controller.PreviousAddress)) { address.Equals (Controller.PreviousAddress)) {
tree.SetCursor (path, service_column, false); tree_view.SetCursor (path, service_column, false);
SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2); SparklePlugin plugin = (SparklePlugin) model.GetValue (iter, 2);
if (plugin.Address != null) { if (plugin.Address != null) {
@ -249,11 +249,11 @@ namespace SparkleShare {
})); }));
address_entry.Changed += delegate { address_entry.Changed += delegate {
Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow); Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree_view.SelectedRow);
}; };
layout_address.PackStart (new Label () { layout_address.PackStart (new Label () {
Markup = "<b>" + "Address:" + "</b>", Markup = "<b>" + "Address" + "</b>",
Xalign = 0 Xalign = 0
}, true, true, 0); }, true, true, 0);
@ -261,11 +261,11 @@ namespace SparkleShare {
layout_address.PackStart (address_example, false, false, 0); layout_address.PackStart (address_example, false, false, 0);
path_entry.Changed += delegate { path_entry.Changed += delegate {
Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow); Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree_view.SelectedRow);
}; };
layout_path.PackStart (new Label () { layout_path.PackStart (new Label () {
Markup = "<b>" + "Remote Path:" + "</b>", Markup = "<b>" + "Remote Path" + "</b>",
Xalign = 0 Xalign = 0
}, true, true, 0); }, true, true, 0);
@ -302,8 +302,11 @@ namespace SparkleShare {
AddOption (check_button); AddOption (check_button);
AddButton (cancel_button); AddButton (cancel_button);
AddButton (add_button); AddButton (add_button);
// TODO: unfocused treeview row: make background grey
Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1); Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
tree_view.GrabFocus ();
} }
if (type == PageType.Invite) { if (type == PageType.Invite) {
@ -681,7 +684,7 @@ namespace SparkleShare {
private void RenderServiceColumn (TreeViewColumn column, CellRenderer cell, private void RenderServiceColumn (TreeViewColumn column, CellRenderer cell,
ITreeModel model, TreeIter iter) ITreeModel model, TreeIter iter)
{ {
string markup = (string) model.GetValue (iter, 1); string markup = (string) model.GetValue (iter, 1);
TreeSelection selection = (column.TreeView as TreeView).Selection; TreeSelection selection = (column.TreeView as TreeView).Selection;
if (selection.IterIsSelected (iter)) { if (selection.IterIsSelected (iter)) {

View file

@ -53,22 +53,17 @@ namespace SparkleShare {
Deletable = false; Deletable = false;
TypeHint = Gdk.WindowTypeHint.Dialog; TypeHint = Gdk.WindowTypeHint.Dialog;
DeleteEvent += delegate (object sender, DeleteEventArgs args) { DeleteEvent += delegate (object sender, DeleteEventArgs args) { args.RetVal = true; };
args.RetVal = true;
};
Gdk.Color color = SparkleUIHelpers.RGBAToColor (StyleContext.GetColor (StateFlags.Insensitive)); Gdk.Color color = SparkleUIHelpers.RGBAToColor (StyleContext.GetColor (StateFlags.Insensitive));
SecondaryTextColor = SparkleUIHelpers.ColorToHex (color); SecondaryTextColor = SparkleUIHelpers.ColorToHex (color);
SecondaryTextColorSelected = color = MixColors (
SparkleUIHelpers.ColorToHex ( SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetColor (StateFlags.Selected)),
MixColors ( SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected)),
new TreeView ().StyleContext.GetColor (StateFlags.Selected), 0.39);
new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected),
0.15 SecondaryTextColorSelected = SparkleUIHelpers.ColorToHex (color);
)
);
SetSizeRequest (680, 400); SetSizeRequest (680, 400);
HBox = new HBox (false, 0); HBox = new HBox (false, 0);
@ -183,15 +178,15 @@ namespace SparkleShare {
} }
private Gdk.Color MixColors (Gdk.RGBA first_color, Gdk.RGBA second_color, double ratio) private Gdk.Color MixColors (Gdk.Color first_color, Gdk.Color second_color, double ratio)
{ {
return new Gdk.Color ( return new Gdk.Color (
Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) + Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) +
second_color.Red * ratio))) / 65535), second_color.Red * ratio))) / 65535),
Convert.ToByte ((255 * (Math.Min (65535, first_color.Green * (1.0 - ratio) + Convert.ToByte ((255 * (Math.Min (65535, first_color.Green * (1.0 - ratio) +
second_color.Green * ratio))) / 65535), second_color.Green * ratio))) / 65535),
Convert.ToByte ((255 * (Math.Min (65535, first_color.Blue * (1.0 - ratio) + Convert.ToByte ((255 * (Math.Min (65535, first_color.Blue * (1.0 - ratio) +
second_color.Blue * ratio))) / 65535) second_color.Blue * ratio))) / 65535)
); );
} }
} }

View file

@ -67,13 +67,7 @@ namespace SparkleShare {
(int) Math.Truncate (color.Green / 256.00), (int) Math.Truncate (color.Green / 256.00),
(int) Math.Truncate (color.Blue / 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) { public static Gdk.Color RGBAToColor (Gdk.RGBA rgba) {
return new Gdk.Color () { return new Gdk.Color () {
@ -82,5 +76,11 @@ namespace SparkleShare {
Blue = (ushort)(rgba.Blue * 65535) Blue = (ushort)(rgba.Blue * 65535)
}; };
} }
public static string RGBAToHex (Gdk.RGBA rgba)
{
return ColorToHex (RGBAToColor (rgba));
}
} }
} }