1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

...

3 commits

Author SHA1 Message Date
Gwenhael Le Moine
dfd97b548a
don't draw annunciators_container twice 2024-11-08 10:10:03 +01:00
Gwenhael Le Moine
cb8574f7d8
don't use ui->lcd_canvas to open popup menu 2024-11-08 10:09:31 +01:00
Gwenhael Le Moine
e6b9ff86db
make pretty-code 2024-11-08 10:01:05 +01:00

View file

@ -1452,7 +1452,7 @@ static gboolean react_to_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
if ( ui->menu_debug ) if ( ui->menu_debug )
gtk_widget_set_sensitive( ui->menu_debug, !gdbserver_isactive() ); gtk_widget_set_sensitive( ui->menu_debug, !gdbserver_isactive() );
gtk_menu_popup_at_widget( GTK_MENU( ui->menu ), ui->lcd_canvas, GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL ); gtk_menu_popup_at_widget( GTK_MENU( ui->menu ), ui->window, GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL );
return false; return false;
default: default:
@ -1535,19 +1535,19 @@ static gboolean react_to_window_click( GtkWidget* widget, GdkEventButton* event,
return false; return false;
switch ( event->button ) { switch ( event->button ) {
case 1: // left click case 1: // left click
gdk_window_begin_move_drag( gtk_widget_get_window( widget ), event->button, event->x_root, event->y_root, event->time ); gdk_window_begin_move_drag( gtk_widget_get_window( widget ), event->button, event->x_root, event->y_root, event->time );
break; break;
case 2: // middle click case 2: // middle click
GtkClipboard* clip = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ); GtkClipboard* clip = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
gchar* text = gtk_clipboard_wait_for_text( clip ); gchar* text = gtk_clipboard_wait_for_text( clip );
fprintf( stderr, "clipboard: %s\n", text ); fprintf( stderr, "clipboard: %s\n", text );
break; break;
case 3: // right click case 3: // right click
gtk_menu_popup_at_widget( GTK_MENU( ui->menu ), ui->lcd_canvas, GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL ); gtk_menu_popup_at_pointer( GTK_MENU( ui->menu ), NULL );
return true; return true;
default: default:
break; break;
} }
return false; return false;
@ -1675,22 +1675,22 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
// create all colors // create all colors
{ {
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_0 ], 0xab, 0xd2, 0xb4 ); /* #abd2b4 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_0 ], 0xab, 0xd2, 0xb4 ); /* #abd2b4 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_1 ], 0xa0, 0xc4, 0xa8 ); /* #a0c4a8 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_1 ], 0xa0, 0xc4, 0xa8 ); /* #a0c4a8 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_2 ], 0x94, 0xb6, 0x9c ); /* #94b69c */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_2 ], 0x94, 0xb6, 0x9c ); /* #94b69c */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_3 ], 0x89, 0xa8, 0x90 ); /* #89a890 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_3 ], 0x89, 0xa8, 0x90 ); /* #89a890 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_4 ], 0x7d, 0x9a, 0x84 ); /* #7d9a84 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_4 ], 0x7d, 0x9a, 0x84 ); /* #7d9a84 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_5 ], 0x72, 0x8c, 0x78 ); /* #728c78 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_5 ], 0x72, 0x8c, 0x78 ); /* #728c78 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_6 ], 0x67, 0x7e, 0x6c ); /* #677e6c */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_6 ], 0x67, 0x7e, 0x6c ); /* #677e6c */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_7 ], 0x5b, 0x70, 0x60 ); /* #5b7060 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_7 ], 0x5b, 0x70, 0x60 ); /* #5b7060 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_8 ], 0x50, 0x62, 0x54 ); /* #506254 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_8 ], 0x50, 0x62, 0x54 ); /* #506254 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_9 ], 0x44, 0x54, 0x48 ); /* #445448 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_9 ], 0x44, 0x54, 0x48 ); /* #445448 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_10 ], 0x39, 0x46, 0x3c ); /* #39463c */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_10 ], 0x39, 0x46, 0x3c ); /* #39463c */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_11 ], 0x2e, 0x38, 0x30 ); /* #2e3830 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_11 ], 0x2e, 0x38, 0x30 ); /* #2e3830 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_12 ], 0x22, 0x2a, 0x24 ); /* #222a24 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_12 ], 0x22, 0x2a, 0x24 ); /* #222a24 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_13 ], 0x17, 0x1c, 0x18 ); /* #171c18 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_13 ], 0x17, 0x1c, 0x18 ); /* #171c18 */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_14 ], 0x0b, 0x03, 0x0c ); /* #0b030c */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_14 ], 0x0b, 0x03, 0x0c ); /* #0b030c */
_ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_15 ], 0x00, 0x00, 0x00 ); /* #000000 */ _ui_load__init_color( &ui->colors[ UI_COLOR_GRAYSCALE_15 ], 0x00, 0x00, 0x00 ); /* #000000 */
} }
/* set calculator type and name */ /* set calculator type and name */
@ -1741,6 +1741,13 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
// create window and widgets/stuff // create window and widgets/stuff
GtkWidget* fixed_widgets_container = gtk_fixed_new(); GtkWidget* fixed_widgets_container = gtk_fixed_new();
{ {
ui->ui_ann_left = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_right = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_alpha = _ui_load__create_annunciator_widget( ui, "α" );
ui->ui_ann_battery = _ui_load__create_annunciator_widget( ui, "🪫" );
ui->ui_ann_busy = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_io = _ui_load__create_annunciator_widget( ui, "" );
ui->window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); ui->window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_default_size( GTK_WINDOW( ui->window ), ui->width, ui->height ); gtk_window_set_default_size( GTK_WINDOW( ui->window ), ui->width, ui->height );
gtk_window_set_accept_focus( GTK_WINDOW( ui->window ), true ); gtk_window_set_accept_focus( GTK_WINDOW( ui->window ), true );
@ -1770,15 +1777,6 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
gtk_box_set_homogeneous( GTK_BOX( annunciators_container ), true ); gtk_box_set_homogeneous( GTK_BOX( annunciators_container ), true );
gtk_widget_set_size_request( annunciators_container, ui->lcd_width, ANN_HEIGHT ); gtk_widget_set_size_request( annunciators_container, ui->lcd_width, ANN_HEIGHT );
gtk_style_context_add_class( gtk_widget_get_style_context( annunciators_container ), "annunciators-container" ); gtk_style_context_add_class( gtk_widget_get_style_context( annunciators_container ), "annunciators-container" );
gtk_fixed_put( GTK_FIXED( fixed_widgets_container ), annunciators_container, ui->annunciators_x_offset, ui->annunciators_y_offset );
ui->ui_ann_left = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_right = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_alpha = _ui_load__create_annunciator_widget( ui, "α" );
ui->ui_ann_battery = _ui_load__create_annunciator_widget( ui, "🪫" );
ui->ui_ann_busy = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_io = _ui_load__create_annunciator_widget( ui, "" );
gtk_container_add( GTK_CONTAINER( annunciators_container ), ui->ui_ann_left ); gtk_container_add( GTK_CONTAINER( annunciators_container ), ui->ui_ann_left );
gtk_container_add( GTK_CONTAINER( annunciators_container ), ui->ui_ann_right ); gtk_container_add( GTK_CONTAINER( annunciators_container ), ui->ui_ann_right );
gtk_container_add( GTK_CONTAINER( annunciators_container ), ui->ui_ann_alpha ); gtk_container_add( GTK_CONTAINER( annunciators_container ), ui->ui_ann_alpha );