rethink UI
This commit is contained in:
parent
347a127c2e
commit
41150946a8
|
@ -23,6 +23,7 @@ namespace SparkleShare {
|
||||||
// This is SparkleShare!
|
// This is SparkleShare!
|
||||||
public class SparkleShare {
|
public class SparkleShare {
|
||||||
|
|
||||||
|
public static SparkleRepo [] Repositories;
|
||||||
public static SparkleUI SparkleUI;
|
public static SparkleUI SparkleUI;
|
||||||
|
|
||||||
public static void Main (string [] args) {
|
public static void Main (string [] args) {
|
||||||
|
@ -64,7 +65,6 @@ namespace SparkleShare {
|
||||||
Gtk.Application.Init ();
|
Gtk.Application.Init ();
|
||||||
|
|
||||||
SparkleUI = new SparkleUI (HideUI);
|
SparkleUI = new SparkleUI (HideUI);
|
||||||
SparkleUI.StartMonitoring ();
|
|
||||||
|
|
||||||
// The main loop
|
// The main loop
|
||||||
Gtk.Application.Run ();
|
Gtk.Application.Run ();
|
||||||
|
|
|
@ -15,12 +15,42 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using SparkleShare;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleStatusIcon : StatusIcon {
|
public class SparkleStatusIcon : StatusIcon {
|
||||||
|
|
||||||
public SparkleStatusIcon () : base () {
|
public SparkleStatusIcon () : base () {
|
||||||
|
Activate += delegate {
|
||||||
|
|
||||||
|
|
||||||
|
Menu popupMenu = new Menu();
|
||||||
|
|
||||||
|
foreach (SparkleRepo SparkleRepo in SparkleShare.Repositories) {
|
||||||
|
ImageMenuItem Item = new ImageMenuItem (SparkleRepo.Name);
|
||||||
|
Item.Image = new Image (SparkleHelpers.GetIcon ("folder", 16));
|
||||||
|
|
||||||
|
Item.Activated += delegate { SparkleWindow SparkleWindow = new SparkleWindow (SparkleRepo);
|
||||||
|
SparkleWindow.ShowAll ();Console.WriteLine (SparkleRepo.Name); };
|
||||||
|
popupMenu.Add(Item);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
ImageMenuItem menuItemQuit = new ImageMenuItem ("Quit SparkleShare");
|
||||||
|
popupMenu.Add(menuItemQuit);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Quit the application when quit has been clicked.
|
||||||
|
menuItemQuit.Activated += delegate { Environment.Exit(0); };
|
||||||
|
popupMenu.ShowAll();
|
||||||
|
popupMenu.Popup();
|
||||||
|
|
||||||
|
};
|
||||||
SetIdleState ();
|
SetIdleState ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +68,14 @@ namespace SparkleShare {
|
||||||
// IconName = "folder-sync-error";
|
// IconName = "folder-sync-error";
|
||||||
// Tooltip = "SparkleShare, something went wrong";
|
// Tooltip = "SparkleShare, something went wrong";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Quits the program
|
||||||
|
public void Quit (object o, EventArgs args) {
|
||||||
|
System.IO.File.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath +
|
||||||
|
"sparkleshare.pid"));
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,8 @@ using System.IO;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
// Holds the status icon, window and repository list
|
|
||||||
public class SparkleUI {
|
public class SparkleUI {
|
||||||
|
|
||||||
public SparkleRepo [] Repositories;
|
|
||||||
|
|
||||||
public SparkleWindow SparkleWindow;
|
|
||||||
public static SparkleStatusIcon NotificationIcon;
|
public static SparkleStatusIcon NotificationIcon;
|
||||||
|
|
||||||
public SparkleUI (bool HideUI) {
|
public SparkleUI (bool HideUI) {
|
||||||
|
@ -81,7 +77,6 @@ namespace SparkleShare {
|
||||||
".git"))) {
|
".git"))) {
|
||||||
TmpRepos [i] = new SparkleRepo (Folder);
|
TmpRepos [i] = new SparkleRepo (Folder);
|
||||||
i++;
|
i++;
|
||||||
Console.WriteLine (Folder);
|
|
||||||
|
|
||||||
// Attach emblems
|
// Attach emblems
|
||||||
if (SparklePlatform.Name.Equals ("GNOME")) {
|
if (SparklePlatform.Name.Equals ("GNOME")) {
|
||||||
|
@ -96,22 +91,34 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Repositories = new SparkleRepo [i];
|
SparkleShare.Repositories = new SparkleRepo [i];
|
||||||
Array.Copy (TmpRepos, Repositories, i);
|
Array.Copy (TmpRepos, SparkleShare.Repositories, i);
|
||||||
|
|
||||||
// Don't create the window and status
|
// Don't create the window and status
|
||||||
// icon when --disable-gui was given
|
// icon when --disable-gui was given
|
||||||
if (!HideUI) {
|
if (!HideUI) {
|
||||||
|
|
||||||
// Create the window
|
|
||||||
SparkleWindow = new SparkleWindow (Repositories);
|
|
||||||
SparkleWindow.DeleteEvent += CloseSparkleWindow;
|
|
||||||
|
|
||||||
// Create the status icon
|
// Create the status icon
|
||||||
NotificationIcon = new SparkleStatusIcon ();
|
NotificationIcon = new SparkleStatusIcon ();
|
||||||
NotificationIcon.Activate += delegate {
|
|
||||||
SparkleWindow.ToggleVisibility ();
|
// Show a notification if there are no folders yet
|
||||||
};
|
if (SparkleShare.Repositories.Length == 0) {
|
||||||
|
|
||||||
|
SparkleBubble NoFoldersBubble;
|
||||||
|
NoFoldersBubble = new SparkleBubble ("Welcome to SparkleShare!",
|
||||||
|
"You don't have any " +
|
||||||
|
"folders set up yet.\n" +
|
||||||
|
"Please create some in " +
|
||||||
|
"the SparkleShare folder.");
|
||||||
|
|
||||||
|
NoFoldersBubble.IconName = "folder-sparkleshare";
|
||||||
|
NoFoldersBubble.AddAction ("", "Open SparkleShare Folder", delegate {
|
||||||
|
Process.StartInfo.FileName = "xdg-open";
|
||||||
|
Process.StartInfo.Arguments = SparklePaths.SparklePath;
|
||||||
|
Process.Start();
|
||||||
|
} );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,21 +153,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes the window
|
|
||||||
public void CloseSparkleWindow (object o, DeleteEventArgs args) {
|
|
||||||
SparkleWindow = new SparkleWindow (Repositories);
|
|
||||||
SparkleWindow.DeleteEvent += CloseSparkleWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartMonitoring () { }
|
|
||||||
public void StopMonitoring () { }
|
|
||||||
|
|
||||||
// Quits the program
|
|
||||||
public void Quit (object o, EventArgs args) {
|
|
||||||
File.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath +
|
|
||||||
"sparkleshare.pid"));
|
|
||||||
Application.Quit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,80 +26,36 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleWindow : Window {
|
public class SparkleWindow : Window {
|
||||||
|
|
||||||
private bool Visibility;
|
|
||||||
private VBox LayoutVerticalLeft;
|
|
||||||
private VBox LayoutVerticalRight;
|
|
||||||
private HBox LayoutHorizontal;
|
|
||||||
|
|
||||||
public Notebook Notebook;
|
|
||||||
private TreeView ReposView;
|
|
||||||
private ListStore ReposStore;
|
|
||||||
private SparkleRepo [] Repositories;
|
|
||||||
|
|
||||||
public SparkleWindow (SparkleRepo [] R) : base ("SparkleShare") {
|
private SparkleRepo SparkleRepo;
|
||||||
|
|
||||||
Repositories = R;
|
|
||||||
|
|
||||||
// Show a notification if there are no folders yet
|
|
||||||
if (Repositories.Length == 0) {
|
|
||||||
|
|
||||||
SparkleBubble NoFoldersBubble;
|
|
||||||
NoFoldersBubble = new SparkleBubble ("Welcome to SparkleShare!",
|
|
||||||
"You don't have any " +
|
|
||||||
"folders set up yet.\n" +
|
|
||||||
"Please create some in " +
|
|
||||||
"the SparkleShare folder.");
|
|
||||||
|
|
||||||
NoFoldersBubble.IconName = "folder-sparkleshare";
|
public SparkleWindow (SparkleRepo Repo) : base ("") {
|
||||||
NoFoldersBubble.AddAction ("", "Open Folder",
|
SparkleRepo = Repo;
|
||||||
delegate {
|
|
||||||
Process Process = new Process ();
|
|
||||||
Process.StartInfo.FileName =
|
|
||||||
"xdg-open";
|
|
||||||
Process.StartInfo.Arguments =
|
|
||||||
SparklePaths.SparklePath;
|
|
||||||
Process.Start();
|
|
||||||
} );
|
|
||||||
|
|
||||||
} else CreateWindow ();
|
CreateWindow ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateWindow () {
|
public void CreateWindow () {
|
||||||
|
|
||||||
Visibility = false;
|
SetSizeRequest (900, 540);
|
||||||
SetSizeRequest (720, 540);
|
|
||||||
SetPosition (WindowPosition.Center);
|
SetPosition (WindowPosition.Center);
|
||||||
BorderWidth = 6;
|
BorderWidth = 6;
|
||||||
|
Title = "Happenings in ‘" + SparkleRepo.Name + "’";
|
||||||
IconName = "folder-sparkleshare";
|
IconName = "folder-sparkleshare";
|
||||||
|
|
||||||
VBox LayoutVertical = new VBox (false, 0);
|
VBox LayoutVertical = new VBox (false, 0);
|
||||||
|
|
||||||
Notebook = new Notebook ();
|
|
||||||
Notebook.BorderWidth = 6;
|
|
||||||
|
|
||||||
LayoutHorizontal = new HBox (false, 0);
|
HBox HBox= new HBox (true, 6);
|
||||||
|
HBox.PackStart (CreatePeopleList());
|
||||||
|
HBox.PackStart (CreateEventLog());
|
||||||
|
|
||||||
ReposStore = new ListStore (typeof (Gdk.Pixbuf),
|
LayoutVertical.PackStart (HBox, true, true, 0);
|
||||||
typeof (string),
|
LayoutVertical.PackStart (CreateDetailedView(), false, false, 0);
|
||||||
typeof (SparkleRepo));
|
|
||||||
|
|
||||||
LayoutVerticalLeft = CreateReposList ();
|
|
||||||
LayoutVerticalLeft.BorderWidth = 12;
|
|
||||||
|
|
||||||
LayoutVerticalRight =
|
|
||||||
CreateDetailedView (Repositories [0]);
|
|
||||||
|
|
||||||
LayoutHorizontal.PackStart (LayoutVerticalLeft,
|
|
||||||
false, false, 0);
|
|
||||||
|
|
||||||
LayoutHorizontal.PackStart (LayoutVerticalRight,
|
|
||||||
true, true, 12);
|
|
||||||
|
|
||||||
Notebook.AppendPage (CreateEventLog (), new Label ("Events"));
|
|
||||||
Notebook.AppendPage (LayoutHorizontal, new Label ("Folders"));
|
|
||||||
|
|
||||||
LayoutVertical.PackStart (Notebook, true, true, 0);
|
|
||||||
|
|
||||||
HButtonBox DialogButtons = new HButtonBox ();
|
HButtonBox DialogButtons = new HButtonBox ();
|
||||||
DialogButtons.Layout = ButtonBoxStyle.End;
|
DialogButtons.Layout = ButtonBoxStyle.End;
|
||||||
|
@ -107,8 +63,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Button CloseButton = new Button (Stock.Close);
|
Button CloseButton = new Button (Stock.Close);
|
||||||
CloseButton.Clicked += delegate (object o, EventArgs args) {
|
CloseButton.Clicked += delegate (object o, EventArgs args) {
|
||||||
Visibility = false;
|
Destroy ();
|
||||||
HideAll ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogButtons.Add (CloseButton);
|
DialogButtons.Add (CloseButton);
|
||||||
|
@ -143,72 +98,8 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Creates a visual list of repositories
|
|
||||||
public VBox CreateReposList() {
|
|
||||||
|
|
||||||
Gdk.Pixbuf FolderIcon = SparkleHelpers.GetIcon ("folder", 32);
|
|
||||||
|
|
||||||
TreeIter ReposIter;
|
|
||||||
foreach (SparkleRepo SparkleRepo in Repositories) {
|
|
||||||
|
|
||||||
ReposIter = ReposStore.Prepend ();
|
|
||||||
|
|
||||||
ReposStore.SetValue (ReposIter, 0, FolderIcon);
|
|
||||||
|
|
||||||
ReposStore.SetValue (ReposIter, 1, SparkleRepo.Name + " \n" +
|
|
||||||
SparkleRepo.Domain + " ");
|
|
||||||
|
|
||||||
ReposStore.SetValue (ReposIter, 2, SparkleRepo);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrolledWindow ScrolledWindow = new ScrolledWindow ();
|
|
||||||
|
|
||||||
ReposView = new TreeView (ReposStore);
|
|
||||||
ReposView.HeadersVisible = false;
|
|
||||||
|
|
||||||
ReposView.AppendColumn ("", new CellRendererPixbuf () , "pixbuf", 0);
|
|
||||||
ReposView.AppendColumn ("", new Gtk.CellRendererText (), "text", 1);
|
|
||||||
|
|
||||||
TreeViewColumn [] ReposViewColumns = ReposView.Columns;
|
|
||||||
|
|
||||||
ReposViewColumns [0].MinWidth = 48;
|
|
||||||
|
|
||||||
ReposStore.IterNthChild (out ReposIter, 0);
|
|
||||||
ReposView.ActivateRow (ReposStore.GetPath (ReposIter),
|
|
||||||
ReposViewColumns [1]);
|
|
||||||
|
|
||||||
// Update the detailed view when something
|
|
||||||
// gets selected in the folders list.
|
|
||||||
ReposView.CursorChanged += delegate {
|
|
||||||
|
|
||||||
TreeSelection Selection = ReposView.Selection;;
|
|
||||||
TreeIter Iter = new TreeIter ();;
|
|
||||||
|
|
||||||
Selection.GetSelected (out Iter);
|
|
||||||
|
|
||||||
SparkleRepo SparkleRepo =
|
|
||||||
(SparkleRepo) ReposStore.GetValue (Iter, 2);
|
|
||||||
|
|
||||||
LayoutHorizontal.Remove (LayoutVerticalRight);
|
|
||||||
LayoutVerticalRight = CreateDetailedView (SparkleRepo);
|
|
||||||
LayoutHorizontal.PackStart (LayoutVerticalRight, true, true, 12);
|
|
||||||
ShowAll ();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ScrolledWindow.AddWithViewport (ReposView);
|
|
||||||
ScrolledWindow.WidthRequest = 200;
|
|
||||||
VBox VBox = new VBox (false, 6);
|
|
||||||
VBox.PackStart (ScrolledWindow, true, true, 0);
|
|
||||||
|
|
||||||
return VBox;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates the detailed view
|
// Creates the detailed view
|
||||||
public VBox CreateDetailedView (SparkleRepo SparkleRepo) {
|
public Table CreateDetailedView () {
|
||||||
|
|
||||||
// Create box layout for Remote Address
|
// Create box layout for Remote Address
|
||||||
HBox RemoteUrlBox = new HBox (false, 0);
|
HBox RemoteUrlBox = new HBox (false, 0);
|
||||||
|
@ -280,29 +171,17 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
VBox VBox = new VBox (false, 0);
|
|
||||||
|
|
||||||
Table Table = new Table(7, 2, false);
|
Table Table = new Table(2, 2, true);
|
||||||
Table.RowSpacing = 6;
|
Table.RowSpacing = 3;
|
||||||
|
Table.ColumnSpacing = 12;
|
||||||
|
Table.BorderWidth = 9;
|
||||||
|
Table.Attach (RemoteUrlBox, 0, 1, 0, 1);
|
||||||
|
Table.Attach (LocalPathBox, 0, 1, 1, 2);
|
||||||
|
Table.Attach (NotifyChangesCheckButton, 1, 2, 0, 1);
|
||||||
|
Table.Attach (SyncChangesCheckButton, 1, 2, 1, 2);
|
||||||
|
|
||||||
Table.Attach (RemoteUrlBox, 0, 2, 0, 1);
|
return Table;
|
||||||
Table.Attach (LocalPathBox, 0, 2, 1, 2);
|
|
||||||
Table.Attach (NotifyChangesCheckButton, 0, 2, 4, 5);
|
|
||||||
Table.Attach (SyncChangesCheckButton, 0, 2, 5, 6);
|
|
||||||
|
|
||||||
Label PeopleLabel =
|
|
||||||
new Label ("<span font_size='large'><b>Active users" +
|
|
||||||
"</b></span>");
|
|
||||||
|
|
||||||
PeopleLabel.UseMarkup = true;
|
|
||||||
PeopleLabel.SetAlignment (0, 0);
|
|
||||||
|
|
||||||
VBox.PackStart (Table, false, false, 12);
|
|
||||||
|
|
||||||
VBox.PackStart (PeopleLabel, false, false, 0);
|
|
||||||
VBox.PackStart (CreatePeopleList (SparkleRepo ), true, true, 12);
|
|
||||||
|
|
||||||
return VBox;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,11 +198,11 @@ namespace SparkleShare {
|
||||||
Process.StartInfo.FileName = "git";
|
Process.StartInfo.FileName = "git";
|
||||||
|
|
||||||
string Output = "";
|
string Output = "";
|
||||||
foreach (SparkleRepo SparkleRepo in Repositories) {
|
foreach (SparkleRepo SparkleRepo in SparkleShare.Repositories) {
|
||||||
|
|
||||||
// We're using the snowman here to separate messages :)
|
// We're using the snowman here to separate messages :)
|
||||||
Process.StartInfo.Arguments =
|
Process.StartInfo.Arguments =
|
||||||
"log --format=\"%at☃In ‘" + SparkleRepo.Name + "’, %an %s☃%cr\" -25";
|
"log --format=\"%at☃%an %s☃%cr\" -25";
|
||||||
|
|
||||||
Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
|
Process.StartInfo.WorkingDirectory = SparkleRepo.LocalPath;
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
@ -388,14 +267,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
ScrolledWindow ScrolledWindow = new ScrolledWindow ();
|
ScrolledWindow ScrolledWindow = new ScrolledWindow ();
|
||||||
ScrolledWindow.AddWithViewport (LogView);
|
ScrolledWindow.AddWithViewport (LogView);
|
||||||
ScrolledWindow.BorderWidth = 12;
|
|
||||||
|
|
||||||
return ScrolledWindow;
|
return ScrolledWindow;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a visual list of people working in the repo
|
// Creates a visual list of people working in the repo
|
||||||
public ScrolledWindow CreatePeopleList (SparkleRepo SparkleRepo) {
|
public ScrolledWindow CreatePeopleList () {
|
||||||
|
|
||||||
Process Process = new Process ();
|
Process Process = new Process ();
|
||||||
Process.EnableRaisingEvents = false;
|
Process.EnableRaisingEvents = false;
|
||||||
|
@ -460,19 +338,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shows or hides the window
|
|
||||||
public void ToggleVisibility() {
|
|
||||||
if (Repositories.Length > 0) {
|
|
||||||
Present ();
|
|
||||||
if (Visibility) {
|
|
||||||
if (HasFocus)
|
|
||||||
HideAll ();
|
|
||||||
} else {
|
|
||||||
ShowAll ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue