commit ed15610270f5927583f67513d1c2c96767700351
parent 2c76ad3d8ef25a84b1f25ef77881ec7c51d1bedd
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Sun,  5 Aug 2012 14:40:57 -0700
Use GtkInfoBar
Diffstat:
5 files changed, 17 insertions(+), 94 deletions(-)
diff --git a/dist/debian/copyright b/dist/debian/copyright
@@ -13,14 +13,10 @@ Upstream Author:
 Copyright:
 
     For everything not noted below:
-      Copyright (C) 2010-2011 Alexander Kojevnikov
-
-    For src/spek-message-bar.*:
-      Copyright (C) 2010 Alexander Kojevnikov
-      Copyright (C) 2008 Novell, Inc
+      Copyright (C) 2010-2012 Alexander Kojevnikov
 
     For src/spek-pipeline.*:
-      Copyright (C) 2010-2011 Alexander Kojevnikov
+      Copyright (C) 2010-2012 Alexander Kojevnikov
       Copyright (C) 2007-2009 Sebastian Dröge
       Copyright (C) 2006 Stefan Kost
       Copyright (C) 1999 Erik Walthinsen
diff --git a/po/POTFILES.in b/po/POTFILES.in
@@ -1,7 +1,6 @@
 [encoding: UTF-8]
 data/spek.desktop.in.in
 src/spek-audio.c
-src/spek-message-bar.vala
 src/spek-pipeline.vala
 src/spek-preferences-dialog.vala
 src/spek-preferences.vala
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -4,7 +4,6 @@ spek_SOURCES = \
 	spek.vala \
 	spek-audio.c \
 	spek-fft.c \
-	spek-message-bar.vala \
 	spek-pipeline.vala \
 	spek-platform.c \
 	spek-preferences.vala \
diff --git a/src/spek-message-bar.vala b/src/spek-message-bar.vala
@@ -1,82 +0,0 @@
-/* spek-message-bar.vala
- *
- * Copyright (C) 2010  Alexander Kojevnikov <alexander@kojevnikov.com>
- *
- * Spek 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.
- *
- * Spek 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 Spek.  If not, see <http://www.gnu.org/licenses/>.
- *
- * This class is heavily influenced by its namesake from Banshee.
- * The original code by Aaron Bockover is (c) 2008 Novell, Inc.
- */
-
-using Gtk;
-
-namespace Spek {
-    public class MessageBar : HBox {
-        private Label label;
-        private Gtk.Window win;
-
-        public MessageBar (string message) {
-            homogeneous = false;
-            spacing = 0;
-            border_width = 6;
-
-            win = new Gtk.Window (WindowType.POPUP);
-            win.name = "gtk-tooltips";
-            win.ensure_style ();
-            win.style_set.connect (() => style = win.style);
-
-            label = new Label (null);
-            label.use_markup = true;
-            label.set_markup (message);
-            label.ellipsize = Pango.EllipsizeMode.END;
-            label.xalign = 0f;
-            label.activate_link.connect (uri => { Platform.show_uri (uri); return true; });
-            var button_box = new HBox (false, 0);
-            button_box.spacing = 3;
-            var close_button = new Button ();
-            close_button.image = new Gtk.Image.from_stock (Stock.CLOSE, IconSize.MENU);
-            close_button.relief = ReliefStyle.NONE;
-            close_button.clicked.connect (() => hide ());
-
-            pack_start (label, true, true, 0);
-            pack_start (button_box, false, false, 0);
-            pack_start (close_button, false, false, 0);
-        }
-
-        private bool changing_style = false;
-        protected override void style_set (Style? previous_style) {
-            if (changing_style) {
-                return;
-            }
-
-            changing_style = true;
-            style = win.style;
-            label.style = style;
-            changing_style = false;
-        }
-
-        protected override bool expose_event (Gdk.EventExpose event) {
-            if (!is_drawable ()) {
-                return false;
-            }
-
-            var cr = Gdk.cairo_create (event.window);
-            var color = style.bg[StateType.NORMAL];
-            cr.set_source_rgb (color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
-            cr.rectangle (allocation.x, allocation.y, allocation.width, allocation.height);
-            cr.fill ();
-            return base.expose_event (event);
-        }
-    }
-}
diff --git a/src/spek-window.vala b/src/spek-window.vala
@@ -23,7 +23,7 @@ namespace Spek {
     public class Window : Gtk.Window {
 
         private UIManager ui;
-        private MessageBar message_bar;
+        private InfoBar info_bar;
         private Spectrogram spectrogram;
         private string description;
         private string cur_dir;
@@ -97,7 +97,18 @@ namespace Spek {
             ((ToolItem) ui.get_widget ("/ToolBar/FileSave")).is_important = true;
             ((ToolItem) ui.get_widget ("/ToolBar/HelpAbout")).is_important = true;
 
-            message_bar = new MessageBar (_("A new version of Spek is available on <a href=\"http://www.spek-project.org\">www.spek-project.org</a>"));
+            info_bar = new InfoBar.with_buttons (Stock.OK, ResponseType.OK);
+            var label = new Label (null);
+            label.use_markup = true;
+            label.set_markup (_("A new version of Spek is available on <a href=\"http://www.spek-project.org\">www.spek-project.org</a>"));
+            label.ellipsize = Pango.EllipsizeMode.END;
+            label.xalign = 0f;
+            label.activate_link.connect (uri => { Platform.show_uri (uri); return true; });
+            label.show();
+            var content_area = (Container) info_bar.get_content_area();
+            content_area.add(label);
+            info_bar.message_type = MessageType.INFO;
+            info_bar.response.connect(() => info_bar.hide());
 
             spectrogram = new Spectrogram ();
             cur_dir = Environment.get_home_dir ();
@@ -117,7 +128,7 @@ namespace Spek {
             var vbox = new VBox (false, 0);
             vbox.pack_start (menubar, false, true, 0);
             vbox.pack_start (toolbar, false, true, 0);
-            vbox.pack_start (message_bar, false, true, 0);
+            vbox.pack_start (info_bar, false, true, 0);
             vbox.pack_start (spectrogram, true, true, 0);
             add (vbox);
             menubar.show_all ();
@@ -330,7 +341,7 @@ namespace Spek {
             }
 
             if (version != null && version > Config.PACKAGE_VERSION) {
-                Idle.add (() => { message_bar.show_all (); return false; });
+                Idle.add (() => { info_bar.show_all (); return false; });
             }
 
             // Update the preferences.