Philipp Hörist pushed to branch master at gajim / gajim
Commits: c3ee820d by Daniel Brötzmann at 2020-04-12T08:35:46+02:00 Notifications: Improve Windows notification style
- - - - - ce40feff by Daniel Brötzmann at 2020-04-12T08:35:47+02:00 Config: Remove obsolete colors
- - - - -
5 changed files:
- gajim/common/config.py - gajim/data/gui/popup_notification_window.ui - gajim/data/style/default.css - gajim/data/style/gajim.css - gajim/gtk/notification.py
Changes:
===================================== gajim/common/config.py ===================================== @@ -90,15 +90,6 @@ class Config: 'allow_hide_roster': [opt_bool, False, _('Allow to hide the contact list window even if the notification area icon is not shown.'), False], 'iconset': [opt_str, DEFAULT_ICONSET, '', True], 'use_transports_iconsets': [opt_bool, True, '', True], - 'notif_signin_color': [opt_color, '#32CD32', _('Notification color for contacts signing in.')], # limegreen - 'notif_signout_color': [opt_color, '#FF0000', _('Notification color for contacts signing out.')], # red - 'notif_message_color': [opt_color, '#1E90FF', _('Notification color for new message notification.')], # dodgerblue - 'notif_ftrequest_color': [opt_color, '#F0E68C', _('Notification color for file transfer request.')], # khaki - 'notif_fterror_color': [opt_color, '#B22222', _('Notification color for file transfer errors.')], # firebrick - 'notif_ftcomplete_color': [opt_color, '#9ACD32', _('Notification color for stopped or completed file transfers.')], # yellowgreen - 'notif_invite_color': [opt_color, '#D2B48C', _('Notification color for group chat invitations.')], # tan1 - 'notif_status_color': [opt_color, '#D8BFD8', _('Notification background color for changed status.')], # thistle2 - 'notif_other_color': [opt_color, '#FFFFFF', _('Notification color for other dialogs.')], # white 'collapsed_rows': [opt_str, '', _('List of rows (accounts and groups) that are collapsed (space separated).'), True], 'roster_theme': [opt_str, _('default'), '', True], 'mergeaccounts': [opt_bool, False, '', True],
===================================== gajim/data/gui/popup_notification_window.ui ===================================== @@ -1,30 +1,44 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> +<!-- Generated with glade 3.22.2 --> <interface> - <requires lib="gtk+" version="3.12"/> + <requires lib="gtk+" version="3.20"/> <object class="GtkEventBox" id="eventbox"> - <property name="name">PopupNotificationEventBox</property> + <property name="name">NotificationPopup</property> <property name="visible">True</property> <property name="can_focus">False</property> <child> <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">4</property> <property name="spacing">6</property> <child> - <object class="GtkImage" id="image"> - <property name="width_request">68</property> - <property name="height_request">86</property> + <object class="GtkBox" id="color_bar"> + <property name="width_request">6</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">False</property> - <property name="fill">False</property> + <property name="fill">True</property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkImage" id="image"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_size">6</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> <child> <object class="GtkBox"> <property name="visible">True</property> @@ -36,11 +50,10 @@ <property name="can_focus">False</property> <child> <object class="GtkLabel" id="event_type_label"> + <property name="name">NotificationPopupTitle</property> <property name="width_request">196</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">Event Type</property> - <property name="use_markup">True</property> <property name="wrap">True</property> <property name="xalign">0</property> </object> @@ -68,7 +81,7 @@ </object> <packing> <property name="expand">False</property> - <property name="fill">False</property> + <property name="fill">True</property> <property name="position">1</property> </packing> </child> @@ -82,14 +95,14 @@ <child> <object class="GtkLabel" id="event_description_label"> <property name="width_request">218</property> - <property name="height_request">64</property> + <property name="height_request">50</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">Event desc</property> <property name="wrap">True</property> <property name="ellipsize">end</property> <property name="max_width_chars">30</property> <property name="xalign">0</property> + <property name="yalign">0</property> </object> <packing> <property name="expand">False</property> @@ -101,7 +114,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object>
===================================== gajim/data/style/default.css ===================================== @@ -50,3 +50,30 @@ .gajim-search-highlight { color: rgb(170, 220, 220) } +.gajim-notify-message { + color: rgb(30, 144, 255); +} +.gajim-notify-signin { + color: rgb(68, 134, 38); +} +.gajim-notify-signout { + color: rgb(134, 22, 22); +} +.gajim-notify-status { + color: rgb(170, 170, 170); +} +.gajim-notify-invite { + color: rgb(224, 145, 42); +} +.gajim-notify-ft-request { + color: rgb(240, 230, 140); +} +.gajim-notify-ft-error { + color: rgb(226, 33, 33); +} +.gajim-notify-ft-complete { + color: rgb(139, 185, 48); +} +.gajim-notify-other { + color: rgb(255, 255, 255); +}
===================================== gajim/data/style/gajim.css ===================================== @@ -280,3 +280,23 @@ button.flat.link { padding: 0; border: 0; }
.assistant-grid { padding: 18px; margin: 6px;} .assistant-grid > box stack { padding: 18px; } + +/* Windows notification */ +#NotificationPopup { + background-color: #333333; + padding: 4px; +} +#NotificationPopup label { + color: #FFF; +} +#NotificationPopup button { + border-width: 0; + background-image: none; + background-color: inherit; + box-shadow: none; + text-shadow: none; + -gtk-icon-shadow: none; +} +#NotificationPopupTitle { + font-weight: bold; +}
===================================== gajim/gtk/notification.py ===================================== @@ -36,6 +36,7 @@ from gajim import gtkgui_helpers from gajim.common import app from gajim.common import helpers from gajim.common import ged +from gajim.common.const import StyleAttr from gajim.common.i18n import _ from gajim.common.nec import EventHelper
@@ -252,10 +253,8 @@ class PopupNotification(Gtk.Window): self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION) self.set_focus_on_map(False) self.set_accept_focus(False) - self.set_name('NotificationPopup') self.set_skip_taskbar_hint(True) self.set_decorated(False) - self.set_size_request(312, 95)
self._timeout_id = None self.account = account @@ -265,57 +264,53 @@ class PopupNotification(Gtk.Window): self._ui = get_builder('popup_notification_window.ui') self.add(self._ui.eventbox)
- if not text: - text = app.get_name_from_jid(account, jid) # default value of text - if not title: - title = '' - - self._ui.event_type_label.set_markup( - '<span foreground="black" weight="bold">%s</span>' % - GLib.markup_escape_text(title)) - - css = '#NotificationPopup {background-color: black }' - gtkgui_helpers.add_css_to_widget(self, css) - if event_type == _('Contact Signed In'): - bg_color = app.config.get('notif_signin_color') + bg_color = app.css_config.get_value('.gajim-notify-signin', + StyleAttr.COLOR) elif event_type == _('Contact Signed Out'): - bg_color = app.config.get('notif_signout_color') + bg_color = app.css_config.get_value('.gajim-notify-signout', + StyleAttr.COLOR) elif event_type in (_('New Message'), - _('New Private Message'), _('New E-mail')): - bg_color = app.config.get('notif_message_color') + _('New Private Message'), + _('New E-mail')): + bg_color = app.css_config.get_value('.gajim-notify-message', + StyleAttr.COLOR) elif event_type == _('File Transfer Request'): - bg_color = app.config.get('notif_ftrequest_color') + bg_color = app.css_config.get_value('.gajim-notify-ft-request', + StyleAttr.COLOR) elif event_type == _('File Transfer Error'): - bg_color = app.config.get('notif_fterror_color') + bg_color = app.css_config.get_value('.gajim-notify-ft-error', + StyleAttr.COLOR) elif event_type in (_('File Transfer Completed'), _('File Transfer Stopped')): - bg_color = app.config.get('notif_ftcomplete_color') + bg_color = app.css_config.get_value('.gajim-notify-ft-complete', + StyleAttr.COLOR) elif event_type == _('Group Chat Invitation'): - bg_color = app.config.get('notif_invite_color') + bg_color = app.css_config.get_value('.gajim-notify-invite', + StyleAttr.COLOR) elif event_type == _('Contact Changed Status'): - 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') + bg_color = app.css_config.get_value('.gajim-notify-status', + StyleAttr.COLOR) + else: # Unknown event (shouldn't happen, but deal with it) + bg_color = app.css_config.get_value('.gajim-notify-other', + StyleAttr.COLOR) + + bar_class = ''' + .popup-bar { + background-color: %s + }''' % bg_color + gtkgui_helpers.add_css_to_widget(self._ui.color_bar, bar_class) + self._ui.color_bar.get_style_context().add_class('popup-bar')
- background_class = ''' - .popup-style { - border-image: none; - background-image: none; - background-color: %s }''' % bg_color - - gtkgui_helpers.add_css_to_widget(self._ui.eventbox, background_class) - self._ui.eventbox.get_style_context().add_class('popup-style') - - gtkgui_helpers.add_css_to_widget( - self._ui.close_button, background_class) - self._ui.close_button.get_style_context().add_class('popup-style') + if not title: + title = '' + self._ui.event_type_label.set_markup(title)
+ if not text: + text = app.get_name_from_jid(account, jid) # default value of text escaped_text = GLib.markup_escape_text(text) - self._ui.event_description_label.set_markup( - '<span foreground="black">%s</span>' % escaped_text) + self._ui.event_description_label.set_markup(escaped_text)
- # set the image self._ui.image.set_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
self.move(*self._get_window_pos())
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/07c1911115828c067df7156886bb678e...