Added new root button functions

pull/66/head
parent 54cd45138a
commit 0d744bec14

@ -528,28 +528,38 @@ void on_root_access(GtkWidget *, GtkWidget *window){
} }
} }
void yon_root_button_setup(template_main_window *widgets, config_str args, int args_size){ void yon_root_button_init(GtkWidget *root_item,GtkWindow *window){
g_signal_connect(G_OBJECT(root_item),"activate", G_CALLBACK(on_root_access),window);
}
GtkWidget *yon_root_button_new(config_str args, int args_size){
textdomain(template_ui_LocaleName); textdomain(template_ui_LocaleName);
arg_size=args_size; arg_size=args_size;
arg_target=args; arg_target=args;
GtkWidget *root_item = gtk_menu_item_new(); GtkWidget *root_item = gtk_menu_item_new();
gtk_style_context_add_class(gtk_widget_get_style_context(root_item),"menuitemtop"); gtk_style_context_add_class(gtk_widget_get_style_context(root_item),"menuitemtop");
gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle");
gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemtop");
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
GtkWidget *root_label = gtk_label_new(ROOT_CHECK_LABEL); GtkWidget *root_label = gtk_label_new(ROOT_CHECK_LABEL);
GtkWidget *root_check = gtk_check_button_new(); GtkWidget *root_check = gtk_check_button_new();
gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_widget_get_parent(widgets->DocumentationMenuItem)),root_item);
gtk_box_pack_start(GTK_BOX(box),root_label,1,1,0); gtk_box_pack_start(GTK_BOX(box),root_label,1,1,0);
gtk_box_pack_start(GTK_BOX(box),root_check,0,0,0); gtk_box_pack_start(GTK_BOX(box),root_check,0,0,0);
gtk_container_add(GTK_CONTAINER(root_item),box); gtk_container_add(GTK_CONTAINER(root_item),box);
gtk_widget_show_all(root_item); gtk_widget_show_all(root_item);
g_signal_connect(G_OBJECT(root_item),"activate", G_CALLBACK(on_root_access),widgets->Window);
if (getuid()==0) { if (getuid()==0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(root_check),1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(root_check),1);
gtk_widget_set_sensitive(root_item,0); gtk_widget_set_sensitive(root_item,0);
} }
textdomain(template_app_information.app_locale); textdomain(template_app_information.app_locale);
return root_item;
}
void yon_root_button_setup(template_main_window *widgets, config_str args, int args_size){
GtkWidget *root_item = yon_root_button_new(args,args_size);
gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle");
gtk_style_context_remove_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemtop");
gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_widget_get_parent(widgets->DocumentationMenuItem)),root_item);
g_signal_connect(G_OBJECT(root_item),"activate", G_CALLBACK(on_root_access),widgets->Window);
} }
void __yon_config_init(){ void __yon_config_init(){

@ -274,14 +274,21 @@ char *yon_debug_output(char *pattern,char*text);
*/ */
int yon_ubl_connect_config(_template_config *config); int yon_ubl_connect_config(_template_config *config);
/// @brief Create and setup root access menu item for applications, which use libublsettingsui-gtk3's window template via yon_ubl_window_setup()
void yon_root_button_setup(template_main_window *widgets, config_str args, int args_size); void yon_root_button_setup(template_main_window *widgets, config_str args, int args_size);
/**yon_ubl_window_init(int argc, char *argv[])
* [EN] /// @brief Create new root access button
* /// @param args list of income parameters
* [RU] /// @param args_size size of income parameters list
* Создаёт и настраивает основное окно приложения. /// @return Type: GtkWidget. A newly created root menu item
*/ GtkWidget *yon_root_button_new(config_str args, int args_size);
/// @brief Setup all callbacks for root button
/// @param root_item Target root menu item
/// @param window Main application window
void yon_root_button_init(GtkWidget *root_item,GtkWindow *window);
template_main_window *yon_ubl_window_setup(); template_main_window *yon_ubl_window_setup();
/**yon_ubl_window_setup(GtkWidget *interface, char *app_title, char *app_description, char *locale, char *css, char *tech_name, char *version, char *wiki) /**yon_ubl_window_setup(GtkWidget *interface, char *app_title, char *app_description, char *locale, char *css, char *tech_name, char *version, char *wiki)

Loading…
Cancel
Save