fix some minor bugs with the current interface name:
-always show descriptive string in combo box -correct the initialization, so cancelling the option dialog won't make trouble svn path=/trunk/; revision=14144
This commit is contained in:
parent
6b90d6085e
commit
5115a265a9
|
@ -148,6 +148,60 @@ get_interface_descriptive_name(const char *if_name)
|
|||
return descr;
|
||||
}
|
||||
|
||||
|
||||
/* search interface info by interface name */
|
||||
static if_info_t *
|
||||
search_info(GList *if_list, gchar *if_name)
|
||||
{
|
||||
GList *if_entry;
|
||||
if_info_t *if_info;
|
||||
|
||||
|
||||
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
|
||||
if_info = if_entry->data;
|
||||
|
||||
if(strcmp(if_name, if_info->name) == 0) {
|
||||
return if_info;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* build the string to display in the combo box for the given interface */
|
||||
char *
|
||||
build_capture_combo_name(GList *if_list, gchar *if_name)
|
||||
{
|
||||
gchar *descr;
|
||||
char *if_string;
|
||||
if_info_t *if_info;
|
||||
|
||||
|
||||
/* Do we have a user-supplied description? */
|
||||
descr = capture_dev_user_descr_find(if_name);
|
||||
if (descr != NULL) {
|
||||
/* Yes, we have a user-supplied description; use it. */
|
||||
if_string = g_strdup_printf("%s: %s", descr, if_name);
|
||||
g_free(descr);
|
||||
} else {
|
||||
/* No, we don't have a user-supplied description; did we get
|
||||
one from the OS or libpcap? */
|
||||
if_info = search_info(if_list, if_name);
|
||||
if (if_info && if_info->description != NULL) {
|
||||
/* Yes - use it. */
|
||||
if_string = g_strdup_printf("%s: %s", if_info->description,
|
||||
if_info->name);
|
||||
} else {
|
||||
/* No. */
|
||||
if_string = g_strdup(if_name);
|
||||
}
|
||||
}
|
||||
|
||||
return if_string;
|
||||
}
|
||||
|
||||
|
||||
GList *
|
||||
build_capture_combo_list(GList *if_list, gboolean do_hide)
|
||||
{
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
* if get_interface_list() supplies a description, use that,
|
||||
* otherwise use the interface name.
|
||||
*
|
||||
* @param if_name The name if the interface.
|
||||
* @param if_name The name of the interface.
|
||||
*
|
||||
* @return The descriptive name.
|
||||
* @return The descriptive name (must be g_free'd later)
|
||||
*/
|
||||
char *get_interface_descriptive_name(const char *if_name);
|
||||
|
||||
|
@ -45,7 +45,7 @@ char *get_interface_descriptive_name(const char *if_name);
|
|||
* @param if_list An interface list from get_interface_list().
|
||||
* @param do_hide Hide the "hidden" interfaces.
|
||||
*
|
||||
* @return A list of if_info_t structs.
|
||||
* @return A list of if_info_t structs (use free_capture_combo_list() later).
|
||||
*/
|
||||
GList *build_capture_combo_list(GList *if_list, gboolean do_hide);
|
||||
|
||||
|
@ -63,8 +63,16 @@ void free_capture_combo_list(GList *combo_list);
|
|||
* This is usually the data from one of the list elements returned by
|
||||
* build_capture_combo_list().
|
||||
*
|
||||
* @return The raw interface name, sans description.
|
||||
* @return The raw interface name, without description (must NOT be g_free'd later)
|
||||
*/
|
||||
char *get_if_name(char *if_text);
|
||||
|
||||
/** Convert plain interface name to the displayed name in the combo box.
|
||||
*
|
||||
* @param if_name The name of the interface.
|
||||
*
|
||||
* @return The descriptive name (must be g_free'd later)
|
||||
*/
|
||||
char * build_capture_combo_name(GList *if_list, gchar *if_name);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -551,6 +551,8 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
#endif
|
||||
guint32 value;
|
||||
gchar *cap_title;
|
||||
gchar *if_device;
|
||||
|
||||
|
||||
if (cap_open_w != NULL) {
|
||||
/* There's already a "Capture Options" dialog box; reactivate it. */
|
||||
|
@ -633,11 +635,15 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
/* No interface was specified on the command line or in a previous
|
||||
capture, but there is one specified in the preferences file;
|
||||
make the one from the preferences file the default */
|
||||
capture_opts->iface = g_strdup(prefs.capture_device);
|
||||
if_device = g_strdup(prefs.capture_device);
|
||||
capture_opts->iface = g_strdup(get_if_name(if_device));
|
||||
g_free(if_device);
|
||||
}
|
||||
if (capture_opts->iface != NULL)
|
||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), capture_opts->iface);
|
||||
else if (combo_list != NULL) {
|
||||
if (capture_opts->iface != NULL) {
|
||||
if_device = build_capture_combo_name(if_list, capture_opts->iface);
|
||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_device);
|
||||
g_free(if_device);
|
||||
} else if (combo_list != NULL) {
|
||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
|
||||
(char *)combo_list->data);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue