Exemplo n.º 1
0
static GtkTreeIter *
fill_list(GtkWidget *main_w)
{
  GList        *fl_entry;
  profile_def  *profile;
  GtkTreeView  *profile_l;
  GtkListStore *store;
  GtkTreeIter   iter, *l_select = NULL;
  const gchar  *profile_name    = get_profile_name();

  profile_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(main_w), E_PROF_PROFILE_L_KEY));
  store = GTK_LIST_STORE(gtk_tree_view_get_model(profile_l));

  init_profile_list();
  fl_entry = edited_profile_list();
  while (fl_entry && fl_entry->data) {
    profile = (profile_def *)fl_entry->data;
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, NAME_COLUMN, profile->name, GLOBAL_COLUMN, profile->is_global, DATA_COLUMN, fl_entry, -1);

    if (profile->name && (strcmp(profile_name, profile->name) == 0)) {
      /*
       * XXX - We're assuming that we can just copy a GtkTreeIter
       * and use it later without any crashes.  This may not be a
       * valid assumption.
       */
      l_select = (GtkTreeIter *)g_memdup(&iter, sizeof(iter));
    }
    fl_entry = g_list_next(fl_entry);
  }

  return l_select;
}
Exemplo n.º 2
0
ProfileDialog::ProfileDialog(QWidget *parent) :
    GeometryStateDialog(parent),
    pd_ui_(new Ui::ProfileDialog),
    ok_button_(NULL)
{
    GList *fl_entry;
    profile_def *profile;
    const gchar *profile_name = get_profile_name();

    pd_ui_->setupUi(this);
    loadGeometry();
    setWindowTitle(wsApp->windowTitleString(tr("Configuration Profiles")));
    ok_button_ = pd_ui_->buttonBox->button(QDialogButtonBox::Ok);

    // XXX - Use NSImageNameAddTemplate and NSImageNameRemoveTemplate to set stock
    // icons on macOS.
    // Are there equivalent stock icons on Windows?
#ifdef Q_OS_MAC
    pd_ui_->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    pd_ui_->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    pd_ui_->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    pd_ui_->infoLabel->setAttribute(Qt::WA_MacSmallSize, true);
#endif

    init_profile_list();
    fl_entry = edited_profile_list();
    pd_ui_->profileTreeWidget->blockSignals(true);
    while (fl_entry && fl_entry->data) {
        profile = (profile_def *) fl_entry->data;
        QTreeWidgetItem *item = new QTreeWidgetItem(pd_ui_->profileTreeWidget);
        item->setText(0, profile->name);
        item->setData(0, Qt::UserRole, VariantPointer<GList>::asQVariant(fl_entry));

        if (profile->is_global || profile->status == PROF_STAT_DEFAULT) {
            QFont ti_font = item->font(0);
            ti_font.setItalic(true);
            item->setFont(0, ti_font);
        } else {
            item->setFlags(item->flags() | Qt::ItemIsEditable);
        }

        if (!profile->is_global && strcmp(profile_name, profile->name) == 0) {
            pd_ui_->profileTreeWidget->setCurrentItem(item);
        }

        fl_entry = g_list_next(fl_entry);
    }
    pd_ui_->profileTreeWidget->blockSignals(false);

    connect(pd_ui_->profileTreeWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)),
            this, SLOT(editingFinished()));
    updateWidgets();
}
Exemplo n.º 3
0
void MainStatusBar::showProfileMenu(const QPoint &global_pos, Qt::MouseButton button)
{
    const gchar *profile_name = get_profile_name();
    bool separator_added = false;
    GList *fl_entry;
    profile_def *profile;
    QAction *pa;

    init_profile_list();
    fl_entry = current_profile_list();

    profile_menu_.clear();
    while (fl_entry && fl_entry->data) {
        profile = (profile_def *) fl_entry->data;
        if (!profile->is_global || !profile_exists(profile->name, false)) {
            if (profile->is_global && !separator_added) {
                profile_menu_.addSeparator();
                separator_added = true;
            }
            pa = profile_menu_.addAction(profile->name);
            if (strcmp(profile->name, profile_name) == 0) {
                /* Bold current profile */
                QFont pa_font = pa->font();
                pa_font.setBold(true);
                pa->setFont(pa_font);
                pa->setCheckable(true);
                pa->setChecked(true);
            }
            connect(pa, SIGNAL(triggered()), this, SLOT(switchToProfile()));
        }
        fl_entry = g_list_next(fl_entry);
    }

    if (button == Qt::LeftButton) {
        profile_menu_.exec(global_pos);
    } else {
        ctx_menu_.exec(global_pos);
    }
}
Exemplo n.º 4
0
void MainStatusBar::showProfileMenu(const QPoint &global_pos, Qt::MouseButton button)
{
    GList *fl_entry;
    profile_def *profile;
    QAction *pa;

    init_profile_list();
    fl_entry = edited_profile_list();

    profile_menu_.clear();
    while (fl_entry && fl_entry->data) {
        profile = (profile_def *) fl_entry->data;
        pa = profile_menu_.addAction(profile->name);
        connect(pa, SIGNAL(triggered()), this, SLOT(switchToProfile()));
        fl_entry = g_list_next(fl_entry);
    }

    if (button == Qt::LeftButton) {
        profile_menu_.exec(global_pos);
    } else {
        ctx_menu_.exec(global_pos);
    }
}