You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-manager/source/ubl-settings-manager.h

217 lines
7.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef UBL_SETTINGS_MANAGER
#define UBL_SETTINGS_MANAGER
#include <gtk/gtk.h>
#include <time.h>
#include <getopt.h>
#include <dlfcn.h>
#include <gtk/gtkx.h>
#include <stdbool.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <libintl.h>
#include <unistd.h>
#include <pthread.h>
#include<sys/utsname.h>
#include<sys/sysinfo.h>
#include <math.h>
#include <wctype.h>
#include <sys/stat.h>
#include <libublsettings.h>
#include <libublsettings-gtk3.h>
#include <libublsettingsui-gtk3.h>
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#include "ubl-strings.h"
#define UBLINUX_WIKI_COMMAND "xdg-open https://wiki.ublinux.ru/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-manager"
#define UBLINUX_WIKI_LINK " https://wiki.ublinux.ru/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-manager"
#define check_web2kit_command "ldconfig -p |grep webkit2"
#define glade_path "/com/ublinux/ui/ubl-settings-manager.glade"
#define glade_path_gnome_theme "/com/ublinux/ui/ubl-settings-manager-theme-gnome.glade"
#define glade_path_gnome_section "/com/ublinux/ui/ubl-settings-manager-theme-gnome-section.glade"
#define glade_path_main_theme "/com/ublinux/ui/ubl-settings-manager-theme-main.glade"
#define CssPath "/com/ublinux/css/ubl-settings-manager.css"
#define GlobalConfigPath "/etc/xdg/ubl-settings-manager/ubl-settings-manager.conf"
#define UserConfigPath "/.config/ubl-settings-manager/ubl-settings-manager.conf"
#define AppIconPath "com.ublinux.ubl-settings-manager"
#define AppBannerPath "/com/ublinux/images/ubl-settings-manager-banner.png"
#define DesktopPath "/usr/share/applications/"
#define IconPicturesPath "/usr/share/icons/hicolor/scalable/apps/"
#define LocalePath "/usr/share/locale"
#define LocaleName "ubl-settings-manager"
#define ubl_settings_infoPath "ubl-settings-info"
#define ubl_settings_infoPathLaunch "ubl-settings-info --socket-id="
typedef char* string;
__attribute__((unused)) static \
string version_application;
#define _(String) gettext(String)
typedef struct {
char *command;
int *exitcode;
} thread_output;
typedef struct IVGrapgicals{
char *sectionName;
char *categories;
GtkListStore *LV;
GtkWidget *Box;
GtkWidget *IV;
GtkWidget *label;
GtkWidget *sep;
GtkCellRendererPixbuf *iconRender;
} IVGraphicals;
typedef struct IconSection{
char *section;
char *categories;
} IconSection;
typedef struct {
template_config_fields;
int apps_icon_size;
dictionary *sections;
int labelDensity;
int lock_settings;
int double_click;
dictionary *SettingsSections;
int banner_hidden;
GHashTable *themes;
} config;
extern config main_config;
typedef struct {
GtkWidget *MainFrame;
GtkWidget *MainBox;
GtkWidget *ElemBox;
GtkWidget *DragButtonBox;
GtkWidget *DragUpButton;
GtkWidget *DragDownButton;
GtkWidget *NameBox;
GtkWidget *CategoriesBox;
GtkWidget *OptionBox;
GtkWidget *NameEntry;
GtkWidget *NameLabel;
GtkWidget *CategoriesEntry;
GtkWidget *CategoriesLabel;
GtkWidget *EditButtonBox;
GtkWidget *EditButtonAccept;
GtkWidget *EditButtonCancel;
GtkWidget *ButtonEdit;
GtkWidget *ButtonDelete;
GtkWidget *DeleditBox;
} SectionSettingSegment;
typedef struct theme_struct {
GtkWidget *MainBox;
GtkWidget *AppsTree;
GtkWidget *SocketBox;
GtkWidget *HideBox;
GtkWidget *Socket;
int (*list_update_func)(struct theme_struct*);
char *(*get_command_func)(struct theme_struct*);
void (*set_sections_func)(struct theme_struct*);
GtkTreeStore *AppsStore;
} theme_struct;
typedef struct gnome_theme_struct {
GtkWidget *MainBox;
GtkWidget *AppsTree;
GtkWidget *SocketBox;
GtkWidget *HideBox;
GtkWidget *Socket;
int (*list_update_func)(struct gnome_theme_struct*);
char *(*get_command_func)(struct gnome_theme_struct*);
void (*set_sections_func)(struct gnome_theme_struct*);
GtkWidget *GnomePaned;
GtkWidget *GnomeInfoLogoImage;
GtkCellRenderer *IconCell;
} gnome_theme_struct;
typedef struct main_theme_struct {
GtkWidget *MainBox;
GtkWidget *AppsIconView;
GtkWidget *SocketBox;
GtkWidget *HideBox;
GtkWidget *Socket;
int (*list_update_func)(struct main_theme_struct*);
char *(*get_command_func)(struct main_theme_struct*);
void (*set_sections_func)(struct main_theme_struct*);
GtkListStore *AppsList;
} main_theme_struct;
typedef struct {
GtkWidget *Window;
GtkWidget *StatusBox;
GtkWidget *TitleLabel;
GtkWidget *ThemeBox;
GtkWidget *SocketBox;
GtkWidget *SettingsButton;
GtkWidget *BannerImage;
GtkWidget *BannerArrow;
GtkWidget *BannerButton;
GtkWidget *BannerRevealer;
theme_struct *current_theme;
} main_window;
typedef struct {
char *name;
int categories_size;
config_str categories;
} app_section;
void on_plug_added(GtkSocket* self, main_window *builder);
void on_plug_removed(GtkSocket* self, main_window *widgets);
void on_Item_activated(GtkIconView* self, GtkTreePath* path, main_window *applist);
void on_gnome_Item_activated(GtkIconView* self, GtkTreePath* path, main_window *applist);
void on_item_selection_changed(GtkIconView *IV, main_window *widgets);
void on_ButtonOpenHelp_activated(GtkWidget *button, GtkBuilder *builder);
void on_backToSettingsButton_clicked(GtkWidget *button,main_window *sctb);
void on_CancelHelpButton_activated(GtkWidget *button,GtkBuilder *builder);
void on_ReadHelpButton_activated(GtkWidget *button, GtkBuilder *builder);
int on_settings_accept(GtkWidget *button, dictionary **widgetsDs);
void on_paned_move(GtkPaned* self, GtkScrollType* scroll_type, main_window *widgets);
int on_settingsOpen(GtkWidget *button, main_window *widgets);
int on_settings_icon_size_changed(GtkWidget* self, main_window *widgets);
int on_settings_cancel(GtkWidget *button, main_window *widgets);
int reload_list(IVGraphicals *section);
int hide_if_unfound(dictionary *widgetsDc);
GtkWidget *create_socket(main_window *builder);
int setup_config();
void update_double_clicks(dictionary *widgetsD);
void yon_icv_resize_item(dictionary *icdict, GtkWidget *paned);
int yon_set_sections(IconSection *section);
void yon_set_default_sections(dictionary *section);
dictionary *yon_section_new(dictionary *section, char *section_name, char *categories);
void yon_switch_theme(dictionary **dict, dictionary *newone);
void yon_segment_show(main_window *widgets, SectionSettingSegment *sgm);
SectionSettingSegment *yon_create_section_setting(char *name, char *categories);
void yon_segments_show(main_window *widgets);
void yon_segments_hide(main_window *widgets);
dictionary *yon_create_icon_section_list(dictionary *sections);
int yon_show_icon_views(dictionary *IVS,main_window *widgets);
void yon_icon_size_convert(int mode);
int launch(thread_output *thread);
float yon_time_average(dictionary *times);
void yon_time_reg_for_average(dictionary *listofregs, int size, time_t tm);
int yon_get_icon_size(int size);
void yon_theme_init();
theme_struct *yon_theme_update(main_window *widgets);
gnome_theme_struct *yon_gnome_theme_new();
main_theme_struct *yon_main_theme_new();
app_section *yon_app_section_new();
gnome_theme_struct *yon_gnome_theme_new();
#endif