1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Add debug output.

This commit is contained in:
Dave Davenport 2016-08-30 21:24:04 +02:00
parent 5646adc34d
commit c099aaeabf
6 changed files with 44 additions and 41 deletions

View file

@ -39,16 +39,16 @@ typedef struct
typedef enum typedef enum
{ {
TB_AUTOHEIGHT = 1 << 0, TB_AUTOHEIGHT = 1 << 0,
TB_AUTOWIDTH = 1 << 1, TB_AUTOWIDTH = 1 << 1,
TB_LEFT = 1 << 16, TB_LEFT = 1 << 16,
TB_RIGHT = 1 << 17, TB_RIGHT = 1 << 17,
TB_CENTER = 1 << 18, TB_CENTER = 1 << 18,
TB_EDITABLE = 1 << 19, TB_EDITABLE = 1 << 19,
TB_MARKUP = 1 << 20, TB_MARKUP = 1 << 20,
TB_WRAP = 1 << 21, TB_WRAP = 1 << 21,
TB_PASSWORD = 1 << 22, TB_PASSWORD = 1 << 22,
TB_INDICATOR = 1 << 23, TB_INDICATOR = 1 << 23,
} TextboxFlags; } TextboxFlags;
typedef enum typedef enum

View file

@ -47,6 +47,7 @@
#include "dialogs/drun.h" #include "dialogs/drun.h"
#define DRUN_CACHE_FILE "rofi2.druncache" #define DRUN_CACHE_FILE "rofi2.druncache"
#define LOG_DOMAIN "Dialogs.DRun"
static inline int execsh ( const char *cmd, int run_in_term ) static inline int execsh ( const char *cmd, int run_in_term )
{ {
@ -231,7 +232,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
g_key_file_load_from_file ( kf, path, 0, &error ); g_key_file_load_from_file ( kf, path, 0, &error );
// If error, skip to next entry // If error, skip to next entry
if ( error != NULL ) { if ( error != NULL ) {
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Failed to parse desktop file: %s because: %s", path, error->message ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to parse desktop file: %s because: %s", path, error->message );
g_error_free ( error ); g_error_free ( error );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
@ -240,12 +241,12 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
gchar *key = g_key_file_get_string ( kf, "Desktop Entry", "Type", NULL ); gchar *key = g_key_file_get_string ( kf, "Desktop Entry", "Type", NULL );
if ( key == NULL ) { if ( key == NULL ) {
// No type? ignore. // No type? ignore.
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: No type indicated", path ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: No type indicated", path );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
} }
if ( g_strcmp0 ( key, "Application" ) ) { if ( g_strcmp0 ( key, "Application" ) ) {
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: Not of type application (%s)", path, key ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: Not of type application (%s)", path, key );
g_free ( key ); g_free ( key );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
@ -253,25 +254,25 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
g_free ( key ); g_free ( key );
// Skip hidden entries. // Skip hidden entries.
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) { if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) {
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: Hidden", path ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: Hidden", path );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
} }
// Skip entries that have NoDisplay set. // Skip entries that have NoDisplay set.
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "NoDisplay", NULL ) ) { if ( g_key_file_get_boolean ( kf, "Desktop Entry", "NoDisplay", NULL ) ) {
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: NoDisplay", path ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Skipping desktop file: %s because: NoDisplay", path );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
} }
// Name key is required. // Name key is required.
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Name", NULL ) ) { if ( !g_key_file_has_key ( kf, "Desktop Entry", "Name", NULL ) ) {
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Invalid DesktopFile: '%s', no 'Name' key present.\n", path ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Invalid DesktopFile: '%s', no 'Name' key present.\n", path );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
} }
// We need Exec, don't support DBusActivatable // We need Exec, don't support DBusActivatable
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) { if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
g_log ( "Dialogs.DRun", G_LOG_LEVEL_DEBUG, "Unsupported DesktopFile: '%s', no 'Exec' key present.\n", path ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Unsupported DesktopFile: '%s', no 'Exec' key present.\n", path );
g_key_file_free ( kf ); g_key_file_free ( kf );
return; return;
} }

View file

