diff options
author | sake <sake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-04-08 18:32:11 +0000 |
---|---|---|
committer | sake <sake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-04-08 18:32:11 +0000 |
commit | a823a0edb2dd8b3dc9bf7ca8013f214641effaa1 (patch) | |
tree | 2e671a614efafba221a2527d0cde4041000b2504 /gtk | |
parent | 57b6955eb823c58700e7f140147b342c015e8b0e (diff) |
Add some more "copy" functionality:
- Enabled "Copy Description" in the main menu and gave it
accelerator key CTRL+SHIFT+D
- Added "Copy Fieldname" to copy the fieldname of the selected
field in the detail view (Acc.Key: CTRL+SHIFT+F)
- Added "Copy Value" to copy the value of the selected
field in the detail view (Acc.Key: CTRL+SHIFT+V)
- Updated documentation to reflect the changes
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@28006 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main.c | 41 | ||||
-rw-r--r-- | gtk/main.h | 18 | ||||
-rw-r--r-- | gtk/main_menu.c | 17 |
3 files changed, 60 insertions, 16 deletions
diff --git a/gtk/main.c b/gtk/main.c index 203551e8df..727f342ec9 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -524,25 +524,46 @@ match_selected_plist_cb(GtkWidget *w _U_, gpointer data, MATCH_SELECTED_E action * fails we display a message to the user to indicate the copy could not be completed. */ void -copy_selected_plist_cb(GtkWidget *w _U_, gpointer data _U_) +copy_selected_plist_cb(GtkWidget *w _U_, gpointer data _U_, COPY_SELECTED_E action) { GString *gtk_text_str = g_string_new(""); char labelstring[256]; char *stringpointer = labelstring; - if (cfile.finfo_selected->rep->representation != 0) { - g_string_append(gtk_text_str, cfile.finfo_selected->rep->representation); /* Get the represented data */ + switch(action) + { + case COPY_SELECTED_DESCRIPTION: + if (cfile.finfo_selected->rep->representation != 0) { + g_string_append(gtk_text_str, cfile.finfo_selected->rep->representation); + } + break; + case COPY_SELECTED_FIELDNAME: + if (cfile.finfo_selected->hfinfo->abbrev != 0) { + g_string_append(gtk_text_str, cfile.finfo_selected->hfinfo->abbrev); + } + break; + case COPY_SELECTED_VALUE: + if (cfile.edt !=0 ) { + g_string_append(gtk_text_str, + get_node_field_value(cfile.finfo_selected, cfile.edt)); + } + break; + default: + break; } - if (gtk_text_str->len == 0) { /* If no representation then... */ - proto_item_fill_label(cfile.finfo_selected, stringpointer); /* Try to read the value */ + + if (gtk_text_str->len == 0) { + /* If no representation then... Try to read the value */ + proto_item_fill_label(cfile.finfo_selected, stringpointer); g_string_append(gtk_text_str, stringpointer); } - if (gtk_text_str->len == 0) { /* Could not get item so display error msg */ + + if (gtk_text_str->len == 0) { + /* Could not get item so display error msg */ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to copy, try expanding or choosing another item"); - } - else - { - copy_to_clipboard(gtk_text_str); /* Copy string to clipboard */ + } else { + /* Copy string to clipboard */ + copy_to_clipboard(gtk_text_str); } g_string_free(gtk_text_str, TRUE); /* Free the memory */ } diff --git a/gtk/main.h b/gtk/main.h index 40442bfee0..2667214d5b 100644 --- a/gtk/main.h +++ b/gtk/main.h @@ -124,21 +124,29 @@ typedef enum { /** "bitwise or" this with MATCH_SELECTED_E value for copy to clipboard instead of prepare only */ #define MATCH_SELECTED_COPY_ONLY 0x200 -/** User highlited item in details window and then right clicked and selected the copy option +/** User requested one of "Apply as Filter" or "Prepare a Filter" functions + * by menu or context menu of protocol tree. * * @param widget parent widget * @param data parent widget + * @param action the function to use */ -extern void copy_selected_plist_cb(GtkWidget *w _U_, gpointer data); +extern void match_selected_ptree_cb(GtkWidget *widget, gpointer data, MATCH_SELECTED_E action); -/** User requested one of "Apply as Filter" or "Prepare a Filter" functions - * by menu or context menu of protocol tree. +/** "Copy ..." action type. */ +typedef enum { + COPY_SELECTED_DESCRIPTION, /**< "Copy Description" */ + COPY_SELECTED_FIELDNAME, /**< "Copy Fieldname" */ + COPY_SELECTED_VALUE /**< "Copy Value" */ +} COPY_SELECTED_E; + +/** User highlited item in details window and then right clicked and selected the copy option * * @param widget parent widget * @param data parent widget * @param action the function to use */ -extern void match_selected_ptree_cb(GtkWidget *widget, gpointer data, MATCH_SELECTED_E action); +extern void copy_selected_plist_cb(GtkWidget *w _U_, gpointer data, COPY_SELECTED_E action); /** User requested the colorize function * by menu or context menu of protocol tree. diff --git a/gtk/main_menu.c b/gtk/main_menu.c index a091077a73..8860926adb 100644 --- a/gtk/main_menu.c +++ b/gtk/main_menu.c @@ -471,6 +471,10 @@ static GtkItemFactoryEntry menu_items[] = 0, "<StockItem>", GTK_STOCK_QUIT,}, {"/_Edit", NULL, NULL, 0, "<Branch>", NULL,}, {"/Edit/Copy", NULL, NULL, 0, "<Branch>", NULL,}, + {"/Edit/Copy/Description", "<shift><control>D", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_DESCRIPTION, NULL, NULL,}, + {"/Edit/Copy/Fieldname", "<shift><control>F", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_FIELDNAME, NULL, NULL,}, + {"/Edit/Copy/Value", "<shift><control>V", GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_VALUE, NULL, NULL,}, + {"/Edit/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, {"/Edit/Copy/As Filter", "<shift><control>C", GTK_MENU_FUNC(match_selected_ptree_cb), MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,}, #if 0 @@ -1001,7 +1005,9 @@ static GtkItemFactoryEntry tree_view_menu_items[] = {"/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, {"/Copy", NULL, NULL, 0, "<Branch>", NULL,}, - {"/Copy/Description", NULL, GTK_MENU_FUNC(copy_selected_plist_cb), 0, NULL, NULL,}, + {"/Copy/Description", NULL, GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_DESCRIPTION, NULL, NULL,}, + {"/Copy/Fieldname", NULL, GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_FIELDNAME, NULL, NULL,}, + {"/Copy/Value", NULL, GTK_MENU_FUNC(copy_selected_plist_cb), COPY_SELECTED_VALUE, NULL, NULL,}, {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, {"/Copy/As Filter", NULL, GTK_MENU_FUNC(match_selected_ptree_cb), MATCH_SELECTED_REPLACE|MATCH_SELECTED_COPY_ONLY, NULL, NULL,}, {"/Copy/<separator>", NULL, NULL, 0, "<Separator>", NULL,}, @@ -3076,6 +3082,12 @@ set_menus_for_selected_tree_row(capture_file *cf) "/Go/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM); set_menu_sensitivity(tree_view_menu_factory, "/Go to Corresponding Packet", hfinfo->type == FT_FRAMENUM); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy/Description", + proto_can_match_selected(cf->finfo_selected, cf->edt)); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy/Fieldname", + proto_can_match_selected(cf->finfo_selected, cf->edt)); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy/Value", + proto_can_match_selected(cf->finfo_selected, cf->edt)); set_menu_sensitivity(main_menu_factory, "/Edit/Copy/As Filter", proto_can_match_selected(cf->finfo_selected, cf->edt)); set_menu_sensitivity(tree_view_menu_factory, "/Copy", @@ -3119,6 +3131,9 @@ set_menus_for_selected_tree_row(capture_file *cf) "/Go/Go to Corresponding Packet", FALSE); set_menu_sensitivity(tree_view_menu_factory, "/Go to Corresponding Packet", FALSE); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy/Description", FALSE); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy/Fieldname", FALSE); + set_menu_sensitivity(main_menu_factory, "/Edit/Copy/Value", FALSE); set_menu_sensitivity(main_menu_factory, "/Edit/Copy/As Filter", FALSE); set_menu_sensitivity(tree_view_menu_factory, "/Copy", FALSE); set_menu_sensitivity(main_menu_factory, "/Analyze/Apply as Filter", FALSE); |