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.
197 lines
6.1 KiB
197 lines
6.1 KiB
#ifndef UBL_UTILS
|
|
#define UBL_UTILS
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <pthread.h>
|
|
#include <string.h>
|
|
#include <dirent.h>
|
|
#include <locale.h>
|
|
#include <gtk/gtk.h>
|
|
#include <gtk/gtkx.h>
|
|
|
|
#define DesktopPath "/usr/share/applications/"
|
|
|
|
#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 yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data = command
|
|
|
|
#define yon_ubl_load_global_config(command, size_pointer) yon_config_load(command, size_pointer)
|
|
#define yon_ubl_load_local_config(command, size_pointer) yon_config_load(command, size_pointer)
|
|
#define yon_ubl_save_global_config(command) yon_config_save(command)
|
|
#define yon_ubl_save_local_config(command) yon_config_save(command)
|
|
|
|
typedef enum
|
|
{
|
|
#ifdef __GTK_H__
|
|
DICTIONARY_GTK_WIDGETS_TYPE,
|
|
#endif
|
|
DICTIONARY_OTHER_TYPE
|
|
|
|
} DICT_TYPE;
|
|
|
|
typedef struct
|
|
{
|
|
char *command;
|
|
int *exitcode;
|
|
} thread_output;
|
|
|
|
typedef struct dictionary
|
|
{
|
|
char *key;
|
|
void *data;
|
|
struct dictionary *next;
|
|
struct dictionary *prev;
|
|
struct dictionary *first;
|
|
DICT_TYPE data_type;
|
|
} dictionary;
|
|
|
|
typedef struct apps
|
|
{
|
|
char *Name;
|
|
int Type;
|
|
char *Categories;
|
|
char *Exec;
|
|
char *Icon;
|
|
int Pluggable;
|
|
int DualPluggable;
|
|
} apps;
|
|
|
|
typedef char** config_str;
|
|
// dictionary functions
|
|
|
|
|
|
#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data)
|
|
#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) if (!dict) dict=yon_dictionary_create_with_data(key,data); \
|
|
else dict=yon_dictionary_create_with_data_connected(dict,key,data);
|
|
|
|
dictionary *yon_dictionary_create_empty();
|
|
|
|
dictionary *yon_dictionary_create_conneced(dictionary *targetdict);
|
|
|
|
dictionary *yon_dictionary_get_last(dictionary *dict);
|
|
|
|
dictionary *yon_dictionary_switch_places(dictionary *dict, int aim);
|
|
|
|
void yon_dictionary_make_first(dictionary *dict);
|
|
|
|
void yon_dictionary_make_nth(dictionary *dict, int nth);
|
|
|
|
dictionary *yon_dictionary_create_with_data(char *key, void *data);
|
|
|
|
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data);
|
|
|
|
dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect);
|
|
|
|
dictionary *yon_dictionary_find(dictionary **dict, char *key);
|
|
|
|
dictionary *yon_dictionary_rip(dictionary *dict);
|
|
|
|
dictionary *yon_dictionary_get_nth(dictionary *dict, int place);
|
|
|
|
// char functions
|
|
|
|
char *yon_char_get_augumented(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_parse(char *parameters, int *size, char *divider);
|
|
|
|
char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete);
|
|
|
|
int yon_char_parsed_check_exist(char **parameters, int size, char *param);
|
|
|
|
|
|
|
|
// parsing functions
|
|
|
|
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);
|
|
|
|
config_str yon_config_load(char *command, int *str_len);
|
|
|
|
int yon_config_save(char *command);
|
|
|
|
char *yon_config_get_parameter(config_str parameters, int size, char *param);
|
|
|
|
char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider);
|
|
|
|
// terminal-using functions
|
|
|
|
int yon_launch_app(char *name);
|
|
|
|
int yon_launch_app_with_arguments(char *name, char *args);
|
|
|
|
int yon_launch(thread_output *thread);
|
|
|
|
// Gtk functions
|
|
|
|
#ifdef __GTK_H__
|
|
|
|
#define yon_gtk_builder_get_widget(obj, obj2) GTK_WIDGET(gtk_builder_get_object(obj, obj2))
|
|
|
|
typedef struct
|
|
{
|
|
GtkWidget *Icon;
|
|
GtkWidget *Label;
|
|
GtkWidget *IconView;
|
|
GtkListStore *List;
|
|
} expander_icon_view;
|
|
|
|
// GtkWidget *yon_gtk_app_chooser_apps_create();
|
|
|
|
// dictionary *yon_gtk_app_chooser_create();
|
|
|
|
// expander_icon_view yon_gtk_icon_view_expander_create(GtkWidget *pack, ...);
|
|
|
|
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);
|
|
|
|
GtkWidget *yon_gtk_socket_create_new_with_connect(GtkWidget *container, gpointer data);
|
|
|
|
int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment);
|
|
|
|
int yon_dictionary_gtk_pack_start_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding);
|
|
int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding);
|
|
|
|
// uninitialised
|
|
|
|
void yon_on_plug_added(GtkSocket *self, gpointer user_data);
|
|
void yon_on_plug_removed(GtkSocket *self, gpointer user_data);
|
|
|
|
|
|
typedef enum
|
|
{
|
|
BACKGROUND_IMAGE_SUCCESS_TYPE,
|
|
BACKGROUND_IMAGE_FAIL_TYPE
|
|
} BACKGROUND_IMAGE_TYPE;
|
|
#ifdef __cplusplus
|
|
#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path)
|
|
#define yon_ubl_status_box_render(statusbox, statusicon, statuslabel, iconname, statustext, backgroundclass) _yon_ubl_status_box_render(GTK_WIDGET(statusbox.gobj()), GTK_WIDGET(statusicon.gobj()), GTK_WIDGET(statuslabel.gobj()), (char *)iconname, (char *)statustext, backgroundclass)
|
|
#else
|
|
#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_status_box_render(statusbox, statusicon, statuslabel, statustext, backgroundclass) _yon_ubl_status_box_render(statusbox, statusicon, statuslabel, statustext, backgroundclass)
|
|
#endif
|
|
|
|
void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path);
|
|
void _yon_ubl_status_box_render(GtkWidget *StatusBox, GtkWidget *StatusIcon, GtkWidget *StatusLabel, char *StatusText, BACKGROUND_IMAGE_TYPE BackgroundClass);
|
|
#endif
|
|
#endif |