Philipp Hörist pushed to branch master at gajim / gajim

Commits:
bdf16c51 by Philipp Hörist at 2017-12-18T00:11:39+01:00
Replace deprecated override_background_color()

- - - - -
c18ef648 by Philipp Hörist at 2017-12-18T00:25:19+01:00
Replace deprecated get_background_color()

- - - - -


3 changed files:

- gajim/data/gui/popup_notification_window.ui
- gajim/dialogs.py
- gajim/gtkgui_helpers.py


Changes:

=====================================
gajim/data/gui/popup_notification_window.ui
=====================================
--- 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>


=====================================
gajim/dialogs.py
=====================================
--- 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))
 


=====================================
gajim/gtkgui_helpers.py
=====================================
--- a/gajim/gtkgui_helpers.py
+++ b/gajim/gtkgui_helpers.py
@@ -398,7 +398,8 @@ def get_fade_color(treeview, selected, focused):
             state = Gtk.StateFlags.ACTIVE
     else:
         state = Gtk.StateFlags.NORMAL
-    bg = context.get_background_color(state)
+
+    bg = context.get_property('background-color', state)
     fg = context.get_color(state)
 
     p = 0.3 # background
@@ -851,6 +852,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)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/f4a6b0299a324648e42e73545c2c484796671391...c18ef648e64182691b7448ea760f51de4f78b87e

---
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/f4a6b0299a324648e42e73545c2c484796671391...c18ef648e64182691b7448ea760f51de4f78b87e
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to