Fixed package info output

pull/207/head
parent bff1147a40
commit 2494cfee41

@ -22,6 +22,7 @@
<file>ubinstall-gtk-layouts.glade</file> <file>ubinstall-gtk-layouts.glade</file>
<file>ubinstall-gtk-keyboard-layouts.glade</file> <file>ubinstall-gtk-keyboard-layouts.glade</file>
<file>ubinstall-gtk-slider.glade</file> <file>ubinstall-gtk-slider.glade</file>
<file>ubinstall-gtk-package-info.glade</file>
</gresource> </gresource>
<gresource prefix="/com/ublinux/css"> <gresource prefix="/com/ublinux/css">
<file>ubinstall-gtk.css</file> <file>ubinstall-gtk.css</file>

@ -62,6 +62,7 @@ set(DEPENDFILES
../ubinstall-gtk-layouts.glade ../ubinstall-gtk-layouts.glade
../ubinstall-gtk-keyboard-layouts.glade ../ubinstall-gtk-keyboard-layouts.glade
../ubinstall-gtk-slider.glade ../ubinstall-gtk-slider.glade
../ubinstall-gtk-package-info.glade
../gresource.xml ../gresource.xml
../ubinstall-gtk.css ../ubinstall-gtk.css
../modules.csv ../modules.csv

@ -240,13 +240,41 @@ void on_kernel_addon_install_enabled(GtkWidget *, kernel_addon_row *row){
} }
} }
void yon_gtk_label_set_font(GtkLabel *label);
void yon_gtk_label_set_font(GtkLabel *label){
g_return_if_fail(GTK_IS_LABEL(label));
PangoAttrList *attributes = pango_attr_list_new();
PangoFontDescription *font_descr = pango_font_description_new();
pango_font_description_set_family(font_descr,"Source Code Pro 10");
PangoAttribute *font_attr = pango_attr_font_desc_new(font_descr);
pango_attr_list_insert(attributes,font_attr);
gtk_label_set_attributes(GTK_LABEL(label),attributes);
}
typedef struct {
GtkWidget *MainBox;
GtkWidget *InfoTree;
GtkListStore *InfoList;
} info_element;
info_element *yon_package_info_element_new();
info_element *yon_package_info_element_new(){
info_element *element = malloc(sizeof(info_element));
memset(element,0,sizeof(info_element));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_package_info);
element->MainBox = yon_gtk_builder_get_widget(builder,"MainBox");
element->InfoTree = yon_gtk_builder_get_widget(builder,"InfoTree");
element->InfoList = GTK_LIST_STORE(gtk_builder_get_object(builder,"InfoList"));
return element;
}
void on_kernel_addon_info(GtkLabel *self){ void on_kernel_addon_info(GtkLabel *self){
yon_window *window = yon_window_new(); yon_window *window = yon_window_new();
yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,PACKAGE_INFO_LABEL,icon_path,"info-label"); yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,PACKAGE_INFO_LABEL,icon_path,"info-label");
char *package=NULL; char *package=NULL;
package = yon_char_new(gtk_label_get_text(self)); package = yon_char_new(gtk_label_get_text(self));
// int size; int size;
if (strstr(package,",")){ if (strstr(package,",")){
@ -256,35 +284,44 @@ void on_kernel_addon_info(GtkLabel *self){
} }
GtkWidget *label = NULL; GtkWidget *label = NULL;
{ // {
yon_packages_info *info = yon_packages_get_info_struct(YON_PACKAGES_ALL,package); // yon_packages_info *info = yon_packages_get_info_struct(YON_PACKAGES_ALL,package);
char *info_string = yon_packages_get_info_string(info); // char *info_string = yon_packages_get_info_string(info);
if (!yon_char_is_empty(info_string)){ // if (!yon_char_is_empty(info_string)){
label = gtk_label_new(NULL); // label = gtk_label_new(NULL);
char *temp = yon_char_replace(info_string,"@",""); // yon_gtk_label_set_font(GTK_LABEL(label));
gtk_label_set_markup(GTK_LABEL(label),temp); // char *temp = info_string;
gtk_widget_show(label); // gtk_label_set_markup(GTK_LABEL(label),temp);
gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0);
} else {
label = gtk_label_new(PACKAGE_NOT_FOUND_LABEL);
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0);
}
}
// config_str info = yon_config_load(get_package_info_command(package),&size);
// if (size!=-1){
// char *final_text = yon_char_parsed_to_string(info,size,"");
// label = gtk_label_new(final_text);
// gtk_widget_show(label); // gtk_widget_show(label);
// gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0); // gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0);
// free(final_text);
// } else { // } else {
// label = gtk_label_new(PACKAGE_NOT_FOUND_LABEL); // label = gtk_label_new(PACKAGE_NOT_FOUND_LABEL);
// yon_gtk_label_set_font(GTK_LABEL(label));
// gtk_widget_show(label); // gtk_widget_show(label);
// gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0); // gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0);
// } // }
// }
config_str info = yon_config_load(get_package_info_command(package),&size);
if (size!=-1){
info_element *element = yon_package_info_element_new();
gtk_box_pack_start(GTK_BOX(window->MainBox),element->MainBox,1,1,0);
for (int i=0;i<size;i++){
yon_char_remove_last_symbol(info[i],'\n');
GtkTreeIter iter;
int parsed_size;
config_str parsed = yon_char_parse(info[i],&parsed_size,":");
gtk_list_store_append(element->InfoList,&iter);
gtk_list_store_set(element->InfoList,&iter,0,parsed[0],1,parsed[1],-1);
}
} else {
label = gtk_label_new(PACKAGE_NOT_FOUND_LABEL);
yon_gtk_label_set_font(GTK_LABEL(label));
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(window->MainBox),label,0,0,0);
gtk_label_set_xalign(GTK_LABEL(label),0); gtk_label_set_xalign(GTK_LABEL(label),0);
}
gtk_widget_show(window->Window); gtk_widget_show(window->Window);
} }

