Example #1
0
gint
anjuta_save_prompt_get_items_count (AnjutaSavePrompt *save_prompt)
{
	GtkTreeModel *model;
	g_return_val_if_fail (ANJUTA_IS_SAVE_PROMPT (save_prompt), -1);
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (save_prompt->priv->treeview));
	return gtk_tree_model_iter_n_children (model, NULL);
}
Example #2
0
void
anjuta_shell_save_prompt (AnjutaShell *shell,
                          AnjutaSavePrompt *save_prompt,
                          GError **error)
{
    g_return_if_fail (ANJUTA_IS_SHELL (shell));
    g_return_if_fail (ANJUTA_IS_SAVE_PROMPT (save_prompt));
    g_signal_emit_by_name (shell, "save-prompt", save_prompt);
}
Example #3
0
void
anjuta_save_prompt_add_item (AnjutaSavePrompt *save_prompt,
							 const gchar *item_name,
							 const gchar *item_detail,
							 gpointer item,
							 AnjutaSavePromptSaveFunc item_save_func,
							 gpointer user_data)
{
	GtkTreeModel *model;
	GtkTreeIter iter;
	gchar *label;
	const gchar *markup;
	gint items_count;
	
	g_return_if_fail (ANJUTA_IS_SAVE_PROMPT (save_prompt));
	g_return_if_fail (item_name != NULL);
	g_return_if_fail (item_save_func != NULL);
	
	if (item_detail)
		label = g_strdup_printf ("<b>%s</b>\n%s", item_name, item_detail);
	else
		label = g_strdup (item_name);
	
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (save_prompt->priv->treeview));
	gtk_list_store_append (GTK_LIST_STORE (model), &iter);
	gtk_list_store_set (GTK_LIST_STORE (model),
						&iter,
						COL_SAVE_ENABLE, TRUE,
						COL_LABEL, label,
						COL_ITEM, item,
						COL_ITEM_SAVE_FUNC, item_save_func,
						COL_ITEM_SAVE_FUNC_DATA, user_data,
						-1);
	g_free (label);
	
	items_count = anjuta_save_prompt_get_items_count (save_prompt);
	
	if (items_count > 1)
	{
		label = g_strdup_printf( 
			ngettext ("<b>There is %d item with unsaved changes. Save changes before closing?</b>",
					  "<b>There are %d items with unsaved changes. Save changes before closing?</b>",
					  items_count), items_count);
	}
	else
	{
		label = g_strdup_printf("<b>%s</b>", 
			_("There is an item with unsaved changes. Save changes before closing?"));
	}

	markup = label;
	gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (save_prompt), markup);
	g_free (label);
}