From 2e8d270ac47b220f42aabedff5d69d73e4c96390 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 5 May 2010 01:17:08 +0100 Subject: [PATCH] rename stuff and add separate bubble class --- SparkleShare/Main.cs | 14 +++------ SparkleShare/Repository.cs | 28 +++++++---------- SparkleShare/SparkleBubble.cs | 31 +++++++++++++++++++ SparkleShare/SparkleShare.csproj | 9 +++--- ...hareStatusIcon.cs => SparkleStatusIcon.cs} | 4 +-- .../{SparkleShareUI.cs => SparkleUI.cs} | 25 +++++++-------- ...SparkleShareWindow.cs => SparkleWindow.cs} | 25 +++++++-------- 7 files changed, 77 insertions(+), 59 deletions(-) create mode 100644 SparkleShare/SparkleBubble.cs rename SparkleShare/{SparkleShareStatusIcon.cs => SparkleStatusIcon.cs} (92%) rename SparkleShare/{SparkleShareUI.cs => SparkleUI.cs} (82%) rename SparkleShare/{SparkleShareWindow.cs => SparkleWindow.cs} (96%) diff --git a/SparkleShare/Main.cs b/SparkleShare/Main.cs index 1cbbea7c..6ae1b363 100644 --- a/SparkleShare/Main.cs +++ b/SparkleShare/Main.cs @@ -15,7 +15,6 @@ // along with this program. If not, see . 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 { } } - - -} \ No newline at end of file +} diff --git a/SparkleShare/Repository.cs b/SparkleShare/Repository.cs index a8be1a1f..15a423d4 100644 --- a/SparkleShare/Repository.cs +++ b/SparkleShare/Repository.cs @@ -15,7 +15,6 @@ // along with this program. If not, see . 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 { } -} \ No newline at end of file +} diff --git a/SparkleShare/SparkleBubble.cs b/SparkleShare/SparkleBubble.cs new file mode 100644 index 00000000..9ed4d264 --- /dev/null +++ b/SparkleShare/SparkleBubble.cs @@ -0,0 +1,31 @@ +// SparkleShare, an instant update workflow to Git. +// Copyright (C) 2010 Hylke Bons +// +// 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 . + +using Notifications; + +namespace SparkleShare { + + public class SparkleBubble : Notification { + + public SparkleBubble (string Title, string Subtext) : base (Title, Subtext) { + Timeout = 4500; + Urgency = Urgency.Normal; + Show (); + } + + } + +} diff --git a/SparkleShare/SparkleShare.csproj b/SparkleShare/SparkleShare.csproj index 799aee5c..696a2313 100644 --- a/SparkleShare/SparkleShare.csproj +++ b/SparkleShare/SparkleShare.csproj @@ -34,8 +34,9 @@ - - - + + + + - \ No newline at end of file + diff --git a/SparkleShare/SparkleShareStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs similarity index 92% rename from SparkleShare/SparkleShareStatusIcon.cs rename to SparkleShare/SparkleStatusIcon.cs index 35016c90..ba520712 100644 --- a/SparkleShare/SparkleShareStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -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"; diff --git a/SparkleShare/SparkleShareUI.cs b/SparkleShare/SparkleUI.cs similarity index 82% rename from SparkleShare/SparkleShareUI.cs rename to SparkleShare/SparkleUI.cs index d6e2844b..e38e95b3 100644 --- a/SparkleShare/SparkleShareUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -15,7 +15,6 @@ // along with this program. If not, see . 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 () { } diff --git a/SparkleShare/SparkleShareWindow.cs b/SparkleShare/SparkleWindow.cs similarity index 96% rename from SparkleShare/SparkleShareWindow.cs rename to SparkleShare/SparkleWindow.cs index af6605f4..cafa6add 100644 --- a/SparkleShare/SparkleShareWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -15,7 +15,6 @@ // along with this program. If not, see . 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 ();