<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 27 May 2013 18:24, Pallai Roland <span dir="ltr"><<a href="mailto:pallair@magex.hu" target="_blank">pallair@magex.hu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>Reproduction:<br><br>1. set new_document_after_close and auto focus widgets to off in preferences<br>2. open a file from file/tree browser or "find in files" search results<br>
3. close the document with shortcut<br>
<br>I expect the focus will jump back where were before. Actual result is no widget with focus (the window still has the focus of course).<br><br><br>I used the the following snippet to debug:<br><br>void<br>get_focused_widget(gpointer data)<br>

{<br>    GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));<br>    printf("focused widget: %s\n", gtk_widget_get_name(widget));<br>}<br>g_timeout_add(1000, (GSourceFunc)get_focused_widget, NULL);<br>

<br>Result of an open-close cycle from tree browser:<br><br>focused widget: GtkTreeView<br>[...]<br>focused widget: Scintilla<br>[...]<br>focused widget: (null)<div class="HOEnZb"><div class="h5"><br></div></div></blockquote>
<div><br></div><div style>Ok, now I see what you are on about. </div><div style><br></div><div style>I see several problems with the proposal:</div><div style><br></div><div style>1) What is the "correct" behaviour? As you say there are several open methods, do I return to the method used for the particular file that was closed last, even though I had opened many other files using a different widget since that file was opened.  I would have said that the most recently used method might be more likely to be the one I want.  And some I probably don't want to return to, eg if the file was opened from a compiler error message and as you say having a dialog open automatically is wrong too.</div>
<div style><br></div><div style>2) Methods of opening files are provided by plugins, filebrowser being the initial example, but treebrowser and the project plugins being other options.  Geany does not know about what plugins can do for opening files, and passing a widget pointer to Geany is risky since the plugin may have been closed in the meantime and the widget deleted.  Trying to use that is a likely crash.</div>
<div><br></div><div style>In general this is a situation where Geany can't assume what the user wants to do, it is better to let the user focus something via the mouse or keybinding.</div><div style><br></div><div style>
Cheers</div><div style>Lex</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">
2013/5/27 Lex Trotman <span dir="ltr"><<a href="mailto:elextr@gmail.com" target="_blank">elextr@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On 27 May 2013 07:51, Pallai Roland <span dir="ltr"><<a href="mailto:pallair@magex.hu" target="_blank">pallair@magex.hu</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br><br><br>I'm struggling with an issue: GTK focus lost when last document closed.<br></blockquote><div><br></div>


</div><div>Can you describe more clearly what the problem you are trying to solve is? AFAICT Geany retains focus after the last document is closed.</div><div><br></div><div>Cheers</div><div>Lex</div><div>
<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><br>To grab the focus by a plugin (eg. filebrowser) on such case would be an easy task, but not right, because the user can open documents from many widgets, the focus should return there.<br>



<br>I tried for a while with gtk_container_set_focus_chain() but no luck. Maybe my bad, I have no experience with GTK.<br><br>Other, simple solution if Geany provides a new API call. eg.:<br> void ui_focus_history_push(GtkWidget *widget);<br>



and widgets/plugins can call it on focus-out-event, so Geany (or a plugin) can restore the focus if there is no better strategy.<br><br>Another solution to extend<br> document_open_file(const gchar *locale_filename, gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc)<br>



with "GtkWidget *widget" or introduce a new function like<br> document_open_file_from_widget(const gchar *locale_filename, gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc, GtkWidget *widget)<br>to store opening widget with the document, but I think this can cause weird behavior if the last closed document were opened from a dialog window.<br>



<br>How should I fix it?<br><br><br>--<br> Roland Pallai<br><br>
<br></div></div>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org" target="_blank">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org" target="_blank">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@lists.geany.org">Devel@lists.geany.org</a><br>
<a href="https://lists.geany.org/cgi-bin/mailman/listinfo/devel" target="_blank">https://lists.geany.org/cgi-bin/mailman/listinfo/devel</a><br>
<br></blockquote></div><br></div></div>