mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Add markup support to error msg.
This commit is contained in:
parent
f0b4b6519d
commit
1a188af2e9
7 changed files with 24 additions and 17 deletions
|
@ -3,6 +3,8 @@
|
|||
- Auto-wrap text in message dialog.
|
||||
- Fix ellipsiziing in entry box.
|
||||
- Fix crash on empty list with custom input (#175).
|
||||
New feature:
|
||||
- Markup support error message.
|
||||
|
||||
0.15.5:
|
||||
Bug fixes:
|
||||
|
|
|
@ -233,10 +233,11 @@ extern Settings config;
|
|||
|
||||
/**
|
||||
* @param msg The error message to show.
|
||||
* @param markup The error message uses pango markup.
|
||||
*
|
||||
* The error message to show.
|
||||
*/
|
||||
void error_dialog ( const char *msg );
|
||||
void error_dialog ( const char *msg, int markup );
|
||||
|
||||
/**
|
||||
* Structure defining a switcher.
|
||||
|
|
|
@ -25,13 +25,13 @@ typedef struct
|
|||
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_LEFT = 1 << 16,
|
||||
TB_RIGHT = 1 << 17,
|
||||
TB_CENTER = 1 << 18,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
} TextboxFlags;
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ static inline void execsh ( const char *cmd, int run_in_term )
|
|||
if ( error != NULL ) {
|
||||
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd,
|
||||
error->message );
|
||||
error_dialog ( msg );
|
||||
error_dialog ( msg, FALSE );
|
||||
g_free ( msg );
|
||||
// print error.
|
||||
g_error_free ( error );
|
||||
|
|
|
@ -64,7 +64,7 @@ static inline int execshssh ( const char *host )
|
|||
if ( error != NULL ) {
|
||||
char *msg = g_strdup_printf ( "Failed to execute: 'ssh %s'\nError: '%s'", host,
|
||||
error->message );
|
||||
error_dialog ( msg );
|
||||
error_dialog ( msg, FALSE );
|
||||
g_free ( msg );
|
||||
// print error.
|
||||
g_error_free ( error );
|
||||
|
|
|
@ -86,7 +86,7 @@ void i3_support_focus_window ( Window id )
|
|||
t = send ( s, &head, sizeof ( i3_ipc_header_t ), 0 );
|
||||
if ( t == -1 ) {
|
||||
char *msg = g_strdup_printf ( "Failed to send message header to i3: %s\n", strerror ( errno ) );
|
||||
error_dialog ( msg );
|
||||
error_dialog ( msg, FALSE );
|
||||
g_free ( msg );
|
||||
close ( s );
|
||||
return;
|
||||
|
@ -95,7 +95,7 @@ void i3_support_focus_window ( Window id )
|
|||
t = send ( s, command, strlen ( command ), 0 );
|
||||
if ( t == -1 ) {
|
||||
char *msg = g_strdup_printf ( "Failed to send message body to i3: %s\n", strerror ( errno ) );
|
||||
error_dialog ( msg );
|
||||
error_dialog ( msg, FALSE );
|
||||
g_free ( msg );
|
||||
close ( s );
|
||||
return;
|
||||
|
|
|
@ -1371,7 +1371,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
|||
return retv;
|
||||
}
|
||||
|
||||
void error_dialog ( const char *msg )
|
||||
void error_dialog ( const char *msg, int markup )
|
||||
{
|
||||
MenuState state = {
|
||||
.selected_line = NULL,
|
||||
|
@ -1409,7 +1409,7 @@ void error_dialog ( const char *msg )
|
|||
menu_calculate_window_and_element_width ( &state, &mon );
|
||||
state.max_elements = 0;
|
||||
|
||||
state.text = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT,
|
||||
state.text = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT + ( ( markup ) ? TB_MARKUP : 0 ),
|
||||
( config.padding ),
|
||||
( config.padding ),
|
||||
( state.w - ( 2 * ( config.padding ) ) ),
|
||||
|
@ -1741,7 +1741,7 @@ static void hup_action_handler ( int num )
|
|||
}
|
||||
}
|
||||
|
||||
static void show_error_message ( const char *msg )
|
||||
static void show_error_message ( const char *msg, int markup )
|
||||
{
|
||||
// Create pid file
|
||||
create_pid_file ( pidfile );
|
||||
|
@ -1749,7 +1749,7 @@ static void show_error_message ( const char *msg )
|
|||
// Request truecolor visual.
|
||||
create_visual_and_colormap ( display );
|
||||
textbox_setup ( &vinfo, map );
|
||||
error_dialog ( msg );
|
||||
error_dialog ( msg, markup );
|
||||
textbox_cleanup ( );
|
||||
if ( map != None ) {
|
||||
XFreeColormap ( display, map );
|
||||
|
@ -1861,7 +1861,11 @@ int main ( int argc, char *argv[] )
|
|||
|
||||
char *msg = NULL;
|
||||
if ( find_arg_str ( "-e", &( msg ) ) ) {
|
||||
show_error_message ( msg );
|
||||
int markup = FALSE;
|
||||
if ( find_arg ( "-markup" ) >= 0 ) {
|
||||
markup = TRUE;
|
||||
}
|
||||
show_error_message ( msg, markup );
|
||||
exit ( EXIT_SUCCESS );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue