Re: [flpsed] New Features ?

From: Johannes Hofmann <Johannes.Hofmann_at_gmx.de>
Date: Mon, 7 Sep 2009 21:50:46 +0200

On Mon, Sep 07, 2009 at 02:25:52AM +0200, Sydro wrote:
> On Sun, 6 Sep 2009 17:47:09 +0200
> Johannes Hofmann <Johannes.Hofmann_at_gmx.de> wrote:
>
> > Hi Sydro,
> >
> > On Sun, Sep 06, 2009 at 02:32:46PM +0200, Sydro wrote:
> > > Hi,
> > >
> > > i'm sYdRo, i'm italian linux user and new user of this mailing list.
> >
> > Welcome. This mailing list is pretty new anyway :)
> >
> > >
> > > though I'm not a good programmer, i tried to implement any features:
> > >
> > > - Window title changes with opened file name.
> >
> > Definately a good thing!
> >
> > > - PagUp and PagDown keys managed like in evince to change page on the end.
> >
> > Sounds good too.
> >
> > > - Recent files menu with list saved in .flpsed file
> >
> > Hm. I'd prefer to save this data with fltk preferences. It's already
> > used to remember the last print command. Check flpsed.cxx.
> >
> > > - Right mouse can create continuos lines with underline of text. ( lines == more underscore )
> >
> > I think I don't understand this, but I'd like to check it.
> >
> > >
> > > if you want, i can upload the source code on my space.
> >
> > Yes please, or just post patches to the mailing list for all to see.
>
> done!
>
> The source is here : http://salug.it/~sydro/progetti/flpsed-0.6.1.tar.gz

Thanks for sharing the code.
For reviewing and integrating it would be better if you could send a
single patch for each feature you added.
As an example I did it for your title feature below.
The patch is for the fltk-1 version but I will merge it into the
fltk-2 version of flpsed as well.

It is very easy to create patches like that:
* Install mercurial (http://selenic.com/mercurial).
* hg clone http://www.flpsed.org/hgweb/flpsed
* hack hack hack
* hg diff

Mercurial is really a joy to work with. It's worth trying.

I made some minor changes to your solution:

* Instead of dynamic array allocation on the stack which seems to
  be a feature of the C99 standard I switched to plain malloc() to
  avoid problems with other compilers than gcc.
* fltk needs to be told to actually copy the label by using
  copy_label().

Cheers,
Johannes

diff -r 5b3075269476 COPYING
--- a/COPYING Mon Sep 07 21:07:12 2009 +0200
+++ b/COPYING Mon Sep 07 21:38:46 2009 +0200
@@ -1,1 +1,1 @@
-/usr/pkg/share/automake-1.10/COPYING
\ No newline at end of file
+/usr/pkg/share/automake-1.11/COPYING
\ No newline at end of file
diff -r 5b3075269476 src/flpsed.cxx
--- a/src/flpsed.cxx Mon Sep 07 21:07:12 2009 +0200
+++ b/src/flpsed.cxx Mon Sep 07 21:38:46 2009 +0200
@@ -34,6 +34,7 @@
 PSEditor *psed_p = NULL;
 Fl_Scroll *scroll = NULL;
 Fl_Hold_Browser *page_sel = NULL;
+Fl_Window *win;
 
 int xev_handler(int ev) {
         if (psed_p)
@@ -132,6 +133,11 @@
         const char *args[5];
         pid_t pid;
         char *dot = strrchr(file, '.');
+ static const char *title_prefix = "flpsed - ";
+ int title_len = strlen(file) + strlen(title_prefix) + 1;
+ char *title = (char*) malloc(title_len);
+
+ snprintf(title, title_len, "%s%s", title_prefix, file);
 
         if (dot && strcasecmp(dot, ".pdf") == 0) {
                 // assume pdf and try to import it using pdftops
@@ -153,6 +159,8 @@
                         } else if (WEXITSTATUS(status) != 0) {
                                 fl_message("PDF import failed\n");
                         }
+
+ win->copy_label(title);
                 } else {
                         perror("pexecvp");
                 }
@@ -160,8 +168,11 @@
                 // assume postscript
                 psed_p->open_file(file);
                 psed_p->load();
+ win->copy_label(title);
         }
 
+ free(title);
+
         page_sel_fill();
 }
 
@@ -482,7 +493,6 @@
         char *sep, *tmp, **my_argv;
         int c, err, bflag = 0, dflag = 0;
         int i, n;
- Fl_Window *win;
         Fl_Menu_Bar *m;
         struct {char *tag; char *value;} tv[TV_LEN];
         int tv_idx = 0, my_argc;
Received on Mon Sep 07 2009 - 21:50:46 CEST

This archive was generated by hypermail 2.2.0 : Mon Sep 07 2009 - 21:55:01 CEST