← Back to team overview

elementaryart team mailing list archive

[Merge] lp:~voldyman666/granite/fixed-1023269 into lp:granite

 

Akshay Shekher has proposed merging lp:~voldyman666/granite/fixed-1023269 into lp:granite.

Requested reviews:
  elementary Pantheon team (elementary-pantheon)
Related bugs:
  Bug #1023269 in Granite: "Replace C code with vala Code (Gtkpatch.c)"
  https://bugs.launchpad.net/granite/+bug/1023269

For more details, see:
https://code.launchpad.net/~voldyman666/granite/fixed-1023269/+merge/114636

The string in About Dialog Box (eg authors = {"Akshay Shekher <voldyman666@xxxxxxxxx>","..."}
where parsed by a function written in C, which was in Gtkpatch.c (=>Gtkpatch.h,Gtkpatch.vapi)
i have created a simple function written in vala to replace that C code. 
-- 
https://code.launchpad.net/~voldyman666/granite/fixed-1023269/+merge/114636
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'lib/CMakeLists.txt'
--- lib/CMakeLists.txt	2012-05-23 14:58:43 +0000
+++ lib/CMakeLists.txt	2012-07-12 13:19:18 +0000
@@ -82,8 +82,6 @@
     Widgets/StatusBar.vala
     Main.vala
     config.vapi
-CUSTOM_VAPIS
-    ${CMAKE_CURRENT_SOURCE_DIR}/GtkPatch/gtkpatch-utils.vapi
 PACKAGES
     ${PKG_DEPS}
     posix
@@ -99,8 +97,7 @@
 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/granite.deps DESTINATION ${CMAKE_INSTALL_PREFIX}/share/vala/vapi/)
 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/granite.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/granite/)
 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/Widgets/widgets-utils.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/granite/)
-add_library (${PKGNAME} SHARED
-    GtkPatch/gtkpatch-utils.c
+add_library (${PKGNAME} SHARED    
     Widgets/widgets-utils.c
     Widgets/close-button.c
     ${VALA_C}

=== modified file 'lib/GtkPatch/AboutDialog.vala'
--- lib/GtkPatch/AboutDialog.vala	2012-05-11 07:35:52 +0000
+++ lib/GtkPatch/AboutDialog.vala	2012-07-12 13:19:18 +0000
@@ -380,8 +380,39 @@
 
     private string set_string_from_string_array(string title, string[] peoples)
     {
-        string text = title;
-        text += add_credits_section (title, peoples);
+        string text  = "";
+        string name  = "";
+        string email = "" ;
+        string _person_data;
+        bool email_started= false;        
+        //text += add_credits_section (title, peoples);
+        text += title + "<span size=\"small\">";
+        for (int i= 0;i<peoples.length;i++){
+            if (peoples[i] == null)
+                break;
+            _person_data = peoples[i];            
+
+            for (int j=0;j< _person_data.length;j++){
+
+                if ( _person_data.get (j) == '<')
+                    email_started = true;
+
+                if (!email_started)
+                    name += _person_data[j].to_string ();
+
+                else 
+                    if (_person_data.get (j) != '>')
+                        email +=_person_data[j].to_string ();               
+
+            }
+            if (email == "")
+                text += "<u>%s</u>\n".printf (name);    
+            else
+                text += "<a href=\"%s\">%s</a>\n".printf (email,name);
+            email = ""; name =""; email_started=false;            
+        }
+        text += "</span>";
+      //  print ("\n==\n"+text+"\n ==\n");
 
         return text;
     }

=== removed file 'lib/GtkPatch/gtkpatch-utils.c'
--- lib/GtkPatch/gtkpatch-utils.c	2011-10-12 12:27:13 +0000
+++ lib/GtkPatch/gtkpatch-utils.c	1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2001 CodeFactory AB
- * Copyright (C) 2001, 2002 Anders Carlsson
- * Copyright (C) 2003, 2004 Matthias Clasen <mclasen@xxxxxxxxxx>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Author: Anders Carlsson <andersca@xxxxxxxxx>
- *
- * Modified by the GTK+ Team and others 1997-2004.  See the AUTHORS
- * file for a list of people on the GTK+ Team.  See the ChangeLog
- * files for a list of changes.  These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "gtkpatch-utils.h"
-
-gchar *
-add_credits_section (gchar *title, gchar **people)
-{
-    gchar **p;
-    gchar *q0, *q1, *q2, *r1, *r2;
-
-    if (people == NULL)
-        return;
-
-    GString *str;
-    str = g_string_new ("<span size=\"small\">");
-    for (p = people; *p; p++)
-    {
-        q0 = *p;
-        while (*q0)
-        {
-            q1 = strchr (q0, '<');
-            q2 = q1 ? strchr (q1, '>') : NULL;
-            r1 = strstr (q0, "http://";);
-            if (r1)
-            {
-                r2 = strpbrk (r1, " \n\t");
-                if (!r2)
-                    r2 = strchr (r1, '\0');
-            }
-            else
-                r2 = NULL;
-
-            if (r1 && r2 && (!q1 || !q2 || (r1 < q1)))
-            {
-                q1 = r1;
-                q2 = r2;
-            }
-            else if (q1 && (q1[1] == 'a' || q1[1] == 'A') && q1[2] == ' ')
-            {
-                /* if it is a <a> link leave it for the label to parse */
-                q1 = NULL;
-            }
-
-            if (q1 && q2)
-            {
-                gchar *link;
-                gchar *text;
-                gchar *name;
-
-                if (*q1 == '<')
-                {
-                    /* email */
-                    gchar *escaped;
-
-                    text = g_strstrip (g_strndup (q0, q1 - q0));
-                    name = g_markup_escape_text (text, -1);
-                    q1++;
-                    link = g_strndup (q1, q2 - q1);
-                    q2++;
-                    escaped = g_uri_escape_string (link, NULL, FALSE);
-                    g_string_append_printf (str,
-                                            "<a href=\"mailto:%s\";>%s</a>",
-                                            escaped,
-                                            name[0] ? name : link);
-                    g_free (escaped);
-                    g_free (link);
-                    g_free (text);
-                    g_free (name);
-                }
-                else
-                {
-                    /* uri */
-                    text = g_strstrip (g_strndup (q0, q1 - q0));
-                    name = g_markup_escape_text (text, -1);
-                    link = g_strndup (q1, q2 - q1);
-                    g_string_append_printf (str,
-                                            "<a href=\"%s\">%s</a>",
-                                            link,
-                                            name[0] ? name : link);
-                    g_free (link);
-                    g_free (text);
-                    g_free (name);
-                }
-
-                q0 = q2;
-            }
-            else
-            {
-                g_string_append (str, q0);
-                break;
-            }
-        }
-        g_string_append (str, "\n");
-    }
-    g_string_append (str, "</span>");
-    gchar *result = strdup (str->str);
-    g_string_free (str, TRUE);
-
-    return result;
-}
-

=== removed file 'lib/GtkPatch/gtkpatch-utils.h'
--- lib/GtkPatch/gtkpatch-utils.h	2011-10-12 12:27:13 +0000
+++ lib/GtkPatch/gtkpatch-utils.h	1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
-#include <glib.h>
-#include <string.h>
-
-gchar   *add_credits_section (gchar *title, gchar **people);

=== removed file 'lib/GtkPatch/gtkpatch-utils.vapi'
--- lib/GtkPatch/gtkpatch-utils.vapi	2011-10-12 12:27:13 +0000
+++ lib/GtkPatch/gtkpatch-utils.vapi	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-
-private string   add_credits_section (string title, string[] people);
-


Follow ups