diya-shell/src/launcher.c

78 lines
2.9 KiB
C
Raw Normal View History

#include "launcher.h"
#include "foreign.h"
#include <assert.h>
#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, DiyaWindow * 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, DiyaWindow * win, gpointer data)
{
(void) app;
(void) data;
assert(win);
g_warning("WINDOW removed %s", diya_object_to_string(DIYA_OBJECT(win)));
}
void diya_launcher_init(DiyaShell * shell)
{
assert(shell);
GtkWindow *gtk_window;
g_object_get(shell, "launchpad", &gtk_window, NULL);
assert(gtk_window);
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_VERTICAL, 5);
gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
gtk_window_set_child (GTK_WINDOW (gtk_window), box);
//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)); /*print out all of the display names of the .desktop files */
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);
}