|
|
#include <gtk/gtk.h>
|
|
|
#include <gtk/gtkx.h>
|
|
|
#include "ubl-settings-video-cm.h"
|
|
|
#ifdef WEBKIT_FOUND
|
|
|
#include <webkit2/webkit2.h>
|
|
|
#endif
|
|
|
#include <vte-2.91/vte/vte.h>
|
|
|
#include <locale.h>
|
|
|
#include <stdio.h>
|
|
|
#include <time.h>
|
|
|
#include <unistd.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <libintl.h>
|
|
|
#include <sys/types.h>
|
|
|
#include <fcntl.h>
|
|
|
#include <getopt.h>
|
|
|
#include <libintl.h>
|
|
|
#include "ubl-utils.h"
|
|
|
#include "ubl-settings-video-strings.h"
|
|
|
#ifndef UBL_SETINGS_VIDEO_H
|
|
|
#define UBL_SETINGS_VIDEO_H
|
|
|
|
|
|
#define UBLINUX_WIKI_LINK " https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-video"
|
|
|
|
|
|
#define icon_name "com.ublinux.ubl-settings-video"
|
|
|
|
|
|
#define banner_path "/usr/share/ubl-settings-video/images/ubl-settings-video-banner.png"
|
|
|
|
|
|
#define glade_path "/usr/share/ubl-settings-video/ui/ubl-settings-video.glade"
|
|
|
#define LocalePath "/usr/share/locale"
|
|
|
#define LocaleName "ubl-settings-video"
|
|
|
#define CssPath "/usr/share/ubl-settings-video/css/ubl-settings-video.css"
|
|
|
#define StatusLoadGlobalFailed _("Failed to load global configuration")
|
|
|
#define StatusLoadLocalFailed _("Failed to load local configuration")
|
|
|
|
|
|
#define StatusSaveGlobalFailed _("Saving to global configuration Succeeded")
|
|
|
#define StatusSaveLocalFailed _("Saving to local configuration Succeeded")
|
|
|
|
|
|
#define get_ports_command "xrandr |grep -E \"*connected\" |cut -d' ' -f1"
|
|
|
|
|
|
#define get_resolutions_command "xrandr |grep -noP \"\\d+x+\\d+\""
|
|
|
#define get_resolution_ports_command "xrandr |grep -nwP \"connected\" |grep -oE \"[0-9a-zA-Z:]{1,10} connected\" |grep -oE \"[0-9a-zA-Z:]{1,10} \""
|
|
|
|
|
|
#define get_proprietary_drivers_info_command "cut -d';' -f2- /usr/share/ubl-settings-video/csv/video-drivers.csv | grep -E \"-\""
|
|
|
|
|
|
#define get_resolutions_supportable_command "cut -d, -f1- /usr/share/ubl-settings-video/csv/resolutions.csv |sed 's/,/ /g'"
|
|
|
|
|
|
#define get_frequences_command "xrandr |grep -v -n \"[a-z][a-z]\" |sed 's/ * / /g' |cut -d' ' -f1,3-"
|
|
|
|
|
|
#define load_drivers_command "/usr/bin/ubconfig --default --source "
|
|
|
|
|
|
#define load_drivers_global_command "/usr/bin/ubconfig --default --source global get video FAILSAFENVIDIA FAILSAFEATI OPTIRUN PRIMUSRUN VGADRV_AUTO "
|
|
|
|
|
|
#define save_drivers_global_command "pkexec /usr/bin/ubconfig --target global --noexecute set video "
|
|
|
|
|
|
#define save_drivers_global_local_command "pkexec /usr/bin/ubconfig set video "
|
|
|
|
|
|
#define load_drivers_local_command "/usr/bin/ubconfig --default --source system get video FAILSAFENVIDIA FAILSAFEATI OPTIRUN PRIMUSRUN VGADRV_AUTO "
|
|
|
|
|
|
#define save_drivers_local_command "pkexec /usr/bin/ubconfig --target system set video "
|
|
|
|
|
|
#define remove_drivers_global_command "/usr/bin/ubconfig --target system remove video "
|
|
|
|
|
|
#define remove_drivers_local_command "/usr/bin/ubconfig --target system remove video "
|
|
|
|
|
|
#define install_proprietary_command "pkexec pacman --quiet --needed --noconfirm -Sy "
|
|
|
|
|
|
#define delete_proprietary_command "pkexec pacman -R --noconfirm "
|
|
|
|
|
|
#define get_info_proprietary_command "pamac-manager --details="
|
|
|
|
|
|
#define get_version_proprietary_command "grep \"VERSION_ID=\" /etc/os-release | cut -d= -f2"
|
|
|
|
|
|
#define get_proprietary_drivers_command "LC_ALL=C pacman -Ssy ubm-nvidia-.* |grep -oE \"[a-zA-Z-]{1,}-nvidia-[a-zA-Z0-9-]{1,}|installed\"|sed ':a;N;$!ba;s/\\ninstalled/ installed/g'"
|
|
|
#define get_proprietary_drivers_local_command "LC_ALL=C pacman -Qq |grep -E \"ubm-nvidia-\""
|
|
|
|
|
|
// #define get_proprietary_drivers_command "LC_ALL=C pacman -Ss ubm-nvidia-.* |grep -oE \"[a-zA-Z-]{1,}nvidia-[a-zA-Z0-9-]{1,}|installed\"|sed ':a;N;$!ba;s/\\ninstalled/ installed/g'"
|
|
|
|
|
|
#define get_adapter_info "lshw -c display -quiet |grep -oE \"vendor:[0-9a-zA-Z ]{1,}|description:[0-9a-zA-Z ]{1,}|product:[]0-9a-zA-Z [-]{1,}\"|sed 's/: /=/g';lspci | grep -E ' VGA | Display ' | cut -d\" \" -f 1 | xargs -i lspci -v -s {} |grep -oE \"Kernel[:a-zA-Z0-9: ]{1,}\"|sed 's/: /=/g'|sed 's/ /_/g'"
|
|
|
|
|
|
#define XORG_MONITOR(port) yon_char_get_augumented(" XORG_MONITOR[",yon_char_get_augumented(port,"] "))
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
char* command;
|
|
|
void *data;
|
|
|
} thread_input;
|
|
|
|
|
|
char *local;
|
|
|
|
|
|
typedef char *string;
|
|
|
|
|
|
string version_application = "2.1";
|
|
|
|
|
|
#define _(String) gettext(String)
|
|
|
|
|
|
typedef dictionary* monitor_config;
|
|
|
typedef dictionary* proprietary_config;
|
|
|
typedef dictionary* monitor_view;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
config_str line;
|
|
|
int size;
|
|
|
} resolution_supported;
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
int alwaysredirect;
|
|
|
config_str loaded_config;
|
|
|
int configsize;
|
|
|
int autoChooseDrivers;
|
|
|
monitor_view monitor_visuals;
|
|
|
monitor_config monitors;
|
|
|
proprietary_config proprietary;
|
|
|
dictionary *supported_resolutions;
|
|
|
GtkListStore *list;
|
|
|
GtkListStore *list2;
|
|
|
char *failsafenVidia;
|
|
|
char *failsafeATI;
|
|
|
int descreteOnly;
|
|
|
char *optirun;
|
|
|
char *primusrun;
|
|
|
int gapfix;
|
|
|
config_str ports;
|
|
|
int portssize;
|
|
|
config_str resolutions;
|
|
|
int resolutionssize;
|
|
|
render_data status_render;
|
|
|
|
|
|
int socket_id;
|
|
|
int save_socket_id;
|
|
|
int load_socket_id;
|
|
|
int lock_save_local;
|
|
|
int lock_save_global;
|
|
|
int lock_load_global;
|
|
|
int lock_help;
|
|
|
} config;
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
int main;
|
|
|
int enable;
|
|
|
int position;
|
|
|
char *position_port;
|
|
|
char *port;
|
|
|
char *resolution;
|
|
|
config_str resolutionCapabilities;
|
|
|
int frequency;
|
|
|
int rotation;
|
|
|
char *stringparameters;
|
|
|
int dpms;
|
|
|
int resolution_size;
|
|
|
int cvt;
|
|
|
int reduced;
|
|
|
int gtf;
|
|
|
int show_usupported;
|
|
|
} monitorconfig;
|
|
|
|
|
|
typedef struct {
|
|
|
GtkWidget *combo;
|
|
|
GtkWidget *tree;
|
|
|
} combo_tree;
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
dictionary *monitors;
|
|
|
dictionary *overlays;
|
|
|
GtkBuilder *builder;
|
|
|
GtkWidget *appsPackBox;
|
|
|
GtkWidget *appsPackWindow;
|
|
|
GtkWidget *extraOptirunChooseAppsButton;
|
|
|
GtkWidget *extraPrimusunChooseAppsButton;
|
|
|
GtkWidget *MainWindow;
|
|
|
GtkWidget *headBox;
|
|
|
GtkWidget *headInfoLabel;
|
|
|
GtkWidget *mainPlugBox;
|
|
|
GtkWidget *mainErrorBox;
|
|
|
GtkWidget *mainHeadOverlay;
|
|
|
GtkWidget *mainHeadBackgroundImage;
|
|
|
GtkWidget *mainDriverAutomaticallyChooseCheck;
|
|
|
GtkWidget *mainDriverProprietaryDriverLabel;
|
|
|
GtkWidget *mainDriverFailsafeNvidiaLabel;
|
|
|
GtkWidget *mainDriverFailsafeAMDLabel;
|
|
|
GtkWidget *mainDriverProprietaryDriverCombo;
|
|
|
GtkWidget *mainDriverProprietaryDriverButton;
|
|
|
GtkWidget *mainExtraFixGapCombo;
|
|
|
GtkWidget *mainDriverFailsafeNvidiaCombo;
|
|
|
GtkWidget *mainDriverFailsafeAMDCombo;
|
|
|
GtkWidget *mainDriverFrameLabel;
|
|
|
GtkWidget *monitorConfigurationMethodLabel;
|
|
|
GtkWidget *monitorConfigurationMethodCombo;
|
|
|
GtkWidget *mainMonitorVisualConfigurationBox;
|
|
|
GtkWidget *mainMonitorConfigurationBox;
|
|
|
GtkWidget *mainMonitorConfigurationFrameLabel;
|
|
|
GtkWidget *mainHybridGraphicsDiscreteLabel;
|
|
|
GtkWidget *mainHybridGraphicsDiscreteCheck;
|
|
|
GtkWidget *mainHybridGraphicsFrameLabel;
|
|
|
GtkWidget *mainExtraLaunchOptirunCheck;
|
|
|
GtkWidget *mainExtraLaunchPrismusunCheck;
|
|
|
GtkWidget *mainExtraFixGapLabel;
|
|
|
GtkWidget *mainExtraLaunchOptirunEntry;
|
|
|
GtkWidget *mainExtraLaunchPrismusunEntry;
|
|
|
GtkWidget *mainExtraLaunchThroughEntry;
|
|
|
GtkWidget *mainExtraFixGapLabelCombo;
|
|
|
GtkWidget *mainExtraLaunchThroughButton;
|
|
|
GtkWidget *mainExtraFrameLabel;
|
|
|
GtkWidget *mainHeaderTitleLabel;
|
|
|
GtkWidget *mainHeaderLoadButton;
|
|
|
GtkWidget *mainHeaderConfigLoadLabel;
|
|
|
GtkWidget *mainHeaderSaveConfigurationLabel;
|
|
|
GtkWidget *mainHeaderSaveButton;
|
|
|
GtkWidget *mainHeaderSettingsButton;
|
|
|
GtkWidget *mainHeaderLoadGlobalMenuItem;
|
|
|
GtkWidget *mainHeaderLoadLocalMenuItem;
|
|
|
GtkWidget *mainHeaderSaveGlobalLocalMenuItem;
|
|
|
GtkWidget *mainHeaderSaveGlobalMenuItem;
|
|
|
GtkWidget *mainHeaderSaveLocalMenuItem;
|
|
|
GtkWidget *mainHeaderSettingsDocumentationMenuItem;
|
|
|
GtkWidget *mainHeaderSettingsAboutMenuItem;
|
|
|
GtkWidget *mainStatusBox;
|
|
|
GtkWidget *mainStatusIcon;
|
|
|
GtkWidget *mainStatusLabel;
|
|
|
GtkWidget *templateMonitorConfigurationBox;
|
|
|
GtkWidget *templateMonitorConfigurationMonitorLabel;
|
|
|
GtkWidget *templateMonitorConfigurationResolutionLabel;
|
|
|
GtkWidget *templateMonitorConfigurationResolutionCombo;
|
|
|
GtkWidget *templateMonitorConfigurationFrequencyLabel;
|
|
|
GtkWidget *templateMonitorConfigurationFrequencyCombo;
|
|
|
GtkWidget *templateMonitorConfigurationRotationLabel;
|
|
|
GtkWidget *templateMonitorConfigurationRotationCombo;
|
|
|
GtkWidget *templateMonitorConfigurationMainRadio;
|
|
|
GtkWidget *templateMonitorConfigurationParameterLineCheck;
|
|
|
GtkWidget *templateMonitorConfigurationParameterLineEntry;
|
|
|
GtkWidget *templateMonitorConfigurationDoNotSwitchOffLabel;
|
|
|
GtkWidget *templateMonitorConfigurationDoNotSwitchOffCheck;
|
|
|
|
|
|
GtkWidget *proprietaryTreeView;
|
|
|
GtkWidget *proprietaryInfoButton;
|
|
|
GtkWidget *proprietaryDeleteButton;
|
|
|
GtkWidget *proprietaryInstallButton;
|
|
|
GtkTreeSelection *proprietaryTreeSelection;
|
|
|
GtkWidget *driversTreeView;
|
|
|
GtkWidget *driversInfoButton;
|
|
|
GtkWidget *driversDeleteButton;
|
|
|
GtkWidget *driversInstallButton;
|
|
|
GtkTreeSelection *driversTreeSelection;
|
|
|
|
|
|
GtkTreeViewColumn *proprietartInstalledColumn;
|
|
|
GtkTreeViewColumn *ProprietaryPackageColumn;
|
|
|
GtkTreeViewColumn *ProprietaryDriverColumn;
|
|
|
GtkTreeViewColumn *ProprietaryDescriptionColumn;
|
|
|
GtkTreeViewColumn *ProprietarySupportedColumn;
|
|
|
|
|
|
GtkTreeViewColumn *driverInstalledColumn;
|
|
|
GtkTreeViewColumn *driverPackageColumn;
|
|
|
GtkTreeViewColumn *driverDriverColumn;
|
|
|
GtkTreeViewColumn *driverDescriptionColumn;
|
|
|
GtkTreeViewColumn *driverSupportedColumn;
|
|
|
|
|
|
GtkWidget *DriverModulesTab;
|
|
|
GtkWidget *DriversTab;
|
|
|
GtkWidget *MainTabLabel;
|
|
|
GtkWidget *DriversTabLabel;
|
|
|
GtkWidget *InformationTabLabel;
|
|
|
GtkWidget *InformationFrameLabel;
|
|
|
GtkWidget *InformationOverlay;
|
|
|
GtkWidget *InformationCompanyLogoImage;
|
|
|
|
|
|
GtkWidget *TerminalOverlay;
|
|
|
GtkWidget *TerminalBox;
|
|
|
GtkWidget *TerminalRevealer;
|
|
|
GtkWidget *TerminalInfoLabel;
|
|
|
GtkWidget *TerminalMoreButton;
|
|
|
GtkWidget *TerminalScroll;
|
|
|
GtkWidget *TerminalMoreRevieler;
|
|
|
|
|
|
|
|
|
GtkWidget *PlugBox;
|
|
|
GtkWidget *PlugSaveBox;
|
|
|
GtkWidget *PlugLoadBox;
|
|
|
|
|
|
GtkWidget *MenusTab;
|
|
|
} widgets_dict;
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
GtkWidget *templateMonitorConfigurationWindow;
|
|
|
GtkWidget *mainMonitorConfigurationBox;
|
|
|
GtkWidget *templateMonitorConfigurationBox;
|
|
|
GtkWidget *templateMonitorConfigurationEnableCheck;
|
|
|
GtkWidget *templateMonitorConfigurationPortLabel;
|
|
|
GtkWidget *templateMonitorConfigurationPortCombo;
|
|
|
GtkWidget *templateMonitorConfigurationMainCheck;
|
|
|
GtkWidget *templateMonitorConfigurationResolutionLabel;
|
|
|
GtkWidget *templateMonitorConfigurationResolutionCombo;
|
|
|
GtkWidget *templateMonitorConfigurationShowUnsupportedCheck;
|
|
|
GtkWidget *templateMonitorConfigurationFrequencyLabel;
|
|
|
GtkWidget *templateMonitorConfigurationFrequencyCombo;
|
|
|
GtkWidget *templateMonitorConfigurationRotationLabel;
|
|
|
GtkWidget *templateMonitorConfigurationRotationCombo;
|
|
|
GtkWidget *templateMonitorConfigurationPositionLabel;
|
|
|
GtkWidget *templateMonitorConfigurationPositionPosCombo;
|
|
|
GtkWidget *templateMonitorConfigurationPositionPortCombo;
|
|
|
GtkWidget *templateMonitorConfigurationDoNotSwitchOffCheck;
|
|
|
GtkWidget *templateMonitorConfigurationModelineCVTCheck;
|
|
|
GtkWidget *templateMonitorConfigurationUseCVTReducedCheck;
|
|
|
GtkWidget *templateMonitorConfigurationModelineGTFCheck;
|
|
|
GtkWidget *templateMonitorConfigurationParameterLineCheck;
|
|
|
GtkWidget *templateMonitorConfigurationParameterLineEntry;
|
|
|
GtkWidget *templateMonitorConfigurationCancelButton;
|
|
|
GtkWidget *templateMonitorConfigurationSaveButton;
|
|
|
|
|
|
dictionary *config;
|
|
|
} monitor_edit_window;
|
|
|
|
|
|
typedef struct {
|
|
|
GtkWidget *templateMonitorscreenOverlay;
|
|
|
GtkWidget *templateMonitorImage;
|
|
|
GtkWidget *templateMonitorInfoBox;
|
|
|
GtkWidget *templateMonitorInfoNameLabel;
|
|
|
GtkWidget *templateMonitorInfoResolutionLabel;
|
|
|
GtkWidget *templateMonitorDeleteButton;
|
|
|
GtkWidget *templateMonitorSwitchButton;
|
|
|
GtkWidget *templateMonitorInfoConfigureButton;
|
|
|
GtkWidget *templateMonitorInfoAddButton;
|
|
|
monitor_config config;
|
|
|
} monitor_window;
|
|
|
|
|
|
typedef struct
|
|
|
{
|
|
|
GtkWidget *window;
|
|
|
|
|
|
GtkWidget *propriearyTreeView;
|
|
|
GtkTreeViewColumn *ProprietaryDriverColumn;
|
|
|
GtkTreeViewColumn *ProprietaryDescriptionColumn;
|
|
|
GtkListStore *list;
|
|
|
|
|
|
GtkWidget *ProprietaryCloseButton;
|
|
|
GtkWidget *ProprietaryAcceptButton;
|
|
|
} driver_window;
|
|
|
|
|
|
|
|
|
// void on_closed_configuration(GtkWidget *self, MonitorSettings *monitors);
|
|
|
// void on_save_configuration(GtkWidget self, MonitorSettings *monitors);
|
|
|
void yon_parse_monitor();
|
|
|
void on_config_fill_interface(widgets_dict *widgets);
|
|
|
void yon_update_config(widgets_dict *widgets);
|
|
|
void on_configuration_save_global(GtkWidget *self, widgets_dict *widgets);
|
|
|
void on_configuration_save__local_global(GtkWidget *self, widgets_dict *widgets);
|
|
|
void on_configuration_save__local(GtkWidget *self, widgets_dict *widgets);
|
|
|
void yon_config_monitor_string_parse(char *parameters, int *size);
|
|
|
char *yon_char_parsed_get_resolution(config_str parsed_string, int size);
|
|
|
void yon_monitor_set_resolutions();
|
|
|
monitor_config yon_monitor_config_new(char *port);
|
|
|
void yon_monitor_config_update(monitorconfig* monitor, char *port, char *config_string);
|
|
|
void yon_monitor_view_new(monitor_config monitor);
|
|
|
void on_configuration_save_global_local(GtkWidget *self, widgets_dict *widgets);
|
|
|
// void on_confugure_monitor_settings(GtkWidget *self, MonitorSettings *settings);
|
|
|
void yon_monitor_view_draw_all(GtkWidget *cnt);
|
|
|
void on_monitor_configure(GtkWidget *self,monitor_window *window);
|
|
|
void on_monitor_add(GtkWidget *self,monitor_window *window);
|
|
|
void on_monitor_switch(GtkWidget *self,monitor_window *window);
|
|
|
void on_monitor_delete(GtkWidget *self,monitor_view windowd);
|
|
|
void yon_monitor_view_update();
|
|
|
void yon_monitor_window_update(monitor_edit_window *window);
|
|
|
char *yon_monitor_make_string(monitorconfig* config);
|
|
|
void yon_launch_with_output(char *command);
|
|
|
dictionary *yon_proprieary_get();
|
|
|
void yon_gtk_list_store_fill_with_proprietaries(GtkListStore *list);
|
|
|
void yon_setup_config(char *configcommand);
|
|
|
void yon_monitor_view_setup(GtkWidget *container);
|
|
|
#endif |