• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision9b2874cb656f72b34151c30c067dc3b5cf87bd9f (tree)
l'heure2023-04-02 21:00:45
Auteurphabrics <phabrics@phab...>
Commiterphabrics

Message de Log

Removal of deprecated status bar in favor of a switch/entry combo for mouse toggling.

Change Summary

Modification

--- a/host/display/gtk/gtk-display.h
+++ b/host/display/gtk/gtk-display.h
@@ -84,8 +84,12 @@ typedef struct tme_gtk_screen {
8484 GtkWidget *tme_gtk_screen_draw;
8585 cairo_surface_t *tme_gtk_screen_surface;
8686
87- /* the mouse on label: */
87+ /* the mouse label: */
8888 GtkWidget *tme_gtk_screen_mouse_label;
89+ /* the mouse toggle button: */
90+ GtkWidget *tme_gtk_screen_mouse_button;
91+ /* the name of the mouse toggle key: */
92+ GtkWidget *tme_gtk_screen_mouse_key;
8993
9094 /* if GDK_VoidSymbol, mouse mode is off. otherwise,
9195 mouse mode is on, and this is the keyval that will
@@ -93,10 +97,6 @@ typedef struct tme_gtk_screen {
9397 guint tme_gtk_screen_mouse_keyval;
9498
9599 #if GTK_MAJOR_VERSION == 3
96- /* the status bar, and the context ID: */
97- GtkWidget *tme_gtk_screen_mouse_statusbar;
98- guint tme_gtk_screen_mouse_statusbar_cid;
99-
100100 cairo_format_t tme_gtk_screen_format;
101101 GtkEventController *key, *mouse, *motion, *event;
102102 GtkGesture *press;
--- a/host/display/gtk/gtk-keyboard.c
+++ b/host/display/gtk/gtk-keyboard.c
@@ -56,16 +56,7 @@ _tme_gtk_keyboard_key_down(
5656 != keyval)
5757 return _tme_keyboard_key_event(TRUE, keyval, screen->screen.tme_screen_display);
5858
59- /* pop our message off of the statusbar: */
60- gtk_statusbar_pop(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
61- screen->tme_gtk_screen_mouse_statusbar_cid);
62-
63- /* restore the text on the mouse label: */
64- gtk_frame_set_label(GTK_FRAME(screen->tme_gtk_screen_mouse_label),
65- _("Mouse is off"));
66-
67- /* the mouse is now off: */
68- screen->tme_gtk_screen_mouse_keyval = GDK_KEY_VoidSymbol;
59+ gtk_switch_set_active(GTK_SWITCH(screen->tme_gtk_screen_mouse_button), FALSE);
6960
7061 return (TRUE);
7162
@@ -98,30 +89,11 @@ _tme_gtk_mouse_key_down(
9889 /* recover our data structure: */
9990 display = screen->screen.tme_screen_display;
10091
101- if(screen->tme_gtk_screen_mouse_keyval
102- != GDK_KEY_VoidSymbol) return (FALSE);
103-
10492 /* lock the mutex: */
10593 tme_mutex_lock(&display->display.tme_display_mutex);
10694
107- /* this keyval must not be GDK_KEY_VoidSymbol: */
108- assert (keyval
109- != GDK_KEY_VoidSymbol);
95+ gtk_entry_set_text(GTK_ENTRY(screen->tme_gtk_screen_mouse_key), gdk_keyval_name(keyval));
11096
111- /* set the text on the mouse label: */
112- gtk_frame_set_label(GTK_FRAME(screen->tme_gtk_screen_mouse_label),
113- _("Mouse is on"));
114-
115- /* push the mouse status onto the statusbar: */
116- status = NULL;
117- tme_output_append(&status,
118- _("Press the %s key to turn the mouse off"),
119- gdk_keyval_name(keyval));
120- gtk_statusbar_push(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
121- screen->tme_gtk_screen_mouse_statusbar_cid,
122- status);
123- tme_free(status);
124-
12597 gdk_device_get_position(gdk_seat_get_pointer(display->tme_gdk_display_seat),
12698 NULL,
12799 &display->display.tme_screen_mouse_warp_x,
@@ -131,6 +103,8 @@ _tme_gtk_mouse_key_down(
131103 screen->tme_gtk_screen_mouse_keyval
132104 = keyval;
133105
106+ gtk_widget_grab_focus(screen->tme_gtk_screen_draw);
107+
134108 /* unlock the mutex: */
135109 tme_mutex_unlock(&display->display.tme_display_mutex);
136110
@@ -146,15 +120,13 @@ _tme_gtk_keyboard_attach(struct tme_gtk_screen *screen)
146120 #if GTK_MAJOR_VERSION == 4
147121 key=gtk_event_controller_key_new();
148122 gtk_widget_add_controller(screen->tme_gtk_screen_draw, key);
149- gtk_widget_set_focussable(screen->tme_gtk_screen_draw, TRUE);
123+ gtk_widget_set_focusable(screen->tme_gtk_screen_draw, TRUE);
150124 mouse=gtk_event_controller_key_new();
151- gtk_widget_add_controller(screen->tme_gtk_screen_mouse_label, mouse);
152- gtk_widget_set_focussable(screen->tme_gtk_screen_mouse_label, TRUE);
125+ gtk_widget_add_controller(screen->tme_gtk_screen_mouse_key, mouse);
153126 #elif GTK_MAJOR_VERSION == 3
154127 key=screen->key=gtk_event_controller_key_new(screen->tme_gtk_screen_draw);
155128 gtk_widget_set_can_focus(screen->tme_gtk_screen_draw, TRUE);
156- mouse=screen->mouse=gtk_event_controller_key_new(screen->tme_gtk_screen_mouse_label);
157- gtk_widget_set_can_focus(screen->tme_gtk_screen_mouse_label, TRUE);
129+ mouse=screen->mouse=gtk_event_controller_key_new(screen->tme_gtk_screen_mouse_key);
158130 #endif
159131
160132 g_signal_connect_after(key,
@@ -167,10 +139,9 @@ _tme_gtk_keyboard_attach(struct tme_gtk_screen *screen)
167139 G_CALLBACK(_tme_gtk_keyboard_key_up),
168140 screen);
169141
170- g_signal_connect_after(mouse,
171- "key-pressed",
172- G_CALLBACK(_tme_gtk_mouse_key_down),
173- screen);
142+ g_signal_connect(mouse,
143+ "key-pressed",
144+ G_CALLBACK(_tme_gtk_mouse_key_down),
145+ screen);
174146
175147 }
176-
--- a/host/display/gtk/gtk-mouse.c
+++ b/host/display/gtk/gtk-mouse.c
@@ -65,8 +65,7 @@ _tme_gtk_mouse_motion_event(GtkEventControllerMotion* self,
6565 struct tme_gtk_screen *screen)
6666
6767 {
68- if(screen->tme_gtk_screen_mouse_keyval
69- != GDK_KEY_VoidSymbol)
68+ if(gtk_switch_get_state(GTK_SWITCH(screen->tme_gtk_screen_mouse_button)))
7069 _tme_mouse_event(0, x, y, screen->screen.tme_screen_display);
7170 }
7271
@@ -78,8 +77,7 @@ _tme_gtk_mouse_button_down(GtkGesture* self,
7877 gdouble y,
7978 struct tme_gtk_screen *screen)
8079 {
81- if(screen->tme_gtk_screen_mouse_keyval
82- != GDK_KEY_VoidSymbol)
80+ if(gtk_switch_get_state(GTK_SWITCH(screen->tme_gtk_screen_mouse_button)))
8381 _tme_mouse_event(gtk_gesture_single_get_current_button(self),
8482 x, y, screen->screen.tme_screen_display);
8583 }
@@ -92,8 +90,7 @@ _tme_gtk_mouse_button_up(GtkGesture* self,
9290 gdouble y,
9391 struct tme_gtk_screen *screen)
9492 {
95- if(screen->tme_gtk_screen_mouse_keyval
96- != GDK_KEY_VoidSymbol)
93+ if(gtk_switch_get_state(GTK_SWITCH(screen->tme_gtk_screen_mouse_button)))
9794 _tme_mouse_event(-gtk_gesture_single_get_current_button(self),
9895 x, y, screen->screen.tme_screen_display);
9996 }
@@ -105,57 +102,35 @@ _tme_gtk_mouse_attach(struct tme_gtk_screen *screen)
105102 GtkEventController *motion, *event;
106103 GtkGesture *press;
107104
108- /* create the event box for the mouse on label: */
109- /* create the mouse on label: */
110- screen->tme_gtk_screen_mouse_label
111- = gtk_frame_new(_("Mouse is off"));
105+ /* create the mouse label, button, and key: */
106+ screen->tme_gtk_screen_mouse_label = gtk_label_new(_("Mouse Mode"));
107+ screen->tme_gtk_screen_mouse_button = gtk_switch_new();
108+ // = gtk_toggle_button_new_with_label(_("Mouse Mode"));
109+ screen->tme_gtk_screen_mouse_key = gtk_entry_new();
112110
113- /* pack the event box into the horizontal packing box: */
114111 gtk_header_bar_pack_start(GTK_HEADER_BAR(screen->tme_gtk_screen_header),
115112 screen->tme_gtk_screen_mouse_label);
113+ gtk_header_bar_pack_start(GTK_HEADER_BAR(screen->tme_gtk_screen_header),
114+ screen->tme_gtk_screen_mouse_button);
115+ gtk_header_bar_pack_start(GTK_HEADER_BAR(screen->tme_gtk_screen_header),
116+ screen->tme_gtk_screen_mouse_key);
116117
117118 #if GTK_MAJOR_VERSION == 4
118119 motion=gtk_event_controller_motion_new();
119120 gtk_widget_add_controller(screen->tme_gtk_screen_draw, motion);
120- event=gtk_event_controller_motion_new();
121- gtk_widget_add_controller(screen->tme_gtk_screen_mouse_label, event);
122121 press = gtk_gesture_click_new();
123122 gtk_widget_add_controller(screen->tme_gtk_screen_draw, GTK_EVENT_CONTROLLER (press));
124123 #elif GTK_MAJOR_VERSION == 3
125124 motion=screen->motion=gtk_event_controller_motion_new(screen->tme_gtk_screen_draw);
126- event=screen->event=gtk_event_controller_motion_new(screen->tme_gtk_screen_mouse_label);
127125 press=screen->press=gtk_gesture_multi_press_new(screen->tme_gtk_screen_draw);
128126 #endif
129127
130128 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE (press), 0);
131- /* set the tip on the event box, which will eventually contain the mouse on label: */
132- gtk_widget_set_tooltip_text(screen->tme_gtk_screen_mouse_label,
129+ /* set the tip on the entry box: */
130+ gtk_widget_set_tooltip_text(screen->tme_gtk_screen_mouse_key,
133131 "Press a key here to turn the mouse on. The same key " \
134132 "will turn the mouse off.");
135133
136- /* set a signal handler for the event box events: */
137- /* g_signal_connect(ebox,
138- "event",
139- G_CALLBACK(_tme_gtk_mouse_ebox_event),
140- screen); */
141-
142- /* create the mouse statusbar: */
143- screen->tme_gtk_screen_mouse_statusbar
144- = gtk_statusbar_new();
145-
146- /* pack the mouse statusbar into the horizontal packing box: */
147- gtk_header_bar_pack_start(GTK_HEADER_BAR(screen->tme_gtk_screen_header),
148- screen->tme_gtk_screen_mouse_statusbar);
149-
150- /* push an initial message onto the statusbar: */
151- screen->tme_gtk_screen_mouse_statusbar_cid
152- = gtk_statusbar_get_context_id(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
153- "mouse context");
154- gtk_statusbar_push(GTK_STATUSBAR(screen->tme_gtk_screen_mouse_statusbar),
155- screen->tme_gtk_screen_mouse_statusbar_cid,
156- _("The Machine Emulator"));
157-
158- /* on entering window, grab keyboard focus: */
159134 g_signal_connect_swapped(motion,
160135 "enter",
161136 G_CALLBACK(gtk_widget_grab_focus),
@@ -174,12 +149,6 @@ _tme_gtk_mouse_attach(struct tme_gtk_screen *screen)
174149 g_signal_connect(press, "pressed", G_CALLBACK(_tme_gtk_mouse_button_down),
175150 screen);
176151
177- /* on entering window, grab keyboard focus: */
178- g_signal_connect_swapped(event,
179- "enter",
180- G_CALLBACK(gtk_widget_grab_focus),
181- screen->tme_gtk_screen_mouse_label);
182-
183152 /* mouse mode is off: */
184153 screen->tme_gtk_screen_mouse_keyval = GDK_KEY_VoidSymbol;
185154 }