mirror of https://github.com/davatorium/rofi.git
[IconFetcher] Look for images in theme directories.
This commit is contained in:
parent
60414886d5
commit
6798a4c4e0
|
@ -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.
|
* @returns a new string with the keys replaced.
|
||||||
*/
|
*/
|
||||||
char *helper_string_replace_if_exists ( char * string, ... );
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
/**@} */
|
/**@} */
|
||||||
|
|
|
@ -375,12 +375,6 @@ gboolean rofi_theme_is_empty ( void );
|
||||||
*/
|
*/
|
||||||
void rofi_theme_reset ( 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.
|
* @param file File name to prepare.
|
||||||
|
|
|
@ -367,7 +367,7 @@ if ( queue == NULL ) {
|
||||||
yytext[yyleng-1] = '\0';
|
yytext[yyleng-1] = '\0';
|
||||||
ParseObject *top = g_queue_peek_head ( file_queue );
|
ParseObject *top = g_queue_peek_head ( file_queue );
|
||||||
g_assert ( top != NULL );
|
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 );
|
char *filename = rofi_theme_parse_prepare_file ( file2, top->filename );
|
||||||
g_free ( file2 );
|
g_free ( file2 );
|
||||||
if ( g_list_find_custom ( imported_files, filename, (GCompareFunc)g_strcmp0 ) != NULL ) {
|
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 )
|
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 );
|
char *filename = rofi_theme_parse_prepare_file ( file2, NULL );
|
||||||
g_free ( file2 );
|
g_free ( file2 );
|
||||||
|
|
||||||
|
|
|
@ -1054,7 +1054,7 @@ gboolean helper_execute_command ( const char *wd, const char *cmd, gboolean run_
|
||||||
return helper_execute ( wd, args, "", cmd, context );
|
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 );
|
char *filename = rofi_expand_path ( file );
|
||||||
g_debug ( "Opening theme, testing: %s\n", filename );
|
g_debug ( "Opening theme, testing: %s\n", filename );
|
||||||
|
@ -1063,11 +1063,11 @@ char *helper_get_theme_path ( const char *file )
|
||||||
}
|
}
|
||||||
g_free ( filename );
|
g_free ( filename );
|
||||||
|
|
||||||
if ( g_str_has_suffix ( file, ".rasi" ) ) {
|
if ( g_str_has_suffix ( file, ext ) ) {
|
||||||
filename = g_strdup ( file );
|
filename = g_strdup ( file );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
filename = g_strconcat ( file, ".rasi", NULL );
|
filename = g_strconcat ( file, ext, NULL );
|
||||||
}
|
}
|
||||||
// Check config's themes directory.
|
// Check config's themes directory.
|
||||||
const char *cpath = g_get_user_config_dir ();
|
const char *cpath = g_get_user_config_dir ();
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
#include "helper.h"
|
||||||
|
|
||||||
typedef struct
|
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 );
|
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 ) {
|
if ( icon_path_ == NULL ) {
|
||||||
g_debug ( "failed to get icon %s(%dx%d): n/a", sentry->entry->name, sentry->wsize, sentry->hsize );
|
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{
|
else{
|
||||||
g_debug ( "found icon %s(%dx%d): %s", sentry->entry->name, sentry->wsize, sentry->hsize, icon_path );
|
g_debug ( "found icon %s(%dx%d): %s", sentry->entry->name, sentry->wsize, sentry->hsize, icon_path );
|
||||||
|
|
|
@ -93,7 +93,7 @@ char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
|
||||||
return NULL;
|
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 );
|
return g_strdup ( file );
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
||||||
return 0;
|
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 );
|
return g_strdup ( file );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue