forked from osmocom/wireshark
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
This commit is contained in:
parent
1f1ba3d328
commit
ff65240906
|
@ -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
|
||||
|
|
|
@ -631,6 +631,30 @@
|
|||
</row>
|
||||
</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>
|
||||
|
|
|
@ -360,11 +360,29 @@
|
|||
</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
|
||||
clipboard.
|
||||
</para>
|
||||
</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>
|
||||
|
|
41
gtk/main.c
41
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 */
|
||||
}
|
||||
|
|
22
gtk/main.h
22
gtk/main.h
|
@ -124,13 +124,6 @@ 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
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data parent widget
|
||||
*/
|
||||
extern void copy_selected_plist_cb(GtkWidget *w _U_, gpointer data);
|
||||
|
||||
/** User requested one of "Apply as Filter" or "Prepare a Filter" functions
|
||||
* by menu or context menu of protocol tree.
|
||||
*
|
||||
|
@ -140,6 +133,21 @@ 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);
|
||||
|
||||
/** "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 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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
4
print.c
4
print.c
|
@ -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.
|
||||
|
|
2
print.h
2
print.h
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue