[IconFetcher] Look for images in theme directories.

This commit is contained in:
Dave Davenport 2021-08-17 11:05:03 +02:00 committed by Dave Davenport
parent 60414886d5
commit 6798a4c4e0
7 changed files with 28 additions and 14 deletions

View File

@ -380,6 +380,17 @@ void rofi_output_formatted_line ( const char *format, const char *string, int se
* @returns a new string with the keys replaced.
*/
char *helper_string_replace_if_exists ( char * string, ... );
/**
* @param file File name passed to option.
* @param ext File extension passed to option.
*
* @returns path to theme or copy of filename if not found.
*/
char *helper_get_theme_path ( const char *file, const char *ext );
G_END_DECLS
/**@} */

View File

@ -375,12 +375,6 @@ gboolean rofi_theme_is_empty ( void );
*/
void rofi_theme_reset ( void );
/**
* @param file File name passed to option.
*
* @returns path to theme or copy of filename if not found.
*/
char *helper_get_theme_path ( const char *file );
/**
* @param file File name to prepare.

View File

@ -367,7 +367,7 @@ if ( queue == NULL ) {
yytext[yyleng-1] = '\0';
ParseObject *top = g_queue_peek_head ( file_queue );
g_assert ( top != NULL );
char *file2 = helper_get_theme_path ( &yytext[1] );
char *file2 = helper_get_theme_path ( &yytext[1], ".rasi" );
char *filename = rofi_theme_parse_prepare_file ( file2, top->filename );
g_free ( file2 );
if ( g_list_find_custom ( imported_files, filename, (GCompareFunc)g_strcmp0 ) != NULL ) {
@ -778,7 +778,7 @@ if ( queue == NULL ) {
gboolean rofi_theme_parse_file ( const char *file )
{
char *file2 = helper_get_theme_path ( file );
char *file2 = helper_get_theme_path ( file, ".rasi" );
char *filename = rofi_theme_parse_prepare_file ( file2, NULL );
g_free ( file2 );

View File

@ -1054,7 +1054,7 @@ gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_
return helper_execute ( wd, args, "", cmd, context );
}
char *helper_get_theme_path ( const char *file )
char *helper_get_theme_path ( const char *file, const char *ext )
{
char *filename = rofi_expand_path ( file );
g_debug ( "Opening theme, testing: %s\n", filename );
@ -1063,11 +1063,11 @@ char *helper_get_theme_path ( const char *file )
}
g_free ( filename );
if ( g_str_has_suffix ( file, ".rasi" ) ) {
if ( g_str_has_suffix ( file, ext ) ) {
filename = g_strdup ( file );
}
else {
filename = g_strconcat ( file, ".rasi", NULL );
filename = g_strconcat ( file, ext, NULL );
}
// Check config's themes directory.
const char *cpath = g_get_user_config_dir ();

View File

@ -46,6 +46,7 @@
#include <stdint.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "helper.h"
typedef struct
{
@ -305,7 +306,15 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
icon_path = icon_path_ = nk_xdg_theme_get_icon ( rofi_icon_fetcher_data->xdg_context, themes, NULL, sentry->entry->name, MIN(sentry->wsize,sentry->hsize), 1, TRUE );
if ( icon_path_ == NULL ) {
g_debug ( "failed to get icon %s(%dx%d): n/a", sentry->entry->name, sentry->wsize, sentry->hsize );
return;
const char *ext = g_strrstr(sentry->entry->name, ".");
if ( ext ) {
printf("%s %s\r\n", sentry->entry->name, ext);
icon_path = helper_get_theme_path ( sentry->entry->name, ext );
}
if ( icon_path == NULL ) {
return;
}
}
else{
g_debug ( "found icon %s(%dx%d): %s", sentry->entry->name, sentry->wsize, sentry->hsize, icon_path );

View File

@ -93,7 +93,7 @@ char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
return NULL;
}
char * helper_get_theme_path ( const char *file )
char * helper_get_theme_path ( const char *file, const char *ext)
{
return g_strdup ( file );
}

View File

@ -78,7 +78,7 @@ int monitor_active ( G_GNUC_UNUSED workarea *mon )
return 0;
}
char * helper_get_theme_path ( const char *file )
char * helper_get_theme_path ( const char *file, const char *ext )
{
return g_strdup ( file );
}