Dont use depracted override_background_color()
This commit is contained in:
		
							parent
							
								
									516a18eb5d
								
							
						
					
					
						commit
						e00341e83e
					
				
					 10 changed files with 33 additions and 146 deletions
				
			
		|  | @ -382,6 +382,7 @@ | |||
|             <property name="spacing">5</property> | ||||
|             <child> | ||||
|               <object class="GtkEventBox" id="banner_eventbox"> | ||||
|                 <property name="name">ChatControl-BannerEventBox</property> | ||||
|                 <property name="visible">True</property> | ||||
|                 <property name="can_focus">False</property> | ||||
|                 <child> | ||||
|  | @ -411,6 +412,7 @@ | |||
|                         <property name="orientation">vertical</property> | ||||
|                         <child> | ||||
|                           <object class="GtkLabel" id="banner_name_label"> | ||||
|                             <property name="name">ChatControl-BannerNameLabel</property> | ||||
|                             <property name="visible">True</property> | ||||
|                             <property name="can_focus">False</property> | ||||
|                             <property name="label"><span weight="heavy" size="large">Contact name</span></property> | ||||
|  | @ -425,6 +427,7 @@ | |||
|                         </child> | ||||
|                         <child> | ||||
|                           <object class="GtkLabel" id="banner_label"> | ||||
|                             <property name="name">ChatControl-BannerLabel</property> | ||||
|                             <property name="visible">True</property> | ||||
|                             <property name="can_focus">False</property> | ||||
|                             <property name="label">label</property> | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ | |||
|         <property name="spacing">6</property> | ||||
|         <child> | ||||
|           <object class="GtkEventBox" id="banner_agent_eventbox"> | ||||
|             <property name="name">Discovery-BannerEventBox</property> | ||||
|             <property name="visible">True</property> | ||||
|             <property name="can_focus">False</property> | ||||
|             <child> | ||||
|  | @ -33,6 +34,7 @@ | |||
|                 <property name="spacing">6</property> | ||||
|                 <child> | ||||
|                   <object class="GtkLabel" id="banner_agent_label"> | ||||
|                     <property name="name">Discovery-BannerLabel</property> | ||||
|                     <property name="visible">True</property> | ||||
|                     <property name="can_focus">False</property> | ||||
|                     <property name="ypad">6</property> | ||||
|  |  | |||
|  | @ -1024,8 +1024,8 @@ class ChatControl(ChatControlBase): | |||
|                 displaymarking = None | ||||
|             if self.correcting: | ||||
|                 self.correcting = False | ||||
|                 self.msg_textview.override_background_color( | ||||
|                     Gtk.StateType.NORMAL, self.old_message_tv_color) | ||||
|                 gtkgui_helpers.remove_css_class( | ||||
|                     self.msg_textview, 'msgcorrectingcolor') | ||||
| 
 | ||||
|             self.print_conversation(message, self.contact.jid, | ||||
|                 encrypted=encrypted, xep0184_id=xep0184_id, xhtml=xhtml, | ||||
|  |  | |||
|  | @ -158,7 +158,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): | |||
|         """ | ||||
|         Derived types MAY implement this | ||||
|         """ | ||||
|         self._paint_banner() | ||||
|         self.draw_banner() | ||||
| 
 | ||||
|     def _update_banner_state_image(self): | ||||
|  | @ -371,7 +370,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): | |||
|         if gajim.config.get('use_speller') and HAS_GTK_SPELL: | ||||
|             self.set_speller() | ||||
|         self.conv_textview.tv.show() | ||||
|         self._paint_banner() | ||||
| 
 | ||||
|         # For XEP-0172 | ||||
|         self.user_nick = None | ||||
|  | @ -503,76 +501,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): | |||
|         # send the message | ||||
|         self.send_message(message, xhtml=xhtml) | ||||
| 
 | ||||
