diff options
author | Sake Blok <sake@euronet.nl> | 2009-04-08 18:32:11 +0000 |
---|---|---|
committer | Sake Blok <sake@euronet.nl> | 2009-04-08 18:32:11 +0000 |
commit | ff6524090664467444ecffbdbd7045fe61d013ec (patch) | |
tree | 2e671a614efafba221a2527d0cde4041000b2504 | |
parent | 1f1ba3d328daaa6d703e57fe3f01dd49fa3d6859 (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
svn path=/trunk/; revision=28006
-rw-r--r-- | doc/wireshark.pod | 15 | ||||
-rw-r--r-- | docbook/wsug_src/WSUG_chapter_use.xml | 24 | ||||
-rw-r--r-- | docbook/wsug_src/WSUG_chapter_work.xml | 20 | ||||
-rw-r--r-- | gtk/main.c | 41 | ||||
-rw-r--r-- | gtk/main.h | 18 | ||||
-rw-r--r-- | gtk/main_menu.c | 17 | ||||
-rw-r--r-- | print.c | 4 | ||||
-rw-r--r-- | print.h | 2 |
8 files changed, 122 insertions, 19 deletions
diff --git a/doc/wireshark.pod b/doc/wireshark.pod index 8381ddcb6a..59a837132f 100644 --- a/doc/wireshark.pod +++ b/doc/wireshark.pod @@ -803,6 +803,21 @@ dialog box popped up by this menu item. Exit the application. +=item Edit:Copy:Decription + +Copies the description of the selected field in the protocol tree to +the clipboard. + +=item Edit:Copy:Fieldname + +Copies the fieldname of the selected field in the protocol tree to +the clipboard. + +=item Edit:Copy:Value + +Copies the value of the selected field in the protocol tree to +the clipboard. + =item Edit:Copy:As Filter Create a display filter based on the data currently highlighted in the diff --git a/docbook/wsug_src/WSUG_chapter_use.xml b/docbook/wsug_src/WSUG_chapter_use.xml index 7f3b885282..db458fa40c 100644 --- a/docbook/wsug_src/WSUG_chapter_use.xml +++ b/docbook/wsug_src/WSUG_chapter_use.xml @@ -632,6 +632,30 @@ </thead> <tbody> <row> + <entry><command>Copy > Description</command></entry> + <entry>Shift+Ctrl+D</entry> + <entry><para> + This menu item will copy the description of the selected item + in the detail view to the clipboard. + </para></entry> + </row> + <row> + <entry><command>Copy > Fieldname</command></entry> + <entry>Shift+Ctrl+F</entry> + <entry><para> + This menu item will copy the fieldname of the selected item + in the detail view to the clipboard. + </para></entry> + </row> + <row> + <entry><command>Copy > Value</command></entry> + <entry>Shift+Ctrl+V</entry> + <entry><para> + This menu item will copy the value of the selected item + in the detail view to the clipboard. + </para></entry> + </row> + <row> <entry><command>Copy > As Filter</command></entry> <entry>Shift+Ctrl+C</entry> <entry><para> diff --git a/docbook/wsug_src/WSUG_chapter_work.xml b/docbook/wsug_src/WSUG_chapter_work.xml index effa32b548..c7d96981a1 100644 --- a/docbook/wsug_src/WSUG_chapter_work.xml +++ b/docbook/wsug_src/WSUG_chapter_work.xml @@ -360,7 +360,7 @@ </row> <row> <entry><command>Copy/ Description</command></entry> - <entry>-</entry> + <entry>Edit</entry> <entry> <para> Copy the displayed text of the selected field to the system @@ -369,6 +369,24 @@ </entry> </row> <row> + <entry><command>Copy/ Fieldname</command></entry> + <entry>Edit</entry> + <entry> + <para> + Copy the name of the selected field to the system clipboard. + </para> + </entry> + </row> + <row> + <entry><command>Copy/ Value</command></entry> + <entry>Edit</entry> + <entry> + <para> + Copy the value of the selected field to the system clipboard. + </para> + </entry> + </row> + <row> <entry><command>Copy/ As Filter</command></entry> <entry>Edit</entry> <entry> 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); @@ -82,7 +82,7 @@ struct _output_fields { }; static const gchar* get_field_hex_value(GSList* src_list, field_info *fi); -static const gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt); +const gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt); static void proto_tree_print_node(proto_node *node, gpointer data); static void proto_tree_write_node_pdml(proto_node *node, gpointer data); static const guint8 *get_field_data(GSList *src_list, field_info *fi); @@ -1486,7 +1486,7 @@ void write_fields_finale(output_fields_t* fields _U_ , FILE *fh _U_) } /* Returns an ep_alloced string or a static constant*/ -static const gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt) +const gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt) { if (fi->hfinfo->id == hf_text_only) { /* Text label. @@ -145,4 +145,6 @@ extern void write_fields_preamble(output_fields_t* fields, FILE *fh); extern void proto_tree_write_fields(output_fields_t* fields, epan_dissect_t *edt, FILE *fh); extern void write_fields_finale(output_fields_t* fields, FILE *fh); +extern const gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt); + #endif /* print.h */ |