...
 
Commits (2)
......@@ -38,7 +38,6 @@ struct Courses {
struct Course {
gchar* name;
gchar* url;
guint id;
gboolean enabled;
};
......
......@@ -30,7 +30,6 @@ struct _GuiCourse
gint linear_growth_width;
GtkBox *box_week;
GtkLabel *title;
GtkLinkButton *url;
//GtkLabel *description; // subtitle? reason? abstract? motivate?
guint course_id;
gboolean content_obtained;
......@@ -38,7 +37,7 @@ struct _GuiCourse
};
enum {
PROP_0, PROP_COURSE_NAME, PROP_COURSE_URL, PROP_COURSE_ID, N_COURSE_PROPERTIES
PROP_0, PROP_COURSE_NAME, PROP_COURSE_ID, N_COURSE_PROPERTIES
};
GParamSpec *gui_course_properties[N_COURSE_PROPERTIES] = { NULL, };
......@@ -52,7 +51,6 @@ gui_course_new (struct Course course_info)
{
return g_object_new (HDY_TYPE_GUI_COURSE,
"course_name", course_info.name,
"course_url", course_info.url,
"course_id", course_info.id,
NULL);
}
......@@ -106,10 +104,6 @@ gui_course_set_property (GObject *object,
case PROP_COURSE_NAME:
gtk_label_set_label (self->title, g_value_get_string (value));
break;
case PROP_COURSE_URL:
gtk_button_set_label (GTK_BUTTON (self->url), g_value_get_string (value));
gtk_link_button_set_uri (self->url, g_value_get_string (value));
break;
case PROP_COURSE_ID:
self->course_id = g_value_get_uint (value);
moodle_provider_get_course_content_async (course_content_obtained_cb, self->course_id, object);
......@@ -133,12 +127,6 @@ gui_course_class_init (GuiCourseClass *class)
NULL,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY);
gui_course_properties[PROP_COURSE_URL] =
g_param_spec_string ("course_url", "url",
"The url of the course (like https://moodle.…/course/view.php?id=12345)",
NULL,
G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY);
gui_course_properties[PROP_COURSE_ID] =
g_param_spec_uint ("course_id", "id",
"The id of the course (like 12345)",
......@@ -153,7 +141,6 @@ gui_course_class_init (GuiCourseClass *class)
gtk_widget_class_set_template_from_resource (widget_class, "/ch/gnugen/Moody/ui/gui-course.ui");
gtk_widget_class_bind_template_child (widget_class, GuiCourse, title);
gtk_widget_class_bind_template_child (widget_class, GuiCourse, url);
gtk_widget_class_bind_template_child (widget_class, GuiCourse, box_week);
//gtk_widget_class_bind_template_child (widget_class, GuiCourse, description);
}
......
......@@ -49,8 +49,7 @@ G_DEFINE_TYPE (GuiResource, gui_resource, HDY_TYPE_ACTION_ROW)
GuiResource *
gui_resource_new (struct Resource file_info)
{
// if both or none are true, there is a problem
g_assert ((file_info.filename==NULL) ^ (file_info.type==RESOURCE_FOLDERFILE));
g_assert_nonnull (file_info.name);
return g_object_new (HDY_TYPE_GUI_RESOURCE,
"resource_type", file_info.type,
"resource_name", file_info.name,
......
......@@ -131,6 +131,10 @@ moodle_parse_folder_content (const gchar *html, gsize html_size, const gchar *mo
if (node->child && node->child->next && node->child->next->child) {
name = g_strdup (myhtml_node_text(node->child->next->child, NULL));
}
if (!name) {
g_warning ("Could not find the name of a file from a folder\n");
name = filename;
}
resources[count] = (struct Resource) {type, id, name, href, filename};
count++;
}
......@@ -198,15 +202,12 @@ moodle_parse_course_list (const gchar *html, gsize html_size, const gchar *filen
if (string && size) {
// nice link, we add it!
courses[count].url = g_strndup (string, size);
sscanf(string, EPFL_COURSE_LINK"%u", &(courses[count].id));
string = myhtml_node_text (myhtml_node_child (hrefs->list[i]), &size);
if (G_UNLIKELY (!string || !size)) {
g_print ("failed to get course name\n");
free (courses[count].url);
continue;
}
courses[count].name = g_strndup (string, size);
......@@ -234,8 +235,7 @@ moodle_extract_week (gchar *week_name, myhtml_tree_t *tree, myhtml_tree_node_t *
resources = malloc (sizeof (struct Resource) * 1000);
for (li = element->child; li; li = li->next) {
gchar *name;
gchar *textname;
gchar *name, *textname, *filename;
enum resource_type type;
guint id;
myhtml_collection_t *hrefs = myhtml_get_nodes_by_tag_id_in_scope (tree, NULL,
......@@ -249,12 +249,12 @@ moodle_extract_week (gchar *week_name, myhtml_tree_t *tree, myhtml_tree_node_t *
}
myhtml_tree_node_t *node = hrefs->list[0];
name = textname = NULL;
name = textname = filename = NULL;
id = 0;
for (myhtml_tree_attr_t *attr = myhtml_node_attribute_first (node); attr; attr = attr->next) {
if (strcmp (myhtml_attribute_key (attr, NULL), "href") == 0) {
const char *href = myhtml_attribute_value (attr, NULL);
type = read_link (href, &id, NULL);
type = read_link (href, &id, &filename);
name = g_strdup (/*g_path_get_basename (*/href/*)*/);
if (node->child && node->child->next && node->child->next->child) {
textname = g_strdup (myhtml_node_text(node->child->next->child, NULL));
......@@ -265,7 +265,7 @@ moodle_extract_week (gchar *week_name, myhtml_tree_t *tree, myhtml_tree_node_t *
if (id && textname && name) {
assert(resource_count<1000); // there should be no more than 1000 files a week, right ? right ??
resources[resource_count] = (struct Resource) {type, id, textname, name, NULL};
resources[resource_count] = (struct Resource) {type, id, textname, name, filename};
resource_count++;
} else {
g_print ("a li doesn't have any link\n");
......
......@@ -71,20 +71,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="url">
<style><class name="url"/></style>
<property name="visible">False</property>
<property name="opacity">0.4</property>
<property name="label" translatable="no">https://…</property>
<!--<property name="margin_top">3</property>-->
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<!--<child>
<object class="GtkLabel" id="description">
<style><class name="description"/></style>
......@@ -100,7 +86,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>-->
</object>
......@@ -135,3 +121,4 @@