Re: [gedit-list] Adding Tabs On Startup Bug?



On 08/30/2010 05:34 AM, Jeff Johnston wrote:
I am adding the ability to load tabs (documents) up on startup for my CodeSlayer plugin. The problem is that if I add them when my plugin is run then gedit starts up with a really small window. I found that the problem is in the gedit_window_create_tab_from_uri() method. Specifically it is the following code that causes the problem:

    if (!GTK_WIDGET_VISIBLE (window))
    {
        gtk_window_present (GTK_WINDOW (window));
    }

If I comment out the gtk_window_present() method then gedit starts up with the window as the size that I closed it. This code seems to be showing the window if the window is not visible? I am wondering when this would be useful? If it is needed then I am not sure how to get around the issue. And, just to be clear, this is just a problem when adding tabs when my plugin is started. It has something to do with the fact that the plugins are called in the gedit_window_init(). If the tabs are added after the window is created then it works. However, by the time the window is fully initialized my plugin has no way to automatically load up the tabs.
An easy workaround would be to only add your tabs when the window is realized (i.e. connect to the 'realize' event). The window size is set using 'gtk_window_set_default_size' which only affects a window that is not yet shown.

On the question whether or not gtk_window_present should be there, I see it was added as part of the OS X integration work (because on OS X, when there are no tabs open, the window is hidden). We might maybe move the window intialization code inside gedit-window if possible to avoid the whole problem. Could you file a bug on bugzilla.gnome.org about this?

I do see in the gedit.c file that somehow I may be able to pass in a "file_list". However, I am not sure how to get this to work with the API directly. And even if it did that would not really work as well as just using the API directly. When I create the tabs I add metadata to the documents. If I just pass in a list of files then I cannot do that.

The other bit of code that I would like to talk about is in gedit.c where it creates a tab if a "file_list" is not passed in. I am wondering if it would be better to check the tabs to see if any exist. If they do then a blank tab is not created.

Thoughts? I am more than willing to submit a patch if I know what the right thing to do is.

-Jeff Johnston


_______________________________________________ gedit-list mailing list gedit-list gnome org http://mail.gnome.org/mailman/listinfo/gedit-list



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