mirror of
https://github.com/davatorium/rofi.git
synced 2025-07-31 21:59:25 -04: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.
|
- Auto-wrap text in message dialog.
|
||||||
- Fix ellipsiziing in entry box.
|
- Fix ellipsiziing in entry box.
|
||||||
- Fix crash on empty list with custom input (#175).
|
- Fix crash on empty list with custom input (#175).
|
||||||
|
New feature:
|
||||||
|
- Markup support error message.
|
||||||
|
|
||||||
0.15.5:
|
0.15.5:
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
|
@ -233,10 +233,11 @@ extern Settings config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param msg The error message to show.
|
* @param msg The error message to show.
|
||||||
|
* @param markup The error message uses pango markup.
|
||||||
*
|
*
|
||||||
* The error message to show.
|
* The error message to show.
|
||||||
*/
|
*/
|
||||||
void error_dialog ( const char *msg );
|
void error_dialog ( const char *msg, int markup );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structure defining a switcher.
|
* Structure defining a switcher.
|
||||||
|
|
|
@ -62,7 +62,7 @@ static inline void execsh ( const char *cmd, int run_in_term )
|
||||||
if ( error != NULL ) {
|
if ( error != NULL ) {
|
||||||
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd,
|
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd,
|
||||||
error->message );
|
error->message );
|
||||||
error_dialog ( msg );
|
error_dialog ( msg, FALSE );
|
||||||
g_free ( msg );
|
g_free ( msg );
|
||||||
// print error.
|
// print error.
|
||||||
g_error_free ( error );
|
g_error_free ( error );
|
||||||
|
|
|
@ -64,7 +64,7 @@ static inline int execshssh ( const char *host )
|
||||||
if ( error != NULL ) {
|
if ( error != NULL ) {
|
||||||
char *msg = g_strdup_printf ( "Failed to execute: 'ssh %s'\nError: '%s'", host,
|
char *msg = g_strdup_printf ( "Failed to execute: 'ssh %s'\nError: '%s'", host,
|
||||||
error->message );
|
error->message );
|
||||||
error_dialog ( msg );
|
error_dialog ( msg, FALSE );
|
||||||
g_free ( msg );
|
g_free ( msg );
|
||||||
// print error.
|
// print error.
|
||||||
g_error_free ( 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 );
|
t = send ( s, &head, sizeof ( i3_ipc_header_t ), 0 );
|
||||||
if ( t == -1 ) {
|
if ( t == -1 ) {
|
||||||
char *msg = g_strdup_printf ( "Failed to send message header to i3: %s\n", strerror ( errno ) );
|
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 );
|
g_free ( msg );
|
||||||
close ( s );
|
close ( s );
|
||||||
return;
|
return;
|
||||||
|
@ -95,7 +95,7 @@ void i3_support_focus_window ( Window id )
|
||||||
t = send ( s, command, strlen ( command ), 0 );
|
t = send ( s, command, strlen ( command ), 0 );
|
||||||
if ( t == -1 ) {
|
if ( t == -1 ) {
|
||||||
char *msg = g_strdup_printf ( "Failed to send message body to i3: %s\n", strerror ( errno ) );
|
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 );
|
g_free ( msg );
|
||||||
close ( s );
|
close ( s );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1371,7 +1371,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void error_dialog ( const char *msg )
|
void error_dialog ( const char *msg, int markup )
|
||||||
{
|
{
|
||||||
MenuState state = {
|
MenuState state = {
|
||||||
.selected_line = NULL,
|
.selected_line = NULL,
|
||||||
|
@ -1409,7 +1409,7 @@ void error_dialog ( const char *msg )
|
||||||
menu_calculate_window_and_element_width ( &state, &mon );
|
menu_calculate_window_and_element_width ( &state, &mon );
|
||||||
state.max_elements = 0;
|
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 ),
|
||||||
( config.padding ),
|
( config.padding ),
|
||||||
( state.w - ( 2 * ( 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
|
||||||
create_pid_file ( pidfile );
|
create_pid_file ( pidfile );
|
||||||
|
@ -1749,7 +1749,7 @@ static void show_error_message ( const char *msg )
|
||||||
// Request truecolor visual.
|
// Request truecolor visual.
|
||||||
create_visual_and_colormap ( display );
|
create_visual_and_colormap ( display );
|
||||||
textbox_setup ( &vinfo, map );
|
textbox_setup ( &vinfo, map );
|
||||||
error_dialog ( msg );
|
error_dialog ( msg, markup );
|
||||||
textbox_cleanup ( );
|
textbox_cleanup ( );
|
||||||
if ( map != None ) {
|
if ( map != None ) {
|
||||||
XFreeColormap ( display, map );
|
XFreeColormap ( display, map );
|
||||||
|
@ -1861,7 +1861,11 @@ int main ( int argc, char *argv[] )
|
||||||
|
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
if ( find_arg_str ( "-e", &( msg ) ) ) {
|
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 );
|
exit ( EXIT_SUCCESS );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue