You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
Add backbutton
This commit is contained in:
18
src/main-executable/back_button.c
Normal file
18
src/main-executable/back_button.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "back_button.h"
|
||||
|
||||
#include "../api-impl-jni/app/android_app_Activity.h"
|
||||
|
||||
GtkWidget *back_button;
|
||||
|
||||
GtkWidget* back_button_new() {
|
||||
back_button = gtk_button_new_from_icon_name("go-previous");
|
||||
|
||||
g_signal_connect(back_button, "clicked", G_CALLBACK(current_activity_back_pressed), NULL);
|
||||
|
||||
back_button_set_sensitive(false);
|
||||
return back_button;
|
||||
}
|
||||
|
||||
void back_button_set_sensitive(bool sensitive) {
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(back_button), sensitive);
|
||||
}
|
||||
4
src/main-executable/back_button.h
Normal file
4
src/main-executable/back_button.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
GtkWidget* back_button_new();
|
||||
void back_button_set_sensitive(bool sensitive);
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "../api-impl-jni/util.h"
|
||||
#include "../api-impl-jni/app/android_app_Activity.h"
|
||||
|
||||
#include "back_button.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
@@ -547,6 +549,11 @@ static void open(GtkApplication *app, GFile **files, gint nfiles, const gchar *h
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), d->window_width, d->window_height);
|
||||
g_signal_connect(window, "close-request", G_CALLBACK(app_exit), env);
|
||||
|
||||
GtkWidget *header_bar = gtk_header_bar_new();
|
||||
GtkWidget *back_button = back_button_new();
|
||||
|
||||
gtk_header_bar_pack_start(GTK_HEADER_BAR(header_bar), back_button);
|
||||
gtk_window_set_titlebar(GTK_WINDOW(window), header_bar);
|
||||
gtk_window_present(GTK_WINDOW(window));
|
||||
|
||||
// set package name as application id for window icon on Wayland. Needs a {package_name}.desktop file defining the icon
|
||||
|
||||
Reference in New Issue
Block a user