|     def _paint_banner(self): | ||||
|         """ | ||||
|         Repaint banner with theme color | ||||
|         """ | ||||
|         theme = gajim.config.get('roster_theme') | ||||
|         bgcolor = gajim.config.get_per('themes', theme, 'bannerbgcolor') | ||||
|         textcolor = gajim.config.get_per('themes', theme, 'bannertextcolor') | ||||
|         # the backgrounds are colored by using an eventbox by | ||||
|         # setting the bg color of the eventbox and the fg of the name_label | ||||
|         banner_eventbox = self.xml.get_object('banner_eventbox') | ||||
|         banner_name_label = self.xml.get_object('banner_name_label') | ||||
|         self.disconnect_style_event(banner_name_label) | ||||
|         self.disconnect_style_event(self.banner_status_label) | ||||
|         if bgcolor: | ||||
|             color = Gdk.RGBA() | ||||
|             Gdk.RGBA.parse(color, bgcolor) | ||||
|             banner_eventbox.override_background_color(Gtk.StateType.NORMAL, | ||||
|                 color) | ||||
|             default_bg = False | ||||
|         else: | ||||
|             default_bg = True | ||||
|         if textcolor: | ||||
|             color = Gdk.RGBA() | ||||
|             Gdk.RGBA.parse(color, textcolor) | ||||
|             banner_name_label.override_color(Gtk.StateType.NORMAL, | ||||
|                 color) | ||||
|             self.banner_status_label.override_color( | ||||
|                 Gtk.StateType.NORMAL, color) | ||||
|             default_fg = False | ||||
|         else: | ||||
|             default_fg = True | ||||
|         if default_bg or default_fg: | ||||
|             self._on_style_set_event(banner_name_label, None, default_fg, | ||||
|                     default_bg) | ||||
|             if self.banner_status_label.get_realized(): | ||||
|                 # Widget is realized | ||||
|                 self._on_style_set_event(self.banner_status_label, None, default_fg, | ||||
|                         default_bg) | ||||
| 
 | ||||
|     def disconnect_style_event(self, widget): | ||||
|         # Try to find the event_id | ||||
|         for id_ in self.handlers.keys(): | ||||
|             if self.handlers[id_] == widget: | ||||
|                 widget.disconnect(id_) | ||||
|                 del self.handlers[id_] | ||||
|                 break | ||||
| 
 | ||||
|     def connect_style_event(self, widget, set_fg=False, set_bg=False): | ||||
|         self.disconnect_style_event(widget) | ||||
|         id_ = widget.connect('style-set', self._on_style_set_event, set_fg, | ||||
|             set_bg) | ||||
|         self.handlers[id_] = widget | ||||
| 
 | ||||
|     def _on_style_set_event(self, widget, style, *opts): | ||||
|         """ | ||||
|         Set style of widget from style class *.Frame.Eventbox | ||||
|                 opts[0] == True -> set fg color | ||||
|                 opts[1] == True -> set bg color | ||||
|         """ | ||||
|         banner_eventbox = self.xml.get_object('banner_eventbox') | ||||
|         self.disconnect_style_event(widget) | ||||
|         context = widget.get_style_context() | ||||
|         if opts[1]: | ||||
|             bg_color = context.get_background_color(Gtk.StateFlags.SELECTED) | ||||
|             banner_eventbox.override_background_color(Gtk.StateType.NORMAL, bg_color) | ||||
|         if opts[0]: | ||||
|             fg_color = context.get_color(Gtk.StateFlags.SELECTED) | ||||
|             widget.override_color(Gtk.StateType.NORMAL, fg_color) | ||||
|         self.connect_style_event(widget, opts[0], opts[1]) | ||||
| 
 | ||||
