[Xfce4-commits] [apps/xfce4-notifyd] 01/01: Fix support for hyperlinks in notifications (Bug #14073)

noreply at xfce.org noreply at xfce.org
Mon Jan 29 00:39:45 CET 2018


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-notifyd.

commit 6d178157e49ba60dddf08857950904f43a56dcd6
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Mon Jan 29 00:39:07 2018 +0100

    Fix support for hyperlinks in notifications (Bug #14073)
    
    Try to set the body with markup and in case this fails (empty label)
    fall back to escaping the whole string and showing it plainly.
    This equals pango_parse_markup extended by checking for valid hyperlinks
    which is not supported by pango).
    This could be avoided if gtk_label_set_markup were gboolean instead of void.
---
 panel-plugin/notification-plugin-log.c |  5 ++---
 xfce4-notifyd-config/main.c            |  5 ++---
 xfce4-notifyd/xfce-notify-window.c     | 34 ++++++----------------------------
 3 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c
index 16f449a..5e7835d 100644
--- a/panel-plugin/notification-plugin-log.c
+++ b/panel-plugin/notification-plugin-log.c
@@ -213,9 +213,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
       tmp = g_key_file_get_string (notify_log, group, "body", NULL);
       body = gtk_label_new (NULL);
-      if (pango_parse_markup (tmp, -1, 0, NULL, NULL, NULL, NULL)) {
-        gtk_label_set_markup (GTK_LABEL (body), tmp);
-      } else {
+      gtk_label_set_markup (GTK_LABEL (body), tmp);
+      if (g_strcmp0 (gtk_label_get_text(GTK_LABEL (body)), "") == 0) {
         gchar *tmp1;
 
         tmp1 = g_markup_escape_text (tmp, -1);
diff --git a/xfce4-notifyd-config/main.c b/xfce4-notifyd-config/main.c
index 44041c8..8e1b9ad 100644
--- a/xfce4-notifyd-config/main.c
+++ b/xfce4-notifyd-config/main.c
@@ -608,9 +608,8 @@ xfce4_notifyd_log_populate (NotificationLogWidgets *log_widgets)
             g_free (markup);
             tmp = g_key_file_get_string (notify_log, group, "body", NULL);
             body = gtk_label_new (NULL);
-            if (pango_parse_markup (tmp, -1, 0, NULL, NULL, NULL, NULL)) {
-                gtk_label_set_markup (GTK_LABEL (body), tmp);
-            } else {
+            gtk_label_set_markup (GTK_LABEL (body), tmp);
+            if (g_strcmp0 (gtk_label_get_text (GTK_LABEL (body)), "") == 0) {
                 gchar *tmp1;
 
                 tmp1 = g_markup_escape_text (tmp, -1);
diff --git a/xfce4-notifyd/xfce-notify-window.c b/xfce4-notifyd/xfce-notify-window.c
index e5e7be2..83db269 100644
--- a/xfce4-notifyd/xfce-notify-window.c
+++ b/xfce4-notifyd/xfce-notify-window.c
@@ -687,29 +687,6 @@ xfce_notify_window_button_clicked(GtkWidget *widget,
                   XFCE_NOTIFY_CLOSE_REASON_DISMISSED);
 }
 
-#define ELEM_B    GUINT_TO_POINTER(1)
-#define ELEM_I    GUINT_TO_POINTER(2)
-#define ELEM_U    GUINT_TO_POINTER(3)
-#define ELEM_A    GUINT_TO_POINTER(4)
-
-static inline const gchar *
-elem_to_string(gconstpointer elem_p)
-{
-    gint elem = GPOINTER_TO_UINT(elem_p);
-    switch(elem) {
-        case GPOINTER_TO_UINT(ELEM_B):
-            return "<b>";
-        case GPOINTER_TO_UINT(ELEM_I):
-            return "<i>";
-        case GPOINTER_TO_UINT(ELEM_U):
-            return "<u>";
-        case GPOINTER_TO_UINT(ELEM_A):
-            return "<a>";
-        default:
-            return "??";
-    }
-}
-
 GtkWidget *
 xfce_notify_window_new(void)
 {
@@ -777,17 +754,18 @@ xfce_notify_window_set_body(XfceNotifyWindow *window,
     g_return_if_fail(XFCE_IS_NOTIFY_WINDOW(window));
 
     if(body && *body) {
-        if (pango_parse_markup (body, -1, 0, NULL, NULL, NULL, NULL)) {
-            gtk_label_set_markup (GTK_LABEL (window->body), body);
-        } else {
+        /* Try to set the body with markup and in case this fails (empty label)
+           fall back to escaping the whole string and showing it plainly.
+           This equals pango_parse_markup extended by checking for valid hyperlinks
+           (which is not supported by pango). */
+        gtk_label_set_markup (GTK_LABEL (window->body), body);
+        if (g_strcmp0 (gtk_label_get_text(GTK_LABEL (window->body)), "") == 0 ) {
             gchar *tmp;
-
             tmp = g_markup_escape_text (body, -1);
             gtk_label_set_text (GTK_LABEL (window->body), body);
             g_free (tmp);
         }
         gtk_widget_show(window->body);
-
         window->has_body_text = TRUE;
     } else {
         gtk_label_set_markup(GTK_LABEL(window->body), "");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list