@@ -94,9 +94,10 @@ def error_dialog(primary: str, secondary: str) -> Gtk.ResponseType:
9494def modal_dialog (
9595 primary : str ,
9696 secondary : str ,
97- buttons : Union [Gtk .ButtonsType , Sequence [Tuple [str , int ]]],
97+ buttons : Union [Gtk .ButtonsType , Sequence [Tuple [str , int , Optional [str ]]]],
98+ * ,
9899 parent : Optional [Gtk .Window ] = None ,
99- messagetype : Gtk .MessageType = Gtk .MessageType .WARNING
100+ messagetype : Gtk .MessageType = Gtk .MessageType .WARNING ,
100101) -> Gtk .ResponseType :
101102 """A common message dialog handler for Meld
102103
@@ -106,7 +107,7 @@ def modal_dialog(
106107 Primary must be plain text. Secondary must be valid markup.
107108 """
108109
109- custom_buttons : Sequence [Tuple [str , int ]] = []
110+ custom_buttons : Sequence [Tuple [str , int , Optional [ str ] ]] = []
110111 if not isinstance (buttons , Gtk .ButtonsType ):
111112 custom_buttons , buttons = buttons , Gtk .ButtonsType .NONE
112113
@@ -116,11 +117,14 @@ def modal_dialog(
116117 destroy_with_parent = True ,
117118 message_type = messagetype ,
118119 buttons = buttons ,
119- text = primary )
120+ text = primary ,
121+ )
120122 dialog .format_secondary_markup (secondary )
121123
122- for label , response_id in custom_buttons :
123- dialog .add_button (label , response_id )
124+ for label , response_id , style_class in custom_buttons :
125+ button = dialog .add_button (label , response_id )
126+ if style_class :
127+ button .get_style_context ().add_class (style_class )
124128
125129 response = dialog .run ()
126130 dialog .destroy ()
0 commit comments