From 9289033a7be42fa7c8c46ab5a8fa6b7d1013fa76 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 17 Feb 2023 11:44:10 +0600 Subject: [PATCH] header button implementation --- source/CMakeLists.txt | 4 +- source/ubl-settings-manager.c | 132 +++++++++++++++++++--------------- source/ubl-settings-manager.h | 5 +- ubl-settings-manager.css | 23 ++++-- 4 files changed, 99 insertions(+), 65 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 8459f65..a1449a6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -8,8 +8,8 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a -g") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -g") set(SOURCE_FILES ubl-settings-manager.c diff --git a/source/ubl-settings-manager.c b/source/ubl-settings-manager.c index 06f20aa..9ab6acb 100644 --- a/source/ubl-settings-manager.c +++ b/source/ubl-settings-manager.c @@ -54,6 +54,7 @@ void on_plug_removed(GtkSocket* self, actionWidgets *widgets){ gtk_widget_set_vexpand(widgets->socketplace,0); gtk_widget_set_vexpand(widgets->HideWhileLaunch,1); //printf("Plug has been removed!\n\n\n"); + gtk_widget_destroy(widgets->socketbutton); } @@ -65,19 +66,33 @@ void on_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets *appl gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,1,&name,-1); apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize); + printf("%s\n",tempapp->Name); if (!tempapp){}else{ char arg[100]; + printf("%s\n",tempapp->Exec); + printf("%d\n",tempapp->Type); + printf("%d\n",tempapp->Pluggable); memset(arg,0,100); printf("%d\n%d\n\n\n\n",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); - sprintf(arg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); + sprintf(arg,"--socket-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); if (tempapp[0].Type==2) if (tempapp->Pluggable==1) - py_launch_app(tempapp[0].Exec,arg); + if (tempapp->DualPluggable==1){ + char *dualarg=malloc(strlen("--socket-id= --socket-ext-id=")+30); + sprintf(dualarg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); + launch_app_with_arguments(tempapp[0].Exec,dualarg); + } else + py_launch_app(tempapp[0].Exec,arg); else py_launch_app(tempapp[0].Exec,""); else if (tempapp[0].Type==1){ if (tempapp->Pluggable==1) - launch_app_with_arguments(tempapp[0].Exec,arg); + if (tempapp->DualPluggable==1){ + char *dualarg=malloc(strlen("--socket-id= --socket-ext-id=")+30); + sprintf(dualarg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); + launch_app_with_arguments(tempapp[0].Exec,dualarg); + } else + launch_app_with_arguments(tempapp[0].Exec,arg); else launch_app(tempapp[0].Exec); } } @@ -90,11 +105,7 @@ void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets gtk_widget_destroy(applist->socket); } applist->socket=create_socket(applist); - char *socket_id=malloc(sizeof(gtk_socket_get_id(GTK_SOCKET(applist->socket)))/sizeof(int)); - sprintf(socket_id,"%d",gtk_socket_get_id(GTK_SOCKET(applist->socket))); - socket_id=yon_char_get_augumented("../ubl-info/ubl-info-bin --socket-id=",socket_id); - socket_id=yon_char_get_augumented(socket_id," &"); - system(socket_id); + on_about_system(NULL,applist); gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path); gtk_tree_model_get(gtk_icon_view_get_model(self),&iter,1,&name,-1); @@ -102,17 +113,26 @@ void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, actionWidgets apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize); char arg[100]; memset(arg,0,100); - printf("%d\n%d\n\n\n\n",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); - sprintf(arg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); + sprintf(arg,"--socket-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket))); if (tempapp[0].Type==2) - if (tempapp->Pluggable==1) - py_launch_app(tempapp[0].Exec,arg); - else py_launch_app(tempapp[0].Exec,""); - else if (tempapp[0].Type==1){ - if (tempapp->Pluggable==1) - launch_app_with_arguments(tempapp[0].Exec,arg); - else launch_app(tempapp[0].Exec); + if (tempapp->Pluggable==1) + if (tempapp->DualPluggable==1){ + char *dualarg=malloc(strlen("--socket-id= --socket-ext-id=")+30); + sprintf(dualarg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); + py_launch_app(tempapp[0].Exec,dualarg); + } else + py_launch_app(tempapp[0].Exec,arg); + else py_launch_app(tempapp[0].Exec,""); + else if (tempapp[0].Type==1){ + if (tempapp->Pluggable==1) + if (tempapp->DualPluggable==1){ + char *dualarg=malloc(strlen("--socket-id= --socket-ext-id=")+30); + sprintf(dualarg,"--socket-id=%d --socket-ext-id=%d",gtk_socket_get_id(GTK_SOCKET(applist->socket)),gtk_socket_get_id(GTK_SOCKET(applist->socketbutton))); + launch_app_with_arguments(tempapp[0].Exec,dualarg); + } else + launch_app_with_arguments(tempapp[0].Exec,arg); + else launch_app(tempapp[0].Exec); } } @@ -121,7 +141,7 @@ void on_item_selection_changed(GtkIconView *IV, actionWidgets *widgets){ dictionary *next=widgets->ICSys->first; for (dictionary *dct=next;dct!=NULL;dct=dct->next){ IVGraphicals *IVG=(IVGraphicals*)dct->data; - if (IVG->IV!=IV) + if (GTK_ICON_VIEW(IVG->IV)!=GTK_ICON_VIEW(IV)) if (gtk_icon_view_get_selected_items(GTK_ICON_VIEW(IVG->IV))>0) gtk_icon_view_unselect_all(GTK_ICON_VIEW(IVG->IV)); } @@ -311,7 +331,7 @@ void on_section_settings_open(GtkButton* self,dictionary *cWidgets){ SectionSettingSegment *Sgm=yon_create_section_setting(IV->sectionName,IV->categories); yon_segment_show(widgets,Sgm); dict->data=Sgm; - dict->key=gtk_label_get_text(GTK_LABEL(Sgm->NameLabel)); + dict->key=(char*)gtk_label_get_text(GTK_LABEL(Sgm->NameLabel)); dict->next=malloc(sizeof(dictionary)); dict->next->prev=dict; dict->next->first=dict->first; @@ -628,25 +648,30 @@ void on_about_system(GtkWidget *button, actionWidgets *widgets){ launch_app_with_arguments("ubl-settings-info",arg); } +void launch(char *command){ + system(command); +} + void launch_app_with_arguments(char *name, char *args){ - char *path=malloc(strlen(name)+strlen(args)+4); - memset(path,0,strlen(name)+strlen(args)+4); - memcpy(path,name,strlen(name)); - memcpy(path+strlen(name)," ",1); - strcat(args," &"); - strcat(path,args); - system(("/usr/bin/%s",path)); + char *path=yon_char_get_augumented("/bin/",name); + path=yon_char_get_augumented(path," "); + path=yon_char_get_augumented(path,args); + printf("%s\n",path); + pthread_t thread_id; + pthread_create(&thread_id, NULL, launch, path); }; void launch_app(char *name){ - char *path=yon_char_get_augumented(name," &"); - system(path); + char *path=name; + pthread_t thread_id; + pthread_create(&thread_id, NULL, launch, path); }; void py_launch_app(char *name,char *args){ char *path=malloc(strlen("python ./")+strlen(name)+6+strlen(args)); sprintf(path,"python ./%s.py %s &",name,args); - system(path); + pthread_t thread_id; + pthread_create(&thread_id, NULL, launch, path); }; @@ -654,7 +679,6 @@ apps *get_app_by_name(apps *applist,char *name, int size){ for (int i=0;ifirst;dct!=NULL;dct=dct->next){ IVGraphicals *iv=dct->data; @@ -1343,7 +1361,8 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them curWidgets->SettingsSections=NULL; gtk_style_context_add_class(gtk_widget_get_style_context(curWidgets->icvpack),"iconview"); curWidgets->socket=GTK_WIDGET(create_socket(curWidgets)); - + curWidgets->MenuItemAboutSystem=GTK_WIDGET(gtk_builder_get_object(curWidgets->builder,"MenuItemAboutSystem")); + g_signal_connect(G_OBJECT(curWidgets->MenuItemAboutSystem), "activate", G_CALLBACK(on_about_system),curWidgets); if (curWidgets->ButtonBackToMain!=NULL) gtk_button_set_label(GTK_BUTTON(curWidgets->ButtonBackToMain),_("Back to settings")); gtk_window_set_title(GTK_WINDOW(curWidgets->window),"UBLinux Settings Manager"); @@ -1419,7 +1438,6 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them g_signal_connect(G_OBJECT(curWidgets->SectionSettingsCloseButton), "clicked", G_CALLBACK(on_sections_close), curWidgets); g_signal_connect(G_OBJECT(curWidgets->SectionSettingsSaveButton), "clicked", G_CALLBACK(on_sections_save), curWidgets); g_signal_connect(G_OBJECT(curWidgets->CautionUnderstandButton), "clicked", G_CALLBACK(on_caution_understand), curWidgets); - g_signal_connect(G_OBJECT(curWidgets->MenuItemAboutSystem), "activate", G_CALLBACK(on_about_system),curWidgets); } gtk_label_set_text(GTK_LABEL(curWidgets->LabelTitle),_("UBLinux Settings Manager")); gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelSize),_("Icon size")); diff --git a/source/ubl-settings-manager.h b/source/ubl-settings-manager.h index d87b897..2d6502b 100644 --- a/source/ubl-settings-manager.h +++ b/source/ubl-settings-manager.h @@ -28,7 +28,7 @@ typedef struct apps{ char *Exec; char *Icon; int Pluggable; - + int DualPluggable; } apps; typedef struct dictionary { @@ -198,4 +198,7 @@ void yon_dictionary_make_first(dictionary *dict); dictionary *yon_create_icon_section_list(dictionary *sections); int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets); void yon_icon_size_convert(int mode); +void on_about_system(GtkWidget *button, actionWidgets *widgets); +char *yon_char_new(char *chr); +void launch(char *command); #endif \ No newline at end of file diff --git a/ubl-settings-manager.css b/ubl-settings-manager.css index 0da2d4f..d8e576c 100644 --- a/ubl-settings-manager.css +++ b/ubl-settings-manager.css @@ -1,5 +1,5 @@ * { -padding: 1; +padding: 1px; } @@ -7,7 +7,16 @@ padding: 1; background-color: #404040; } - +#thinborder { + border:0px; + background-image:none; + background-color: transparent; + color: transparent; + border-style: solid; + border-color:black; + border-bottom-width: 1px; + box-shadow: none; +} #GnomeIcon{ border-style:solid; @@ -26,12 +35,16 @@ background-color: #404040; background-color: #000000; color: #000000; } - GtkIconView.view.cell:selected, + + iconview:disabled { + background-color: rgba(0,0,0,0); +} +GtkIconView.view.cell:selected, GtkIconView.view.cell:selected:focus { background-color: #bababa; border-style: solid; - border-radius: 10px; - border-width: 3px; + border-radius: 3px; + border-width: 1px; border-color: #ffffff; }