Replace deprecated override_background_color()
This commit is contained in:
		
							parent
							
								
									f4a6b0299a
								
							
						
					
					
						commit
						bdf16c5182
					
				
					 3 changed files with 28 additions and 11 deletions
				
			
		|  | @ -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> | ||||
|  |  | |||
|  | @ -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)) | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue