예제 #1
0
void ProfileDialog::on_buttonBox_accepted()
{
    gchar *err_msg;
    QTreeWidgetItem *default_item = pd_ui_->profileTreeWidget->topLevelItem(0);
    QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem();
    gchar *profile_name = NULL;
    bool write_recent = true;
    bool item_data_removed = false;

    if (default_item && default_item->font(0).strikeOut()) {
        // Reset Default profile.
        GList *fl_entry = VariantPointer<GList>::asPtr(default_item->data(0, Qt::UserRole));
        remove_from_profile_list(fl_entry);

        // Don't write recent file if leaving the Default profile after this has been reset.
        write_recent = !is_default_profile();

        // Don't fetch profile data if removed.
        item_data_removed = (item == default_item);
    }

    if (write_recent) {
        /* Get the current geometry, before writing it to disk */
        wsApp->emitAppSignal(WiresharkApplication::ProfileChanging);

        /* Write recent file for current profile now because
         * the profile may be renamed in apply_profile_changes() */
        write_profile_recent();
    }

    if ((err_msg = apply_profile_changes()) != NULL) {
        QMessageBox::critical(this, tr("Profile Error"),
                              err_msg,
                              QMessageBox::Ok);
        g_free(err_msg);
        return;
    }

    if (item && !item_data_removed) {
        profile_def *profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data;
        profile_name = profile->name;
    }

    if (profile_exists (profile_name, FALSE) || profile_exists (profile_name, TRUE)) {
        // The new profile exists, change.
        wsApp->setConfigurationProfile (profile_name, FALSE);
    } else if (!profile_exists (get_profile_name(), FALSE)) {
        // The new profile does not exist, and the previous profile has
        // been deleted.  Change to the default profile.
        wsApp->setConfigurationProfile (NULL, FALSE);
    }
}
예제 #2
0
/*
 * Update the packets statusbar to the current values
 */
void
profile_bar_update(void)
{
    if (profile_bar) {
        /* remove old status */
        if(profile_str) {
            g_free(profile_str);
            gtk_statusbar_pop(GTK_STATUSBAR(profile_bar), profile_ctx);
        }

        profile_str = g_strdup_printf (" Profile: %s", get_profile_name ());
        gtk_statusbar_push(GTK_STATUSBAR(profile_bar), profile_ctx, profile_str);

        set_menus_for_profiles(is_default_profile());
    }
}