Adding support for large text on details view title.
This commit is contained in:
parent
dbcd7afff0
commit
45089c5e92
@ -31,5 +31,7 @@ mg_util_xml_get_nodes_xpath_expression (MgUtilXML *self,
|
||||
int
|
||||
mg_util_xml_has_class (MgUtilXML *self,
|
||||
const char *class_attribute, const char *class_to_check);
|
||||
|
||||
char *
|
||||
mg_util_xml_get_title_text (MgUtilXML *self,
|
||||
const char *const text);
|
||||
G_END_DECLS
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <pango/pango.h>
|
||||
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml/xpath.h>
|
||||
|
||||
@ -20,6 +22,9 @@ mg_util_xml_class_init (MgUtilXMLClass *class) {
|
||||
static void
|
||||
mg_util_xml_init (MgUtilXML *self) {
|
||||
}
|
||||
static char *
|
||||
mg_util_xml_get_as_char_node (MgUtilXML *self,
|
||||
xmlNodePtr node, xmlDocPtr document);
|
||||
|
||||
MgUtilXML *
|
||||
mg_util_xml_new () {
|
||||
@ -140,3 +145,41 @@ mg_util_xml_get_nodes_xpath_expression (MgUtilXML *self,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
mg_util_xml_get_title_text (MgUtilXML *self,
|
||||
const char *const text) {
|
||||
xmlDocPtr document = xmlNewDoc ((xmlChar *) "1.0");
|
||||
xmlNodePtr root_node = xmlNewNode (NULL, (xmlChar *) "span");
|
||||
xmlNodePtr text_content = NULL;
|
||||
xmlDocSetRootElement (document, root_node);
|
||||
char *size_text = NULL;
|
||||
size_text = g_malloc (sizeof *size_text * 2000);
|
||||
|
||||
text_content = xmlNewText ((xmlChar *) text);
|
||||
xmlAddChild (root_node, text_content);
|
||||
snprintf (size_text, 2000, "%d", 40 * PANGO_SCALE);
|
||||
xmlNewProp (root_node, (xmlChar *) "size", (xmlChar *) size_text);
|
||||
|
||||
return mg_util_xml_get_as_char_node (self, root_node, document);
|
||||
}
|
||||
|
||||
static char *
|
||||
mg_util_xml_get_as_char_node (MgUtilXML *self,
|
||||
xmlNodePtr node, xmlDocPtr document) {
|
||||
xmlBufferPtr buffer = xmlBufferCreate ();
|
||||
const char *buffer_contents;
|
||||
char *return_value = NULL;
|
||||
size_t buffer_len;
|
||||
MgUtilString *string_util = NULL;
|
||||
xmlNodeDump (buffer, document, node, 0, 1);
|
||||
|
||||
buffer_contents = (char *) xmlBufferContent (buffer);
|
||||
buffer_len = strlen (buffer_contents);
|
||||
return_value = mg_util_string_alloc_string (string_util, buffer_len);
|
||||
mg_util_string_copy_substring (string_util, buffer_contents,
|
||||
return_value, buffer_len, 0, buffer_len);
|
||||
|
||||
xmlBufferFree (buffer);
|
||||
return return_value;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
#include <openmg/manga.h>
|
||||
|
||||
#include <openmg/util/xml.h>
|
||||
|
||||
#include <openmg/view/picture.h>
|
||||
#include <openmg/view/detail_manga.h>
|
||||
|
||||
@ -9,9 +11,16 @@ GtkBox *
|
||||
create_detail_view (MgManga *manga) {
|
||||
GtkBox *detail_view = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
|
||||
GtkBox *descriptive_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
|
||||
MgUtilXML *xml_util = mg_util_xml_new ();
|
||||
GtkWidget *manga_title = NULL;
|
||||
GtkPicture *manga_image = create_picture_from_url (
|
||||
mg_manga_get_image_url(manga), 200);
|
||||
char *title_text = mg_util_xml_get_title_text (
|
||||
xml_util, mg_manga_get_title (manga));
|
||||
manga_title = gtk_label_new (title_text);
|
||||
gtk_label_set_use_markup (GTK_LABEL (manga_title), 1);
|
||||
gtk_box_append (descriptive_box, GTK_WIDGET (manga_image));
|
||||
gtk_box_append (descriptive_box, manga_title);
|
||||
gtk_box_append (detail_view, GTK_WIDGET (descriptive_box));
|
||||
return detail_view;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user