[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gEDA-dev: [PATCH] gschem: recent files support



On Sat, 2007-04-21 at 11:42 +0200, Ivan Stankovic wrote:

> Yes. But that's just my preference. I could probably make it
> configurable, to allow opening in a new page or in a new window, 
> but I'm not sure if it would be worth the time/code. What do others
> think?

Its no big problem if it opens in a new window. If it someone wants to
make it configurable, then they can do it later anyway.

Probably best to get the functionality in first.

With my patch, the code to do this would be (of the top of my head)

  toplevel = s_toplevel_new ();
  x_window_setup (toplevel);

  page = x_window_open_page (toplevel, new_filename_to_open);
  x_window_set_current_page (toplevel, page);
  s_log_message (_("New Window created [%s]\n"), page->page_filename);

Ok - I know, I didn't consolidate all the file->open stuff into
x_window_open_page(), the log entries are still required.

Also, x_window_set_current_page() handles updating zoom factor and
scroll bars etc. This is not done from within x_window_open_page(..) as
when opening multiple files, you don't need or want to do this for every
page, just the final one you end up showing.

> > 5.
> > 
> > It seems you don't add to the recent files list for files opened from
> > the command line. This would be addressed nicely with the fix to 2.
> 
> Agreed. I will wait for your patch to be in CVS.

I'm looking at it this morning. I'm sorry - It appears I didn't upload
this one to the tracker! I'll upload it for you to see, but hopefully it
will make CVS soon.

> Hmm, I'll need to have a closer look at how menus are created from
> scheme.... (The above was easiest for me to do since I'm not so
> familiar with gschem code.)
> 
> Thanks for the comments!

Take a look in system-gschemrc.in under gschem/lib in the source tree.


(define file-menu-items 
;;
;;          menu item name      menu action     	menu hotkey function
;;
	'( ("New Window"  	file-new-window 	file-new-window) 
	   ("New Page"		file-new 		file-new)
[snip]
	   ("Close Window"   	file-close-window 	file-close-window)
	   ("Quit" 		file-quit 		file-quit)))

There also appear to be strings for internationalisation purposes in
src/rcstrings.c but I'm not sure where they are referenced. I'd guess,
adding a line to that when you add a "Recent items" line in
system-gschemrc.in does the trick. (Not sure if it has to be in the same
order as the gschemrc file).

The actions file-quit etc.. are defined in gschem as functions exported
to guile (the scheme interpreter). They are defined in i_callbacks.c,
like this:

DEFINE_I_CALLBACK(file_new_window)
{
...
}

The macro expansion is:

#define DEFINE_I_CALLBACK(name)				\
	void i_callback_ ## name(gpointer data,		\
			         guint callback_action,	\
			         GtkWidget *widget)

a grep helps find the rest of the puzzle:

grep file_new_window *.c

g_keys.c:DEFINE_G_KEYS(file_new_window)
g_register.c:  { "file-new-window",           0, 0, 0, g_keys_file_new_window },
i_callbacks.c:DEFINE_I_CALLBACK(file_new_window)

g_keys.c defines a wrapper function around the i_callback.c function,
and g_register.c registers it with guile. You'll find "file-new-window"
referenced from within system-gschemrc.in.

My strategy for dealing with the guile stuff is to find a similar thing
I want to copy, then use grep to chase it through the various places it
is implemented.

Good luck, and great work on the patch so far.

Regards,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev