void SurfaceDialog::addCoordEvent(){
    // desabilitar os botoes
    gtk_widget_set_sensitive(GTK_WIDGET(m_rbBezier), false);
    gtk_widget_set_sensitive(GTK_WIDGET(m_rbBSpline), false);
    gtk_widget_set_sensitive(GTK_WIDGET(m_comboBox), false);
    gtk_widget_set_sensitive(GTK_WIDGET(m_btnAddSurface), false);

    // terminou de preencher a 'matriz'
    if(m_i == m_max_i)
        return;

    // monta a coordenada
    std::stringstream fmt;
    fmt << "(" << getX() << ", " << getY() << ", " << getZ() << ")";

    std::string coord = fmt.str();

    // salva a coord
    m_coords.emplace_back(getX(), getY(), getZ());

    // seta o texto da label na posição 'i' e 'j'
    GtkLabel* label = GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(m_grid), m_j++, m_i));
    gtk_label_set_text(label, coord.c_str());

    // verifica se chego na ultima coluna
    if(m_j == m_max_j){
        m_j = 0;
        m_i++;
    }
}
示例#2
0
/** \brief  Synchronize \a widget with its current resource value
 *
 * \param[in,out]   widget  PET video size widget
 */
void pet_video_size_widget_sync(GtkWidget *widget)
{
    GtkWidget *group;

    group = gtk_grid_get_child_at(GTK_GRID(widget), 0, 1);
    if (group != NULL && GTK_IS_GRID(group)) {
        vice_gtk3_resource_radiogroup_sync(group);
    }
}
示例#3
0
/*!
 * \fn G_MODULE_EXPORT void endAssistantNewCsu(GtkWidget *widget, gpointer data)
 *  End the assistant for a new csu file
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void endAssistantNewCsu(GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    gchar name[SIZE_MAX_FILE_NAME];
    gchar *folder;

    /* Read the game configuration list */
    char home_path[SIZE_MAX_FILE_NAME]="";
    #ifndef PORTABLE
    readHomePathSlash(home_path);
    #endif // PORTABLE


    /* Get the filename */
    GtkWidget *grid = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_1");

    folder = g_locale_from_utf8(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gtk_grid_get_child_at(GTK_GRID(grid),1,1))),-1,NULL,NULL,NULL);
    strncpy(name,g_locale_from_utf8(gtk_entry_get_text(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,0))),-1,NULL,NULL,NULL),SIZE_MAX_NAME-1);

    sprintf(user_data->csu_filename,"%s/%s",folder,name);
    addFileCsuExtension(user_data->csu_filename);

    /* Save the game configuration if ask */
    if (user_data->save_new_game_config)
        newConfigFile(user_data->config,home_path);

    /* Update the information of the global data */
    if (user_data->ptr_csu_struct != NULL)
        closeCsuStruct(user_data->ptr_csu_struct);
    user_data->ptr_csu_struct = user_data->ptr_csu_struct_tmp;
    user_data->ptr_csu_struct_tmp = NULL;

    updateMainWindow(user_data,!exceedMaxNumber(user_data->ptr_csu_struct));
    if (writeCsuFile(user_data->csu_filename,user_data->ptr_csu_struct) == false)
        saveFileError(user_data);
    deleteAllLastCsuStruct(user_data);
    addLastCsuStruct(user_data);

    deleteAssistantNewCsu(NULL,user_data);
    setButtonMainWindow(user_data);
    fillCalculatorNames(user_data);
    g_free(folder);
}
示例#4
0
/*!
 * \fn G_MODULE_EXPORT void validAssistantNewCsuTwo(GtkWidget *widget, gpointer data)
 *  Valid name of the second page of the assistant for a new csu file
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void validAssistantNewCsuTwo(GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    gboolean valid = TRUE;
    gint i;
    gint j;

    /* Get the grid */
    GtkWidget *scrolled_window = getWidgetFromBuilder(user_data->ptr_builder,"scrolled_window_new_csu_file_assistant_2");
    GtkGrid *grid = GTK_GRID(gtk_bin_get_child(GTK_BIN(gtk_bin_get_child(GTK_BIN(scrolled_window)))));

    /* Save all the name in the csu structure and check if there are non null */
    for (i=0 ; i<user_data->ptr_csu_struct_tmp->nb_player ; i++)
    {
        strncpy(user_data->ptr_csu_struct_tmp->player_names[i],gtk_entry_get_text(GTK_ENTRY(gtk_grid_get_child_at(grid,1,i))),SIZE_MAX_NAME-1);
        if (strcmp(user_data->ptr_csu_struct_tmp->player_names[i],"") == 0)
        {
            valid = FALSE;
            setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid),0,i)),0,TRUE,100,0,0,FALSE,0,0,0);
        }
        else
            setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid),0,i)),0,FALSE,100,0,0,FALSE,0,0,0);
    }

    /* Check if all the name are different */
    for (i=0 ; i<user_data->ptr_csu_struct_tmp->nb_player ; i++)
    {
        for (j=i+1 ; j<user_data->ptr_csu_struct_tmp->nb_player ; j++)
        {
            if (strcmp(user_data->ptr_csu_struct_tmp->player_names[i],user_data->ptr_csu_struct_tmp->player_names[j]) == 0)
            {
                setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid),0,i)),0,TRUE,100,0,0,FALSE,0,0,0);
                setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid),0,j)),0,TRUE,100,0,0,FALSE,0,0,0);
            }
        }
    }

    /* Check if the page is valid */
    if (valid && differentsPlayerName(user_data->ptr_csu_struct_tmp) == true)
        gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),GTK_WIDGET(scrolled_window),TRUE);
    else
        gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),GTK_WIDGET(scrolled_window),FALSE);
}
static void
gcal_date_selector_constructed (GObject *object)
{
  GcalDateSelectorPrivate *priv;

  GtkWidget *label, *box;
  GList *l, *aux;

  priv = gcal_date_selector_get_instance_private (GCAL_DATE_SELECTOR (object));

  /* chaining up */
  G_OBJECT_CLASS (gcal_date_selector_parent_class)->constructed (object);

  /* set labels, on the first row */
  label = gtk_grid_get_child_at (GTK_GRID (priv->grid), priv->day_pos, 0);
  gtk_label_set_text (GTK_LABEL (label), _("Day"));
  label = gtk_grid_get_child_at (GTK_GRID (priv->grid), priv->month_pos, 0);
  gtk_label_set_text (GTK_LABEL (label), _("Month"));
  label = gtk_grid_get_child_at (GTK_GRID (priv->grid), priv->year_pos, 0);
  gtk_label_set_text (GTK_LABEL (label), _("Year"));

  /* retrieve components from UI definition: entries */
  box = gtk_grid_get_child_at (GTK_GRID (priv->grid), 0, 1);
  aux = gtk_container_get_children (GTK_CONTAINER (box));
  for (l = aux; l != NULL; l = g_list_next (l))
    {
      gint position;
      gtk_container_child_get (GTK_CONTAINER (box), l->data, "position", &position, NULL);
      if (position == priv->day_pos)
        priv->entries[DAY] = l->data;
      if (position == priv->month_pos)
        priv->entries[MONTH] = l->data;
      if (position == priv->year_pos)
        priv->entries[YEAR] = l->data;

      if (position == priv->day_pos || position == priv->month_pos)
        gtk_entry_set_max_length (GTK_ENTRY (l->data), 2);
    }
  g_list_free (aux);

  gtk_widget_set_direction (box, GTK_TEXT_DIR_LTR);
  gtk_widget_set_direction (priv->grid, GTK_TEXT_DIR_LTR);
}
void SurfaceDialog::addSurfaceEvent(){
    gtk_widget_set_sensitive(GTK_WIDGET(m_rbBezier), false);
    gtk_widget_set_sensitive(GTK_WIDGET(m_rbBSpline), false);

    int num = 0;
    if(m_type == ObjType::BEZIER_SURFACE){
        num = 3;
    }else if(m_type == ObjType::BSPLINE_SURFACE){
        num = 1;
    }

    char *tmpSide = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(m_comboBox));
    std::string side(tmpSide);
    delete tmpSide;

    if(side == "Ao lado"){
        for(int col = 0; col < num; col++){
            gtk_grid_insert_column(GTK_GRID(m_grid), m_max_j);

            for(int line = 0; line < m_max_i; line++){
                gtk_grid_attach (GTK_GRID(m_grid),
                     gtk_label_new(NULL),
                     m_max_j, line, 1, 1);
                gtk_widget_show(gtk_grid_get_child_at(GTK_GRID(m_grid), m_max_j, line));
            }
            ++m_max_j;
        }
    }else if(side == "Abaixo"){
        for(int line = 0; line < num; line++){
            gtk_grid_insert_row(GTK_GRID(m_grid), m_max_i);

            for(int col = 0; col < m_max_j; col++){
                gtk_grid_attach (GTK_GRID(m_grid),
                     gtk_label_new(NULL),
                     col, m_max_i, 1, 1);
                gtk_widget_show(gtk_grid_get_child_at(GTK_GRID(m_grid), col, m_max_i));
            }
            ++m_max_i;
        }
    }
}
/**
 * autoar_gtk_chooser_advanced_get:
 * @advanced: a #GtkGrid returned by autoar_gtk_chooser_advanced_new()
 * @format: the place to store the #AutoarFormat selected by the user
 * @filter: the place to store the #AutoarFilter selected by the user
 *
 * Gets the selected archive format of the widget created by
 * autoar_gtk_chooser_advanced_new().
 *
 * Returns: %TRUE if @format and @filter are set. %FALSE if there is no
 * selected item on @advanced, so @format and @filter are not modified.
 **/
