[longomatch] Provide link handlers for Message Dialogs.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Provide link handlers for Message Dialogs.
- Date: Fri, 17 Apr 2015 16:21:09 +0000 (UTC)
commit 9a5cf9cc7999a5f5835b3d6c2402a3aefdec0042
Author: Xavi Artigas <xartigas fluendo com>
Date: Fri Apr 10 13:00:57 2015 +0200
Provide link handlers for Message Dialogs.
The first label in the message area of all Message Dialogs (Info, Warning, Error, ...)
is given a link handler. This allows links to be clicked on Windows. On Linux it was
already working.
LongoMatch.GUI.Helpers/GtkGlue.cs | 10 ++++++++++
LongoMatch.GUI.Helpers/MessagesHelpers.cs | 18 ++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.GUI.Helpers/GtkGlue.cs b/LongoMatch.GUI.Helpers/GtkGlue.cs
index bd426f8..d5c2c45 100644
--- a/LongoMatch.GUI.Helpers/GtkGlue.cs
+++ b/LongoMatch.GUI.Helpers/GtkGlue.cs
@@ -28,6 +28,9 @@ namespace LongoMatch
[DllImport ("libgtk-2.0.dll") /* willfully unmapped */]
static extern void gtk_menu_item_set_label (IntPtr menu, IntPtr label);
+ [DllImport ("libgtk-2.0.dll") /* willfully unmapped */]
+ static extern IntPtr gtk_message_dialog_get_message_area (IntPtr dialog);
+
[DllImport ("libcesarplayer.dll")]
static extern void lgm_gtk_glue_gdk_event_button_set_button (IntPtr evt, uint button);
@@ -36,6 +39,13 @@ namespace LongoMatch
gtk_menu_item_set_label (menu.Handle, GLib.Marshaller.StringToFilenamePtr (label));
}
+ public static VBox MessageDialogGetMessageArea (this MessageDialog dialog)
+ {
+ IntPtr handle = gtk_message_dialog_get_message_area (dialog.Handle);
+
+ return new VBox (handle);
+ }
+
public static void SetButton (this EventButton ev, uint button)
{
diff --git a/LongoMatch.GUI.Helpers/MessagesHelpers.cs b/LongoMatch.GUI.Helpers/MessagesHelpers.cs
index 484f90a..458b246 100644
--- a/LongoMatch.GUI.Helpers/MessagesHelpers.cs
+++ b/LongoMatch.GUI.Helpers/MessagesHelpers.cs
@@ -21,6 +21,7 @@ using System;
using Gtk;
using Dialog = Gtk.Dialog;
using Mono.Unix;
+using LongoMatch.Core.Common;
namespace LongoMatch.Gui.Helpers
{
@@ -79,6 +80,23 @@ namespace LongoMatch.Gui.Helpers
ButtonsType.Ok,
errorMessage);
md.Icon = Misc.LoadIcon ("longomatch", Gtk.IconSize.Dialog, 0);
+ try {
+ var vbox = md.MessageDialogGetMessageArea ();
+ var label = (Label)vbox.Children [0];
+
+ label.SetLinkHandler (url => {
+ try {
+ System.Diagnostics.Process.Start (url);
+ } catch (Exception ex) {
+ Log.WarningFormat ("Could not spawn process for url {0}\n{1}",
+ url, ex);
+ }
+ });
+ } catch (Exception ex) {
+ Log.WarningFormat ("Could not set link handler for Message Dialog\n{0}",
+ ex);
+ }
+
ret = md.Run ();
md.Destroy ();
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]