[blam/gtk-builder] Wire up 'about' and 'quit'
- From: Carlos Martín Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam/gtk-builder] Wire up 'about' and 'quit'
- Date: Thu, 10 Oct 2013 12:06:03 +0000 (UTC)
commit e40ab81ee199397999862066882b1b6274fbd96a
Author: Carlos Martín Nieto <cmn dwim me>
Date: Thu Oct 10 11:31:03 2013 +0200
Wire up 'about' and 'quit'
src/Blam.cs | 20 +++-
src/Dialogs.cs | 14 +++
src/TrayIcon.cs | 37 ++++++
src/blam.ui | 327 +++++--------------------------------------------------
4 files changed, 96 insertions(+), 302 deletions(-)
---
diff --git a/src/Blam.cs b/src/Blam.cs
index b6d5d6c..6e4f7e4 100644
--- a/src/Blam.cs
+++ b/src/Blam.cs
@@ -14,6 +14,7 @@ namespace Blam
using IChannel = Imendio.Blam.IChannel;
using ChannelGroup = Imendio.Blam.ChannelGroup;
using ItemStore = Imendio.Blam.ItemStore;
+ using Unit = System.Reactive.Unit;
public class BlamApplication
{
@@ -48,7 +49,6 @@ namespace Blam
//trayIcon.PreferencesEvent += PreferencesActivated;
//trayIcon.AboutEvent += AboutActivated;
- trayIcon.ObserveQuit.Subscribe(_ => Application.Quit());
trayIcon.ObserveClick.Subscribe(_ => {
if (MainWindow.Visible)
MainWindow.Hide();
@@ -103,6 +103,24 @@ namespace Blam
}
}
});
+
+ item = bld.GetObject<MenuItem>("menu-about");
+ Observable.Merge(
+ item.ObserveActivated().Select(_ => Unit.Default),
+ trayIcon.ObserveAbout).Subscribe(_ => {
+ using (var dialog = new AboutDialog(MainWindow))
+ {
+ dialog.Run();
+ dialog.Destroy();
+ }
+ });
+
+ item = bld.GetObject<MenuItem>("menu-quit");
+ Observable.Merge(
+ item.ObserveActivated().Select(_ => Unit.Default),
+ trayIcon.ObserveQuit).Subscribe(_ => {
+ Application.Quit();
+ });
}
void addChannel(AddChannelDialog dialog)
diff --git a/src/Dialogs.cs b/src/Dialogs.cs
index db36cf0..625688f 100644
--- a/src/Dialogs.cs
+++ b/src/Dialogs.cs
@@ -19,6 +19,7 @@ namespace Blam
using ChannelCollection = Imendio.Blam.ChannelCollection;
using IChannel = Imendio.Blam.IChannel;
using Channel = Imendio.Blam.Channel;
+ using Defines = Imendio.Blam.Defines;
class Modal : IDisposable
{
@@ -240,6 +241,19 @@ namespace Blam
return res == (int)ResponseType.Ok;
}
}
+
+ class AboutDialog : Gtk.AboutDialog
+ {
+ public AboutDialog(Gtk.Window parent)
+ {
+ TransientFor = parent;
+ LogoIconName = "blam";
+ IconName = "blam";
+ Version = Defines.VERSION + "\n" + Defines.CODENAME;
+ Copyright = "Copyright 2006-20013 © Carlos Martín Nieto <cmn dwim me>\n"
+ + "Copyright 2004-2006 © Mikael Hallendal <micke imendio com>";
+ }
+ }
}
namespace Imendio.Blam {
diff --git a/src/TrayIcon.cs b/src/TrayIcon.cs
index 97471e5..7d96c2c 100644
--- a/src/TrayIcon.cs
+++ b/src/TrayIcon.cs
@@ -34,6 +34,13 @@ namespace Blam
}
}
+ Subject<Unit> aboutSubject = new Subject<Unit>();
+ public IObservable<Unit> ObserveAbout {
+ get {
+ return aboutSubject;
+ }
+ }
+
Subject<Unit> clickSubject = new Subject<Unit>();
public IObservable<Unit> ObserveClick {
get {
@@ -63,6 +70,36 @@ namespace Blam
clickSubject.OnNext(Unit.Default);
base.OnActivate();
}
+
+ protected override void OnPopupMenu(uint button, uint time)
+ {
+ Gtk.Menu menu = new Gtk.Menu();
+ Gtk.ImageMenuItem refreshItem = new Gtk.ImageMenuItem(Catalog.GetString("_Refresh"));
+ refreshItem.Image = new Gtk.Image(Gtk.Stock.Refresh, IconSize.Menu);
+ //refreshItem.Activated += RefreshAllEvent;
+
+ Gtk.ImageMenuItem prefItem = new Gtk.ImageMenuItem(Catalog.GetString("Preferences"));
+ prefItem.Image = new Gtk.Image(Gtk.Stock.Preferences,IconSize.Menu);
+ //prefItem.Activated += PreferencesEvent;
+
+ Gtk.ImageMenuItem aboutItem = new Gtk.ImageMenuItem(Catalog.GetString("About Blam"));
+ aboutItem.Image = new Gtk.Image(Gtk.Stock.About,IconSize.Menu);
+ aboutItem.Activated += (sender, e) => aboutSubject.OnNext(Unit.Default);
+
+ Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem(Catalog.GetString("Quit"));
+ quitItem.Image = new Gtk.Image(Gtk.Stock.Quit,IconSize.Menu);
+ quitItem.Activated += (sender, e) => quitSubject.OnNext(Unit.Default);
+
+ menu.Add(refreshItem);
+ menu.Add(prefItem);
+ menu.Add(new Gtk.SeparatorMenuItem());
+ menu.Add(aboutItem);
+ menu.Add(new Gtk.SeparatorMenuItem());
+ menu.Add(quitItem);
+ menu.ShowAll();
+ menu.Popup();
+ }
+
}
}
diff --git a/src/blam.ui b/src/blam.ui
index 9f0bf3b..c6beab1 100644
--- a/src/blam.ui
+++ b/src/blam.ui
@@ -2,226 +2,6 @@
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkDialog" id="edit-channel">
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel-button">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="ok-button">
- <property name="label">gtk-ok</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImage" id="edit-channel-image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-missing-image</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Change the fields to update channel
information</property>
- <property name="single_line_mode">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="n_rows">4</property>
- <property name="n_columns">2</property>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Name</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">URL</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Username</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Password</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry4">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">cancel-button</action-widget>
- <action-widget response="0">ok-button</action-widget>
- </action-widgets>
- </object>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">list-add</property>
- </object>
<object class="GtkWindow" id="main-window">
<property name="can_focus">False</property>
<child>
@@ -291,7 +71,7 @@
</object>
</child>
<child>
- <object class="GtkImageMenuItem" id="imagemenuitem5">
+ <object class="GtkImageMenuItem" id="menu-quit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -305,86 +85,6 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="menuitem2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem6">
- <property name="label">gtk-cut</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem7">
- <property name="label">gtk-copy</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem8">
- <property name="label">gtk-paste</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem9">
- <property name="label">gtk-delete</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menuitem4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">_Help</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem10">
- <property name="label">gtk-about</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="item2">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -488,6 +188,31 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkMenuItem" id="menuitem4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="label" translatable="yes">_Help</property>
+ <property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkImageMenuItem" id="menu-about">
+ <property name="label">gtk-about</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]