diff options
-rw-r--r-- | source/dialogs/combi.c | 7 | ||||
-rw-r--r-- | source/dialogs/dmenu.c | 7 | ||||
-rw-r--r-- | source/dialogs/drun.c | 17 | ||||
-rw-r--r-- | source/dialogs/run.c | 14 | ||||
-rw-r--r-- | source/dialogs/script.c | 8 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 19 | ||||
-rw-r--r-- | source/dialogs/window.c | 6 | ||||
-rw-r--r-- | source/helper.c | 18 | ||||
-rw-r--r-- | source/history.c | 18 | ||||
-rw-r--r-- | source/rofi.c | 67 | ||||
-rw-r--r-- | source/theme.c | 7 | ||||
-rw-r--r-- | source/view.c | 23 | ||||
-rw-r--r-- | source/widgets/box.c | 5 | ||||
-rw-r--r-- | source/widgets/container.c | 5 | ||||
-rw-r--r-- | source/x11-helper.c | 15 | ||||
-rw-r--r-- | source/xrmoptions.c | 8 |
16 files changed, 121 insertions, 123 deletions
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index f1e041c3..dd0cfb67 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -24,6 +24,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ + +#define G_LOG_DOMAIN "Dialogs.Combi" + #include <config.h> #include <stdlib.h> #include <stdio.h> @@ -85,7 +88,7 @@ static void combi_mode_parse_switchers ( Mode *sw ) } else { // Report error, don't continue. - fprintf ( stderr, "Invalid script switcher: %s\n", token ); + g_warning ( "Invalid script switcher: %s", token ); token = NULL; } } @@ -240,7 +243,7 @@ static char * combi_get_completion ( const Mode *sw, unsigned int index ) } } // Should never get here. - g_error ( "Failure, could not resolve sub-switcher." ); + g_assert_not_reached (); return NULL; } diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index be9b4be1..255fd720 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -25,6 +25,8 @@ * */ +#define G_LOG_DOMAIN "Dialogs.DMenu" + #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -47,9 +49,6 @@ #include "xrmoptions.h" #include "view.h" -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Dialogs.DMenu" - struct range_pair { unsigned int start; @@ -444,7 +443,7 @@ static int dmenu_mode_init ( Mode *sw ) char *estr = rofi_expand_path ( str ); fd = open ( str, O_RDONLY ); if ( fd < 0 ) { - char *msg = g_markup_printf_escaped ( "Failed to open file: <b>%s</b>:\n\t<i>%s</i>", estr, strerror ( errno ) ); + char *msg = g_markup_printf_escaped ( "Failed to open file: <b>%s</b>:\n\t<i>%s</i>", estr, g_strerror ( errno ) ); rofi_view_error_dialog ( msg, TRUE ); g_free ( msg ); g_free ( estr ); diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 062617c0..c16c6f2b 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -24,6 +24,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ + +#define G_LOG_DOMAIN "Dialogs.DRun" + #include <config.h> #ifdef ENABLE_DRUN #include <stdlib.h> @@ -48,8 +51,6 @@ #include "dialogs/drun.h" #define DRUN_CACHE_FILE "rofi2.druncache" -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Dialogs.DRun" #define GET_CAT_PARSE_TIME @@ -147,24 +148,24 @@ static void exec_cmd_entry ( DRunModeEntry *e ) GError *error = NULL; GRegex *reg = g_regex_new ( "%[a-zA-Z]", 0, 0, &error ); if ( error != NULL ) { - fprintf ( stderr, "Internal error, failed to create regex: %s.\n", error->message ); + g_warning ( "Internal error, failed to create regex: %s.", error->message ); g_error_free ( error ); return; } struct RegexEvalArg earg = { .e = e, .success = TRUE }; char *str = g_regex_replace_eval ( reg, e->exec, -1, 0, 0, drun_helper_eval_cb, &earg, &error ); if ( error != NULL ) { - fprintf ( stderr, "Internal error, failed replace field codes: %s.\n", error->message ); + g_warning ( "Internal error, failed replace field codes: %s.", error->message ); g_error_free ( error ); return; } g_regex_unref ( reg ); if ( earg.success == FALSE ) { - fprintf ( stderr, "Invalid field code in Exec line: %s.\n", e->exec );; + g_warning ( "Invalid field code in Exec line: %s.", e->exec );; return; } if ( str == NULL ) { - fprintf ( stderr, "Nothing to execute after processing: %s.\n", e->exec );; + g_warning ( "Nothing to execute after processing: %s.", e->exec );; return; } gchar *fp = rofi_expand_path ( g_strstrip ( str ) ); @@ -237,7 +238,7 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c // Name key is required. if ( !g_key_file_has_key ( kf, "Desktop Entry", "Name", NULL ) ) { - g_debug ( "Invalid DesktopFile: '%s', no 'Name' key present.\n", path ); + g_debug ( "Invalid DesktopFile: '%s', no 'Name' key present.", path ); g_key_file_free ( kf ); return FALSE; } @@ -258,7 +259,7 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c } // We need Exec, don't support DBusActivatable if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) { - g_debug ( "Unsupported DesktopFile: '%s', no 'Exec' key present.\n", path ); + g_debug ( "Unsupported DesktopFile: '%s', no 'Exec' key present.", path ); g_key_file_free ( kf ); return FALSE; } diff --git a/source/dialogs/run.c b/source/dialogs/run.c index b8534095..62e55150 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -29,6 +29,10 @@ * \ingroup RUNMode * @{ */ + +/** The log domain of this dialog. */ +#define G_LOG_DOMAIN "Dialogs.Run" + #include <config.h> #include <stdlib.h> #include <stdio.h> @@ -56,10 +60,6 @@ */ #define RUN_CACHE_FILE "rofi-3.runcache" -/** The log domain of this dialog. */ -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Dialogs.Run" - /** * The internal data structure holding the private data of the Run Mode. */ @@ -86,7 +86,7 @@ static void exec_cmd ( const char *cmd, int run_in_term ) gsize lf_cmd_size = 0; gchar *lf_cmd = g_locale_from_utf8 ( cmd, -1, NULL, &lf_cmd_size, &error ); if ( error != NULL ) { - fprintf ( stderr, "Failed to convert command to locale encoding: %s\n", error->message ); + g_warning ( "Failed to convert command to locale encoding: %s", error->message ); g_error_free ( error ); return; } @@ -188,8 +188,8 @@ static char ** get_apps_external ( char **retv, unsigned int *length, unsigned i free ( buffer ); } if ( fclose ( inp ) != 0 ) { - fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", - strerror ( errno ) ); + g_warning ( "Failed to close stdout off executor script: '%s'", + g_strerror ( errno ) ); } } } diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 72594a67..52cc1a03 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -25,6 +25,8 @@ * */ +#define G_LOG_DOMAIN "Dialogs.Script" + #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -66,8 +68,8 @@ static char **get_script_output ( const char *command, unsigned int *length ) free ( buffer ); } if ( fclose ( inp ) != 0 ) { - fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", - strerror ( errno ) ); + g_warning ( "Failed to close stdout off executor script: '%s'", + g_strerror ( errno ) ); } } } @@ -201,7 +203,7 @@ Mode *script_switcher_parse_setup ( const char *str ) return sw; } - fprintf ( stderr, "The script command '%s' has %u options, but needs 2: <name>:<script>.\n", str, index ); + g_warning ( "The script command '%s' has %u options, but needs 2: <name>:<script>.", str, index ); script_switcher_free ( sw ); return NULL; } diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index 0dc2d9a7..0bc277fb 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -29,6 +29,12 @@ * \ingroup SSHMode * @{ */ + +/** + * Log domain for the ssh modi. + */ +#define G_LOG_DOMAIN "Dialogs.Ssh" + #include <config.h> #include <glib.h> #include <stdlib.h> @@ -51,13 +57,6 @@ #include "dialogs/ssh.h" /** - * Log domain for the ssh modi. - */ - -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Dialogs.Ssh" - -/** * Name of the history file where previously choosen hosts are stored. */ #define SSH_CACHE_FILE "rofi-2.sshcache" @@ -181,7 +180,7 @@ static char **read_known_hosts_file ( char ** retv, unsigned int *length ) free ( buffer ); } if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close hosts file: '%s'\n", strerror ( errno ) ); + g_warning ( "Failed to close hosts file: '%s'", g_strerror ( errno ) ); } } @@ -256,7 +255,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length ) free ( buffer ); } if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close hosts file: '%s'\n", strerror ( errno ) ); + g_warning ( "Failed to close hosts file: '%s'", g_strerror ( errno ) ); } } @@ -357,7 +356,7 @@ static void parse_ssh_config_file ( const char *filename, char ***retv, unsigned } if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close ssh configuration file: '%s'\n", strerror ( errno ) ); + g_warning ( "Failed to close ssh configuration file: '%s'", g_strerror ( errno ) ); } } } diff --git a/source/dialogs/window.c b/source/dialogs/window.c index 9d65aeb4..2ed4bad4 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -24,6 +24,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ + +#define G_LOG_DOMAIN "Dialogs.Window" + #include <config.h> #ifdef WINDOW_MODE @@ -56,9 +59,6 @@ #define CLIENTSTATE 10 #define CLIENTWINDOWTYPE 10 -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Dialogs.Window" - // a manageable window typedef struct { diff --git a/source/helper.c b/source/helper.c index 7e85dea7..8d70c422 100644 --- a/source/helper.c +++ b/source/helper.c @@ -25,6 +25,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ + +#define G_LOG_DOMAIN "Helper" + #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -51,9 +54,6 @@ #include "rofi.h" #include "view.h" -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Helper" - /** * Textual description of positioning rofi. */ @@ -383,7 +383,7 @@ char helper_parse_char ( const char *arg ) if ( len > 2 && arg[0] == '\\' && arg[1] == 'x' ) { return (char) strtol ( &arg[2], NULL, 16 ); } - fprintf ( stderr, "Failed to parse character string: \"%s\"\n", arg ); + g_warning ( "Failed to parse character string: \"%s\"", arg ); // for now default to newline. return '\n'; } @@ -491,22 +491,22 @@ int create_pid_file ( const char *pidfile ) int fd = g_open ( pidfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR ); if ( fd < 0 ) { - fprintf ( stderr, "Failed to create pid file: '%s'.\n", pidfile ); + g_warning ( "Failed to create pid file: '%s'.", pidfile ); return -1; } // Set it to close the File Descriptor on exit. int flags = fcntl ( fd, F_GETFD, NULL ); flags = flags | FD_CLOEXEC; if ( fcntl ( fd, F_SETFD, flags, NULL ) < 0 ) { - fprintf ( stderr, "Failed to set CLOEXEC on pidfile.\n" ); + g_warning ( "Failed to set CLOEXEC on pidfile." ); remove_pid_file ( fd ); return -1; } // Try to get exclusive write lock on FD int retv = flock ( fd, LOCK_EX | LOCK_NB ); if ( retv != 0 ) { - fprintf ( stderr, "Failed to set lock on pidfile: Rofi already running?\n" ); - fprintf ( stderr, "Got error: %d %s\n", retv, strerror ( errno ) ); + g_warning ( "Failed to set lock on pidfile: Rofi already running?" ); + g_warning ( "Got error: %d %s", retv, g_strerror ( errno ) ); remove_pid_file ( fd ); return -1; } @@ -526,7 +526,7 @@ void remove_pid_file ( int fd ) { if ( fd >= 0 ) { if ( close ( fd ) ) { - fprintf ( stderr, "Failed to close pidfile: '%s'\n", strerror ( errno ) ); + g_warning ( "Failed to close pidfile: '%s'", g_strerror ( errno ) ); } } } diff --git a/source/history.c b/source/history.c index 25cfcb00..f9e6422c 100644 --- a/source/history.c +++ b/source/history.c @@ -145,7 +145,7 @@ void history_set ( const char *filename, const char *entry ) list = __history_get_element_list ( fd, &length ); // Close file, if fails let user know on stderr. if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to close history file: %s", g_strerror ( errno ) ); } } // Look if the entry exists. @@ -178,14 +178,14 @@ void history_set ( const char *filename, const char *entry ) fd = fopen ( filename, "w" ); if ( fd == NULL ) { - fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to open file: %s", g_strerror ( errno ) ); } else { // Write list. __history_write_element_list ( fd, list, length ); // Close file, if fails let user know on stderr. if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to close history file: %s", g_strerror ( errno ) ); } } // Free the list. @@ -208,7 +208,7 @@ void history_remove ( const char *filename, const char *entry ) // Open file for reading and writing. FILE *fd = g_fopen ( filename, "r" ); if ( fd == NULL ) { - fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to open file: %s", g_strerror ( errno ) ); return; } // Get list. @@ -216,7 +216,7 @@ void history_remove ( const char *filename, const char *entry ) // Close file, if fails let user know on stderr. if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to close history file: %s", g_strerror ( errno ) ); } // Find entry. for ( unsigned int iter = 0; !found && iter < length; iter++ ) { @@ -244,11 +244,11 @@ void history_remove ( const char *filename, const char *entry ) __history_write_element_list ( fd, list, length ); // Close file, if fails let user know on stderr. if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to close history file: %s", g_strerror ( errno ) ); } } else{ - fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to open file: %s", g_strerror ( errno ) ); } } @@ -277,7 +277,7 @@ char ** history_get_list ( const char *filename, unsigned int *length ) // File that does not exists is not an error, so ignore it. // Everything else? panic. if ( errno != ENOENT ) { - fprintf ( stderr, "Failed to open file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to open file: %s", g_strerror ( errno ) ); } return NULL; } @@ -298,7 +298,7 @@ char ** history_get_list ( const char *filename, unsigned int *length ) // Close file, if fails let user know on stderr. if ( fclose ( fd ) != 0 ) { - fprintf ( stderr, "Failed to close history file: %s\n", strerror ( errno ) ); + g_warning ( "Failed to close history file: %s", g_strerror ( errno ) ); } return retv; } diff --git a/source/rofi.c b/source/rofi.c index 832ff76c..7162e973 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -25,6 +25,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#define G_LOG_DOMAIN "Rofi" + #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -75,9 +77,6 @@ // TODO: move this check to mode.c #include "mode-private.h" -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Rofi" - // Pidfile. char *pidfile = NULL; const char *cache_dir = NULL; @@ -310,7 +309,7 @@ static void help ( G_GNUC_UNUSED int argc, char **argv ) break; } } - fprintf ( stderr, " * %s%s%s%s\n", + printf ( " * %s%s%s%s\n", active?"+":"" , is_term ? (active?color_green:color_red) : "", available_modi[i]->name, @@ -367,9 +366,9 @@ static void help_print_disabled_mode ( const char *mode ) int is_term = isatty ( fileno ( stdout ) ); // Only output to terminal if ( is_term ) { - fprintf ( stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n", + g_warning ( "Mode %s%s%s is not enabled. I have enabled it for now.", color_red, mode, color_reset ); - fprintf ( stderr, "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.\n", + g_warning ( "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.", color_red, mode, color_reset, color_green, config.modi, color_reset, color_red, mode, color_reset @@ -533,7 +532,7 @@ static void rofi_collect_modi_dir ( const char *base_dir ) Mode *m = NULL; if ( g_module_symbol ( mod, "mode", (gpointer *) &m ) ) { if ( m->abi_version != ABI_VERSION ) { - fprintf ( stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION ); + g_warning ( "ABI version of plugin does not match: %08X expecting: %08X", m->abi_version, ABI_VERSION ); g_module_close ( mod ); } else { @@ -544,7 +543,7 @@ static void rofi_collect_modi_dir ( const char *base_dir ) } } else { - fprintf ( stderr, "Symbol 'mode' not found in module: %s\n", fn ); + g_warning ( "Symbol 'mode' not found in module: %s", fn ); g_module_close ( mod ); } } @@ -622,7 +621,7 @@ static int add_mode ( const char * token ) } else { // Report error, don't continue. - fprintf ( stderr, "Invalid script mode: %s\n", token ); + g_warning ( "Invalid script mode: %s", token ); } } return ( index == num_modi ) ? -1 : (int) index; @@ -664,7 +663,7 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN if ( ev == NULL ) { int status = xcb_connection_has_error ( xcb->connection ); if(status > 0) { - fprintf ( stderr, "The XCB connection to X server had a fatal error: %d\n", status ); + g_warning ( "The XCB connection to X server had a fatal error: %d", status ); g_main_loop_quit ( main_loop ); return G_SOURCE_REMOVE; } else { @@ -732,7 +731,7 @@ static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xc static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, xcb_connection_t *xdisplay ) { if ( error_trap_depth == 0 ) { - fprintf ( stderr, "Error trap underflow!\n" ); + g_warning ( "Error trap underflow!" ); exit ( EXIT_FAILURE ); } @@ -747,7 +746,7 @@ static gboolean lazy_grab_pointer ( G_GNUC_UNUSED gpointer data ) { // After 5 sec. if ( lazy_grab_retry_count_pt > ( 5 * 1000 ) ) { - fprintf ( stderr, "Failed to grab pointer after %u times. Giving up.\n", lazy_grab_retry_count_pt ); + g_warning ( "Failed to grab pointer after %u times. Giving up.", lazy_grab_retry_count_pt ); return G_SOURCE_REMOVE; } if ( take_pointer ( xcb_stuff_get_root_window ( xcb ), 0 ) ) { @@ -760,7 +759,7 @@ static gboolean lazy_grab_keyboard ( G_GNUC_UNUSED gpointer data ) { // After 5 sec. if ( lazy_grab_retry_count_kb > ( 5 * 1000 ) ) { - fprintf ( stderr, "Failed to grab keyboard after %u times. Giving up.\n", lazy_grab_retry_count_kb ); + g_warning ( "Failed to grab keyboard after %u times. Giving up.", lazy_grab_retry_count_kb ); g_main_loop_quit ( main_loop ); return G_SOURCE_REMOVE; } @@ -792,12 +791,12 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) if ( ( window_flags & MENU_NORMAL_WINDOW ) == 0 ) { if ( find_arg ( "-no-lazy-grab" ) >= 0 ) { if ( !take_keyboard ( xcb_stuff_get_root_window ( xcb ), 500 ) ) { - fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); + g_warning ( "Failed to grab keyboard, even after %d uS.", 500 * 1000 ); g_main_loop_quit ( main_loop ); return G_SOURCE_REMOVE; } if ( !take_pointer ( xcb_stuff_get_root_window ( xcb ), 100 ) ) { - fprintf ( stderr, "Failed to grab mouse pointer, even after %d uS.", 100 * 1000 ); + g_warning ( "Failed to grab mouse pointer, even after %d uS.", 100 * 1000 ); } } else { @@ -874,7 +873,7 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data ) run_switcher ( index ); } else { - fprintf ( stderr, "The %s mode has not been enabled\n", sname ); + g_warning ( "The %s mode has not been enabled", sname ); g_main_loop_quit ( main_loop ); return G_SOURCE_REMOVE; } @@ -908,9 +907,9 @@ int main ( int argc, char *argv[] ) // Version if ( find_arg ( "-v" ) >= 0 || find_arg ( "-version" ) >= 0 ) { #ifdef GIT_VERSION - fprintf ( stdout, "Version: "GIT_VERSION "\n" ); + g_print ( "Version: "GIT_VERSION "\n" ); #else - fprintf ( stdout, "Version: "VERSION "\n" ); + g_print ( "Version: "VERSION "\n" ); #endif return EXIT_SUCCESS; } @@ -935,7 +934,7 @@ int main ( int argc, char *argv[] ) cache_dir = g_get_user_cache_dir (); if ( g_mkdir_with_parents ( cache_dir, 0700 ) < 0 ) { - fprintf ( stderr, "Failed to create cache directory: %s\n", strerror ( errno ) ); + g_warning ( "Failed to create cache directory: %s", g_strerror ( errno ) ); return EXIT_FAILURE; } @@ -943,7 +942,7 @@ int main ( int argc, char *argv[] ) const char *path = g_get_user_runtime_dir (); if ( path ) { if ( g_mkdir_with_parents ( path, 0700 ) < 0 ) { - g_warning ( "Failed to create user runtime directory: %s with error: %s\n", path, strerror ( errno ) ); + g_warning ( "Failed to create user runtime directory: %s with error: %s", path, g_strerror ( errno ) ); pidfile = g_build_filename ( g_get_home_dir (), ".rofi.pid", NULL ); } else { @@ -966,7 +965,7 @@ int main ( int argc, char *argv[] ) TICK (); if ( setlocale ( LC_ALL, "" ) == NULL ) { - fprintf ( stderr, "Failed to set locale.\n" ); + g_warning ( "Failed to set locale." ); cleanup (); return EXIT_FAILURE; } @@ -978,7 +977,7 @@ int main ( int argc, char *argv[] ) xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr ); if ( xcb_connection_has_error ( xcb->connection ) ) { - fprintf ( stderr, "Failed to open display: %s", display_str ); + g_warning( "Failed to open display: %s", display_str ); cleanup (); return EXIT_FAILURE; } @@ -996,7 +995,7 @@ int main ( int argc, char *argv[] ) xcb_generic_error_t *errors = NULL; xcb_ewmh_init_atoms_replies ( &xcb->ewmh, ac, &errors ); if ( errors ) { - fprintf ( stderr, "Failed to create EWMH atoms\n" ); + g_warning ( "Failed to create EWMH atoms" ); free ( errors ); } // Discover the current active window manager. @@ -1005,14 +1004,14 @@ int main ( int argc, char *argv[] ) if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION, XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xkb.first_event, NULL ) < 0 ) { - fprintf ( stderr, "cannot setup XKB extension!\n" ); + g_warning ( "cannot setup XKB extension!" ); cleanup (); return EXIT_FAILURE; } xkb.context = xkb_context_new ( XKB_CONTEXT_NO_FLAGS ); if ( xkb.context == NULL ) { - fprintf ( stderr, "cannot create XKB context!\n" ); + g_warning ( "cannot create XKB context!" ); cleanup (); return EXIT_FAILURE; } @@ -1063,13 +1062,13 @@ int main ( int argc, char *argv[] ) xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS ); if ( xkb.keymap == NULL ) { - fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" ); + g_warning ( "Failed to get Keymap for current keyboard device." ); cleanup (); return EXIT_FAILURE; } xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id ); if ( xkb.state == NULL ) { - fprintf ( stderr, "Failed to get state object for current keyboard device.\n" ); + g_warning ( "Failed to get state object for current keyboard device." ); cleanup (); return EXIT_FAILURE; } @@ -1079,18 +1078,18 @@ int main ( int argc, char *argv[] ) xkb.compose.state = xkb_compose_state_new ( xkb.compose.table, 0 ); } else { - fprintf ( stderr, "Failed to get keyboard compose table. Trying to limp on.\n" ); + g_warning ( "Failed to get keyboard compose table. Trying to limp on." ); } if ( xcb_connection_has_error ( xcb->connection ) ) { - fprintf ( stderr, "Connection has error\n" ); + g_warning ( "Connection has error" ); cleanup (); return EXIT_FAILURE; } x11_setup ( &xkb ); TICK_N ( "Setup xkb" ); if ( xcb_connection_has_error ( xcb->connection ) ) { - fprintf ( stderr, "Connection has error\n" ); + g_warning ( "Connection has error" ); cleanup (); return EXIT_FAILURE; } @@ -1100,7 +1099,7 @@ int main ( int argc, char *argv[] ) // startup not. xcb->sndisplay = sn_xcb_display_new ( xcb->connection, error_trap_push, error_trap_pop ); if ( xcb_connection_has_error ( xcb->connection ) ) { - fprintf ( stderr, "Connection has error\n" ); + g_warning ( "Connection has error" ); cleanup (); return EXIT_FAILURE; } @@ -1109,7 +1108,7 @@ int main ( int argc, char *argv[] ) xcb->sncontext = sn_launchee_context_new_from_environment ( xcb->sndisplay, xcb->screen_nbr ); } if ( xcb_connection_has_error ( xcb->connection ) ) { - fprintf ( stderr, "Connection has error\n" ); + g_warning ( "Connection has error" ); cleanup (); return EXIT_FAILURE; } @@ -1162,11 +1161,11 @@ int main ( int argc, char *argv[] ) } if ( rofi_theme_is_empty ( ) ) { if ( rofi_theme_parse_string ( default_theme ) ) { - fprintf ( stderr, "Failed to parse default theme. Giving up..\n" ); + g_warning ( "Failed to parse default theme. Giving up.." ); if ( list_of_error_msgs ) { for ( GList *iter = g_list_first ( list_of_error_msgs ); iter != NULL; iter = g_list_next ( iter ) ) { - fprintf ( stderr, "Error: %s%s%s\n", + g_warning ( "Error: %s%s%s", color_bold, ( (GString *) iter->data )->str, color_reset ); } } diff --git a/source/theme.c b/source/theme.c index 4fd41003..e9f145ef 100644 --- a/source/theme.c +++ b/source/theme.c @@ -1,3 +1,6 @@ + +#define G_LOG_DOMAIN "Theme" + #include <stdio.h> #include <stdlib.h> #include <errno.h> @@ -10,10 +13,6 @@ #include "view.h" #include "rofi.h" -/** Logging domain for theme */ -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "Theme" - /** * Name of the property type */ diff --git a/source/view.c b/source/view.c index 8c1064d1..3bbba504 100644 --- a/source/view.c +++ b/source/view.c @@ -24,6 +24,9 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/** The Rofi View log domain */ +#define G_LOG_DOMAIN "View" + #include <config.h> #include <stdio.h> #include <stdlib.h> @@ -63,10 +66,6 @@ #include "theme.h" -/** The Rofi View log domain */ -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "View" - #include "xcb.h" /** * @param state The handle to the view @@ -178,12 +177,12 @@ static void menu_capture_screenshot ( void ) const char *outp = g_getenv ( "ROFI_PNG_OUTPUT" ); if ( CacheState.edit_surf == NULL ) { // Nothing to store. - fprintf ( stderr, "There is no rofi surface to store\n" ); + g_warning ( "There is no rofi surface to store" ); return; } const char *xdg_pict_dir = g_get_user_special_dir ( G_USER_DIRECTORY_PICTURES ); if ( outp == NULL && xdg_pict_dir == NULL ) { - fprintf ( stderr, "XDG user picture directory or ROFI_PNG_OUTPUT is not set. Cannot store screenshot.\n" ); + g_warning ( "XDG user picture directory or ROFI_PNG_OUTPUT is not set. Cannot store screenshot." ); return; } // Get current time. @@ -210,10 +209,10 @@ static void menu_capture_screenshot ( void ) else { fpath = g_strdup ( outp ); } - fprintf ( stderr, color_green "Storing screenshot %s\n"color_reset, fpath ); + g_warning ( color_green "Storing screenshot %s\n"color_reset, fpath ); cairo_status_t status = cairo_surface_write_to_png ( CacheState.edit_surf, fpath ); if ( status != CAIRO_STATUS_SUCCESS ) { - fprintf ( stderr, "Failed to produce screenshot '%s', got error: '%s'\n", fpath, + g_warning ( "Failed to produce screenshot '%s', got error: '%s'", fpath, cairo_status_to_string ( status ) ); } g_free ( fpath ); @@ -978,7 +977,7 @@ void rofi_view_update ( RofiViewState *state, gboolean qr ) static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t *xse ) { if ( xse->property == XCB_ATOM_NONE ) { - fprintf ( stderr, "Failed to convert selection\n" ); + g_warning ( "Failed to convert selection" ); } else if ( xse->property == xcb->ewmh.UTF8_STRING ) { gchar *text = window_get_text_prop ( CacheState.main_window, xcb->ewmh.UTF8_STRING ); @@ -999,7 +998,7 @@ static void rofi_view_paste ( RofiViewState *state, xcb_selection_notify_event_t g_free ( text ); } else { - fprintf ( stderr, "Failed\n" ); + g_warning ( "Failed" ); } } @@ -1443,7 +1442,7 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *ev, xkb_st CacheState.edit_surf = cairo_xcb_surface_create ( xcb->connection, CacheState.edit_pixmap, visual, state->width, state->height ); CacheState.edit_draw = cairo_create ( CacheState.edit_surf ); - g_debug ( "Re-size window based external request: %d %d\n", state->width, state->height ); + g_debug ( "Re-size window based external request: %d %d", state->width, state->height ); widget_ |