diff options
author | Ahmed Sarfraaz <sarfraaz@src.gnome.org> | 2005-07-07 19:35:32 +0800 |
---|---|---|
committer | Ahmed Sarfraaz <sarfraaz@src.gnome.org> | 2005-07-07 19:35:32 +0800 |
commit | e09fbe62d6fcc6ea85caae58b5023dfaf6bd80f3 (patch) | |
tree | 652462cb86e6bca6edbaff7dada490cb0a37e68b /plugins | |
parent | 9d190a6f2cd1c9072e4c1d43018e4a584947460e (diff) | |
download | gsoc2013-evolution-e09fbe62d6fcc6ea85caae58b5023dfaf6bd80f3.tar.gz gsoc2013-evolution-e09fbe62d6fcc6ea85caae58b5023dfaf6bd80f3.tar.zst gsoc2013-evolution-e09fbe62d6fcc6ea85caae58b5023dfaf6bd80f3.zip |
Adding the new files
svn path=/trunk/; revision=29669
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/exchange-operations/exchange-folder-size-display.c | 122 | ||||
-rw-r--r-- | plugins/exchange-operations/exchange-folder-size-display.h | 21 |
2 files changed, 143 insertions, 0 deletions
diff --git a/plugins/exchange-operations/exchange-folder-size-display.c b/plugins/exchange-operations/exchange-folder-size-display.c new file mode 100644 index 0000000000..1204afb28f --- /dev/null +++ b/plugins/exchange-operations/exchange-folder-size-display.c @@ -0,0 +1,122 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* Copyright (C) 2002-2004 Novell, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* ExchangeFolderSize: Display the folder tree with the folder sizes */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> + +#include <e-util/e-dialog-utils.h> +#include <glade/glade-xml.h> +#include <gtk/gtkbox.h> +#include <gtk/gtkcellrenderertext.h> +#include <gtk/gtkmessagedialog.h> +#include <gtk/gtktreeselection.h> +#include <gtk/gtktreeview.h> + +enum { + COLUMN_NAME, + COLUMN_SIZE, + NUM_COLUMNS +}; + + +static void +format_size_func (GtkTreeViewColumn *col, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer user_data) +{ + GtkCellRendererText *cell = (GtkCellRendererText *)renderer; + gdouble folder_size; + char * new_text; + + gtk_tree_model_get(model, iter, COLUMN_SIZE, &folder_size, -1); + + if (folder_size) + new_text = g_strdup_printf ("%.2f", folder_size); + else + new_text = g_strdup ("0"); + + g_object_set (cell, "text", new_text, NULL); + g_free (new_text); +} + +static void +parent_destroyed (gpointer dialog, GObject *ex_parent) +{ + gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL); +} + +void +exchange_folder_size_display (GtkListStore *model, GtkWidget *parent) +{ + GtkTreeViewColumn *column; + GtkTreeSortable *sortable; + GtkCellRenderer *cell; + GHashTable *folder_size_table; + GladeXML *xml; + GtkWidget *dialog, *table; + GList *l; + char *col_name; + int response; + + printf ("exchange_folder_size_display called\n"); + g_return_if_fail (GTK_IS_WIDGET (parent)); + + xml = glade_xml_new (CONNECTOR_GLADEDIR "/exchange-folder-tree.glade", NULL, NULL); + g_return_if_fail (xml != NULL); + dialog = glade_xml_get_widget (xml, "folder_tree"); + table = glade_xml_get_widget (xml, "folder_treeview"); + + e_dialog_set_transient_for (GTK_WINDOW (dialog), parent); + /* fsize->parent = parent; */ + g_object_weak_ref (G_OBJECT (parent), parent_destroyed, dialog); + + /* Set up the table */ + sortable = GTK_TREE_SORTABLE (model); + gtk_tree_sortable_set_sort_column_id (sortable, COLUMN_SIZE, GTK_SORT_DESCENDING); + + column = gtk_tree_view_column_new_with_attributes ( + ("Folder Name"), gtk_cell_renderer_text_new (), "text", COLUMN_NAME, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (table), + column); + + col_name = g_strdup_printf ("%s (KB)", ("Folder Size")); + column = gtk_tree_view_column_new_with_attributes ( + col_name, gtk_cell_renderer_text_new (), "text", COLUMN_SIZE, NULL); + g_free (col_name); + + l = gtk_tree_view_column_get_cell_renderers (column); + cell = (GtkCellRenderer *)l->data; + gtk_tree_view_column_set_cell_data_func (column, cell, format_size_func, NULL, NULL ); + g_list_free (l); + + gtk_tree_view_append_column (GTK_TREE_VIEW (table), + column); + gtk_tree_view_set_model (GTK_TREE_VIEW (table), + GTK_TREE_MODEL (model)); + response = gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + g_object_unref (xml); +} diff --git a/plugins/exchange-operations/exchange-folder-size-display.h b/plugins/exchange-operations/exchange-folder-size-display.h new file mode 100644 index 0000000000..2f09094062 --- /dev/null +++ b/plugins/exchange-operations/exchange-folder-size-display.h @@ -0,0 +1,21 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* Copyright (C) 2002-2004 Novell, Inc. */ + +#ifndef __EXCHANGE_FOLDER_SIZE_DISPLAY_H__ +#define __EXCHANGE_FOLDER_SIZE_DISPLAY_H__ + +#include <gtk/gtkwidget.h> +#include <gtk/gtkliststore.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +void exchange_folder_size_display (GtkListStore *model, GtkWidget *parent); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EXCHANGE_FOLDER_SIZE_DISPLAY_H__ */ |