From 258a4be06d9d1333458add94ea2b30fa19f2a761 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 9 Apr 2025 15:00:53 +0600 Subject: [PATCH] Fixed session update button --- source/ubl-settings-services.c | 147 +++++++++++---------------------- ubl-settings-services.glade | 12 +-- 2 files changed, 56 insertions(+), 103 deletions(-) diff --git a/source/ubl-settings-services.c b/source/ubl-settings-services.c index 6f665c1..00a3d1f 100644 --- a/source/ubl-settings-services.c +++ b/source/ubl-settings-services.c @@ -4,8 +4,7 @@ config main_config; //saving & loading -void on_save_done(main_window *widgets, config_str output, int size){ - if (widgets) {}; +void on_save_done(main_window *, config_str output, int size){ char *final_output = yon_char_parsed_to_string(output,size,""); if (!yon_char_is_empty(final_output)){ printf("%s\n",final_output); @@ -67,8 +66,7 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } } -void on_config_local_load(GtkWidget *self,main_window *widgets){ - if (self){} +void on_config_local_load(GtkWidget *,main_window *widgets){ if (!main_config.update_thread_active){ main_config.update_thread_active=1; yon_load_proceed(YON_CONFIG_LOCAL); @@ -78,8 +76,7 @@ void on_config_local_load(GtkWidget *self,main_window *widgets){ } } -void on_config_global_load(GtkWidget *self,main_window *widgets){ - if (self){} +void on_config_global_load(GtkWidget *,main_window *widgets){ if (!main_config.update_thread_active){ main_config.update_thread_active=1; yon_load_proceed(YON_CONFIG_GLOBAL); @@ -90,8 +87,7 @@ void on_config_global_load(GtkWidget *self,main_window *widgets){ } -void on_config_custom_load(GtkWidget *self,main_window *widgets){ - if (self){} +void on_config_custom_load(GtkWidget *,main_window *widgets){ yon_load_proceed(YON_CONFIG_CUSTOM); textdomain(template_ui_LocaleName); yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); @@ -121,8 +117,7 @@ void on_config_global_save(){ } -void on_config_custom_save(GtkWidget *self, main_window *widgets){ - if (self&&widgets){} +void on_config_custom_save(GtkWidget *, main_window *){ main_config.save_config=1; template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,yon_config_get_custom_command("system"),NULL); if (window){}; @@ -183,8 +178,7 @@ void on_activate(GtkTreeView *self, main_window *widgets){ if (self&&widgets){}; } -void on_config_autostart_clicked(GtkCellRenderer *self, char *path, main_window *widgets){ - if (self){}; +void on_config_autostart_clicked(GtkCellRenderer *, char *path, main_window *widgets){ GtkTreeIter filter_iter; GtkTreeIter iter; GtkTreeModel *model; @@ -242,8 +236,7 @@ void on_config_autostart_clicked(GtkCellRenderer *self, char *path, main_window } } -void on_config_autostop_clicked(GtkCellRenderer *self, char *path, main_window *widgets){ - if (self){}; +void on_config_autostop_clicked(GtkCellRenderer *, char *path, main_window *widgets){ GtkTreeIter filter_iter; GtkTreeIter iter; GtkTreeModel *model; @@ -302,8 +295,7 @@ void on_config_autostop_clicked(GtkCellRenderer *self, char *path, main_window * } -void on_config_block_clicked(GtkCellRenderer *self, char *path, main_window *widgets){ - if (self){}; +void on_config_block_clicked(GtkCellRenderer *, char *path, main_window *widgets){ GtkTreeIter filter_iter; GtkTreeIter iter; GtkTreeModel *model; @@ -362,13 +354,11 @@ void on_config_block_clicked(GtkCellRenderer *self, char *path, main_window *wid } -void on_system_autostart_confirmed(GtkWidget *self,char *service_command){ - if (self){}; +void on_system_autostart_confirmed(GtkWidget *,char *service_command){ yon_launch_app_with_arguments(service_command,""); } -void on_system_autostart_clicked(GtkCellRenderer *self, char *path, main_window *widgets){ - if (self){}; +void on_system_autostart_clicked(GtkCellRenderer *, char *path, main_window *widgets){ GtkTreeIter filter_iter; GtkTreeIter iter; GtkTreeModel *model; @@ -408,17 +398,17 @@ gboolean yon_filter(GtkTreeModel* model, GtkTreeIter *iter, main_window *widgets GtkWidget *loaded_check=NULL; GtkWidget *active_check=NULL; GtkWidget *name_entry = NULL; - int page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook)); - if (page == 0){ + if (model == GTK_TREE_MODEL(widgets->SystemList)){ combo = widgets->SystemFiltersCombo; loaded_check = widgets->SystemUnloadedShowCheck; active_check = widgets->SystemInactiveShowCheck; name_entry = widgets->SystemSearchEntry; - } else if (page == 1){ - combo = widgets->UserFiltersCombo; - loaded_check = widgets->UserUnloadedShowCheck; - active_check = widgets->UserInactiveShowCheck; - name_entry = widgets->UserSearchEntry; + } + if (model == GTK_TREE_MODEL(widgets->UserList)){ + combo = widgets->UserFiltersCombo; + loaded_check = widgets->UserUnloadedShowCheck; + active_check = widgets->UserInactiveShowCheck; + name_entry = widgets->UserSearchEntry; } int type_filter = 1; int active_filter = 0; @@ -458,8 +448,7 @@ gboolean yon_filter(GtkTreeModel* model, GtkTreeIter *iter, main_window *widgets return 0; } -void on_filter_changed(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_filter_changed(GtkWidget *, main_window *widgets){ int page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook)); if (page == 0){ gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SystemUnitsTree),NULL); @@ -472,13 +461,11 @@ void on_filter_changed(GtkWidget *self, main_window *widgets){ } } -void on_system_kill_confirmed(GtkWidget *self,char *service_name){ - if (self){}; +void on_system_kill_confirmed(GtkWidget *,char *service_name){ yon_launch(service_name); } -void on_system_launch_clicked(GtkWidget *self, char *path, main_window *widgets){ - if (self){}; +void on_system_launch_clicked(GtkWidget *, char *path, main_window *widgets){ GtkTreeIter iter, filter_iter; GtkTreeModel *model; GtkTreeModel *filter; @@ -548,8 +535,7 @@ void on_service_restart_confirmed(GtkWidget *self,char *service_name){ yon_launch_app_with_arguments(command,""); } -void on_system_restart_clicked(GtkWidget *self, main_window *widgets){ - if (self&&widgets){}; +void on_system_restart_clicked(GtkWidget *, main_window *widgets){ GtkWidget *target_tree; switch(gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))){ case 0:target_tree=widgets->SystemUnitsTree; @@ -574,8 +560,7 @@ void on_system_restart_clicked(GtkWidget *self, main_window *widgets){ } } -void on_sessions_selection_changed(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_sessions_selection_changed(GtkWidget *, main_window *widgets){ GtkTreeIter iter; GtkTreeModel *model; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){ @@ -609,8 +594,7 @@ void yon_sessions_update(main_window *widgets){ gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->SessionMainTree),GTK_TREE_MODEL(widgets->SessionsList)); } -void on_session_activate(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_session_activate(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->SessionsList); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){ @@ -623,8 +607,7 @@ void on_session_activate(GtkWidget *self, main_window *widgets){ } } -void on_session_end(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_session_end(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->SessionsList); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){ @@ -637,8 +620,7 @@ void on_session_end(GtkWidget *self, main_window *widgets){ } } -void on_session_block(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_session_block(GtkWidget *, main_window *widgets){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->SessionsList); GtkTreeIter iter; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SessionMainTree)),&model,&iter)){ @@ -674,8 +656,7 @@ log_window *yon_log_window_new(){ return window; } -void yon_system_systemd_restart(GtkWidget *self, main_window *widgets){ - if (self){}; +void yon_system_systemd_restart(GtkWidget *, main_window *widgets){ if (widgets){ if (!getuid()&>k_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))==0){ if (system(reload_systemd_root_command)){ @@ -695,8 +676,7 @@ void yon_system_systemd_restart(GtkWidget *self, main_window *widgets){ } } -void yon_system_systemd_reexec(GtkWidget *self, main_window *widgets){ - if (self){}; +void yon_system_systemd_reexec(GtkWidget *, main_window *widgets){ if (widgets){ if (getuid()!=0&>k_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook))==0){ if (system(reexec_systemd_root_command)){ @@ -719,7 +699,6 @@ void yon_system_systemd_reexec(GtkWidget *self, main_window *widgets){ typedef void (*data_function)(void*,void*); void on_system_update_hz_clicked(GtkWidget *self, main_window *widgets){ - if (self){} if (widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text = RELOAD_SERVICE_WARMING_LABEL("systemd"); @@ -731,7 +710,6 @@ void on_system_update_hz_clicked(GtkWidget *self, main_window *widgets){ } void on_system_update_clicked(GtkWidget *self, main_window *widgets){ - if (self){} if (widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text = REEXEC_SERVICE_WARMING_LABEL("systemd"); @@ -742,8 +720,7 @@ void on_system_update_clicked(GtkWidget *self, main_window *widgets){ } -void on_system_info_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_system_info_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->SystemList); @@ -761,8 +738,7 @@ void on_system_info_clicked(GtkWidget *self, main_window *widgets){ } -void on_system_log_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_system_log_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->SystemList); @@ -788,21 +764,18 @@ gboolean on_terminal_relaunch(log_window *window){ return G_SOURCE_REMOVE; } -void on_save_clicked(GtkWidget *self, log_window *window){ - if (self){}; +void on_save_clicked(GtkWidget *, log_window *window){ vte_terminal_feed_child(VTE_TERMINAL(window->SystemTerminal),"\30",-1); vte_terminal_feed_child(VTE_TERMINAL(window->SystemTerminal),"Y\r",-1); gtk_widget_grab_focus(window->SystemTerminal); g_idle_add((GSourceFunc)on_terminal_relaunch,window); } -void on_update_clicked(GtkWidget *self, log_window *window){ - if (self){}; +void on_update_clicked(GtkWidget *, log_window *window){ yon_terminal_integrated_start_shell(window->SystemTerminal,window->target,NULL,NULL); } -void on_system_edit_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_system_edit_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->SystemList); @@ -828,8 +801,7 @@ void on_system_edit_clicked(GtkWidget *self, main_window *widgets){ } -void on_system_status_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_system_status_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->SystemList); @@ -849,7 +821,6 @@ void on_system_status_clicked(GtkWidget *self, main_window *widgets){ } void on_user_update_hz_clicked(GtkWidget *self, main_window *widgets){ - if (self){} if (widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text = REEXEC_SERVICE_WARMING_LABEL("systemd"); @@ -862,7 +833,6 @@ void on_user_update_hz_clicked(GtkWidget *self, main_window *widgets){ } void on_user_update_clicked(GtkWidget *self, main_window *widgets){ - if (self){} if (widgets){ dialog_confirmation_data *data = malloc(sizeof(dialog_confirmation_data)); data->action_text = RELOAD_SERVICE_WARMING_LABEL("systemd"); @@ -873,8 +843,7 @@ void on_user_update_clicked(GtkWidget *self, main_window *widgets){ } -void on_user_info_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_user_info_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->UserList); @@ -892,8 +861,7 @@ void on_user_info_clicked(GtkWidget *self, main_window *widgets){ } -void on_user_log_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_user_log_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->UserList); @@ -911,8 +879,7 @@ void on_user_log_clicked(GtkWidget *self, main_window *widgets){ } -void on_user_edit_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_user_edit_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->UserList); @@ -938,8 +905,7 @@ void on_user_edit_clicked(GtkWidget *self, main_window *widgets){ } -void on_user_status_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_user_status_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->UserList); @@ -958,8 +924,7 @@ void on_user_status_clicked(GtkWidget *self, main_window *widgets){ } -void on_config_log_save(GtkWidget *self, log_window *window){ - if (self){}; +void on_config_log_save(GtkWidget *, log_window *window){ GtkTextIter start, end; GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->TextEditor)); gtk_text_buffer_get_end_iter(buffer,&end); @@ -974,8 +939,7 @@ void on_config_log_save(GtkWidget *self, log_window *window){ } } -void on_config_edit_clicked(GtkWidget *self, main_window *widgets){ - if (self){} +void on_config_edit_clicked(GtkWidget *, main_window *widgets){ if (widgets){ GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->ConfigList); @@ -1003,8 +967,7 @@ void on_config_edit_clicked(GtkWidget *self, main_window *widgets){ } -void on_system_services_status(GtkWidget *self, main_window *widgets){ - if (self){} +void on_system_services_status(GtkWidget *, main_window *widgets){ if (widgets){ log_window *window = yon_log_window_new(); gtk_label_set_text(GTK_LABEL(window->webHeaderNameLabel),SYSTEM_STATUS_LABEL); @@ -1017,8 +980,7 @@ void on_system_services_status(GtkWidget *self, main_window *widgets){ } -void on_user_services_status(GtkWidget *self, main_window *widgets){ - if (self){} +void on_user_services_status(GtkWidget *, main_window *widgets){ if (widgets){ log_window *window = yon_log_window_new(); gtk_label_set_text(GTK_LABEL(window->webHeaderNameLabel),USER_STATUS_LABEL); @@ -1031,8 +993,7 @@ void on_user_services_status(GtkWidget *self, main_window *widgets){ } -void on_units_status(GtkWidget *self, main_window *widgets){ - if (self){} +void on_units_status(GtkWidget *, main_window *widgets){ if (widgets){ log_window *window = yon_log_window_new(); gtk_label_set_text(GTK_LABEL(window->webHeaderNameLabel),INSTALLED_UNIT_LABEL); @@ -1045,8 +1006,7 @@ void on_units_status(GtkWidget *self, main_window *widgets){ } -void on_units_list_status(GtkWidget *self, main_window *widgets){ - if (self){} +void on_units_list_status(GtkWidget *, main_window *widgets){ if (widgets){ log_window *window = yon_log_window_new(); gtk_label_set_text(GTK_LABEL(window->webHeaderNameLabel),UNITS_LIST_LABEL); @@ -1059,8 +1019,7 @@ void on_units_list_status(GtkWidget *self, main_window *widgets){ } -void on_sockets_list_status(GtkWidget *self, main_window *widgets){ - if (self){} +void on_sockets_list_status(GtkWidget *, main_window *widgets){ if (widgets){ log_window *window = yon_log_window_new(); gtk_label_set_text(GTK_LABEL(window->webHeaderNameLabel),SOCKETS_LIST_LABEL); @@ -1073,8 +1032,7 @@ void on_sockets_list_status(GtkWidget *self, main_window *widgets){ } -void on_timers_list_status(GtkWidget *self, main_window *widgets){ - if (self){} +void on_timers_list_status(GtkWidget *, main_window *widgets){ if (widgets){ log_window *window = yon_log_window_new(); gtk_label_set_text(GTK_LABEL(window->webHeaderNameLabel),TIMERS_LIST_LABEL); @@ -1397,8 +1355,7 @@ gboolean yon_interface_update(main_window *widgets){ return G_SOURCE_REMOVE; } -void on_interface_update(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_interface_update(GtkWidget *, main_window *widgets){ if (!main_config.update_thread_active){ gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SystemUnitsTree))); gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->UserUnitsTree))); @@ -1407,8 +1364,7 @@ void on_interface_update(GtkWidget *self, main_window *widgets){ } } -void on_column_resize(GtkTreeViewColumn *self,GParamSpec *pspec,main_window *widgets){ - if (self||pspec){} +void on_column_resize(GtkTreeViewColumn *,GParamSpec *,main_window *widgets){ GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->SystemUnitsTree)); int width_configuration = gtk_tree_view_column_get_width(g_list_nth_data(list,0))+gtk_tree_view_column_get_width(g_list_nth_data(list,1))+gtk_tree_view_column_get_width(g_list_nth_data(list,2)); int width_system = gtk_tree_view_column_get_width(g_list_nth_data(list,3))+gtk_tree_view_column_get_width(g_list_nth_data(list,4))+gtk_tree_view_column_get_width(g_list_nth_data(list,5)); @@ -1446,8 +1402,7 @@ void config_init(){ main_config.launch_size=0; } -void on_tree_selection_changed(GtkWidget *self, main_window *widgets){ - if (self){}; +void on_tree_selection_changed(GtkWidget *, main_window *widgets){ GtkTreeModel *model; GtkWidget *Tree; GtkTreeIter iter; @@ -1512,9 +1467,7 @@ void on_tree_selection_changed(GtkWidget *self, main_window *widgets){ } } -gboolean on_tooltip_show(GtkWidget* self, gint x, gint y, gboolean keyboard_mode, GtkTooltip* tooltip, main_window *widgets) { - if (self || x || y || keyboard_mode) {}; - +gboolean on_tooltip_show(GtkWidget*, gint x, gint y, gboolean, GtkTooltip* tooltip, main_window *widgets) { gtk_tooltip_set_custom(tooltip,widgets->TooltipBox); GtkWidget *tree = NULL; GtkTreeModel *model = NULL; @@ -1763,7 +1716,7 @@ void yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->ConfigEditButton),"clicked",G_CALLBACK(on_config_edit_clicked),widgets); - // g_signal_connect(G_OBJECT(widgets->SessionRestartButton),"clicked",G_CALLBACK(on_interface_update),widgets); + g_signal_connect(G_OBJECT(widgets->SessionRestartButton),"clicked",G_CALLBACK(on_interface_update),widgets); g_signal_connect(G_OBJECT(widgets->SessionStartButton),"clicked",G_CALLBACK(on_session_activate),widgets); g_signal_connect(G_OBJECT(widgets->SessionStopButton),"clicked",G_CALLBACK(on_session_end),widgets); g_signal_connect(G_OBJECT(widgets->SessionBlockButton),"clicked",G_CALLBACK(on_session_block),widgets); diff --git a/ubl-settings-services.glade b/ubl-settings-services.glade index 93a428e..860abb8 100644 --- a/ubl-settings-services.glade +++ b/ubl-settings-services.glade @@ -407,11 +407,6 @@ False com.ublinux.ubl-settings-services.properties-symbolic - - True - False - com.ublinux.ubl-settings-services.sync-symbolic - True False @@ -427,6 +422,11 @@ False com.ublinux.ubl-settings-services.arrow-round-symbolic + + True + False + com.ublinux.ubl-settings-services.sync-symbolic + True False @@ -1916,7 +1916,7 @@ True True Update - image19 + image22