diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2c7ced --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +ublexec.glade~ +#ublexec.glade# +test.cpp +.vscode +ublexec +nohup.out +ublexec_ru.po~ \ No newline at end of file diff --git a/Makefile b/Makefile index ad374d7..61b9849 100644 --- a/Makefile +++ b/Makefile @@ -120,6 +120,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" + @install -Dm755 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "${PKGNAME}_terminals.csv" @install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy @if [ -z ${DESTDIR} ]; then \ diff --git a/gresource.xml b/gresource.xml index 67946e6..a2846f6 100644 --- a/gresource.xml +++ b/gresource.xml @@ -2,6 +2,7 @@ ublexec.glade + ublexec-application.glade ublexec.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e35dd6d..7091ce7 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -3,20 +3,15 @@ project(ublexec) find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK3 REQUIRED gtk+-3.0) -include_directories(${GTK3_INCLUDE_DIRS}) -link_directories(${GTK3_LIBRARY_DIRS}) -add_definitions(${GTK3_CFLAGS_OTHER}) +pkg_check_modules(GTK REQUIRED gtk+-3.0) +include_directories(${GTK_INCLUDE_DIRS}) +link_directories(${GTK_LIBRARY_DIRS}) +add_definitions(${GTK_CFLAGS_OTHER}) -pkg_check_modules(GTKMM30 REQUIRED gtkmm-3.0) -include_directories(${GTKMM30_INCLUDE_DIRS}) -link_directories(${GTKMM30_LIBRARY_DIRS}) -add_definitions(${GTKMM30_CFLAGS_OTHER}) - -#pkg_check_modules(VTE291 REQUIRED vte-2.91) -#include_directories(${VTE291_INCLUDE_DIRS}) -#link_directories(${VTE291_LIBRARY_DIRS}) -#add_definitions(${VTE291_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) @@ -41,6 +36,7 @@ add_custom_target(GLADE ublexec.glade) set(DEPENDFILES ../ublexec.glade + ../ublexec-application.glade ../gresource.xml ../ublexec-banner.png ../ublexec.css @@ -71,23 +67,22 @@ add_custom_target( set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection -g") + -fstack-clash-protection -fcf-protection") - set(SOURCE_FILES - main.cc - ublexec.cc + ublexec.c ublexec.h - ubl-util-standard.h - ubl-util-standard.c - ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h) + ubl-strings.h + ubl-utils.h + ubl-utils.c + ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h + ) set(LIBRARIES - ${GTK3_LIBRARIES} - ${GTKMM30_LIBRARIES} + ${GTK_LIBRARIES} ${WEBKIT_LIBRARIES} -# ${VTE291_LIBRARIES} + ${VTE291_LIBRARIES} pthread) @@ -99,4 +94,4 @@ set_source_files_properties( PROPERTIES GENERATED TRUE ) install(TARGETS ${PROJECT_NAME} DESTINATION bin) -add_dependencies(${PROJECT_NAME} dummy-resource) +add_dependencies(${PROJECT_NAME} dummy-resource) \ No newline at end of file diff --git a/source/main.cc b/source/main.cc deleted file mode 100644 index a00cdcb..0000000 --- a/source/main.cc +++ /dev/null @@ -1,51 +0,0 @@ -#include "ublexec.h" - -void pars_flag(int index_start, int argc, char* argv[]); - -int main(int argc, char** argv) { - string str_argv= ""; - string str_cmd_argv = ""; - - setlocale(LC_ALL, ""); - bindtextdomain(app_name, "/usr/share/locale/"); - bind_textdomain_codeset(app_name, "UTF-8"); - textdomain(app_name); - if (argc > 1){ - str_argv = argv[1]; - } - if (argc == 3) { - name_app_cmd = argv[2]; - string str_flag = argv[1]; - if (str_flag == "-x") { - flag_prog_file = 1; - } - else if (str_flag == "-e") { - flag_prog_file = 2; - } - } - pars_flag(1,argc, argv); - int local_argc = 1; - auto app = Gtk::Application::create(local_argc, argv, "org.gtkmm.example.plug"); - auto builder = Gtk::Builder::create_from_resource(path_glade); - MainWindow* wnd = nullptr; - builder->get_widget_derived("window", wnd); - auto r = app->run(*wnd); - delete wnd; - return r; -} - -void pars_flag(int index_start, int argc, char* argv[]) { - string str_argv = ""; - for (int i = index_start; i0&&LeftWidget){ - GtkWidget *plug=gtk_plug_new(left_plug_id); - GtkWidget *toplug=LeftWidget; - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - ret->plugLeft=plug; - } - if (right_plug_id>0&&RightWidget){ - GtkWidget *plug=gtk_plug_new(right_plug_id); - GtkWidget *toplug=RightWidget; - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - ret->plugRight=plug; - } - return ret; -} - -#endif - -#else - - -inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id){ - if (left_plug_id>0&&LeftWidget){ - GtkWidget *plug=gtk_plug_new(left_plug_id); - GtkWidget *toplug=GTK_WIDGET(LeftWidget->gobj()); - {GdkScreen *screen = gtk_widget_get_screen(plug); - gtk_widget_set_app_paintable(plug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(plug, colormap);} - {GdkScreen *screen = gtk_widget_get_screen(toplug); - gtk_widget_set_app_paintable(toplug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(toplug, colormap);} - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); - } - if (right_plug_id>0&&RightWidget){ - GtkWidget *plug=gtk_plug_new(right_plug_id); - GtkWidget *toplug=GTK_WIDGET(RightWidget->gobj()); - {GdkScreen *screen = gtk_widget_get_screen(plug); - gtk_widget_set_app_paintable(plug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(plug, colormap);} - {GdkScreen *screen = gtk_widget_get_screen(toplug); - gtk_widget_set_app_paintable(toplug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(toplug, colormap);} - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); - } -} -#endif \ No newline at end of file diff --git a/source/ubl-util-standard.h b/source/ubl-util-standard.h deleted file mode 100644 index 3209625..0000000 --- a/source/ubl-util-standard.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __cplusplus -#include -#include - -typedef struct { - GtkWidget *plugLeft; - GtkWidget *plugRight; - - -} returnstruct; -static returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id); -#else -#include -#include -#include -#include - - -static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id); -#endif \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c new file mode 100644 index 0000000..2041cd3 --- /dev/null +++ b/source/ubl-utils.c @@ -0,0 +1,2151 @@ +#include "ubl-utils.h" + +// dictionary functions + +/**yon_dictionary_new(): + * [EN] + * Creates and returns empty dictionary + * [RU] + * Создаёт и возвращает пустой словарь. + */ +dictionary *yon_dictionary_new() +{ + dictionary *dict = malloc(sizeof(dictionary)); + dict->data = NULL; + dict->key = NULL; + dict->next = NULL; + dict->prev = NULL; + dict->first = dict; + dict->data_type = DICTIONARY_OTHER_TYPE; + return dict; +} + +/**yon_dictionary_copy(dictionary *dict) + * [EN] + * + * [RU] + * Создаёт и возвращает копию элемента словаря [dict] +*/ +dictionary *yon_dictinoary_copy(dictionary *dict){ + dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data); + dct->data_type= dict->data_type; + return dct; +} + +/**yon_dictionary_copy_deep(dictionary *dict) + * [EN] + * + * [RU] + * Создаёт полную копию словаря [dict] и возвращает первый элемент +*/ +dictionary *yon_dictionary_copy_deep(dictionary *dict){ + dictionary *dct = NULL; + dictionary *newone=NULL; + for_dictionaries(dct,dict){ + yon_dictionary_add_or_create_if_exists_with_data(newone,dct->key,dct->data); + newone->data_type=dct->data_type; + } + return newone->first; +} + +/**int yon_dictionary_set_data(dictionary *dict, void *data) + * [EN] + * + * [RU] + * Установить элементу словаря [dict] значение [data] +*/ +int yon_dictionary_set_data(dictionary *dict, void *data){ + dict->data=data; +} + +/**int yon_dictionary_set_key(dictionary *dict, char *key) + * [EN] + * + * [RU] + * Изменяет ключ элемента словаря [dict] на [key] +*/ +int yon_dictionary_set_key(dictionary *dict, char *key){ + dict->key=key; + return 1; +} + +/** int yon_dictionary_set(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] +* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] +*/ +int yon_dictionary_set(dictionary *dict, char *key, void *data){ + dict->key=key; + dict->data=data; + return 1; +} + +/**int yon_dictionary_empty(dictionary *dict) + * [EN] + * + * [RU] + * Очищает элемент словаря [dict] от данных +*/ +int yon_dictionary_empty(dictionary *dict){ + dict->data=NULL; + dict->data_type=DICTIONARY_OTHER_TYPE; + return 1; +} + +/**yon_dictionary_switch_to_last(dictionary **dict) + * [EN] + * + * [RU] + * Переключает словарь [dict] на последний элемент. +*/ +void yon_dictionary_switch_to_last(dictionary **dict) +{ + dictionary *dct=NULL, *dact=*dict; + for_dictionaries(dct,dact); +} + +/**yon_dictionary_create_conneced(dictionary *targetdict) + * [EN] + * + * [RU] + * Создаёт новый элемент словаря [targetdict] +*/ +dictionary *yon_dictionary_append(dictionary *targetdict) +{ + targetdict = yon_dictionary_get_last(targetdict); + targetdict->next = yon_dictionary_new(); + targetdict->next->prev = targetdict; + targetdict->next->first = targetdict->first; + targetdict->next->data_type = DICTIONARY_OTHER_TYPE; + return targetdict->next; +} + +/**yon_dictionary_get_last(dictionary *dict) + * [EN] + * + * [RU] + * Возвращает последний элемент словаря [dict]. + * В отличае от yon_dictionary_switch_to_last() + * словарь [dict] остаётся на прежнем элементе. +*/ +dictionary *yon_dictionary_get_last(dictionary *dict) +{ + if (dict->next){ + dictionary *dct = NULL; + for_dictionaries(dct,dict); + return dct; + } else return dict; +} + +/**yon_dictionary_switch_places(dictionary *dict, int aim) + * [EN] + * + * [RU] + * Меняет элемент словаря [dict] местами с другим элементом. + * если [aim]<0 элемент меняется местами с левым элементом; + * если [aim]>0 элемент меняется местами с правым элементом; +*/ +dictionary *yon_dictionary_swap(dictionary *dict, int aim) +{ + if (aim < 0) + { + if (dict->prev) + { + if (dict->prev->prev) + { + dictionary *next = dict->next, *prev = dict->prev, *preprev = prev->prev; + if (next) + { + preprev->next = dict; + dict->prev = preprev; + dict->next = prev; + prev->prev = dict; + prev->next = next; + next->prev = prev; + } + else + { + preprev->next = dict; + dict->prev = preprev; + dict->next = prev; + prev->prev = dict; + prev->next = NULL; + } + return prev; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + if (next) + { + yon_dictionary_make_first(dict); + dict->prev = NULL; + dict->next = prev; + prev->prev = dict; + prev->next = next; + next->prev = prev; + } + else + { + dict->prev = NULL; + dict->next = prev; + prev->prev = dict; + prev->next = NULL; + } + return prev; + } + } + } + else if (aim > 0) + { + if (dict->next) + { + if (dict->next->next) + { + dictionary *next = dict->next, *prev = dict->prev, *afnext = next->next; + if (prev) + { + prev->next = next; + next->prev = prev; + next->next = dict; + dict->prev = next; + dict->next = afnext; + afnext->prev = dict; + } + else + { + yon_dictionary_make_first(next); + next->prev = NULL; + next->next = dict; + dict->prev = next; + dict->next = afnext; + afnext->prev = dict; + } + return next; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + if (prev) + { + prev->next = next; + next->prev = prev; + next->next = dict; + dict->prev = next; + dict->next = NULL; + } + else + { + next->prev = NULL; + next->next = dict; + dict->prev = next; + dict->next = NULL; + } + } + } + } +} + +/**yon_dictionary_make_first(dictionary *dict) + * [EN] + * + * [RU] + * Устанавливает указатель первого элемента словаря [dict] + * на текущий элемент. Не использовать. +*/ +void yon_dictionary_make_first(dictionary *dict) +{ + for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) + { + dct->first = dict; + } +} + +/**yon_dictionary_make_nth(dictionary *dict, int nth) + * [EN] + * + * [RU] + * Перемещает элемент словаря [dict] на позицию [nth]. +*/ +void yon_dictionary_make_nth(dictionary *dict, int nth) +{ + dictionary *dct = dict->first; + for (int i = 0; i < nth; i++) + { + if (dct == NULL) + return; + else + dct = dct->next; + } + yon_dictionary_rip(dict); + dictionary *prev = dct->prev; + prev->next = dict; + dict->prev = prev; + dict->next = dct; + dct->prev = dict; +} + +/**yon_dictionary_create_with_data(char *key, void *data) + * [EN] + * + * [RU] + * Создаёт новый словарь с ключом [key] и указателем на данные [data] +*/ +dictionary *yon_dictionary_new_with_data(char *key, void *data) +{ + dictionary *dct = yon_dictionary_new(); + dct->key = yon_char_new(key); + dct->data = data; + dct->data_type = DICTIONARY_OTHER_TYPE; + return dct; +} + +/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) + * [EN] + * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. + * [RU] + * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. +*/ +void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ + dictionary *dict=NULL; + for_dictionaries(dict,dictionary_to_free){ + if(data_manipulation) + data_manipulation(dict->data); + if(dict->prev) + free(dict->prev); + } + free(dict); + return NULL; +} + +/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] + * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] + * с ключом [key] и указателем на данные [data] +*/ +dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data) +{ + dictionary *dct = yon_dictionary_append(dict); + dct->key = yon_char_new(key); + dct->data = data; + dct->data_type = DICTIONARY_OTHER_TYPE; + return dct; +} + +/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) + * [EN] + * + * [RU] + * Присоединяет словарь [toconnect] в конец словаря [old]. +*/ +dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) +{ + dictionary *dict = yon_dictionary_get_last(old); + dict->next = toconnect; + toconnect->prev = dict; + toconnect->first = dict->first; + return toconnect; +} + +/**yon_dictionary_get(dictionary **dict, char *key) + * [EN] + * + * [RU] + * Возвращает элемент словаря [dict] с ключом [key]. + * Если такого элемента не было обнаружено, возвращается NULL +*/ +dictionary *yon_dictionary_get(dictionary **dict, char *key) +{ + dictionary *dct = *dict; + for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next) + { + if (strcmp(pointer->key, key) == 0) + { + *dict = pointer; + return pointer; + } + } + return NULL; +} + +/**yon_dictionary_rip(dictionary *dict) + * [EN] + * + * [RU] + * Вырезает элемент из словаря и возвращает вырезанный элемент. +*/ +dictionary *yon_dictionary_rip(dictionary *dict) +{ + if (!dict->next&&!dict->prev) return NULL; + else if (!dict->next) + { + dictionary *prev = dict->prev; + if (prev) + { + prev->next = NULL; + return prev; + } + else + return dict; + } + else if (!dict->prev) + { + dictionary *next = dict->next; + if (next) + { + yon_dictionary_make_first(next); + next->prev = NULL; + return next; + } + else + return dict; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + next->prev = prev; + prev->next = next; + return next; + } +} + +/**yon_dictionary_get_nth(dictionary *dict, int place) + * [EN] + * + * [RU] + * Возвращает [place]-й элемент словаря [dict] +*/ +dictionary *yon_dictionary_get_nth(dictionary *dict, int place) +{ + if (dict){ + dict = dict->first; + int i = 0; + for (i = 0; i < place; i++) + if (dict->next) + dict = dict->next; + else + break; + if (i == place) + return dict; + else + return NULL; + } else return NULL; +} + +// char functions + +int yon_char_find_last(char *source, char find){ + int size = strlen(source); + int i=size; + for (;source[i]!=find&&i>0;i--); + return i; +} + +/**[EN] + * + * creates new char string by combining two char strings. + */ +char *yon_char_append(char *source, char *append) +{ + if (source && append) + { + int size = strlen(source) + strlen(append) + 1; + char *final = malloc(size); + memset(final, 0, size); + if (strstr(source, "%%")) + sprintf(final, source, append); + else + sprintf(final, "%s%s", source, append); + return final; + } + else + return NULL; +} + +/**[EN] + * + * creates new char string by copying another char. + */ +char *yon_char_new(char *chr) +{ + if (chr){ + char *newchar = malloc(strlen(chr) + 1); + memset(newchar, 0, strlen(chr) + 1); + memcpy(newchar, chr, strlen(chr)); + return newchar; + } else + return NULL; +} + +/**yon_char_unite(char *source, ...) + * [En] + * + * [RU] + * Объединяет строку [source] со всеми строками, написанными в [...] +*/ +char *yon_char_unite(char *source, ...){ + va_list arglist; + char *new_char=NULL; + char *unite_char=NULL; + new_char=yon_char_new(source); + va_start(arglist,source); + unite_char = va_arg(arglist,char*); + while(unite_char){ + new_char = yon_char_append(new_char,unite_char); + unite_char = va_arg(arglist,char*); + } + va_end(arglist); + return new_char; +} + +/**yon_cut(char *source, int size, int startpos) + * [EN] + * cuts source string by size length from startpos position. + */ +char *yon_cut(char *source, int size, int startpos) +{ + char *cut = NULL; + cut = malloc(size + 1); + memset(cut, 0, size + 1); + memcpy(cut, source + startpos, size); + return cut; +} + +/**yon_char_divide(char *source, int dividepos) + * [EN] + * divides source string in dividepos position, + * returning left part of divided string and + * inserting right part to source string. + */ +char *yon_char_divide(char *source, int dividepos) +{ + char *cut = malloc(dividepos + 1); + memset(cut, 0, dividepos + 1); + memcpy(cut, source, dividepos); + char *left = malloc(strlen(source) - strlen(cut)); + memset(left, 0, strlen(source) - strlen(cut)); + memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); + memset(source, 0, strlen(source)); + memcpy(source, left, strlen(left)); + return cut; +} + +/**yon_char_find_count(char *source, char *find) + * [EN] + * + * [RU] + * Считает количество символов [find] в строке [source] +*/ +int yon_char_find_count(char *source, char *find){ + char *working_string=yon_char_new(source); + int i=0; + int size=0; + int pos=0; + config_str rtn = yon_char_parse(working_string,&size,"\n"); + for (int j=0;j= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(i * sizeof(char) + 1); + sprintf(ch, "%d", int_to_convert); + return ch; +} + +/**yon_char_from_long(int int_to_convert) + * [EN] + * converts int to char*. + * + * [RU] + * Конвертирует int в char* + */ +char *yon_char_from_long(long int_to_convert) +{ + int i = 1; + double convert_check = (double)int_to_convert; + for (i = 1; convert_check >= 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = g_malloc0(i * sizeof(char) + 1); + sprintf(ch, "%ld", int_to_convert); + return ch; +} + +/**yon_char_replace(char *source, char *find, char*replace) + * [EN] + * + * [RU] + * Заменяет в строке [source] все вхождения строки [find] на [replace] +*/ +char *yon_char_replace(char *source, char *find, char*replace){ + if (!strstr(replace,find)){ + + + char *final=NULL; + char *temp=NULL; + if(!strstr(replace,find)){ + while ((final=strstr(source,find))){ + temp=malloc(strlen(source)-strlen(final)); + memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); + memcpy(temp,source,strlen(source)-strlen(final)); + temp=yon_char_append(temp,replace); + source=yon_char_append(temp,final+1); + } + + } + } + return source; +} + +/**yon_char_parse(char *parameters, int *size, char *divider) + * [EN] + * Parses string [parameters], divided by [divider], + * then returns parsed string array and sets [size] to + * size of returned array +*/ +char **yon_char_parse(char *parameters, int *size, char *divider){ + char **string=NULL; + int i=1; + string=malloc(sizeof(char*)); + char *paramline=yon_char_new(parameters); + char *param; + if (!strstr(parameters,divider)) return NULL; + while ((param=yon_char_divide_search(paramline,divider,1))){ + if (strcmp(param,paramline)==0||paramline[0]=='\0') break; + string=realloc(string,sizeof(char*)*i); + string[i-1]=yon_char_new(param); + i++; + } + string=realloc(string,sizeof(char*)*i); + string[i-1]=yon_char_new(paramline); + i++; + *size=i-1; + return string; +} + +/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) + * [EN] + * + * [RU] + * Удаляет элемент [item_to_delete] из массива строк [char_string], размера [size] + * Возвращает получившийся массив, в [size] загружается размер нового массива. +*/ +char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){ + char **new_char_parsed=NULL; + new_char_parsed=malloc(sizeof(char*)*((*size)-1)); + int flag = 0; + for (int i=0;i < (*size);i++){ + if (i==item_to_delete) { + flag = 1; + } + if (flag == 0) { + new_char_parsed[i]=yon_char_new(char_string[i]); + } + else if (flag == 1 && i!=item_to_delete) { + new_char_parsed[i-1]=yon_char_new(char_string[i]); + } + } + (*size)=(*size)-1; + return new_char_parsed; +} + +/**yon_char_parsed_check_exist(char **parameters, int size, char *param) + * [EN] + * Checks if [parameters] string array of length [size] + * has [param] element; + * [RU] + * Проверяет есть ли в массиве строк [parameters], размера [size] + * элемент [param] +*/ +int yon_char_parsed_check_exist(char **parameters, int size, char *param){ + + for (int i=0;ipw_name,NULL); + else { + user_list = yon_char_parsed_append(user_list,user_size,user->pw_name); + } + } + endpwent(); + return user_list; +} + +config_str yon_ubl_get_all_processes(int *processes_size){ + config_str processes = yon_config_load(get_processes_command,processes_size); + yon_char_parsed_remove_newline_symbols(processes,processes_size); + return processes; +} + +config_str yon_ubl_get_all_slices(int *slices_size){ + config_str slices = yon_config_load(get_slices_command,slices_size); + yon_char_parsed_remove_newline_symbols(slices,slices_size); + return slices; +} + +// parsing functions + + +apps *yon_apps_scan_and_parse_desktops(int *sizef) +{ + int size = 0; + struct apps *applist; + { + DIR *directory = opendir(DesktopPath); + struct dirent *de; + while ((de = readdir(directory))) + { + FILE *file; + char *path = yon_char_append(DesktopPath, de->d_name); + file = fopen(path, "r"); + if (strlen(de->d_name) > 9) + { + char *extension = strstr(path, "."); + if (extension != NULL) + { + if (strcmp(extension, ".desktop") == 0) + { + apps tempapp; + GKeyFile *gfile = g_key_file_new(); + GError *err = NULL; + g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); + char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); + if (err) + { + printf("%s\n", err->message); + } + if (strcmp(Type, "Application") == 0) + tempapp.Type = 1; + else if (strcmp(Type, "pyApplication") == 0) + tempapp.Type = 2; + else + continue; + tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); + if (tempapp.Name == NULL) + continue; + tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); + if (tempapp.Categories == NULL) + continue; + tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); + if (tempapp.Exec == NULL) + continue; + tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); + if (tempapp.Icon == NULL) + continue; + tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); + if (!tempapp.Pluggable) + tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); + if (tempapp.Pluggable) + tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); + if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) + if (size == 0) + { + applist = (apps *)malloc(size + 1 * sizeof(apps)); + applist[0].filename = yon_char_new(path); + applist[0].Name = yon_char_new(tempapp.Name); + applist[0].Categories = yon_char_new(tempapp.Categories); + applist[0].Exec = yon_char_new(tempapp.Exec); + applist[0].Icon = yon_char_new(tempapp.Icon); + applist[0].Type = tempapp.Type; + applist[0].Pluggable = tempapp.Pluggable; + applist[0].DualPluggable = tempapp.DualPluggable; + size++; + } + else + { + applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); + applist[size].filename = yon_char_new(path); + applist[size].Name = yon_char_new(tempapp.Name); + applist[size].Categories = yon_char_new(tempapp.Categories); + applist[size].Exec = yon_char_new(tempapp.Exec); + applist[size].Icon = yon_char_new(tempapp.Icon); + applist[size].Pluggable = tempapp.Pluggable; + applist[size].DualPluggable = tempapp.DualPluggable; + applist[size].Type = tempapp.Type; + size++; + } + } + } + } + } + } + *sizef = size; + return applist; +}; + +void yon_apps_sort(apps *applist, int size) +{ + apps tmp; + if (size > 2) + { + for (int i = 1; i < size; i++) + { + for (int j = 1; j < size; j++) + { + if (strcmp(applist[j].Name, applist[j - 1].Name) < 0) + { + tmp = applist[j]; + applist[j] = applist[j - 1]; + applist[j - 1] = tmp; + }; + } + }; + } +}; + +apps *yon_apps_get_by_name(apps *applist, char *name, int size) +{ + for (int i = 0; i < size; i++) + { + if (strcmp(applist[i].Name, name) == 0) + return &applist[i]; + } + return NULL; +}; + +void __yon_on_app_chooser_selection(GtkTreeView *self, GtkTreeStore *store){ + GtkTreeModel *model = GTK_TREE_MODEL(store); + GtkTreeIter iter, parentiter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(self),&model,&iter)){ + if (!gtk_tree_model_iter_parent(model,&parentiter,&iter)){ + gtk_tree_view_expand_row(self,gtk_tree_model_get_path(model,&iter),0); + if (gtk_tree_model_iter_nth_child(model,&parentiter,&iter,0)) + gtk_tree_selection_select_iter(gtk_tree_view_get_selection(self),&parentiter); + } + } +} + +/**yon_app_chooser_open_with_sections(char *section_name, char *section_filter, char *section_icon, ...) + * [EN] + * + * [RU] + * Вызывает диалоговое окно выбора приложений с разделом [section_name], разделом [section_filter] и иконкой, полученной по названию [section_icon]. + * после них можно вводить любое количество пар названий раздела и названий иконок для получения дополнительных разделов, + * оканчивающиеся NULL. +*/ +char *yon_app_chooser_open_with_sections(char *section_name, char *section_filter, char *section_icon, ...){ + GtkBuilder *builder = gtk_builder_new_from_resource("/com/ublinux/ui/ublexec-application.glade"); + GtkWidget *dialog = gtk_dialog_new(); + gtk_widget_set_size_request(dialog,500,600); + gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ublexec"); + gtk_window_set_title(GTK_WINDOW(dialog),_("Applications")); + gtk_dialog_add_buttons(GTK_DIALOG(dialog),_("Cancel"),0,_("Accept"),1,NULL); + GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder,"ApplicationsWindow")); + GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder,"box")); + g_object_ref(box); + gtk_container_remove(GTK_CONTAINER(window),box); + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),box,1,1,5); + GtkWidget *main_tree = GTK_WIDGET(gtk_builder_get_object(builder,"MainTree")); + GtkTreeStore *store = GTK_TREE_STORE(gtk_builder_get_object(builder,"treestore1")); + va_list args; + GtkTreeIter iter, childiter; + + g_signal_connect(G_OBJECT(main_tree),"cursor-changed",G_CALLBACK(__yon_on_app_chooser_selection),store); + + gtk_tree_store_append(GTK_TREE_STORE(store),&iter,NULL); + gtk_tree_store_set(GTK_TREE_STORE(store),&iter,0,section_icon,1,section_name,2,section_filter,-1); + va_start(args,section_icon); + char *section; + while ((section = va_arg(args,char*))){ + char *filter = va_arg(args,char*); + char *icon = va_arg(args,char*); + if (icon&&filter){ + gtk_tree_store_append(GTK_TREE_STORE(store),&iter,NULL); + gtk_tree_store_set(GTK_TREE_STORE(store),&iter,0,icon,1,section,2,filter,-1); + } + } + va_end(args); + int size; + apps *app_list = yon_apps_scan_and_parse_desktops(&size); + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),&iter); + for (; valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store),&iter)){ + char *cur_categories; + gtk_tree_model_get(GTK_TREE_MODEL(store),&iter,2,&cur_categories,-1); + for (int i=0; idata_type=DICTIONARY_CHAR_TYPE; + } + } + check_config + return 1; + else return 0; +} + +/**yon_config_remove_by_key(char *key) + * [EN] + * + * [RU] + * Удаляет параметр конфига по ключу [key] +*/ +int yon_config_remove_by_key(char *key){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + if (dict){ + yon_dictionary_rip(dict); + return 1; + }else return 0; + } + return 0; +} + +/**yon_config_remove_by_data(void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу на наличие параметра со значением [data] и удаляет найденное значение из конфига. +*/ +int yon_config_remove_by_data(void *data){ + check_config{ + dictionary *dict = NULL; + for_dictionaries(dict,__yon__config__strings){ + if (dict->data==data){ + yon_dictionary_rip(dict); + return 1; + } + } + return 0; + } + return 0; +} + +/**yon_config_remove_element(char *key, char *deleted) + * [EN] + * + * [RU] + * Удаляет элемент [deleted] из массива параметров с ключом [key] +*/ +int yon_config_remove_element(char *key, char *deleted){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + char *data = (char*)dict->data; + char *found = strstr(data,deleted); + int size=strlen(data)-strlen(found)+1; + char *new_data = malloc(size); + memset(new_data,0,size); + if (strlen(found)!=strlen(deleted)){ + memcpy(new_data,data,size-1); + new_data = yon_char_append(new_data,found+strlen(deleted)+1); + } else { + memcpy(new_data,data,size-2); + new_data = yon_char_append(new_data,found+strlen(deleted)); + } + dict->data=(void*)(new_data); + // free(data); + dict->flag1=1; + return 1; + } else return 0; +} + +/**yon_config_get_by_key(char *key) + * [EN] + * + * [RU] + * Возвращает значение параметра конфига с ключом [key] +*/ +void *yon_config_get_by_key(char *key){ + check_config{ + dictionary *dict = NULL; + for_dictionaries(dict, __yon__config__strings){ + if (strcmp(dict->key,key)==0){ + return dict->data; + } + } + } + return NULL; +} + +/**yon_config_get_key_by_data(char *data) + * [EN] + * + * [RU] + * Возвращает ключ параметра конфига со значением [data]. + * Если параметр с таким значением не найден, возвращается NULL +*/ +char *yon_config_get_key_by_data(char *data){ + check_config{ + dictionary *dict = NULL; + for_dictionaries(dict, __yon__config__strings){ + if (strcmp(((char*)dict->data),data)==0){ + return dict->key; + } + } + } + return NULL; +} + +/**yon_config_set(char *key, void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу и заменяет значение параметра с ключом [key] на новое значение [data]; +*/ +int yon_config_set(char *key, void *data){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + dict->data=data; + dict->flag1=1; + return 1; + } else return 0; +} + + +/**yon_config_append(char *key, void *data) + * [EN] + * + * [RU] + * Производит поиск по конфигу и дополняет значение параметра с ключом [key] значением [data]; +*/ +int yon_config_append(char *key, char *data){ + check_config{ + dictionary *dict = yon_dictionary_get(&__yon__config__strings,key); + if (strcmp(((char*)dict->data),"")!=0) + dict->data=(void*)(yon_char_unite((char*)dict->data," ",data,NULL)); + else dict->data=(void*)data; + dict->flag1=1; + return 1; + } else return 0; +} + + +/**yon_config_clean() + * [EN] + * Erase all parameters from config; + * [RU] + * Удаляет все параметры из конфига; +*/ +int yon_config_clean(){ + check_config{ + __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); + return 1; + } + else return 0; +} + +/**yon_config_register(char *key, void *data) + * [EN] + * + * [RU] + * Регистрирует новый параметр конфига. + * [key] - ключ параметра; + * [data] - значение параметра; +*/ +void yon_config_register(char *key, void *data){ + if (!__yon__config__strings||!yon_dictionary_get(&__yon__config__strings,key)){ + yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,data); + } + else if (yon_dictionary_get(&__yon__config__strings,key)) __yon__config__strings->data=data; + __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; + __yon__config__strings->flag1=1; +} + +/**yon_config_load(char *command, int *str_len) + * [EN] + * + * [RU] + * Выполняет команду [command] и возвращает распаршеный результат выполнения команды. + * В [str_len] возвращается длина возвращаемого массива +*/ +config_str yon_config_load(char *command, int *str_len){ + FILE *output = popen(command, "r"); + char **output_strings = NULL; + output_strings = malloc(sizeof(char)); + int i = 0; + char str[4096]; + memset(str, 0, 4096); + while (fgets(str, 4096, output)) + { + if (strcmp(str, "") != 0) + { + output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); + // printf("%s\n", str); + output_strings[i] = NULL; + output_strings[i] = yon_char_new(str); + memset(str, 0, 4096); + i++; + } + } + if (i>0){ + *str_len = i; + return output_strings; + } else{ + *str_len=-1; + return NULL; + } +} + +/**int yon_config_save_registered(char *path, char *section) + * [EN] + * Saves config with [command] + * [RU] + * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: + * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" +*/ +int yon_config_save_registered(char *path, char *section){ + check_config{ + char *command = yon_char_unite("/usr/bin/ubconfig",path ? yon_char_append(" --target ",path):"", " set ", section,NULL); + char *remove_command = yon_char_unite("/usr/bin/ubconfig", path ? yon_char_append(" --target ",path):"", " remove ", section,NULL); + dictionary *dict = NULL; + int any_add = 0; + int any_remove = 0; + for_dictionaries(dict,__yon__config__strings){ + char *data = yon_dictionary_get_data(dict,char*); + if (dict->flag1==1&&strcmp(data,"")!=0){ + command = yon_char_unite(command, " ", dict->key,"=\"", yon_dictionary_get_data(dict,char*),"\"", NULL); + any_add=1; + } + if (strcmp(data,"")==0){ + remove_command = yon_char_unite(remove_command, " ", dict->key, NULL); + any_remove=1; + } + } + if (any_add) yon_launch(command); + if (any_remove) yon_launch(remove_command); + return 1; + } else return 1; +} + +/**yon_config_get_all(int *size) + * [EN] + * + * [RU] + * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL + * [size] - указатель, в который выгружается длина массива +*/ +config_str yon_config_get_all(int *size){ + check_config{ + *size = 1; + config_str conf = NULL; + dictionary *dict = NULL; + for_dictionaries(dict,__yon__config__strings){ + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); + (*size)++; + } + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[*size-1] = NULL; + return conf; + } else return NULL; +} + +/**char *yon_config_get_parameter(config parameters, int size, char *param) + * [EN] + * Gets parameter [param] from parameter list [parameters] of size [size]; + * or NULL if nothing were found + * [RU] + * Возвращает параметр [param] из массива строк [parameters] размером [size] + * или NULL если такой не был найден +*/ +char *yon_config_get_parameter(config_str parameters, int size, char *param) +{ + if (param[0]==' ') + yon_char_divide_search(param," ",-1); + param=yon_char_divide_search(yon_char_new(param)," ",-1); + + char *str = NULL; + for (int j = 0; j < size; j++) + { + char *name = yon_char_divide_search(yon_char_new(parameters[j]), "=", 1); + if (name) + { + if (strcmp(name, param) == 0) + { + str = yon_char_divide_search(yon_char_new(parameters[j]), "\n", 1); + if (strcmp(str, "") != 0 && strcmp(str, "(null)") != 0) + return str; + else + return NULL; + } + } + } + return NULL; +} + + + +// terminal-using functions + +/**yon_launch_app_with_arguments(char *name, char *args) + * [EN] + * Execute [command] in separate thread; + * [RU] + * Выполнить команду [command] в отдельном потоке; +*/ +int yon_launch_app_with_arguments(char *name, char *args) +{ + char *path = yon_char_unite(name, " ", args,NULL); + pthread_t thread_id; + char *command = NULL; + command = path; + pthread_create(&thread_id, NULL, (void *)yon_launch, command); +}; + +/**yon_launch(char *command) + * [EN] + * Execute command [command] + * [RU] + * Выполнить команду [command] +*/ +void yon_launch(char *command) +{ + system(command); +} + + +/**yon_launch(char *command) + * [EN] + * Execute command [command] + * [RU] + * Выполнить команду [command] +*/ +void yon_launch_thread(char *command) +{ + pthread_t thread_id; + pthread_create(&thread_id, NULL, (void *)yon_launch, command); +} + +// Gtk functions + + +#ifdef __GTK_H__ + + +static render_data render; + +#ifdef VTE_TERMINAL + +static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) +{ + if (!terminal) return; + if (pid == -1) printf("Error\n\n\n"); + else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); +} + +/** + * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) + * [EN] + * launches terminal with specific [command], + * terminal is shown in [place_to_show] container, + * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. + * [RU] + * Запускает терминал с командой [command], + * терминал добавляется в контейнер [place_to_show] виджета, + * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. +*/ +void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){ + char **commands=new_arr(char*,2); + gchar **envp = g_get_environ(); + commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); + commands[1]=NULL; + char **env=new_arr(char*,2); + env[0]=""; + env[1]=NULL; + GtkWidget *terminal = vte_terminal_new(); + vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); + VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); + vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); + gtk_container_add(GTK_CONTAINER(place_to_show),terminal); + char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); + if(endwork_function) + g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); + vte_terminal_spawn_async(VTE_TERMINAL(terminal), + VTE_PTY_DEFAULT, + NULL, + commands, + NULL, + 0, + NULL, NULL, + NULL, + -1, + NULL, + child_ready, + install_command); + vte_pty_spawn_async(pty, + NULL, + commands, + NULL, + 0, + NULL, NULL, + NULL, + -1, + NULL, + NULL, + NULL); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); + vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); + vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); + gtk_widget_show_all(terminal); + } + +/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument) + * [EN] + * launches terminal with specific [command], + * terminal is shown in [place_to_show] container, + * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. + * [RU] + * Запускает терминал с командой [command], + * терминал добавляется в контейнер [place_to_show] виджета, + * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. +*/ +void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ + char **commands=new_arr(char*,2); + gchar **envp = g_get_environ(); + commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); + commands[1]=NULL; + char **env=new_arr(char*,2); + env[0]=""; + env[1]=NULL; + vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); + VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); + vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); + char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL); + if(endwork_function) + g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); + vte_terminal_spawn_async(VTE_TERMINAL(terminal), + VTE_PTY_DEFAULT, + NULL, + commands, + NULL, + 0, + NULL, NULL, + NULL, + -1, + NULL, + child_ready, + install_command); + vte_pty_spawn_async(pty, + NULL, + commands, + NULL, + 0, + NULL, NULL, + NULL, + -1, + NULL, + NULL, + NULL); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); + vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); + vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); + gtk_widget_show_all(terminal); + } +#endif + + // Window config functions + + #define check_window_config_setup if(__yon_window_config_target_window) + + typedef struct { + char *parameter_name; + enum YON_TYPE containing_type; + GtkWidget *track_widget; + char *property_name; + } __yon_listener_parameter; + + typedef struct { + char *parameter_name; + char *section; + enum YON_TYPE containing_type; + void *property; + } __yon_custom_parameter; + + struct { + int x; + int y; + int width; + int height; + int fullscreen; + dictionary *custom_listeners; + dictionary *custom_parameters; + dictionary *deleted_parameters; + } __yon_main_window_config; + + static GtkWindow *__yon_window_config_target_window = NULL; + static GKeyFile *__yon_window_config_file = NULL; + static char *__yon_window_config_path = NULL; + + void yon_window_config_save(){ + g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); + g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); + g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width); + g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); + g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); + dictionary *dict=NULL; + if (__yon_main_window_config.custom_listeners) + for_dictionaries(dict,__yon_main_window_config.custom_listeners){ + __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); + switch(param->containing_type){ + case YON_TYPE_STRING: + g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val)); + break; + case YON_TYPE_INT: + g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val)); + break; + case YON_TYPE_DOUBLE: + g_key_file_set_double(__yon_window_config_file,"window",param->parameter_name, g_value_get_double(val)); + break; + case YON_TYPE_BOOLEAN: + g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val)); + break; + case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; + } + } + if (__yon_main_window_config.custom_parameters) + for_dictionaries(dict,__yon_main_window_config.custom_parameters){ + __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); + switch (param->containing_type){ + case YON_TYPE_STRING: + g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property); + break; + case YON_TYPE_INT: + g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property); + break; + case YON_TYPE_DOUBLE: + g_key_file_set_double(__yon_window_config_file,param->section,param->parameter_name, *(double*)param->property); + break; + case YON_TYPE_BOOLEAN: + g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property); + break; + default: + break; + } + } + if (__yon_main_window_config.deleted_parameters) + for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ + __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); + g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); + } + g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); + } + + void yon_get_is_fullscreen(){ + gtk_window_is_maximized(__yon_window_config_target_window); + __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); + if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); + } + + /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) + * [EN] + * + * [RU] + * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. + */ + void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ + check_window_config_setup{ + yon_get_is_fullscreen(); + yon_window_config_save(); + } + gtk_main_quit(); + } + + void __yon_window_config_on_resize(){ + int max=0; + max=gtk_window_is_maximized(__yon_window_config_target_window); + if(max==0){ + gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); + gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); + } + } + + /**yon_window_config_setup(GtkWindow *window) + * [EN] + * + * [RU] + * Устанавливает указатель на окно для отслеживания его положения и размера + */ + void yon_window_config_setup(GtkWindow *window){ + __yon_window_config_target_window = window; + g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); + g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); + } + + void _yon_maximize(void *data){ + g_usleep(G_USEC_PER_SEC/10); + if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); + } + + /**yon_window_config_load(char *path) + * [EN] + * + * [RU] + * Загружает конфиг окна и инициализирует отслеживание его параметров + */ + int yon_window_config_load(char *path){ + __yon_window_config_file = g_key_file_new(); + __yon_window_config_path=yon_char_new(path); + if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ + struct stat st; + int size; + char *path = yon_char_divide(yon_char_new(__yon_window_config_path),yon_char_find_last(__yon_window_config_path,'/')); + if (stat(path, &st) == -1) { + mkdir(path, 0777); + } + FILE *fp; + fp=fopen(__yon_window_config_path,"w"); + fclose(fp); + g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); + } + __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); + __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL); + __yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL); + __yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL); + __yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL); + dictionary *dict=NULL; + if (__yon_main_window_config.custom_listeners) + for_dictionaries(dict,__yon_main_window_config.custom_listeners){ + __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); + GValue *val = g_malloc0(sizeof(GValue)); + g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); + switch(param->containing_type){ + case YON_TYPE_STRING: + g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL)); + break; + case YON_TYPE_INT: + g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL)); + break; + case YON_TYPE_DOUBLE: + g_value_set_double(val,g_key_file_get_double(__yon_window_config_file,"window",param->parameter_name, NULL)); + break; + case YON_TYPE_BOOLEAN: + gboolean res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL); + g_value_set_boolean(val,res); + break; + default:printf("\033[0;31mCannot load %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; + } + g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val); + } + if (__yon_main_window_config.width!=0&&__yon_main_window_config.height!=0) gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); + if (__yon_main_window_config.x!=0&&__yon_main_window_config.y!=0) gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); + + + pthread_t tid; + pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); + return 1; + } + + void yon_window_config_apply(){ + dictionary *dict=NULL; + gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); + gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); + } + + config_str yon_window_config_get_section(char *section, gsize *size){ + config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL); + return key; + } + + /**yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type) + * [EN] + * + * [RU] + * Добавляет параметр виджета [widget] по названию [widget_property] для отслеживания и сохраняет его в конфиг под ключом [param_name]. + */ + void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type){ + __yon_listener_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_listener_parameter)); + param->parameter_name = yon_char_new(param_name); + param->track_widget = widget; + param->property_name = yon_char_new(widget_property); + param->containing_type = val_type; + yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_listeners,param->parameter_name,param); + } + + void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type){ + __yon_custom_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_custom_parameter)); + param->parameter_name = yon_char_new(param_name); + param->section=section; + param->property = tracked_value; + param->containing_type = val_type; + yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.custom_parameters,param->parameter_name,param); + } + + void yon_window_config_erase_custom_parameter(char *param_name, char *section){ + __yon_custom_parameter *param = NULL; + param = yon_remalloc(param,sizeof(__yon_custom_parameter)); + param->parameter_name=param_name; + param->section=section; + yon_dictionary_add_or_create_if_exists_with_data(__yon_main_window_config.deleted_parameters,param->parameter_name,param); + } + + int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type){ + GError *err=NULL; + switch (type){ + case YON_TYPE_BOOLEAN: + *((int*)return_value) = g_key_file_get_boolean(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_INT: + *((int*)return_value) = g_key_file_get_integer(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_DOUBLE: + *((int*)return_value) = g_key_file_get_double(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_STRING: + *((char**)return_value) = g_key_file_get_string(__yon_window_config_file,section,config_parameter,&err); + if (err) return 0; else return 1; + break; + case YON_TYPE_STRING_LIST: + gsize size=0; + *((char***)return_value) = g_key_file_get_string_list(__yon_window_config_file,section,config_parameter,&size,&err); + *((char***)return_value)=yon_remalloc(return_value,size+1); + *((char***)return_value)[size]=NULL; + if (err) return 0; else return 1; + break; + } + } + +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"aaa"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"aaa"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + + +// other Gtk functions + +/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) + * [EN] + * + * [RU] + * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] +*/ +int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ + if (combo&¶meters){ + for (int i=0;i=0 ? 1 : 0); +} + +void yon_gtk_widget_set_sensitive_from_toggle_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target){ + gtk_widget_set_sensitive(target,!gtk_combo_box_get_active(toggle)>=0 ? 0 : 1); +} + +void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) +{ + gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); + gtk_image_set_from_file(GTK_IMAGE(Image), image_path); +} + +void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) +{ + gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); + gtk_image_set_from_resource(GTK_IMAGE(Image), image_path); +} + +int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) +{ + if(icon&&box&&label){ + render.icon=icon; + render.box=box; + render.label=label; + return 1; + } else return 0; +} + +void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) +{ + render_data data = render; + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + GError *err = NULL; + if (err) + { + printf("%s\n", err->message); + g_error_free(err); + } + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); + } + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); + } + if (text) + gtk_label_set_text(GTK_LABEL(data.label), text); +} + +void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ + _yon_ubl_status_box_render(text,type); +} + +/**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) + * [EN] + * Set up plugs for using with GtkSockets insine ubl-settings-manager. + * [main_window] is container widget, which holds main application functionality. + * [left_window] is container widget, which holds widgets, have to be shown at left part of ubl-settings-manager header. + * [right_window] is container widget, which holds widgets, have to be shown at right part of ubl-settings-manager header. + * [socket_main_id] is id of socket for [main_window]. + * [socket_left_id] is id of socket for [left_window]. + * [socket_right_id] is id of socket for [right_window]. + * [RU] + * Настраивает плаги для работы с сокетами в утилите ubl-settings-manager. + * [main_window] - контейнер основного интерфейса приложения. + * [left_window] - контейнер для виджетов которые должны отображаться в левой части шапки ubl-settings-manager. + * [right_window] - контейнер для виджетов которые должны отображаться в правой части шапки ubl-settings-manager. + * [socket_main_id] - id сокета для [main_window]. + * [socket_left_id] - id сокета для [left_window]. + * [socket_right_id] - id сокета для [right_window]. +*/ +void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id){ + if (main_window&&socket_main_id>-1){ + gtk_widget_hide(gtk_widget_get_toplevel(main_window)); + GtkWidget *plug_main=gtk_plug_new(socket_main_id); + GtkWidget *plug_left=NULL; + GtkWidget *plug_right=NULL; + GtkWidget *box=NULL; + g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL); + if (socket_left_id>-1&&left_window){ + plug_left=gtk_plug_new(socket_left_id); + g_object_ref(left_window); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); + gtk_container_add(GTK_CONTAINER(plug_left),left_window); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar"); + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button"); + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited"); + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder"); + gtk_widget_show(plug_left); + } + else if (left_window){ + if (box==NULL){ + box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); + gtk_box_reorder_child(GTK_BOX(main_window),box,0); + gtk_widget_show(box); + } + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"inherited"); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); + gtk_box_pack_end(GTK_BOX(box),left_window,0,0,5); + } + if (socket_right_id>-1&&right_window){ + plug_right=gtk_plug_new(socket_right_id); + g_object_ref(right_window); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); + gtk_container_add(GTK_CONTAINER(plug_right),right_window); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar"); + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button"); + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited"); + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder"); + gtk_widget_show(plug_right); + } + else if (right_window){ + if (box==NULL){ + box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); + gtk_box_reorder_child(GTK_BOX(main_window),box,0); + gtk_widget_show(box); + } + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"inherited"); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); + gtk_box_pack_start(GTK_BOX(box),right_window,0,0,5); + } + g_object_ref(main_window); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window); + gtk_container_add(GTK_CONTAINER(plug_main),main_window); + gtk_widget_show(plug_main); + } +} + +#ifdef WEBKIT_FOUND + +/**yon_ubl_browser_window_open(char *link, char *browser_window_name) + * [EN] + * Launches integrated browser window, named [browser_window_name] at header with [link]. + * [RU] + * Открывает встроенный браузер с именем [browser_window_name] и показываемой страницей по ссылке [link] +*/ +void yon_ubl_browser_window_open(char *link, char *browser_window_name){ + GtkWidget *browser=gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget *web_place=gtk_box_new(GTK_ORIENTATION_VERTICAL,0); + GtkWidget *header=gtk_header_bar_new(); + GtkWidget *header_label=gtk_label_new(browser_window_name); + GtkWidget *WebView=webkit_web_view_new(); + gtk_container_add(GTK_CONTAINER(browser),web_place); + gtk_window_set_titlebar(GTK_WINDOW(browser),header); + gtk_window_set_title(GTK_WINDOW(browser),browser_window_name); + gtk_widget_set_size_request(browser,800,600); + gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header),header_label); + gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),link); + gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0); + gtk_widget_show_all(browser); +} +#else + +/**yon_ubl_browser_window_open(char *link, char *browser_window_name) + * [EN] + * Launches browser with [link]. + * [browser_window_name] is't used. It's needed for compatibility with webkit version of that function. + * [RU] + * Открывает браузер со страницей по ссылке [link] + * [browser_window_name] не используется. Нужна для совместимости с webkit версией этой функции. +*/ +void yon_ubl_browser_window_open(char *link, char *browser_window_name){ + char *user=getenv("SUDO_USER"); + if (!user) + user=getlogin(); + char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); + yon_launch_app(command); +} +#endif + +#endif \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h new file mode 100644 index 0000000..7d05925 --- /dev/null +++ b/source/ubl-utils.h @@ -0,0 +1,380 @@ +#ifndef UBL_UTILS +#define UBL_UTILS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ubl-cmake.h" +#ifdef WEBKIT_FOUND + #include +#endif + +#define _(String) gettext(String) + +#define DesktopPath "/usr/share/applications/" +#define try bool __HadError=false; +#define catch(x) ExitJmp:if(__HadError) +#define throw(x) {__HadError=true;goto ExitJmp;} +static char** array_size_pow; +#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) + +#define new(type) malloc(sizeof(type)) +#define new_arr(type,size) malloc(sizeof(type)*size) + +#define get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL) + +#define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\"" +#define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\"" + +typedef enum +{ + #ifdef __GTK_H__ + DICTIONARY_GTK_WIDGETS_TYPE, + #endif + DICTIONARY_OTHER_TYPE=0, + DICTIONARY_CHAR_TYPE, + DICTIONARY_INT_TYPE, + DICTIONARY_BOOL_TYPE, + +} DICT_TYPE; + +typedef struct dictionary +{ + char *key; + void *data; + struct dictionary *next; + struct dictionary *prev; + struct dictionary *first; + DICT_TYPE data_type; + int flag1; +} dictionary; + +typedef struct apps +{ + char *filename; + char *Name; + int Type; + char *Categories; + char *Exec; + char *Icon; + int Pluggable; + int DualPluggable; +} apps; + +typedef char** config_str; + +static dictionary *__yon__config__strings = NULL; +#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) + +#define config(key) yon_config_get_by_key(key) + +#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings) + +#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) +// dictionary functions + +/**yon_dictionary_get_data(dictionary, type) + * [EN] + * Gets data from dictionary. + * [dictionary] is dictionary, from which data should be extracted; + * [type] is type of data, [dictionary] contains. + * [RU] + * Возвращает данные из словаря. + * [dictionary] - словарь из которого достаются данные. + * [type] - тип данных, хранящихся в словаре [dictionary]. +*/ +#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) + +/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) + * [EN] + * + * [RU] + * Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data]. + * Если словарь не существует, создаёт его +*/ +#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \ + else dict=yon_dictionary_append_with_data(dict,key,data);} + +dictionary *yon_dictionary_new(); + +dictionary *yon_dictionary_append(dictionary *targetdict); + +dictionary *yon_dictionary_get_last(dictionary *dict); + +dictionary *yon_dictionary_swap(dictionary *dict, int aim); + +void yon_dictionary_make_first(dictionary *dict); + +void yon_dictionary_make_nth(dictionary *dict, int nth); + +dictionary *yon_dictionary_new_with_data(char *key, void *data); + +dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); + +dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); + +dictionary *yon_dictionary_get(dictionary **dict, char *key); + +dictionary *yon_dictionary_rip(dictionary *dict); + +dictionary *yon_dictionary_get_nth(dictionary *dict, int place); + +void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); + +// char functions + +int yon_char_find_last(char *source, char find); + +char *yon_char_append(char *source, char *append); + +char *yon_char_new(char *chr); + +char *yon_char_unite(char *source, ...); + +char *yon_cut(char *source, int size, int startpos); + +char *yon_char_divide(char *source, int dividepos); + +char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); + +char *yon_char_from_int(int int_to_convert); +char *yon_char_from_long(long int_to_convert); + +char *yon_char_replace(char *source, char *find, char*replace); + +char **yon_char_parse(char *parameters, int *size, char *divider); + +char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete); + +int yon_char_parsed_check_exist(char **parameters, int size, char *param); + +int yon_char_find_count(char *source, char *find); + +int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); + +config_str yon_char_parsed_new (int *size, ...); + +void yon_char_parsed_copy(config_str *source, config_str *to_copy); + +config_str yon_char_parsed_append(config_str parsed, int *size, char *string); + +int yon_char_parsed_remove_newline_symbols(config_str parsed, int *size); + +int yon_ubl_check_root(); + +char *yon_ubl_root_user_get(); + +char *yon_ubl_user_get_home_directory(); + +config_str yon_ubl_get_all_users(int *user_size); +config_str yon_ubl_get_all_processes(int *processes_size); +config_str yon_ubl_get_all_slices(int *slices_size); + +// parsing functions + +config_str philos_list_user(int* size); + +apps *yon_apps_scan_and_parse_desktops(int *sizef); + +void yon_apps_sort(apps *applist, int size); + +apps *yon_apps_get_by_name(apps *applist, char *name, int size); + +char *yon_app_chooser_open_with_sections(char *section_name, char *section_filter, char *section_icon, ...); + +config_str yon_config_load(char *command, int *str_len); + +int yon_config_save_registered(char *path, char *section); + +char *yon_config_get_parameter(config_str parameters, int size, char *param); + +int yon_config_load_register(char *command); + +int yon_config_remove_by_key(char *key); + +int yon_config_remove_by_data(void *data); + +int yon_config_remove_element(char *key, char *deleted); + +void *yon_config_get_by_key(char *key); + +char *yon_config_get_key_by_data(char *data); + +int yon_config_set(char *key, void *data); + +int yon_config_clean(); + +void yon_config_register(char *key, void *data); + +config_str yon_config_get_all(); + +// terminal-using functions + +int yon_launch_app_with_arguments(char *name, char *args); + +void yon_launch(char *command); + +void yon_launch_thread(char *command); + +// Gtk functions + +#ifdef __GTK_H__ +#ifdef VTE_TERMINAL +void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument); + +void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); + +#endif + +enum YON_TYPE{ + YON_TYPE_STRING, + YON_TYPE_STRING_LIST, + YON_TYPE_INT, + YON_TYPE_DOUBLE, + YON_TYPE_BOOLEAN, + YON_TYPE_OTHER +}; + +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); + +/**yon_gtk_builder_get_widget(builder, widget_name) + * [EN] + * Returns GtkWidget from GtkBuilder *[builder]. + * [builder] is GtkBuilder*; + * [widget_name] is id of widget; +*/ +#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) + +typedef struct +{ + GtkWidget *Icon; + GtkWidget *Label; + GtkWidget *IconView; + GtkListStore *List; +} expander_icon_view; + +void yon_window_config_setup(GtkWindow *window); + +int yon_window_config_load(char *path); + +config_str yon_window_config_get_section(char *section, gsize *size); + +void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type); + +void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type); + +void yon_window_config_erase_custom_parameter(char *param_name, char *section); + +int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type); + +int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); + +int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); + +void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column); + +int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); + +void yon_subwindow_close(GtkWidget *self); + + +int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); + +int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...); + +void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target); +void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target); + +typedef enum +{ + BACKGROUND_IMAGE_SUCCESS_TYPE, + BACKGROUND_IMAGE_FAIL_TYPE +} BACKGROUND_IMAGE_TYPE; + +typedef struct { + BACKGROUND_IMAGE_TYPE type; + GtkWidget *icon; + GtkWidget *box; + GtkWidget *label; + char* text_to_render; +} render_data; + + +/**yon_ubl_status_box_setup(render,icon,box,label) + * [EN] + * Sets up [render] structure of type render_data. + * [icon] is GtkImage widget of status box for showing status icons; + * [box] is GtkBox widget of status box for showing status color; + * [label] is GtkLabel widget of status box for showing status text; + * [RU] + * Настраивает структуру [render] типа render_data. + * [icon] - виджет типа GtkIcon в котором будут отображаться статусные иконки; + * [box] - виджет типа GtkBox в котором будет отображаться цвет статуса; + * [label] - виджет типа GtkLabel в котором будет отображаться текст статусного сообщения; +*/ +int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); + +/**yon_ubl_status_box_render(render,text,type) + * [EN] + * Renders message in status box; + * [render] is render_data structure of status box; + * [text] is text to be shown in status box; + * [type] if type of message. Can be BACKGROUND_IMAGE_FAIL_TYPE or BACKGROUND_IMAGE_SUCCESS_TYPE + * [RU] + * Отображает сообщение в статусном окне. + * [render] - структура типа render_data для нужного статусного окна; + * [text] - текст, отображаемый в статусном окне; + * [type] - тип сообщения. Может быть: + * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) + * или + * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) +*/ +void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); + +/**yon_ubl_header_setup(overlay, head, image, imag_path) + * [EN] + * Sets up header of app. + * [overlay] is overlay for app header; + * [head] is box of header, which connects to [overlay] + * [image] is header background image; + * [imag_path] is path of image, shown in [image] + * [RU] + * Настраивает заголовок приложения. + * [overlay] - оверлей заголовка приложения; + * [head] - шапка заголовка, присоединяемая к [overlay] + * [image] - виджет картинки для заднего фона; + * [imag_path] - путь до картинки, загружаемой в [image] +*/ +#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) +#define yon_ubl_header_setup_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) +#endif + +void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); + +void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); + +void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id); +#ifdef WEBKIT_FOUND + +void yon_ubl_browser_window_open(char *link, char *browser_window_name); +#else +void yon_ubl_browser_window_open(char *link, char *browser_window_name); +#endif +#endif \ No newline at end of file diff --git a/source/ublexec.c b/source/ublexec.c new file mode 100644 index 0000000..9d237ef --- /dev/null +++ b/source/ublexec.c @@ -0,0 +1,473 @@ +#include "ublexec.h" + +config main_config; + +//signal emmit handlers - no header initialization + +/**on_close_subwindow(GtkWidget *self) + * [EN] + * Closes window in which [self] is contained. + * [RU] + * Закрывает окно, в котором расположен виджет [self]. +*/ +void on_close_subwindow(GtkWidget *self){ + gtk_widget_destroy(gtk_widget_get_toplevel(self)); +} + +/**yon_open_browser(GtkWidget *self, char *link) + * [EN] + * Opens browser with [link] link. + * [RU] + * Открывает браузер с [link] ссылкой. +*/ +void yon_open_browser(GtkWidget *self, char *link){ + yon_ubl_browser_window_open(link,TITLE_LABEL); +} + +/**on_open_documentation_confirmation(GtkWidget *self, char *link) + * [EN] + * Opens confirmation window for [link] link. + * [RU] + * Открывает окно подтверждение перехода по ссылке [link]. +*/ +void on_open_documentation_confirmation(GtkWidget *self, char *link){ + if (main_config.always_open_documentation==0){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window)); + widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); + widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); + widgets->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); + widgets->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); + gtk_widget_show_all(widgets->Window); + g_signal_connect(G_OBJECT(widgets->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); + g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + + + } else { + yon_open_browser(self,link); + } +} + +/**on_link(GtkWidget *self, char* uri, gpointer user_data) + * [EN] + * Signal for hadnling AboutDialog links. + * Connect to "activate-link" signal. + * [self] is AboutDialog window; + * [uri] is activated link; + * [user_data] is pointer for user data, hasn't used in standard handler; + * [RU] + * Функция для обработки сигнала нажатия на ссылку окна AboutDialog. + * Присоединять к сигналу "activate-link". + * [self] - окно AboutDialog; + * [uri] - ссылка, по которой совершается переход; + * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; +*/ +void on_link(GtkWidget *self, char* uri, gpointer user_data){ + gtk_widget_destroy(self); + on_open_documentation_confirmation(self,uri); +} + +/**on_about() + * [EN] + * Function for setting up and showing AboutDialog. + * Connect it to "activate" signal of Documentation MenuItem. + * [RU] + * Функиця для настройки и показа окна AboutDialog. + * Присоединять к сигналу "activate" кнопки справки типа MenuItem. +*/ +void on_about(){ + GtkBuilder *builder=gtk_builder_new_from_resource(glade_path); + GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); + GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); + GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); + gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); + gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); + g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); + gtk_widget_set_visible(hideButtonBox,0); + gtk_widget_destroy(hideButtonBox); + gtk_widget_show(window); +} + +//functions + +void on_file_chooser_open(GtkWidget *self, main_window *widgets){ + GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_OPEN,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),"/usr/bin/"); + gtk_window_set_icon_name(GTK_WINDOW(dialog),icon_path); + + int res = gtk_dialog_run(GTK_DIALOG(dialog)); + if (res==GTK_RESPONSE_ACCEPT){ + char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + gtk_entry_set_text(GTK_ENTRY(widgets->TargetNameEntry),filename); + } + on_close_subwindow(dialog); + +} + +void on_application_chooser_open(GtkWidget *self, main_window *widgets){ + char *app = yon_app_chooser_open_with_sections(GRAPHICS_LABEL,"Graphics","", + TOOLS_LABEL,"Utility","", + INTERNET_LABEL,"Network","", + MULTIMEDIA_LABEL,"AudioVideo","", + SETTINGS_LABEL,"Settings","", + EDUCATION_LABEL,"Education","", + OFFICE_LABEL,"Office","", + DEVELOPMENT_LABEL,"Development","", + SYSTEM_LABEL,"System","",NULL); + if (app){ + gtk_entry_set_text(GTK_ENTRY(widgets->TargetNameEntry),app); + } +} + +void on_user_changed(GtkWidget *self, main_window *widgets){ + GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->prioritySpin)); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(self))==0){ + gtk_adjustment_set_lower(adj,-20); + gtk_label_set_text(GTK_LABEL(widgets->highestPriorityLabel),PRIORITY_ROOT_LABEL); + } + else { + gtk_adjustment_set_lower(adj,0); + gtk_label_set_text(GTK_LABEL(widgets->highestPriorityLabel),PRIORITY_USER_LABEL); + } + if (gtk_adjustment_get_value(adj)runWithTerminalCheck,0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck),1); + } else { + gtk_widget_set_sensitive(widgets->runWithTerminalCheck,1); + } +} + +void on_user_activate(GtkToggleButton *self, main_window *widgets){ + if (!gtk_toggle_button_get_active(self)) gtk_widget_set_sensitive((widgets->runWithTerminalCheck),1); + if (gtk_toggle_button_get_active(self)&&(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck))||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck)))) + gtk_widget_set_sensitive((widgets->runWithTerminalCheck),0); +} + +void on_user_switching(GtkToggleButton *self, main_window *widgets){ + GtkAdjustment *adj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->prioritySpin)); + if (gtk_toggle_button_get_active(self)){ + if (!gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){ + gtk_adjustment_set_lower(adj,-20); + gtk_label_set_text(GTK_LABEL(widgets->highestPriorityLabel),PRIORITY_ROOT_LABEL); + } else { + gtk_adjustment_set_lower(adj,0); + gtk_label_set_text(GTK_LABEL(widgets->highestPriorityLabel),PRIORITY_USER_LABEL); + } + } else { + gtk_adjustment_set_lower(adj,0); + gtk_label_set_text(GTK_LABEL(widgets->highestPriorityLabel),PRIORITY_USER_LABEL); + } + if (gtk_adjustment_get_value(adj)TargetNameEntry)); + if (target&&strcmp(target,"")){ + char *final_command; + char *terminal_exec = yon_dictionary_get_data(yon_dictionary_get(&main_config.terminals,(char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo))),terminal_info*)->exec_file; + char *terminal_hold = yon_dictionary_get_data(main_config.terminals,terminal_info*)->hold; + char *terminal_exec_arg = yon_dictionary_get_data(main_config.terminals,terminal_info*)->exec_arg; + char *user = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithUserCombo)); + char *priority = yon_char_append("nice -n ",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserCheck))){ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserPkexecCheck))){ + final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "pkexec ", NULL); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root + final_command = yon_char_unite(final_command, " --user root env HOME=$HOME DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR SESSION_MANAGER=$SESSION_MANAGER GNOME_DESKTOP_SESSION_ID=$GNOME_DESKTOP_SESSION_ID KDE_FULL_SESSION=$KDE_FULL_SESSION ",NULL); + } else { + final_command = yon_char_unite(final_command, " --user ",user," env HOME=$HOME DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL); + } + + if (strstr(target,".")){ + final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open ",target,NULL); + } else { + final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," ") : "",target,NULL); + } + + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck))){ + final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "su ", NULL); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root + final_command = yon_char_unite(final_command, " --preserve-environment --command \"setsid ",NULL); + } else { + final_command = yon_char_unite("xhost +SI:localuser:",user,"; ",final_command, " --login ",user," --command \"setsid env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL); + } + + if (strstr(target,".")){ + final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open ",target,"\"",NULL); + } else { + final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," ") : "",target,"\"",NULL); + } + if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){ + final_command = yon_char_unite(final_command,"; sleep 10 && xhost -SI:localuser:",user,NULL); + } + + } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck))){ + final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "sudo ", NULL); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root + final_command = yon_char_unite(final_command, " --preserve-env setsid ",NULL); + } else { + final_command = yon_char_unite("xhost +SI:localuser:",user,"; ",final_command, " --user ",user," setsid env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL); + } + + if (strstr(target,".")){ + final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open '",target,"'",NULL); + } else { + final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," '") : "'",target,"'",NULL); + } + if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){ + final_command = yon_char_unite(final_command,"; sleep 10 && xhost -SI:localuser:",user,NULL); + } + + } + } else { + if (strstr(target,".")){ + final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ", !strstr(target,".") ? terminal_hold : "",!strstr(target,".") ? " " : "", terminal_exec_arg, " ",NULL) : "",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "setsid xdg-open ",target,NULL); + } else { + final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ", !strstr(target,".") ? terminal_hold : "",!strstr(target,".") ? " " : "", terminal_exec_arg, " ",NULL) : "",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "",target,NULL); + } + } + gtk_entry_set_text(GTK_ENTRY(widgets->commandEntry),final_command); + free(final_command); + } +} + +void on_command_run(GtkWidget *self, main_window *widgets){ + const char *command = gtk_entry_get_text(GTK_ENTRY(widgets->commandEntry)); + yon_launch_thread((char*)command); +} + +// standard functions + +void config_init(){ + main_config.always_open_documentation=0; + main_config.win_height=0; + main_config.win_width=0; + main_config.win_pos_x=0; + main_config.win_pos_y=0; + main_config.socket_id=-1; + main_config.save_socket_id=-1; + main_config.load_socket_id=-1; + main_config.lock_help=0; + main_config.lock_help=0; + main_config.lock_load_global=0; + main_config.lock_save_global=0; + main_config.lock_save_local=0; +} + +main_window *setup_window(){ + /* Widgets getting | Получение виджетов */ + main_window *widgets = malloc(sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + widgets->Window = yon_gtk_builder_get_widget(builder,"window"); + widgets->PlugBox = yon_gtk_builder_get_widget(builder,"plugBox"); + widgets->TargetNameEntry = yon_gtk_builder_get_widget(builder,"targetNameEntry"); + widgets->chooseFileButton = yon_gtk_builder_get_widget(builder,"chooseFileButton"); + widgets->chooseDesktopButton = yon_gtk_builder_get_widget(builder,"chooseDesktopButton"); + + widgets->StatusBox = yon_gtk_builder_get_widget(builder,"mainStatusBox"); + widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); + widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); + + widgets->runWithTerminalCheck = yon_gtk_builder_get_widget(builder,"runWithTerminalCheck"); + widgets->runWithTerminalCombo = yon_gtk_builder_get_widget(builder,"runWithTerminalCombo"); + + widgets->runWithUserCheck = yon_gtk_builder_get_widget(builder,"runWithUserCheck"); + widgets->runWithUserPkexecCheck = yon_gtk_builder_get_widget(builder,"runWithUserPkexecCheck"); + widgets->runWithUserSuCheck = yon_gtk_builder_get_widget(builder,"runWithUserSuCheck"); + widgets->runWithUserSudoCheck = yon_gtk_builder_get_widget(builder,"runWithUserSudoCheck"); + widgets->runWithUserCombo = yon_gtk_builder_get_widget(builder,"runWithUserCombo"); + + widgets->priorityCheck = yon_gtk_builder_get_widget(builder,"priorityCheck"); + widgets->priorityScale = yon_gtk_builder_get_widget(builder,"priorityScale"); + widgets->prioritySpin = yon_gtk_builder_get_widget(builder,"prioritySpin"); + widgets->highestPriorityLabel = yon_gtk_builder_get_widget(builder,"highestPriorityLabel"); + + widgets->commandCheck = yon_gtk_builder_get_widget(builder,"commandCheck"); + widgets->commandEntry = yon_gtk_builder_get_widget(builder,"commandEntry"); + + widgets->runButton = yon_gtk_builder_get_widget(builder,"runButton"); + + widgets->HeadOverlay = yon_gtk_builder_get_widget(builder,"overHead"); + widgets->HeadImage = yon_gtk_builder_get_widget(builder,"imgHeadBackground"); + widgets->HeadBox = yon_gtk_builder_get_widget(builder,"boxColor"); + + widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); + widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); + + gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL); + + GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); + gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); + gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); + + /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ + // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); + + /* Signal connection | Присоединение сигналов */ + g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(gtk_main_quit), NULL); + g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),WIKI_LINK); + g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),NULL); + g_signal_connect(G_OBJECT(widgets->chooseFileButton),"clicked",G_CALLBACK(on_file_chooser_open),widgets); + g_signal_connect(G_OBJECT(widgets->chooseDesktopButton),"clicked",G_CALLBACK(on_application_chooser_open),widgets); + + g_signal_connect(G_OBJECT(widgets->priorityCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->priorityScale); + g_signal_connect(G_OBJECT(widgets->priorityCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->prioritySpin); + + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->runWithUserPkexecCheck); + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->runWithUserSuCheck); + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->runWithUserSudoCheck); + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->runWithUserCombo); + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(on_user_switching),widgets); + + g_signal_connect(G_OBJECT(widgets->runWithTerminalCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->runWithTerminalCombo); + + g_signal_connect(G_OBJECT(widgets->commandCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->commandEntry); + g_signal_connect(G_OBJECT(widgets->runWithUserCombo),"changed",G_CALLBACK(on_user_changed),widgets); + + g_signal_connect(G_OBJECT(widgets->runWithUserSuCheck),"toggled",G_CALLBACK(on_su_sudo_activate),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserSudoCheck),"toggled",G_CALLBACK(on_su_sudo_activate),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(on_user_activate),widgets); + + g_signal_connect(G_OBJECT(widgets->TargetNameEntry),"changed",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithTerminalCheck),"toggled",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithTerminalCombo),"changed",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserCheck),"toggled",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserPkexecCheck),"toggled",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserSuCheck),"toggled",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserSudoCheck),"toggled",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->runWithUserCombo),"changed",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->priorityCheck),"toggled",G_CALLBACK(on_setup_command),widgets); + g_signal_connect(G_OBJECT(widgets->priorityScale),"value-changed",G_CALLBACK(on_setup_command),widgets); + + g_signal_connect(G_OBJECT(widgets->runButton),"clicked",G_CALLBACK(on_command_run),widgets); + + int size; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithUserCombo),"root"); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->runWithUserCombo),0); + main_config.user_id_min = atoi(yon_config_load(get_user_id_min_command,&size)[0]); + main_config.user_id_max = atoi(yon_config_load(get_user_id_max_command,&size)[0]); + config_str users = yon_config_load(get_users_command,&size); + for (int i=0;i=main_config.user_id_min&&atoi(strstr(users[i],":")+1)<=main_config.user_id_max) + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithUserCombo),yon_char_divide_search(users[i],":",-1)); + } + + + config_str terminals = yon_config_load(get_terminals_info_command,&size); + for (int i=0;iname = terminal_parsed[0]; + term->exec_file = terminal_parsed[1]; + term->hold = terminal_parsed[2]; + term->exec_arg = terminal_parsed[3]; + yon_dictionary_add_or_create_if_exists_with_data(main_config.terminals,term->name,term); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo),term->name); + } + } + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->runWithTerminalCombo),0); + gtk_widget_show(widgets->Window); + return widgets; +} + +int main(int argc, char *argv[]){ + local=setlocale(LC_ALL, ""); + textdomain (LocaleName); + config_init(); + int option_index=0; + int show_help=0; + int debug_mode=0; + { + struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"version", 0, 0, 'V'}, + {"lock-help", 0,0, 1}, + {"lock-save", 0,0, 2}, + {"lock-save-local", 0,0, 3}, + {"lock-save-global", 0,0, 4}, + {"lock-load-global", 0,0, 5}, + {"socket-id", 1, 0, 's'}, + {"socket-ext-id", 1,0, 'e'}, + {"socket-trd-id", 1,0, 't'}, + {"debug", 0,0, 'd'}, + { NULL, 0, NULL, 0 } + }; + for (int i=0;iStatusIcon,widgets->StatusBox,widgets->StatusLabel); + yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); + yon_ubl_status_box_render(CHOOSE_APP_OR_FILE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_window_config_setup(GTK_WINDOW(widgets->Window)); + yon_window_config_load(config_path); + GtkCssProvider *css=gtk_css_provider_new(); + gtk_css_provider_load_from_resource(css,CssPath); + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), + GTK_STYLE_PROVIDER(css), + -1); + gtk_main(); +} \ No newline at end of file diff --git a/source/ublexec.cc b/source/ublexec.cc new file mode 100644 index 0000000..ed6f8af --- /dev/null +++ b/source/ublexec.cc @@ -0,0 +1,1058 @@ +#include "ublexec.h" +using namespace std; + + +int flag_prog_file = 0; +string name_app_cmd = ""; +string version_application = "2.27"; +int socket_ext_id_I = 0; +int socket_trd_id_I = 0; + +MainWindow* obj_main; +void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data) { + if (self && user_data) {} + obj_main->global_lick_doc = link; + obj_main->aboutWindows->hide(); + obj_main->temp_help_show(); +} + +CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help) +: Glib::OptionGroup{p_name, p_description, p_help} { + Glib::OptionEntry socketIDArg; + socketIDArg.set_long_name("socket-id"); + socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); + socketIDArg.set_description("Settings manager socket"); + Glib::OptionEntry socketExtId; + socketExtId.set_long_name("socket-ext-id"); + socketExtId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); + socketExtId.set_description("Settings manager secondary socket"); + Glib::OptionEntry socketTrdId; + socketTrdId.set_long_name("socket-trd-id"); + socketTrdId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); + socketTrdId.set_description("Settings manager secondary socket"); + add_entry(socketIDArg, m_socketID); + add_entry(socketExtId, socket_ext_id_I); + add_entry(socketTrdId, socket_trd_id_I); +} +::Window CmdArgParser::GetSocketID() const{ + return m_socketID; +} + +MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder) + : Gtk::ApplicationWindow(obj), builder{builder} { + this->builder = builder; + this->settings(); +} + +MainWindow::MainWindow(Glib::RefPtr const& builder) { + this->builder = builder; + this->settings(); +} + +void MainWindow::get_builder() { + builder->get_widget("imgHeadBackground", imgHeadBackground); + builder->get_widget("overHead", overHead); + builder->get_widget("btnFilemaneg", btnFilemaneg); + builder->get_widget("btnListApp", btnListApp); + builder->get_widget("btnStart", btnStart); + builder->get_widget("chbTerminal", chbTerminal); + builder->get_widget("chbAnotherUser", chbAnotherUser); + builder->get_widget("cbxExecuteEpriority", cbxExecuteEpriority); + builder->get_widget("cmbUser", cmbUser); + builder->get_widget("spinPriority", spinPriority); + builder->get_widget("scalePriority", scalePriority); + builder->get_widget("rbPkexec", rbPkexec); + builder->get_widget("rbSu", rbSu); + builder->get_widget("rbSudo", rbSudo); + builder->get_widget("txtCmd", txtCmd); + builder->get_widget("wndChooseFileWallpaper", wndChooseFileWallpaper); + builder->get_widget("btnFilemangerExit", btnFilemangerExit); + builder->get_widget("btnFilemangerOk", btnFilemangerOk); + builder->get_widget("lblTimeEpriorityLow", lblTimeEpriorityLow); + builder->get_widget("lblTime4EpriorityHigh", lblTime4EpriorityHigh); + builder->get_widget("messageError", messageError); + builder->get_widget("lblMessageError", lblMessageError); + builder->get_widget("btnMessageErrorOk", btnMessageErrorOk); + builder->get_widget("dialogStartMenu", dialogStartMenu); + builder->get_widget("btnStartMenuOK", btnStartMenuOK); + builder->get_widget("btnStartMenuExit", btnStartMenuExit); + builder->get_widget("lblInfoHead", lblInfoHead); + builder->get_widget("lblinfoCmd", lblinfoCmd); + builder->get_widget("lblInfoTime", lblInfoTime); + builder->get_widget("labInfoExecutTerm", labInfoExecutTerm); + builder->get_widget("lblInfoUser", lblInfoUser); + builder->get_widget("lblInfoUserOther", lblInfoUserOther); + builder->get_widget("lblInfoUserName", lblInfoUserName); + builder->get_widget("lblInfoNooPriority", lblInfoNooPriority); + builder->get_widget("lblInfoExec", lblInfoExec); + builder->get_widget("lblInfoPriority", lblInfoPriority); + builder->get_widget("boxColor", boxColor); + builder->get_widget("lblGraphics", lblGraphics); + builder->get_widget("lblTools", lblTools); + builder->get_widget("lblInternet", lblInternet); + builder->get_widget("lblMultimedia", lblMultimedia); + builder->get_widget("lblSettings", lblSettings); + builder->get_widget("lblEducation", lblEducation); + builder->get_widget("lblOffice", lblOffice); + builder->get_widget("lblOther", lblOther); + builder->get_widget("lblDevelopment", lblDevelopment); + builder->get_widget("iconGraphics", iconGraphics); + builder->get_widget("iconTools", iconTools); + builder->get_widget("iconInternet", iconInternet); + builder->get_widget("iconMultimedia", iconMultimedia); + builder->get_widget("iconSettings", iconSettings); + builder->get_widget("iconEducation", iconEducation); + builder->get_widget("iconOffice", iconOffice); + builder->get_widget("iconOther", iconOther); + builder->get_widget("iconDevelopment", iconDevelopment); + builder->get_widget("iconSystem", iconSystem); + builder->get_widget("lblSystem", lblSystem); + builder->get_widget("lblHeaderName", lblHeaderName); + builder->get_widget("btnhelp", btnhelp); + builder->get_widget("btnAbout", btnAbout); + builder->get_widget("aboutWindows", aboutWindows); + builder->get_widget("btnSettings", btnSettings); + builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog); + builder->get_widget("boxAbout", boxAbout); + builder->get_widget("cmbTerminal", cmbTerminal); + builder->get_widget("lblHeaderAboutTopic", lblHeaderAboutTopic); + + builder->get_widget("lblwebHeaderName", lblwebHeaderName); + builder->get_widget("lblhelpText", lblhelpText); + builder->get_widget("lblhelpHeader", lblhelpHeader); + builder->get_widget("chkAlwaysOpenHelp", chkAlwaysOpenHelp); + builder->get_widget("btnReadHelp", btnReadHelp); + builder->get_widget("btnCancelHelp", btnCancelHelp); + builder->get_widget("wndShowWeb", wndShowWeb); + builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb); + + #ifdef WEBKIT_FOUND + builder->get_widget("wndWeb", wndWeb); + #endif +} + +void MainWindow::set_icon_array() { + array_icon[0] = this->iconGraphics; + array_icon[1] = this->iconTools; + array_icon[2] = this->iconInternet; + array_icon[3] = this->iconMultimedia; + array_icon[4] = this->iconSettings; + array_icon[5] = this->iconEducation; + array_icon[6] = this->iconOffice; + array_icon[7] = this->iconOther; + array_icon[8] = this->iconDevelopment; + array_icon[9] = this->iconSystem; +} + +void MainWindow::template_apps_obj(Gtk::IconView *icon, Glib::RefPtr >k_list_app) { + gtk_list_app = Gtk::ListStore::create(m_Columns); + gtk_list_app->set_sort_column(m_Columns.m_col_description, Gtk::SORT_ASCENDING); + icon->set_model(gtk_list_app); + icon->set_text_column(m_Columns.m_col_description); +} + +void MainWindow::add_CSS() { + Glib::RefPtr cssProvider = Gtk::CssProvider::create(); + cssProvider->load_from_resource(path_css); + Glib::RefPtr styleContext = Gtk::StyleContext::create(); + Glib::RefPtr screen = Gdk::Screen::get_default();//get default screen + styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application + Glib::RefPtr context_lbl_head = lblInfoHead->get_style_context(); + Glib::RefPtr boxAbout_css = boxAbout->get_style_context(); + imgHeadBackground->set_from_resource(path_img_head_background); + for (auto &view: array_icon) { + Glib::RefPtr view_css = view->get_style_context(); + view_css->add_class("view_app"); + } + context_lbl_head->add_class("textHead"); + if (socket_ext_id_I == 0){ + boxAbout_css->add_class("bkim_no_plug"); + } +} + +void MainWindow::localization() { + time_t now = time(0); + tm *ltm = localtime(&now); + unsigned int year= 1900+ ltm->tm_year; + string str_authors = string(copyright) + to_string(year); + aboutWindows->set_copyright(str_authors); + aboutWindows->set_website(website); + btnhelp->set_label(str_help); + btnAbout->set_label(str_about_1); + aboutWindows->set_comments(define_name_app); + aboutWindows->set_website_label(home_page ); + aboutWindows->set_version(_(version_application.c_str())); + aboutWindows->set_title(space_name_app ); + lblHeaderAboutTopic->set_label(space_name_app ); + lblHeaderName->set_text(define_name_app); + this->set_title(define_name_app); + btnStart->set_label(str_run); + wndChooseFileWallpaper->set_title(str_please_select_file); + dialogStartMenu->set_title(str_selecting_programs); + lblInfoHead->set_text(define_name_app); + lblinfoCmd->set_text(str_localization_cmd_line); + lblInfoTime->set_text(str_localization_team); + labInfoExecutTerm->set_text(str_run_terminal); + lblInfoUser->set_text(str_localization_user); + lblInfoUserOther->set_text(str_run_of_user); + lblInfoUserName->set_text(str_localization_username); + lblInfoNooPriority->set_text(str_localization_priority); + lblInfoExec->set_text(str_change_priority); + lblInfoPriority->set_text(string(str_localization_priority) + ":"); + lblMessageError->set_text(str_select_app_program); + messageError->set_title(str_localization_attention); + lblGraphics->set_text(str_localization_graphics); + lblTools->set_text(str_localization_tools); + lblInternet->set_text(str_localization_internet); + lblMultimedia->set_text(str_localization_multimedia); + lblSettings->set_text(str_localization_settings); + lblEducation->set_text(str_localization_education); + lblOffice->set_text(str_localization_office); + lblOther->set_text(str_localization_other); + lblDevelopment->set_text(str_localization_development); + lblSystem->set_text(str_localization_system); + btnListApp->set_tooltip_text(str_application_overview); + btnFilemaneg->set_tooltip_text(str_file_overview); + btnMessageErrorOk->set_label(str_close); + lblhelpHeader->set_text(read_documentation_web); + lblhelpText->set_text(redirected_documentation); + btnReadHelp->set_label(read_online); + btnCancelHelp->set_label(cancel); + chkAlwaysOpenHelp->set_label(always_redirect); + lblwebHeaderName->set_label(name_app_1); + lblHeadeWndWeb->set_label(define_name_app); + lblwebHeaderName->set_label(define_name_app); + btnFilemaneg->set_tooltip_text(str_tooltip_filemanager); + btnListApp->set_tooltip_text(str_tooltip_list_app); +} + +void MainWindow::event() { + g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_help_show), this); + btnCancelHelp->signal_clicked().connect([&]() {wndShowWeb->hide();}); + chkAlwaysOpenHelp->signal_toggled().connect([&]() {flag_open_browser = true;}); + btnReadHelp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_browser)); + btnhelp->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::open_help)); + btnFilemaneg->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_filemaneg)); + btnListApp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_list_app)); + btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::entry_app)); + chbTerminal->signal_toggled().connect([&]() {cmbTerminal->set_sensitive(chbTerminal->get_active());denamic_cmd();}); + chbAnotherUser->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::activ_or_block_other_user)); + spinPriority->signal_value_changed().connect(sigc::mem_fun(*this, &MainWindow::change_scale_priority)); + scalePriority->signal_value_changed().connect(sigc::mem_fun(*this, &MainWindow::change_spin_priority)); + btnFilemangerExit->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::close_filemaneg)); + btnFilemangerOk->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::get_path_filemaneg)); + cbxExecuteEpriority->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::activ_or_block_execute_epriority)); + btnMessageErrorOk->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::message_gui_close)); + btnStartMenuOK->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::start_menu_entry_app)); + btnStartMenuExit->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::close_entry_app)); + btnStartMenuOK->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::ok_close_entry_app)); + iconGraphics->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Graphics)); + iconTools->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Tools)); + iconInternet->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Internet)); + iconMultimedia->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Multimedia)); + iconSettings->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Settings)); + iconEducation->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Education)); + iconOffice->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Office)); + iconOther->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Other)); + iconDevelopment->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Development)); + iconSystem->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_System)); + btnAbout->signal_activate().connect([&]() {aboutWindows->show();}); + cmbUser->signal_changed().connect([&]() {changed_user();this->denamic_cmd();}); + rbSudo->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); + txtCmd->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_cmd)); + txtCmd->signal_focus_in_event().connect(sigc::mem_fun(*this, &MainWindow::focus_in_txt_cmd)); + txtCmd->signal_delete_text().connect(sigc::mem_fun(*this, &MainWindow::delete_cmd)); + rbSu->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); + rbPkexec->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); + cmbTerminal->signal_changed().connect([&]() {this->denamic_cmd();}); +} + + + +void MainWindow::sudo_nice(){ + string response = this->call("id -Gn"); + if (geteuid() == 0 || cmbUser->get_active_text() == "root" ){ + spinPriority->set_range(-20, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(-20, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice__20); + } + else if (rbSudo->get_active() && response.find("wheel") != string::npos){ + spinPriority->set_range(-20, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(-20, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice__20); + } + else if (rbSu->get_active()){ + spinPriority->set_range(0, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(0, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice_0); + } + else if (rbPkexec->get_active()){ + spinPriority->set_range(0, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(0, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice_0); + } + this->denamic_cmd(); +} + +void MainWindow::changed_user() { + Glib::ustring entry_user = cmbUser->get_active_text(); + string response = this->call("id -Gn"); + bool flag_wheel_sudo = (rbSudo->get_active()==true && response.find("wheel") != string::npos); + if (geteuid() == 0 || entry_user == "root" || flag_wheel_sudo==true) { + spinPriority->set_range(-20, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(-20, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice__20); + } + else{ + spinPriority->set_range(0, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(0, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice_0); + } +} + +void MainWindow::delete_cmd(const int &x, const int &y) { + if (x == 0) {} + if (y > 1) { + chbTerminal->set_active(false); + chbAnotherUser->set_active(false); + cbxExecuteEpriority->set_active(false); + name_app = ""; + path_file = ""; + user_cmd = ""; + txtCmd->set_text(""); + } +} + +bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) { + if (event) {} + if (user_cmd.length() != 0) { + } + else if (name_app.length() != 0) { + } + else if (path_file.length() != 0) { + } + else{ + user_cmd = txtCmd->get_text(); + } + cmd_old = txtCmd->get_text(); + return true; +} + +void MainWindow::temp_help_show() { + if (flag_open_browser == true) { + this->open_browser(); + } + else { + wndShowWeb->show_all(); + } + +} + +void MainWindow::open_help() { + global_lick_doc = const_link_doc; + temp_help_show(); +} + +void MainWindow::open_browser() { + #ifdef WEBKIT_FOUND + if (my_web_kit) { + gtk_widget_destroy(GTK_WIDGET(my_web_kit)); + } + my_web_kit = WEBKIT_WEB_VIEW(webkit_web_view_new()); + three = Glib::wrap(GTK_WIDGET(my_web_kit)); + wndWeb->add(*three); + webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); + wndWeb->show_all(); + webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); + wndWeb->show_all(); + #else + this->template_open_browser(global_lick_doc); + #endif + wndShowWeb->hide(); +} + +void MainWindow::template_open_browser(string link_doc) { + string cmd = cmd_xdg + string(_(link_doc.c_str())) + " &"; + string buf = ""; + if (geteuid() == 0) { + string response_user = getlogin(); + int size_s = std::snprintf(nullptr, 0, cmd_execute, response_user.c_str(), cmd.c_str()) + 1; + auto size = static_cast(size_s); + std::unique_ptr buf(new char[ size ]); + std::snprintf(buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str()); + cmd = string(buf.get(), buf.get() + size - 1); + } + index_error = system(cmd.c_str()); +} + +void MainWindow::icon_clear() { + list_Graphics->clear(); + list_Tools->clear(); + list_Internet->clear(); + list_Multimedia->clear(); + list_Settings->clear(); + list_Education->clear(); + list_Office->clear(); + list_Other->clear(); + list_Development->clear(); + list_System->clear(); +} + +void MainWindow::ok_close_entry_app() { + this->icon_clear(); + dialogStartMenu->hide(); +} + +void MainWindow::select_Graphics() { + this->tempate_icon_select(this->iconGraphics, list_Graphics); +} +void MainWindow::select_Tools() { + this->tempate_icon_select(this->iconTools, list_Tools); +} +void MainWindow::select_Internet() { + this->tempate_icon_select(this->iconInternet, list_Internet); +} +void MainWindow::select_Multimedia() { + this->tempate_icon_select(this->iconMultimedia, list_Multimedia); +} +void MainWindow::select_Settings() { + this->tempate_icon_select(this->iconSettings, list_Settings); +} +void MainWindow::select_Education() { + this->tempate_icon_select(this->iconEducation, list_Education); +} +void MainWindow::select_Office() { + this->tempate_icon_select(this->iconOffice, list_Office); +} +void MainWindow::select_Other() { + this->tempate_icon_select(this->iconOther, list_Other); +} +void MainWindow::select_Development() { + this->tempate_icon_select(this->iconDevelopment, list_Development); +} +void MainWindow::select_System() { + this->tempate_icon_select(this->iconSystem, list_System); +} +void MainWindow::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr >k_list) { + auto selected = (*icon).get_selected_items(); + if(!selected.empty()) { + this->set_icon_array(); + this->unselect_icon(icon); + const Gtk::TreeModel::Path& path = *selected.begin(); + Gtk::TreeModel::iterator iter = gtk_list->get_iter(path); + Gtk::TreeModel::Row row = *iter; + auto app_name_exec = row[m_Columns.app_name_exec]; + const Glib::ustring description = row[m_Columns.m_col_description]; + path_file = ""; + name_app = ""; + user_cmd = ""; + txtCmd->set_text(app_name_exec); + name_app = txtCmd->get_text(); + size_t len_name_app = name_app.length(); + string array_del[] = {"%f", "%F", "%d", "%D", "%n", "%N", "%U"}; + for (auto &del_sim: array_del) { + str_remove(name_app, del_sim); + if (name_app.length() != len_name_app) { + txtCmd->set_text(name_app); + break; + } + } + this->denamic_cmd(); + + } +} + +void MainWindow::unselect_icon(Gtk::IconView *icon_entry) { + for (int index=0; index<10; ++index) { + Gtk::IconView *icon = this->array_icon[index]; + if (icon_entry != icon) { + icon->unselect_all(); + } + } +} + +void MainWindow::settings() { + obj_main = this; + if (flag_prog_file == 1){ + user_cmd = name_app_cmd; + } + if (flag_prog_file == 2){ + path_file = name_app_cmd; + } + + this->pars_apps(); + this->get_builder(); + this->event(); + this->localization(); + this->set_icon_array(); + this->add_CSS(); + spinPriority->set_range(0, 19); + spinPriority->set_increments(1.0, -1.0); + scalePriority->set_range(0, 19); + scalePriority->set_value(0); + lblTimeEpriorityLow->set_text(nice_19); + lblTime4EpriorityHigh->set_text(nice_0); + scalePriority->set_inverted(true); + Gtk::Widget *boxWidget; + builder->get_widget("boxColor", boxWidget); + overHead->add_overlay(*boxWidget); + this->pars_dir_bin(); + this->pars_dir_terminal(); + this->pars_users(); + this->is_user_wheel(); + cmbUser->set_active_text(user_exec_app); + this->activ_or_block_execute_epriority(); + this->changed_user(); + cmbUser->set_sensitive(false); + lblInfoUserName->set_sensitive(false); + rbPkexec->set_sensitive(false); + rbSu->set_sensitive(false); + rbSudo->set_sensitive(false); + btnBoxAboutDialog->set_visible(false); + cmbTerminal->set_sensitive(false); + ubl_make_plugs(boxAbout, boxAbout, socket_ext_id_I, 0); +} + +void MainWindow::close_entry_app() { + this->icon_clear(); + dialogStartMenu->hide(); +} + +void MainWindow::start_menu_entry_app() {} + +void MainWindow::message_gui_close() { + messageError->hide(); +} + +void MainWindow::activ_or_block_execute_epriority() { + bool flag = cbxExecuteEpriority->get_active(); + scalePriority->set_sensitive(flag); + spinPriority->set_sensitive(flag); + lblTimeEpriorityLow->set_sensitive(flag); + lblTime4EpriorityHigh->set_sensitive(flag); + this->denamic_cmd(); +} + +void MainWindow::open_filemaneg() { + wndChooseFileWallpaper->set_current_folder("/bin/"); + wndChooseFileWallpaper->show(); +} + +void MainWindow::close_filemaneg() { + wndChooseFileWallpaper->hide(); +} + +void MainWindow::get_path_filemaneg() { + name_app = ""; + user_cmd = ""; + path_file = wndChooseFileWallpaper->get_filename(); + if (path_file.length() == 0) {} + else{ + txtCmd->set_text(path_file); + this->close_filemaneg(); + + } + this->denamic_cmd(); +} + +vector MainWindow::find_all(string &text, string &word) { + size_t index{}; + vector list_index; + while ((index = text.find(word, index)) != std::string::npos) + { + index += word.length(); + list_index.push_back(index); + } + return list_index; +} + +void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr &dtk_list) { + Gtk::TreeModel::Row row = *(dtk_list->append()); + string s_remove[] = {".png", ".jpg", ".jpeg", ".svg", ".xpm"}; + string str_search = "/"; + if (path.find(str_search) != string::npos){ + vector list_index = this->find_all(path, str_search); + int index = list_index.size(); + if (index>1){ + index = index-1; + index = list_index.at(index); + if (index){ + size_t len_path = path.length(); + path = path.substr(index, len_path); + } + } + } + for (string &del: s_remove){ + if (path.find(del) != string::npos){ + str_remove(path, del); + } + } + row[m_Columns.m_col_filename] = path; + row[m_Columns.m_col_description] = Name; + row[m_Columns.icon_name] = path; + row[m_Columns.app_name_exec] = Exec; + row[m_Columns.float_h_align] = 0.5; + row[m_Columns.float_w_align] = 0.5; +} + +void MainWindow::open_list_app() { + this->template_apps_obj(iconGraphics, list_Graphics); + this->template_apps_obj(iconTools, list_Tools); + this->template_apps_obj(iconInternet, list_Internet); + this->template_apps_obj(iconMultimedia, list_Multimedia); + this->template_apps_obj(iconSettings, list_Settings); + this->template_apps_obj(iconEducation, list_Education); + this->template_apps_obj(iconOffice, list_Office); + this->template_apps_obj(iconOther, list_Other); + this->template_apps_obj(iconDevelopment, list_Development); + this->template_apps_obj(iconSystem, list_System); + string path = ""; + for ( const auto &st_app: list_app) { + for ( const auto &str_categor: st_app.Categories) { + path = st_app.Icon; + if (str_categor == "Graphics") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Graphics); + } + else if (str_categor == "Utility") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Tools); + } + else if (str_categor == "Network") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Internet); + } + else if (str_categor == "AudioVideo") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Multimedia); + } + else if (str_categor == "Settings") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Settings); + } + else if (str_categor == "Education") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Education); + } + else if (str_categor == "Office") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Office); + } + else if (str_categor == "Other") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Other); + } + else if (str_categor == "Development") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Development); + } + else if (str_categor == "System") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_System); + } + } + } + dialogStartMenu->show_all(); +} + + +string MainWindow::start_cmd(string user_cmd) { + string str_cmd_terminal = ""; + string str_variants_root = ""; + string str_nice_cmd = ""; + if (chbAnotherUser->get_active()) { + if (rbPkexec->get_active()) { + str_variants_root = "pkexec --user " + cmbUser->get_active_text(); + if (cbxExecuteEpriority->get_active()) { + str_variants_root += " nice -n " + to_string(spinPriority->get_value_as_int()); + } + str_variants_root += " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "; + } + else if (rbSu->get_active()) { + chbTerminal->set_active(true); + string str_user = cmbUser->get_active_text(); + if (str_user != "root") { + str_variants_root = "su -l " + cmbUser->get_active_text(); + } + else{ + str_variants_root = "su "; + } + str_variants_root += " -c \" DISPLAY=$DISPLAY "; + if (cbxExecuteEpriority->get_active()) { + str_variants_root += "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; + } + } + else if (rbSudo->get_active()) { + chbTerminal->set_active(true); + if (user_exec_app==cmbUser->get_active_text()) { + str_variants_root = "sudo "; + } + else{ + str_variants_root = "sudo -u " + cmbUser->get_active_text() + " "; + } + if (cbxExecuteEpriority->get_active()) { + str_variants_root += "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; + } + } + } + if (cmbUser->get_active_text().length() != 0) { + string user_cmd_X = "xhost +SI:localuser:"; + user_cmd_X += cmbUser->get_active_text(); + user_cmd_X += " > /dev/null 2>&1"; + index_error = system(user_cmd_X.c_str()); + } + if ((cbxExecuteEpriority->get_active()) && (chbAnotherUser->get_active() == false)) { + str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; + } + if (user_cmd.length() == 0 && name_app.length() == 0 && path_file.length() == 0) { + messageError->set_title(str_localization_attention); + messageError->show(); + return ""; + } + if (chbTerminal->get_active() == true) { + string name_terminal_arr = ""; + string name_terminal = cmbTerminal->get_active_text(); + if (name_terminal.length() != 0) { + int len_termunal_cmd = sizeof(termunal_cmd)/sizeof(*termunal_cmd); + for (int index = 0; index 0) { + if (access(path_file.c_str(), X_OK) != -1) { + cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + " " + path_file; + } + else{ + cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' "; + } + + } + else if (name_app.length() > 0) { + cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + name_app; + } + else if (user_cmd.length() > 0) { + cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + " " + user_cmd; + } + if ((cmd.find("-e su ") != string::npos) || (cmd.find("-x su ") != string::npos)) { + cmd+=" \""; + } + cmd = "nohup " + cmd; + cmd += " > /dev/null 2>&1"; + return cmd; +} + +void MainWindow::call_app(string &cmd) { + if (cmd.length() != 0) { + std::thread t([&](string cmd) {int index = system(cmd.c_str()); if (index){}}, cmd); + t.detach(); + } +} +void MainWindow::denamic_cmd() { + if (chbTerminal->get_active() == true || chbAnotherUser->get_active() == true || cbxExecuteEpriority->get_active() == true) { + if (txtCmd->get_text().length() == 0) { + chbTerminal->set_active(false); + chbAnotherUser->set_active(false); + cbxExecuteEpriority->set_active(false); + path_file = ""; + name_app = ""; + user_cmd = ""; + txtCmd->set_text(user_cmd); + messageError->set_title(str_localization_attention); + messageError->show(); + } + else{ + txtCmd->set_text(this->start_cmd(user_cmd)); + } + } + else{ + if (user_cmd.length() != 0) { + txtCmd->set_text(this->start_cmd(user_cmd)); + } + else if (path_file.length() != 0) { + txtCmd->set_text(this->start_cmd(user_cmd)); + } + else if (name_app.length() != 0) { + txtCmd->set_text(this->start_cmd(user_cmd)); + } + } +} + +string MainWindow::call(string cmd) { + FILE *fp; + int status; + char path[PATH_MAX] = {0}; + fp = popen(cmd.c_str(), "r"); + if (fp == NULL) { + exit(1); + } + while (fgets(path, PATH_MAX, fp) != NULL) { + break; + } + status = pclose(fp); + if (status == -1) { + exit(1); + } + return path; +} + +bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event) { + if (event) {} + if (cmd_old != txtCmd->get_text()) { + user_cmd = txtCmd->get_text(); + } + return true; +} + +void MainWindow::entry_app() { + this->denamic_cmd(); + if (name_app.length() == 0 && path_file.length() == 0) { + } + string cmd = txtCmd->get_text(); + this->call_app(cmd); +} + +void MainWindow::activ_or_block_other_user() { + bool flag = chbAnotherUser->get_active(); + cmbUser->set_sensitive(flag); + lblInfoUserName->set_sensitive(flag); + if (flag_pkexec == true) { + rbPkexec->set_sensitive(flag); + } + if (flag_su == true) { + rbSu->set_sensitive(flag); + } + if (flag_sudo == true) { + rbSudo->set_sensitive(flag); + } + this->denamic_cmd(); +} + +void MainWindow::change_scale_priority() { + scalePriority->set_value(spinPriority->get_value_as_int()); + this->denamic_cmd(); +} + +void MainWindow::change_spin_priority() { + spinPriority->set_value(scalePriority->get_value()); + this->denamic_cmd(); +} + +void MainWindow::pars_dir_bin() { + namespace fs = std::filesystem; + std::string path = "/bin"; + string file_name = ""; + for (const auto & entry: fs::directory_iterator(path)) { + file_name = entry.path().filename().string(); + if (file_name == "su") { + flag_su = true; + } + else if (file_name == "sudo") { + flag_sudo = true; + } + else if (file_name == "pkexec") { + flag_pkexec = true; + } + } + rbPkexec->set_sensitive(flag_pkexec); + rbSu->set_sensitive(flag_su); + rbSudo->set_sensitive(flag_sudo); +} + +void MainWindow::pars_dir_terminal() { + namespace fs = std::filesystem; + std::string path = "/bin"; + string file_name = ""; + string name_terminal = ""; + for (const auto & entry: fs::directory_iterator(path)) { + file_name = entry.path().filename().string(); + int len_termunal_cmd = sizeof(termunal_cmd)/sizeof(*termunal_cmd); + for (int index = 0; index < len_termunal_cmd; ++index) { + name_terminal = termunal_cmd[index]; + size_t index_term = name_terminal.find(" "); + if (index_term != string::npos){ + name_terminal = name_terminal.substr(0, index_term); + if (name_terminal == file_name) { + cmbTerminal->append(name_terminal); + cmbTerminal->set_active_text(name_terminal); + } + } + } + } +} + +void MainWindow::is_user_wheel(){ + string response = this->call("id -Gn"); + if (response.find("wheel") == string::npos){ + flag_sudo = false; + rbSudo->set_sensitive(flag_sudo); + } + size_t user_index = response.find(" "); + if (user_index!=string::npos){ + user_exec_app = response.substr(0, user_index); + } +} + +unsigned short MainWindow::read_uid_min_max(string filename, string search){ + std::string line; + int uid = 0; + string remove_tab = "\t"; + string remove_space = " "; + std::ifstream in(filename); // окрываем файл для чтения + if (in.is_open()){ + while (getline(in, line)){ + try{ + if (line.find(search) != string::npos && (line.find("SYS_"+search) == string::npos)) { + this->str_remove(line, search); + this->str_remove(line, remove_space); + this->str_remove(line, remove_tab); + uid = atoi(line.c_str()); + } + } + catch (int x) { + if (search == "UID_MIN"){ + uid = 1000; + } + else{ + uid = 65534; + } + + } + + } + } + else{ + if (search == "UID_MIN") { + uid = 1000; + } + else{ + uid = 65534; + } + } + in.close(); + return uid; + +} + +void MainWindow::pars_users() { + unsigned short uid_min = this->read_uid_min_max(file_source_login_min_max, "UID_MIN"); + unsigned short uid_max = this->read_uid_min_max(file_source_login_min_max, "UID_MAX"); + while (true) { + errno = 0; + passwd* entry = getpwent(); + if (!entry) { + if (errno) { + break; + } + break; + } + if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { + cmbUser->append(entry->pw_name); + } + } + endpwent(); +} + +vector MainWindow::split(const std::string &s, char delim) { + std::stringstream ss(s); + std::string item; + std::vector elems; + while (std::getline(ss, item, delim)) { + elems.push_back(item); + } + return elems; +} + +void MainWindow::str_remove(std::string& source, std::string to_remove) { + string::size_type n = to_remove.length(); + for (string::size_type i = source.find(to_remove); + i != string::npos; + i = source.find(to_remove)) + source.erase(i, n); +} + +void MainWindow::pars_apps() { + if (list_app.size() != 0 ) {return;} + namespace fs = std::filesystem; + struct struct_App App; + string file_name = ""; + string str_Categories; + string path = path_all_applications; + for (const auto & entry : fs::directory_iterator(path)) { + file_name = entry.path().filename().string(); + path = string(path_all_applications) +file_name; + if (file_name.find(".desktop") != std::string::npos) { + GKeyFile *gfile=g_key_file_new(); + g_key_file_load_from_file(gfile, path.c_str(), G_KEY_FILE_KEEP_TRANSLATIONS, NULL); + char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", NULL); + char *Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); + char *Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); + char *Categories = g_key_file_get_locale_string(gfile, "Desktop Entry", "Categories", setlocale(LC_ALL, ""), NULL); + char *Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); + char *Mime = g_key_file_get_string(gfile, "Desktop Entry", "MimeType", NULL); + if (Type == NULL) continue; + if (Name == NULL) continue; + if (Exec == NULL) continue; + if (Categories == NULL) continue; + if (Icon == NULL) continue; + str_Categories = Categories; + App.Name = Name; + App.Type = Type; + App.Exec = Exec; + App.Icon = Icon; + if (Mime != NULL) { + App.MimeType = Mime; + } + else{ + App.MimeType = ""; + } + App.Name_desktop = file_name; + App.Categories = split(str_Categories, ';'); + } + list_app.push_back(App); + } +} + +SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) + : Gtk::Plug{p_socketID} { + MainWindow* wnd = nullptr; + builder->get_widget_derived("window", wnd); + builder->get_widget("plugBox", plugBox); + plugBox->get_parent()->remove(*plugBox); + add(*plugBox); + show_all_children(); +} + +MainWindow::~MainWindow() { +} + +void help() { + cout << str_help_h; +} + + + diff --git a/source/ublexec.h b/source/ublexec.h index f9a0fc5..5ea1bd6 100644 --- a/source/ublexec.h +++ b/source/ublexec.h @@ -1,340 +1,124 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include "ubl-utils.h" +#include #include -#include -#include -#include -#include -#include -#include -#include "ubl-util-standard.c" -#include +#include +#include +#include +#include #include "../compile/ubl-cmake.h" - #ifdef WEBKIT_FOUND - #include -#endif + #include +#endif +#include "ubl-strings.h" + +#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ublexec" + +#define _(String) gettext(String) + +#define glade_path "/com/ublinux/ui/ublexec.glade" +#define banner_path "/com/ublinux/images/ublexec-banner.png" +#define CssPath "/com/ublinux/css/ublexec.css" +#define icon_path "com.ublinux.ublexec" +#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) + +#define get_user_id_min_command "grep \"^UID_MIN\" /etc/login.defs |grep -vE '(nologin|false)$' | sed -e 's/\t/ /g' -e 's/ */ /g'|grep -oE \"[0-9]{1,}\"" +#define get_user_id_max_command "grep \"^UID_MAX\" /etc/login.defs | sed -e 's/\t/ /g' -e 's/ */ /g'|grep -oE \"[0-9]{1,}\"" +#define get_users_command "getent passwd |cut -d: -f1,3" +#define get_terminals_info_command "grep \"\" /usr/share/ublexec/csv/ublexec_terminals.csv" + +#define LocalePath "/usr/share/locale" +#define LocaleName "ublexec" +typedef char* string; +string version_application; + +char *local; + +typedef struct { + int always_open_documentation; + int win_pos_x; + int win_pos_y; + int win_width; + int win_height; + + int socket_id; + int load_socket_id; + int save_socket_id; + + int lock_help; + int lock_save_local; + int lock_save_global; + int lock_load_global; + + int user_id_min; + int user_id_max; + dictionary *terminals; +} config; + +typedef struct { + char *name; + char *exec_file; + char *hold; + char *exec_arg; +} terminal_info; + +typedef struct { + //Standard + GtkWidget *Window; + GtkWidget *HatLabel; + GtkWidget *PlugBox; + + GtkWidget *HeadOverlay; + GtkWidget *HeadImage; + GtkWidget *HeadBox; + GtkWidget *HeadTitleLabel; + GtkWidget *HeadInfoLabel; + + GtkWidget *StatusBox; + GtkWidget *StatusIcon; + GtkWidget *StatusLabel; + + GtkWidget *TargetNameEntry; + GtkWidget *AboutMenuItem; + GtkWidget *DocumentationMenuItem; -#define str_tooltip_filemanager _("Program view") -#define str_tooltip_list_app _("File view") -#define copyright _("Copyright © UBSoft LLC, 2022 - ") -#define define_name_app _("Run as...") -#define name_app_1 _("ublexec") -#define website _("https://wiki.ublinux.com") -#define home_page _("Project hompage") -#define space_name_app _(" Run as...") -#define str_about_1 _("About") -#define str_help _("Help") -#define read_online _("Read online") -#define cancel _("Cancel") -#define always_redirect _("Always redirect") -#define read_documentation_web _("Would you like to read documentation in the Web?") -#define redirected_documentation _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") -#define str_help_h _("GTK \"Run applications as another user with the specified priority\" for ""UBLinux\n""\n""Usage: ublexec [OPTIONS...]\n""Options:\n"" -h, --help\t Show this help\n"" -V, --version\t Show package version\n"" -x APP_NAME Running the program\n"" -e FILE_NAME Running the file\n") -#define str_version _("ublexec version: ") -#define nice_19 _("19 (Low)") -#define nice_0 _("0 (High)") -#define nice__20 _("-20 (High)") -#define str_close _("Close") -#define str_localization_system _("System") -#define str_localization_development _("Development") -#define str_localization_other _("Other") -#define str_localization_office _("Office") -#define str_localization_education _("Education") -#define str_localization_settings _("Settings") -#define str_localization_multimedia _("Multimedia") -#define str_localization_internet _("Internet") -#define str_localization_tools _("Tools") -#define str_localization_graphics _("Graphics") -#define str_localization_attention _("Attention") -#define str_localization_priority _("Priority") -#define str_run_of_user _("Run as another user:") -#define str_select_app_program _("Select an executable file or program") -#define str_change_priority _("Change startup priority") -#define str_run_terminal _("Run in the terminal emulator") -#define str_file_overview _("File Overview") -#define str_application_overview _("Application Overview") -#define str_run_applications_as_another _("Run applications as another user\nwith the specified priority") -#define str_localization_username _("User Name:") -#define str_selecting_programs _("Selecting Programs") -#define str_please_select_file _("Please select File") -#define str_localization_cmd_line _("Command Line") -#define str_localization_user _("User") -#define str_localization_team _("Command:") -#define str_run _("Run") + GtkWidget *targetNameEntry; + GtkWidget *chooseFileButton; + GtkWidget *chooseDesktopButton; + GtkWidget *runWithTerminalCheck; + GtkWidget *runWithTerminalCombo; -#define const_link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ublexec" -#define cmd_xdg "xdg-open " -#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \"" -#define path_app "/usr/bin/" -#define path_glade "/com/ublinux/ui/ublexec.glade" -#define path_css "/com/ublinux/css/ublexec.css" -#define app_name "ublexec" -#define path_img_head_background "/com/ublinux/images/ublexec-banner.png" -#define path_all_applications "/usr/share/applications/" -#define file_source_login_min_max "/etc/login.defs" -#define no_print_cmd "nohup %s > /dev/null 2>&1" + GtkWidget *runWithUserCheck; + GtkWidget *runWithUserPkexecCheck; + GtkWidget *runWithUserSuCheck; + GtkWidget *runWithUserSudoCheck; -using namespace std; + GtkWidget *runWithUserCombo; + GtkWidget *priorityCheck; + GtkWidget *priorityScale; + GtkWidget *prioritySpin; + GtkWidget *highestPriorityLabel; -extern string name_app_cmd; -extern int socket_ext_id_I; -extern int socket_trd_id_I; -extern int flag_prog_file; -extern string version_application; -void me_thread(string cmd); -class CmdArgParser : public Glib::OptionGroup -{ -public: - CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help); - ::Window GetSocketID() const; + GtkWidget *commandCheck; + GtkWidget *commandEntry; -private: - int m_socketID = 0; + GtkWidget *runButton; + // Custom +} main_window; -}; -class MainWindow : public Gtk::ApplicationWindow { -public: - MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); - MainWindow(Glib::RefPtr const& builder); - ~MainWindow(); - void template_apps_obj(Gtk::IconView *icon, Glib::RefPtr >k_list_app); - void get_builder(); - void add_CSS(); - void localization(); - void event(); - void settings(); - void close_entry_app(); - void start_menu_entry_app(); - void message_gui_close(); - void activ_or_block_execute_epriority(); - void open_filemaneg(); - void close_filemaneg(); - void get_path_filemaneg(); - void open_list_app(); - string start_cmd(string user_cmd); - void call_app(string &cmd); - void changed_user(); - void entry_app(); - void execute_another_User(){} - void activ_or_block_other_user(); - void change_scale_priority(); - void change_spin_priority(); - void pars_dir_bin(); - void pars_users(); - void pars_apps(); - void select_Graphics(); - void tmp_desktop(string cmd_name); - void on_item_activated(const Gtk::TreeModel::Path& path); - void tempalte_row(string Name, string Exec, string path , Glib::RefPtr &dtk_list); - void tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr >k_list); - void ok_close_entry_app(); - void select_Tools(); - void select_Internet(); - void select_Multimedia(); - void select_Settings(); - void select_Education(); - void select_Office(); - void select_Other(); - void select_Development(); - void select_System(); - void icon_clear(); - void set_icon_array(); - void delete_cmd(const int &x,const int &y); - void help_show(); - void denamic_cmd(); - void temp_help_show(); - void open_help(); - void is_user_wheel(); - void sudo_nice(); - void template_open_browser(string link_doc); - void open_browser(); - vector find_all(string &text, string &word); - bool focus_out_txt_cmd(GdkEventFocus* event); - bool focus_in_txt_cmd(GdkEventFocus* event); - void unselect_icon(Gtk::IconView *icon_entry); - void pars_dir_terminal(); - unsigned short read_uid_min_max(string filename, string search); - void str_remove(std::string& source, std::string to_remove); - void set_sensitive_from_check(); - string call(string cmd); - vector split(const std::string &s, char delim); - public: - class ModelColumns : public Gtk::TreeModel::ColumnRecord { - public: - ModelColumns() - { - add(m_col_filename); - add(m_col_description); - add(m_col_pixbuf); - add(app_name_exec); - add(float_h_align); - add(float_w_align); - add(icon_name); - - } - Gtk::TreeModelColumn m_col_filename; - Gtk::TreeModelColumn icon_name; - Gtk::TreeModelColumn m_col_description; - Gtk::TreeModelColumn app_name_exec; - Gtk::TreeModelColumn > m_col_pixbuf; - Gtk::TreeModelColumn float_h_align; - Gtk::TreeModelColumn float_w_align; - }; - ModelColumns m_Columns; - public: - Glib::RefPtr builder; - Gtk::Button *btnFilemaneg; - Gtk::Button *btnListApp; - Gtk::Button *btnStart; - Gtk::CheckButton *chbTerminal; - Gtk::CheckButton *chbAnotherUser; - Gtk::CheckButton *cbxExecuteEpriority; - Gtk::ComboBoxText *cmbUser; - Gtk::SpinButton *spinPriority; - Gtk::Scale *scalePriority; - Gtk::RadioButton *rbPkexec; - Gtk::RadioButton *rbSu; - Gtk::RadioButton *rbSudo; - Gtk::Entry *txtCmd; - Gtk::FileChooserDialog *wndChooseFileWallpaper; - Gtk::Button *btnFilemangerExit; - Gtk::Button *btnFilemangerOk; - Gtk::Label *lblTimeEpriority; - Gtk::Label *lblTimeEpriorityLow; - Gtk::Label *lblTime4EpriorityHigh; - Gtk::Label *lblUserName; - Gtk::Window *messageError; - Gtk::Button *btnMessageErrorOk; - Gtk::Label *lblMessageError; - Gtk::Button *btnStartMenuOK; - Gtk::Button *btnStartMenuExit; - Gtk::Window *dialogStartMenu; - Gtk::Box *boxColor; - Gtk::Label *lblInfoHead; - Gtk::Label *lblinfoCmd; - Gtk::Label *lblInfoTime; - Gtk::Label *labInfoExecutTerm; - Gtk::Label *lblInfoUser; - Gtk::Label *lblInfoUserOther; - Gtk::Label *lblInfoUserName; - Gtk::Label *lblInfoNooPriority; - Gtk::Label *lblInfoExec; - Gtk::Label *lblInfoPriority; - Gtk::Label *lblGraphics; - Gtk::Label *lblTools; - Gtk::Label *lblInternet; - Gtk::Label *lblMultimedia; - Gtk::Label *lblSettings; - Gtk::Label *lblEducation; - Gtk::Label *lblOffice; - Gtk::Label *lblOther; - Gtk::Label *lblDevelopment; - Gtk::Label *lblSystem; - Gtk::Label *lblHeaderName; - Gtk::IconView *iconGraphics; - Gtk::IconView *iconTools; - Gtk::IconView *iconInternet; - Gtk::IconView *iconMultimedia; - Gtk::IconView *iconSettings; - Gtk::IconView *iconEducation; - Gtk::IconView *iconOffice; - Gtk::IconView *iconOther; - Gtk::IconView *iconDevelopment; - Gtk::IconView *iconSystem; - Gtk::IconView *iconEntry; - Gtk::MenuItem *btnAbout; - Gtk::MenuItem *btnhelp; - Gtk::AboutDialog *aboutWindows; - Gtk::MenuButton *btnSettings; - Gtk::ButtonBox *btnBoxAboutDialog; - Gtk::ComboBoxText *cmbTerminal; - Glib::RefPtr list_Graphics; - Glib::RefPtr list_Tools; - Glib::RefPtr list_Internet; - Glib::RefPtr list_Multimedia; - Glib::RefPtr list_Settings; - Glib::RefPtr list_Education; - Glib::RefPtr list_Office; - Glib::RefPtr list_Other; - Glib::RefPtr list_Development; - Glib::RefPtr list_System; - Gtk::Image *imgHeadBackground; - Gtk::Overlay *overHead; - Gtk::Widget *boxAbout; - Gtk::Label *lblHeaderAboutTopic; - - Gtk::Label *lblHeadeWndWeb; - Gtk::Label *lblwebHeaderName; - Gtk::Label *lblhelpText; - Gtk::Label *lblhelpHeader; - Gtk::CheckButton *chkAlwaysOpenHelp; - Gtk::Button *btnReadHelp; - Gtk::Button *btnCancelHelp; - Gtk::Window *wndShowWeb; - Gtk::Entry *CommandEntry; - Gtk::CheckButton *CommandCheck; - - #ifdef WEBKIT_FOUND - Gtk::Window *wndWeb; - Gtk::Widget *three; - WebKitWebView *my_web_kit = NULL; - #endif - public: - string termunal_cmd[3] = {"konsole -e ", "xfce4-terminal -x ", "xterm -e "}; - string cmd_old = ""; - string user_exec_app = ""; - string user_cmd = ""; - string user_cmd_old = ""; - string name_app_old = ""; - string path_file_old = ""; - string execute_cmd = ""; - string path_file = ""; - string name_app = ""; - int index_error = 0; - bool flag_pkexec = false; - bool flag_su = false; - bool flag_sudo = false; - bool flag_open_browser = false; - string path_file_name; - string global_lick_doc; - struct struct_App { - string Name_desktop; - string Name; - string Exec; - string Icon; - string MimeType; - string Type; - vector Categories; - }; - list list_app; - set set_categories; - int index_exec_gui_apps = 0; - Gtk::IconView* array_icon[10]; - -}; +typedef struct { + GtkWidget *Window; -class SettingsPlug : public Gtk::Plug{ -public: - Gtk::Window *window; - SettingsPlug(::Window p_socketID, Glib::RefPtr builder); + GtkWidget *HatText; + GtkWidget *HeaderText; + GtkWidget *InfoText; + GtkWidget *AlwaysOpenCheck; -private: - Gtk::Widget *plugBox; - Gtk::Widget *parent; -}; -void help(); -void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data); + GtkWidget *CloseButton; + GtkWidget *AcceptButton; +} documentation_confirmation_window; +main_window *setup_window(); \ No newline at end of file diff --git a/ublexec-application.glade b/ublexec-application.glade new file mode 100644 index 0000000..cae39b8 --- /dev/null +++ b/ublexec-application.glade @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + 500 + 600 + False + com.ublinux.ublexec + + + True + False + vertical + 5 + + + True + True + in + + + True + True + treestore1 + False + treeviewcolumn1 + + + column + + + 4 + + + 0 + + + + + + 1 + + + + + + + + + True + True + 0 + + + + + + + True + False + True + + + True + False + center + Applications + + + + + + + + True + False + 32 + com.ublinux.ublexec + + + + + + diff --git a/ublexec.css b/ublexec.css index 3d86970..f8f987c 100644 --- a/ublexec.css +++ b/ublexec.css @@ -18,6 +18,13 @@ transition: 10ms ease-out; border-radius: 3px; } +.boxInfoMessError{ + background-color: #ea9999; +} + +.boxInfoMessOK{ + background-color: #f3f0ac; +} #GnomeIcon{ border-style:solid; border-bottom-width: 1px; @@ -142,3 +149,29 @@ opacity:0.99; } +.aaa{ + margin-top:0px; + margin-bottom:0px; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; +} +.aaa *{ + margin:0 2px 0 2px; + padding-top: 3px; + padding-bottom:3px; + border:transparent; +} +.aaa:hover { + background:@theme_bg_color; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; +} +.aaa:hover * { + margin:0 2px 0 2px; + padding-top: 3px; + padding-bottom:3px; + background:@theme_selected_bg_color; + border-radius:2px; +} \ No newline at end of file diff --git a/ublexec.glade b/ublexec.glade new file mode 100644 index 0000000..b31d342 --- /dev/null +++ b/ublexec.glade @@ -0,0 +1,2365 @@ + + + + + + True + True + 6 + + + False + False + True + center + com.ublinux.ublexec + dialog + True + True + ublexec + 1.0 + Copyright © 2022 - 2023, UBSoft LLC + ublexec + https://ublinux.ru/ + Project Home Page + Это приложение распространяется без каких-либо гарантий. +Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. + UBGroup + UBGroup + com.ublinux.ublexec + True + gpl-2-0 + + + True + False + vertical + 2 + + + False + end + + + False + False + 1 + + + + + + + + + + True + False + True + + + True + False + 5 + 5 + 5 + 5 + 2 + ublexec + + + + + + + + + + -20 + 19 + 1 + 10 + + + True + False + + + 90 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 69 + com.ublinux.ublexec + + + False + True + 0 + + + + + True + False + + + True + False + + + True + False + vertical + + + 255 + True + False + end + Run as... + 0 + + + + + + + + True + True + 0 + + + + + 255 + True + False + start + Run the application as a user with a changed priority + True + 0 + + + + + + + + True + True + 1 + + + + + False + True + 0 + + + + + True + True + 0 + + + + + True + True + 1 + + + + + 410 + 240 + False + com.ublinux.ublexec + + + True + False + vertical + + + True + True + in + + + True + False + 5 + 5 + 5 + 5 + 5 + natural + + + True + False + 1 + 1 + 5 + 0 + etched-out + + + True + False + 12 + + + True + False + vertical + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 4 + 5 + + + + + False + True + 1 + + + + + + + True + False + Graphics + + + + + False + True + 1 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Tools + + + + + False + True + 3 + + + + + True + True + 1 + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Internet + + + + + False + True + 5 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Multimedia + + + + + False + True + 7 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Settings + + + + + False + True + 9 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Education + + + + + False + True + 11 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Office + + + + + False + True + 13 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Other + + + + + False + True + 15 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + Development + + + + + False + True + 17 + + + + + True + True + + + True + False + + + True + False + 7 + 7 + 7 + 7 + + + False + True + 0 + + + + + True + True + 1 + queue + horizontal + 1 + 350 + 1 + 1 + 1 + + + + 5 + 5 + 6 + 2 + + + + + + 5 + 4 + + + + + False + True + 1 + + + + + + + True + False + System + + + + + False + True + 19 + + + + + + + + + + True + False + + + + + + + + + + + + True + True + 1 + + + + + True + False + end + start + + + gtk-cancel + True + True + True + 5 + 5 + 5 + 5 + 6 + 6 + True + + + True + True + 0 + + + + + gtk-ok + -1 + -1 + True + True + True + 5 + 5 + 5 + 5 + 6 + 6 + True + + + True + True + 1 + + + + + False + True + 2 + + + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + gtk-media-play + + + + + + + + + + + + + + + + + + + True + False + False + False + 4 + dropdown-menu + + + True + False + Help + + + + + + True + False + About + + + + + + False + com.ublinux.ublexec + + + True + False + vertical + + + True + False + + + 81 + True + False + start + + + -1 + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + vertical + + + True + False + True + vertical + + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + True + vertical + + + True + False + True + + + 0 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + Team: + True + 0 + + + False + True + 0 + + + + + 440 + True + True + 5 + 5 + 5 + 5 + 6 + 6 + + + True + True + 1 + + + + + 51 + True + True + True + end + 5 + 5 + 5 + 5 + 6 + 6 + + + True + False + center + center + 5 + 5 + 5 + 5 + 3 + 3 + gtk-directory + + + + + False + True + 2 + + + + + 51 + True + True + True + end + 5 + 5 + 5 + 5 + 6 + 6 + + + True + False + center + center + 5 + 5 + 5 + 5 + view-list-details + + + + + False + True + 3 + + + + + False + True + 0 + + + + + True + False + 6 + 6 + True + + + 44 + True + False + 15 + 5 + 15 + 5 + + + False + True + 0 + + + + + True + True + False + start + center + 5 + 5 + 5 + 5 + 6 + True + + + True + False + Run in the terminal emulator + + + + + False + True + 1 + + + + + True + False + start + 2 + 5 + 5 + 6 + + + False + True + 2 + + + + + 116 + True + False + + + False + True + 3 + + + + + False + True + 1 + + + + + + + True + False + start + Command Line + + + + + True + True + 0 + + + + + False + True + 1 + + + + + True + False + 5 + True + vertical + + + True + False + 5 + 5 + 5 + 5 + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + True + vertical + + + True + False + True + + + True + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + True + + + True + False + Run as another user: + + + + + False + True + 0 + + + + + pkexec + True + True + False + 6 + 6 + 6 + True + rbSu + + + False + True + 1 + + + + + su + True + True + False + 3 + 31 + 3 + 31 + True + rbPkexec + + + False + True + 2 + + + + + sudo + True + True + False + 6 + 6 + 6 + 6 + True + rbSu + + + False + True + 3 + + + + + 95 + True + False + end + 15 + 5 + 15 + 5 + + + False + True + 4 + + + + + False + True + 0 + + + + + True + False + True + + + 123 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + User Name: + True + 0 + + + False + True + 0 + + + + + 374 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + + + False + True + 1 + + + + + 0 + True + False + 100 + + + False + True + 2 + + + + + False + True + 1 + + + + + + + True + False + start + User + + + + + True + True + 0 + + + + + False + True + 2 + + + + + True + False + 5 + True + vertical + + + True + False + 5 + 5 + 5 + 5 + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + True + vertical + + + True + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + True + + + True + False + Change startup priority + + + + + False + True + 0 + + + + + True + False + True + + + 5 + True + False + 5 + 5 + 5 + 5 + 13 + Priority: + True + 0 + + + False + True + 0 + + + + + -1 + True + True + 5 + 5 + 5 + 5 + adjustment1 + 20 + 0 + 0 + + + True + True + 1 + + + + + True + True + 5 + 5 + 5 + 5 + 15 + True + + + False + True + 2 + + + + + False + True + 1 + + + + + True + False + 9 + False + + + 62 + True + False + 15 + 5 + 15 + 5 + 0 + + + False + True + 0 + + + + + 145 + True + False + 5 + 5 + 5 + 5 + 6 + 19 (Low) + True + 0 + + + False + True + 1 + + + + + True + False + end + center + 5 + 5 + 5 + 5 + 6 + -20 (High) + True + 0 + + + True + True + 3 + + + + + 107 + True + False + end + 15 + 5 + 15 + 5 + + + False + True + 4 + + + + + False + True + 2 + + + + + + + True + False + start + Priority + + + + + True + True + 0 + + + + + False + True + 3 + + + + + Run + True + True + True + 5 + 5 + 5 + 5 + 6 + 6 + image1 + True + + + False + True + 4 + + + + + False + True + 0 + + + + + False + True + 2 + + + + + + + True + False + True + + + True + False + center + Ublexec + + + + + + + + True + False + 32 + com.ublinux.ublexec + + + + + True + False + + + True + True + False + True + True + menu1 + none + + + True + False + open-menu-symbolic + + + + + False + True + 0 + + + + + end + 1 + + + + + + + False + start + False + + + True + False + vertical + + + True + False + + + True + False + center + 20 + 20 + 20 + 20 + 20 + 20 + dialog-warning-symbolic + 6 + + + False + True + 1 + + + + + True + False + 10 + 25 + 10 + 25 + 20 + 20 + Select an executable file or program + True + 0 + + + True + True + 2 + + + + + True + True + 0 + + + + + Close + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + False + True + 2 + + + + + + + True + False + Warning! + True + + + True + False + 32 + com.ublinux.ublexec + 5 + + + + + + + False + Please select File + True + center + 500 + 400 + True + com.ublinux.ublexec + dialog + True + True + + + False + vertical + 2 + + + False + end + + + gtk-cancel + True + True + True + True + + + True + True + 0 + + + + + gtk-ok + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + + + + + + False + start + start + False + 450 + 250 + dialog-question-symbolic + + + True + False + vertical + + + True + False + + + True + False + start + 20 + 20 + dialog-question-symbolic + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + start + 10 + 5 + Would you like to read documentation in the Web? + True + 0 + + + + + + + False + True + 0 + + + + + True + False + start + start + 10 + 10 + You will be redirected to documentation website where documentation is translated and supported by community. + True + 0 + + + + True + True + 1 + + + + + Always redirect to online documentation + True + True + False + end + 10 + True + + + + False + True + 2 + + + + + + True + True + 1 + + + + + + True + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 30 + True + + + Cancel + True + True + True + + + + True + True + 0 + + + + + Read Online + True + True + True + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + True + False + True + + + True + False + ublexec + + + + + + + + True + False + 32 + dialog-question-symbolic + + + + + + + 800 + 600 + False + True + True + com.ublinux.ublexec + + + + + + True + False + True + + + True + False + ublexec + + + + + True + False + 32 + com.ublinux.ublexec + 5 + + + + + + diff --git a/ublexec.pot b/ublexec.pot index f187a7b..e42dbac 100644 --- a/ublexec.pot +++ b/ublexec.pot @@ -17,355 +17,192 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -msgid "Run the application as a user with a changed priority" +#: source/ubl-strings.h:1 +msgid "Version:" msgstr "" -msgid "File view" +#: source/ubl-strings.h:2 +msgid "ublexec version:" msgstr "" -msgid "Program view" +#: source/ubl-strings.h:2 source/ubl-strings.h:4 +msgid "Run as..." msgstr "" -#: source/ublexec.h:32 source/ublexec.cc:181 source/ublexec.cc:182 -#: source/ublexec.cc:180 source/ublexec.cc:163 -msgid " Run as..." +#: source/ubl-strings.h:2 +msgid "Usage:" msgstr "" -#: source/ublexec.h:53 source/ublexec.cc:274 source/ublexec.cc:282 -#: source/ublexec.cc:313 source/ublexec.cc:272 source/ublexec.cc:280 -#: source/ublexec.cc:311 source/ublexec.cc:242 source/ublexec.cc:250 -#: source/ublexec.cc:281 source/ublexec.cc:236 source/ublexec.cc:244 -#: source/ublexec.cc:275 -msgid "-20 (High)" +#: source/ubl-strings.h:2 +msgid "[OPTIONS]" msgstr "" -#: source/ublexec.h:52 source/ublexec.cc:290 source/ublexec.cc:298 -#: source/ublexec.cc:321 source/ublexec.cc:487 source/ublexec.cc:288 -#: source/ublexec.cc:296 source/ublexec.cc:319 source/ublexec.cc:485 -#: source/ublexec.cc:258 source/ublexec.cc:266 source/ublexec.cc:289 -#: source/ublexec.cc:426 source/ublexec.cc:252 source/ublexec.cc:260 -#: source/ublexec.cc:283 source/ublexec.cc:413 -msgid "0 (High)" +#: source/ubl-strings.h:2 +msgid "Options:" msgstr "" -#: source/ublexec.h:51 source/ublexec.cc:273 source/ublexec.cc:281 -#: source/ublexec.cc:289 source/ublexec.cc:297 source/ublexec.cc:312 -#: source/ublexec.cc:320 source/ublexec.cc:486 source/ublexec.cc:271 -#: source/ublexec.cc:279 source/ublexec.cc:287 source/ublexec.cc:295 -#: source/ublexec.cc:310 source/ublexec.cc:318 source/ublexec.cc:484 -#: source/ublexec.cc:241 source/ublexec.cc:249 source/ublexec.cc:257 -#: source/ublexec.cc:265 source/ublexec.cc:280 source/ublexec.cc:288 -#: source/ublexec.cc:425 source/ublexec.cc:235 source/ublexec.cc:243 -#: source/ublexec.cc:251 source/ublexec.cc:259 source/ublexec.cc:274 -#: source/ublexec.cc:282 source/ublexec.cc:412 -msgid "19 (Low)" +#: source/ubl-strings.h:2 +msgid "Show this help" msgstr "" -#: source/ublexec.h:33 source/ublexec.cc:177 source/ublexec.cc:176 -#: source/ublexec.cc:159 source/ublexec.cc:156 -msgid "About" +#: source/ubl-strings.h:2 +msgid "Show package version" msgstr "" -#: source/ublexec.h:34 -msgid "About ubl-settings-datetime" +#: source/ubl-strings.h:2 +msgid "Lock this help menu" msgstr "" -#: source/ublexec.h:45 source/ublexec.cc:218 source/ublexec.cc:216 -msgid "Always redirect" +#: source/ubl-strings.h:5 +msgid "Run the application as a user with a changed priority" msgstr "" -#: source/ublexec.h:72 source/ublexec.cc:210 source/ublexec.cc:208 -#: source/ublexec.cc:191 source/ublexec.cc:186 -msgid "Application Overview" +#: source/ubl-strings.h:7 +msgid "Operation succeeded" msgstr "" -#: source/ublexec.h:65 source/ublexec.cc:199 source/ublexec.cc:696 -#: source/ublexec.cc:765 source/ublexec.cc:197 source/ublexec.cc:694 -#: source/ublexec.cc:763 source/ublexec.cc:180 source/ublexec.cc:631 -#: source/ublexec.cc:700 -msgid "Attention" +#: source/ubl-strings.h:9 +msgid "About" msgstr "" -#: source/ublexec.h:44 source/ublexec.cc:217 source/ublexec.cc:215 -msgid "Cancel" +#: source/ubl-strings.h:10 +msgid "Documentation" msgstr "" -#: source/ublexec.h:69 source/ublexec.cc:196 source/ublexec.cc:194 -#: source/ublexec.cc:177 source/ublexec.cc:173 -msgid "Change startup priority" +#: source/ubl-strings.h:12 source/ubl-utils.c:1023 +msgid "Cancel" msgstr "" -#: source/ublexec.h:54 source/ublexec.cc:212 source/ublexec.cc:210 -#: source/main.cc:197 -msgid "Close" +#: source/ubl-strings.h:13 +msgid "Open" msgstr "" -#: source/ublexec.h:77 source/ublexec.cc:189 source/ublexec.cc:187 -#: source/ublexec.cc:170 source/ublexec.cc:166 -msgid "Command Line" +#: source/ubl-strings.h:15 +msgid "Would you like to read documentation in the Web?" msgstr "" -#: source/ublexec.h:27 source/ublexec.cc:173 source/ublexec.cc:172 -#: source/ublexec.cc:155 source/ublexec.cc:152 -msgid "Copyright © UBSoft LLC, 2022 - " +#: source/ubl-strings.h:16 +msgid "" +"You will be redirected to documentation website where documentation is\n" +"translated and supported by community." msgstr "" -#: source/ublexec.h:56 source/ublexec.cc:208 source/ublexec.cc:206 -#: source/ublexec.cc:189 source/ublexec.cc:184 -msgid "Development" +#: source/ubl-strings.h:17 +msgid "Always redirect to online documentation" msgstr "" -#: source/ublexec.h:59 source/ublexec.cc:205 source/ublexec.cc:203 -#: source/ublexec.cc:186 source/ublexec.cc:181 -msgid "Education" +#: source/ubl-strings.h:18 +msgid "Open documentation" msgstr "" -#: source/ublexec.h:71 source/ublexec.cc:211 source/ublexec.cc:209 -#: source/ublexec.cc:192 source/ublexec.cc:187 -msgid "File Overview" +#: source/ubl-strings.h:19 +msgid "Project homepage" msgstr "" -#: source/ublexec.h:49 -msgid "" -"GTK \"Run applications as another user with the specified priority\" for " -"UBLinux\n" -"\n" -"Usage: ublexec [OPTIONS...]\n" -"Options:\n" -" -h, --help\t Show this help\n" -" -V, --version\t Show package version\n" -" -x APP_NAME Running the program\n" -" -e FILE_NAME Running the file\n" -msgstr "" - -#: source/ublexec.h:49 -msgid "" -"GTK settings datetime for UBLinux\n" -"\n" -"Usage: ubl-settings-datetime [OPTIONS...]\n" -"Options:\n" -" -h, --help\t Show this help\n" -" -V, --version\t Show package version\n" -" --lock-datetime Lock date and time changes\n" -" --lock-timezone Lock time zone changes\n" -" --lock-ntp-mode Lock NTP mode selection\n" -" --lock-ntp-edit Lock editing NTP servers\n" -" --lock-sync-hwclock Lock sync hwclock mode selection\n" -" --lock-save Lock saving local and global configuration\n" -" --lock-save-local Lock save global configuration\n" -" --lock-save-global Lock load global configuration\n" -" --lock-load-global Lock load global configuration\n" -msgstr "" - -#: source/ublexec.h:64 source/ublexec.cc:200 source/ublexec.cc:198 -#: source/ublexec.cc:181 source/ublexec.cc:176 +#: source/ubl-strings.h:21 msgid "Graphics" msgstr "" -#: source/ublexec.h:35 source/ublexec.cc:176 source/ublexec.cc:175 -#: source/ublexec.cc:158 source/ublexec.cc:155 -msgid "Help" +#: source/ubl-strings.h:22 +msgid "Tools" msgstr "" -#: source/ublexec.h:62 source/ublexec.cc:202 source/ublexec.cc:200 -#: source/ublexec.cc:183 source/ublexec.cc:178 +#: source/ubl-strings.h:23 msgid "Internet" msgstr "" -#: source/ublexec.h:37 -msgid "Load" -msgstr "" - -#: source/ublexec.h:41 -msgid "Load global configuration" -msgstr "" - -#: source/ublexec.h:42 -msgid "Load local configuration" +#: source/ubl-strings.h:24 +msgid "Multimedia" msgstr "" -#: source/ublexec.h:61 source/ublexec.cc:203 source/ublexec.cc:201 -#: source/ublexec.cc:184 source/ublexec.cc:179 -msgid "Multimedia" +#: source/ubl-strings.h:25 +msgid "Settings" msgstr "" -#: source/ublexec.h:46 -msgid "Nothing to save!" +#: source/ubl-strings.h:26 +msgid "Education" msgstr "" -#: source/ublexec.h:58 source/ublexec.cc:206 source/ublexec.cc:204 -#: source/ublexec.cc:187 source/ublexec.cc:182 +#: source/ubl-strings.h:27 msgid "Office" msgstr "" -#: source/ublexec.h:57 source/ublexec.cc:207 source/ublexec.cc:205 -#: source/ublexec.cc:188 source/ublexec.cc:183 +#: source/ubl-strings.h:28 msgid "Other" msgstr "" -#: source/ublexec.h:76 source/ublexec.cc:186 source/ublexec.cc:184 -#: source/ublexec.cc:167 source/ublexec.cc:163 -msgid "Please select File" -msgstr "" - -#: source/ublexec.h:66 source/ublexec.cc:195 source/ublexec.cc:193 -#: source/ublexec.cc:176 source/ublexec.cc:172 -msgid "Priority" -msgstr "" - -#: source/ublexec.cc:197 source/ublexec.cc:195 source/ublexec.cc:178 -#: source/ublexec.cc:174 -msgid "Priority:" -msgstr "" - -#: source/ublexec.h:31 source/ublexec.cc:179 source/ublexec.cc:178 -#: source/ublexec.cc:161 source/ublexec.cc:158 -msgid "Project Home Page" -msgstr "" - -#: source/ublexec.h:43 source/ublexec.cc:216 source/ublexec.cc:214 -msgid "Read online" +#: source/ubl-strings.h:29 +msgid "Development" msgstr "" -#: source/ublexec.h:80 source/ublexec.cc:185 source/ublexec.cc:183 -#: source/ublexec.cc:162 -msgid "Run" +#: source/ubl-strings.h:30 +msgid "System" msgstr "" -#: source/ublexec.h:73 source/ublexec.cc:188 source/ublexec.cc:186 -#: source/ublexec.cc:169 source/ublexec.cc:165 -msgid "" -"Run applications as another user\n" -"with the specified priority" +#: source/ubl-strings.h:32 +msgid "-20 (High)" msgstr "" -msgid "Run as another user" +#: source/ubl-strings.h:33 +msgid "0 (High)" msgstr "" -#: source/ublexec.h:67 source/ublexec.cc:193 source/ublexec.cc:191 -#: source/ublexec.cc:174 source/ublexec.cc:170 -msgid "Run as another user:" +#: source/ubl-strings.h:34 +msgid "19 (Low)" msgstr "" -#: source/ublexec.h:28 source/ublexec.cc:178 source/ublexec.cc:183 -#: source/ublexec.cc:184 source/ublexec.cc:220 source/ublexec.cc:221 -#: source/ublexec.cc:177 source/ublexec.cc:181 source/ublexec.cc:182 -#: source/ublexec.cc:218 source/ublexec.cc:219 source/ublexec.cc:160 -#: source/ublexec.cc:164 source/ublexec.cc:165 source/ublexec.cc:166 -msgid "Run as..." +#: source/ubl-strings.h:36 +msgid "Choose application or file for running" msgstr "" -#: source/ublexec.h:70 source/ublexec.cc:191 source/ublexec.cc:189 -#: source/ublexec.cc:172 source/ublexec.cc:168 +#: source/ubl-strings.h:38 msgid "Run in the terminal emulator" msgstr "" -#: source/ublexec.h:36 -msgid "Save" -msgstr "" - -#: source/ublexec.h:40 -msgid "Save global configuration" -msgstr "" - -#: source/ublexec.h:39 -msgid "Save local configuration" -msgstr "" - -#: source/ublexec.h:38 -msgid "Save to global and local configuration" -msgstr "" - -#: source/ublexec.h:68 source/ublexec.cc:198 source/ublexec.cc:196 -#: source/ublexec.cc:179 source/ublexec.cc:175 -msgid "Select an executable file or program" -msgstr "" - -#: source/ublexec.h:75 source/ublexec.cc:187 source/ublexec.cc:185 -#: source/ublexec.cc:168 source/ublexec.cc:164 -msgid "Selecting Programs" -msgstr "" - -#: source/ublexec.h:60 source/ublexec.cc:204 source/ublexec.cc:202 -#: source/ublexec.cc:185 source/ublexec.cc:180 -msgid "Settings" -msgstr "" - -#: source/ublexec.h:55 source/ublexec.cc:209 source/ublexec.cc:207 -#: source/ublexec.cc:190 source/ublexec.cc:185 -msgid "System" -msgstr "" - -msgid "Team" -msgstr "" - -#: source/ublexec.h:79 source/ublexec.cc:190 source/ublexec.cc:188 -#: source/ublexec.cc:171 source/ublexec.cc:167 -msgid "Team:" +#: source/ubl-strings.h:39 +msgid "File or app for running" msgstr "" -#: source/ublexec.h:63 source/ublexec.cc:201 source/ublexec.cc:199 -#: source/ublexec.cc:182 source/ublexec.cc:177 -msgid "Tools" -msgstr "" - -#: source/ublexec.h:78 source/ublexec.cc:192 source/ublexec.cc:190 -#: source/ublexec.cc:173 source/ublexec.cc:169 -msgid "User" -msgstr "" - -msgid "User Name" +#: source/ubl-strings.h:40 +msgid "Run as another user:" msgstr "" -#: source/ublexec.h:74 source/ublexec.cc:194 source/ublexec.cc:192 -#: source/ublexec.cc:175 source/ublexec.cc:171 +#: source/ubl-strings.h:41 msgid "User Name:" msgstr "" -#: source/ublexec.h:47 source/ublexec.cc:213 source/ublexec.cc:211 -msgid "Would you like to read documentation in the Web?" -msgstr "" - -#: source/ublexec.h:48 source/ublexec.cc:214 source/ublexec.cc:212 -"You will be redirected to documentation website where documentation is\n" -"translated and supported by community." -msgstr "" - -#: source/ublexec.h:30 source/ublexec.cc:175 source/ublexec.cc:174 -#: source/ublexec.cc:157 source/ublexec.cc:154 -msgid "https://wiki.ublinux.com" -msgstr "" - -#: source/ublexec.cc:321 source/ublexec.cc:313 -msgid "" -"https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/" +#: source/ubl-strings.h:42 +msgid "Priority" msgstr "" -msgid "pkexec" +#: source/ubl-strings.h:43 +msgid "Change startup priority" msgstr "" -msgid "su" +#: source/ubl-strings.h:44 +msgid "Priority:" msgstr "" -msgid "sudo" +#: source/ubl-strings.h:45 +msgid "Command line" msgstr "" -#: source/ublexec.cc:219 source/ublexec.cc:217 -msgid "ubl-settings-bootloader" +#: source/ubl-strings.h:46 +msgid "Run" msgstr "" -#: source/ublexec.h:29 source/ublexec.cc:157 source/ublexec.cc:160 -#: source/ublexec.cc:161 -msgid "ublexec" +#: source/ubl-strings.h:47 +msgid "Edit" msgstr "" -#: source/ublexec.h:50 source/main.cc:60 source/main.cc:970 -msgid "ublexec version: " +#: source/ubl-strings.h:48 +msgid "User" msgstr "" -msgid "ОК" +#: source/ubl-utils.c:1022 +msgid "Applications" msgstr "" -#: source/ublexec.cc:193 -msgid "Сancel" +#: source/ubl-utils.c:1023 +msgid "Accept" msgstr "" diff --git a/ublexec_ru.po b/ublexec_ru.po index 242c5cc..0c09fe9 100644 --- a/ublexec_ru.po +++ b/ublexec_ru.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ublexec 1.0\n" "Report-Msgid-Bugs-To: info@ublinux.com\n" -"POT-Creation-Date: 2023-04-24 11:43+0600\n" +"POT-Creation-Date: 2023-04-25 15:52+0600\n" "PO-Revision-Date: 2023-01-01 00:00+0600\n" "Last-Translator: UBLinux Team \n" "Language-Team: Russian - UBLinux Team \n" @@ -17,374 +17,195 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -msgid "Run the application as a user with a changed priority" -msgstr "Выполнить приложение от имени пользователя с изменённым приоритетом" +#: source/ubl-strings.h:1 +msgid "Version:" +msgstr "Версия:" -msgid "File view" -msgstr "Обзор файлов" +#: source/ubl-strings.h:2 +#, fuzzy +msgid "ublexec version:" +msgstr "ublexec версия: " -msgid "Program view" -msgstr "Обзор программ" +#: source/ubl-strings.h:2 source/ubl-strings.h:4 +msgid "Run as..." +msgstr "Выполнить как..." -#: source/ublexec.h:32 source/ublexec.cc:181 source/ublexec.cc:182 -#: source/ublexec.cc:180 source/ublexec.cc:163 -msgid " Run as..." -msgstr "О программе Выполнить как..." +#: source/ubl-strings.h:2 +msgid "Usage:" +msgstr "Использование:" -#: source/ublexec.h:53 source/ublexec.cc:274 source/ublexec.cc:282 -#: source/ublexec.cc:313 source/ublexec.cc:272 source/ublexec.cc:280 -#: source/ublexec.cc:311 source/ublexec.cc:242 source/ublexec.cc:250 -#: source/ublexec.cc:281 source/ublexec.cc:236 source/ublexec.cc:244 -#: source/ublexec.cc:275 -msgid "-20 (High)" -msgstr "-20 (Высокий)" +#: source/ubl-strings.h:2 +msgid "[OPTIONS]" +msgstr "[АРГУМЕНТЫ]" -#: source/ublexec.h:52 source/ublexec.cc:290 source/ublexec.cc:298 -#: source/ublexec.cc:321 source/ublexec.cc:487 source/ublexec.cc:288 -#: source/ublexec.cc:296 source/ublexec.cc:319 source/ublexec.cc:485 -#: source/ublexec.cc:258 source/ublexec.cc:266 source/ublexec.cc:289 -#: source/ublexec.cc:426 source/ublexec.cc:252 source/ublexec.cc:260 -#: source/ublexec.cc:283 source/ublexec.cc:413 -msgid "0 (High)" -msgstr "0 (Высокий)" +#: source/ubl-strings.h:2 +msgid "Options:" +msgstr "Аргументы:" -#: source/ublexec.h:51 source/ublexec.cc:273 source/ublexec.cc:281 -#: source/ublexec.cc:289 source/ublexec.cc:297 source/ublexec.cc:312 -#: source/ublexec.cc:320 source/ublexec.cc:486 source/ublexec.cc:271 -#: source/ublexec.cc:279 source/ublexec.cc:287 source/ublexec.cc:295 -#: source/ublexec.cc:310 source/ublexec.cc:318 source/ublexec.cc:484 -#: source/ublexec.cc:241 source/ublexec.cc:249 source/ublexec.cc:257 -#: source/ublexec.cc:265 source/ublexec.cc:280 source/ublexec.cc:288 -#: source/ublexec.cc:425 source/ublexec.cc:235 source/ublexec.cc:243 -#: source/ublexec.cc:251 source/ublexec.cc:259 source/ublexec.cc:274 -#: source/ublexec.cc:282 source/ublexec.cc:412 -msgid "19 (Low)" -msgstr "19 (Низкий)" +#: source/ubl-strings.h:2 +msgid "Show this help" +msgstr "Показать эту подсказку" -#: source/ublexec.h:33 source/ublexec.cc:177 source/ublexec.cc:176 -#: source/ublexec.cc:159 source/ublexec.cc:156 -msgid "About" -msgstr "О программе" +#: source/ubl-strings.h:2 +msgid "Show package version" +msgstr "Показать версию пакета" -#: source/ublexec.h:34 -msgid "About ubl-settings-datetime" -msgstr "" +#: source/ubl-strings.h:2 +msgid "Lock this help menu" +msgstr "Заблокироват справку" -#: source/ublexec.h:45 source/ublexec.cc:218 source/ublexec.cc:216 -msgid "Always redirect" -msgstr "Всегда перенаправлять" +#: source/ubl-strings.h:5 +msgid "Run the application as a user with a changed priority" +msgstr "Выполнить приложение от имени пользователя с изменённым приоритетом" -#: source/ublexec.h:72 source/ublexec.cc:210 source/ublexec.cc:208 -#: source/ublexec.cc:191 source/ublexec.cc:186 -msgid "Application Overview" -msgstr "Обзор приложений" +#: source/ubl-strings.h:7 +msgid "Operation succeeded" +msgstr "Операция завершена" -#: source/ublexec.h:65 source/ublexec.cc:199 source/ublexec.cc:696 -#: source/ublexec.cc:765 source/ublexec.cc:197 source/ublexec.cc:694 -#: source/ublexec.cc:763 source/ublexec.cc:180 source/ublexec.cc:631 -#: source/ublexec.cc:700 -msgid "Attention" -msgstr "Внимание" +#: source/ubl-strings.h:9 +msgid "About" +msgstr "О программе" -#: source/ublexec.h:44 source/ublexec.cc:217 source/ublexec.cc:215 +#: source/ubl-strings.h:10 +msgid "Documentation" +msgstr "Справка" + +#: source/ubl-strings.h:12 source/ubl-utils.c:1023 msgid "Cancel" msgstr "Отменить" -#: source/ublexec.h:69 source/ublexec.cc:196 source/ublexec.cc:194 -#: source/ublexec.cc:177 source/ublexec.cc:173 -msgid "Change startup priority" -msgstr "Изменить приоритет запуска" - -#: source/ublexec.h:54 source/ublexec.cc:212 source/ublexec.cc:210 -#: source/main.cc:197 -msgid "Close" -msgstr "Закрыть" +#: source/ubl-strings.h:13 +msgid "Open" +msgstr "Открыть" -#: source/ublexec.h:77 source/ublexec.cc:189 source/ublexec.cc:187 -#: source/ublexec.cc:170 source/ublexec.cc:166 -msgid "Command Line" -msgstr "Командная строка" - -#: source/ublexec.h:27 source/ublexec.cc:173 source/ublexec.cc:172 -#: source/ublexec.cc:155 source/ublexec.cc:152 -msgid "Copyright © UBSoft LLC, 2022 - " -msgstr "Авторские права © ООО \"Юбисофт\", 2022 - " +#: source/ubl-strings.h:15 +msgid "Would you like to read documentation in the Web?" +msgstr "Вы хотите прочитать справку в Сети?" -#: source/ublexec.h:56 source/ublexec.cc:208 source/ublexec.cc:206 -#: source/ublexec.cc:189 source/ublexec.cc:184 -msgid "Development" -msgstr "Разработка" +#: source/ubl-strings.h:16 +msgid "" +"You will be redirected to documentation website where documentation is\n" +"translated and supported by community." +msgstr "" +"Вы будете перенаправлены на сайт с документацией где страницы помощи\n" +"переводятся и поддерживаются сообществом." -#: source/ublexec.h:59 source/ublexec.cc:205 source/ublexec.cc:203 -#: source/ublexec.cc:186 source/ublexec.cc:181 -msgid "Education" -msgstr "Образование" +#: source/ubl-strings.h:17 +msgid "Always redirect to online documentation" +msgstr "Всегда перенаправлять на онлайн документацию" -#: source/ublexec.h:71 source/ublexec.cc:211 source/ublexec.cc:209 -#: source/ublexec.cc:192 source/ublexec.cc:187 -msgid "File Overview" -msgstr "Обзор файлов" +#: source/ubl-strings.h:18 +msgid "Open documentation" +msgstr "Открыть документацию" -#: source/ublexec.h:49 -msgid "" -"GTK \"Run applications as another user with the specified priority\" for " -"UBLinux\n" -"\n" -"Usage: ublexec [OPTIONS...]\n" -"Options:\n" -" -h, --help\t Show this help\n" -" -V, --version\t Show package version\n" -" -x APP_NAME Running the program\n" -" -e FILE_NAME Running the file\n" -msgstr "" -"GTK-утилита \"Запускать приложения от имени другого пользователя с указанным " -"приоритетом\" для UBLinux\n" -"\n" -"Использование: ublexec [Параметры приложения...]\n" -"Параметры приложения:\n" -" -h, --help\t Показать параметры справки\n" -" -V, --version\t Показать версию пакета\n" -" -x APP_NAME Запуск программы\n" -" -e FILE_NAME Запуск файла\n" - -#: source/ublexec.h:49 -msgid "" -"GTK settings datetime for UBLinux\n" -"\n" -"Usage: ubl-settings-datetime [OPTIONS...]\n" -"Options:\n" -" -h, --help\t Show this help\n" -" -V, --version\t Show package version\n" -" --lock-datetime Lock date and time changes\n" -" --lock-timezone Lock time zone changes\n" -" --lock-ntp-mode Lock NTP mode selection\n" -" --lock-ntp-edit Lock editing NTP servers\n" -" --lock-sync-hwclock Lock sync hwclock mode selection\n" -" --lock-save Lock saving local and global configuration\n" -" --lock-save-local Lock save global configuration\n" -" --lock-save-global Lock load global configuration\n" -" --lock-load-global Lock load global configuration\n" -msgstr "" +#: source/ubl-strings.h:19 +msgid "Project homepage" +msgstr "Домашняя страница проекта" -#: source/ublexec.h:64 source/ublexec.cc:200 source/ublexec.cc:198 -#: source/ublexec.cc:181 source/ublexec.cc:176 +#: source/ubl-strings.h:21 msgid "Graphics" msgstr "Графика" -#: source/ublexec.h:35 source/ublexec.cc:176 source/ublexec.cc:175 -#: source/ublexec.cc:158 source/ublexec.cc:155 -msgid "Help" -msgstr "Справка" +#: source/ubl-strings.h:22 +msgid "Tools" +msgstr "Инструменты" -#: source/ublexec.h:62 source/ublexec.cc:202 source/ublexec.cc:200 -#: source/ublexec.cc:183 source/ublexec.cc:178 +#: source/ubl-strings.h:23 msgid "Internet" msgstr "Интернет" -#: source/ublexec.h:37 -msgid "Load" -msgstr "" - -#: source/ublexec.h:41 -msgid "Load global configuration" -msgstr "" - -#: source/ublexec.h:42 -msgid "Load local configuration" -msgstr "" - -#: source/ublexec.h:61 source/ublexec.cc:203 source/ublexec.cc:201 -#: source/ublexec.cc:184 source/ublexec.cc:179 +#: source/ubl-strings.h:24 msgid "Multimedia" msgstr "Мультимедиа" -#: source/ublexec.h:46 -msgid "Nothing to save!" -msgstr "" +#: source/ubl-strings.h:25 +msgid "Settings" +msgstr "Настройки" + +#: source/ubl-strings.h:26 +msgid "Education" +msgstr "Образование" -#: source/ublexec.h:58 source/ublexec.cc:206 source/ublexec.cc:204 -#: source/ublexec.cc:187 source/ublexec.cc:182 +#: source/ubl-strings.h:27 msgid "Office" msgstr "Офис" -#: source/ublexec.h:57 source/ublexec.cc:207 source/ublexec.cc:205 -#: source/ublexec.cc:188 source/ublexec.cc:183 +#: source/ubl-strings.h:28 msgid "Other" msgstr "Прочие" -#: source/ublexec.h:76 source/ublexec.cc:186 source/ublexec.cc:184 -#: source/ublexec.cc:167 source/ublexec.cc:163 -msgid "Please select File" -msgstr "Пожалуйста выберите Файл" - -#: source/ublexec.h:66 source/ublexec.cc:195 source/ublexec.cc:193 -#: source/ublexec.cc:176 source/ublexec.cc:172 -msgid "Priority" -msgstr "Приоритет" - -#: source/ublexec.cc:197 source/ublexec.cc:195 source/ublexec.cc:178 -#: source/ublexec.cc:174 -msgid "Priority:" -msgstr "Приоритет:" - -#: source/ublexec.h:31 source/ublexec.cc:179 source/ublexec.cc:178 -#: source/ublexec.cc:161 source/ublexec.cc:158 -msgid "Project Home Page" -msgstr "Домашняя страница проекта" - -#: source/ublexec.h:43 source/ublexec.cc:216 source/ublexec.cc:214 -msgid "Read online" -msgstr "Прочитать онлайн" +#: source/ubl-strings.h:29 +msgid "Development" +msgstr "Разработка" -#: source/ublexec.h:80 source/ublexec.cc:185 source/ublexec.cc:183 -#: source/ublexec.cc:162 -msgid "Run" -msgstr "Запустить" +#: source/ubl-strings.h:30 +msgid "System" +msgstr "Система" -#: source/ublexec.h:73 source/ublexec.cc:188 source/ublexec.cc:186 -#: source/ublexec.cc:169 source/ublexec.cc:165 -msgid "" -"Run applications as another user\n" -"with the specified priority" -msgstr "" -"Запускать приложения от имени другого пользователя\n" -"с указанным приоритетом" +#: source/ubl-strings.h:32 +msgid "-20 (High)" +msgstr "-20 (Высокий)" -#, fuzzy -msgid "Run as another user" -msgstr "Выполнить от имени другого пользователя:" +#: source/ubl-strings.h:33 +msgid "0 (High)" +msgstr "0 (Высокий)" -#: source/ublexec.h:67 source/ublexec.cc:193 source/ublexec.cc:191 -#: source/ublexec.cc:174 source/ublexec.cc:170 -msgid "Run as another user:" -msgstr "Выполнить от имени другого пользователя:" +#: source/ubl-strings.h:34 +msgid "19 (Low)" +msgstr "19 (Низкий)" -#: source/ublexec.h:28 source/ublexec.cc:178 source/ublexec.cc:183 -#: source/ublexec.cc:184 source/ublexec.cc:220 source/ublexec.cc:221 -#: source/ublexec.cc:177 source/ublexec.cc:181 source/ublexec.cc:182 -#: source/ublexec.cc:218 source/ublexec.cc:219 source/ublexec.cc:160 -#: source/ublexec.cc:164 source/ublexec.cc:165 source/ublexec.cc:166 -msgid "Run as..." -msgstr "Выполнить как..." +#: source/ubl-strings.h:36 +msgid "Choose application or file for running" +msgstr "Выберите приложение или файл для запуска" -#: source/ublexec.h:70 source/ublexec.cc:191 source/ublexec.cc:189 -#: source/ublexec.cc:172 source/ublexec.cc:168 +#: source/ubl-strings.h:38 msgid "Run in the terminal emulator" -msgstr "Выполнить в эмуляторе терминала" - -#: source/ublexec.h:36 -msgid "Save" -msgstr "" +msgstr "Запустить в эмуляторе терминала" -#: source/ublexec.h:40 -msgid "Save global configuration" -msgstr "" +#: source/ubl-strings.h:39 +msgid "File or app for running" +msgstr "Запуск приложения или файла" -#: source/ublexec.h:39 -msgid "Save local configuration" -msgstr "" - -#: source/ublexec.h:38 -msgid "Save to global and local configuration" -msgstr "" - -#: source/ublexec.h:68 source/ublexec.cc:198 source/ublexec.cc:196 -#: source/ublexec.cc:179 source/ublexec.cc:175 -msgid "Select an executable file or program" -msgstr "Выберите исполняемый файл или программу" - -#: source/ublexec.h:75 source/ublexec.cc:187 source/ublexec.cc:185 -#: source/ublexec.cc:168 source/ublexec.cc:164 -msgid "Selecting Programs" -msgstr "Выбор программ" - -#: source/ublexec.h:60 source/ublexec.cc:204 source/ublexec.cc:202 -#: source/ublexec.cc:185 source/ublexec.cc:180 -msgid "Settings" -msgstr "Настройки" - -#: source/ublexec.h:55 source/ublexec.cc:209 source/ublexec.cc:207 -#: source/ublexec.cc:190 source/ublexec.cc:185 -msgid "System" -msgstr "Система" - -#, fuzzy -msgid "Team" -msgstr "Команда:" - -#: source/ublexec.h:79 source/ublexec.cc:190 source/ublexec.cc:188 -#: source/ublexec.cc:171 source/ublexec.cc:167 -msgid "Team:" -msgstr "Команда:" - -#: source/ublexec.h:63 source/ublexec.cc:201 source/ublexec.cc:199 -#: source/ublexec.cc:182 source/ublexec.cc:177 -msgid "Tools" -msgstr "Инструменты" - -#: source/ublexec.h:78 source/ublexec.cc:192 source/ublexec.cc:190 -#: source/ublexec.cc:173 source/ublexec.cc:169 -msgid "User" -msgstr "Пользователь" - -#, fuzzy -msgid "User Name" -msgstr "Имя пользователя:" +#: source/ubl-strings.h:40 +msgid "Run as another user:" +msgstr "Выполнить от имени другого пользователя с помощью:" -#: source/ublexec.h:74 source/ublexec.cc:194 source/ublexec.cc:192 -#: source/ublexec.cc:175 source/ublexec.cc:171 +#: source/ubl-strings.h:41 msgid "User Name:" msgstr "Имя пользователя:" -#: source/ublexec.h:47 source/ublexec.cc:213 source/ublexec.cc:211 -msgid "Would you like to read documentation in the Web?" -msgstr "Вы хотите прочитать справку в Сети?" - -#: source/ublexec.h:48 source/ublexec.cc:214 source/ublexec.cc:212 -msgid "" -"You will be redirected to documentation website where documentation is\n" -"translated and supported by community." -msgstr "" -"Вы будете перенаправлены на сайт с документацией где страницы помощи\n" -"переводятся и поддерживаются сообществом." - -#: source/ublexec.h:30 source/ublexec.cc:175 source/ublexec.cc:174 -#: source/ublexec.cc:157 source/ublexec.cc:154 -msgid "https://wiki.ublinux.com" -msgstr "https://wiki.ublinux.ru" - -#: source/ublexec.cc:321 source/ublexec.cc:313 -msgid "" -"https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/" -msgstr "" -"https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/" +#: source/ubl-strings.h:42 +msgid "Priority" +msgstr "Приоритет" -msgid "pkexec" -msgstr "pkexec" +#: source/ubl-strings.h:43 +msgid "Change startup priority" +msgstr "Изменить приоритет запуска" -msgid "su" -msgstr "su" +#: source/ubl-strings.h:44 +msgid "Priority:" +msgstr "Приоритет:" -msgid "sudo" -msgstr "sudo" +#: source/ubl-strings.h:45 +msgid "Command line" +msgstr "Команда выполнения" -#: source/ublexec.cc:219 source/ublexec.cc:217 -msgid "ubl-settings-bootloader" -msgstr "" +#: source/ubl-strings.h:46 +msgid "Run" +msgstr "Запустить" -#: source/ublexec.h:29 source/ublexec.cc:157 source/ublexec.cc:160 -#: source/ublexec.cc:161 -#, fuzzy -msgid "ublexec" -msgstr "pkexec" +#: source/ubl-strings.h:47 +msgid "Edit" +msgstr "Редактировать" -#: source/ublexec.h:50 source/main.cc:60 source/main.cc:970 -msgid "ublexec version: " -msgstr "ublexec версия: " +#: source/ubl-strings.h:48 +msgid "User" +msgstr "Пользователь" -msgid "ОК" -msgstr "ОК" +#: source/ubl-utils.c:1022 +msgid "Applications" +msgstr "Обзор приложений" -#: source/ublexec.cc:193 -msgid "Сancel" -msgstr "Отмена" +#: source/ubl-utils.c:1023 +msgid "Accept" +msgstr "Принять" diff --git a/ublexec_terminals.csv b/ublexec_terminals.csv new file mode 100644 index 0000000..42ad3b6 --- /dev/null +++ b/ublexec_terminals.csv @@ -0,0 +1,7 @@ +XTerm (xterm emulator):/usr/bin/xterm:-hold:-e +XFCE (xfce4-terminal emulator):/usr/bin/xfce4-terminal:--hold:-x +Mate (mate-terminal emulator):/usr/bin/mate-terminal:--window-with-profile=HoldOpen:-e +Gnome (gnome-terminal emulator):/usr/bin/gnome-terminal:--window-with-profile=HoldOpen:-e +KDE (konsole emulator):/usr/bin/konsole:-hold:-e +Enlightenment (terminology emulator):/usr/bin/terminology:--hold:-e +LXDE (lxterminal emulator):/usr/bin/lxterminal::-e \ No newline at end of file