@ -53,6 +53,7 @@
* Name of the history file where previously choosen commands are stored. * Name of the history file where previously choosen commands are stored.
*/ */
#define RUN_CACHE_FILE "rofi-3.runcache" #define RUN_CACHE_FILE "rofi-3.runcache"
#define LOG_DOMAIN "Dialogs.Run"
/** /**
* The internal data structure holding the private data of the Run Mode. * The internal data structure holding the private data of the Run Mode.
@ -249,7 +250,7 @@ static char ** get_apps ( unsigned int *length )
gsize l = 0; gsize l = 0;
gchar *homedir = g_locale_to_utf8 ( g_get_home_dir (), -1, NULL, &l, &error ); gchar *homedir = g_locale_to_utf8 ( g_get_home_dir (), -1, NULL, &l, &error );
if ( error != NULL ) { if ( error != NULL ) {
fprintf ( stderr, "Failed to convert homedir to UTF-8: %s\n", error->message ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to convert homedir to UTF-8: %s", error->message );
g_clear_error ( &error ); g_clear_error ( &error );
g_free ( homedir ); g_free ( homedir );
return NULL; return NULL;
@ -259,12 +260,13 @@ static char ** get_apps ( unsigned int *length )
for ( const char *dirname = strtok ( path, sep ); dirname != NULL; dirname = strtok ( NULL, sep ) ) { for ( const char *dirname = strtok ( path, sep ); dirname != NULL; dirname = strtok ( NULL, sep ) ) {
DIR *dir = opendir ( dirname ); DIR *dir = opendir ( dirname );
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Checking path %s for executable.", dirname );
if ( dir != NULL ) { if ( dir != NULL ) {
struct dirent *dent; struct dirent *dent;
gsize dirn_len = 0; gsize dirn_len = 0;
gchar *dirn = g_locale_to_utf8 ( dirname, -1, NULL, &dirn_len, &error ); gchar *dirn = g_locale_to_utf8 ( dirname, -1, NULL, &dirn_len, &error );
if ( error != NULL ) { if ( error != NULL ) {
fprintf ( stderr, "Failed to convert directory name to UTF-8: %s\n", error->message ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to convert directory name to UTF-8: %s", error->message );
g_clear_error ( &error ); g_clear_error ( &error );
continue; continue;
} }
@ -291,7 +293,7 @@ static char ** get_apps ( unsigned int *length )
gsize name_len; gsize name_len;
gchar *name = g_filename_to_utf8 ( dent->d_name, -1, NULL, &name_len, &error ); gchar *name = g_filename_to_utf8 ( dent->d_name, -1, NULL, &name_len, &error );
if ( error != NULL ) { if ( error != NULL ) {
fprintf ( stderr, "Failed to convert filename to UTF-8: %s\n", error->message ); g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Failed to convert filename to UTF-8: %s", error->message );
g_clear_error ( &error ); g_clear_error ( &error );
g_free ( name ); g_free ( name );
continue; continue;

View file

@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time. // Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) { while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line. // Evaluate one line.
unsigned int index = 0, ti = 0; unsigned int index = 0, ti = 0;
char *token = buffer; char *token = buffer;
// Tokenize it. // Tokenize it.

View file

@ -194,7 +194,7 @@ static GRegex * create_regex ( const char *input, int case_sensitive )
{ {
#define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL ) #define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL )
GRegex * retv = NULL; GRegex * retv = NULL;
gchar *r; gchar *r;
switch ( config.matching_method ) switch ( config.matching_method )
{ {
case MM_GLOB: case MM_GLOB:
@ -234,7 +234,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
} }
char *saveptr = NULL, *token; char *saveptr = NULL, *token;
GRegex **retv = NULL; GRegex **retv = NULL;
if ( !config.tokenize ) { if ( !config.tokenize ) {
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 ); retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
retv[0] = (GRegex *) create_regex ( input, case_sensitive ); retv[0] = (GRegex *) create_regex ( input, case_sensitive );

View file

@ -73,9 +73,9 @@ struct xkb_stuff xkb = {
.keymap = NULL, .keymap = NULL,
.state = NULL, .state = NULL,
.compose = { .compose = {
.table = NULL, .table = NULL,
.state = NULL .state = NULL
} }
}; };
char *config_path = NULL; char *config_path = NULL;
// Array of modi. // Array of modi.
@ -470,22 +470,22 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id ); xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break; break;
case XCB_XKB_STATE_NOTIFY: case XCB_XKB_STATE_NOTIFY:
{ {
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev; xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
guint modmask; guint modmask;
xkb_state_update_mask ( xkb.state, xkb_state_update_mask ( xkb.state,
ksne->baseMods, ksne->baseMods,
ksne->latchedMods, ksne->latchedMods,
ksne->lockedMods, ksne->lockedMods,
ksne->baseGroup, ksne->baseGroup,
ksne->latchedGroup, ksne->latchedGroup,
ksne->lockedGroup ); ksne->lockedGroup );
modmask = x11_get_current_mask ( &xkb ); modmask = x11_get_current_mask ( &xkb );
if ( modmask == 0 ) { if ( modmask == 0 ) {
abe_trigger_release ( ); abe_trigger_release ( );
}
break;
} }
break;
}
} }
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }