2017-04-15 10:32:05 +00:00
|
|
|
/*
|
|
|
|
* rofi
|
|
|
|
*
|
|
|
|
* MIT/X11 License
|
|
|
|
* Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-10-24 15:48:04 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <widgets/scrollbar.h>
|
2017-05-30 10:44:41 +00:00
|
|
|
#include <widgets/textbox.h>
|
2019-08-08 18:02:20 +00:00
|
|
|
#include <widgets/icon.h>
|
2017-05-30 10:44:41 +00:00
|
|
|
#include <widgets/listview.h>
|
2016-10-24 15:48:04 +00:00
|
|
|
#include <widgets/widget.h>
|
|
|
|
#include <widgets/widget-internal.h>
|
2017-05-04 12:54:38 +00:00
|
|
|
#include "rofi.h"
|
|
|
|
#include "xrmoptions.h"
|
|
|
|
#include "helper.h"
|
2021-06-15 10:45:02 +00:00
|
|
|
#include "rofi-icon-fetcher.h"
|
2016-10-24 15:48:04 +00:00
|
|
|
unsigned int test =0;
|
|
|
|
#define TASSERT( a ) { \
|
|
|
|
assert ( a ); \
|
2019-02-02 10:17:50 +00:00
|
|
|
printf ( "Test %3u passed (%s)\n", ++test, # a ); \
|
2016-10-24 15:48:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define TASSERTE( a, b ) { \
|
|
|
|
if ( ( a ) == ( b ) ) { \
|
2019-02-02 10:17:50 +00:00
|
|
|
printf ( "Test %u passed (%s == %s) (%u == %u)\n", ++test, # a, # b, a, b ); \
|
2021-08-14 11:03:16 +00:00
|
|
|
} else { \
|
2019-02-02 10:17:50 +00:00
|
|
|
printf ( "Test %u failed (%s == %s) (%u != %u)\n", ++test, # a, # b, a, b ); \
|
2016-10-24 15:48:04 +00:00
|
|
|
abort ( ); \
|
|
|
|
} \
|
|
|
|
}
|
2017-04-17 16:07:50 +00:00
|
|
|
|
2021-06-15 10:31:32 +00:00
|
|
|
ThemeWidget *rofi_configuration = NULL;
|
|
|
|
|
|
|
|
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-06-15 22:11:57 +00:00
|
|
|
uint32_t rofi_icon_fetcher_query_advanced ( const char *name, const int wsize, const int hsize )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2021-06-15 10:31:32 +00:00
|
|
|
|
|
|
|
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-09-27 08:43:29 +00:00
|
|
|
int monitor_active ( G_GNUC_UNUSED workarea *mon )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-17 09:05:03 +00:00
|
|
|
char * helper_get_theme_path ( const char *file, const char *ext )
|
2017-04-17 16:07:50 +00:00
|
|
|
{
|
|
|
|
return g_strdup ( file );
|
|
|
|
}
|
2017-09-17 16:17:26 +00:00
|
|
|
gboolean config_parse_set_property ( G_GNUC_UNUSED const Property *p, G_GNUC_UNUSED char **error )
|
2017-03-28 10:08:14 +00:00
|
|
|
{
|
2017-06-20 19:02:13 +00:00
|
|
|
return FALSE;
|
2017-03-28 10:08:14 +00:00
|
|
|
}
|
2017-05-03 15:57:08 +00:00
|
|
|
void rofi_add_error_message ( G_GNUC_UNUSED GString *msg )
|
2017-01-09 22:15:45 +00:00
|
|
|
{}
|
2016-10-24 15:48:04 +00:00
|
|
|
|
2017-05-03 15:57:08 +00:00
|
|
|
char * rofi_expand_path ( G_GNUC_UNUSED const char *path )
|
2017-03-11 16:06:06 +00:00
|
|
|
{
|
2017-05-03 15:57:08 +00:00
|
|
|
return NULL;
|
2017-03-11 16:06:06 +00:00
|
|
|
}
|
2017-05-30 10:44:41 +00:00
|
|
|
double textbox_get_estimated_char_height ( void )
|
2017-01-01 15:32:01 +00:00
|
|
|
{
|
|
|
|
return 16;
|
|
|
|
}
|
2017-09-05 11:52:21 +00:00
|
|
|
double textbox_get_estimated_ch ( void )
|
|
|
|
{
|
|
|
|
return 8.0;
|
|
|
|
}
|
2016-10-24 15:48:04 +00:00
|
|
|
|
2017-05-30 10:44:41 +00:00
|
|
|
void listview_set_selected ( G_GNUC_UNUSED listview *lv, G_GNUC_UNUSED unsigned int selected )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2017-05-03 15:57:08 +00:00
|
|
|
void rofi_view_get_current_monitor ( G_GNUC_UNUSED int *width, G_GNUC_UNUSED int *height )
|
2017-01-03 18:35:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-24 15:48:04 +00:00
|
|
|
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|
|
|
{
|
2017-09-07 11:46:09 +00:00
|
|
|
scrollbar * sb = scrollbar_create ( NULL, "scrollbar" );
|
2017-01-01 15:32:01 +00:00
|
|
|
widget_resize ( WIDGET (sb), 10, 100);
|
2016-10-24 15:48:04 +00:00
|
|
|
|
|
|
|
scrollbar_set_handle ( NULL, 10213);
|
|
|
|
scrollbar_set_max_value ( NULL, 10 );
|
|
|
|
scrollbar_set_handle_length ( NULL , 1000);
|
|
|
|
|
|
|
|
scrollbar_set_max_value ( sb, 10000);
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->length, 10000u );
|
2016-10-24 15:48:04 +00:00
|
|
|
scrollbar_set_handle_length ( sb, 10);
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->pos_length, 10u );
|
2016-10-24 15:48:04 +00:00
|
|
|
scrollbar_set_handle ( sb , 5000 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->pos, 5000u );
|
2016-10-24 15:48:04 +00:00
|
|
|
scrollbar_set_handle ( sb , 15000 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->pos, 10000u );
|
2016-10-24 15:48:04 +00:00
|
|
|
scrollbar_set_handle ( sb , UINT32_MAX );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->pos, 10000u );
|
2016-10-24 15:48:04 +00:00
|
|
|
scrollbar_set_handle_length ( sb, 15000);
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->pos_length, 10000u );
|
2016-10-24 15:48:04 +00:00
|
|
|
scrollbar_set_handle_length ( sb, 0);
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( sb->pos_length, 1u );
|
2016-10-24 15:48:04 +00:00
|
|
|
|
2016-10-26 06:24:34 +00:00
|
|
|
|
2017-05-30 10:41:44 +00:00
|
|
|
guint cl = scrollbar_scroll_get_line ( sb, 10 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 1010u);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 20 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 2020u);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 0 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 0u);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 99 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 9999u);
|
2016-10-26 06:24:34 +00:00
|
|
|
scrollbar_set_handle_length ( sb, 1000);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 10 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 555u);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 20 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 1666u);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 0 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 0u);
|
2017-05-30 10:41:44 +00:00
|
|
|
cl = scrollbar_scroll_get_line ( sb, 99 );
|
2019-02-02 10:38:33 +00:00
|
|
|
TASSERTE ( cl, 9999u);
|
2016-10-24 15:48:04 +00:00
|
|
|
|
|
|
|
widget_free( WIDGET (sb ) );
|
|
|
|
}
|