From bdf16c51828039ceb9bb67c4823aa6181869820c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <forenjunkie@chello.at> Date: Mon, 18 Dec 2017 00:11:39 +0100 Subject: [PATCH] Replace deprecated override_background_color() --- gajim/data/gui/popup_notification_window.ui | 6 ++++- gajim/dialogs.py | 26 +++++++++++++-------- gajim/gtkgui_helpers.py | 7 ++++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/gajim/data/gui/popup_notification_window.ui b/gajim/data/gui/popup_notification_window.ui index fcc16d5d05..2fade7bb88 100644 --- a/gajim/data/gui/popup_notification_window.ui +++ b/gajim/data/gui/popup_notification_window.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.1 --> <interface> <requires lib="gtk+" version="3.12"/> <object class="GtkWindow" id="popup_notification_window"> @@ -16,6 +16,7 @@ <signal name="button-press-event" handler="on_popup_notification_window_button_press_event" swapped="no"/> <child> <object class="GtkEventBox" id="eventbox"> + <property name="name">PopupNotificationEventBox</property> <property name="visible">True</property> <property name="can_focus">False</property> <child> @@ -116,5 +117,8 @@ </child> </object> </child> + <child type="titlebar"> + <placeholder/> + </child> </object> </interface> diff --git a/gajim/dialogs.py b/gajim/dialogs.py index 6dcd10e066..9b6a990227 100644 --- a/gajim/dialogs.py +++ b/gajim/dialogs.py @@ -3114,10 +3114,10 @@ class PopupNotificationWindow: self.jid = jid self.msg_type = msg_type self.index = len(app.interface.roster.popup_notification_windows) - xml = gtkgui_helpers.get_gtk_builder('popup_notification_window.ui') self.window = xml.get_object('popup_notification_window') self.window.set_type_hint(Gdk.WindowTypeHint.TOOLTIP) + self.window.set_name('NotificationPopup') close_button = xml.get_object('close_button') event_type_label = xml.get_object('event_type_label') event_description_label = xml.get_object('event_description_label') @@ -3133,10 +3133,8 @@ class PopupNotificationWindow: '<span foreground="black" weight="bold">%s</span>' % GLib.markup_escape_text(title)) - # set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ] - color = Gdk.RGBA() - Gdk.RGBA.parse(color, 'black') - self.window.override_background_color(Gtk.StateType.NORMAL, color) + css = '#NotificationPopup {background-color: black }' + gtkgui_helpers.add_css_to_widget(self.window, css) # default image if not path_to_image: @@ -3162,11 +3160,19 @@ class PopupNotificationWindow: bg_color = app.config.get('notif_status_color') else: # Unknown event! Shouldn't happen but deal with it bg_color = app.config.get('notif_other_color') - popup_bg_color = Gdk.RGBA() - Gdk.RGBA.parse(popup_bg_color, bg_color) - close_button.override_background_color(Gtk.StateType.NORMAL, - popup_bg_color) - eventbox.override_background_color(Gtk.StateType.NORMAL, popup_bg_color) + + background_class = ''' + .popup-style { + border-image: none; + background-image: none; + background-color: %s }''' % bg_color + + gtkgui_helpers.add_css_to_widget(eventbox, background_class) + eventbox.get_style_context().add_class('popup-style') + + gtkgui_helpers.add_css_to_widget(close_button, background_class) + eventbox.get_style_context().add_class('popup-style') + event_description_label.set_markup('<span foreground="black">%s</span>' % GLib.markup_escape_text(text)) diff --git a/gajim/gtkgui_helpers.py b/gajim/gtkgui_helpers.py index 4c9553fbff..f3b396d326 100644 --- a/gajim/gtkgui_helpers.py +++ b/gajim/gtkgui_helpers.py @@ -851,6 +851,13 @@ def add_css_class(widget, class_name): if class_name: style.add_class('theme_' + class_name) +def add_css_to_widget(widget, css): + provider = Gtk.CssProvider() + provider.load_from_data(bytes(css.encode())) + context = widget.get_style_context() + context.add_provider(provider, + Gtk.STYLE_PROVIDER_PRIORITY_USER) + def remove_css_class(widget, class_name): style = widget.get_style_context() style.remove_class('theme_' + class_name) -- GitLab