gboolean
autoar_gtk_chooser_advanced_get (GtkWidget *advanced,
                                 int *format,
                                 int *filter)
{
  GtkGrid *grid;
  GtkTreeIter format_iter, filter_iter;
  GtkTreeView *format_view, *filter_view;
  GtkTreePath *format_path, *filter_path;
  GtkTreeModel *format_model, *filter_model;

  grid = GTK_GRID (advanced);
  format_view = GTK_TREE_VIEW (gtk_grid_get_child_at (grid, 0, 0));
  filter_view = GTK_TREE_VIEW (gtk_grid_get_child_at (grid, 1, 0));

  gtk_tree_view_get_cursor (format_view, &format_path, NULL);
  gtk_tree_view_get_cursor (filter_view, &filter_path, NULL);
  if (format_path == NULL || filter_path == NULL) {
    gtk_tree_path_free (format_path);
    gtk_tree_path_free (filter_path);
    return FALSE;
  }

  format_model = gtk_tree_view_get_model (format_view);
  filter_model = gtk_tree_view_get_model (filter_view);
  if (!gtk_tree_model_get_iter (format_model, &format_iter, format_path) ||
      !gtk_tree_model_get_iter (filter_model, &filter_iter, filter_path)) {
    gtk_tree_path_free (format_path);
    gtk_tree_path_free (filter_path);
    return FALSE;
  }
  gtk_tree_path_free (format_path);
  gtk_tree_path_free (filter_path);

  gtk_tree_model_get (format_model, &format_iter,
                      ADVANCED_FORMAT_COL_FORMAT, format, -1);
  gtk_tree_model_get (filter_model, &filter_iter,
                      ADVANCED_FILTER_COL_FILTER, filter, -1);

  return TRUE;
}
示例#8
0
/*!
 * \fn G_MODULE_EXPORT void validAssistantNewCsuThree(GtkWidget *widget, gpointer data)
 *  Valid the third page of the assistant for a new csu file
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void validAssistantNewCsuThree(GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    gint index;

    GtkWidget *grid= getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_3");

    index = gtk_combo_box_get_active(GTK_COMBO_BOX(gtk_grid_get_child_at(GTK_GRID(grid),1,0)));

    if (index >= 0)
    {
        user_data->ptr_csu_struct_tmp->distributor = index;
        setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid),0,0)),0,FALSE,100,0,0,FALSE,0,0,0);
        gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),GTK_WIDGET(grid),TRUE);
    }
    else
    {
        setGtkLabelAttributes(GTK_LABEL(gtk_grid_get_child_at(GTK_GRID(grid),0,0)),0,TRUE,100,0,0,FALSE,0,0,0);
        gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),GTK_WIDGET(grid),FALSE);
    }
}
示例#9
0
void addOutputLabel(GtkGrid *grid, char* text, int col, int row, int width) {
    GtkWidget* label = gtk_grid_get_child_at(grid, col, row);
    if(label == NULL){
        label = gtk_label_new(NULL);
        gtk_label_set_xalign(GTK_LABEL(label), 0);
        gtk_grid_attach(grid,label,col,row,width,1);
        gtk_widget_show(label);
    }

    const char *format = "<b>\%s</b>";
    char *markup;
        
    markup = g_markup_printf_escaped (format, text);
    gtk_label_set_markup (GTK_LABEL (label), markup);
    g_free (markup);
}
示例#10
0
void
window_del_widget(struct window *w, GtkWidget *widget)
{
    int i;

    if (!w->toplevel)
        return;
    for (i = 0; i < w->grid_height; i++) {
        GtkWidget *current = gtk_grid_get_child_at(GTK_GRID(w->grid),
                             WIDGET_COLUMN, i);
        if (current == widget) {
            gtk_grid_remove_row(GTK_GRID(w->grid), i);
            w->grid_height--;
            return;
        }
    }
}
static void
advanced_update_description_cb (GtkTreeView *unused_variable,
                                GtkWidget *advanced)
{
  int format;
  int filter;
  GtkLabel *description;
  char *description_string;

  if (!autoar_gtk_chooser_advanced_get (advanced, &format, &filter))
    return;

  description = GTK_LABEL (gtk_grid_get_child_at (GTK_GRID (advanced), 0, 1));
  description_string = format_filter_full_description (format, filter);
  gtk_label_set_text (description, description_string);
  g_free (description_string);
}
示例#12
0
static int
get_grid_float_entry (GtkGrid *g, int y, int x, GnmCell *cell, gnm_float *number,
		       GtkEntry **wp, gboolean with_default, gnm_float default_float)
{
	GOFormat const *format;
	GtkWidget *w = gtk_grid_get_child_at (g, x, y + 1);

	g_return_val_if_fail (GTK_IS_ENTRY (w), 3);

	*wp = GTK_ENTRY (w);
	format = gnm_style_get_format (gnm_cell_get_style (cell));

	return (with_default?
	        entry_to_float_with_format_default (*wp, number, TRUE, format,
	                                            default_float):
			entry_to_float_with_format (*wp, number, TRUE, format));
}
示例#13
0
static void
insert_cb (GtkButton *button, GtkWidget *window)
{
  GtkGrid *g, *g1, *g2, *g3, *g4;
  GtkWidget *child;
  gboolean inserted;

  g = GTK_GRID (gtk_bin_get_child (GTK_BIN (window)));
  g1 = GTK_GRID (gtk_grid_get_child_at (g, 0, 0));
  g2 = GTK_GRID (gtk_grid_get_child_at (g, 1, 0));
  g3 = GTK_GRID (gtk_grid_get_child_at (g, 0, 1));
  g4 = GTK_GRID (gtk_grid_get_child_at (g, 1, 1));

  inserted = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "inserted"));

  if (inserted)
    {
      gtk_grid_remove_row (g1, 1);
      gtk_grid_remove_column (g2, 1);
      gtk_grid_remove_row (g3, 1);
      gtk_grid_remove_column (g4, 1);
    }
  else
    {
      gtk_grid_insert_row (g1, 1);
      gtk_grid_attach (g1, test_widget ("(0, 1)", "red"), 0, 1, 1, 1);
      gtk_grid_attach (g1, test_widget ("(2, 1)", "red"), 2, 1, 1, 1);

      gtk_grid_insert_column (g2, 1);
      gtk_grid_attach (g2, test_widget ("(1, 0)", "red"), 1, 0, 1, 1);
      gtk_grid_attach (g2, test_widget ("(1, 2)", "red"), 1, 2, 1, 1);

      child = gtk_grid_get_child_at (g3, 0, 0);
      gtk_grid_insert_next_to (g3, child, GTK_POS_BOTTOM);
      gtk_grid_attach (g3, test_widget ("(0, 1)", "red"), 0, 1, 1, 1);
      gtk_grid_attach (g3, test_widget ("(2, 1)", "red"), 2, 1, 1, 1);

      child = gtk_grid_get_child_at (g4, 0, 0);
      gtk_grid_insert_next_to (g4, child, GTK_POS_RIGHT);
      gtk_grid_attach (g4, test_widget ("(1, 0)", "red"), 1, 0, 1, 1);
      gtk_grid_attach (g4, test_widget ("(1, 2)", "red"), 1, 2, 1, 1);

      gtk_widget_show_all (GTK_WIDGET (g));
    }

  gtk_button_set_label (button, inserted ? "Insert" : "Remove");
  g_object_set_data (G_OBJECT (button), "inserted", GINT_TO_POINTER (!inserted));
}
示例#14
0
static void
load_finished (NemoImagePropertiesPage *page)
{
	GtkWidget *label;

	label = gtk_grid_get_child_at (GTK_GRID (page->details->grid), 0, 0);
	gtk_container_remove (GTK_CONTAINER (page->details->grid), label);

	if (page->details->loader != NULL) {
		gdk_pixbuf_loader_close (page->details->loader, NULL);
	}

	if (page->details->got_size) {
		append_basic_info (page);
		append_options_info (page);
		append_exif_info (page);
		append_xmp_info (page);
	} else {
		append_item (page, _("Failed to load image information"), NULL);
	}

	if (page->details->loader != NULL) {
		g_object_unref (page->details->loader);
		page->details->loader = NULL;
	}
#ifdef HAVE_EXIF
	if (page->details->exifldr != NULL) {
		exif_loader_unref (page->details->exifldr);
		page->details->exifldr = NULL;
	}
#endif /*HAVE_EXIF*/
#ifdef HAVE_EXEMPI
	if (page->details->xmp != NULL) {
		xmp_free (page->details->xmp);
		page->details->xmp = NULL;
	}
#endif
}
示例#15
0
/** \brief  Update the printer driver widget
 *
 * \param[in]   widget  printer driver widget
 * \param[in]   driver  driver name
 */
void printer_driver_widget_update(GtkWidget *widget, const char *driver)
{
    GtkWidget *radio;
    int index = 4;  /* RAW for 4/5 */
    int device;

    /* get device number from custom GObject property */
    device = GPOINTER_TO_INT(
            g_object_get_data(G_OBJECT(widget), "DeviceNumber"));

    /* this is a little silly, using string constants, but it works */
    if (device == 4 || device == 5) {
        if (strcmp(driver, "ascii") == 0) {
            index = 1;
        } else if (strcmp(driver, "mps803") == 0) {
            index = 2;
        } else if (strcmp(driver, "nl10") == 0) {
            index = 3;
        }
    } else if (device == 6) {
        if (strcmp(driver, "1520") == 0) {
            index = 1;
        } else {
            index = 2;  /* RAW */
        }
    } else {
        fprintf(stderr, "%s:%d:%s(): invalid printer device #%d\n",
                __FILE__, __LINE__, __func__, device);
        archdep_vice_exit(1);
    }

    /* now select the proper radio button */
    radio = gtk_grid_get_child_at(GTK_GRID(widget), 0, index);
    if (radio != NULL && GTK_IS_RADIO_BUTTON(radio)) {
        /* set toggle button to active, this also sets the resource */
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
    }
}
示例#16
0
static void
simple_grid (void)
{
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *test1, *test2, *test3, *test4, *test5, *test6;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Orientation");
  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);
  g_signal_connect (window, "button-press-event", G_CALLBACK (toggle_orientation), grid);

  gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
  gtk_grid_set_row_spacing (GTK_GRID (grid), 5);
  test1 = test_widget ("1", "red");
  gtk_container_add (GTK_CONTAINER (grid), test1);
  test2 = test_widget ("2", "green");
  gtk_container_add (GTK_CONTAINER (grid), test2);
  test3 = test_widget ("3", "blue");
  gtk_container_add (GTK_CONTAINER (grid), test3);
  test4 = test_widget ("4", "green");
  gtk_grid_attach (GTK_GRID (grid), test4, 0, 1, 1, 1);
  gtk_widget_set_vexpand (test4, TRUE);
  test5 = test_widget ("5", "blue");
  gtk_grid_attach_next_to (GTK_GRID (grid), test5, test4, GTK_POS_RIGHT, 2, 1);
  test6 = test_widget ("6", "yellow");
  gtk_grid_attach (GTK_GRID (grid), test6, -1, 0, 1, 2);
  gtk_widget_set_hexpand (test6, TRUE);

  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 0, -1) == NULL);
  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 0, 0) == test1);
  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 1, 0) == test2);
  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), 0, 1) == test4);
  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), -1, 0) == test6);
  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), -1, 1) == test6);
  g_assert (gtk_grid_get_child_at (GTK_GRID (grid), -1, 2) == NULL);
  gtk_widget_show_all (window);
}
示例#17
0
        debug_gtk3("called: cleaning up driver list.");
        lib_free(video_driver_list);
    }
    ui_pause_emulation(FALSE);
}


/** \brief  Set new widget for the screenshot options, replacing the old one
 *
 * Destroys any widget present before setting the \a new widget.
 *
 * \param[in]   new     new widget
 */
static void update_screenshot_options_grid(GtkWidget *new)
{
    GtkWidget *old = gtk_grid_get_child_at(GTK_GRID(screenshot_options_grid),
            0, 1);
    if (old != NULL) {
        gtk_widget_destroy(old);
    }
    gtk_grid_attach(GTK_GRID(screenshot_options_grid), new, 0, 1, 1, 1);
}


/** \brief  Handler for the "response" event of the \a dialog
 *
 * \param[in,out]   dialog      dialog triggering the event
 * \param[in]       response_id response ID
 * \param[in]       data        extra event data (unused)
 */
static void on_response(GtkDialog *dialog, gint response_id, gpointer data)
{
示例#18
0
void
lorem_ipsum_dialog(Tbfwin * bfwin)
{
#if GTK_CHECK_VERSION(3,0,0)
	GtkWidget *child, *dialog, *grid, *spin1, *spin2, *combo;
#else
	GtkWidget *dialog, *spin1, *spin2, *combo, *table;
#endif
	gint result, i;
	GList *poplist;
	gchar *command;

	dialog = gtk_dialog_new_with_buttons(_("Lorem Ipsum generator"),
										 GTK_WINDOW(bfwin->main_window),
										 GTK_DIALOG_DESTROY_WITH_PARENT,
										 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
										 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);

#if GTK_CHECK_VERSION(3,0,0)
	grid = gtk_grid_new();
	gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
	gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
	gtk_container_set_border_width(GTK_CONTAINER(grid), 6);
	gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), grid, FALSE, FALSE, 0);

	spin1 = dialog_spin_button_new(0, 5000, 1);
	gtk_container_add(GTK_CONTAINER(grid), spin1);
	gtk_grid_insert_column(GTK_GRID(grid), 0);
	gtk_grid_attach(GTK_GRID(grid), dialog_mnemonic_label_new(_("Number of _paragraphs:"), spin1), 0, 0, 1,
					1);

	spin2 = dialog_spin_button_new(0, 5000, 0);
	gtk_grid_attach_next_to(GTK_GRID(grid), spin2, spin1, GTK_POS_BOTTOM, 1, 1);
	gtk_grid_attach_next_to(GTK_GRID(grid), dialog_mnemonic_label_new(_("Number of _sentences:"), spin2),
							spin2, GTK_POS_LEFT, 1, 1);

	poplist = list_from_arglist(FALSE, _("Insert plain text"), _("Insert in <li>"), _("Insert in <p>"), NULL);
	combo = combobox_with_popdown(NULL, poplist, FALSE);
	child = gtk_grid_get_child_at(GTK_GRID(grid), 0, 1);
	gtk_grid_attach_next_to(GTK_GRID(grid), combo, child, GTK_POS_BOTTOM, 2, 1);
	g_list_free(poplist);
	gtk_grid_insert_next_to(GTK_GRID(grid), combo, GTK_POS_BOTTOM);
#else
	table = dialog_table_in_vbox_defaults(3, 2, 6, gtk_dialog_get_content_area(GTK_DIALOG(dialog)));

	spin1 = dialog_spin_button_in_table(0, 5000, 1, table, 1, 2, 0, 1);
	dialog_mnemonic_label_in_table(_("Number of paragraphs"), spin1, table, 0, 1, 0, 1);

	spin2 = dialog_spin_button_in_table(0, 5000, 0, table, 1, 2, 1, 2);
	dialog_mnemonic_label_in_table(_("Number of sentences"), spin2, table, 0, 1, 1, 2);

	poplist = list_from_arglist(FALSE, _("Insert plain text"), _("Insert in <li>"), _("Insert in <p>"), NULL);
	combo = combobox_with_popdown(NULL, poplist, FALSE);
	gtk_table_attach_defaults(GTK_TABLE(table), combo, 0, 2, 2, 3);
	g_list_free(poplist);
#endif

	gtk_widget_show_all(dialog);

	result = gtk_dialog_run(GTK_DIALOG(dialog));
	switch (result) {
	case GTK_RESPONSE_ACCEPT:
		i = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
#ifdef WIN32
		command = g_strdup_printf("python " PKGDATADIR "/lorem-ipsum-generator -l -p %d -s %d %s|",
								  (gint) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin1)),
								  (gint) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin2)),
								  i == 0 ? "" : (i == 1 ? "-f html-li" : "-f html-p")
			);
#else
		command = g_strdup_printf(PKGDATADIR "/lorem-ipsum-generator -l -p %d -s %d %s|",
								  (gint) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin1)),
								  (gint) gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin2)),
								  i == 0 ? "" : (i == 1 ? "-f html-li" : "-f html-p")
			);
#endif
		custom_command(bfwin, command, (CustomCommandCallback) lorem_ipsum_command_callback, NULL);
		g_free(command);
		break;
	default:
		break;
	}
	gtk_widget_destroy(dialog);
}
示例#19
0
static void
tabulate_ok_clicked (G_GNUC_UNUSED GtkWidget *widget, DialogState *dd)
{
	GtkDialog *dialog = dd->dialog;
	GnmCell *resultcell;
	int dims = 0;
	int row;
	gboolean with_coordinates;
	GnmTabulateInfo *data;
	/* we might get the 4 below from the positon of some of the widgets inside the grid */
	int nrows = 4;
	GnmCell **cells;
	gnm_float *minima, *maxima, *steps;

	cells = g_new (GnmCell *, nrows);
	minima = g_new (gnm_float, nrows);
	maxima = g_new (gnm_float, nrows);
	steps = g_new (gnm_float, nrows);

	for (row = 1; row < nrows; row++) {
		GtkEntry *e_w;
		GnmExprEntry *w = GNM_EXPR_ENTRY (gtk_grid_get_child_at (dd->grid, COL_CELL, row + 1));

		if (!w || gnm_expr_entry_is_blank (w))
			continue;

		cells[dims] = single_cell (dd->sheet, w);
		if (!cells[dims]) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("You should introduce a single valid cell as dependency cell"));
			gnm_expr_entry_grab_focus (GNM_EXPR_ENTRY (w), TRUE);
			goto error;
		}
		if (gnm_cell_has_expr (cells[dims])) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("The dependency cells should not contain an expression"));
			gnm_expr_entry_grab_focus (GNM_EXPR_ENTRY (w), TRUE);
			goto error;
		}

		if (get_grid_float_entry (dd->grid, row, COL_MIN, cells[dims],
					   &(minima[dims]), &e_w, FALSE, 0.0)) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("You should introduce a valid number as minimum"));
			focus_on_entry (e_w);
			goto error;
		}

		if (get_grid_float_entry (dd->grid, row, COL_MAX, cells[dims],
					   &(maxima[dims]), &e_w, FALSE, 0.0)) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("You should introduce a valid number as maximum"));
			focus_on_entry (e_w);
			goto error;
		}

		if (maxima[dims] < minima[dims]) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("The maximum value should be bigger than the minimum"));
			focus_on_entry (e_w);
			goto error;
		}

		if (get_grid_float_entry (dd->grid, row, COL_STEP, cells[dims],
					   &(steps[dims]), &e_w, TRUE, 1.0)) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("You should introduce a valid number as step size"));
			focus_on_entry (e_w);
			goto error;
		}

		if (steps[dims] <= 0) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("The step size should be positive"));
			focus_on_entry (e_w);
			goto error;
		}

		dims++;
	}

	if (dims == 0) {
		go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
				 GTK_MESSAGE_ERROR,
				 _("You should introduce one or more dependency cells"));
		goto error;
	}

	{
		resultcell = single_cell (dd->sheet, dd->resultrangetext);

		if (!resultcell) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("You should introduce a single valid cell as result cell"));
			gnm_expr_entry_grab_focus (dd->resultrangetext, TRUE);
			goto error;
		}

		if (!gnm_cell_has_expr (resultcell)) {
			go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
					 GTK_MESSAGE_ERROR,
					 _("The target cell should contain an expression"));
			gnm_expr_entry_grab_focus (dd->resultrangetext, TRUE);
			goto error;
		}
	}

	{
		int i = gnm_gui_group_value (dd->gui, mode_group);
		with_coordinates = (i == -1) ? TRUE : (gboolean)i;
	}

	data = g_new (GnmTabulateInfo, 1);
	data->target = resultcell;
	data->dims = dims;
	data->cells = cells;
	data->minima = minima;
	data->maxima = maxima;
	data->steps = steps;
	data->with_coordinates = with_coordinates;

	if (!cmd_tabulate (GNM_WBC (dd->wbcg), data)) {
		gtk_widget_destroy (GTK_WIDGET (dialog));
		return;
	}

	g_free (data);
 error:
	g_free (minima);
	g_free (maxima);
	g_free (steps);
	g_free (cells);
}
示例#20
0
/*!
 * \fn G_MODULE_EXPORT void preparePageAssistantNewCsu(GtkAssistant *assistant,GtkWidget *widget, gpointer data)
 *  Prepare the new pages
 * \param[in] assistant the GtkAssistant
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void preparePageAssistantNewCsu(GtkAssistant *assistant,GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    gint page = gtk_assistant_get_current_page(assistant);
    gint nb_ligne=0;
    gint i;

    if (page == 1)
    {
        /* Calculate the number of line which already exist */
        GtkGrid *grid = GTK_GRID(gtk_bin_get_child(GTK_BIN(gtk_bin_get_child(GTK_BIN(widget)))));
        while(gtk_grid_get_child_at(grid,0,nb_ligne) != 0)
            nb_ligne++;

        /* Add the missing lines */
        for (i=nb_ligne ; i<user_data->ptr_csu_struct_tmp->nb_player ; i++)
        {
            gtk_grid_attach(grid,gtk_label_new(g_strdup_printf(_("Name of the %dth player"),i+1)),0,i,1,1);
            gtk_grid_attach(grid,gtk_entry_new(),1,i,1,1);
            gtk_entry_set_max_length(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,i)),SIZE_MAX_NAME);
            gtk_entry_set_placeholder_text(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,i)),g_strdup_printf(_("Type here the name of the %dth player"),i+1));
            gtk_entry_set_alignment(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,i)),0.5);
            g_signal_connect(gtk_grid_get_child_at(GTK_GRID(grid),1,i),"changed", G_CALLBACK(validAssistantNewCsuTwo),user_data);
        }

        /* Remove the unwanted lines */
        for (i = nb_ligne ; i > user_data->ptr_csu_struct_tmp->nb_player ; i--)
        {
            gtk_widget_destroy(gtk_grid_get_child_at(grid,0,i-1));
            gtk_widget_destroy(gtk_grid_get_child_at(grid,1,i-1));
        }
        validAssistantNewCsuTwo(NULL,user_data);
        gtk_widget_show_all(GTK_WIDGET(grid));
    }

    if (page == 2)
    {
        GtkGrid *grid = GTK_GRID(widget);

        /* If there is no distributor valid the page 3 */
        if (user_data->ptr_csu_struct_tmp->config.use_distributor == 0)
        {
            gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(gtk_grid_get_child_at(grid,1,0)));
            gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),GTK_WIDGET(grid),TRUE);
        }
        /* Otherwise Create a combo box to choose the distributor */
        else
        {
            gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(gtk_grid_get_child_at(grid,1,0)));
            gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(gtk_grid_get_child_at(grid,1,0)));
            for (i = 0 ; i<user_data->ptr_csu_struct_tmp->nb_player ; i++)
                gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(gtk_grid_get_child_at(grid,1,0)),i,NULL,user_data->ptr_csu_struct_tmp->player_names[i]);

            /* If the last distributor still exist, choose it */
            if (index <= user_data->ptr_csu_struct_tmp->nb_player)
                gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_grid_get_child_at(grid,1,0)),index);

            validAssistantNewCsuThree(NULL,user_data);
        }
    }

    if (page == 0)
        validAssistantNewCsuOne(NULL,user_data);
}
示例#21
0
 /*!
 * \fn G_MODULE_EXPORT void openAssistantNewCsu(GtkWidget *widget, gpointer data)
 *  Open the assistant for a new csu file
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void openAssistantNewCsu(GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    char home_path[SIZE_MAX_FILE_NAME]="";
    gchar system_path[SIZE_MAX_FILE_NAME]="";
    list_game_config *ptr_list_config;
    gint i;

    #ifndef PORTABLE
    readHomePathSlash(home_path);
    readSystemPath(system_path);
    #else
    readHomePath(system_path);
    #endif // PORTABLE

    /* creating of the assistant */
    user_data->ptr_new_csu_file_assistant = gtk_assistant_new();

    /* Set the assistant windows */
    gtk_window_set_transient_for(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GTK_WINDOW(user_data->ptr_main_window));
    gtk_window_set_gravity(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GDK_GRAVITY_CENTER);
    gtk_window_set_position(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GTK_WIN_POS_CENTER_ON_PARENT);
    gtk_window_set_modal(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),TRUE);
    gtk_window_set_type_hint(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_resize(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),700,400);
    gtk_window_set_title(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),_("New csu file assistant"));

    /*Set the signal of the assistant */
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"delete-event", G_CALLBACK(deleteEventAssistantNewCsu),user_data);
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"cancel", G_CALLBACK(deleteAssistantNewCsu),user_data);
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"prepare", G_CALLBACK(preparePageAssistantNewCsu),user_data);
    g_signal_connect(user_data->ptr_new_csu_file_assistant,"close", G_CALLBACK(endAssistantNewCsu),user_data);


    /* Set the first page */
    GtkWidget *grid_1 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_1");
    gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1);
    gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,GTK_ASSISTANT_PAGE_INTRO);
    gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,_("General information"));

    /* Configure the file chooser */
    gtk_entry_set_max_length(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid_1),1,0)),SIZE_MAX_FILE_NAME/8);
    gtk_file_chooser_set_current_folder_file(GTK_FILE_CHOOSER(gtk_grid_get_child_at(GTK_GRID(grid_1),1,1)),g_file_new_for_path(g_locale_to_utf8(system_path,-1,NULL,NULL,NULL)),NULL);

    /* Set the combo  box of the game configuration */
    GtkWidget *combo_config = gtk_combo_box_text_new();
    ptr_list_config = readConfigListFile(home_path);
    for (i=0 ; i<ptr_list_config->nb_config ; i++)
        gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),i,NULL,ptr_list_config->name_game_config[i]);
    gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),ptr_list_config->nb_config,NULL,_("Add a new game configuration"));
    gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),ptr_list_config->nb_config +1,NULL,_("Use an other game configuration"));
    gtk_grid_attach(GTK_GRID(grid_1),combo_config,1,3,1,1);
    g_signal_connect(combo_config,"changed", G_CALLBACK(chooseGameConfigurationNewAssistant),user_data);
    closeListGameConfig(ptr_list_config);


    /* Set the second page */
    GtkWidget *scrolled_window_name = getWidgetFromBuilder(user_data->ptr_builder,"scrolled_window_new_csu_file_assistant_2");
    gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name);
    gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name,GTK_ASSISTANT_PAGE_CONTENT);
    gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name,_("Player's names"));

    /* Set the grid */
    GtkWidget *grid_name = gtk_grid_new();
    gtk_grid_set_column_spacing(GTK_GRID(grid_name),10);
    gtk_grid_set_row_spacing(GTK_GRID(grid_name),10);
    gtk_grid_set_column_homogeneous(GTK_GRID(grid_name),TRUE);
    #if GTK_MINOR_VERSION >= 12
    gtk_widget_set_margin_end(grid_name,10);
    gtk_widget_set_margin_start(grid_name,10);
    #else
    gtk_widget_set_margin_right(grid_name,10);
    gtk_widget_set_margin_left(grid_name,10);
    #endif // GTK_MINOR_VERSION
    gtk_widget_set_margin_top(grid_name,10);
    gtk_widget_set_margin_bottom(grid_name,10);
    gtk_container_add(GTK_CONTAINER(gtk_bin_get_child(GTK_BIN(scrolled_window_name))),grid_name);


    /* Set the third page */
    GtkWidget *grid_3 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_3");
    gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3);
    gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3,GTK_ASSISTANT_PAGE_CONFIRM);
    gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3,_("Distributor and validation"));

    GtkWidget *combo_distributor = gtk_combo_box_text_new();
    gtk_grid_attach(GTK_GRID(grid_3),combo_distributor,1,0,1,1);
    g_signal_connect(combo_distributor,"changed", G_CALLBACK(validAssistantNewCsuThree),user_data);

    cleanAssistantNewCsu(user_data);
    gtk_widget_show_all(user_data->ptr_new_csu_file_assistant);
}