#include "launcher.h" #include "foreign.h" #include "session.h" #include #define NAMESPACE "launcher" static void on_launcher_destroy(GtkWindow *window, GApplication *_data) { (void) window; (void)_data; //g_application_quit (G_APPLICATION (gtk_window_get_application (window))); } static void on_foreign_window_change(GtkApplication* app, DiyaForeignWindow * win, gpointer data) { (void) app; (void) data; assert(win); g_warning("WINDOW CHANGEEEEEEEEE %s", diya_object_to_string(DIYA_OBJECT(win))); } static void on_foreign_window_removed(GtkApplication* app, DiyaForeignWindow * win, gpointer data) { (void) app; (void) data; assert(win); g_warning("WINDOW removed %s", diya_object_to_string(DIYA_OBJECT(win))); } static void session_lock(GtkWidget *widget,gpointer data) { g_warning("Enter session lock"); diya_shell_lock(data); } void diya_shell_launcher_init(DiyaShell * shell) { assert(shell); GtkApplication * app; g_object_get(shell, "application", &app, NULL); assert(app); GtkWindow *gtk_window = GTK_WINDOW (gtk_application_window_new (app)); assert(gtk_window); g_object_set(shell, "launchpad", gtk_window, NULL); g_signal_connect (gtk_window, "destroy", G_CALLBACK (on_launcher_destroy), NULL); // int layer shell for window gtk_layer_init_for_window (gtk_window); // anchor window to all edges gtk_layer_set_anchor (gtk_window, GTK_LAYER_SHELL_EDGE_LEFT, true); gtk_layer_set_anchor (gtk_window, GTK_LAYER_SHELL_EDGE_RIGHT, true); gtk_layer_set_anchor (gtk_window, GTK_LAYER_SHELL_EDGE_TOP, true); gtk_layer_set_anchor (gtk_window, GTK_LAYER_SHELL_EDGE_BOTTOM, false); // set margin on window for (int i = 0; i < GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER; i++) gtk_layer_set_margin (gtk_window, i, 0); gtk_layer_set_layer (gtk_window, GTK_LAYER_SHELL_LAYER_TOP); gtk_layer_set_keyboard_mode (gtk_window, GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND); gtk_layer_set_namespace (gtk_window, NAMESPACE); // the top launcher shall be exclusive gtk_layer_auto_exclusive_zone_enable (gtk_window); gtk_widget_set_name(GTK_WIDGET(gtk_window),NAMESPACE); gtk_window_set_default_size(gtk_window, 48, 48); GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_set_homogeneous (GTK_BOX (box), TRUE); gtk_window_set_child (GTK_WINDOW (gtk_window), box); gtk_widget_set_halign (box, GTK_ALIGN_CENTER); gtk_widget_set_valign (box, GTK_ALIGN_CENTER); GtkWidget * button = gtk_button_new_with_label ("lock"); g_signal_connect (button, "clicked", G_CALLBACK (session_lock), shell); gtk_box_append (GTK_BOX (box), button); //g_signal_connect (gtk_window, "orientation-changed", G_CALLBACK (on_orientation_changed), /*data*/NULL); gtk_window_present (GTK_WINDOW (gtk_window)); g_signal_connect (shell, "foreign-window-changed", G_CALLBACK (on_foreign_window_change), NULL); g_signal_connect (shell, "foreign-window-removed", G_CALLBACK (on_foreign_window_removed), NULL); GList *apps = g_app_info_get_all (); GList * l; for (l = apps; l != NULL; l = l->next) { gpointer element_data = l->data; /*g_warning("%s", g_app_info_get_display_name(element_data)); g_warning("%s", g_app_info_get_id(element_data)); g_warning("%s", g_app_info_get_name(element_data)); //g_warning("%s", g_app_info_get_icon(element_data));*/ } g_list_free_full(apps, g_object_unref); }