diff --git a/gresource.xml b/gresource.xml index 8c2f42b..a1da154 100644 --- a/gresource.xml +++ b/gresource.xml @@ -5,6 +5,8 @@ ubl-settings-bootloader-password.glade ubl-settings-bootloader-user.glade ubl-settings-bootloader-ringtone.glade + ubl-settings-bootloader-menu.glade + ubl-settings-bootloader-menu-item.glade ubl-settings-bootloader.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 69fae4c..594b711 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -35,6 +35,8 @@ set(DEPENDFILES ../ubl-settings-bootloader-password.glade ../ubl-settings-bootloader-user.glade ../ubl-settings-bootloader-ringtone.glade + ../ubl-settings-bootloader-menu.glade + ../ubl-settings-bootloader-menu-item.glade ../grub-parameters.csv ../grub-terminal-input.csv ../grub-terminal-output.csv @@ -81,6 +83,7 @@ set(SOURCE_FILES ubl-settings-bootloader-user.c ubl-settings-bootloader-password.c ubl-settings-bootloader-melody.c + ubl-settings-bootloader-menu.c ubl-settings-bootloader.h ubl-strings.h ) diff --git a/source/ubl-settings-bootloader-menu.c b/source/ubl-settings-bootloader-menu.c new file mode 100644 index 0000000..b1ef954 --- /dev/null +++ b/source/ubl-settings-bootloader-menu.c @@ -0,0 +1,116 @@ +#include "ubl-settings-bootloader.h" + + + +void on_menu_chosen(GtkWidget *,dictionary *){ + +} + +void on_submenu_open(GtkWidget *,dictionary *dict){ + yon_menu_window *window = yon_dictionary_get_data(dict->first,yon_menu_window*); + yon_menu_item *item = yon_dictionary_get_data(dict->first->next,yon_menu_item*); + dictionary *dact = NULL; + for_dictionaries(dact,item->children){ + yon_menu_item *child = yon_dictionary_get_data(dact,yon_menu_item*); + gtk_list_box_insert(GTK_LIST_BOX(window->ChildrenListBox),child->MenuItemBox,-1); + g_signal_connect(G_OBJECT(child->MenuButton),"clicked",G_CALLBACK(on_menu_chosen),item); + + } +} + +yon_menu_window *yon_menu_window_open(GtkWidget *, main_window *widgets){ + yon_menu_window *window = yon_menu_window_new(); + int size; + config_str parsed = yon_config_load(get_menus_entry_command,&size); + for (int i=0;i"); + if (yon_dictionary_get(&window->menu_items,parameter[0])){ + + } else { + yon_menu_item *item = yon_menu_item_new(); + gtk_widget_hide(item->NextIconButton); + gtk_label_set_text(GTK_LABEL(item->MenuTextLabel),parameter[0]); + item->target=yon_char_new(parameter[0]); + gtk_list_box_insert(GTK_LIST_BOX(window->ItemsListBox),item->MenuItemBox,-1); + yon_dictionary_add_or_create_if_exists_with_data(window->menu_items,parameter[0],item); + gtk_widget_show(item->MenuItemBox); + if (size==2){ + yon_menu_item *item_child = yon_menu_item_new(); + g_signal_connect(G_OBJECT(item->MenuButton),"clicked",G_CALLBACK(on_submenu_open),item); + yon_dictionary_add_or_create_if_exists_with_data(item->children,parameter[1],item_child); + } else { + g_signal_connect(G_OBJECT(item->MenuButton),"clicked",G_CALLBACK(on_menu_chosen),item); + } + } + + } + int x,y,x2,y2,width; + gdk_window_get_position(gtk_widget_get_window(widgets->MenuButton),&x,&y); + gtk_widget_translate_coordinates(widgets->MenuButton,widgets->Window,x,y,&x2,&y2); + gtk_window_get_size(GTK_WINDOW(window->MenuWindow),&width,NULL); + gtk_window_get_position(GTK_WINDOW(widgets->Window),&x,&y); + gtk_window_move(GTK_WINDOW(window->MenuWindow),x+x2-width,y+y2); + gtk_widget_realize(window->MenuWindow); + gtk_widget_show(window->MenuWindow); + gdk_seat_grab(gdk_display_get_default_seat(gdk_display_get_default()),gtk_widget_get_window(window->MenuWindow),GDK_SEAT_CAPABILITY_POINTER,TRUE,NULL,NULL,NULL,NULL); + return window; +} + +gboolean on_menu_clicked(GtkWidget *, GdkEventButton *event, yon_menu_window *window){ + int x,y,width,height; + gtk_window_get_size(GTK_WINDOW(window->MenuWindow),&width,&height); + gtk_window_get_position(GTK_WINDOW(window->MenuWindow),&x,&y); + if (event->x_rooty_rootx_root>x+width||event->y_root>y+height){ + + GdkDisplay *display = gdk_display_get_default(); + GdkSeat *seat = gdk_display_get_default_seat(display); + gdk_seat_ungrab(seat); + // gtk_grab_remove(widget); + gtk_widget_destroy(window->MenuWindow); + } + return 1; + +} + +void on_children_clean(GtkWidget*, yon_menu_window *window){ + GList *list = gtk_container_get_children(GTK_CONTAINER(window->ChildrenListBox)); + for (guint i=0;idata)); + g_object_ref(G_OBJECT(item->data)); + gtk_container_remove(GTK_CONTAINER(list->data),GTK_WIDGET(item->data)); + gtk_widget_destroy(GTK_WIDGET(list->data)); + g_list_free(item); + list=list->next; + } +} + + yon_menu_window *yon_menu_window_new(){ + yon_menu_window *window = new(yon_menu_window); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_menu_window); + window->MenuWindow = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->ItemsRevealer = yon_gtk_builder_get_widget(builder,"ItemsRevealer"); + window->BackButton = yon_gtk_builder_get_widget(builder,"BackButton"); + window->ItemsListBox = yon_gtk_builder_get_widget(builder,"ItemsListBox"); + window->ChildrenRevealer = yon_gtk_builder_get_widget(builder,"ChildrenRevealer"); + window->ChildrenListBox = yon_gtk_builder_get_widget(builder,"ChildrenListBox"); + + window->menu_items=NULL; + + g_signal_connect(G_OBJECT(window->BackButton),"clicked",G_CALLBACK(on_children_clean),window); + g_signal_connect(G_OBJECT(window->MenuWindow),"button-press-event",G_CALLBACK(on_menu_clicked),window); + return window; +} + +yon_menu_item *yon_menu_item_new(){ + yon_menu_item *item = new(yon_menu_item); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_menu_item); + item->MenuItemBox = yon_gtk_builder_get_widget(builder,"MenuItemBox"); + item->MenuButton = yon_gtk_builder_get_widget(builder,"MenuButton"); + item->MenuTextLabel = yon_gtk_builder_get_widget(builder,"MenuTextLabel"); + item->NextIconButton = yon_gtk_builder_get_widget(builder,"NextIconButton"); + item->children=NULL; + + return item; +} \ No newline at end of file diff --git a/source/ubl-settings-bootloader.c b/source/ubl-settings-bootloader.c index ea63b0f..a15985b 100644 --- a/source/ubl-settings-bootloader.c +++ b/source/ubl-settings-bootloader.c @@ -446,6 +446,7 @@ void yon_main_window_complete(main_window *widgets){ } + g_signal_connect(G_OBJECT(widgets->MenuButton),"clicked",G_CALLBACK(yon_menu_window_open),widgets); g_signal_connect(G_OBJECT(widgets->BootUsersAddButton),"clicked",G_CALLBACK(on_user_add_clicked),widgets); g_signal_connect(G_OBJECT(widgets->BootUsersEditButton),"clicked",G_CALLBACK(on_user_edit_clicked),widgets); g_signal_connect(G_OBJECT(widgets->BootUsersRemoveButton),"clicked",G_CALLBACK(on_user_remove_clicked),widgets); diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 876b436..ab5556a 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -23,6 +23,8 @@ #define glade_path_password "/com/ublinux/ui/ubl-settings-bootloader-password.glade" #define glade_path_user "/com/ublinux/ui/ubl-settings-bootloader-user.glade" #define glade_path_ringtone "/com/ublinux/ui/ubl-settings-bootloader-ringtone.glade" +#define glade_path_menu_window "/com/ublinux/ui/ubl-settings-bootloader-menu.glade" +#define glade_path_menu_item "/com/ublinux/ui/ubl-settings-bootloader-menu-item.glade" #define banner_path "/com/ublinux/images/ubl-settings-bootloader-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-bootloader.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -33,6 +35,8 @@ #define LocaleName "ubl-settings-bootloader" +#define get_menus_entry_command "/usr/lib/ublinux/scripts/grub-functions exec_get_all_menuentry" + #define check_is_password_hash(password) system(yon_char_unite("/lib/ublinux/functions is_hash_password '", password,"'",NULL)) #define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get boot GRUB_SUPERUSERS GRUB_TIMEOUT GRUB_DEFAULT GRUB_BOOT_SILENT GRUB_PASSWORD[*] GRUB_CMDLINE_LINUX GRUB_TERMINAL_INPUT GRUB_TERMINAL_OUTPUT GRUB_PLAY",NULL) @@ -225,4 +229,38 @@ void on_ringtone_accept(GtkWidget *,dictionary *dict); void on_ringtone_add_clicked(GtkWidget *,main_window *widgets); void on_ringtone_edit_clicked(GtkWidget *,main_window *widgets); void on_ringtone_remove_clicked(GtkWidget *,main_window *widgets); -yon_ringtone_window *yon_ringtone_window_new(); \ No newline at end of file +yon_ringtone_window *yon_ringtone_window_new(); + +//menu + +typedef struct { + GtkWidget *MenuWindow; + GtkWidget *BackButton; + GtkWidget *ItemsRevealer; + GtkWidget *ItemsListBox; + GtkWidget *ChildrenRevealer; + GtkWidget *ChildrenListBox; + + dictionary *menu_items; + char *cur_selection; +} yon_menu_window; + +typedef struct { + GtkWidget *MenuItemBox; + GtkWidget *MenuButton; + GtkWidget *MenuTextLabel; + GtkWidget *NextIconButton; + + char *target; + + dictionary *children; + +} yon_menu_item; + +yon_menu_window *yon_menu_window_open(GtkWidget *target, main_window *widgets); +gboolean on_menu_clicked(GtkWidget *, GdkEventButton *, yon_menu_window *); + yon_menu_window *yon_menu_window_new(); +yon_menu_item *yon_menu_item_new(); +void on_menu_chosen(GtkWidget *,dictionary *dict); +void on_submenu_open(GtkWidget *,dictionary *dict); +void on_children_clean(GtkWidget*, yon_menu_window *window); \ No newline at end of file diff --git a/ubl-settings-bootloader-menu-item.glade b/ubl-settings-bootloader-menu-item.glade new file mode 100644 index 0000000..c9d988a --- /dev/null +++ b/ubl-settings-bootloader-menu-item.glade @@ -0,0 +1,73 @@ + + + + + + + True + False + + + True + True + True + + + True + False + 5 + + + True + False + label + + + False + True + 0 + + + + + True + True + False + True + menu1 + right + + + + + + + False + True + end + 1 + + + + + + + + True + True + 0 + + + + + True + False + + diff --git a/ubl-settings-bootloader-menu.glade b/ubl-settings-bootloader-menu.glade new file mode 100644 index 0000000..1ae2a36 --- /dev/null +++ b/ubl-settings-bootloader-menu.glade @@ -0,0 +1,174 @@ + + + + + + + 450 + 250 + False + False + True + 450 + com.ublinux.ubl-settings-bootloader + True + True + False + + + True + False + 0 + in + + + True + False + 5 + 5 + 5 + 5 + + + True + False + none + True + + + True + False + none + + + True + False + OS options were not found + + + + + + + + + True + True + 0 + + + + + True + False + none + + + True + False + vertical + 5 + + + True + True + True + + + True + False + 5 + + + True + True + False + True + left + + + + + + + False + True + 0 + + + + + True + False + Back + + + False + True + 1 + + + + + + + + False + True + 0 + + + + + True + False + none + + + True + False + Children options were not found + + + + + True + True + 1 + + + + + + + False + True + 1 + + + + + + + + + + + + + diff --git a/ubl-settings-bootloader.css b/ubl-settings-bootloader.css index 1ca94fe..fc12bd9 100644 --- a/ubl-settings-bootloader.css +++ b/ubl-settings-bootloader.css @@ -5,6 +5,9 @@ .noborder { border:none; } +.borders { + border:1px; +} .nobackground { background:transparent; } @@ -134,6 +137,21 @@ background:transparent; margin-right: 2px; } +.menunoborder { + border-radius: 0; + border:none; +} + +.menunoborder:active { + border-radius: 0; + border:none; +} + +.menunoborder:hover { + border-radius: 0; + border:none; +} + treeview row:nth-child(odd) { background-color: #000000; } treeview row:nth-child(even) { background-color: #ffffff; } \ No newline at end of file diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 414e8aa..1c640a8 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -63,6 +63,11 @@ False com.ublinux.libublsettingsui-gtk3.increase-symbolic + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + True False @@ -196,7 +201,7 @@ True True - 2 + 1 @@ -1070,9 +1075,46 @@ - + True False - com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + True + False + gaevdb + True + + + True + False + + + True + False + feagae + True + + + + + + + + + True + False + feagaegaeg + True + + + + + True + False + brtbrtbrb + True + +