Hello, I want to help with making CentOS a bit more comfortable, so there is a spec of a little clipboard manager called Parcellite. Function that check links replaced, now based on protocol prefix instead of regex (pcre wrapper appeared in glib 2.16, but I'm not used to pcre to replace it). Actually I make rpms really rare, so wait for your comments (especially about dependencies).
patch text placed after spec file. url of srpm - http://rapidshare.com/files/264092985/parcellite-0.9.1-1.src.rpm.html mirror - http://depositfiles.com/files/nel3gwg4p
// sorry, I used English "readonly" most of my life.
--- parcellite.spec --- Name: parcellite Version: 0.9.1 Release: 1%{?dist} Summary: Parcellite - Lightweight GTK+ Clipboard Manager
Group: Applications/Applets License: GPLv3 URL: http://parcellite.sourceforge.net Source0: parcellite-%{version}.tar.gz Patch0: parcellite-%{version}-fix.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gtk2-devel >= 2.10.0, glib2-devel Requires: gtk2, glib2
%description Parcellite is a lightweight GTK+ clipboard manager. This is a stripped down, basic-features-only clipboard manager with a small memory footprint for those who like simplicity. Project website: http://parcellite.sourceforge.net/
%prep %setup -q %patch -b .fix
%build %configure make %{?_smp_mflags}
%install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT
%clean rm -rf $RPM_BUILD_ROOT
%post update-desktop-database > /dev/null 2>&1 || :
%postun update-desktop-database > /dev/null 2>&1 || :
%files %defattr(-,root,root,-) %doc COPYING %{_sysconfdir}/xdg/autostart/parcellite-startup.desktop %{_bindir}/parcellite %{_datadir}/applications/parcellite.desktop %{_datadir}/locale/de/LC_MESSAGES/parcellite.mo %{_datadir}/locale/es/LC_MESSAGES/parcellite.mo %{_datadir}/locale/hu/LC_MESSAGES/parcellite.mo %{_datadir}/locale/ja/LC_MESSAGES/parcellite.mo %{_datadir}/locale/pt_BR/LC_MESSAGES/parcellite.mo %{_datadir}/locale/sv/LC_MESSAGES/parcellite.mo %doc %{_mandir}/man1/parcellite.1.gz
%changelog * Wed Aug 5 2009 Anton "d41" Karmanov defunct41@gmail.com - init, don't sure about dependencies
--- parcellite-0.9.1-fix.patch --- diff -up ./configure.fix ./configure --- ./configure.fix 2009-03-18 21:36:15.000000000 +0500 +++ ./configure 2009-08-05 22:59:30.000000000 +0600 @@ -10044,7 +10044,8 @@ fi PKG_CONFIG=no fi
- min_glib_version=2.14.0 + # d41: we don't have glib 2.14 + min_glib_version=2.12.0 { $as_echo "$as_me:$LINENO: checking for GLIB - version >= $min_glib_version" >&5 $as_echo_n "checking for GLIB - version >= $min_glib_version... " >&6; }
diff -up ./src/main.c.fix ./src/main.c --- ./src/main.c.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/main.c 2009-08-05 22:59:30.000000000 +0600 @@ -50,6 +50,21 @@ prefs_t prefs = {DEF_USE_COPY, DE INIT_HISTORY_KEY, INIT_ACTIONS_KEY, INIT_MENU_KEY, DEF_NO_ICON};
+/* d41: CentOS have glib 2.12 (not 2.14) =( +so, thereis no g_strcmp0 +from glib docs: +Compares str1 and str2 like strcmp(). Handles NULL gracefully by sorting it before non-NULL strings. +str1 : a C string or NULL +str2 : another C string or NULL +Returns : -1, 0 or 1, if str1 is <, == or > than str2. +*/ +int g_strcmp0(const char *str1, const char *str2) +{ + if( str1 == NULL && str2 == NULL ) return 0; + if( str1 == NULL ) return -1; + if( str2 == NULL ) return 1; + return g_strcasecmp(str1, str2); +};
/* Called every CHECK_INTERVAL seconds to check for new items */ @@ -89,7 +104,10 @@ item_check(gpointer data) delete_duplicate(primary_text); append_item(primary_text); } - else + /* d41: add anything else only if hyperlinks_only disabled + to remove junk from history + */ + else if (!prefs.hyperlinks_only) { delete_duplicate(primary_text); append_item(primary_text); @@ -121,7 +139,10 @@ item_check(gpointer data) delete_duplicate(clipboard_text); append_item(clipboard_text); } - else + /* d41: add anything else only if hyperlinks_only disabled + to remove junk from history + */ + else if (!prefs.hyperlinks_only) { delete_duplicate(clipboard_text); append_item(clipboard_text); @@ -236,8 +257,12 @@ edit_selected(GtkMenuItem *menu_item, gp
gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - + +#if GTK_CHECK_VERSION(2,14,0) + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), scrolled_window, TRUE, TRUE, 2); +#else gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolled_window, TRUE, TRUE, 2); +#endif GtkWidget* text_view = gtk_text_view_new_with_buffer(clipboard_buffer); gtk_text_view_set_left_margin((GtkTextView*)text_view, 2); gtk_text_view_set_right_margin((GtkTextView*)text_view, 2); diff -up ./src/main.h.fix ./src/main.h --- ./src/main.h.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/main.h 2009-08-05 22:59:30.000000000 +0600 @@ -64,6 +64,9 @@ actions_hotkey(char *keystring, gpointer void menu_hotkey(char *keystring, gpointer user_data);
+int g_strcmp0(const char *str1, const char *str2); + + G_END_DECLS
#endif diff -up ./src/preferences.c.fix ./src/preferences.c --- ./src/preferences.c.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/preferences.c 2009-08-05 22:59:30.000000000 +0600 @@ -422,7 +422,6 @@ show_preferences(gint tab) vbox = gtk_vbox_new(FALSE, 2); gtk_container_add((GtkContainer*)alignment, vbox); save_check = gtk_check_button_new_with_mnemonic(_("_Save history")); - gtk_widget_set_tooltip_text(save_check, _("Save and restore history between sessions")); gtk_box_pack_start((GtkBox*)vbox, save_check, FALSE, FALSE, 0); hbox = gtk_hbox_new(FALSE, 4); gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0); diff -up ./src/utils.c.fix ./src/utils.c --- ./src/utils.c.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/utils.c 2009-08-05 23:50:33.000000000 +0600 @@ -50,17 +50,18 @@ check_dirs() }
/* Returns TRUE if text is a hyperlink */ +/* d41: CentOS have glib 2.12 (not 2.14) =( +so, thereis no gregex +*/ gboolean is_hyperlink(gchar* text) { - /* TODO: I need a better regex, this one is poor */ - GRegex* regex = g_regex_new("([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/]" \ - "(([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}" \ - "(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)", - G_REGEX_CASELESS, 0, NULL); - - gboolean result = g_regex_match(regex, text, 0, NULL); - g_regex_unref(regex); + gchar* proto[] = { "http://%22,%22ftp://%22,%22https://%22,%22sftp://%22,%22mailto:%22,%22svn://" }; + gboolean result = FALSE; + int idx, length = sizeof(proto)/sizeof(proto[0]); + for(idx=0; idx<length; idx++) { + result = result || g_str_has_prefix( text, proto[idx] ); + } return result; }
Hello All!
2009/8/5 Karmanov Anton defunct41@gmail.com:
Hello, I want to help with making CentOS a bit more comfortable, so there is a spec of a little clipboard manager called Parcellite.
Why not to iinclude it to EPEL? I can help you.
On Thu, Aug 6, 2009 at 12:45 AM, Peter Lemenkovlemenkov@gmail.com wrote:
Hello All!
2009/8/5 Karmanov Anton defunct41@gmail.com:
Hello, I want to help with making CentOS a bit more comfortable, so there is a spec of a little clipboard manager called Parcellite.
Why not to iinclude it to EPEL? I can help you.
-- With best regards, Peter Lemenkov. _______________________________________________ CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
EPEL? Actually I don't understand the way of including packages to EPEL. And I'm not sure that spec file follow fedoras guidelines. So, If you can help, then lets try.
--- wbr, d41
On 08/05/2009 10:20 PM, Karmanov Anton wrote:
On Thu, Aug 6, 2009 at 12:45 AM, Peter Lemenkovlemenkov@gmail.com wrote:
Hello All!
2009/8/5 Karmanov Anton defunct41@gmail.com:
Hello, I want to help with making CentOS a bit more comfortable, so there is a spec of a little clipboard manager called Parcellite.
Why not to iinclude it to EPEL? I can help you.
-- With best regards, Peter Lemenkov.
EPEL? Actually I don't understand the way of including packages to EPEL. And I'm not sure that spec file follow fedoras guidelines. So, If you can help, then lets try.
I have cleaned up a bit your package (fixed a few tags, added a few missing BRs, corrected %install and %files) and did a successful build in fedora's koji. The modified src.rpm and spec can be found at http://wolfy.fedorapeople.org/parcellite , while the binaries are at http://koji.fedoraproject.org/koji/taskinfo?taskID=1585375
On Thu, Aug 6, 2009 at 7:28 AM, Manuel Wolfshantwolfy@nobugconsulting.ro wrote:
I have cleaned up a bit your package (fixed a few tags, added a few missing BRs, corrected %install and %files) and did a successful build in fedora's koji. The modified src.rpm and spec can be found at http://wolfy.fedorapeople.org/parcellite , while the binaries are at http://koji.fedoraproject.org/koji/taskinfo?taskID=1585375
CentOS-devel mailing list CentOS-devel@centos.org http://lists.centos.org/mailman/listinfo/centos-devel
Thanks Manuel, I'll study it's text. it is only third package I ever created spec file for (previous were conky and linuxdcpp), so I don't know all the detail. And I found a way to return back link check by authors regular expression (replaced GRegex by POSIX regex), plus make g_strcmp0 replacement case sensitive back, but I don't know is it normal to mess standard strcmp and regex with glib (actually I' scared of work with local chars can be broken). So if you want to try that version patch here.
diff -up ./configure.fix ./configure --- ./configure.fix 2009-03-18 21:36:15.000000000 +0500 +++ ./configure 2009-08-06 20:05:31.000000000 +0600 @@ -10044,7 +10044,8 @@ fi PKG_CONFIG=no fi
- min_glib_version=2.14.0 + # d41: we don't have glib 2.14 + min_glib_version=2.12.0 { $as_echo "$as_me:$LINENO: checking for GLIB - version >= $min_glib_version" >&5 $as_echo_n "checking for GLIB - version >= $min_glib_version... " >&6; }
diff -up ./src/main.c.fix ./src/main.c --- ./src/main.c.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/main.c 2009-08-06 20:05:31.000000000 +0600 @@ -50,6 +50,21 @@ prefs_t prefs = {DEF_USE_COPY, DE INIT_HISTORY_KEY, INIT_ACTIONS_KEY, INIT_MENU_KEY, DEF_NO_ICON};
+/* d41: CentOS have glib 2.12 (not 2.14) =( +so, thereis no g_strcmp0 +from glib docs: +Compares str1 and str2 like strcmp(). Handles NULL gracefully by sorting it before non-NULL strings. +str1 : a C string or NULL +str2 : another C string or NULL +Returns : -1, 0 or 1, if str1 is <, == or > than str2. +*/ +int g_strcmp0(const char *str1, const char *str2) +{ + if( str1 == NULL && str2 == NULL ) return 0; + if( str1 == NULL ) return -1; + if( str2 == NULL ) return 1; + return strcmp(str1, str2); +};
/* Called every CHECK_INTERVAL seconds to check for new items */ @@ -89,7 +104,10 @@ item_check(gpointer data) delete_duplicate(primary_text); append_item(primary_text); } - else + /* d41: add anything else only if hyperlinks_only disabled + to remove junk from history + */ + else if (!prefs.hyperlinks_only) { delete_duplicate(primary_text); append_item(primary_text); @@ -121,7 +139,10 @@ item_check(gpointer data) delete_duplicate(clipboard_text); append_item(clipboard_text); } - else + /* d41: add anything else only if hyperlinks_only disabled + to remove junk from history + */ + else if (!prefs.hyperlinks_only) { delete_duplicate(clipboard_text); append_item(clipboard_text); @@ -236,8 +257,12 @@ edit_selected(GtkMenuItem *menu_item, gp
gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - + +#if GTK_CHECK_VERSION(2,14,0) + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), scrolled_window, TRUE, TRUE, 2); +#else gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolled_window, TRUE, TRUE, 2); +#endif GtkWidget* text_view = gtk_text_view_new_with_buffer(clipboard_buffer); gtk_text_view_set_left_margin((GtkTextView*)text_view, 2); gtk_text_view_set_right_margin((GtkTextView*)text_view, 2); diff -up ./src/main.h.fix ./src/main.h --- ./src/main.h.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/main.h 2009-08-06 20:05:31.000000000 +0600 @@ -64,6 +64,9 @@ actions_hotkey(char *keystring, gpointer void menu_hotkey(char *keystring, gpointer user_data);
+int g_strcmp0(const char *str1, const char *str2); + + G_END_DECLS
#endif diff -up ./src/preferences.c.fix ./src/preferences.c --- ./src/preferences.c.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/preferences.c 2009-08-06 20:05:31.000000000 +0600 @@ -422,7 +422,6 @@ show_preferences(gint tab) vbox = gtk_vbox_new(FALSE, 2); gtk_container_add((GtkContainer*)alignment, vbox); save_check = gtk_check_button_new_with_mnemonic(_("_Save history")); - gtk_widget_set_tooltip_text(save_check, _("Save and restore history between sessions")); gtk_box_pack_start((GtkBox*)vbox, save_check, FALSE, FALSE, 0); hbox = gtk_hbox_new(FALSE, 4); gtk_box_pack_start((GtkBox*)vbox, hbox, FALSE, FALSE, 0); diff -up ./src/utils.c.fix ./src/utils.c --- ./src/utils.c.fix 2009-03-18 21:33:03.000000000 +0500 +++ ./src/utils.c 2009-08-06 20:19:57.000000000 +0600 @@ -23,6 +23,8 @@ #include "daemon.h" #include "history.h" #include "parcellite-i18n.h" +#include <sys/types.h> +#include <regex.h>
/* Creates program related directories if needed */ void @@ -50,17 +52,22 @@ check_dirs() }
/* Returns TRUE if text is a hyperlink */ +/* d41: CentOS have glib 2.12 (not 2.14) =( +so, thereis no gregex +*/ gboolean is_hyperlink(gchar* text) { - /* TODO: I need a better regex, this one is poor */ - GRegex* regex = g_regex_new("([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/]" \ - "(([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}" \ - "(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)", - G_REGEX_CASELESS, 0, NULL); - - gboolean result = g_regex_match(regex, text, 0, NULL); - g_regex_unref(regex); + gboolean result = FALSE; + regex_t pattern; + if( regcomp(&pattern, "([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/]" \ + "(([A-Za-z0-9$_.+!*,;/?:@&~=-])|%[A-Fa-f0-9]{2}){1,333}" \ + "(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)", + REG_EXTENDED|REG_ICASE|REG_NOSUB) == 0) + { + if( regexec(&pattern, text, 0, NULL, REG_NOTEOL) == 0) result = TRUE; + regfree(&pattern); + } return result; }