mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Run indenter.
This commit is contained in:
parent
5bec191d2e
commit
30735791b4
21 changed files with 349 additions and 331 deletions
|
@ -119,7 +119,6 @@ typedef struct RofiDistanceUnit
|
||||||
|
|
||||||
/** Modifier */
|
/** Modifier */
|
||||||
struct RofiDistanceUnit *right;
|
struct RofiDistanceUnit *right;
|
||||||
|
|
||||||
} RofiDistanceUnit;
|
} RofiDistanceUnit;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -249,7 +249,6 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doub
|
||||||
*/
|
*/
|
||||||
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d );
|
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param widget The widget to query
|
* @param widget The widget to query
|
||||||
* @param property The property to query.
|
* @param property The property to query.
|
||||||
|
|
|
@ -307,7 +307,6 @@ void rofi_capture_screenshot ( void );
|
||||||
*/
|
*/
|
||||||
void rofi_view_set_window_title ( const char * title );
|
void rofi_view_set_window_title ( const char * title );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set ellipsize mode to start.
|
* set ellipsize mode to start.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,7 +81,7 @@ struct _widget
|
||||||
int ( *get_desired_height )( struct _widget * );
|
int ( *get_desired_height )( struct _widget * );
|
||||||
int ( *get_desired_width )( struct _widget * );
|
int ( *get_desired_width )( struct _widget * );
|
||||||
|
|
||||||
void ( *set_state ) ( struct _widget *, const char *);
|
void ( *set_state ) ( struct _widget *, const char * );
|
||||||
|
|
||||||
/** widget find_mouse_target callback */
|
/** widget find_mouse_target callback */
|
||||||
widget_find_mouse_target_cb find_mouse_target;
|
widget_find_mouse_target_cb find_mouse_target;
|
||||||
|
|
|
@ -172,7 +172,8 @@ void widget_set_enabled ( widget *widget, gboolean enabled );
|
||||||
* Disable the widget.
|
* Disable the widget.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
void widget_disable ( widget *widget ) {
|
void widget_disable ( widget *widget )
|
||||||
|
{
|
||||||
widget_set_enabled ( widget, FALSE );
|
widget_set_enabled ( widget, FALSE );
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -181,7 +182,8 @@ void widget_disable ( widget *widget ) {
|
||||||
* Enable the widget.
|
* Enable the widget.
|
||||||
*/
|
*/
|
||||||
static inline
|
static inline
|
||||||
void widget_enable ( widget *widget ) {
|
void widget_enable ( widget *widget )
|
||||||
|
{
|
||||||
widget_set_enabled ( widget, TRUE );
|
widget_set_enabled ( widget, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,9 +157,9 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned
|
||||||
if ( input[0][0] == '!' ) {
|
if ( input[0][0] == '!' ) {
|
||||||
int switcher = -1;
|
int switcher = -1;
|
||||||
// Implement strchrnul behaviour.
|
// Implement strchrnul behaviour.
|
||||||
char *eob = g_utf8_strchr ( input[0], -1,' ' );
|
char *eob = g_utf8_strchr ( input[0], -1, ' ' );
|
||||||
if ( eob == NULL ) {
|
if ( eob == NULL ) {
|
||||||
eob = &(input[0][strlen(input[0])]);
|
eob = &( input[0][strlen ( input[0] )] );
|
||||||
}
|
}
|
||||||
ssize_t bang_len = g_utf8_pointer_to_offset ( input[0], eob ) - 1;
|
ssize_t bang_len = g_utf8_pointer_to_offset ( input[0], eob ) - 1;
|
||||||
if ( bang_len > 0 ) {
|
if ( bang_len > 0 ) {
|
||||||
|
@ -285,7 +285,7 @@ static char * combi_preprocess_input ( Mode *sw, const char *input )
|
||||||
const char *eob = g_utf8_strchr ( input, -1, ' ' );
|
const char *eob = g_utf8_strchr ( input, -1, ' ' );
|
||||||
if ( eob == NULL ) {
|
if ( eob == NULL ) {
|
||||||
// Set it to end.
|
// Set it to end.
|
||||||
eob = &(input[strlen(input)]);
|
eob = &( input[strlen ( input )] );
|
||||||
}
|
}
|
||||||
ssize_t bang_len = g_utf8_pointer_to_offset ( input, eob ) - 1;
|
ssize_t bang_len = g_utf8_pointer_to_offset ( input, eob ) - 1;
|
||||||
if ( bang_len > 0 ) {
|
if ( bang_len > 0 ) {
|
||||||
|
|
|
@ -736,7 +736,6 @@ int dmenu_switcher_dialog ( void )
|
||||||
find_arg_str ( "-p", &( dmenu_mode.display_name ) );
|
find_arg_str ( "-p", &( dmenu_mode.display_name ) );
|
||||||
RofiViewState *state = rofi_view_create ( &dmenu_mode, input, menu_flags, dmenu_finalize );
|
RofiViewState *state = rofi_view_create ( &dmenu_mode, input, menu_flags, dmenu_finalize );
|
||||||
|
|
||||||
|
|
||||||
if ( find_arg ( "-keep-right" ) >= 0 ) {
|
if ( find_arg ( "-keep-right" ) >= 0 ) {
|
||||||
rofi_view_ellipsize_start ( state );
|
rofi_view_ellipsize_start ( state );
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ static gboolean drun_helper_eval_cb ( const GMatchInfo *info, GString *res, gpoi
|
||||||
case 'm':
|
case 'm':
|
||||||
break;
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
g_string_append(res, "%");
|
g_string_append ( res, "%" );
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
if ( e->e->path ) {
|
if ( e->e->path ) {
|
||||||
|
@ -241,12 +241,12 @@ static void launch_link_entry ( DRunModeEntry *e )
|
||||||
if ( url == NULL || strlen ( url ) == 0 ) {
|
if ( url == NULL || strlen ( url ) == 0 ) {
|
||||||
g_warning ( "[%s] [%s] No URL found.", e->app_id, e->path );
|
g_warning ( "[%s] [%s] No URL found.", e->app_id, e->path );
|
||||||
g_free ( url );
|
g_free ( url );
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gsize command_len = strlen( config.drun_url_launcher ) + strlen( url ) + 2; // space + terminator = 2
|
gsize command_len = strlen ( config.drun_url_launcher ) + strlen ( url ) + 2; // space + terminator = 2
|
||||||
gchar *command = g_newa ( gchar, command_len );
|
gchar *command = g_newa ( gchar, command_len );
|
||||||
g_snprintf( command, command_len, "%s %s", config.drun_url_launcher, url );
|
g_snprintf ( command, command_len, "%s %s", config.drun_url_launcher, url );
|
||||||
g_free ( url );
|
g_free ( url );
|
||||||
|
|
||||||
g_debug ( "Link launch command: |%s|", command );
|
g_debug ( "Link launch command: |%s|", command );
|
||||||
|
@ -393,9 +393,11 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
|
||||||
}
|
}
|
||||||
if ( !g_strcmp0 ( key, "Application" ) ) {
|
if ( !g_strcmp0 ( key, "Application" ) ) {
|
||||||
desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_APPLICATION;
|
desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_APPLICATION;
|
||||||
} else if ( !g_strcmp0 ( key, "Link" ) ) {
|
}
|
||||||
|
else if ( !g_strcmp0 ( key, "Link" ) ) {
|
||||||
desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_LINK;
|
desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_LINK;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
g_debug ( "[%s] [%s] Skipping desktop file: Not of type Application or Link (%s)", id, path, key );
|
g_debug ( "[%s] [%s] Skipping desktop file: Not of type Application or Link (%s)", id, path, key );
|
||||||
g_free ( key );
|
g_free ( key );
|
||||||
g_key_file_free ( kf );
|
g_key_file_free ( kf );
|
||||||
|
@ -499,7 +501,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
|
||||||
char **categories = NULL;
|
char **categories = NULL;
|
||||||
if ( pd->show_categories ) {
|
if ( pd->show_categories ) {
|
||||||
categories = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Categories", NULL, NULL, NULL );
|
categories = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Categories", NULL, NULL, NULL );
|
||||||
if ( !rofi_strv_contains ( (const char * const *) categories, (const char *const *) pd->show_categories ) ) {
|
if ( !rofi_strv_contains ( (const char * const *) categories, (const char * const *) pd->show_categories ) ) {
|
||||||
g_strfreev ( categories );
|
g_strfreev ( categories );
|
||||||
g_key_file_free ( kf );
|
g_key_file_free ( kf );
|
||||||
return;
|
return;
|
||||||
|
@ -563,7 +565,8 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
|
||||||
pd->entry_list[pd->cmd_list_length].type = desktop_entry_type;
|
pd->entry_list[pd->cmd_list_length].type = desktop_entry_type;
|
||||||
if ( desktop_entry_type == DRUN_DESKTOP_ENTRY_TYPE_APPLICATION ) {
|
if ( desktop_entry_type == DRUN_DESKTOP_ENTRY_TYPE_APPLICATION ) {
|
||||||
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, action, "Exec", NULL );
|
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, action, "Exec", NULL );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
pd->entry_list[pd->cmd_list_length].exec = NULL;
|
pd->entry_list[pd->cmd_list_length].exec = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,7 +1022,8 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
|
||||||
retv = ( mretv & MENU_LOWER_MASK );
|
retv = ( mretv & MENU_LOWER_MASK );
|
||||||
}
|
}
|
||||||
else if ( ( mretv & MENU_OK ) ) {
|
else if ( ( mretv & MENU_OK ) ) {
|
||||||
switch ( rmpd->entry_list[selected_line].type ) {
|
switch ( rmpd->entry_list[selected_line].type )
|
||||||
|
{
|
||||||
case DRUN_DESKTOP_ENTRY_TYPE_APPLICATION:
|
case DRUN_DESKTOP_ENTRY_TYPE_APPLICATION:
|
||||||
exec_cmd_entry ( &( rmpd->entry_list[selected_line] ) );
|
exec_cmd_entry ( &( rmpd->entry_list[selected_line] ) );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -80,10 +80,9 @@ void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *
|
||||||
{
|
{
|
||||||
gchar **extras = g_strsplit ( buffer, "\x1f", -1 );
|
gchar **extras = g_strsplit ( buffer, "\x1f", -1 );
|
||||||
gchar **extra;
|
gchar **extra;
|
||||||
for ( extra = extras ; *extra != NULL && *(extra + 1) != NULL ; extra += 2 )
|
for ( extra = extras; *extra != NULL && *( extra + 1 ) != NULL; extra += 2 ) {
|
||||||
{
|
|
||||||
gchar *key = *extra;
|
gchar *key = *extra;
|
||||||
gchar *value = *(extra + 1);
|
gchar *value = *( extra + 1 );
|
||||||
if ( strcasecmp ( key, "icon" ) == 0 ) {
|
if ( strcasecmp ( key, "icon" ) == 0 ) {
|
||||||
entry->icon_name = value;
|
entry->icon_name = value;
|
||||||
}
|
}
|
||||||
|
@ -95,14 +94,14 @@ void dmenuscript_parse_entry_extras ( G_GNUC_UNUSED Mode *sw, DmenuScriptEntry *
|
||||||
}
|
}
|
||||||
else if ( strcasecmp ( key, "nonselectable" ) == 0 ) {
|
else if ( strcasecmp ( key, "nonselectable" ) == 0 ) {
|
||||||
entry->nonselectable = strcasecmp ( value, "true" ) == 0;
|
entry->nonselectable = strcasecmp ( value, "true" ) == 0;
|
||||||
g_free(value);
|
g_free ( value );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
g_free(value);
|
g_free ( value );
|
||||||
}
|
}
|
||||||
g_free(key);
|
g_free ( key );
|
||||||
}
|
}
|
||||||
g_free(extras);
|
g_free ( extras );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +116,7 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
|
||||||
length_key++;
|
length_key++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (length_key+1) < length ) {
|
if ( ( length_key + 1 ) < length ) {
|
||||||
line[length_key] = '\0';
|
line[length_key] = '\0';
|
||||||
char *value = line + length_key + 1;
|
char *value = line + length_key + 1;
|
||||||
if ( strcasecmp ( line, "message" ) == 0 ) {
|
if ( strcasecmp ( line, "message" ) == 0 ) {
|
||||||
|
@ -140,8 +139,9 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
|
||||||
}
|
}
|
||||||
else if ( strcasecmp ( line, "delim" ) == 0 ) {
|
else if ( strcasecmp ( line, "delim" ) == 0 ) {
|
||||||
pd->delim = helper_parse_char ( value );
|
pd->delim = helper_parse_char ( value );
|
||||||
} else if ( strcasecmp ( line, "no-custom" ) == 0 ) {
|
}
|
||||||
pd->no_custom = ( strcasecmp ( value, "true") == 0 );
|
else if ( strcasecmp ( line, "no-custom" ) == 0 ) {
|
||||||
|
pd->no_custom = ( strcasecmp ( value, "true" ) == 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,23 +156,21 @@ static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *l
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
*length = 0;
|
*length = 0;
|
||||||
|
|
||||||
|
|
||||||
// Environment
|
// Environment
|
||||||
char ** env = g_get_environ ();
|
char ** env = g_get_environ ();
|
||||||
|
|
||||||
char *str_value = g_strdup_printf("%d", value);
|
char *str_value = g_strdup_printf ( "%d", value );
|
||||||
env = g_environ_setenv ( env, "ROFI_RETV", str_value, TRUE);
|
env = g_environ_setenv ( env, "ROFI_RETV", str_value, TRUE );
|
||||||
g_free ( str_value );
|
g_free ( str_value );
|
||||||
|
|
||||||
str_value = g_strdup_printf("%d", (int) getpid());
|
str_value = g_strdup_printf ( "%d", (int) getpid () );
|
||||||
env = g_environ_setenv ( env, "ROFI_OUTSIDE", str_value, TRUE);
|
env = g_environ_setenv ( env, "ROFI_OUTSIDE", str_value, TRUE );
|
||||||
g_free ( str_value );
|
g_free ( str_value );
|
||||||
|
|
||||||
if ( entry && entry->info ) {
|
if ( entry && entry->info ) {
|
||||||
env = g_environ_setenv ( env, "ROFI_INFO", entry->info, TRUE);
|
env = g_environ_setenv ( env, "ROFI_INFO", entry->info, TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( g_shell_parse_argv ( sw->ed, &argc, &argv, &error ) ) {
|
if ( g_shell_parse_argv ( sw->ed, &argc, &argv, &error ) ) {
|
||||||
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
|
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
|
||||||
argv[argc] = g_strdup ( arg );
|
argv[argc] = g_strdup ( arg );
|
||||||
|
@ -181,7 +179,7 @@ static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *l
|
||||||
}
|
}
|
||||||
g_strfreev ( env );
|
g_strfreev ( env );
|
||||||
if ( error != NULL ) {
|
if ( error != NULL ) {
|
||||||
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", (char*)sw->ed, error->message );
|
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", (char *) sw->ed, error->message );
|
||||||
rofi_view_error_dialog ( msg, FALSE );
|
rofi_view_error_dialog ( msg, FALSE );
|
||||||
g_free ( msg );
|
g_free ( msg );
|
||||||
// print error.
|
// print error.
|
||||||
|
@ -290,11 +288,13 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
|
||||||
//retv = 1+( mretv & MENU_LOWER_MASK );
|
//retv = 1+( mretv & MENU_LOWER_MASK );
|
||||||
script_mode_reset_highlight ( sw );
|
script_mode_reset_highlight ( sw );
|
||||||
if ( selected_line != UINT32_MAX ) {
|
if ( selected_line != UINT32_MAX ) {
|
||||||
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length,10+( mretv & MENU_LOWER_MASK ), &(rmpd->cmd_list[selected_line]) );
|
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if ( rmpd->no_custom == FALSE ) {
|
if ( rmpd->no_custom == FALSE ) {
|
||||||
new_list = execute_executor ( sw, *input, &new_length,10+( mretv & MENU_LOWER_MASK ), NULL );
|
new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return RELOAD_DIALOG;
|
return RELOAD_DIALOG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,13 +304,14 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned
|
||||||
return RELOAD_DIALOG;
|
return RELOAD_DIALOG;
|
||||||
}
|
}
|
||||||
script_mode_reset_highlight ( sw );
|
script_mode_reset_highlight ( sw );
|
||||||
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 1, &(rmpd->cmd_list[selected_line]) );
|
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 1, &( rmpd->cmd_list[selected_line] ) );
|
||||||
}
|
}
|
||||||
else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) {
|
else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) {
|
||||||
if ( rmpd->no_custom == FALSE ) {
|
if ( rmpd->no_custom == FALSE ) {
|
||||||
script_mode_reset_highlight ( sw );
|
script_mode_reset_highlight ( sw );
|
||||||
new_list = execute_executor ( sw, *input, &new_length, 2 , NULL );
|
new_list = execute_executor ( sw, *input, &new_length, 2, NULL );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return RELOAD_DIALOG;
|
return RELOAD_DIALOG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,7 +519,7 @@ static SshEntry * get_ssh ( SSHModePrivateData *pd, unsigned int *length )
|
||||||
g_free ( path );
|
g_free ( path );
|
||||||
for ( GList *iter = g_list_first ( pd->user_known_hosts ); iter; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( pd->user_known_hosts ); iter; iter = g_list_next ( iter ) ) {
|
||||||
char *path = rofi_expand_path ( (const char *) iter->data );
|
char *path = rofi_expand_path ( (const char *) iter->data );
|
||||||
retv = read_known_hosts_file ( (const char*) path, retv, length );
|
retv = read_known_hosts_file ( (const char *) path, retv, length );
|
||||||
g_free ( path );
|
g_free ( path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,7 +464,7 @@ static const char * _window_name_list_entry ( const char *str, uint32_t length,
|
||||||
}
|
}
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
if ( offset >= length ){
|
if ( offset >= length ) {
|
||||||
return invalid_desktop_name;
|
return invalid_desktop_name;
|
||||||
}
|
}
|
||||||
return &str[offset];
|
return &str[offset];
|
||||||
|
|
|
@ -133,62 +133,64 @@ void rofi_icon_fetcher_destroy ( void )
|
||||||
g_free ( rofi_icon_fetcher_data );
|
g_free ( rofi_icon_fetcher_data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cairo_surface_t* cairo_image_surface_create_from_jpeg_private ( struct jpeg_decompress_struct* cinfo )
|
||||||
|
{
|
||||||
static cairo_surface_t* cairo_image_surface_create_from_jpeg_private(struct jpeg_decompress_struct* cinfo) {
|
|
||||||
cairo_surface_t* surface = 0;
|
cairo_surface_t* surface = 0;
|
||||||
unsigned char* data = 0;
|
unsigned char * data = 0;
|
||||||
unsigned char* rgb = 0;
|
unsigned char * rgb = 0;
|
||||||
|
|
||||||
jpeg_read_header(cinfo, TRUE);
|
jpeg_read_header ( cinfo, TRUE );
|
||||||
jpeg_start_decompress(cinfo);
|
jpeg_start_decompress ( cinfo );
|
||||||
|
|
||||||
surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, cinfo->image_width, cinfo->image_height);
|
surface = cairo_image_surface_create ( CAIRO_FORMAT_RGB24, cinfo->image_width, cinfo->image_height );
|
||||||
data = cairo_image_surface_get_data(surface);
|
data = cairo_image_surface_get_data ( surface );
|
||||||
rgb = (unsigned char*)(malloc(cinfo->output_width * cinfo->output_components));
|
rgb = (unsigned char *) ( malloc ( cinfo->output_width * cinfo->output_components ) );
|
||||||
|
|
||||||
while(cinfo->output_scanline < cinfo->output_height) {
|
while ( cinfo->output_scanline < cinfo->output_height ) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int scanline = cinfo->output_scanline * cairo_image_surface_get_stride(surface);
|
int scanline = cinfo->output_scanline * cairo_image_surface_get_stride ( surface );
|
||||||
|
|
||||||
jpeg_read_scanlines(cinfo, &rgb, 1);
|
jpeg_read_scanlines ( cinfo, &rgb, 1 );
|
||||||
|
|
||||||
for(i = 0; i < cinfo->output_width; i++) {
|
for ( i = 0; i < cinfo->output_width; i++ ) {
|
||||||
int offset = scanline + (i * 4);
|
int offset = scanline + ( i * 4 );
|
||||||
|
|
||||||
data[offset + 3] = 255;
|
data[offset + 3] = 255;
|
||||||
data[offset + 2] = rgb[(i * 3)];
|
data[offset + 2] = rgb[( i * 3 )];
|
||||||
data[offset + 1] = rgb[(i * 3) + 1];
|
data[offset + 1] = rgb[( i * 3 ) + 1];
|
||||||
data[offset ] = rgb[(i * 3) + 2];
|
data[offset ] = rgb[( i * 3 ) + 2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(rgb);
|
free ( rgb );
|
||||||
|
|
||||||
jpeg_finish_decompress(cinfo);
|
jpeg_finish_decompress ( cinfo );
|
||||||
jpeg_destroy_decompress(cinfo);
|
jpeg_destroy_decompress ( cinfo );
|
||||||
|
|
||||||
cairo_surface_mark_dirty(surface);
|
cairo_surface_mark_dirty ( surface );
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cairo_surface_t* cairo_image_surface_create_from_jpeg(const char* file) {
|
static cairo_surface_t* cairo_image_surface_create_from_jpeg ( const char* file )
|
||||||
|
{
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
struct jpeg_error_mgr jerr;
|
struct jpeg_error_mgr jerr;
|
||||||
cairo_surface_t* surface;
|
cairo_surface_t * surface;
|
||||||
FILE* infile;
|
FILE * infile;
|
||||||
|
|
||||||
if((infile = fopen(file, "rb")) == NULL) return NULL;
|
if ( ( infile = fopen ( file, "rb" ) ) == NULL ) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
cinfo.err = jpeg_std_error(&jerr);
|
cinfo.err = jpeg_std_error ( &jerr );
|
||||||
|
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress ( &cinfo );
|
||||||
jpeg_stdio_src(&cinfo, infile);
|
jpeg_stdio_src ( &cinfo, infile );
|
||||||
|
|
||||||
surface = cairo_image_surface_create_from_jpeg_private(&cinfo);
|
surface = cairo_image_surface_create_from_jpeg_private ( &cinfo );
|
||||||
|
|
||||||
fclose(infile);
|
fclose ( infile );
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
@ -235,29 +237,26 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
||||||
}
|
}
|
||||||
if ( icon_surf ) {
|
if ( icon_surf ) {
|
||||||
if ( cairo_surface_status ( icon_surf ) == CAIRO_STATUS_SUCCESS ) {
|
if ( cairo_surface_status ( icon_surf ) == CAIRO_STATUS_SUCCESS ) {
|
||||||
float sw = sentry->size/(float)cairo_image_surface_get_width( icon_surf );
|
float sw = sentry->size / (float) cairo_image_surface_get_width ( icon_surf );
|
||||||
float sh = sentry->size/(float)cairo_image_surface_get_height( icon_surf );
|
float sh = sentry->size / (float) cairo_image_surface_get_height ( icon_surf );
|
||||||
|
|
||||||
float scale = ( sw > sh)? sh:sw;
|
float scale = ( sw > sh ) ? sh : sw;
|
||||||
if ( scale < 0.5 )
|
if ( scale < 0.5 ) {
|
||||||
{
|
cairo_surface_t * surface = cairo_image_surface_create (
|
||||||
cairo_surface_t * surface = cairo_image_surface_create(
|
cairo_image_surface_get_format ( icon_surf ),
|
||||||
cairo_image_surface_get_format( icon_surf ),
|
cairo_image_surface_get_width ( icon_surf ) * scale,
|
||||||
cairo_image_surface_get_width( icon_surf )*scale,
|
cairo_image_surface_get_height ( icon_surf ) * scale );
|
||||||
cairo_image_surface_get_height( icon_surf )*scale);
|
|
||||||
|
|
||||||
cairo_t *d = cairo_create ( surface );
|
cairo_t *d = cairo_create ( surface );
|
||||||
cairo_scale ( d, scale, scale );
|
cairo_scale ( d, scale, scale );
|
||||||
cairo_set_source_surface ( d, icon_surf, 0.0,0.0);
|
cairo_set_source_surface ( d, icon_surf, 0.0, 0.0 );
|
||||||
cairo_pattern_set_filter (cairo_get_source (d), CAIRO_FILTER_FAST);
|
cairo_pattern_set_filter ( cairo_get_source ( d ), CAIRO_FILTER_FAST );
|
||||||
cairo_paint ( d );
|
cairo_paint ( d );
|
||||||
|
|
||||||
cairo_destroy ( d );
|
cairo_destroy ( d );
|
||||||
cairo_surface_destroy ( icon_surf );
|
cairo_surface_destroy ( icon_surf );
|
||||||
icon_surf = surface;
|
icon_surf = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// check if surface is valid.
|
// check if surface is valid.
|
||||||
if ( cairo_surface_status ( icon_surf ) != CAIRO_STATUS_SUCCESS ) {
|
if ( cairo_surface_status ( icon_surf ) != CAIRO_STATUS_SUCCESS ) {
|
||||||
|
|
|
@ -193,9 +193,9 @@ static void run_switcher ( ModeMode mode )
|
||||||
RofiViewState * state = rofi_view_create ( modi[mode], config.filter, 0, process_result );
|
RofiViewState * state = rofi_view_create ( modi[mode], config.filter, 0, process_result );
|
||||||
|
|
||||||
// User can pre-select a row.
|
// User can pre-select a row.
|
||||||
if ( find_arg ( "-selected-row" ) >= 0 ){
|
if ( find_arg ( "-selected-row" ) >= 0 ) {
|
||||||
unsigned int sr = 0;
|
unsigned int sr = 0;
|
||||||
find_arg_uint ( "-selected-row", &(sr) );
|
find_arg_uint ( "-selected-row", &( sr ) );
|
||||||
rofi_view_set_selected_line ( state, sr );
|
rofi_view_set_selected_line ( state, sr );
|
||||||
}
|
}
|
||||||
if ( state ) {
|
if ( state ) {
|
||||||
|
@ -565,7 +565,7 @@ static void rofi_collect_modi ( void )
|
||||||
g_debug ( "Parse plugin path: %s", config.plugin_path );
|
g_debug ( "Parse plugin path: %s", config.plugin_path );
|
||||||
rofi_collect_modi_dir ( config.plugin_path );
|
rofi_collect_modi_dir ( config.plugin_path );
|
||||||
/* ROFI_PLUGIN_PATH */
|
/* ROFI_PLUGIN_PATH */
|
||||||
const char *path = g_getenv("ROFI_PLUGIN_PATH");
|
const char *path = g_getenv ( "ROFI_PLUGIN_PATH" );
|
||||||
if ( path != NULL ) {
|
if ( path != NULL ) {
|
||||||
gchar ** paths = g_strsplit ( path, ":", -1 );
|
gchar ** paths = g_strsplit ( path, ":", -1 );
|
||||||
for ( unsigned int i = 0; paths[i]; i++ ) {
|
for ( unsigned int i = 0; paths[i]; i++ ) {
|
||||||
|
@ -789,7 +789,7 @@ int main ( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char *ro_pid = g_getenv("ROFI_OUTSIDE");
|
const char *ro_pid = g_getenv ( "ROFI_OUTSIDE" );
|
||||||
if ( ro_pid != NULL ) {
|
if ( ro_pid != NULL ) {
|
||||||
int ro_pidi = g_ascii_strtoll ( ro_pid, NULL, 0 );
|
int ro_pidi = g_ascii_strtoll ( ro_pid, NULL, 0 );
|
||||||
if ( kill ( ro_pidi, 0 ) == 0 ) {
|
if ( kill ( ro_pidi, 0 ) == 0 ) {
|
||||||
|
@ -881,10 +881,9 @@ int main ( int argc, char *argv[] )
|
||||||
if ( find_arg ( "-no-config" ) < 0 ) {
|
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||||
// Load distro default settings
|
// Load distro default settings
|
||||||
gboolean found_system = FALSE;
|
gboolean found_system = FALSE;
|
||||||
const char * const * dirs = g_get_system_config_dirs();
|
const char * const * dirs = g_get_system_config_dirs ();
|
||||||
if ( dirs )
|
if ( dirs ) {
|
||||||
{
|
for ( unsigned int i = 0; !found_system && dirs[i]; i++ ) {
|
||||||
for ( unsigned int i =0; !found_system && dirs[i]; i++ ) {
|
|
||||||
/** New format. */
|
/** New format. */
|
||||||
gchar *etc = g_build_filename ( dirs[i], "rofi.rasi", NULL );
|
gchar *etc = g_build_filename ( dirs[i], "rofi.rasi", NULL );
|
||||||
g_debug ( "Look for default config file: %s", etc );
|
g_debug ( "Look for default config file: %s", etc );
|
||||||
|
@ -892,7 +891,8 @@ int main ( int argc, char *argv[] )
|
||||||
g_debug ( "Parsing: %s", etc );
|
g_debug ( "Parsing: %s", etc );
|
||||||
rofi_theme_parse_file ( etc );
|
rofi_theme_parse_file ( etc );
|
||||||
found_system = TRUE;
|
found_system = TRUE;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/** Old format. */
|
/** Old format. */
|
||||||
gchar *xetc = g_build_filename ( dirs[i], "rofi.conf", NULL );
|
gchar *xetc = g_build_filename ( dirs[i], "rofi.conf", NULL );
|
||||||
g_debug ( "Look for default config file: %s", xetc );
|
g_debug ( "Look for default config file: %s", xetc );
|
||||||
|
@ -906,14 +906,15 @@ int main ( int argc, char *argv[] )
|
||||||
g_free ( etc );
|
g_free ( etc );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! found_system ) {
|
if ( !found_system ) {
|
||||||
/** New format. */
|
/** New format. */
|
||||||
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.rasi", NULL );
|
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.rasi", NULL );
|
||||||
g_debug ( "Look for default config file: %s", etc );
|
g_debug ( "Look for default config file: %s", etc );
|
||||||
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
|
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
|
||||||
g_debug ( "Look for default config file: %s", etc );
|
g_debug ( "Look for default config file: %s", etc );
|
||||||
rofi_theme_parse_file ( etc );
|
rofi_theme_parse_file ( etc );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/** Old format. */
|
/** Old format. */
|
||||||
gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
|
gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
|
||||||
g_debug ( "Look for default config file: %s", xetc );
|
g_debug ( "Look for default config file: %s", xetc );
|
||||||
|
|
111
source/theme.c
111
source/theme.c
|
@ -84,7 +84,7 @@ Property *rofi_theme_property_create ( PropertyType type )
|
||||||
|
|
||||||
static RofiDistanceUnit *rofi_theme_property_copy_distance_unit ( RofiDistanceUnit *unit )
|
static RofiDistanceUnit *rofi_theme_property_copy_distance_unit ( RofiDistanceUnit *unit )
|
||||||
{
|
{
|
||||||
RofiDistanceUnit *retv = g_slice_new0( RofiDistanceUnit );
|
RofiDistanceUnit *retv = g_slice_new0 ( RofiDistanceUnit );
|
||||||
*retv = *unit;
|
*retv = *unit;
|
||||||
if ( unit->left ) {
|
if ( unit->left ) {
|
||||||
retv->left = rofi_theme_property_copy_distance_unit ( unit->left );
|
retv->left = rofi_theme_property_copy_distance_unit ( unit->left );
|
||||||
|
@ -97,12 +97,10 @@ static RofiDistanceUnit *rofi_theme_property_copy_distance_unit ( RofiDistanceU
|
||||||
RofiDistance rofi_theme_property_copy_distance ( RofiDistance const distance )
|
RofiDistance rofi_theme_property_copy_distance ( RofiDistance const distance )
|
||||||
{
|
{
|
||||||
RofiDistance retv = distance;
|
RofiDistance retv = distance;
|
||||||
if ( distance.base.left )
|
if ( distance.base.left ) {
|
||||||
{
|
|
||||||
retv.base.left = rofi_theme_property_copy_distance_unit ( distance.base.left );
|
retv.base.left = rofi_theme_property_copy_distance_unit ( distance.base.left );
|
||||||
}
|
}
|
||||||
if ( distance.base.right )
|
if ( distance.base.right ) {
|
||||||
{
|
|
||||||
retv.base.right = rofi_theme_property_copy_distance_unit ( distance.base.right );
|
retv.base.right = rofi_theme_property_copy_distance_unit ( distance.base.right );
|
||||||
}
|
}
|
||||||
return retv;
|
return retv;
|
||||||
|
@ -131,10 +129,10 @@ Property* rofi_theme_property_copy ( Property *p )
|
||||||
case P_PADDING:
|
case P_PADDING:
|
||||||
{
|
{
|
||||||
retv->value = p->value;
|
retv->value = p->value;
|
||||||
retv->value.padding.top = rofi_theme_property_copy_distance ( p->value.padding.top);
|
retv->value.padding.top = rofi_theme_property_copy_distance ( p->value.padding.top );
|
||||||
retv->value.padding.left = rofi_theme_property_copy_distance ( p->value.padding.left);
|
retv->value.padding.left = rofi_theme_property_copy_distance ( p->value.padding.left );
|
||||||
retv->value.padding.bottom = rofi_theme_property_copy_distance ( p->value.padding.bottom);
|
retv->value.padding.bottom = rofi_theme_property_copy_distance ( p->value.padding.bottom );
|
||||||
retv->value.padding.right = rofi_theme_property_copy_distance ( p->value.padding.right);
|
retv->value.padding.right = rofi_theme_property_copy_distance ( p->value.padding.right );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -153,7 +151,7 @@ static void rofi_theme_distance_unit_property_free ( RofiDistanceUnit *unit )
|
||||||
rofi_theme_distance_unit_property_free ( unit->right );
|
rofi_theme_distance_unit_property_free ( unit->right );
|
||||||
unit->right = NULL;
|
unit->right = NULL;
|
||||||
}
|
}
|
||||||
g_slice_free ( RofiDistanceUnit, unit);
|
g_slice_free ( RofiDistanceUnit, unit );
|
||||||
}
|
}
|
||||||
static void rofi_theme_distance_property_free ( RofiDistance *distance )
|
static void rofi_theme_distance_property_free ( RofiDistance *distance )
|
||||||
{
|
{
|
||||||
|
@ -182,11 +180,11 @@ void rofi_theme_property_free ( Property *p )
|
||||||
rofi_theme_property_free ( p->value.link.def_value );
|
rofi_theme_property_free ( p->value.link.def_value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( p->type == P_PADDING) {
|
if ( p->type == P_PADDING ) {
|
||||||
rofi_theme_distance_property_free( &(p->value.padding.top));
|
rofi_theme_distance_property_free ( &( p->value.padding.top ) );
|
||||||
rofi_theme_distance_property_free( &(p->value.padding.right));
|
rofi_theme_distance_property_free ( &( p->value.padding.right ) );
|
||||||
rofi_theme_distance_property_free( &(p->value.padding.bottom));
|
rofi_theme_distance_property_free ( &( p->value.padding.bottom ) );
|
||||||
rofi_theme_distance_property_free( &(p->value.padding.left));
|
rofi_theme_distance_property_free ( &( p->value.padding.left ) );
|
||||||
}
|
}
|
||||||
g_slice_free ( Property, p );
|
g_slice_free ( Property, p );
|
||||||
}
|
}
|
||||||
|
@ -216,7 +214,7 @@ static void rofi_theme_insert_listview_backwards_fix ( void )
|
||||||
|
|
||||||
rofi_theme_widget_add_properties ( tt, table );
|
rofi_theme_widget_add_properties ( tt, table );
|
||||||
|
|
||||||
RofiDistance dsize = (RofiDistance){ .base = {1.2, ROFI_PU_CH, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, .style = ROFI_HL_SOLID };
|
RofiDistance dsize = (RofiDistance){ .base = { 1.2, ROFI_PU_CH, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, .style = ROFI_HL_SOLID };
|
||||||
Property *pts = rofi_theme_property_create ( P_PADDING );
|
Property *pts = rofi_theme_property_create ( P_PADDING );
|
||||||
pts->value.padding.top = pts->value.padding.right = pts->value.padding.bottom = pts->value.padding.left = dsize;
|
pts->value.padding.top = pts->value.padding.right = pts->value.padding.bottom = pts->value.padding.left = dsize;
|
||||||
pts->name = g_strdup ( "size" );
|
pts->name = g_strdup ( "size" );
|
||||||
|
@ -229,7 +227,7 @@ static void rofi_theme_insert_listview_backwards_fix ( void )
|
||||||
table = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify) rofi_theme_property_free );
|
table = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify) rofi_theme_property_free );
|
||||||
Property *psp = rofi_theme_property_create ( P_PADDING );
|
Property *psp = rofi_theme_property_create ( P_PADDING );
|
||||||
psp->name = g_strdup ( "spacing" );
|
psp->name = g_strdup ( "spacing" );
|
||||||
RofiDistance d = (RofiDistance){ .base = {5, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, .style = ROFI_HL_SOLID };
|
RofiDistance d = (RofiDistance){ .base = { 5, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, .style = ROFI_HL_SOLID };
|
||||||
psp->value.padding = (RofiPadding){ d, d, d, d };
|
psp->value.padding = (RofiPadding){ d, d, d, d };
|
||||||
g_hash_table_replace ( table, psp->name, psp );
|
g_hash_table_replace ( table, psp->name, psp );
|
||||||
rofi_theme_widget_add_properties ( t, table );
|
rofi_theme_widget_add_properties ( t, table );
|
||||||
|
@ -277,27 +275,33 @@ inline static void printf_double ( double d )
|
||||||
|
|
||||||
static void rofi_theme_print_distance_unit ( RofiDistanceUnit *unit )
|
static void rofi_theme_print_distance_unit ( RofiDistanceUnit *unit )
|
||||||
{
|
{
|
||||||
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP )
|
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP ) {
|
||||||
fputs("( " , stdout);
|
fputs ( "( ", stdout );
|
||||||
if ( unit->left )
|
}
|
||||||
|
if ( unit->left ) {
|
||||||
rofi_theme_print_distance_unit ( unit->left );
|
rofi_theme_print_distance_unit ( unit->left );
|
||||||
|
}
|
||||||
|
|
||||||
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_ADD ) {
|
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_ADD ) {
|
||||||
fputs ( " + ", stdout );
|
fputs ( " + ", stdout );
|
||||||
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_SUBTRACT ) {
|
}
|
||||||
|
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_SUBTRACT ) {
|
||||||
fputs ( " - ", stdout );
|
fputs ( " - ", stdout );
|
||||||
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_DIVIDE ) {
|
}
|
||||||
|
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_DIVIDE ) {
|
||||||
fputs ( " / ", stdout );
|
fputs ( " / ", stdout );
|
||||||
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MULTIPLY) {
|
}
|
||||||
|
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MULTIPLY ) {
|
||||||
fputs ( " * ", stdout );
|
fputs ( " * ", stdout );
|
||||||
} else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MODULO) {
|
}
|
||||||
|
else if ( unit->modtype == ROFI_DISTANCE_MODIFIER_MODULO ) {
|
||||||
fputs ( " % ", stdout );
|
fputs ( " % ", stdout );
|
||||||
}
|
}
|
||||||
if ( unit->right )
|
if ( unit->right ) {
|
||||||
rofi_theme_print_distance_unit ( unit->right );
|
rofi_theme_print_distance_unit ( unit->right );
|
||||||
|
}
|
||||||
|
|
||||||
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_NONE )
|
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_NONE ) {
|
||||||
{
|
|
||||||
if ( unit->type == ROFI_PU_PX ) {
|
if ( unit->type == ROFI_PU_PX ) {
|
||||||
printf ( "%upx ", (unsigned int) unit->distance );
|
printf ( "%upx ", (unsigned int) unit->distance );
|
||||||
}
|
}
|
||||||
|
@ -318,18 +322,19 @@ static void rofi_theme_print_distance_unit ( RofiDistanceUnit *unit )
|
||||||
fputs ( "em ", stdout );
|
fputs ( "em ", stdout );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP )
|
if ( unit->modtype == ROFI_DISTANCE_MODIFIER_GROUP ) {
|
||||||
fputs(" )" , stdout);
|
fputs ( " )", stdout );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rofi_theme_print_distance ( RofiDistance d )
|
static void rofi_theme_print_distance ( RofiDistance d )
|
||||||
{
|
{
|
||||||
if ( d.base.modtype == ROFI_DISTANCE_MODIFIER_GROUP ){
|
if ( d.base.modtype == ROFI_DISTANCE_MODIFIER_GROUP ) {
|
||||||
fputs( "calc( ", stdout );
|
fputs ( "calc( ", stdout );
|
||||||
}
|
}
|
||||||
rofi_theme_print_distance_unit ( &(d.base) );
|
rofi_theme_print_distance_unit ( &( d.base ) );
|
||||||
if ( d.base.modtype == ROFI_DISTANCE_MODIFIER_GROUP ){
|
if ( d.base.modtype == ROFI_DISTANCE_MODIFIER_GROUP ) {
|
||||||
fputs( ")", stdout );
|
fputs ( ")", stdout );
|
||||||
}
|
}
|
||||||
if ( d.style == ROFI_HL_DASH ) {
|
if ( d.style == ROFI_HL_DASH ) {
|
||||||
printf ( "dash " );
|
printf ( "dash " );
|
||||||
|
@ -746,17 +751,17 @@ RofiDistance rofi_theme_get_distance ( const widget *widget, const char *propert
|
||||||
if ( widget->parent ) {
|
if ( widget->parent ) {
|
||||||
return rofi_theme_get_distance ( widget->parent, property, def );
|
return rofi_theme_get_distance ( widget->parent, property, def );
|
||||||
}
|
}
|
||||||
return (RofiDistance){ .base = {def, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, .style = ROFI_HL_SOLID };
|
return (RofiDistance){ .base = { def, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, .style = ROFI_HL_SOLID };
|
||||||
}
|
}
|
||||||
if ( p->type == P_INTEGER ) {
|
if ( p->type == P_INTEGER ) {
|
||||||
return (RofiDistance){ .base = { p->value.i, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, .style = ROFI_HL_SOLID };
|
return (RofiDistance){ .base = { p->value.i, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, .style = ROFI_HL_SOLID };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return p->value.padding.left;
|
return p->value.padding.left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
||||||
return (RofiDistance){ .base = {def, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, .style = ROFI_HL_SOLID };
|
return (RofiDistance){ .base = { def, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, .style = ROFI_HL_SOLID };
|
||||||
}
|
}
|
||||||
|
|
||||||
int rofi_theme_get_boolean ( const widget *widget, const char *property, int def )
|
int rofi_theme_get_boolean ( const widget *widget, const char *property, int def )
|
||||||
|
@ -872,7 +877,7 @@ RofiPadding rofi_theme_get_padding ( const widget *widget, const char *property,
|
||||||
pad = p->value.padding;
|
pad = p->value.padding;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RofiDistance d = (RofiDistance){ .base = {p->value.i, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL}, .style = ROFI_HL_SOLID };
|
RofiDistance d = (RofiDistance){ .base = { p->value.i, ROFI_PU_PX, ROFI_DISTANCE_MODIFIER_NONE, NULL, NULL }, .style = ROFI_HL_SOLID };
|
||||||
return (RofiPadding){ d, d, d, d };
|
return (RofiPadding){ d, d, d, d };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -927,7 +932,6 @@ static int get_pixels ( RofiDistanceUnit *unit, RofiOrientation ori )
|
||||||
{
|
{
|
||||||
int val = unit->distance;
|
int val = unit->distance;
|
||||||
|
|
||||||
|
|
||||||
if ( unit->type == ROFI_PU_EM ) {
|
if ( unit->type == ROFI_PU_EM ) {
|
||||||
val = unit->distance * textbox_get_estimated_char_height ();
|
val = unit->distance * textbox_get_estimated_char_height ();
|
||||||
}
|
}
|
||||||
|
@ -952,35 +956,34 @@ static int get_pixels ( RofiDistanceUnit *unit, RofiOrientation ori )
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int distance_unit_get_pixel ( RofiDistanceUnit *unit, RofiOrientation ori )
|
static int distance_unit_get_pixel ( RofiDistanceUnit *unit, RofiOrientation ori )
|
||||||
{
|
{
|
||||||
switch ( unit->modtype)
|
switch ( unit->modtype )
|
||||||
{
|
{
|
||||||
case ROFI_DISTANCE_MODIFIER_GROUP:
|
case ROFI_DISTANCE_MODIFIER_GROUP:
|
||||||
return distance_unit_get_pixel ( unit->left, ori );
|
return distance_unit_get_pixel ( unit->left, ori );
|
||||||
break;
|
break;
|
||||||
case ROFI_DISTANCE_MODIFIER_ADD:
|
case ROFI_DISTANCE_MODIFIER_ADD:
|
||||||
return distance_unit_get_pixel ( unit->left, ori)+ distance_unit_get_pixel ( unit->right, ori);
|
return distance_unit_get_pixel ( unit->left, ori ) + distance_unit_get_pixel ( unit->right, ori );
|
||||||
case ROFI_DISTANCE_MODIFIER_SUBTRACT:
|
case ROFI_DISTANCE_MODIFIER_SUBTRACT:
|
||||||
return distance_unit_get_pixel ( unit->left, ori)- distance_unit_get_pixel ( unit->right, ori);
|
return distance_unit_get_pixel ( unit->left, ori ) - distance_unit_get_pixel ( unit->right, ori );
|
||||||
case ROFI_DISTANCE_MODIFIER_MULTIPLY:
|
case ROFI_DISTANCE_MODIFIER_MULTIPLY:
|
||||||
return distance_unit_get_pixel ( unit->left, ori)* distance_unit_get_pixel ( unit->right, ori);
|
return distance_unit_get_pixel ( unit->left, ori ) * distance_unit_get_pixel ( unit->right, ori );
|
||||||
case ROFI_DISTANCE_MODIFIER_DIVIDE:
|
case ROFI_DISTANCE_MODIFIER_DIVIDE:
|
||||||
{
|
{
|
||||||
int a = distance_unit_get_pixel ( unit->left, ori);
|
int a = distance_unit_get_pixel ( unit->left, ori );
|
||||||
int b = distance_unit_get_pixel ( unit->right, ori);
|
int b = distance_unit_get_pixel ( unit->right, ori );
|
||||||
if ( b != 0 ) {
|
if ( b != 0 ) {
|
||||||
return a/b;
|
return a / b;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
case ROFI_DISTANCE_MODIFIER_MODULO:
|
case ROFI_DISTANCE_MODIFIER_MODULO:
|
||||||
{
|
{
|
||||||
int a = distance_unit_get_pixel ( unit->left, ori);
|
int a = distance_unit_get_pixel ( unit->left, ori );
|
||||||
int b = distance_unit_get_pixel ( unit->right, ori);
|
int b = distance_unit_get_pixel ( unit->right, ori );
|
||||||
if ( b != 0 ) {
|
if ( b != 0 ) {
|
||||||
return a%b;
|
return a % b;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -990,10 +993,9 @@ static int distance_unit_get_pixel ( RofiDistanceUnit *unit, RofiOrientation ori
|
||||||
return get_pixels ( unit, ori );
|
return get_pixels ( unit, ori );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int distance_get_pixel ( RofiDistance d, RofiOrientation ori )
|
int distance_get_pixel ( RofiDistance d, RofiOrientation ori )
|
||||||
{
|
{
|
||||||
return distance_unit_get_pixel ( &(d.base), ori);
|
return distance_unit_get_pixel ( &( d.base ), ori );
|
||||||
}
|
}
|
||||||
|
|
||||||
void distance_get_linestyle ( RofiDistance d, cairo_t *draw )
|
void distance_get_linestyle ( RofiDistance d, cairo_t *draw )
|
||||||
|
@ -1017,8 +1019,8 @@ gboolean rofi_theme_is_empty ( void )
|
||||||
}
|
}
|
||||||
if ( rofi_theme->num_widgets == 3 ) {
|
if ( rofi_theme->num_widgets == 3 ) {
|
||||||
// HACK: check for default added elements.
|
// HACK: check for default added elements.
|
||||||
for ( unsigned int i = 0; i < rofi_theme->num_widgets;i++) {
|
for ( unsigned int i = 0; i < rofi_theme->num_widgets; i++ ) {
|
||||||
if ( strncmp ( rofi_theme->widgets[i]->name, "element", 7) != 0 ){
|
if ( strncmp ( rofi_theme->widgets[i]->name, "element", 7 ) != 0 ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1321,6 @@ ThemeMediaType rofi_theme_parse_media_type ( const char *type )
|
||||||
return THEME_MEDIA_TYPE_INVALID;
|
return THEME_MEDIA_TYPE_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean rofi_theme_has_property ( const widget *widget, const char *property )
|
gboolean rofi_theme_has_property ( const widget *widget, const char *property )
|
||||||
{
|
{
|
||||||
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
|
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
|
||||||
|
|
|
@ -223,12 +223,12 @@ void rofi_capture_screenshot ( void )
|
||||||
g_date_time_unref ( now );
|
g_date_time_unref ( now );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code used for benchmarking drawing the gui, this will keep updating the UI as fast as possible.
|
* Code used for benchmarking drawing the gui, this will keep updating the UI as fast as possible.
|
||||||
*/
|
*/
|
||||||
gboolean do_bench = TRUE;
|
gboolean do_bench = TRUE;
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
GTimer *time;
|
GTimer *time;
|
||||||
uint64_t draws;
|
uint64_t draws;
|
||||||
double last_ts;
|
double last_ts;
|
||||||
|
@ -247,17 +247,17 @@ static gboolean bench_update ( void )
|
||||||
}
|
}
|
||||||
BenchMark.draws++;
|
BenchMark.draws++;
|
||||||
if ( BenchMark.time == NULL ) {
|
if ( BenchMark.time == NULL ) {
|
||||||
BenchMark.time = g_timer_new();
|
BenchMark.time = g_timer_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (BenchMark.draws & 1023) == 0 ){
|
if ( ( BenchMark.draws & 1023 ) == 0 ) {
|
||||||
double ts = g_timer_elapsed(BenchMark.time, NULL);
|
double ts = g_timer_elapsed ( BenchMark.time, NULL );
|
||||||
double fps = 1024/(ts-BenchMark.last_ts);
|
double fps = 1024 / ( ts - BenchMark.last_ts );
|
||||||
|
|
||||||
if ( fps < BenchMark.min ) {
|
if ( fps < BenchMark.min ) {
|
||||||
BenchMark.min = fps;
|
BenchMark.min = fps;
|
||||||
}
|
}
|
||||||
printf("current: %.2f fps, avg: %.2f fps, min: %.2f fps, %lu draws\r\n", fps, BenchMark.draws/ts, BenchMark.min, BenchMark.draws);
|
printf ( "current: %.2f fps, avg: %.2f fps, min: %.2f fps, %lu draws\r\n", fps, BenchMark.draws / ts, BenchMark.min, BenchMark.draws );
|
||||||
|
|
||||||
BenchMark.last_ts = ts;
|
BenchMark.last_ts = ts;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ static gboolean rofi_view_repaint ( G_GNUC_UNUSED void * data )
|
||||||
TICK_N ( "flush" );
|
TICK_N ( "flush" );
|
||||||
CacheState.repaint_source = 0;
|
CacheState.repaint_source = 0;
|
||||||
}
|
}
|
||||||
return (bench_update () == TRUE )? G_SOURCE_CONTINUE:G_SOURCE_REMOVE;
|
return ( bench_update () == TRUE ) ? G_SOURCE_CONTINUE : G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rofi_view_update_prompt ( RofiViewState *state )
|
static void rofi_view_update_prompt ( RofiViewState *state )
|
||||||
|
@ -785,7 +785,8 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
|
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
|
||||||
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, dpi );
|
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, dpi );
|
||||||
config.dpi = dpi;
|
config.dpi = dpi;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// default pango is 96.
|
// default pango is 96.
|
||||||
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
|
PangoFontMap *font_map = pango_cairo_font_map_get_default ();
|
||||||
config.dpi = pango_cairo_font_map_get_resolution ( (PangoCairoFontMap *) font_map );
|
config.dpi = pango_cairo_font_map_get_resolution ( (PangoCairoFontMap *) font_map );
|
||||||
|
|
|
@ -231,7 +231,9 @@ static void hori_calculate_size ( box *b )
|
||||||
int left = widget_padding_get_left ( WIDGET ( b ) );
|
int left = widget_padding_get_left ( WIDGET ( b ) );
|
||||||
double rem = rem_width - b->max_size;
|
double rem = rem_width - b->max_size;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if ( rem < 0 ) rem = 0;
|
if ( rem < 0 ) {
|
||||||
|
rem = 0;
|
||||||
|
}
|
||||||
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
widget * child = (widget *) iter->data;
|
widget * child = (widget *) iter->data;
|
||||||
if ( child->enabled == FALSE ) {
|
if ( child->enabled == FALSE ) {
|
||||||
|
@ -332,7 +334,7 @@ static widget *box_find_mouse_target ( widget *wid, WidgetType type, gint x, gin
|
||||||
|
|
||||||
static void box_set_state ( widget *wid, const char *state )
|
static void box_set_state ( widget *wid, const char *state )
|
||||||
{
|
{
|
||||||
for ( GList *iter = g_list_first ( ((box*)wid)->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( ( (box *) wid )->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
widget * child = (widget *) iter->data;
|
widget * child = (widget *) iter->data;
|
||||||
widget_set_state ( child, state );
|
widget_set_state ( child, state );
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@
|
||||||
/**
|
/**
|
||||||
* Orientation of the listview
|
* Orientation of the listview
|
||||||
*/
|
*/
|
||||||
/** Vertical (classical) list */
|
/** Vertical (classical) list */
|
||||||
#define LISTVIEW ROFI_ORIENTATION_VERTICAL
|
#define LISTVIEW ROFI_ORIENTATION_VERTICAL
|
||||||
/** Horizontal list. (barview) */
|
/** Horizontal list. (barview) */
|
||||||
#define BARVIEW ROFI_ORIENTATION_HORIZONTAL
|
#define BARVIEW ROFI_ORIENTATION_HORIZONTAL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,7 +143,7 @@ const char *const listview_theme_prop_names[][3] = {
|
||||||
|
|
||||||
static void listview_set_state ( _listview_row r, TextBoxFontType tbft )
|
static void listview_set_state ( _listview_row r, TextBoxFontType tbft )
|
||||||
{
|
{
|
||||||
widget *w = WIDGET(r.box);
|
widget *w = WIDGET ( r.box );
|
||||||
TextBoxFontType t = tbft & STATE_MASK;
|
TextBoxFontType t = tbft & STATE_MASK;
|
||||||
if ( w == NULL ) {
|
if ( w == NULL ) {
|
||||||
return;
|
return;
|
||||||
|
@ -171,25 +171,25 @@ static void listview_add_widget ( listview *lv, _listview_row *row, widget *wid,
|
||||||
if ( strcasecmp ( label, "element-icon" ) == 0 ) {
|
if ( strcasecmp ( label, "element-icon" ) == 0 ) {
|
||||||
if ( config.show_icons ) {
|
if ( config.show_icons ) {
|
||||||
row->icon = icon_create ( WIDGET ( wid ), "element-icon" );
|
row->icon = icon_create ( WIDGET ( wid ), "element-icon" );
|
||||||
box_add ( (box *)wid, WIDGET ( row->icon ), FALSE );
|
box_add ( (box *) wid, WIDGET ( row->icon ), FALSE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( strcasecmp ( label, "element-text" ) == 0 ) {
|
else if ( strcasecmp ( label, "element-text" ) == 0 ) {
|
||||||
row->textbox = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT | flags, NORMAL, "DDD", 0, 0 );
|
row->textbox = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT | flags, NORMAL, "DDD", 0, 0 );
|
||||||
box_add ( (box *)wid, WIDGET ( row->textbox ), TRUE );
|
box_add ( (box *) wid, WIDGET ( row->textbox ), TRUE );
|
||||||
}
|
}
|
||||||
else if ( strcasecmp ( label, "element-index" ) == 0 ) {
|
else if ( strcasecmp ( label, "element-index" ) == 0 ) {
|
||||||
row->index = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
|
row->index = textbox_create ( WIDGET ( wid ), WIDGET_TYPE_TEXTBOX_TEXT, "element-text", TB_AUTOHEIGHT, NORMAL, " ", 0, 0 );
|
||||||
box_add ( (box *)wid, WIDGET ( row->index ), FALSE );
|
box_add ( (box *) wid, WIDGET ( row->index ), FALSE );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
widget *wid2 = (widget *) box_create ( wid, label, ROFI_ORIENTATION_VERTICAL );
|
widget *wid2 = (widget *) box_create ( wid, label, ROFI_ORIENTATION_VERTICAL );
|
||||||
box_add ( (box *) wid, WIDGET ( wid2 ), TRUE );
|
box_add ( (box *) wid, WIDGET ( wid2 ), TRUE );
|
||||||
GList *list = rofi_theme_get_list ( WIDGET ( wid2 ), "children", "" );
|
GList *list = rofi_theme_get_list ( WIDGET ( wid2 ), "children", "" );
|
||||||
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
listview_add_widget ( lv,row, wid2, (const char *)iter->data );
|
listview_add_widget ( lv, row, wid2, (const char *) iter->data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void listview_create_row ( listview *lv, _listview_row *row )
|
static void listview_create_row ( listview *lv, _listview_row *row )
|
||||||
|
@ -203,7 +203,7 @@ static void listview_create_row ( listview *lv, _listview_row *row )
|
||||||
row->index = NULL;
|
row->index = NULL;
|
||||||
|
|
||||||
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
|
for ( GList *iter = g_list_first ( list ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||||
listview_add_widget ( lv,row, WIDGET(row->box), (const char *)iter->data );
|
listview_add_widget ( lv, row, WIDGET ( row->box ), (const char *) iter->data );
|
||||||
}
|
}
|
||||||
g_list_free_full ( list, g_free );
|
g_list_free_full ( list, g_free );
|
||||||
}
|
}
|
||||||
|
@ -661,10 +661,13 @@ listview *listview_create ( widget *parent, const char *name, listview_update_ca
|
||||||
listview_create_row ( lv, &row );
|
listview_create_row ( lv, &row );
|
||||||
// FIXME: hack to scale hight correctly.
|
// FIXME: hack to scale hight correctly.
|
||||||
if ( lv->eh > 1 && row.textbox ) {
|
if ( lv->eh > 1 && row.textbox ) {
|
||||||
char buff[lv->eh*2+1] ;
|
char buff[lv->eh * 2 + 1];
|
||||||
memset( buff, '\0', lv->eh*2+1);
|
memset ( buff, '\0', lv->eh * 2 + 1 );
|
||||||
for ( unsigned int i = 0; i < (lv->eh-1); i++) { buff[i*2] = 'a'; buff[i*2+1] ='\n'; };
|
for ( unsigned int i = 0; i < ( lv->eh - 1 ); i++ ) {
|
||||||
textbox_text( row.textbox, buff);
|
buff[i * 2] = 'a'; buff[i * 2 + 1] = '\n';
|
||||||
|
}
|
||||||
|
;
|
||||||
|
textbox_text ( row.textbox, buff );
|
||||||
}
|
}
|
||||||
lv->element_height = widget_get_desired_height ( WIDGET ( row.box ) );
|
lv->element_height = widget_get_desired_height ( WIDGET ( row.box ) );
|
||||||
widget_free ( WIDGET ( row.box ) );
|
widget_free ( WIDGET ( row.box ) );
|
||||||
|
|
|
@ -914,7 +914,7 @@ double textbox_get_estimated_ch ( void )
|
||||||
int textbox_get_estimated_height ( const textbox *tb, int eh )
|
int textbox_get_estimated_height ( const textbox *tb, int eh )
|
||||||
{
|
{
|
||||||
int height = pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics );
|
int height = pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics );
|
||||||
return ceil(( eh * height ) / (double)PANGO_SCALE) + widget_padding_get_padding_height ( WIDGET ( tb ) );
|
return ceil ( ( eh * height ) / (double) PANGO_SCALE ) + widget_padding_get_padding_height ( WIDGET ( tb ) );
|
||||||
}
|
}
|
||||||
int textbox_get_desired_width ( widget *wid )
|
int textbox_get_desired_width ( widget *wid )
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,27 +41,31 @@ static void draw_rounded_rect ( cairo_t * d,
|
||||||
double r0, double r1, double r2, double r3 )
|
double r0, double r1, double r2, double r3 )
|
||||||
{
|
{
|
||||||
if ( r0 > 0 ) {
|
if ( r0 > 0 ) {
|
||||||
cairo_move_to ( d, x1, y1+r0 );
|
cairo_move_to ( d, x1, y1 + r0 );
|
||||||
cairo_arc ( d, x1+r0, y1+r0, r0, -G_PI, -G_PI_2 );
|
cairo_arc ( d, x1 + r0, y1 + r0, r0, -G_PI, -G_PI_2 );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cairo_move_to ( d, x1, y1 );
|
cairo_move_to ( d, x1, y1 );
|
||||||
}
|
}
|
||||||
if ( r1 > 0 ) {
|
if ( r1 > 0 ) {
|
||||||
cairo_line_to ( d, x2-r1, y1 );
|
cairo_line_to ( d, x2 - r1, y1 );
|
||||||
cairo_arc ( d, x2-r1, y1+r1, r1, -G_PI_2, 0.0 );
|
cairo_arc ( d, x2 - r1, y1 + r1, r1, -G_PI_2, 0.0 );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cairo_line_to ( d, x2, y1 );
|
cairo_line_to ( d, x2, y1 );
|
||||||
}
|
}
|
||||||
if ( r2 > 0 ) {
|
if ( r2 > 0 ) {
|
||||||
cairo_line_to ( d, x2, y2-r2 );
|
cairo_line_to ( d, x2, y2 - r2 );
|
||||||
cairo_arc ( d, x2-r2, y2-r2, r2, 0.0, G_PI_2 );
|
cairo_arc ( d, x2 - r2, y2 - r2, r2, 0.0, G_PI_2 );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cairo_line_to ( d, x2, y2 );
|
cairo_line_to ( d, x2, y2 );
|
||||||
}
|
}
|
||||||
if ( r3 > 0 ) {
|
if ( r3 > 0 ) {
|
||||||
cairo_line_to ( d, x1+r3, y2 );
|
cairo_line_to ( d, x1 + r3, y2 );
|
||||||
cairo_arc ( d, x1+r3, y2-r3, r3, G_PI_2, G_PI );
|
cairo_arc ( d, x1 + r3, y2 - r3, r3, G_PI_2, G_PI );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cairo_line_to ( d, x1, y2 );
|
cairo_line_to ( d, x1, y2 );
|
||||||
}
|
}
|
||||||
cairo_close_path ( d );
|
cairo_close_path ( d );
|
||||||
|
@ -277,28 +281,32 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
double radius_int_tl, radius_int_tr, radius_int_br, radius_int_bl;
|
double radius_int_tl, radius_int_tr, radius_int_br, radius_int_bl;
|
||||||
double radius_out_tl, radius_out_tr, radius_out_br, radius_out_bl;
|
double radius_out_tl, radius_out_tr, radius_out_br, radius_out_bl;
|
||||||
|
|
||||||
if (radius_tl > 0) {
|
if ( radius_tl > 0 ) {
|
||||||
radius_out_tl = radius_tl + minof_tl ,
|
radius_out_tl = radius_tl + minof_tl,
|
||||||
radius_int_tl = radius_tl - minof_tl;
|
radius_int_tl = radius_tl - minof_tl;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
radius_out_tl = radius_int_tl = 0;
|
radius_out_tl = radius_int_tl = 0;
|
||||||
}
|
}
|
||||||
if (radius_tr > 0) {
|
if ( radius_tr > 0 ) {
|
||||||
radius_out_tr = radius_tr + minof_tr ,
|
radius_out_tr = radius_tr + minof_tr,
|
||||||
radius_int_tr = radius_tr - minof_tr;
|
radius_int_tr = radius_tr - minof_tr;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
radius_out_tr = radius_int_tr = 0;
|
radius_out_tr = radius_int_tr = 0;
|
||||||
}
|
}
|
||||||
if (radius_br > 0) {
|
if ( radius_br > 0 ) {
|
||||||
radius_out_br = radius_br + minof_br ,
|
radius_out_br = radius_br + minof_br,
|
||||||
radius_int_br = radius_br - minof_br;
|
radius_int_br = radius_br - minof_br;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
radius_out_br = radius_int_br = 0;
|
radius_out_br = radius_int_br = 0;
|
||||||
}
|
}
|
||||||
if (radius_bl > 0) {
|
if ( radius_bl > 0 ) {
|
||||||
radius_out_bl = radius_bl + minof_bl ,
|
radius_out_bl = radius_bl + minof_bl,
|
||||||
radius_int_bl = radius_bl - minof_bl;
|
radius_int_bl = radius_bl - minof_bl;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
radius_out_bl = radius_int_bl = 0;
|
radius_out_bl = radius_int_bl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +424,7 @@ gboolean widget_need_redraw ( widget *wid )
|
||||||
if ( wid == NULL ) {
|
if ( wid == NULL ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ( ! wid->enabled ) {
|
if ( !wid->enabled ) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return wid->need_redraw;
|
return wid->need_redraw;
|
||||||
|
|
Loading…
Reference in a new issue