Enlightenment CVS committal Author : andreas99 Project : e16 Module : tools
Dir : e16/tools/e16menuedit2/src Modified Files: e16menuedit2.c file.c file.h icon_chooser.c Log Message: added librsvg check =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/e16menuedit2.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e16menuedit2.c 28 Jul 2004 22:12:28 -0000 1.4 +++ e16menuedit2.c 29 Jul 2004 21:28:29 -0000 1.5 @@ -34,14 +34,19 @@ #include "treeview.h" #include "toolbar.h" +int librsvg_cmp; + int main (int argc, char *argv[]) { GtkWidget *main_window; GtkWidget *treeview_menu; GladeXML *main_xml; - GtkWidget *toolbar1; - int i; + GtkWidget *toolbar1; char app_dir[PATH_MAX]; + char package[] = "librsvg-2.0"; + char good_version[] = "2.7.1"; + char *version; + int i; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); @@ -79,6 +84,10 @@ sprintf (app_dir, "%s/%s/%s", homedir (getuid ()), APP_HOME, ICON_DIR); mkdir_with_parent (app_dir, 0755); + /* get librsvg version and check if good enough */ + version = pkg_config_version (package); + librsvg_cmp = version_cmp (version, good_version); + gtk_widget_show (main_window); gtk_main (); =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- file.c 28 Jul 2004 22:12:28 -0000 1.3 +++ file.c 29 Jul 2004 21:28:29 -0000 1.4 @@ -198,3 +198,78 @@ return NULL; } + +/* if ver1 < ver2 -> return -1 + * if ver1 > ver2 -> return 1 + * if ver1 == ver2 -> return 0 + */ +int version_cmp (char *ver1, char *ver2) +{ + char *ver1_token; + char *ver2_token; + char *ver1_ptr = malloc (strlen (ver1)+1); + char *ver2_ptr = malloc (strlen (ver2)+1); + + ver1_token = strtok_r (ver1, ".", &ver1_ptr); + ver2_token = strtok_r (ver2, ".", &ver2_ptr); + + while ((ver1_token != NULL) || (ver2_token != NULL)) + { + int ver1_i; + int ver2_i; + + if (ver1_token == NULL) + ver1_i = 0; + else + ver1_i = atoi (ver1_token); + + if (ver2_token == NULL) + ver2_i = 0; + else + ver2_i = atoi (ver2_token); + + if (ver1_i < ver2_i) + return -1; + else if (ver1_i > ver2_i) + return 1; + + ver1_token = strtok_r (NULL, ".", &ver1_ptr); + ver2_token = strtok_r (NULL, ".", &ver2_ptr); + } + + return 0; +} + +/* returns a version number of a pkg-config package + * the return char* could be freed after use + */ +char *pkg_config_version (char *package) +{ + gboolean spawn; + const int buf_len = 128; + gchar buf[buf_len]; + gchar *argv_child[4]; + gint stdout_child; + gint stderr_child; + int ret_val; + + argv_child[0] = g_strdup ("pkg-config"); + argv_child[1] = g_strdup ("--modversion"); + argv_child[2] = package; + argv_child[3] = NULL; + + spawn = g_spawn_async_with_pipes (NULL, argv_child, NULL, + G_SPAWN_SEARCH_PATH, NULL, + NULL, NULL, NULL, + &stdout_child, &stderr_child, NULL); + + g_free (argv_child[0]); + g_free (argv_child[1]); + + ret_val = read (stdout_child, buf, buf_len); + + if (ret_val == 0) + return 0; + else + return strdup (buf); +} =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- file.h 28 Jul 2004 22:12:28 -0000 1.2 +++ file.h 29 Jul 2004 21:28:29 -0000 1.3 @@ -18,5 +18,7 @@ int mkdir_with_parent (const char *pathname, mode_t mode); char *strtok_left (char *s, const char *delim, unsigned int number); char *strsplit (char *s, char **right, int count); +int version_cmp (char *ver1, char *ver2); +char *pkg_config_version (char *package); #endif /* _FILE_H */ =================================================================== RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/icon_chooser.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- icon_chooser.c 28 Jul 2004 22:12:28 -0000 1.1 +++ icon_chooser.c 29 Jul 2004 21:28:29 -0000 1.2 @@ -33,6 +33,8 @@ #include "file.h" #include "treeview.h" +extern int librsvg_cmp; + void open_icon_chooser (GtkWidget *treeview_menu) { GtkWidget *main_window; @@ -137,12 +139,12 @@ entry_select = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO ( resize_combo)->entry)); - /* temporary fix for probability broken librsvg function. - * it should autodetect librsvg version... + /* check for broken librsvg function + * perhaps better handling next stable librsvg release */ right = g_malloc (3); strsplit (filename, &right, g_utf8_strlen (filename, -1) - 3); - if (strcmp (right, "svg")) + if ((strcmp (right, "svg")) || (librsvg_cmp >= 0)) { gdk_pixbuf_get_file_info (filename, &width, @@ -150,8 +152,8 @@ } else { - width = ICON_SIZE_AUTO; - height = ICON_SIZE_AUTO; + width = ICON_SIZE_AUTO+1; + height = ICON_SIZE_AUTO+1; } g_free (right); @@ -296,13 +298,13 @@ { gchar *right; - /* temporary fix for probability broken librsvg function - * it should autodetect librsvg version... + /* check for broken librsvg function + * perhaps better handling next stable librsvg release */ right = g_malloc (3); strsplit (filename, &right, g_utf8_strlen (filename, -1) - 3); - if (strcmp (right, "svg")) + if ((strcmp (right, "svg")) || (librsvg_cmp >= 0)) { gdk_pixbuf_get_file_info (filename, &width, &height); } ------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs