Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added background color and text color to tab label #2236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion guake/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _add_search_box(self):
self.search_frame.get_style_context().add_class("background")
css_provider = Gtk.CssProvider()
css_provider.load_from_data(
b"#search-frame border {" b" padding: 5px 5px 5px 5px;" b" border: none;" b"}"
"""#search-frame border { padding: 5px 5px 5px 5px; border: none;} notebook tab {padding:5px 5px 0px 5px; margin: 0px 0px 0px 0px;}"""
)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
Expand Down Expand Up @@ -711,6 +711,20 @@ def on_rename(self, user_data):

self.grab_focus_on_last_focused_terminal()

@save_tabs_when_changed
def on_tab_color_change(self, user_data):
HidePrevention(self.get_toplevel()).prevent()
dialog = Gtk.ColorChooserDialog(_("Select Color"), self.notebook.guake.window)
if dialog.run() == Gtk.ResponseType.OK:
color = dialog.get_rgba()
dialog.destroy()
page_num = self.notebook.find_tab_index_by_label(self)
self.notebook.color_page(page_num, color, True)
HidePrevention(self.get_toplevel()).allow()
self.grab_focus_on_last_focused_terminal()



@save_tabs_when_changed
def on_reset_custom_colors(self, user_data):
HidePrevention(self.get_toplevel()).prevent()
Expand Down
11 changes: 11 additions & 0 deletions guake/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ def mk_tab_context_menu(callback_object):
mi_reset_custom_colors = Gtk.MenuItem(_("Reset custom colors"))
mi_reset_custom_colors.connect("activate", callback_object.on_reset_custom_colors)
menu.add(mi_reset_custom_colors)

menu.add(Gtk.SeparatorMenuItem())

mi_change_tab_colors = Gtk.MenuItem(_("Change tab colors"))
mi_change_tab_colors.connect("activate", callback_object.on_tab_color_change)
menu.add(mi_change_tab_colors)
menu.add(Gtk.SeparatorMenuItem())




mi_close = Gtk.MenuItem(_("Close"))
mi_close.connect("activate", callback_object.on_close)
menu.add(mi_close)
Expand Down
28 changes: 27 additions & 1 deletion guake/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def on_tab_selection(self, user_data):
# ref: epiphany
css_provider = Gtk.CssProvider()
css_provider.load_from_data(
b"#popover-window list { border-style: none; background-color: transparent; }"
b"#popover-window list { border-style: none; background-color: transparent; }"
)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
Expand Down Expand Up @@ -376,6 +376,11 @@ def new_page(self, directory=None, position=None, empty=False, open_tab_cwd=Fals
root_terminal_box, None, position if position is not None else -1
)
self.set_tab_reorderable(root_terminal_box, True)





self.show_all() # needed to show newly added tabs and pages
# this is needed because self.window.show_all() results in showing every
# thing which includes the scrollbar too
Expand Down Expand Up @@ -472,6 +477,27 @@ def rename_page(self, page_index, new_text, user_set=False):
if user_set:
setattr(page, "custom_label_set", new_text != "-")

def color_page(self, page_index, color, user_set=False):
page = self.get_nth_page(page_index)
#page.set_name("tab-label")
label = self.get_tab_label(page)
text_color = '#FFFFFF' if (color.red * 0.299 + color.green * 0.587 + color.blue * 0.114) > 186 else '#000000'
label.set_name("tab-label" + str(page_index))
css = """notebook #tab-label{page_index} {{border:none; background-color: rgba({red}, {green}, {blue}, 1); color: {text_color}; }}""".format(page_index=page_index,
red=color.red *255, green=color.green*255, blue=color.blue*255,
text_color=text_color
).encode()

css_provider = Gtk.CssProvider()
css_provider.load_from_data(css)

Gtk.StyleContext().add_provider_for_screen(
Gdk.Screen.get_default(),
css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
)


def find_tab_index_by_label(self, eventbox):
for index, tab_eventbox in enumerate(self.iter_tabs()):
if eventbox is tab_eventbox:
Expand Down