Sunday, July 8, 2012

Ambiance Fix: Gedit's "Highlight Current Line" (zonModAmbiance Update)

In previous post, I wrote an article about fixing Ambiance theme (Ubuntu default theme), and also created a new theme called zonModAmbiance (a modified version of Ambiance), containing some fix mainly for the GNOME Panel in Classic session in Ubuntu 12.04.

Later, I found that Ambiance theme is also has some problem with Gedit text editor. If you use Gedit with its default settings/preferences, you won't see any problem when using Ambiance them.

The problem will appear when you activate the "Display line numbers" and "Highlight current line" features in Gedit Preferences.


Like you can see in the screenshot above, the current line is not highlighted, just like other lines in the main text area. And also, the line numbers is displayed without any difference from the main text area.

FYI: This bug has been reported on Launchpad (see this page).

This won't be a big problem if you just use Gedit to open one or two text files. But if you use it a lot with many tabs opened, especially when working with long line of codes, this gives you a problem to quickly recognize the cursor position in current line from others.

So, to fix this issue, I made some other modifications to the original Ambiance theme. Here is a screenshot of the modification, displaying current line and line numbers:


O.K., without further bla bla bla, how to fix this issue? Here it is.


Alternatif 1:
Create css config file in User's Home folder


Open a text editor (Gedit), copy-paste the following codes into a new blank text document:
GtkTextView {
    background-color: @bg_color;
}
GtkTextView.view {
    background-color: @base_color;
}
GtkTextView.view:selected {
    background-color: @selected_bg_color;
}
GtkTextView.view:backdrop {
    background-color: mix (@base_color, @bg_color, 0.4);
}
GtkTextView.view:selected:backdrop {
    background-color: shade (@bg_color, 0.92);
}

Then save the newly created file as gtk.css in ~/.config/gtk-3.0 folder (/home/[YourUserName]/.config/gtk-3.0/gtk.css). Create the gtk-3.0 folder if it doesn't exist. Close Gedit and re-open it to see the changes.

***

Alternatif 2:
Modify the original Ambiance theme code directly


Modify gtk-widgets.css and gtk-widgets-backdrop.css of the original Ambiance theme.
  1. Modify gtk-widgets.css

    • Open /usr/share/themes/Ambiance/gtk-3.0/gtk-widgets.css with text editor/Gedit with admin privilege, by running the following command in Terminal:
      sudo gedit /usr/share/themes/Ambiance/gtk-3.0/gtk-widgets.css
    • Find/search the following codes (line 1895-1897):
      GtkTextView {
          background-color: @base_color;
      }
    • Replace with:
      GtkTextView.view {
          background-color: @base_color;
      }
      GtkTextView.view:selected {
          background-color: @selected_bg_color;
      }
    • Save the file.
      .
  2. Modify gtk-widgets-backdrop.css

    • Open /usr/share/themes/Ambiance/gtk-3.0/gtk-widgets-backdrop.css with text editor/Gedit with admin privilege, by running the following command in Terminal:
      sudo gedit /usr/share/themes/Ambiance/gtk-3.0/gtk-widgets-backdrop.css
    • Find/search the following codes (line 992-994):
      GtkTextView:backdrop {
          background-color: mix (@base_color, @bg_color, 0.4);
      }
    • Replace with:
      GtkTextView.view:backdrop {
          background-color: mix (@base_color, @bg_color, 0.4);
      }
      GtkTextView.view:selected:backdrop {
          background-color: @backdrop_selected_bg_color;
      }
    • Save the file.
      .

***

Alternatif 3:
Use a modified theme

If you don't want to modify existing theme nor create css config files, you can simply use the updated version of my theme called "zonModAmbiance", a ready-to-use, modified version of the original Ambiance theme.


To use the theme, extract the .tar.gz file and move either to /usr/share/themes/ or /home/[YourUserName]/.themes/, and then use gnome-tweak-tool or MyUnity in Ubuntu 12.04 to activate the theme.

***

Flexible theme can mimic Ambiance theme

Recently, I released a new theme called zonColor, that you can use to mimic the color scheme of Ambiance theme, or any other themes, or even make your own (and of course, without the "highlight current line" bug in Gedit).

.

PS: Still, sorry for my English :)

4 comments:

  1. Many thanks! I downloaded the theme you prepared, and that worked flawlessly. I appreciate your work; it was very helpful.

    ReplyDelete
  2. Exactly what i was looking for.

    ReplyDelete
  3. Can you please tell me how to make the "current line" darker?

    ReplyDelete

Google+ Comments Disqus Comments
Disqus Comments Google+ Comments
comments powered by Disqus