|     def _conv_textview_key_press_event(self, widget, event): | ||||
|         # translate any layout to latin_layout | ||||
|         valid, entries = self.keymap.get_entries_for_keyval(event.keyval) | ||||
|  | @ -1226,20 +1154,15 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): | |||
|         msg_type == 'sent' and not self.correcting and (not \ | ||||
|         history[pos - 1].startswith('/') or history[pos - 1].startswith('/me')): | ||||
|             self.correcting = True | ||||
|             context = self.msg_textview.get_style_context() | ||||
|             state = Gtk.StateFlags.NORMAL | ||||
|             self.old_message_tv_color = context.get_background_color(state) | ||||
|             color = Gdk.RGBA() | ||||
|             Gdk.RGBA.parse(color, 'PaleGoldenrod') | ||||
|             self.msg_textview.override_background_color(Gtk.StateType.NORMAL, | ||||
|                 color) | ||||
|             gtkgui_helpers.add_css_class( | ||||
|                 self.msg_textview, 'msgcorrectingcolor') | ||||
|             message = history[pos - 1] | ||||
|             msg_buf.set_text(message) | ||||
|             return | ||||
|         if self.correcting: | ||||
|             # We were previously correcting | ||||
|             self.msg_textview.override_background_color(Gtk.StateType.NORMAL, | ||||
|                 self.old_message_tv_color) | ||||
|             gtkgui_helpers.remove_css_class( | ||||
|                 self.msg_textview, 'msgcorrectingcolor') | ||||
|         self.correcting = False | ||||
|         pos += -1 if direction == 'up' else +1 | ||||
|         if pos == -1: | ||||
|  |  | |||
|  | @ -468,6 +468,7 @@ class Config: | |||
|                     'bannerbgcolor': [ opt_color, '', '', True ], | ||||
|                     'bannerfont': [ opt_str, '', '', True ], | ||||
|                     'bannerfontattrs': [ opt_str, 'B', '', True ], | ||||
|                     'msgcorrectingcolor': [opt_color, '#eee8aa'], | ||||
| 
 | ||||
|                     # http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html | ||||
|                     'state_inactive_color': [ opt_color, 'grey62' ], | ||||
|  |  | |||
|  | @ -750,6 +750,7 @@ class PreferencesWindow: | |||
|         # begin repainting themed widgets throughout | ||||
|         gajim.interface.roster.repaint_themed_widgets() | ||||
|         gajim.interface.roster.change_roster_style(None) | ||||
|         gtkgui_helpers.load_css() | ||||
| 
 | ||||
|     def update_theme_list(self): | ||||
|         theme_combobox = self.xml.get_object('theme_combobox') | ||||
|  |  | |||
							
								
								
									
										58
									
								
								src/disco.py
									
										
									
									
									
								
							
							
						
						
									
										58
									
								
								src/disco.py
									
										
									
									
									
								
							|  | @ -561,7 +561,6 @@ _('Without a connection, you can not browse available services')) | |||
|         self.banner_eventbox = self.xml.get_object('banner_agent_eventbox') | ||||
|         self.style_event_id = 0 | ||||
|         self.banner.realize() | ||||
|         self.paint_banner() | ||||
|         self.action_buttonbox = self.xml.get_object('action_buttonbox') | ||||
| 
 | ||||
|         # Address combobox | ||||
|  | @ -660,63 +659,6 @@ _('Without a connection, you can not browse available services')) | |||
|                 (markup, font.to_string(), text_after) | ||||
|         self.banner.set_markup(markup) | ||||
| 
 | ||||
|     def paint_banner(self): | ||||
|         """ | ||||
|         Repaint the banner with theme color | ||||
|         """ | ||||
|         theme = gajim.config.get('roster_theme') | ||||
|         bgcolor = gajim.config.get_per('themes', theme, 'bannerbgcolor') | ||||
|         textcolor = gajim.config.get_per('themes', theme, 'bannertextcolor') | ||||
|         self.disconnect_style_event() | ||||
|         if bgcolor: | ||||
|             color = Gdk.RGBA() | ||||
|             Gdk.RGBA.parse(color, bgcolor) | ||||
|             self.banner_eventbox.override_background_color(Gtk.StateType.NORMAL, | ||||
|                 color) | ||||
|             default_bg = False | ||||
|         else: | ||||
|             default_bg = True | ||||
| 
 | ||||
|         if textcolor: | ||||
|             color = Gdk.RGBA() | ||||
|             Gdk.RGBA.parse(color, textcolor) | ||||
|             self.banner.override_color(Gtk.StateType.NORMAL, color) | ||||
|             default_fg = False | ||||
|         else: | ||||
|             default_fg = True | ||||
|         if default_fg or default_bg: | ||||
|             self._on_style_set_event(self.banner, None, default_fg, default_bg) | ||||
|         if self.browser: | ||||
|             self.browser.update_theme() | ||||
| 
 | ||||
|     def disconnect_style_event(self): | ||||
|         if self.style_event_id: | ||||
|             self.banner.disconnect(self.style_event_id) | ||||
|             self.style_event_id = 0 | ||||
| 
 | ||||
|     def connect_style_event(self, set_fg = False, set_bg = False): | ||||
|         self.disconnect_style_event() | ||||
|         self.style_event_id = self.banner.connect('style-set', | ||||
|                                 self._on_style_set_event, set_fg, set_bg) | ||||
| 
 | ||||
|     def _on_style_set_event(self, widget, style, *opts): | ||||
|         """ | ||||
|         Set style of widget from style class *.Frame.Eventbox | ||||
|                 opts[0] == True -> set fg color | ||||
|                 opts[1] == True -> set bg color | ||||
|         """ | ||||
|         self.disconnect_style_event() | ||||
|         context = widget.get_style_context() | ||||
|         if opts[1]: | ||||
|             bg_color = context.get_background_color(Gtk.StateFlags.SELECTED) | ||||
|             self.banner_eventbox.override_background_color(Gtk.StateType.NORMAL, | ||||
|                 bg_color) | ||||
|         if opts[0]: | ||||
|             fg_color = context.get_color(Gtk.StateFlags.SELECTED) | ||||
|             self.banner.override_color(Gtk.StateType.NORMAL, fg_color) | ||||
|         self.banner.ensure_style() | ||||
|         self.connect_style_event(opts[0], opts[1]) | ||||
| 
 | ||||
|     def destroy(self, chain = False): | ||||
|         """ | ||||
|         Close the browser. This can optionally close its children and propagate | ||||
|  |  | |||
|  | @ -1996,8 +1996,8 @@ class GroupchatControl(ChatControlBase): | |||
|                 self.last_sent_msg = msg | ||||
|                 if self.correcting: | ||||
|                     self.correcting = False | ||||
|                     self.msg_textview.override_background_color( | ||||
|                         Gtk.StateType.NORMAL, self.old_message_tv_color) | ||||
|                     gtkgui_helpers.remove_css_class( | ||||
|                         self.msg_textview, 'msgcorrectingcolor') | ||||
| 
 | ||||
|             if self.correcting and self.last_sent_msg: | ||||
|                 correction_msg = self.last_sent_msg | ||||
|  |  | |||
|  | @ -1109,7 +1109,13 @@ def load_css(): | |||
| 
 | ||||
| def convert_config_to_css(): | ||||
|     css = '' | ||||
|     themed_widgets = {} | ||||
|     themed_widgets = { | ||||
|         'ChatControl-BannerEventBox': ('bannerbgcolor', 'background'), | ||||
|         'ChatControl-BannerNameLabel': ('bannertextcolor', 'color'), | ||||
|         'ChatControl-BannerLabel': ('bannertextcolor', 'color'), | ||||
|         'Discovery-BannerEventBox': ('bannerbgcolor', 'background'), | ||||
|         'Discovery-BannerLabel': ('bannertextcolor', 'color')} | ||||
| 
 | ||||
|     classes = {'state_composing_color': ('', 'color'), | ||||
|                'state_inactive_color': ('', 'color'), | ||||
|                'state_gone_color': ('', 'color'), | ||||
|  | @ -1133,3 +1139,14 @@ def convert_config_to_css(): | |||
|                 cls=key, node=node, attr=attr, color=value) | ||||
| 
 | ||||
|     return css | ||||
| 
 | ||||
| def add_css_class(widget, class_name): | ||||
|     style = widget.get_style_context() | ||||
|     for css_cls in style.list_classes(): | ||||
|         if css_cls.startswith('theme_'): | ||||
|             style.remove_class(css_cls) | ||||
|     style.add_class('theme_' + class_name) | ||||
| 
 | ||||
| def remove_css_class(widget, class_name): | ||||
|     style = widget.get_style_context() | ||||
|     style.remove_class('theme_' + class_name) | ||||
|  |  | |||
|  | @ -4800,8 +4800,6 @@ class RosterWindow: | |||
|         for win in gajim.interface.msg_win_mgr.windows(): | ||||
|             win.repaint_themed_widgets() | ||||
|         for account in gajim.connections: | ||||
|             for addr in gajim.interface.instances[account]['disco']: | ||||
|                 gajim.interface.instances[account]['disco'][addr].paint_banner() | ||||
|             for ctrl in list(gajim.interface.minimized_controls[account].values()): | ||||
|                 ctrl.repaint_themed_widgets() | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue