header button implementation

pull/8/head
parent 2d666f2d85
commit 9289033a7b

@ -8,8 +8,8 @@ include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS}) link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER}) 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 -std=c++2a -g")
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 -g")
set(SOURCE_FILES set(SOURCE_FILES
ubl-settings-manager.c 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->socketplace,0);
gtk_widget_set_vexpand(widgets->HideWhileLaunch,1); gtk_widget_set_vexpand(widgets->HideWhileLaunch,1);
//printf("Plug has been removed!\n\n\n"); //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); 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); apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize);
printf("%s\n",tempapp->Name);
if (!tempapp){}else{ if (!tempapp){}else{
char arg[100]; char arg[100];
printf("%s\n",tempapp->Exec);
printf("%d\n",tempapp->Type);
printf("%d\n",tempapp->Pluggable);
memset(arg,0,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))); 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[0].Type==2)
if (tempapp->Pluggable==1) 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 py_launch_app(tempapp[0].Exec,"");
else if (tempapp[0].Type==1){ else if (tempapp[0].Type==1){
if (tempapp->Pluggable==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); 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); gtk_widget_destroy(applist->socket);
} }
applist->socket=create_socket(applist); applist->socket=create_socket(applist);
char *socket_id=malloc(sizeof(gtk_socket_get_id(GTK_SOCKET(applist->socket)))/sizeof(int)); on_about_system(NULL,applist);
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);
gtk_tree_model_get_iter(gtk_icon_view_get_model(self),&iter,path); 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); 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); apps *tempapp=get_app_by_name(applist->applist,name,applist->appssize);
char arg[100]; char arg[100];
memset(arg,0,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",gtk_socket_get_id(GTK_SOCKET(applist->socket)));
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)));
if (tempapp[0].Type==2) if (tempapp[0].Type==2)
if (tempapp->Pluggable==1) if (tempapp->Pluggable==1)
py_launch_app(tempapp[0].Exec,arg); if (tempapp->DualPluggable==1){
else py_launch_app(tempapp[0].Exec,""); char *dualarg=malloc(strlen("--socket-id= --socket-ext-id=")+30);
else if (tempapp[0].Type==1){ 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)));
if (tempapp->Pluggable==1) py_launch_app(tempapp[0].Exec,dualarg);
launch_app_with_arguments(tempapp[0].Exec,arg); } else
else launch_app(tempapp[0].Exec); 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; dictionary *next=widgets->ICSys->first;
for (dictionary *dct=next;dct!=NULL;dct=dct->next){ for (dictionary *dct=next;dct!=NULL;dct=dct->next){
IVGraphicals *IVG=(IVGraphicals*)dct->data; 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) if (gtk_icon_view_get_selected_items(GTK_ICON_VIEW(IVG->IV))>0)
gtk_icon_view_unselect_all(GTK_ICON_VIEW(IVG->IV)); 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); SectionSettingSegment *Sgm=yon_create_section_setting(IV->sectionName,IV->categories);
yon_segment_show(widgets,Sgm); yon_segment_show(widgets,Sgm);
dict->data=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=malloc(sizeof(dictionary));
dict->next->prev=dict; dict->next->prev=dict;
dict->next->first=dict->first; 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); launch_app_with_arguments("ubl-settings-info",arg);
} }
void launch(char *command){
system(command);
}
void launch_app_with_arguments(char *name, char *args){ void launch_app_with_arguments(char *name, char *args){
char *path=malloc(strlen(name)+strlen(args)+4); char *path=yon_char_get_augumented("/bin/",name);
memset(path,0,strlen(name)+strlen(args)+4); path=yon_char_get_augumented(path," ");
memcpy(path,name,strlen(name)); path=yon_char_get_augumented(path,args);
memcpy(path+strlen(name)," ",1); printf("%s\n",path);
strcat(args," &"); pthread_t thread_id;
strcat(path,args); pthread_create(&thread_id, NULL, launch, path);
system(("/usr/bin/%s",path));
}; };
void launch_app(char *name){ void launch_app(char *name){
char *path=yon_char_get_augumented(name," &"); char *path=name;
system(path); pthread_t thread_id;
pthread_create(&thread_id, NULL, launch, path);
}; };
void py_launch_app(char *name,char *args){ void py_launch_app(char *name,char *args){
char *path=malloc(strlen("python ./")+strlen(name)+6+strlen(args)); char *path=malloc(strlen("python ./")+strlen(name)+6+strlen(args));
sprintf(path,"python ./%s.py %s &",name,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;i<size;i++){ for (int i=0;i<size;i++){
if (strcmp(applist[i].Name,name)==0) return &applist[i]; if (strcmp(applist[i].Name,name)==0) return &applist[i];
} }
return NULL; return NULL;
}; };
@ -780,39 +804,25 @@ apps *find_apps(int *sizef){
if (tempapp.Icon==NULL) continue; if (tempapp.Icon==NULL) continue;
tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "Pluggable",NULL); tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "Pluggable",NULL);
if (tempapp.Pluggable==NULL) tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "X-XfcePluggable",NULL); if (tempapp.Pluggable==NULL) tempapp.Pluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "X-XfcePluggable",NULL);
if (tempapp.Pluggable!=NULL) tempapp.DualPluggable=g_key_file_get_boolean(gfile,"Desktop Entry", "X-UBLPluggable",NULL);
if (size==0){ if (size==0){
applist=(apps*)malloc(size+1*sizeof(apps)); applist=(apps*)malloc(size+1*sizeof(apps));
applist[0].Name=malloc(strlen(tempapp.Name)+1); applist[0].Name=yon_char_new(tempapp.Name);
applist[0].Categories=malloc(strlen(tempapp.Categories)+1); applist[0].Categories=yon_char_new(tempapp.Categories);
applist[0].Exec=malloc(strlen(tempapp.Exec)+1); applist[0].Exec=yon_char_new(tempapp.Exec);
applist[0].Icon=malloc(strlen(tempapp.Icon)+1); applist[0].Icon=yon_char_new(tempapp.Icon);
strncpy(applist[0].Name,tempapp.Name,strlen(tempapp.Name));
applist[0].Name[strlen(tempapp.Name)]='\0';
strncpy(applist[0].Categories,tempapp.Categories,strlen(tempapp.Categories));
applist[0].Categories[strlen(tempapp.Categories)]='\0';
strncpy(applist[0].Exec,tempapp.Exec,strlen(tempapp.Exec));
applist[0].Exec[strlen(tempapp.Exec)]='\0';
strncpy(applist[0].Icon,tempapp.Icon,strlen(tempapp.Icon));
applist[0].Icon[strlen(tempapp.Icon)]='\0';
applist[0].Type=tempapp.Type; applist[0].Type=tempapp.Type;
applist[0].Pluggable=tempapp.Pluggable; applist[0].Pluggable=tempapp.Pluggable;
applist[0].DualPluggable=tempapp.DualPluggable;
size++; size++;
} else { } else {
applist=(apps*)realloc(applist,(size+1)*sizeof(apps)); applist=(apps*)realloc(applist,(size+1)*sizeof(apps));
applist[size].Name=malloc(strlen(tempapp.Name)+1); applist[size].Name=yon_char_new(tempapp.Name);
applist[size].Categories=malloc(strlen(tempapp.Categories)+1); applist[size].Categories=yon_char_new(tempapp.Categories);
applist[size].Exec=malloc(strlen(tempapp.Exec)+1); applist[size].Exec=yon_char_new(tempapp.Exec);
applist[size].Icon=malloc(strlen(tempapp.Icon)+1); applist[size].Icon=yon_char_new(tempapp.Icon);
strncpy(applist[size].Name,tempapp.Name,strlen(tempapp.Name));
applist[size].Name[strlen(tempapp.Name)]='\0';
//printf("%s\n",applist[size].Name);
strncpy(applist[size].Categories,tempapp.Categories,strlen(tempapp.Categories));
applist[size].Categories[strlen(tempapp.Categories)]='\0';
strncpy(applist[size].Exec,tempapp.Exec,strlen(tempapp.Exec));
applist[size].Exec[strlen(tempapp.Exec)]='\0';
strncpy(applist[size].Icon,tempapp.Icon,strlen(tempapp.Icon));
applist[size].Icon[strlen(tempapp.Icon)]='\0';
applist[size].Pluggable=tempapp.Pluggable; applist[size].Pluggable=tempapp.Pluggable;
applist[size].DualPluggable=tempapp.DualPluggable;
applist[size].Type=tempapp.Type; applist[size].Type=tempapp.Type;
size++; size++;
} }
@ -986,6 +996,7 @@ IVGraphicals *yon_create_single_section_IV(char *name,char *cats){
} }
GtkWidget *sep=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); GtkWidget *sep=gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_name(sep,"thinborder");
GtkListStore *lv=gtk_list_store_new(2, GDK_TYPE_PIXBUF,G_TYPE_STRING); GtkListStore *lv=gtk_list_store_new(2, GDK_TYPE_PIXBUF,G_TYPE_STRING);
gtk_widget_set_halign(box,0); gtk_widget_set_halign(box,0);
gtk_widget_set_valign(box,1); gtk_widget_set_valign(box,1);
@ -1084,6 +1095,13 @@ char *yon_char_get_augumented(char *source, char *append){
return final; return final;
} }
char *yon_char_new(char *chr){
char *newchar=malloc(strlen(chr)+1);
memset(newchar,0,strlen(chr)+1);
memcpy(newchar,chr,strlen(chr));
return newchar;
}
int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets){ int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets){
for (dictionary *dct=IVS->first;dct!=NULL;dct=dct->next){ for (dictionary *dct=IVS->first;dct!=NULL;dct=dct->next){
IVGraphicals *iv=dct->data; IVGraphicals *iv=dct->data;
@ -1343,7 +1361,8 @@ dictionary *yon_theme_new(dictionary **widgetss, GtkBuilder *builder, char *them
curWidgets->SettingsSections=NULL; curWidgets->SettingsSections=NULL;
gtk_style_context_add_class(gtk_widget_get_style_context(curWidgets->icvpack),"iconview"); gtk_style_context_add_class(gtk_widget_get_style_context(curWidgets->icvpack),"iconview");
curWidgets->socket=GTK_WIDGET(create_socket(curWidgets)); 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) if (curWidgets->ButtonBackToMain!=NULL)
gtk_button_set_label(GTK_BUTTON(curWidgets->ButtonBackToMain),_("Back to settings")); gtk_button_set_label(GTK_BUTTON(curWidgets->ButtonBackToMain),_("Back to settings"));
gtk_window_set_title(GTK_WINDOW(curWidgets->window),"UBLinux Settings Manager"); 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->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->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->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->LabelTitle),_("UBLinux Settings Manager"));
gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelSize),_("Icon size")); gtk_label_set_text(GTK_LABEL(curWidgets->settingsSubmenuLabelSize),_("Icon size"));

@ -28,7 +28,7 @@ typedef struct apps{
char *Exec; char *Exec;
char *Icon; char *Icon;
int Pluggable; int Pluggable;
int DualPluggable;
} apps; } apps;
typedef struct dictionary { typedef struct dictionary {
@ -198,4 +198,7 @@ void yon_dictionary_make_first(dictionary *dict);
dictionary *yon_create_icon_section_list(dictionary *sections); dictionary *yon_create_icon_section_list(dictionary *sections);
int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets); int yon_show_icon_views(dictionary *IVS,actionWidgets *widgets);
void yon_icon_size_convert(int mode); 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 #endif

@ -1,5 +1,5 @@
* { * {
padding: 1; padding: 1px;
} }
@ -7,7 +7,16 @@ padding: 1;
background-color: #404040; 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{ #GnomeIcon{
border-style:solid; border-style:solid;
@ -26,12 +35,16 @@ background-color: #404040;
background-color: #000000; background-color: #000000;
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 { GtkIconView.view.cell:selected:focus {
background-color: #bababa; background-color: #bababa;
border-style: solid; border-style: solid;
border-radius: 10px; border-radius: 3px;
border-width: 3px; border-width: 1px;
border-color: #ffffff; border-color: #ffffff;
} }

Loading…
Cancel
Save