eventlog: Remove spinner code and use GTK+3's native spinner

This commit is contained in:
Hylke Bons 2013-10-09 12:58:14 +02:00
parent 715e4793cd
commit 9c8b7b72b0
5 changed files with 18 additions and 97 deletions

View file

@ -28,7 +28,6 @@ SOURCES = \
SparkleEventLog.cs \
SparkleSetup.cs \
SparkleSetupWindow.cs \
SparkleSpinner.cs \
SparkleStatusIcon.cs \
SparkleUI.cs \
SparkleUIHelpers.cs

View file

@ -23,7 +23,6 @@ system_theme_icons = \
status,process-syncing-error-48.png
app_theme_icons = \
animations,process-working-22.png \
status,document-added-12.png \
status,document-edited-12.png \
status,document-deleted-12.png \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

View file

@ -39,7 +39,8 @@ namespace SparkleShare {
private EventBox content_wrapper;
private ScrolledWindow scrolled_window;
// private WebView web_view;
private SparkleSpinner spinner;
private VBox spinner_wrapper;
private Spinner spinner;
public SparkleEventLog () : base ("")
@ -86,27 +87,29 @@ namespace SparkleShare {
layout_sizes.Add (this.history_label);
VBox layout_vertical = new VBox (false, 0);
this.spinner = new SparkleSpinner (22);
this.spinner = new Spinner ();
this.spinner_wrapper = new VBox ();
this.content_wrapper = new EventBox ();
this.scrolled_window = new ScrolledWindow ();
this.content_wrapper.OverrideBackgroundColor (StateFlags.Normal,
new Gdk.RGBA () { Red = 1, Green = 1, Blue=1, Alpha = 1 });
/*
this.web_view = new WebView () {
Editable = false
};
// this.web_view = new WebView () { Editable = false };
// this.web_view.NavigationRequested += WebViewNavigationRequested;
this.web_view.NavigationRequested += WebViewNavigationRequested;
*/
// this.scrolled_window.Add (this.web_view);
// this.scrolled_window.Add (this.web_view);
this.scrolled_window.AddWithViewport (new Button ("WebView"));
this.content_wrapper.Add (this.spinner);
this.spinner_wrapper = new VBox (false, 0);
this.spinner_wrapper.PackStart (new Label(""), true, true, 0);
this.spinner_wrapper.PackStart (this.spinner, false, false, 0);
this.spinner_wrapper.PackStart (new Label(""), true, true, 0);
this.spinner.SetSizeRequest (24, 24);
this.spinner.Start ();
this.content_wrapper.Add (this.spinner_wrapper);
this.layout_horizontal = new HBox (true, 0);
this.layout_horizontal.PackStart (layout_sizes, true, true, 12);
@ -157,15 +160,11 @@ namespace SparkleShare {
};
Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
Application.Invoke (delegate {
this.combo_box.Sensitive = enabled;
});
Application.Invoke (delegate { this.combo_box.Sensitive = enabled; });
};
Controller.UpdateContentEvent += delegate (string html) {
Application.Invoke (delegate {
UpdateContent (html);
});
Application.Invoke (delegate { UpdateContent (html); });
};
Controller.ContentLoadingEvent += delegate {
@ -173,7 +172,7 @@ namespace SparkleShare {
if (this.content_wrapper.Child != null)
this.content_wrapper.Remove (this.content_wrapper.Child);
this.content_wrapper.Add (this.spinner);
this.content_wrapper.Add (this.spinner_wrapper);
this.spinner.Start ();
this.content_wrapper.ShowAll ();
});

View file

@ -1,76 +0,0 @@
// SparkleShare, a collaboration and sharing tool.
// 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 System.Timers;
using Gtk;
namespace SparkleShare {
// This is a close implementation of GtkSpinner
public class SparkleSpinner : Image {
private Timer timer;
public SparkleSpinner (int size) : base ()
{
int current_frame = 0;
Gdk.Pixbuf spinner_gallery = SparkleUIHelpers.GetIcon ("process-working", size);
int frames_in_width = spinner_gallery.Width / size;
int frames_in_height = spinner_gallery.Height / size;
int frame_count = (frames_in_width * frames_in_height) - 1;
Gdk.Pixbuf [] frames = new Gdk.Pixbuf [frame_count];
int i = 0;
for (int y = 0; y < frames_in_height; y++) {
for (int x = 0; x < frames_in_width; x++) {
if (!(y == 0 && x == 0)) {
frames [i] = new Gdk.Pixbuf (spinner_gallery, x * size, y * size, size, size);
i++;
}
}
}
timer = new Timer () {
Interval = 600 / frame_count
};
timer.Elapsed += delegate {
if (current_frame < frame_count - 1)
current_frame++;
else
current_frame = 0;
Application.Invoke (delegate {
Pixbuf = frames [current_frame];
});
};
}
public void Start ()
{
timer.Start ();
}
public void Stop ()
{
timer.Stop ();
}
}
}