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/>.
|
||||
|
||||
using Gtk;
|
||||
using Notifications;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -26,15 +25,12 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
// This is SparkleShare!
|
||||
public class SparkleShare {
|
||||
|
||||
|
||||
|
||||
public static SparkleShareUI SparkleShareUI;
|
||||
public static SparkleUI SparkleUI;
|
||||
|
||||
public static void Main (string [] args) {
|
||||
|
||||
|
@ -73,8 +69,8 @@ namespace SparkleShare {
|
|||
|
||||
Gtk.Application.Init ();
|
||||
|
||||
SparkleShareUI = new SparkleShareUI (HideUI);
|
||||
SparkleShareUI.StartMonitoring ();
|
||||
SparkleUI = new SparkleUI (HideUI);
|
||||
SparkleUI.StartMonitoring ();
|
||||
|
||||
Gtk.Application.Run ();
|
||||
|
||||
|
@ -100,7 +96,5 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using Gtk;
|
||||
using Notifications;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -206,7 +205,7 @@ namespace SparkleShare {
|
|||
Console.WriteLine ("[Git][" + Name + "] Commiting changes...");
|
||||
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
|
||||
Process.Start();
|
||||
ShowEventNotification (UserName + " " + Message,
|
||||
ShowEventBubble (UserName + " " + Message,
|
||||
GetAvatarFileName (UserEmail, 48), true);
|
||||
}
|
||||
|
||||
|
@ -251,7 +250,7 @@ namespace SparkleShare {
|
|||
Process.Start();
|
||||
string LastCommitUserName = Process.StandardOutput.ReadToEnd().Trim ();
|
||||
|
||||
ShowEventNotification (LastCommitUserName + " " + LastCommitMessage,
|
||||
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage,
|
||||
GetAvatarFileName (LastCommitEmail, 48), true);
|
||||
|
||||
}
|
||||
|
@ -374,25 +373,22 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
// Shows a notification with text and image
|
||||
public void ShowEventNotification (string Title,
|
||||
string IconFileName,
|
||||
bool ShowButtons) {
|
||||
public void ShowEventBubble (string Title,
|
||||
string IconFileName,
|
||||
bool ShowButtons) {
|
||||
|
||||
Notification Notification = new Notification (Title, " ");
|
||||
Notification.Urgency = Urgency.Low;
|
||||
Notification.Timeout = 4500;
|
||||
Notification.Icon = new Gdk.Pixbuf (IconFileName);
|
||||
SparkleBubble StuffChangedBubble = new SparkleBubble (Title, "");
|
||||
StuffChangedBubble.Icon = new Gdk.Pixbuf (IconFileName);
|
||||
|
||||
// Add a button to open the folder where the changed file is
|
||||
if (ShowButtons)
|
||||
Notification.AddAction ("", "Open Folder",
|
||||
delegate (object o, ActionArgs args) {
|
||||
Process.StartInfo.FileName = "xdg-open";
|
||||
StuffChangedBubble.AddAction ("", "Open Folder",
|
||||
delegate {
|
||||
Process.StartInfo.FileName = "xdg-open";
|
||||
Process.StartInfo.Arguments = LocalPath;
|
||||
Process.Start();
|
||||
Process.StartInfo.FileName = "git";
|
||||
} );
|
||||
Notification.Show ();
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
@ -461,4 +457,4 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
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>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Repository.cs" />
|
||||
<Compile Include="SparkleShareUI.cs" />
|
||||
<Compile Include="SparkleShareStatusIcon.cs" />
|
||||
<Compile Include="SparkleShareWindow.cs" />
|
||||
<Compile Include="SparkleUI.cs" />
|
||||
<Compile Include="SparkleStatusIcon.cs" />
|
||||
<Compile Include="SparkleWindow.cs" />
|
||||
<Compile Include="SparkleBubble.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -28,9 +28,9 @@ using System.Timers;
|
|||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleShareStatusIcon : StatusIcon {
|
||||
public class SparkleStatusIcon : StatusIcon {
|
||||
|
||||
public SparkleShareStatusIcon () : base () {
|
||||
public SparkleStatusIcon () : base () {
|
||||
|
||||
IconName = "folder-sparkleshare";
|
||||
|
|
@ -15,7 +15,6 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using Gtk;
|
||||
using Notifications;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -29,13 +28,13 @@ using System.Timers;
|
|||
namespace SparkleShare {
|
||||
|
||||
// Holds the status icon, window and repository list
|
||||
public class SparkleShareUI {
|
||||
public class SparkleUI {
|
||||
|
||||
public SparkleShareWindow SparkleShareWindow;
|
||||
public SparkleShareStatusIcon SparkleShareStatusIcon;
|
||||
public SparkleWindow SparkleWindow;
|
||||
public SparkleStatusIcon SparkleStatusIcon;
|
||||
public Repository [] Repositories;
|
||||
|
||||
public SparkleShareUI (bool HideUI) {
|
||||
public SparkleUI (bool HideUI) {
|
||||
|
||||
Process Process = new Process();
|
||||
Process.EnableRaisingEvents = false;
|
||||
|
@ -90,13 +89,13 @@ namespace SparkleShare {
|
|||
if (!HideUI) {
|
||||
|
||||
// Create the window
|
||||
SparkleShareWindow = new SparkleShareWindow (Repositories);
|
||||
SparkleShareWindow.DeleteEvent += CloseSparkleShareWindow;
|
||||
SparkleWindow = new SparkleWindow (Repositories);
|
||||
SparkleWindow.DeleteEvent += CloseSparkleWindow;
|
||||
|
||||
// Create the status icon
|
||||
SparkleShareStatusIcon = new SparkleShareStatusIcon ();
|
||||
SparkleShareStatusIcon.Activate += delegate {
|
||||
SparkleShareWindow.ToggleVisibility ();
|
||||
SparkleStatusIcon = new SparkleStatusIcon ();
|
||||
SparkleStatusIcon.Activate += delegate {
|
||||
SparkleWindow.ToggleVisibility ();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -104,9 +103,9 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
// Closes the window
|
||||
public void CloseSparkleShareWindow (object o, DeleteEventArgs args) {
|
||||
SparkleShareWindow = new SparkleShareWindow (Repositories);
|
||||
SparkleShareWindow.DeleteEvent += CloseSparkleShareWindow;
|
||||
public void CloseSparkleWindow (object o, DeleteEventArgs args) {
|
||||
SparkleWindow = new SparkleWindow (Repositories);
|
||||
SparkleWindow.DeleteEvent += CloseSparkleWindow;
|
||||
}
|
||||
|
||||
public void StartMonitoring () { }
|
|
@ -15,7 +15,6 @@
|
|||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using Gtk;
|
||||
using Notifications;
|
||||
using SparkleShare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -29,7 +28,7 @@ using System.Timers;
|
|||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleShareWindow : Window {
|
||||
public class SparkleWindow : Window {
|
||||
|
||||
private bool Visibility;
|
||||
private VBox LayoutVerticalLeft;
|
||||
|
@ -40,23 +39,21 @@ namespace SparkleShare {
|
|||
private ListStore ReposStore;
|
||||
private Repository [] Repositories;
|
||||
|
||||
public SparkleShareWindow (Repository [] R) : base ("SparkleShare") {
|
||||
public SparkleWindow (Repository [] R) : base ("SparkleShare") {
|
||||
|
||||
Repositories = R;
|
||||
|
||||
// Show a notification if there are no folders yet
|
||||
if (Repositories.Length == 0) {
|
||||
Notification Notification;
|
||||
Notification = new Notification ("Welcome to SparkleShare!",
|
||||
"You don't have any folders " +
|
||||
"configured yet.");
|
||||
|
||||
Notification.AddAction ("", "Add a Folder",
|
||||
delegate { CreateAddDialog (); } );
|
||||
SparkleBubble NoFoldersBubble;
|
||||
NoFoldersBubble = new SparkleBubble ("Welcome to SparkleShare!",
|
||||
"You don't have any folders " +
|
||||
"configured yet.");
|
||||
|
||||
NoFoldersBubble.AddAction ("", "Add a Folder",
|
||||
delegate { CreateAddDialog (); } );
|
||||
|
||||
Notification.Urgency = Urgency.Normal;
|
||||
Notification.Timeout = 7500;
|
||||
Notification.Show ();
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -440,11 +437,11 @@ namespace SparkleShare {
|
|||
|
||||
public void CreateAddDialog () {
|
||||
|
||||
Window AddDialog = new Window ("Add Folder");
|
||||
Window AddDialog = new Window ("");
|
||||
AddDialog.SetPosition (WindowPosition.Center);
|
||||
// AddDialog.SetSizeRequest (320, 200);
|
||||
AddDialog.BorderWidth = 6;
|
||||
|
||||
AddDialog.IconName = "folder-sparkleshare";
|
||||
|
||||
Label NameLabel = new Label ("Folder Name: ");
|
||||
Entry NameEntry = new Entry ();
|
Loading…
Reference in a new issue