@ -39,6 +39,7 @@
#define glade_locales_path "/com/ublinux/ui/ubinstall-gtk-layouts.glade" #define glade_locales_path "/com/ublinux/ui/ubinstall-gtk-layouts.glade"
#define glade_layouts_path "/com/ublinux/ui/ubinstall-gtk-keyboard-layouts.glade" #define glade_layouts_path "/com/ublinux/ui/ubinstall-gtk-keyboard-layouts.glade"
#define glade_path_slider "/com/ublinux/ui/ubinstall-gtk-slider.glade" #define glade_path_slider "/com/ublinux/ui/ubinstall-gtk-slider.glade"
#define glade_path_package_info "/com/ublinux/ui/ubinstall-gtk-package-info.glade"
#define CssPath "/com/ublinux/css/ubinstall-gtk.css" #define CssPath "/com/ublinux/css/ubinstall-gtk.css"
#define config_path yon_char_unite(yon_ubl_user_get_home_directory(), "/.config/", LocaleName, "/", LocaleName, ".conf", NULL) #define config_path yon_char_unite(yon_ubl_user_get_home_directory(), "/.config/", LocaleName, "/", LocaleName, ".conf", NULL)
@ -298,7 +299,7 @@ layout && /description:/ {\
#define languages_command "while IFS= read -ru3 SELECT_LOCALE; do SELECT_LOCALE=\"${SELECT_LOCALE% *}\"; [[ $(< /usr/share/i18n/locales/${SELECT_LOCALE%.*}) =~ (\"language\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"territory\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"country_name\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"lang_name\"[[:blank:]]*\\\"([^\\\"]*)\\\")|(\"language\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"territory\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"lang_name\"[[:blank:]]*\\\"([^\\\"]*)\\\")|(\"language\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"territory\"[[:blank:]]*\\\"([^\\\"]*)\\\") ]] && echo \"${SELECT_LOCALE}|${BASH_REMATCH[2]}${BASH_REMATCH[7]}${BASH_REMATCH[11]}${BASH_REMATCH[5]:+ (${BASH_REMATCH[5]})}${BASH_REMATCH[9]:+ (${BASH_REMATCH[9]})}|${BASH_REMATCH[3]}${BASH_REMATCH[8]}${BASH_REMATCH[12]}${BASH_REMATCH[4]:+ (${BASH_REMATCH[4]})}\" || echo \"${SELECT_LOCALE}\"; done 3< \"/usr/share/i18n/SUPPORTED\"" #define languages_command "while IFS= read -ru3 SELECT_LOCALE; do SELECT_LOCALE=\"${SELECT_LOCALE% *}\"; [[ $(< /usr/share/i18n/locales/${SELECT_LOCALE%.*}) =~ (\"language\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"territory\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"country_name\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"lang_name\"[[:blank:]]*\\\"([^\\\"]*)\\\")|(\"language\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"territory\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"lang_name\"[[:blank:]]*\\\"([^\\\"]*)\\\")|(\"language\"[[:blank:]]*\\\"([^\\\"]*)\\\".*\"territory\"[[:blank:]]*\\\"([^\\\"]*)\\\") ]] && echo \"${SELECT_LOCALE}|${BASH_REMATCH[2]}${BASH_REMATCH[7]}${BASH_REMATCH[11]}${BASH_REMATCH[5]:+ (${BASH_REMATCH[5]})}${BASH_REMATCH[9]:+ (${BASH_REMATCH[9]})}|${BASH_REMATCH[3]}${BASH_REMATCH[8]}${BASH_REMATCH[12]}${BASH_REMATCH[4]:+ (${BASH_REMATCH[4]})}\" || echo \"${SELECT_LOCALE}\"; done 3< \"/usr/share/i18n/SUPPORTED\""
#define get_package_info_command(target) yon_char_append("pacman -Si ", target) #define get_package_info_command(target) yon_char_unite("pacman -Si ", target,"| sed 's/ */ /g'",NULL)
#define layouts_command "sed -En '/^! layout$/,/^ *$/!d;s/[[:blank:]]+([^ ]+)[[:blank:]]+(.*)/\\1|\\2/p' /usr/share/X11/xkb/rules/evdev.lst" #define layouts_command "sed -En '/^! layout$/,/^ *$/!d;s/[[:blank:]]+([^ ]+)[[:blank:]]+(.*)/\\1|\\2/p' /usr/share/X11/xkb/rules/evdev.lst"
#define layouts_variant_command "sed -En '/^! variant$/,/^ *$/!d;s/[[:blank:]]+([^ ]+)[[:blank:]]+([^ :]+):[[:blank:]]+(.*)/\\2|\\1|\\3/p' /usr/share/X11/xkb/rules/evdev.lst" #define layouts_variant_command "sed -En '/^! variant$/,/^ *$/!d;s/[[:blank:]]+([^ ]+)[[:blank:]]+([^ :]+):[[:blank:]]+(.*)/\\2|\\1|\\3/p' /usr/share/X11/xkb/rules/evdev.lst"

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface domain="ubinstall-gtk">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubinstall-gtk.css -->
<object class="GtkListStore" id="InfoList">
<columns>
<!-- column-name Name -->
<column type="gchararray"/>
<!-- column-name Value -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkBox" id="MainBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="InfoTree">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTreeView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="model">InfoList</property>
<property name="headers-visible">False</property>
<property name="enable-search">False</property>
<property name="enable-grid-lines">vertical</property>
<child internal-child="selection">
<object class="GtkTreeSelection">
<property name="mode">none</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>
Loading…
Cancel
Save