rename stuff and add separate bubble class
This commit is contained in:
parent
2ce523a263
commit
2e8d270ac4
|
@ -15,7 +15,6 @@
|
||||||
// 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 Notifications;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -26,15 +25,12 @@ using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
// This is SparkleShare!
|
// This is SparkleShare!
|
||||||
public class SparkleShare {
|
public class SparkleShare {
|
||||||
|
|
||||||
|
public static SparkleUI SparkleUI;
|
||||||
|
|
||||||
public static SparkleShareUI SparkleShareUI;
|
|
||||||
|
|
||||||
public static void Main (string [] args) {
|
public static void Main (string [] args) {
|
||||||
|
|
||||||
|
@ -73,8 +69,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Gtk.Application.Init ();
|
Gtk.Application.Init ();
|
||||||
|
|
||||||
SparkleShareUI = new SparkleShareUI (HideUI);
|
SparkleUI = new SparkleUI (HideUI);
|
||||||
SparkleShareUI.StartMonitoring ();
|
SparkleUI.StartMonitoring ();
|
||||||
|
|
||||||
Gtk.Application.Run ();
|
Gtk.Application.Run ();
|
||||||
|
|
||||||
|
@ -101,6 +97,4 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,7 +15,6 @@
|
||||||
// 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 Notifications;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -206,7 +205,7 @@ namespace SparkleShare {
|
||||||
Console.WriteLine ("[Git][" + Name + "] Commiting changes...");
|
Console.WriteLine ("[Git][" + Name + "] Commiting changes...");
|
||||||
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
|
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
ShowEventNotification (UserName + " " + Message,
|
ShowEventBubble (UserName + " " + Message,
|
||||||
GetAvatarFileName (UserEmail, 48), true);
|
GetAvatarFileName (UserEmail, 48), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ namespace SparkleShare {
|
||||||
Process.Start();
|
Process.Start();
|
||||||
string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim ();
|
string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim ();
|
||||||
|
|
||||||
ShowEventNotification (LastCommitUserName + " " + LastCommitMessage,
|
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage,
|
||||||
GetAvatarFileName (LastCommitEmail, 48), true);
|
GetAvatarFileName (LastCommitEmail, 48), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -374,25 +373,22 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shows a notification with text and image
|
// Shows a notification with text and image
|
||||||
public void ShowEventNotification (string Title,
|
public void ShowEventBubble (string Title,
|
||||||
string IconFileName,
|
string IconFileName,
|
||||||
bool ShowButtons) {
|
bool ShowButtons) {
|
||||||
|
|
||||||
Notification Notification = new Notification (Title, " ");
|
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
|
||||||
Notification.Urgency = Urgency.Low;
|
StuffChangedBubble.Icon = new Gdk.Pixbuf (IconFileName);
|
||||||
Notification.Timeout = 4500;
|
|
||||||
Notification.Icon = new Gdk.Pixbuf (IconFileName);
|
|
||||||
|
|
||||||
// Add a button to open the folder where the changed file is
|
// Add a button to open the folder where the changed file is
|
||||||
if (ShowButtons)
|
if (ShowButtons)
|
||||||
Notification.AddAction ("", "Open Folder",
|
StuffChangedBubble.AddAction ("", "Open Folder",
|
||||||
delegate (object o, ActionArgs args) {
|
delegate {
|
||||||
Process.StartInfo.FileName = "xdg-open";
|
Process.StartInfo.FileName = "xdg-open";
|
||||||
Process.StartInfo.Arguments = LocalPath;
|
Process.StartInfo.Arguments = LocalPath;
|
||||||
Process.Start();
|
Process.Start();
|
||||||
Process.StartInfo.FileName = "git";
|
Process.StartInfo.FileName = "git";
|
||||||
} );
|
} );
|
||||||
Notification.Show ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
31
SparkleShare/SparkleBubble.cs
Normal file
31
SparkleShare/SparkleBubble.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// SparkleShare, an instant update workflow to Git.
|
||||||
|
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using Notifications;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
public class SparkleBubble : Notification {
|
||||||
|
|
||||||
|
public SparkleBubble (string Title, string Subtext) : base (Title, Subtext) {
|
||||||
|
Timeout = 4500;
|
||||||
|
Urgency = Urgency.Normal;
|
||||||
|
Show ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -34,8 +34,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="Repository.cs" />
|
<Compile Include="Repository.cs" />
|
||||||
<Compile Include="SparkleShareUI.cs" />
|
<Compile Include="SparkleUI.cs" />
|
||||||
<Compile Include="SparkleShareStatusIcon.cs" />
|
<Compile Include="SparkleStatusIcon.cs" />
|
||||||
<Compile Include="SparkleShareWindow.cs" />
|
<Compile Include="SparkleWindow.cs" />
|
||||||
|
<Compile Include="SparkleBubble.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -28,9 +28,9 @@ using System.Timers;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleShareStatusIcon : StatusIcon {
|
public class SparkleStatusIcon : StatusIcon {
|
||||||
|
|
||||||
public SparkleShareStatusIcon () : base () {
|
public SparkleStatusIcon () : base () {
|
||||||
|
|
||||||
IconName = "folder-sparkleshare";
|
IconName = "folder-sparkleshare";
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
// 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 Notifications;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -29,13 +28,13 @@ using System.Timers;
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
// Holds the status icon, window and repository list
|
// Holds the status icon, window and repository list
|
||||||
public class SparkleShareUI {
|
public class SparkleUI {
|
||||||
|
|
||||||
public SparkleShareWindow SparkleShareWindow;
|
public SparkleWindow SparkleWindow;
|
||||||
public SparkleShareStatusIcon SparkleShareStatusIcon;
|
public SparkleStatusIcon SparkleStatusIcon;
|
||||||
public Repository [] Repositories;
|
public Repository [] Repositories;
|
||||||
|
|
||||||
public SparkleShareUI (bool HideUI) {
|
public SparkleUI (bool HideUI) {
|
||||||
|
|
||||||
Process Process = new Process();
|
Process Process = new Process();
|
||||||
Process.EnableRaisingEvents = false;
|
Process.EnableRaisingEvents = false;
|
||||||
|
@ -90,13 +89,13 @@ namespace SparkleShare {
|
||||||
if (!HideUI) {
|
if (!HideUI) {
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
SparkleShareWindow = new SparkleShareWindow (Repositories);
|
SparkleWindow = new SparkleWindow (Repositories);
|
||||||
SparkleShareWindow.DeleteEvent += CloseSparkleShareWindow;
|
SparkleWindow.DeleteEvent += CloseSparkleWindow;
|
||||||
|
|
||||||
// Create the status icon
|
// Create the status icon
|
||||||
SparkleShareStatusIcon = new SparkleShareStatusIcon ();
|
SparkleStatusIcon = new SparkleStatusIcon ();
|
||||||
SparkleShareStatusIcon.Activate += delegate {
|
SparkleStatusIcon.Activate += delegate {
|
||||||
SparkleShareWindow.ToggleVisibility ();
|
SparkleWindow.ToggleVisibility ();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -104,9 +103,9 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes the window
|
// Closes the window
|
||||||
public void CloseSparkleShareWindow (object o, DeleteEventArgs args) {
|
public void CloseSparkleWindow (object o, DeleteEventArgs args) {
|
||||||
SparkleShareWindow = new SparkleShareWindow (Repositories);
|
SparkleWindow = new SparkleWindow (Repositories);
|
||||||
SparkleShareWindow.DeleteEvent += CloseSparkleShareWindow;
|
SparkleWindow.DeleteEvent += CloseSparkleWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartMonitoring () { }
|
public void StartMonitoring () { }
|
|
@ -15,7 +15,6 @@
|
||||||
// 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 Notifications;
|
|
||||||
using SparkleShare;
|
using SparkleShare;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -29,7 +28,7 @@ using System.Timers;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
public class SparkleShareWindow : Window {
|
public class SparkleWindow : Window {
|
||||||
|
|
||||||
private bool Visibility;
|
private bool Visibility;
|
||||||
private VBox LayoutVerticalLeft;
|
private VBox LayoutVerticalLeft;
|
||||||
|
@ -40,23 +39,21 @@ namespace SparkleShare {
|
||||||
private ListStore ReposStore;
|
private ListStore ReposStore;
|
||||||
private Repository [] Repositories;
|
private Repository [] Repositories;
|
||||||
|
|
||||||
public SparkleShareWindow (Repository [] R) : base ("SparkleShare") {
|
public SparkleWindow (Repository [] R) : base ("SparkleShare") {
|
||||||
|
|
||||||
Repositories = R;
|
Repositories = R;
|
||||||
|
|
||||||
// Show a notification if there are no folders yet
|
// Show a notification if there are no folders yet
|
||||||
if (Repositories.Length == 0) {
|
if (Repositories.Length == 0) {
|
||||||
Notification Notification;
|
|
||||||
Notification = new Notification ("Welcome to SparkleShare!",
|
SparkleBubble NoFoldersBubble;
|
||||||
|
NoFoldersBubble = new SparkleBubble ("Welcome to SparkleShare!",
|
||||||
"You don't have any folders " +
|
"You don't have any folders " +
|
||||||
"configured yet.");
|
"configured yet.");
|
||||||
|
|
||||||
Notification.AddAction ("", "Add a Folder",
|
NoFoldersBubble.AddAction ("", "Add a Folder",
|
||||||
delegate { CreateAddDialog (); } );
|
delegate { CreateAddDialog (); } );
|
||||||
|
|
||||||
Notification.Urgency = Urgency.Normal;
|
|
||||||
Notification.Timeout = 7500;
|
|
||||||
Notification.Show ();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -440,11 +437,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public void CreateAddDialog () {
|
public void CreateAddDialog () {
|
||||||
|
|
||||||
Window AddDialog = new Window ("Add Folder");
|
Window AddDialog = new Window ("");
|
||||||
AddDialog.SetPosition (WindowPosition.Center);
|
AddDialog.SetPosition (WindowPosition.Center);
|
||||||
// AddDialog.SetSizeRequest (320, 200);
|
// AddDialog.SetSizeRequest (320, 200);
|
||||||
AddDialog.BorderWidth = 6;
|
AddDialog.BorderWidth = 6;
|
||||||
|
AddDialog.IconName = "folder-sparkleshare";
|
||||||
|
|
||||||
Label NameLabel = new Label ("Folder Name: ");
|
Label NameLabel = new Label ("Folder Name: ");
|
||||||
Entry NameEntry = new Entry ();
|
Entry NameEntry = new Entry ();
|
Loading…
Reference in a new issue