After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 309187 - Preselected highlighting mode in preferences
Preselected highlighting mode in preferences
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: general
2.10.x
Other All
: Low enhancement
: 2.12.0
Assigned To: Gedit maintainers
gedit QA volunteers
Depends on:
Blocks:
 
 
Reported: 2005-06-30 06:03 UTC by Timo Saarinen
Modified: 2005-08-01 17:43 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
gedit-preselect-highlighting.patch (1.72 KB, patch)
2005-07-31 10:24 UTC, Ruben Vermeersch
none Details | Review
Correctly formatted patch (1.66 KB, patch)
2005-07-31 10:46 UTC, Ruben Vermeersch
accepted-commit_now Details | Review
Cleaned patch (2.37 KB, patch)
2005-08-01 11:08 UTC, Ruben Vermeersch
none Details | Review
Catch NULL from gedit_get_active_document () (2.54 KB, patch)
2005-08-01 11:52 UTC, Ruben Vermeersch
committed Details | Review

Description Timo Saarinen 2005-06-30 06:03:02 UTC
The highlighting mode of the current file should be selected in the highlighting
mode in the Syntax highlighting tab in preferences. Currently the highligh mode
faults empty even if the editor "knows" the highlighling mode of the current file.

Other information:
Comment 1 Timo Saarinen 2005-06-30 06:05:50 UTC
Correction: the highlighting mode always defaults "Ada".
Comment 2 Paolo Maggi 2005-07-21 17:17:55 UTC
Note that the preferences dialog is not modal, so the concept of "current file"
is  not very well defined in this case. 
You mean the file that was active when the preferences dialog has been opened.
Right?
Comment 3 Timo Saarinen 2005-07-25 12:11:54 UTC
That solution sounds good enough. :-)
Comment 4 Ruben Vermeersch 2005-07-31 10:24:54 UTC
Created attachment 50010 [details] [review]
gedit-preselect-highlighting.patch

Made a quick patch for this (looks like it's indented wrong (tabs/spaces),
sorry). As I have very little experience doing GTK+ programming, I'd like to
get some feedback whether or not this is the sane way to do this.

Works fine though.

 gedit-preferences-dialog.c |	14 ++++++++++++++
 1 files changed, 14 insertions(+)
Comment 5 Ruben Vermeersch 2005-07-31 10:46:08 UTC
Created attachment 50012 [details] [review]
Correctly formatted patch

Fixed the formatting
Comment 6 Paolo Maggi 2005-08-01 10:14:40 UTC
Comment on attachment 50012 [details] [review]
Correctly formatted patch

The patch looks really good to me.

A few cosmetic comments:

>+	current_document = gedit_get_active_document();

Add a space before left bracket.

>+	gtk_option_menu_set_history (GTK_OPTION_MENU (dlg->hl_mode_optionmenu), 
>+			  selected_language);

Align selected_language just below GTK_OPTION_MENU

Please, re-attach the patch with a ChangeLog entry and I will commit it for
you.

When you create a patch, please use the -p option too (for diff).

Thanks for you help.
Comment 7 Paolo Borelli 2005-08-01 10:31:19 UTC
another minor cosmetic comment: braces on their own line.

if (foo)
{
       lalal;
}
Comment 8 Paolo Borelli 2005-08-01 10:33:41 UTC
there is another issue actually: gedit_get_active_document() may return NULL, so
you need to handle that case.
Comment 9 Ruben Vermeersch 2005-08-01 11:07:47 UTC
> ------- Additional Comment #8 From paolo borelli  2005-08-01 10:33 UTC -------
> there is another issue actually: gedit_get_active_document() may return NULL, 
> so you need to handle that case.

This shouldn't be a problem, gedit_document_get_language (GeditDocument *doc)
contains a "g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);" line.
Current_document_language would then be NULL and never match the in-progress
language. Selected_language defaults to 0, so it would simply select the first item.

Or am I failing to see something crucial here?
Comment 10 Ruben Vermeersch 2005-08-01 11:08:51 UTC
Created attachment 50059 [details] [review]
Cleaned patch

New patch, not sure if the ChangeLog entry is OK though.
Comment 11 Paolo Borelli 2005-08-01 11:24:42 UTC
g_return_val_if_fail is substantially an assertion of something that should
never happen, when the condition is hit a critical warning is printed on screen.
Beside these assertion can be disabled in distro builds, so you should never
rely on them.
Comment 12 Ruben Vermeersch 2005-08-01 11:52:10 UTC
Created attachment 50064 [details] [review]
Catch NULL from gedit_get_active_document ()

OK, added the assertion in real code, new patch attached:

+   current_document = gedit_get_active_document ();
+   if (current_document != NULL) 
+   {
+	current_document_language = gedit_document_get_language (
+			current_document);
+   }
+   else 
+   {
+	current_document_language = NULL;
+   }
Comment 13 Paolo Maggi 2005-08-01 13:10:25 UTC
Comment on attachment 50064 [details] [review]
Catch NULL from gedit_get_active_document ()

Thank you very much for the patch. It looks good to me.
I will test and commit it ASAP.
Comment 14 Paolo Maggi 2005-08-01 17:43:14 UTC
Committed with some cosmetic changes.

2005-08-01  Ruben Vermeersch  <ruben@Lambda1.be>

	Fixed bug #309187 (Preselected highlighting mode in preferences)
	
	* dialogs/gedit-preferences-dialog.c setup_syntax_highlighting_page): 
	Automatically select the language of the active document.