Beispiel #1
0
/** 
 * To be called whenever a node was selected and should
 * replace the current itemlist.
 */
void
itemlist_load (nodePtr node) 
{
	itemSetPtr	itemSet;
	gint		folder_display_mode;
	gboolean	folder_display_hide_read;

	debug_enter ("itemlist_load");

	g_return_if_fail (NULL != node);
	
	debug1 (DEBUG_GUI, "loading item list with node \"%s\"", node_get_title (node));

	g_assert (!itemlist->priv->guids);
	g_assert (!itemlist->priv->filter);

	/* 1. Filter check. Don't continue if folder is selected and 
	   no folder viewing is configured. If folder viewing is enabled
	   set up a "unread items only" rule depending on the prefences. */

	/* for folders and other heirarchic nodes do filtering */
	if (IS_FOLDER (node) || node->children) {
		liferea_shell_update_allitems_actions (FALSE, 0 != node->unreadCount);

		conf_get_int_value (FOLDER_DISPLAY_MODE, &folder_display_mode);
		if (!folder_display_mode)
			return;
	
		conf_get_bool_value (FOLDER_DISPLAY_HIDE_READ, &folder_display_hide_read);
		if (folder_display_hide_read) {
			itemlist->priv->filter = g_new0(struct itemSet, 1);
			itemlist->priv->filter->anyMatch = TRUE;
			itemset_add_rule (itemlist->priv->filter, "unread", "", TRUE);
		}
	} else {
Beispiel #2
0
SearchDialog *
search_dialog_open (const gchar *query)
{
	SearchDialog	*sd;
	
	if (search)
		return search;
		
	sd = SEARCH_DIALOG (g_object_new (SEARCH_DIALOG_TYPE, NULL));
	sd->priv->dialog = liferea_dialog_new (NULL, "searchdialog");
	
	if (query)
		itemset_add_rule (sd->priv->vfolder->itemset, "exact", query, TRUE);

	sd->priv->re = rule_editor_new (sd->priv->vfolder);

	/* Note: the following code is somewhat duplicated from search_folder_dialog.c */
	
	/* Setting default rule match type */
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (sd->priv->dialog, "anyRuleRadioBtn2")), TRUE);
	
	/* Set up rule list vbox */
	gtk_container_add (GTK_CONTAINER (liferea_dialog_lookup (sd->priv->dialog, "ruleview_search_dialog")), rule_editor_get_widget (sd->priv->re));

	/* bind buttons */
	g_signal_connect (liferea_dialog_lookup (sd->priv->dialog, "addrulebtn2"), "clicked", G_CALLBACK (on_addrulebtn_clicked), sd);
	g_signal_connect (G_OBJECT (sd->priv->dialog), "response", G_CALLBACK (on_search_dialog_response), sd);
	
	gtk_widget_show_all (sd->priv->dialog);
	
	search = sd;
	return sd;
}
Beispiel #3
0
static void
on_simple_search_dialog_response (GtkDialog *dialog, gint responseId, gpointer user_data)
{
	SimpleSearchDialog	*ssd = (SimpleSearchDialog *)user_data;
	const gchar		*searchString;
	vfolderPtr		vfolder = ssd->priv->vfolder;

	searchString = 	gtk_entry_get_text (GTK_ENTRY (ssd->priv->query));
	
	if (1 == responseId) {	/* Search */
		search_clean_results (vfolder);
		
		/* Create new search... */
		ssd->priv->vfolder = vfolder = vfolder_new (node_new (vfolder_get_node_type ()));
		node_set_title (vfolder->node, searchString);
		itemset_add_rule (vfolder->itemset, "exact", searchString, TRUE);

		search_load_results (vfolder);
	}
	
	if (2 == responseId)	/* Advanced... */			
		search_dialog_open (searchString);

	/* Do not close the dialog when "just" searching. The user
	   should click "Close" to close the dialog to be able to
	   do subsequent searches... */	
	if (1 != responseId)
		g_object_unref (ssd);
}
Beispiel #4
0
static void
vfolder_import_rules (xmlNodePtr cur,
                      vfolderPtr vfolder)
{
	xmlChar		*matchType, *type, *ruleId, *value, *additive;
	
	matchType = xmlGetProp (cur, BAD_CAST"matchType");
	if (matchType) {
		/* currently we only OR or AND the rules,
		   "any" is the value for OR'ing, "all" for AND'ing */
		vfolder->itemset->anyMatch = (0 != xmlStrcmp (matchType, BAD_CAST"all"));
	} else {
		vfolder->itemset->anyMatch = TRUE;
	}
	xmlFree (matchType);

	/* process any children */
	cur = cur->xmlChildrenNode;
	while (cur) {
		if (!xmlStrcmp (cur->name, BAD_CAST"outline")) {
			type = xmlGetProp (cur, BAD_CAST"type");
			if (type && !xmlStrcmp (type, BAD_CAST"rule")) {

				ruleId = xmlGetProp (cur, BAD_CAST"rule");
				value = xmlGetProp (cur, BAD_CAST"value");
				additive = xmlGetProp (cur, BAD_CAST"additive");

				if (ruleId && value) {			
					debug2 (DEBUG_CACHE, "loading rule \"%s\" \"%s\"", ruleId, value);

					if (additive && !xmlStrcmp (additive, BAD_CAST"true"))
						itemset_add_rule (vfolder->itemset, ruleId, value, TRUE);
					else
						itemset_add_rule (vfolder->itemset, ruleId, value, FALSE);
				} else {
					g_warning ("ignoring invalid rule entry for vfolder \"%s\"...\n", node_get_title (vfolder->node));
				}
				
				xmlFree (ruleId);
				xmlFree (value);
				xmlFree (additive);
			}
			xmlFree (type);
		}
		cur = cur->next;
	}
}
Beispiel #5
0
void
rule_editor_save (RuleEditor *re, itemSetPtr itemset)
{
    GSList	*iter;

    /* delete all old rules */
    iter = itemset->rules;
    while (iter) {
        rule_free ((rulePtr)iter->data);
        iter = g_slist_next (iter);
    }
    g_slist_free (itemset->rules);
    itemset->rules = NULL;

    /* and add all rules from editor */
    iter = re->priv->newRules;
    while (iter) {
        rulePtr rule = (rulePtr)iter->data;
        itemset_add_rule (itemset, rule->ruleInfo->ruleId, rule->value, rule->additive);
        iter = g_slist_next (iter);
    }
}
Beispiel #6
0
static void
on_simple_search_dialog_response (GtkDialog *dialog, gint responseId, gpointer user_data)
{
	SimpleSearchDialog	*ssd = (SimpleSearchDialog *)user_data;
	const gchar		*searchString;

	searchString = 	gtk_entry_get_text (GTK_ENTRY (ssd->priv->query));
	
	if (1 == responseId) {	/* Search */
		/* Clean up old search result data and display... */
		if (ssd->priv->searchResult) {
			if (ssd->priv->searchResult == itemlist_get_displayed_node ())
				itemlist_unload (FALSE);
			
			node_free (ssd->priv->searchResult);
		}
		
		/* Create new search... */
		ssd->priv->searchResult = node_new (vfolder_get_node_type ());
		ssd->priv->vfolder = vfolder_new (ssd->priv->searchResult);
	
		node_set_title (ssd->priv->searchResult, searchString);
		itemset_add_rule (ssd->priv->vfolder->itemset, "exact", searchString, TRUE);
		vfolder_reset (ssd->priv->vfolder);

		search_load_results (ssd->priv->searchResult, searchString);
	}
	
	if (2 == responseId)	/* Advanced... */			
		search_dialog_open (searchString);

	/* Do not close the dialog when "just" searching. The user
	   should click "Close" to close the dialog to be able to
	   do subsequent searches... */	
	if (1 != responseId)
		g_object_unref (ssd);
}