Date: Fri, 11 Mar 2005 12:20:50 +0100 From: "Piotr Smyrak" <piotr.smyrak@heron.pl> To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@freebsd.org> Subject: [patch] support new GTK file selector in editors/leafpad Message-ID: <1110540050.0@smyru.smyrak.com>
next in thread | raw e-mail | index | archive | help
>Submitter-Id: current-users >Originator: Piotr Smyrak >Organization: >Confidential: no >Synopsis: [patch] support new GTK file selector in editors/leafpad >Severity: non-critical >Priority: low >Category: ports >Class: update >Release: FreeBSD 5.3-STABLE i386 >Environment: System: FreeBSD 5.3-STABLE #0: Mon Nov 22 01:43:22 CET 2004 root@smyru.smyrak.com:/usr/obj/usr/src/sys/SMYRU >Description: The following patch adds an extra patch to the port that lets editors/leafpad compile so it could take advantage of the new standard GTK+ file selector. The patch originates from leafpad's website, and its author is Link Dupont. It was cleaned to properly integrate with the port. I also got Radek, port maintainer approval to get this commited. >How-To-Repeat: >Fix: --- leafpad.patch begins here --- diff -Naru leafpad.orig/Makefile leafpad/Makefile --- leafpad.orig/Makefile Tue Jan 18 10:51:45 2005 +++ leafpad/Makefile Tue Feb 22 00:10:51 2005 @@ -18,10 +18,26 @@ USE_REINPLACE= yes USE_X_PREFIX= yes GNU_CONFIGURE= yes -CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ - LDFLAGS="-L${LOCALBASE}/lib" +CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -I${X11BASE}/include ${PTHREAD_CFLAGS}" \ + LDFLAGS="-L${LOCALBASE}/lib -L${X11BASE}/lib ${PTHREAD_LIBS}" \ + PTHREAD_LIB="${PTHREAD_LIBS}" PORTDOCS= AUTHORS COPYING ChangeLog INSTALL README + +.if defined (WITH_NEW_SELECTOR) +EXTRA_PATCHES= ${FILESDIR}/extra-new-selector.patch +.endif + +pre-everything:: +.if !defined(WITH_NEW_SELECTOR) + @${ECHO_MSG} "" + @${ECHO_MSG} "You may choose to compile with unsupported patch" + @${ECHO_MSG} "that lets leafpad use the new GTK file selector." + @${ECHO_MSG} "Define:" + @${ECHO_MSG} "" + @${ECHO_MSG} " WITH_NEW_SELECTOR=yes" + @${ECHO_MSG} "" +.endif post-patch: @${REINPLACE_CMD} -e 's|/pixmaps|/gnome/pixmaps|; \ --- leafpad.orig/pkg-plist.orig Thu Mar 10 02:25:39 2005 +++ leafpad/pkg-plist Thu Mar 10 02:20:42 2005 @@ -16,5 +16,6 @@ share/locale/ta/LC_MESSAGES/leafpad.mo share/locale/zh_CN/LC_MESSAGES/leafpad.mo share/locale/zh_TW/LC_MESSAGES/leafpad.mo +%%PORTDOCS%%@dirrm %%DOCSDIR%% @exec update-desktop-database > /dev/null || /usr/bin/true @unexec update-desktop-database > /dev/null || /usr/bin/true diff -Naru leafpad.orig/files/extra-new-selector.patch leafpad/files/extra-new-selector.patch --- leafpad.orig/files/extra-new-selector.patch Thu Jan 1 01:00:00 1970 +++ leafpad/files/extra-new-selector.patch Thu Feb 3 21:09:32 2005 @@ -0,0 +1,130 @@ +--- src/callback.c.orig Mon Dec 20 12:58:26 2004 ++++ src/callback.c Thu Feb 3 20:08:07 2005 +@@ -93,7 +93,7 @@ + + if (!check_text_modification(sd)) { + // fi = get_file_info_by_selector(OPEN, sd->fi); +- fi = get_fileinfo_from_selector(sd->mainwin->window, sd->fi, OPEN); ++ fi = get_fileinfo_from_chooser(sd->mainwin->window, sd->fi, OPEN); + if (fi) { + if (file_open_real(sd->mainwin->textview, fi)) { + g_free(fi); +@@ -123,7 +123,7 @@ + { + FileInfo *fi; + +- fi = get_fileinfo_from_selector(sd->mainwin->window, sd->fi, SAVE); ++ fi = get_fileinfo_from_chooser(sd->mainwin->window, sd->fi, SAVE); + if (fi) { + if (file_save_real(sd->mainwin->textview, fi)) + g_free(fi); +--- src/selector.c.orig Fri Dec 24 10:35:12 2004 ++++ src/selector.c Thu Feb 3 21:02:00 2005 +@@ -310,7 +310,7 @@ + return option_menu; + } + +-static GtkWidget *create_file_selector(FileInfo *selected_fi) ++static GtkWidget *create_file_chooser(FileInfo *selected_fi, GtkWidget *window) + { + GtkWidget *filesel; + GtkWidget *align; +@@ -322,12 +322,19 @@ + + title = mode ? _("Open") : _("Save As"); + +- filesel = gtk_file_selection_new(title); +-// gtk_window_set_transient_for(GTK_WINDOW(filesel), GTK_WINDOW(window)); ++ if(mode == OPEN) ++ filesel = gtk_file_chooser_dialog_new(title, GTK_WINDOW(window), ++ GTK_FILE_CHOOSER_ACTION_OPEN, ++ GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, ++ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,NULL); ++ else ++ filesel = gtk_file_chooser_dialog_new(title, GTK_WINDOW(window), ++ GTK_FILE_CHOOSER_ACTION_SAVE, ++ GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, ++ GTK_STOCK_SAVE,GTK_RESPONSE_ACCEPT,NULL); + + align = gtk_alignment_new(1, 0, 0, 0); +- gtk_box_pack_end(GTK_BOX(GTK_FILE_SELECTION(filesel)->main_vbox), +- align, FALSE, FALSE, 0); ++ gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(filesel),align); + table = gtk_table_new(2, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(table), 5); + gtk_container_add(GTK_CONTAINER(align), table); +@@ -340,15 +347,15 @@ + option_menu_lineend = create_lineend_menu(selected_fi); + gtk_table_attach_defaults(GTK_TABLE(table), option_menu_lineend, 1, 2, 0, 1); + } +- gtk_widget_show_all(GTK_FILE_SELECTION(filesel)->main_vbox); ++ gtk_widget_show_all(GTK_FILE_CHOOSER(filesel)); + + if (selected_fi->filename) +- gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), selected_fi->filename); ++ gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(filesel), selected_fi->filename); + + return filesel; + } + +-FileInfo *get_fileinfo_from_selector(GtkWidget *window, FileInfo *fi, gint requested_mode) ++FileInfo *get_fileinfo_from_chooser(GtkWidget *window, FileInfo *fi, gint requested_mode) + { + FileInfo *selected_fi; + GtkWidget *filesel; +@@ -366,24 +373,24 @@ + selected_fi->manual_charset = + fi->manual_charset ? g_strdup(fi->manual_charset) : NULL; + +- filesel = create_file_selector(selected_fi); ++ filesel = create_file_chooser(selected_fi,window); + + gtk_window_set_transient_for(GTK_WINDOW(filesel), GTK_WINDOW(window)); + + do { + res = gtk_dialog_run(GTK_DIALOG(filesel)); +- if (res == GTK_RESPONSE_OK) { ++ if (res == GTK_RESPONSE_ACCEPT) { + if (selected_fi->filename) + g_free(selected_fi->filename); + selected_fi->filename = g_strdup( +- gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel))); ++ gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel))); + if (g_file_test(selected_fi->filename, G_FILE_TEST_IS_DIR)) { + len = strlen(selected_fi->filename); + if (len < 1 || selected_fi->filename[len - 1] != G_DIR_SEPARATOR) + str = g_strconcat(selected_fi->filename, G_DIR_SEPARATOR_S, NULL); + else + str = g_strdup(selected_fi->filename); +- gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), str); ++ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filesel), str); + g_free(str); + continue; + } +@@ -397,14 +404,14 @@ + case GTK_RESPONSE_NO: + continue; + case GTK_RESPONSE_YES: +- res = GTK_RESPONSE_OK; ++ res = GTK_RESPONSE_ACCEPT; + } + } + } + gtk_widget_hide(filesel); + } while (GTK_WIDGET_VISIBLE(filesel)); + +- if (res != GTK_RESPONSE_OK) { ++ if (res != GTK_RESPONSE_ACCEPT) { + if (selected_fi->charset) + g_free(selected_fi->charset); + if (selected_fi->manual_charset) +--- src/selector.h.orig Thu Feb 3 20:17:09 2005 ++++ src/selector.h Thu Feb 3 20:17:27 2005 +@@ -30,6 +30,6 @@ + OPEN + }; + +-FileInfo *get_fileinfo_from_selector(GtkWidget *window, FileInfo *fi, gint requested_mode); ++FileInfo *get_fileinfo_from_chooser(GtkWidget *window, FileInfo *fi, gint requested_mode); + + #endif /* _SELECTOR_H */ --- leafpad.patch ends here ---
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1110540050.0>