diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-01-23 19:04:36 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-01-23 19:04:36 +0000 |
commit | 21e66f0c6f38d20dc4ac3968324fff0959113b14 (patch) | |
tree | e801135c51e407d67516e1969c1ef788af48292e /ui/preference_utils.c | |
parent | d59e9cf574976b1e9849f5c35be1fd2abdf8ed6d (diff) | |
download | wireshark-21e66f0c6f38d20dc4ac3968324fff0959113b14.tar.gz wireshark-21e66f0c6f38d20dc4ac3968324fff0959113b14.tar.bz2 wireshark-21e66f0c6f38d20dc4ac3968324fff0959113b14.zip |
Add column preferences.
svn path=/trunk/; revision=47231
Diffstat (limited to 'ui/preference_utils.c')
-rw-r--r-- | ui/preference_utils.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ui/preference_utils.c b/ui/preference_utils.c index 2896ac3d2c..29e403f5f8 100644 --- a/ui/preference_utils.c +++ b/ui/preference_utils.c @@ -28,6 +28,8 @@ #include <glib.h> +#include <epan/column_info.h> +#include <epan/column.h> #include <epan/filesystem.h> #include <epan/prefs.h> #include <epan/prefs-int.h> @@ -271,6 +273,61 @@ prefs_main_write(void) } } +void +column_prefs_add_custom(gint fmt, const gchar *title, const gchar *custom_field, gint custom_occurrence) +{ + GList *clp; + fmt_data *cfmt, *last_cfmt; + + cfmt = (fmt_data *) g_malloc(sizeof(fmt_data)); + /* + * Because a single underscore is interpreted as a signal that the next character + * is going to be marked as accelerator for this header (i.e. is going to be + * shown underlined), escape it be inserting a second consecutive underscore. + */ + cfmt->title = g_strdup(title); + cfmt->fmt = fmt; + cfmt->custom_field = g_strdup(custom_field); + cfmt->custom_occurrence = custom_occurrence; + cfmt->resolved = TRUE; + + if (custom_field) { + cfmt->visible = TRUE; + clp = g_list_last(prefs.col_list); + last_cfmt = (fmt_data *) clp->data; + if (last_cfmt->fmt == COL_INFO) { + /* Last column is COL_INFO, add custom column before this */ + prefs.col_list = g_list_insert(prefs.col_list, cfmt, g_list_length(prefs.col_list)-1); + } else { + prefs.col_list = g_list_append(prefs.col_list, cfmt); + } + } else { + cfmt->visible = FALSE; /* Will be set to TRUE in visible_toggled() when added to list */ + prefs.col_list = g_list_append(prefs.col_list, cfmt); + } +} + +void +column_prefs_remove_link(GList *col_link) +{ + fmt_data *cfmt; + + if (!col_link || !col_link->data) return; + + cfmt = (fmt_data *) col_link->data; + + g_free(cfmt->title); + g_free(cfmt->custom_field); + g_free(cfmt); + prefs.col_list = g_list_remove_link(prefs.col_list, col_link); +} + +void +column_prefs_remove_nth(gint col) +{ + column_prefs_remove_link(g_list_nth(prefs.col_list, col)); +} + /* * Editor modelines * |