Example #1
0
/* Build the composite widget */
static void game_buildings_init(GameBuildings * gb)
{
	GtkWidget *label;
	GtkWidget *spin;
	GtkObject *adjustment;
	gint row;

	gtk_table_resize(GTK_TABLE(gb), NUM_BUILD_TYPES - 1, 2);
	gtk_table_set_row_spacings(GTK_TABLE(gb), 3);
	gtk_table_set_col_spacings(GTK_TABLE(gb), 5);
	gtk_table_set_homogeneous(GTK_TABLE(gb), TRUE);

	for (row = 1; row < NUM_BUILD_TYPES; row++) {
		label = gtk_label_new(gettext(building_names[row]));
		gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
		gtk_table_attach_defaults(GTK_TABLE(gb), label,
					  0, 1, row - 1, row);

		adjustment = gtk_adjustment_new(0, 0, 100, 1, 5, 0);
		spin =
		    gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0);
		gtk_entry_set_alignment(GTK_ENTRY(spin), 1.0);
		gtk_table_attach_defaults(GTK_TABLE(gb), spin,
					  1, 2, row - 1, row);
		gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin), TRUE);
		gb->num_buildings[row] = GTK_SPIN_BUTTON(spin);
	}
}
Example #2
0
static void _slider_init (GtkDarktableSlider *slider)
{
  slider->is_dragging=FALSE;
  slider->is_sensibility_key_pressed=FALSE;
  slider->entry=gtk_entry_new();

  gtk_widget_add_events (GTK_WIDGET (slider),
                         GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                         GDK_ENTER_NOTIFY_MASK |  GDK_LEAVE_NOTIFY_MASK |
                         GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
                         GDK_POINTER_MOTION_MASK);

  GtkWidget *hbox=gtk_hbox_new(TRUE,0);
  slider->hbox = GTK_HBOX(hbox);

  GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1);
  gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, DTGTK_SLIDER_BORDER_WIDTH*2, DTGTK_SLIDER_ADJUST_BUTTON_WIDTH+DTGTK_SLIDER_BORDER_WIDTH*2);
  gtk_container_add(GTK_CONTAINER(alignment), slider->entry);
  gtk_box_pack_start(GTK_BOX(hbox),alignment,TRUE,TRUE,0);

  gtk_container_add(GTK_CONTAINER(slider),hbox);

  gtk_entry_set_has_frame (GTK_ENTRY(slider->entry), FALSE);
  gtk_entry_set_alignment (GTK_ENTRY(slider->entry), 1.0);
  g_signal_connect (G_OBJECT (slider->entry), "key-press-event", G_CALLBACK(_slider_entry_key_event), (gpointer)slider);
  dt_gui_key_accel_block_on_focus_connect (slider->entry);
}
Example #3
0
GtkWidget *toolbar_init(GtkWindow *parent)
{
	GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
	GtkToolbar *toolbar;
	GtkActionGroup *ag = gtk_action_group_new("Actions");
	gtk_action_group_add_actions(ag, action_items,
					G_N_ELEMENTS(action_items), parent);
	gtk_action_group_add_toggle_actions(ag, toggle_items,
					G_N_ELEMENTS(toggle_items), parent);

	GtkUIManager *ui = gtk_ui_manager_new();
	g_object_set_data(G_OBJECT(parent), "ui_manager", ui);
	gtk_ui_manager_insert_action_group(ui, ag, 0);
	GtkAccelGroup *accel = gtk_ui_manager_get_accel_group(ui);
	gtk_window_add_accel_group(parent, accel);

	GError *error = NULL;
        if (!gtk_ui_manager_add_ui_from_string (ui, ui_xml, -1, &error)) {
                g_message ("building menus failed: %s", error->message);
                g_error_free (error);
                exit (-1);
        }

	GtkWidget *menubar = gtk_ui_manager_get_widget(ui, "/menubar");
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menubar), FALSE, TRUE, 0);
	toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget(ui, "/toolbar"));
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(toolbar), FALSE, TRUE, 0);

	/* Device selection GtkComboBox */
	GtkToolItem *toolitem = gtk_tool_item_new();
	GtkWidget *dev = dev_select_combo_box_new(parent);

	gtk_container_add(GTK_CONTAINER(toolitem), dev);
	gtk_toolbar_insert(toolbar, toolitem, 0);

	/* Time/Samples entry */
	toolitem = gtk_tool_item_new();
	GtkWidget *timesamples = gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(timesamples), "100");
	gtk_entry_set_alignment(GTK_ENTRY(timesamples), 1.0);
	gtk_widget_set_size_request(timesamples, 100, -1);
	gtk_container_add(GTK_CONTAINER(toolitem), timesamples);
	gtk_toolbar_insert(toolbar, toolitem, 7);

	/* Time unit combo box */
	toolitem = gtk_tool_item_new();
	GtkWidget *timeunit = gtk_combo_box_new_text();
	gtk_combo_box_append_text(GTK_COMBO_BOX(timeunit), "samples");
	gtk_combo_box_append_text(GTK_COMBO_BOX(timeunit), "ms");
	gtk_combo_box_append_text(GTK_COMBO_BOX(timeunit), "s");
	gtk_combo_box_set_active(GTK_COMBO_BOX(timeunit), 0);
	gtk_container_add(GTK_CONTAINER(toolitem), timeunit);
	gtk_toolbar_insert(toolbar, toolitem, 8);

	g_object_set_data(G_OBJECT(parent), "timesamples", timesamples);
	g_object_set_data(G_OBJECT(parent), "timeunit", timeunit);

	return GTK_WIDGET(vbox);
}
Example #4
0
static GtkWidget* new_entry(const char *text, int width, gfloat align){
    GtkWidget *prog=monitor_new_entry_progress();
    if(!text) text="Not Available";
    gtk_entry_set_text(GTK_ENTRY(prog),text);
    gtk_entry_set_width_chars(GTK_ENTRY(prog),width);
    gtk_entry_set_alignment(GTK_ENTRY(prog),align);
    return prog;
}
Example #5
0
void gui_init(dt_lib_module_t *self)
{
  /* initialize ui widgets */
  dt_lib_tool_lighttable_t *d = (dt_lib_tool_lighttable_t *)g_malloc0(sizeof(dt_lib_tool_lighttable_t));
  self->data = (void *)d;

  self->widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  d->layout =  dt_conf_get_int("plugins/lighttable/layout");
  d->previous_layout = d->layout == DT_LIGHTTABLE_LAYOUT_EXPOSE ? DT_LIGHTTABLE_LAYOUT_FILEMANAGER : DT_LIGHTTABLE_LAYOUT_EXPOSE;
  d->current_zoom = dt_conf_get_int("plugins/lighttable/images_in_row");

  /* create layout selection combobox */
  d->layout_combo = gtk_combo_box_text_new();
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->layout_combo), _("zoomable light table"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->layout_combo), _("file manager"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->layout_combo), _("expose"));

  gtk_combo_box_set_active(GTK_COMBO_BOX(d->layout_combo), d->layout);

  g_signal_connect(G_OBJECT(d->layout_combo), "changed", G_CALLBACK(_lib_lighttable_layout_changed), (gpointer)self);

  gtk_box_pack_start(GTK_BOX(self->widget), d->layout_combo, TRUE, TRUE, 0);


  /* create horizontal zoom slider */
  d->zoom = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 1, 21, 1);
  gtk_widget_set_size_request(GTK_WIDGET(d->zoom), DT_PIXEL_APPLY_DPI(140), -1);
  gtk_scale_set_draw_value(GTK_SCALE(d->zoom), FALSE);
  gtk_range_set_increments(GTK_RANGE(d->zoom), 1, 1);
  gtk_box_pack_start(GTK_BOX(self->widget), d->zoom, TRUE, TRUE, 0);

  /* manual entry of the zoom level */
  d->zoom_entry = gtk_entry_new();
  gtk_entry_set_alignment(GTK_ENTRY(d->zoom_entry), 1.0);
  gtk_entry_set_max_length(GTK_ENTRY(d->zoom_entry), 2);
  gtk_entry_set_width_chars(GTK_ENTRY(d->zoom_entry), 3);
  gtk_entry_set_max_width_chars(GTK_ENTRY(d->zoom_entry), 3);
  dt_gui_key_accel_block_on_focus_connect(d->zoom_entry);
  gtk_box_pack_start(GTK_BOX(self->widget), d->zoom_entry, TRUE, TRUE, 0);

  g_signal_connect(G_OBJECT(d->zoom), "value-changed", G_CALLBACK(_lib_lighttable_zoom_slider_changed),
                   (gpointer)self);
  g_signal_connect(d->zoom_entry, "key-press-event", G_CALLBACK(_lib_lighttable_zoom_entry_changed), self);
  gtk_range_set_value(GTK_RANGE(d->zoom), d->current_zoom);
  _lib_lighttable_zoom_slider_changed(GTK_RANGE(d->zoom), self); // the slider defaults to 1 and GTK doesn't
                                                                 // fire a value-changed signal when setting
                                                                 // it to 1 => empty text box
  gtk_widget_set_no_show_all(d->zoom, TRUE);
  gtk_widget_set_no_show_all(d->zoom_entry, TRUE);
  _lib_lighttable_layout_changed(GTK_COMBO_BOX(d->layout_combo), self);

  darktable.view_manager->proxy.lighttable.module = self;
  darktable.view_manager->proxy.lighttable.set_zoom = _lib_lighttable_set_zoom;
  darktable.view_manager->proxy.lighttable.get_zoom = _lib_lighttable_get_zoom;
  darktable.view_manager->proxy.lighttable.get_layout = _lib_lighttable_get_layout;
  darktable.view_manager->proxy.lighttable.set_layout = _lib_lighttable_set_layout;
}
Example #6
0
static void facq_display_constructed(GObject *self)
{
	FacqDisplay *dis = FACQ_DISPLAY(self);
	GtkWidget *vbox = NULL;
	GtkWidget *frame = NULL;
	GtkWidget *dra = NULL;
	GtkWidget *footer_label = NULL;
	GtkWidget *entry = NULL;

	/* frame */
	frame = gtk_frame_new(dis->priv->title);
	gtk_frame_set_label_align(GTK_FRAME(frame),0.5,0.0);
	gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_ETCHED_OUT);

	/* entry */
	entry = gtk_entry_new();
	if(dis->priv->entrytext)
		gtk_entry_set_text(GTK_ENTRY(entry),dis->priv->entrytext);
	//gtk_entry_set_overwrite_mode(GTK_ENTRY(entry),TRUE);
	gtk_entry_set_alignment(GTK_ENTRY(entry),0.5);

	/* drawing area */
	dra = gtk_drawing_area_new();

	/* label */
	footer_label = gtk_label_new(dis->priv->footer);

	/* vbox */
	vbox = gtk_vbox_new(FALSE,0);

	gtk_container_add(GTK_CONTAINER(frame),vbox);

	gtk_box_pack_start(GTK_BOX(vbox),
			   entry,FALSE,FALSE,3);

	gtk_box_pack_start(GTK_BOX(vbox),
			   dra,TRUE,TRUE,3);

	gtk_box_pack_end(GTK_BOX(vbox),
			 footer_label,FALSE,FALSE,3);

	/* connect draw function on expose-event */
	g_signal_connect(dra,"expose-event",
			G_CALLBACK(facq_display_expose_event),dis);


	gtk_widget_set_size_request(dra,150,50);

	gtk_widget_show_all(vbox);

	dis->priv->vbox = vbox;
	dis->priv->frame = frame;
	dis->priv->entry = entry;
	dis->priv->dra = dra;
	dis->priv->footer_label = footer_label;
}
Example #7
0
GtkWidget *
gtk_utils_create_spin_button (GtkAdjustment *adjustment, gdouble climb_rate,
			      guint num_digits, gboolean snap_to_ticks)
{
  GtkWidget *spin_button = gtk_spin_button_new (adjustment, climb_rate,
						num_digits);

  gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spin_button),
				     snap_to_ticks);
  gtk_entry_set_alignment (GTK_ENTRY (spin_button), 1.0);
  gtk_entry_set_activates_default (GTK_ENTRY (spin_button), TRUE);

  return spin_button;
}
Example #8
0
void gui_init(dt_lib_module_t *self)
{
  /* initialize ui widgets */
  dt_lib_tool_lighttable_t *d = (dt_lib_tool_lighttable_t *)g_malloc(sizeof(dt_lib_tool_lighttable_t));
  self->data = (void *)d;
  memset(d,0,sizeof(dt_lib_tool_lighttable_t));

  self->widget = gtk_hbox_new(FALSE,2);

  GtkWidget* widget;

  /* create layout selection combobox */
  widget = gtk_combo_box_new_text();
  gtk_combo_box_append_text(GTK_COMBO_BOX(widget), _("zoomable light table"));
  gtk_combo_box_append_text(GTK_COMBO_BOX(widget), _("file manager"));

  gtk_combo_box_set_active(GTK_COMBO_BOX(widget), dt_conf_get_int("plugins/lighttable/layout"));

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (_lib_lighttable_layout_changed),
                    (gpointer)self);

  gtk_box_pack_start(GTK_BOX(self->widget), widget, TRUE, TRUE, 0);


  /* create horizontal zoom slider */
  d->zoom = gtk_hscale_new_with_range(1, 26, 1);
  gtk_widget_set_size_request (GTK_WIDGET(d->zoom), 160, -1);
  gtk_scale_set_draw_value(GTK_SCALE(d->zoom), FALSE);
  gtk_box_pack_start(GTK_BOX(self->widget), d->zoom, TRUE, TRUE, 0);

  /* manual entry of the zoom level */
  d->zoom_entry = gtk_entry_new();
  gtk_entry_set_alignment(GTK_ENTRY(d->zoom_entry), 1.0);
  gtk_entry_set_max_length(GTK_ENTRY(d->zoom_entry), 2);
  g_object_set(G_OBJECT(d->zoom_entry), "width-chars", 3, (char *)NULL);
  dt_gui_key_accel_block_on_focus_connect(d->zoom_entry);
  gtk_box_pack_start(GTK_BOX(self->widget), d->zoom_entry, TRUE, TRUE, 0);

  g_signal_connect (G_OBJECT(d->zoom), "value-changed",
                    G_CALLBACK (_lib_lighttable_zoom_slider_changed),
                    (gpointer)self);
  g_signal_connect(d->zoom_entry, "key-press-event", G_CALLBACK(_lib_lighttable_zoom_entry_changed), self);
  gtk_range_set_value(GTK_RANGE(d->zoom), dt_conf_get_int("plugins/lighttable/images_in_row"));

  darktable.view_manager->proxy.lighttable.module = self;
  darktable.view_manager->proxy.lighttable.set_zoom = _lib_lighttable_set_zoom;

}
Example #9
0
/** Initialize an edit field that will display a number in the users
 *  local currency.
 *
 *  @param edit A pointer to the edit widget.
 */
static void
fincalc_init_commodity_gae (GNCAmountEdit *edit)
{
    GNCPrintAmountInfo print_info;
    gnc_commodity *commodity;
    gint fraction;

    commodity = gnc_default_currency();
    fraction = gnc_commodity_get_fraction(commodity);
    print_info = gnc_commodity_print_info (commodity, FALSE);

    gnc_amount_edit_set_print_info (edit, print_info);
    gnc_amount_edit_set_fraction (edit, fraction);
    gnc_amount_edit_set_evaluate_on_enter (edit, TRUE);
    gtk_entry_set_alignment (GTK_ENTRY(edit), 1.0);
}
Example #10
0
bool wxSpinCtrlGTKBase::Create(wxWindow *parent, wxWindowID id,
                        const wxString& value,
                        const wxPoint& pos,  const wxSize& size,
                        long style,
                        double min, double max, double initial, double inc,
                        const wxString& name)
{
    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxSpinCtrlGTKBase creation failed") );
        return false;
    }

    m_widget = gtk_spin_button_new_with_range(min, max, inc);
    g_object_ref(m_widget);

    gtk_spin_button_set_value( GTK_SPIN_BUTTON(m_widget), initial);

    gfloat align;
    if ( HasFlag(wxALIGN_RIGHT) )
        align = 1.0;
    else if ( HasFlag(wxALIGN_CENTRE) )
        align = 0.5;
    else
        align = 0.0;

    gtk_entry_set_alignment(GTK_ENTRY(m_widget), align);

    gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
                              (int)(m_windowStyle & wxSP_WRAP) );

    g_signal_connect_after(m_widget, "value_changed", G_CALLBACK(gtk_value_changed), this);
    g_signal_connect_after(m_widget, "changed", G_CALLBACK(gtk_changed), this);

    m_parent->DoAddChild( this );

    PostCreation(size);

    if (!value.empty())
    {
        SetValue(value);
    }

    return true;
}
Example #11
0
/** Initialize an edit field that will display a general number.
 *
 *  @param edit A pointer to the edit widget.
 *
 *  @param min_places The minimum number of places after the decimal
 *  point.
 *
 *  @param max_places The maximum number of places after the decimal
 *  point.
 *
 *  @param fraction The fraction used to maintain numbers internally.
 */
static void
fincalc_init_gae (GNCAmountEdit *edit,
                  gint min_places,
                  gint max_places,
                  gint fraction)
{
    GNCPrintAmountInfo print_info;

    print_info = gnc_integral_print_info ();
    print_info.min_decimal_places = min_places;
    print_info.max_decimal_places = max_places;

    gnc_amount_edit_set_print_info (edit, print_info);
    gnc_amount_edit_set_fraction (edit, fraction);
    gnc_amount_edit_set_evaluate_on_enter (edit, TRUE);
    gtk_entry_set_alignment (GTK_ENTRY(edit), 1.0);
}
ZLGtkApplicationWindow::GtkEntryParameter::GtkEntryParameter(ZLGtkApplicationWindow &window, const ZLToolbar::ParameterItem &item) : myWindow(window), myItem(item) {
	if (item.type() == ZLToolbar::Item::COMBO_BOX) {
		myWidget = gtk_combo_box_entry_new_text();
		myEntry = GTK_ENTRY(GTK_BIN(myWidget)->child);
		ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myEntry), "changed", GTK_SIGNAL_FUNC(::onValueChanged), this);
	} else {
		myWidget = gtk_entry_new();
		myEntry = GTK_ENTRY(myWidget);
	}
	gtk_entry_set_alignment(myEntry, 0.5);
	gtk_entry_set_width_chars(myEntry, item.maxWidth());
	gtk_entry_set_max_length(myEntry, item.maxWidth());
	if (item.symbolSet() == ZLToolbar::ParameterItem::SET_DIGITS) {
		hildon_gtk_entry_set_input_mode(myEntry, HILDON_GTK_INPUT_MODE_NUMERIC);
	} else {
		hildon_gtk_entry_set_input_mode(myEntry, HILDON_GTK_INPUT_MODE_FULL);
	}
	ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myEntry), "key_press_event", GTK_SIGNAL_FUNC(::onKeyPressed), this);
}
void
gnc_item_edit_configure (GncItemEdit *item_edit)
{
    GnucashSheet *sheet = item_edit->sheet;
    GnucashCursor *cursor;
    gfloat xalign;

    cursor = GNUCASH_CURSOR(sheet->cursor);

    item_edit->virt_loc.vcell_loc.virt_row = cursor->row;
    item_edit->virt_loc.vcell_loc.virt_col = cursor->col;

    item_edit->style =
        gnucash_sheet_get_style (sheet,
                                 item_edit->virt_loc.vcell_loc);

    item_edit->virt_loc.phys_row_offset = cursor->cell.row;
    item_edit->virt_loc.phys_col_offset = cursor->cell.col;

    switch (gnc_table_get_align (sheet->table, item_edit->virt_loc))
    {
        default:
        case CELL_ALIGN_LEFT:
            xalign = 0;
            break;

        case CELL_ALIGN_RIGHT:
            xalign = 1;
            break;

        case CELL_ALIGN_CENTER:
            xalign = 0.5;
            break;
    }
    gtk_entry_set_alignment(GTK_ENTRY(item_edit->editor), xalign);

    if (!gnc_table_is_popup (sheet->table, item_edit->virt_loc))
        gnc_item_edit_set_popup (item_edit, NULL, NULL, NULL,
                                 NULL, NULL, NULL, NULL);

    g_idle_add_full (G_PRIORITY_HIGH_IDLE,
                    (GSourceFunc) gnc_item_edit_update, item_edit, NULL);
}
Example #14
0
static GtkWidget *
_build_verification_code_entry_widget (GtkWidget *dialog)
{
  GtkWidget *hbox = NULL;
  GtkWidget *entry = NULL;
  GtkWidget *separator = NULL;
  gchar *entry_key = NULL;
  gint i = 0;

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
  for (i = 0; i < 3; i++)
    {
      entry = gtk_entry_new ();
      gtk_entry_set_max_length (GTK_ENTRY (entry), 3);
      gtk_entry_set_width_chars (GTK_ENTRY (entry), 3);
      gtk_entry_set_alignment (GTK_ENTRY (entry), 0.5);
      gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, 6);
      gtk_widget_show (entry);

      entry_key = g_strdup_printf ("vercode-%d", i + 1);
      g_object_set_data (G_OBJECT (dialog), entry_key, entry);
      g_free (entry_key);

      g_signal_connect (G_OBJECT (entry), "insert-text",
                    G_CALLBACK (_code_entry_text_inserted_cb),
                    NULL);
      if (i < 2)
        {
          separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
          gtk_box_pack_start (GTK_BOX (hbox), separator, TRUE, TRUE, 0);
          gtk_widget_show (separator);
        }
    }

  gtk_widget_show (hbox);
  return hbox;
}
Example #15
0
bool
dataInitializer(char **player1, char **player2, const int *horizontalLines,
        const int *verticalLines, OPPONENT_TYPE *opponent, Difficulty *difficulty) {
    Data *data = g_slice_new0(Data);
    GtkWidget *vbox_root, *hbox_root, *vseparator, *hseparator,
            *quit_button, *apply_button, *label;
    PangoFontDescription *font = pango_font_description_from_string
            (TEXT_ENTRY_FONT);
    char buffer[3];

    data->player1Name = (char *) calloc(21, sizeof (char));
    data->player2Name = (char *) calloc(21, sizeof (char));

    data->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    vbox_root = gtk_vbox_new(FALSE, 10);

    gtk_window_set_default_size(GTK_WINDOW(data->window), 600, 400);
    gtk_window_set_position(GTK_WINDOW(data->window), GTK_WIN_POS_CENTER);
    gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE);
    gtk_window_set_title(GTK_WINDOW(data->window), "New Game - GSquares");
    GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(ICON_PATH, NULL);
    pixbuf = gdk_pixbuf_scale_simple(pixbuf, 48, 48, GDK_INTERP_BILINEAR);
    gtk_window_set_icon(GTK_WINDOW(data->window), pixbuf);
    gtk_container_set_border_width(GTK_CONTAINER(data->window), 10);
    gtk_container_add(GTK_CONTAINER(data->window), vbox_root);

    data->comboBoxHorizontal = gtk_combo_box_new_text();
    data->comboBoxVertical = gtk_combo_box_new_text();
    data->difficulty_combo = gtk_combo_box_new_text();

    gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(data->comboBoxHorizontal), 4);
    gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(data->comboBoxVertical), 4);

    for (int i = 1; i <= 20; i++) {
        sprintf(buffer, "%d", i);
        gtk_combo_box_append_text(GTK_COMBO_BOX(data->comboBoxHorizontal),
                buffer);
        gtk_combo_box_append_text(GTK_COMBO_BOX(data->comboBoxVertical),
                buffer);
    }
    gtk_combo_box_append_text(GTK_COMBO_BOX(data->difficulty_combo), "Easy");
    gtk_combo_box_append_text(GTK_COMBO_BOX(data->difficulty_combo), "Medium");
    gtk_combo_box_append_text(GTK_COMBO_BOX(data->difficulty_combo), "Hard");

    gtk_combo_box_set_active(GTK_COMBO_BOX(data->comboBoxHorizontal), 3);
    gtk_combo_box_set_active(GTK_COMBO_BOX(data->comboBoxVertical), 3);
    gtk_combo_box_set_active(GTK_COMBO_BOX(data->difficulty_combo), 2);
    gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(data->difficulty_combo),
            GTK_SENSITIVITY_OFF);

    GtkWidget * hbox = gtk_hbox_new(FALSE, 10);
    label = gtk_label_new("Number of Horizontal Line(s)    ");

    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 4);
    gtk_box_pack_start(GTK_BOX(hbox), data->comboBoxHorizontal, TRUE, FALSE, 4);

    gtk_box_pack_start(GTK_BOX(vbox_root), hbox, FALSE, FALSE, 4);

    hbox = gtk_hbox_new(FALSE, 10);
    label = gtk_label_new("Number of Vertical Line(s)       ");

    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 4);
    gtk_box_pack_start(GTK_BOX(hbox), data->comboBoxVertical, TRUE, FALSE, 4);

    gtk_box_pack_start(GTK_BOX(vbox_root), hbox, FALSE, FALSE, 4);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox_root), hseparator, FALSE, FALSE, 5);

    hbox_root = gtk_hbox_new(FALSE, 4);

    GtkWidget *vbox = gtk_vbox_new(TRUE, 4);
    label = gtk_label_new("Player 1 : ");
    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);

    label = gtk_label_new("Player 2 : ");
    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(hbox_root), vbox, FALSE, FALSE, 0);

    vbox = gtk_vbox_new(TRUE, 4);

    data->player1Entry = gtk_entry_new();
    data->player2Entry = gtk_entry_new();
    gtk_widget_modify_font(data->player1Entry, font);
    gtk_widget_modify_font(data->player2Entry, font);
    gtk_entry_set_alignment(GTK_ENTRY(data->player1Entry), 0.5);
    gtk_entry_set_alignment(GTK_ENTRY(data->player2Entry), 0.5);
    gtk_entry_set_max_length(GTK_ENTRY(data->player1Entry),
            PLAYER_NAME_MAX_LENGTH);
    gtk_entry_set_max_length(GTK_ENTRY(data->player2Entry),
            PLAYER_NAME_MAX_LENGTH);
    gtk_entry_set_text(GTK_ENTRY(data->player1Entry), getenv("USER"));
    gtk_box_pack_start(GTK_BOX(vbox), data->player1Entry, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), data->player2Entry, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(hbox_root), vbox, FALSE, FALSE, 0);

    vseparator = gtk_vseparator_new();
    gtk_box_pack_start(GTK_BOX(hbox_root), vseparator, FALSE, FALSE, 5);

    label = gtk_label_new("Opponent ");
    gtk_box_pack_start(GTK_BOX(hbox_root), label, FALSE, FALSE, 5);

    vbox = gtk_vbox_new(TRUE, 4);
    data->radioButtonHuman = gtk_radio_button_new_with_label(NULL, "Human");
    data->radioButtonComputer = gtk_radio_button_new_with_label_from_widget
            (GTK_RADIO_BUTTON(data->radioButtonHuman), "Computer");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->radioButtonHuman),
            TRUE);
    gtk_box_pack_start(GTK_BOX(vbox), data->radioButtonHuman, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), data->radioButtonComputer, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(hbox_root), vbox, FALSE, FALSE, 0);

    gtk_box_pack_start(GTK_BOX(vbox_root), hbox_root, FALSE, FALSE, 5);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox_root), hseparator, FALSE, FALSE, 5);

    hbox = gtk_hbox_new(TRUE, 10);

    label = gtk_label_new("AI Difficulty ");
    gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 10);
    gtk_box_pack_start(GTK_BOX(hbox), data->difficulty_combo, TRUE, TRUE, 10);
    gtk_box_pack_start(GTK_BOX(vbox_root), hbox, FALSE, FALSE, 5);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox_root), hseparator, FALSE, FALSE, 5);

    hbox = gtk_hbox_new(FALSE, 10);

    apply_button = gtk_button_new_with_label("Apply");
    quit_button = gtk_button_new_with_label("Quit");
    gtk_widget_set_size_request(apply_button, 80, 35);
    gtk_widget_set_size_request(quit_button, 80, 35);
    gtk_box_pack_end(GTK_BOX(hbox), quit_button, FALSE, TRUE, 10);
    gtk_box_pack_end(GTK_BOX(hbox), apply_button, FALSE, TRUE, 10);

    gtk_box_pack_start(GTK_BOX(vbox_root), hbox, FALSE, FALSE, 5);


    g_signal_connect(data->window, "delete-event",
            G_CALLBACK(window_delete), NULL);
    g_signal_connect(apply_button, "clicked",
            G_CALLBACK(parse_user_data), (gpointer) data);
    g_signal_connect(quit_button, "clicked",
            G_CALLBACK(destroy), (gpointer) data);
    g_signal_connect(data->radioButtonComputer, "toggled",
            G_CALLBACK(toggle_event), (gpointer) data);
    g_signal_connect(GTK_ENTRY(data->player1Entry), "focus-in-event",
            G_CALLBACK(focus_text_entry_event), NULL);
    g_signal_connect(GTK_ENTRY(data->player2Entry), "focus-in-event",
            G_CALLBACK(focus_text_entry_event), NULL);

    gtk_widget_show_all(data->window);
    gtk_main();

    memmove((void *) horizontalLines, (void *) &(data->horizontalLines), sizeof
            (int));
    memmove((void *) verticalLines, (void *) &(data->verticalLines), sizeof
            (int));
    *player1 = (char *) calloc(strlen(data->player1Name) + 1, sizeof (char));
    *player2 = (char *) calloc(strlen(data->player2Name) + 1, sizeof (char));
    strcpy(*player1, data->player1Name);
    strcpy(*player2, data->player2Name);
    *opponent = data->opponent;
    if (data->opponent == COMPUTER)
        *difficulty = data->difficulty;

    gtk_widget_destroy(data->window);

    pango_font_description_free(font); 
    free(data->player1Name);
    free(data->player2Name);
    g_slice_free(Data, data);
    //free(pixbuf);
    
    return true;
}
Example #16
0
void as_sound_win_create(GawSndData *snd)
{
   UserData *ud = snd->ud;
   SoundParams *sparams = snd->sparams;
   GtkWidget *dialog;
   GtkWidget *vbox;
   gint response;
   GtkWidget *frame;
   GtkWidget *combo;
   GtkWidget *c_table;
   GtkWidget *s_table;
   GtkWidget *label;
   GtkWidget *entry;
   gchar *str;
   char text[64];
   
   dialog = gtk_dialog_new_with_buttons (_("Sound card settings and Capture"),
					 GTK_WINDOW (ud->window),
					 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
					  _("_Cancel"),
                                         GTK_RESPONSE_REJECT,
                                         _("_OK"),
                                         GTK_RESPONSE_ACCEPT,
					 NULL);
   vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);

   /* frame Sound card setting */
   frame = gtk_frame_new (_(" Sound card setting"));
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
   c_table = gtk_grid_new ();
   gtk_grid_set_column_spacing( GTK_GRID(c_table), 5);
   gtk_grid_set_row_spacing( GTK_GRID (c_table), 2);
   gtk_container_add (GTK_CONTAINER (frame), c_table);

   /*   title */   
   str = _("Card");
   label = gtk_label_new( str );
   gtk_grid_attach(GTK_GRID(c_table), label, 
                /* left,    top,  width,   height    */
                      0,      0,      1,        1  );   

   str = _("Input");
   label = gtk_label_new( str );
   gtk_grid_attach(GTK_GRID(c_table), label, 
                /* left,    top,  width,   height    */
                      1,      0,      1,        1  );   

   /*   Card */   
   combo = gtk_combo_box_text_new ();
   snd->w_card = combo;
   as_setup_card_combo (combo, sparams);
   g_signal_connect (combo, "changed",
		     G_CALLBACK (as_card_changed_cb),
		     ( gpointer) snd );
   gtk_grid_attach(GTK_GRID(c_table), combo, 
                /* left,    top,  width,   height    */
                      0,      1,      1,        1  );   

   /*   Input */   
   combo = gtk_combo_box_text_new ();
   as_setup_input_combo (combo, sparams);
   g_signal_connect (combo, "changed",
		     G_CALLBACK (as_input_changed_cb),
		     ( gpointer) snd );
   gtk_grid_attach(GTK_GRID(c_table), combo, 
                /* left,    top,  width,   height    */
                      1,      1,      1,        1  );   

   /*   title */   
   str = _("Sample Rate");
   label = gtk_label_new( str );
   gtk_grid_attach(GTK_GRID(c_table), label, 
                /* left,    top,  width,   height    */
                      0,      2,      1,        1  );   

   str = _("Sample Format");
   label = gtk_label_new( str );
   gtk_grid_attach(GTK_GRID(c_table), label, 
                /* left,    top,  width,   height    */
                      1,      2,      1,        1  );   

   /*   rate */
   combo = gtk_combo_box_text_new_with_entry ();
   snd->w_rate = combo;
   entry = gtk_bin_get_child (GTK_BIN (combo));
   gtk_entry_set_alignment (GTK_ENTRY (entry), 1); /* right */

//   as_setup_rate_combo (snd);
   g_signal_connect (combo, "changed", G_CALLBACK (as_rate_changed_cb),
		     (gpointer) snd );
   gtk_grid_attach(GTK_GRID(c_table), combo, 
                /* left,    top,  width,   height    */
                      0,      3,      1,        1  );   
   sprintf(text, "%d", sparams->rate);
   gtk_entry_set_text (GTK_ENTRY (entry), text );

   /*   format */   
   combo = gtk_combo_box_text_new ();
   snd->w_format = combo;
//   as_setup_format_combo (snd);
   g_signal_connect (combo, "changed",
		     G_CALLBACK (as_format_changed_cb),
		     ( gpointer) snd );
   gtk_grid_attach(GTK_GRID(c_table), combo, 
                /* left,    top,  width,   height    */
                      1,      3,      1,        1  );   

   /* fire the card setting callback */
   int idx = 0;
   if ( *sparams->indexstr != '-' ){ 
      idx = 1 + atoi(sparams->indexstr);
   }
   gtk_combo_box_set_active (GTK_COMBO_BOX (snd->w_card), idx );


   /* frame Capture Settings */
   frame = gtk_frame_new (_(" Capture Settings"));
   gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
   s_table =  gtk_grid_new ();
   gtk_grid_set_column_spacing( GTK_GRID(s_table), 5);
   gtk_grid_set_row_spacing( GTK_GRID (s_table), 2);
   gtk_container_add (GTK_CONTAINER (frame), s_table);

   str = _("Duration : Seconds");
   label = gtk_label_new( str );
   gtk_grid_attach(GTK_GRID(s_table), label, 
                /* left,    top,  width,   height    */
                      0,      0,      1,        1  );

   str = _("Sample number");
   label = gtk_label_new( str );
   gtk_grid_attach(GTK_GRID(s_table), label, 
                /* left,    top,  width,   height    */
                      1,      0,      1,        1  );

   /* Size */
   entry = gtk_entry_new() ;
   snd->w_size = entry;
   gtk_entry_set_alignment (GTK_ENTRY (entry), 1); /* right */
   g_signal_connect (entry, "changed",
		     G_CALLBACK (as_size_entry_changed_cb),
		     ( gpointer) snd );
   gtk_grid_attach(GTK_GRID(s_table), entry, 
                /* left,    top,  width,   height    */
                      1,      1,      1,        1  );

   /* Duration */
   entry = gtk_entry_new() ;
   snd->w_duration = entry;
   gtk_entry_set_alignment (GTK_ENTRY (entry), 1); /* right */
   g_signal_connect (entry, "changed",
		     G_CALLBACK (as_duration_entry_changed_cb),
		     ( gpointer) snd);
   gtk_grid_attach(GTK_GRID(s_table), entry, 
                /* left,    top,  width,   height    */
                      0,      1,      1,        1  );
   sprintf(text, "%0.2f", sparams->duration);
   sparams->duration -= 1.0;
   gtk_entry_set_text (GTK_ENTRY (entry), text);

   gtk_widget_show_all (vbox);
   response = gtk_dialog_run (GTK_DIALOG (dialog));

   if (response == GTK_RESPONSE_ACCEPT) {
      msg_dbg(_("dialog OK loading fom sound card"));
      
      DataFile *wdata = datafile_new( ud, "SoundCard" );
      datafile_set_sound(wdata, sparams);

      ap_load_wave ( wdata );
   }

   gtk_widget_destroy (dialog);

   /*
    * widget are suppressed
    *  need this for next creation
    */
   snd->w_card = 0;
   snd->w_rate = 0;
   snd->n_rate = 0;
   snd->w_format = 0;
   snd->n_format = 0;
   snd->w_duration = 0;
   snd->w_size = 0;
}
Example #17
0
GtkWidget *
entry_create_widget (GtkWidget * dlg)
{
  GtkWidget *c, *l = NULL, *w = NULL;

#if !GTK_CHECK_VERSION(3,0,0)
  w = gtk_hbox_new (FALSE, 5);
#else
  w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
#endif

  if (options.entry_data.entry_label)
    {
      l = gtk_label_new (NULL);
      if (options.data.no_markup)
        gtk_label_set_text_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label);
      else
        gtk_label_set_markup_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label);
      gtk_widget_set_name (l, "yad-entry-label");
      gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 1);
    }

  if (options.entry_data.numeric)
    {
      gdouble min, max, step, val;
      guint prec;

      min = 0.0;
      max = 65535.0;
      step = 1.0;
      prec = 0;

      if (options.extra_data && options.extra_data[0])
        {
          min = g_ascii_strtod (options.extra_data[0], NULL);
          if (options.extra_data[1])
            max = g_ascii_strtod (options.extra_data[1], NULL);
          if (options.extra_data[2])
            step = g_ascii_strtod (options.extra_data[2], NULL);
          if (options.extra_data[3])
            {
              prec = (guint) g_ascii_strtoull (options.extra_data[3], NULL, 0);
              if (prec > 20)
                prec = 20;
            }
        }

      c = entry = gtk_spin_button_new_with_range (min, max, step);
      gtk_entry_set_alignment (GTK_ENTRY (c), 1.0);
      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c), prec);
      gtk_widget_set_name (entry, "yad-entry-spin");

      if (options.entry_data.entry_text)
        {
          val = g_ascii_strtod (options.entry_data.entry_text, NULL);

          if (min >= max)
            {
              g_printerr (_("Maximum value must be greater than minimum value.\n"));
              min = 0.0;
              max = 65535.0;
            }

          if (val < min)
            {
              g_printerr (_("Initial value less than minimal.\n"));
              val = min;
            }
          else if (val > max)
            {
              g_printerr (_("Initial value greater than maximum.\n"));
              val = max;
            }

          gtk_spin_button_set_value (GTK_SPIN_BUTTON (c), val);
        }
    }
  else if (!options.entry_data.completion && options.extra_data && *options.extra_data)
    {
      gint active, i;

      if (options.common_data.editable || settings.combo_always_editable)
        {
#if GTK_CHECK_VERSION(2,24,0)
          c = gtk_combo_box_text_new_with_entry ();
#else
          c = gtk_combo_box_entry_new_text ();
#endif
          gtk_widget_set_name (c, "yad-entry-edit-combo");
          entry = gtk_bin_get_child (GTK_BIN (c));
          if (options.entry_data.licon)
            {
              GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON);

              if (pb)
                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb);
            }
          if (options.entry_data.ricon)
            {
              GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON);

              if (pb)
                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb);
            }
        }
      else
        {
#if GTK_CHECK_VERSION(2,24,0)
          c = entry = gtk_combo_box_text_new ();
#else
          c = entry = gtk_combo_box_new_text ();
#endif
          gtk_widget_set_name (c, "yad-entry-combo");
          is_combo = TRUE;
        }

      i = 0;
      active = -1;
      while (options.extra_data[i] != NULL)
        {
          if (options.entry_data.entry_text &&
              g_ascii_strcasecmp (options.extra_data[i], options.entry_data.entry_text) == 0)
            active = i;
#if GTK_CHECK_VERSION(2,24,0)
          gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (c), options.extra_data[i]);
#else
          gtk_combo_box_append_text (GTK_COMBO_BOX (c), options.extra_data[i]);
#endif
          i++;
        }

      if (options.entry_data.entry_text && active == -1)
        {
#if GTK_CHECK_VERSION(2,24,0)
          gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (c), options.entry_data.entry_text);
#else
          gtk_combo_box_prepend_text (GTK_COMBO_BOX (c), options.entry_data.entry_text);
#endif
        }

      /* set first iter active */
      if (!options.common_data.editable)
        gtk_combo_box_set_active (GTK_COMBO_BOX (c), (active != -1 ? active : 0));
    }
  else
    {
      c = entry = gtk_entry_new ();
      gtk_widget_set_name (c, "yad-entry-widget");

      gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);

      if (options.entry_data.entry_text)
        gtk_entry_set_text (GTK_ENTRY (entry), options.entry_data.entry_text);

      if (options.entry_data.hide_text)
        g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL);

      if (options.entry_data.completion)
        {
          GtkEntryCompletion *completion;
          GtkTreeModel *completion_model;

          completion = gtk_entry_completion_new ();
          gtk_entry_set_completion (GTK_ENTRY (entry), completion);

          completion_model = create_completion_model ();
          gtk_entry_completion_set_model (completion, completion_model);
          g_object_unref (completion_model);

          gtk_entry_completion_set_text_column (completion, 0);
          g_object_unref (completion);
        }

      if (options.entry_data.licon)
        {
          GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON);

          if (pb)
            gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb);
        }
      if (options.entry_data.ricon)
        {
          GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON);

          if (pb)
            gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb);
        }
    }

  if (l)
    gtk_label_set_mnemonic_widget (GTK_LABEL (l), entry);

  if (!is_combo)
    g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (entry_activate_cb), dlg);
  else
    g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK (combo_activate_cb), dlg);

  if (options.entry_data.licon || options.entry_data.ricon)
    g_signal_connect (G_OBJECT (entry), "icon-press", G_CALLBACK (icon_cb), NULL);

  gtk_box_pack_start (GTK_BOX (w), c, TRUE, TRUE, 1);

  return w;
}
Example #18
0
int main(int argc,char *argv[])
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *table;
	GtkWidget *button;
	
	guint i,j,num;
	gchar *values[20]={"7","8","9",
					   "4","5","6",
					   "1","2","3",
					   "0",".","=",
					   "/","*","-","+",
					   "Bksp","CE","Clear","+/-"
				 };
	
	gtk_init(&argc,&argv);
	
	//窗体设置
	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window),"计算器");
	gtk_window_set_default_size(GTK_WINDOW(window),400,300);
	gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
	gtk_window_set_icon(GTK_WINDOW(window),create_pixbuf("calc.png"));
	gtk_container_set_border_width(GTK_CONTAINER(window),10);
	g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
	
	vbox=gtk_vbox_new(FALSE,5);
	gtk_container_add(GTK_CONTAINER(window),vbox);
	
	table=gtk_table_new(6,4,TRUE);
	gtk_table_set_row_spacings(GTK_TABLE(table),10);
	gtk_table_set_col_spacings(GTK_TABLE(table),10);
	
	gtk_box_pack_start(GTK_BOX(vbox),table,TRUE,TRUE,0);
	
	entry=gtk_entry_new();
	gtk_entry_set_alignment(GTK_ENTRY(entry),1);
	gtk_table_attach_defaults(GTK_TABLE(table),entry,0,4,0,1);
	
	//数字0-9和小数点按钮
	num=0;
	for(j=2;j<6;j++)
	{
		for(i=0;i<3;i++)
		{
			button=gtk_button_new_with_label(values[num]);
			gtk_table_attach_defaults(GTK_TABLE(table),button,i,i+1,j,j+1);
			num++;
			
			g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(num_click),NULL);
			
			if(j==5 && i==1)
				i=3;
		}
	}
	
	//加、减、乘、除按钮
	num=12;
	for(j=2,i=3;j<6;j++,i--)
	{
		button=gtk_button_new_with_label(values[num]);
		gtk_table_attach_defaults(GTK_TABLE(table),button,3,4,j,j+1);
		num++;
			
		g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(suan_click),NULL);
	}
	
	//等号按钮
	button=gtk_button_new_with_label(values[11]);
	gtk_table_attach_defaults(GTK_TABLE(table),button,2,3,5,6);
	g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(deng_click),NULL);
	
	//Backspace按钮
	button=gtk_button_new_with_label(values[16]);
	gtk_table_attach_defaults(GTK_TABLE(table),button,0,1,1,2);
	g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(backspace_click),NULL);
	
	//CE按钮
	button=gtk_button_new_with_label(values[17]);
	gtk_table_attach_defaults(GTK_TABLE(table),button,1,2,1,2);
	g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(ce_click),NULL);
	
	//Clear按钮
	button=gtk_button_new_with_label(values[18]);
	gtk_table_attach_defaults(GTK_TABLE(table),button,2,3,1,2);	
	g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(clear_click),NULL);
	
	//+/-按钮
	button=gtk_button_new_with_label(values[19]);
	gtk_table_attach_defaults(GTK_TABLE(table),button,3,4,1,2);
	g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(flag_click),NULL);
	
	frame=gtk_frame_new("");
	gtk_box_pack_start(GTK_BOX(vbox),frame,TRUE,TRUE,0);
	label=gtk_label_new("");
	gtk_label_set_markup(GTK_LABEL(label),title);
	gtk_container_add(GTK_CONTAINER(frame),label);

	gtk_widget_show_all(window);
	
	gtk_main();
	
}
static void
build_tab_view(AccountGeneralTab *view)
{
    g_return_if_fail(IS_ACCOUNT_GENERAL_TAB(view));
    AccountGeneralTabPrivate *priv = ACCOUNT_GENERAL_TAB_GET_PRIVATE(view);

    int grid_row = 0;
    GtkWidget *label = NULL;

    /* separate pointers for each so that we reference them in the account changed callback */
    GtkWidget *entry_alias = NULL;
    GtkWidget *entry_username = NULL;
    GtkWidget *entry_hostname = NULL;
    GtkWidget *entry_password = NULL;
    GtkWidget *entry_proxy = NULL;
    GtkWidget *entry_voicemail = NULL;
    GtkWidget *checkbutton_autoanswer = NULL;
    GtkWidget *checkbutton_upnp = NULL;
    GtkWidget *radiobutton_dtmf_rtp = NULL;
    GtkWidget *radiobutton_dtmf_sip = NULL;

    /* build account grid */

    /* check if its ip2ip account */
    const QByteArray& alias = priv->account->alias().toLocal8Bit();

    if (strcmp(alias.constData(), "IP2IP") == 0) {
        label = gtk_label_new("IP2IP");
        gtk_widget_set_halign(label, GTK_ALIGN_START);
        gtk_grid_attach(GTK_GRID(priv->grid_account), label, 0, grid_row, 1, 1);
        ++grid_row;
    } else {
        /* account alias */
        label = gtk_label_new(_("Alias"));
        gtk_widget_set_halign(label, GTK_ALIGN_START);
        gtk_grid_attach(GTK_GRID(priv->grid_account), label, 0, grid_row, 1, 1);
        entry_alias = gtk_entry_new();
        gtk_entry_set_text(GTK_ENTRY(entry_alias), alias.constData());
        gtk_widget_set_halign(entry_alias, GTK_ALIGN_START);
        g_signal_connect(entry_alias, "changed", G_CALLBACK(account_alias_changed), view);
        gtk_grid_attach(GTK_GRID(priv->grid_account), entry_alias, 1, grid_row, 1, 1);
        ++grid_row;

        /* account type */
        label = gtk_label_new(_("Type"));
        gtk_widget_set_halign(label, GTK_ALIGN_START);
        gtk_grid_attach(GTK_GRID(priv->grid_account), label, 0, grid_row, 1, 1);

        label = gtk_label_new("");
        gtk_widget_set_halign(label, GTK_ALIGN_START);
        switch (priv->account->protocol()) {
            case Account::Protocol::SIP:
                gtk_label_set_text(GTK_LABEL(label), "SIP");
                break;
            case Account::Protocol::IAX:
                gtk_label_set_text(GTK_LABEL(label), "IAX");
                break;
            case Account::Protocol::RING:
                gtk_label_set_text(GTK_LABEL(label), "RING");
                break;
            case Account::Protocol::COUNT__:
                break;
        }

        gtk_grid_attach(GTK_GRID(priv->grid_account), label, 1, grid_row, 1, 1);
        ++grid_row;
    }

    if (priv->account->protocol() == Account::Protocol::RING) {
        label = gtk_label_new("RingID");
        gtk_widget_set_halign(label, GTK_ALIGN_START);
        gtk_grid_attach(GTK_GRID(priv->grid_account), label, 0, grid_row, 1, 1);
        entry_username = gtk_entry_new();
        gtk_entry_set_placeholder_text(GTK_ENTRY(entry_username), _("auto-generating..."));
        gtk_entry_set_text(GTK_ENTRY(entry_username), priv->account->username().toLocal8Bit().constData());
        g_object_set(G_OBJECT(entry_username), "editable", FALSE, NULL);
        g_object_set(G_OBJECT(entry_username), "max-width-chars", 50, NULL);
        gtk_widget_override_font(entry_username, pango_font_description_from_string("monospace"));
        gtk_entry_set_alignment(GTK_ENTRY(entry_username), 0.5);
        gtk_grid_attach(GTK_GRID(priv->grid_account), entry_username, 1, grid_row, 1, 1);
        ++grid_row;
    }

    gtk_widget_show_all(priv->grid_account);

    /* build parameters grid */
    grid_row = 0;
    if (strcmp(alias.constData(), "IP2IP") != 0) {
        if (priv->account->protocol() != Account::Protocol::RING) {
            /* SIP and IAX have the same params */

            /* host name */
            label = gtk_label_new(_("Hostname"));
            gtk_widget_set_halign(label, GTK_ALIGN_START);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
            entry_hostname = gtk_entry_new();
            gtk_entry_set_text(GTK_ENTRY(entry_hostname), priv->account->hostname().toLocal8Bit().constData());
            g_signal_connect(entry_hostname, "changed", G_CALLBACK(account_hostname_changed), view);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_hostname, 1, grid_row, 1, 1);
            ++grid_row;

            /* user name */
            label = gtk_label_new(_("Username"));
            gtk_widget_set_halign(label, GTK_ALIGN_START);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
            entry_username = gtk_entry_new();
            gtk_entry_set_text(GTK_ENTRY(entry_username), priv->account->username().toLocal8Bit().constData());
            g_signal_connect(entry_username, "changed", G_CALLBACK(account_username_changed), view);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_username, 1, grid_row, 1, 1);
            ++grid_row;

            /* password */
            label = gtk_label_new(_("Password"));
            gtk_widget_set_halign(label, GTK_ALIGN_START);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
            entry_password = gtk_entry_new();
            gtk_entry_set_input_purpose(GTK_ENTRY(entry_password), GTK_INPUT_PURPOSE_PASSWORD);
            gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry_password), GTK_ENTRY_ICON_PRIMARY, "dialog-password");
            gtk_entry_set_visibility(GTK_ENTRY(entry_password), FALSE);
            gtk_entry_set_text(GTK_ENTRY(entry_password), priv->account->password().toLocal8Bit().constData());
            g_signal_connect(entry_password, "changed", G_CALLBACK(account_password_changed), view);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_password, 1, grid_row, 1, 1);
            ++grid_row;

            /* show password */
            GtkWidget *checkbutton = gtk_check_button_new_with_label(_("Show password"));
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton, 1, grid_row, 1, 1);
            g_signal_connect(checkbutton, "toggled", G_CALLBACK(show_password), entry_password);
            ++grid_row;

            /* proxy */
            label = gtk_label_new(_("Proxy"));
            gtk_widget_set_halign(label, GTK_ALIGN_START);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
            entry_proxy = gtk_entry_new();
            gtk_entry_set_text(GTK_ENTRY(entry_proxy), priv->account->proxy().toLocal8Bit().constData());
            g_signal_connect(entry_proxy, "changed", G_CALLBACK(account_proxy_changed), view);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_proxy, 1, grid_row, 1, 1);
            ++grid_row;

            /* voicemail number */
            label = gtk_label_new(_("Voicemail number"));
            gtk_widget_set_halign(label, GTK_ALIGN_START);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
            entry_voicemail = gtk_entry_new();
            gtk_entry_set_text(GTK_ENTRY(entry_voicemail), priv->account->mailbox().toLocal8Bit().constData());
            g_signal_connect(entry_voicemail, "changed", G_CALLBACK(account_mailbox_changed), view);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_voicemail, 1, grid_row, 1, 1);
            ++grid_row;
        } else {
            /* RING accoutn */

            /* bootstrap */
            label = gtk_label_new(C_("The DHT bootstrap server url", "Bootstrap"));
            gtk_widget_set_halign(label, GTK_ALIGN_START);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);
            entry_hostname = gtk_entry_new();
            gtk_entry_set_text(GTK_ENTRY(entry_hostname), priv->account->hostname().toLocal8Bit().constData());
            g_signal_connect(entry_hostname, "changed", G_CALLBACK(account_hostname_changed), view);
            gtk_grid_attach(GTK_GRID(priv->grid_parameters), entry_hostname, 1, grid_row, 1, 1);
            ++grid_row;
        }
    }

    /* auto answer */
    checkbutton_autoanswer = gtk_check_button_new_with_label(_("Auto-answer calls"));
    gtk_widget_set_halign(checkbutton_autoanswer, GTK_ALIGN_START);
    gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton_autoanswer, 0, grid_row, 1, 1);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_autoanswer), priv->account->isAutoAnswer());
    g_signal_connect(checkbutton_autoanswer, "toggled", G_CALLBACK(auto_answer), view);
    ++grid_row;

    /* upnp */
    checkbutton_upnp = gtk_check_button_new_with_label(_("UPnP enabled"));
    gtk_widget_set_halign(checkbutton_upnp, GTK_ALIGN_START);
    gtk_grid_attach(GTK_GRID(priv->grid_parameters), checkbutton_upnp, 0, grid_row, 1, 1);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_upnp), priv->account->isUpnpEnabled());
    g_signal_connect(checkbutton_upnp, "toggled", G_CALLBACK(upnp_enabled), view);
    ++grid_row;

    /* DTMF tone type */
    label = gtk_label_new(_("DTMF tone type:"));
    gtk_widget_set_halign(label, GTK_ALIGN_START);
    gtk_grid_attach(GTK_GRID(priv->grid_parameters), label, 0, grid_row, 1, 1);

    GtkWidget *dtmf_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(dtmf_box), GTK_BUTTONBOX_START);
    gtk_box_set_spacing(GTK_BOX(dtmf_box), 10);
    radiobutton_dtmf_rtp = gtk_radio_button_new_with_label(NULL, "RTP");
    radiobutton_dtmf_sip = gtk_radio_button_new_with_label_from_widget(
        GTK_RADIO_BUTTON(radiobutton_dtmf_rtp),
        "SIP");
    gtk_toggle_button_set_active(
        priv->account->DTMFType() == DtmfType::OverRtp ?
            GTK_TOGGLE_BUTTON(radiobutton_dtmf_rtp) : GTK_TOGGLE_BUTTON(radiobutton_dtmf_sip),
        TRUE);
    g_signal_connect(radiobutton_dtmf_rtp, "toggled", G_CALLBACK(dtmf_set_rtp), view);
    gtk_box_pack_start(GTK_BOX(dtmf_box),
                       radiobutton_dtmf_rtp,
                       FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(dtmf_box),
                       radiobutton_dtmf_sip,
                       FALSE, TRUE, 0);
    gtk_grid_attach(GTK_GRID(priv->grid_parameters), dtmf_box, 1, grid_row, 1, 1);
    ++grid_row;

    /* update account parameters if model is updated */
    priv->account_updated = QObject::connect(
        priv->account,
        &Account::changed,
        [=] () {
            if (strcmp(alias.constData(), "IP2IP") != 0) {
                gtk_entry_set_text(GTK_ENTRY(entry_alias), priv->account->alias().toLocal8Bit().constData());
                gtk_entry_set_text(GTK_ENTRY(entry_username), priv->account->username().toLocal8Bit().constData());
                gtk_entry_set_text(GTK_ENTRY(entry_hostname), priv->account->hostname().toLocal8Bit().constData());

                if (priv->account->protocol() != Account::Protocol::RING) {
                    gtk_entry_set_text(GTK_ENTRY(entry_password), priv->account->password().toLocal8Bit().constData());
                    gtk_entry_set_text(GTK_ENTRY(entry_proxy), priv->account->proxy().toLocal8Bit().constData());
                    gtk_entry_set_text(GTK_ENTRY(entry_voicemail), priv->account->mailbox().toLocal8Bit().constData());
                }
            }

            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_autoanswer), priv->account->isAutoAnswer());
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_upnp), priv->account->isUpnpEnabled());
             gtk_toggle_button_set_active(
                priv->account->DTMFType() == DtmfType::OverRtp ?
                    GTK_TOGGLE_BUTTON(radiobutton_dtmf_rtp) : GTK_TOGGLE_BUTTON(radiobutton_dtmf_sip),
                TRUE);
        }
    );

    gtk_widget_show_all(priv->grid_parameters);

}
static void
thunar_sbr_number_renamer_init (ThunarSbrNumberRenamer *number_renamer)
{
  AtkRelationSet *relations;
  AtkRelation    *relation;
  GEnumClass     *klass;
  AtkObject      *object;
  GtkWidget      *combo;
  GtkWidget      *entry;
  GtkWidget      *label;
  GtkWidget      *hbox;
  guint           n;

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_box_pack_start (GTK_BOX (number_renamer), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new_with_mnemonic (_("_Number Format:"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  combo = gtk_combo_box_new_text ();
  klass = g_type_class_ref (THUNAR_SBR_TYPE_NUMBER_MODE);
  for (n = 0; n < klass->n_values; ++n)
    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick));
  exo_mutual_binding_new (G_OBJECT (number_renamer), "mode", G_OBJECT (combo), "active");
  gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
  g_type_class_unref (klass);
  gtk_widget_show (combo);

  /* set Atk label relation for the combo */
  object = gtk_widget_get_accessible (combo);
  relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
  relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
  atk_relation_set_add (relations, relation);
  g_object_unref (G_OBJECT (relation));

  number_renamer->start_entry = gtk_entry_new ();
  gtk_entry_set_max_length (GTK_ENTRY (number_renamer->start_entry), 4);
  gtk_entry_set_width_chars (GTK_ENTRY (number_renamer->start_entry), 3);
  gtk_entry_set_alignment (GTK_ENTRY (number_renamer->start_entry), 1.0f);
  gtk_entry_set_activates_default (GTK_ENTRY (number_renamer->start_entry), TRUE);
  exo_mutual_binding_new (G_OBJECT (number_renamer->start_entry), "text", G_OBJECT (number_renamer), "start");
  gtk_box_pack_end (GTK_BOX (hbox), number_renamer->start_entry, TRUE, TRUE, 0);
  gtk_widget_show (number_renamer->start_entry);

  label = gtk_label_new_with_mnemonic (_("_Start With:"));
  gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), number_renamer->start_entry);
  gtk_widget_show (label);

  /* set Atk label relation for the entry */
  object = gtk_widget_get_accessible (number_renamer->start_entry);
  relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
  relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
  atk_relation_set_add (relations, relation);
  g_object_unref (G_OBJECT (relation));

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_box_pack_end (GTK_BOX (number_renamer), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  label = gtk_label_new_with_mnemonic (_("Text _Format:"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  combo = gtk_combo_box_new_text ();
  klass = g_type_class_ref (THUNAR_SBR_TYPE_TEXT_MODE);
  for (n = 0; n < klass->n_values; ++n)
    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick));
  exo_mutual_binding_new (G_OBJECT (number_renamer), "text-mode", G_OBJECT (combo), "active");
  gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
  g_type_class_unref (klass);
  gtk_widget_show (combo);

  /* set Atk label relation for the combo */
  object = gtk_widget_get_accessible (combo);
  relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
  relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
  atk_relation_set_add (relations, relation);
  g_object_unref (G_OBJECT (relation));

  entry = gtk_entry_new ();
  gtk_entry_set_width_chars (GTK_ENTRY (entry), 4);
  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
  exo_mutual_binding_new (G_OBJECT (entry), "text", G_OBJECT (number_renamer), "text");
  gtk_box_pack_end (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
  gtk_widget_show (entry);

  label = gtk_label_new_with_mnemonic (_("_Text:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f);
  gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
  gtk_widget_show (label);

  /* set Atk label relation for the entry */
  object = gtk_widget_get_accessible (entry);
  relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
  relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
  atk_relation_set_add (relations, relation);
  g_object_unref (G_OBJECT (relation));
}
Example #21
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);
}
static void
thunar_sbr_insert_renamer_init (ThunarSbrInsertRenamer *insert_renamer)
{
  AtkRelationSet *relations;
  GtkAdjustment  *adjustment;
  AtkRelation    *relation;
  GEnumClass     *klass;
  AtkObject      *object;
  GtkWidget      *spinner;
  GtkWidget      *combo;
  GtkWidget      *entry;
  GtkWidget      *label;
  GtkWidget      *table;
  GtkWidget      *hbox;
  guint           n;

  table = gtk_table_new (2, 3, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
  gtk_box_pack_start (GTK_BOX (insert_renamer), table, TRUE, TRUE, 0);
  gtk_widget_show (table);

  combo = gtk_combo_box_text_new ();
  klass = g_type_class_ref (THUNAR_SBR_TYPE_INSERT_MODE);
  for (n = 0; n < klass->n_values; ++n)
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _(klass->values[n].value_nick));
  exo_mutual_binding_new (G_OBJECT (insert_renamer), "mode", G_OBJECT (combo), "active");
  gtk_table_attach (GTK_TABLE (table), combo, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
  g_type_class_unref (klass);
  gtk_widget_show (combo);

  label = gtk_label_new_with_mnemonic (_("_Text:"));
  gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
  gtk_widget_show (label);

  entry = gtk_entry_new ();
  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
  exo_mutual_binding_new (G_OBJECT (entry), "text", G_OBJECT (insert_renamer), "text");
  gtk_table_attach (GTK_TABLE (table), entry, 2, 3, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
  gtk_widget_show (entry);

  /* set Atk label relation for the entry */
  object = gtk_widget_get_accessible (entry);
  relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
  relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
  atk_relation_set_add (relations, relation);
  g_object_unref (G_OBJECT (relation));

  label = gtk_label_new_with_mnemonic (_("_At position:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0f, 0.5f);
  gtk_table_attach (GTK_TABLE (table), label, 0, 2, 1, 2, GTK_FILL, 0, 0, 0);
  gtk_widget_show (label);

  hbox = gtk_hbox_new (FALSE, 12);
  gtk_table_attach (GTK_TABLE (table), hbox, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
  gtk_widget_show (hbox);

  spinner = gtk_spin_button_new_with_range (0u, G_MAXUINT, 1u);
  gtk_entry_set_width_chars (GTK_ENTRY (spinner), 4);
  gtk_entry_set_alignment (GTK_ENTRY (spinner), 1.0f);
  gtk_entry_set_activates_default (GTK_ENTRY (spinner), TRUE);
  gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner), 0);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE);
  gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spinner), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner);
  gtk_widget_show (spinner);

  adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinner));
  exo_mutual_binding_new (G_OBJECT (insert_renamer), "offset", G_OBJECT (adjustment), "value");

  /* set Atk label relation for the entry */
  object = gtk_widget_get_accessible (spinner);
  relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
  relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
  atk_relation_set_add (relations, relation);
  g_object_unref (G_OBJECT (relation));

  combo = gtk_combo_box_text_new ();
  klass = g_type_class_ref (THUNAR_SBR_TYPE_OFFSET_MODE);
  for (n = 0; n < klass->n_values; ++n)
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _(klass->values[n].value_nick));
  exo_mutual_binding_new (G_OBJECT (insert_renamer), "offset-mode", G_OBJECT (combo), "active");
  gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
  g_type_class_unref (klass);
  gtk_widget_show (combo);
}
Example #23
0
int main(int argc, char *argv[])
{
    if(argc > 1)
    {
        if(strequ(argv[1], "--version"))
        {
            printf("Boggle Solver version 2.0\nBuild number %X\n", BUILDNUMBER);
            return 0;
        }
    }

    gdk_threads_init();

    // Load dictionary
    pthread_t dictThread;
    pthread_create(&dictThread, NULL, load_dict_threaded, NULL);
    pthread_detach(dictThread);

    GtkWidget *textbox_table, *solve_b, *clear_b, *list_scroll;

    gtk_init(&argc, &argv); //140

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    gtk_widget_set_size_request(window, 653, 485);
    gtk_window_set_title(GTK_WINDOW(window), "Boggle Solver");

    gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL);

    textbox_table = gtk_table_new(6, 5, FALSE);
    list = gtk_tree_view_new();

    list_scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(list_scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
    gtk_widget_set_size_request(list_scroll, 190, -1);
    gtk_container_add(GTK_CONTAINER(list_scroll), list);
    gtk_table_attach_defaults(GTK_TABLE(textbox_table), list_scroll, 4, 5, 0, 5);
    gtk_table_set_col_spacings(GTK_TABLE(textbox_table), 10);
    gtk_table_set_row_spacings(GTK_TABLE(textbox_table), 10);

    solve_b = gtk_button_new_with_label("Solve");
    clear_b = gtk_button_new_with_label("Clear");

    gtk_widget_set_size_request(solve_b, 100, 27);
    gtk_widget_set_size_request(clear_b, 100, 27);

    gtk_table_attach_defaults(GTK_TABLE(textbox_table), solve_b, 0, 1, 4, 5);
    gtk_table_attach_defaults(GTK_TABLE(textbox_table), clear_b, 3, 4, 4, 5);

    gtk_signal_connect(GTK_OBJECT(solve_b), "clicked", GTK_SIGNAL_FUNC(solve_clicked), NULL);
    gtk_signal_connect(GTK_OBJECT(clear_b), "clicked", GTK_SIGNAL_FUNC(clear_clicked), NULL);

    int x, y;
    for(x = 0; x < 4; x++)
    {
        for(y = 0; y < 4; y++)
        {
            textboxes[x][y] = gtk_entry_new();
            GtkWidget *tb = textboxes[x][y];
            int *idx = malloc(sizeof(int));
            *idx = y * 4 + x;
            gtk_entry_set_max_length(GTK_ENTRY(tb), 1);
            gtk_table_attach_defaults(GTK_TABLE(textbox_table), tb, x, x + 1, y, y + 1);
            gtk_entry_set_width_chars(GTK_ENTRY(tb), 5);
            gtk_entry_set_alignment(GTK_ENTRY(tb), 0.5);
            gtk_widget_set_size_request(tb, 100, 100);
            gtk_widget_modify_font(tb, pango_font_description_from_string("Ubuntu 55"));
            gtk_signal_connect(GTK_OBJECT(tb), "backspace", GTK_SIGNAL_FUNC(backspace_pressed), NULL);
            gtk_signal_connect(GTK_OBJECT(tb), "key-press-event", GTK_SIGNAL_FUNC(key_pressed), NULL);
            gtk_signal_connect(GTK_OBJECT(tb), "button-press-event", GTK_SIGNAL_FUNC(tb_focus), idx);
        }
    }

    gtk_container_add(GTK_CONTAINER(window), textbox_table);

    init_list(list);

    gtk_widget_show_all(window);

    gtk_main();

    dict_clean_up();

    gdk_threads_leave();

    return 0;
}
Example #24
0
static void
drw_cc_panel_init (DrwCcPanel *self)
{
  GtkBuilder *builder;
  GError *error = NULL;
  GtkWidget *widget;
  GSettings *settings;

  /* priv = self->priv = DRW_CC_PANEL_GET_PRIVATE (self); */

  builder = gtk_builder_new ();
  gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);

  if (!gtk_builder_add_from_resource (builder, "/org/gnome/drwright/drwright-panel.ui", &error))
    g_error ("%s", error->message);

  widget = (GtkWidget *) gtk_builder_get_object (builder, "typing-break-preferences-box");
  gtk_widget_reparent (widget, GTK_WIDGET (self));

  widget = (GtkWidget *) gtk_builder_get_object (builder, "typing-break-preferences-dialog");
  gtk_widget_destroy (widget);

  /* Now connect the settings */
  settings = g_settings_new (DRW_SETTINGS_SCHEMA_ID);

  g_settings_bind (settings, "enabled",
                   gtk_builder_get_object (builder, "break-enabled-checkbutton"),
                   "active",
                   G_SETTINGS_BIND_DEFAULT);
  g_settings_bind (settings, "enabled",
                   gtk_builder_get_object (builder, "inner-box"),
                   "sensitive",
                   G_SETTINGS_BIND_GET);
  widget = (GtkWidget *) gtk_builder_get_object (builder, "work-interval-spinbutton");
  gtk_entry_set_width_chars (GTK_ENTRY (widget), 8);
  gtk_entry_set_alignment (GTK_ENTRY (widget), 1.0);
  g_signal_connect (widget, "input",
                    G_CALLBACK (spinbutton_input_cb), NULL);
  g_signal_connect (widget, "output",
                    G_CALLBACK (spinbutton_output_cb), NULL);
  g_settings_bind (settings, "type-time",
                   gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)),
                   "value",
                   G_SETTINGS_BIND_DEFAULT);
  widget = (GtkWidget *) gtk_builder_get_object (builder, "break-interval-spinbutton");
  gtk_entry_set_width_chars (GTK_ENTRY (widget), 8);
  gtk_entry_set_alignment (GTK_ENTRY (widget), 1.0);
  g_signal_connect (widget, "input",
                    G_CALLBACK (spinbutton_input_cb), NULL);
  g_signal_connect (widget, "output",
                    G_CALLBACK (spinbutton_output_cb), NULL);
  g_settings_bind (settings, "break-time",
                   gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)),
                   "value",
                   G_SETTINGS_BIND_DEFAULT);
  g_settings_bind (settings, "allow-postpone",
                   gtk_builder_get_object (builder, "allow-postpone-checkbutton"),
                   "active",
                   G_SETTINGS_BIND_DEFAULT);

  g_object_unref (settings);
  g_object_unref (builder);
}
Example #25
0
/*!
  \brief add_slider() creates the slider from the passed data, and attaches
  it the the gui.
  \param ctrl_name is the name of the slider as defined in the config file
  \param tbl is the table number to bind this slider to
  \param table_num is  the table_num from the firmware that this slider is
  bound to. (used for the sliders on the 3D view)
  \param row is the row of the table (tbl) that this slider goes on
  \param source is the data source for this slider 
  \param ident is the enumeration of the page this slider goes on
  \returns a Struct Rt_Slider *
  */
G_MODULE_EXPORT Rt_Slider * add_slider(gchar *ctrl_name, gint tbl, gint table_num, gint row, gchar *source, TabIdent ident)
{
	Rt_Slider *slider = NULL;
	GtkWidget *label = NULL;
	GtkWidget *pbar = NULL;
	GtkWidget *table = NULL;
	GtkWidget *hbox = NULL;
	gchar * name = NULL;
	Rtv_Map *rtv_map = NULL;
	gconstpointer *object = NULL;

	rtv_map = (Rtv_Map *)DATA_GET(global_data,"rtv_map");
	object = (gconstpointer *)g_hash_table_lookup(rtv_map->rtv_hash,source);
	if (!(object))
	{
		MTXDBG(CRITICAL,_("Request to create slider for non-existant datasource \"%s\"\n"),source);
		return NULL;
	}

	if (ident == RUNTIME_TAB)
		name = g_strdup_printf("runtime_rt_table%i",tbl);
	else if (ident == WARMUP_WIZ_TAB)
		name = g_strdup_printf("ww_rt_table%i",tbl);
	else if (ident == VE3D_VIEWER_TAB)
		name = g_strdup_printf("ve3d_rt_table%i_%i",tbl,table_num);
	else
	{
		MTXDBG(CRITICAL,_("Page ident passed is not handled, ERROR, widget add aborted\n"));
		return NULL;
	}
	table = lookup_widget(name);
	if (!table)
	{
		MTXDBG(CRITICAL,_("Table \"%s\" was not found, RuntimeSlider map or runtime datamap has a typo\n"),name);
		g_free(name);
		return NULL;
	}
	g_free(name);

	slider = (Rt_Slider *)g_malloc0(sizeof(Rt_Slider));
	slider->ctrl_name = g_strdup(ctrl_name);
	slider->tbl = tbl;
	slider->table_num = table_num;
	slider->row = row;
	slider->last = 0.0;
	slider->type = MTX_PROGRESS;
	slider->friendly_name = (gchar *) DATA_GET(object,"dlog_gui_name");
	slider->temp_dep = (GBOOLEAN)DATA_GET(object,"temp_dep");
	if ((gchar *)DATA_GET(object,"real_lower"))
		slider->lower = (GINT)strtol((gchar *)DATA_GET(object,"real_lower"),NULL,10);
	else
		MTXDBG(CRITICAL,_("No \"real_lower\" value defined for control name %s, datasource %s\n"),ctrl_name,source);
	if ((gchar *)DATA_GET(object,"real_upper"))
		slider->upper = (GINT)strtol((gchar *)DATA_GET(object,"real_upper"),NULL,10);
	else
		MTXDBG(CRITICAL,_("No \"real_upper\" value defined for control name %s, datasource %s\n"),ctrl_name,source);
	slider->history = (GArray *) DATA_GET(object,"history");
	slider->object = object;
	hbox = gtk_hbox_new(FALSE,5);

	label = gtk_label_new(NULL);
	slider->label = label;
	gtk_label_set_markup(GTK_LABEL(label),slider->friendly_name);
	gtk_misc_set_alignment(GTK_MISC(label),0.0,0.5);
	gtk_box_pack_start(GTK_BOX(hbox),label,TRUE,TRUE,0);

	label = gtk_entry_new();
	gtk_entry_set_has_frame(GTK_ENTRY(label),FALSE);
	gtk_entry_set_width_chars(GTK_ENTRY(label),6);
	gtk_entry_set_alignment(GTK_ENTRY(label),1);
	gtk_entry_set_editable(GTK_ENTRY(label),FALSE);
	/* PRELIGHT seems to not give the box as NORMAL does, not sure why */
	gtk_widget_modify_base(GTK_WIDGET(label),GTK_STATE_NORMAL,&gtk_widget_get_style(slider->label)->bg[GTK_STATE_PRELIGHT]);

	slider->textval = label;
	gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);

	if ((ident == RUNTIME_TAB) || (ident == VE3D_VIEWER_TAB))
	{
		if (((tbl+1) % 2) == 0)
			gtk_size_group_add_widget(size_group_right,hbox);
		else
			gtk_size_group_add_widget(size_group_left,hbox);
	}

	gtk_table_attach (GTK_TABLE (table),hbox,
			0,2,slider->row,(slider->row)+1,
			(GtkAttachOptions) (GTK_FILL),
			(GtkAttachOptions) (GTK_FILL), 0, 0);

	pbar = mtx_progress_bar_new();
	/* 1.1 Seconds peak hold time */
	mtx_progress_bar_set_hold_time(MTX_PROGRESS_BAR(pbar),1100);
	gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(pbar),
			GTK_PROGRESS_LEFT_TO_RIGHT);

	gtk_table_attach (GTK_TABLE (table),pbar,
			2,3,slider->row,(slider->row)+1,
			(GtkAttachOptions) (GTK_FILL|GTK_EXPAND|GTK_SHRINK),
			(GtkAttachOptions) (GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0);
	slider->pbar = pbar;

	slider->parent = table;
	gtk_widget_show_all(slider->parent);

	return slider;
}
GtkWidget* setup_sector_edit()
{
	sector_t* sector;
	if (selected_items.size() == 0)
		sector = map.sectors[hilight_item];
	else
		sector = map.sectors[selected_items[0]];

	// Init data
	sedit_data.f_height = sector->f_height;
	sedit_data.c_height = sector->c_height;
	sedit_data.f_tex = sector->f_tex;
	sedit_data.c_tex = sector->c_tex;
	sedit_data.light = sector->light;
	sedit_data.special = sector->special;
	sedit_data.tag = sector->tag;
	sedit_data.f_height_consistent = true;
	sedit_data.c_height_consistent = true;
	sedit_data.f_tex_consistent = true;
	sedit_data.c_tex_consistent = true;
	sedit_data.light_consistent = true;
	sedit_data.special_consistent = true;
	sedit_data.tag_consistent = true;

	// Check for inconsistency
	if (selected_items.size() > 1)
	{
		for (int a = 0; a < selected_items.size(); a++)
		{
			if (map.sectors[selected_items[a]]->f_height != sedit_data.f_height)
				sedit_data.f_height_consistent = false;

			if (map.sectors[selected_items[a]]->c_height != sedit_data.c_height)
				sedit_data.c_height_consistent = false;

			if (map.sectors[selected_items[a]]->f_tex != sedit_data.f_tex)
				sedit_data.f_tex_consistent = false;

			if (map.sectors[selected_items[a]]->c_tex != sedit_data.c_tex)
				sedit_data.c_tex_consistent = false;

			if (map.sectors[selected_items[a]]->light != sedit_data.light)
				sedit_data.light_consistent = false;

			if (map.sectors[selected_items[a]]->special != sedit_data.special)
				sedit_data.special_consistent = false;

			if (map.sectors[selected_items[a]]->tag != sedit_data.tag)
				sedit_data.tag_consistent = false;
		}
	}

	if (sedit_tbox_floor)
	{
		delete sedit_tbox_floor;
		sedit_tbox_floor = NULL;
	}

	if (sedit_tbox_ceil)
	{
		delete sedit_tbox_ceil;
		sedit_tbox_ceil = NULL;
	}

	GtkWidget* main_vbox = gtk_vbox_new(false, 0);
	GtkWidget* hbox = gtk_hbox_new(true, 0);
	gtk_box_pack_start(GTK_BOX(main_vbox), hbox, true, true, 0);

	// FLOOR FRAME
	GtkWidget *frame = gtk_frame_new("Floor");
	gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
	gtk_box_pack_start(GTK_BOX(hbox), frame, true, true, 0);
	GtkWidget *vbox = gtk_vbox_new(false, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
	gtk_container_add(GTK_CONTAINER(frame), vbox);

	GtkWidget *entry = gtk_entry_new();

	// Texture box
	sedit_tbox_floor = new tex_box_t(sedit_data.f_tex, 2, 2.0f, rgba_t(180, 180, 180, 255, 0));
	sedit_tbox_floor->set_size(128, 128);
	frame = gtk_aspect_frame_new(NULL, 0.5, 0.5, 1.0, true);
	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
	gtk_container_add(GTK_CONTAINER(frame), sedit_tbox_floor->widget);
	gtk_widget_set_events(sedit_tbox_floor->widget, GDK_BUTTON_PRESS_MASK);
	g_signal_connect(G_OBJECT(sedit_tbox_floor->widget), "button_press_event", G_CALLBACK(sedit_ftex_clicked), entry);
	gtk_box_pack_start(GTK_BOX(vbox), frame, true, true, 0);

	// Entry
	gtk_entry_set_alignment(GTK_ENTRY(entry), 0.5);
	gtk_widget_set_size_request(entry, 32, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_ftex_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(vbox), entry, false, false , 4);
	if (sedit_data.f_tex_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), sedit_data.f_tex.c_str());

	// Height
	GtkWidget *hbox2 = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, false, false, 4);
	GtkWidget *label = gtk_label_new("Height: ");
	gtk_box_pack_start(GTK_BOX(hbox2), label, false, false, 0);

	entry = gtk_entry_new();
	gtk_widget_set_size_request(entry, 32, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_fheight_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(hbox2), entry, true, true, 0);
	if (sedit_data.f_height_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), parse_string("%d", sedit_data.f_height).c_str());


	// CEILING FRAME
	frame = gtk_frame_new("Ceiling");
	gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
	gtk_box_pack_start(GTK_BOX(hbox), frame, true, true, 0);
	vbox = gtk_vbox_new(false, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
	gtk_container_add(GTK_CONTAINER(frame), vbox);

	entry = gtk_entry_new();

	// Texture box
	sedit_tbox_ceil = new tex_box_t(sedit_data.c_tex, 2, 2.0f, rgba_t(180, 180, 180, 255, 0));
	sedit_tbox_ceil->set_size(128, 128);
	frame = gtk_aspect_frame_new(NULL, 0.5, 0.5, 1.0, true);
	gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
	gtk_widget_set_events(sedit_tbox_ceil->widget, GDK_BUTTON_PRESS_MASK);
	g_signal_connect(G_OBJECT(sedit_tbox_ceil->widget), "button_press_event", G_CALLBACK(sedit_ctex_clicked), entry);
	gtk_container_add(GTK_CONTAINER(frame), sedit_tbox_ceil->widget);
	gtk_box_pack_start(GTK_BOX(vbox), frame, true, true, 0);

	// Entry
	gtk_entry_set_alignment(GTK_ENTRY(entry), 0.5);
	gtk_widget_set_size_request(entry, 32, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_ctex_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(vbox), entry, false, false , 4);
	if (sedit_data.c_tex_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), sedit_data.c_tex.c_str());

	// Height
	hbox2 = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox2, false, false, 4);
	label = gtk_label_new("Height: ");
	gtk_box_pack_start(GTK_BOX(hbox2), label, false, false, 0);

	entry = gtk_entry_new();
	gtk_widget_set_size_request(entry, 32, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_cheight_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(hbox2), entry, true, true, 0);
	if (sedit_data.c_height_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), parse_string("%d", sedit_data.c_height).c_str());


	// PROPERTIES FRAME
	frame = gtk_frame_new("Properties");
	gtk_container_set_border_width(GTK_CONTAINER(frame), 4);
	gtk_box_pack_start(GTK_BOX(main_vbox), frame, false, false, 0);
	vbox = gtk_vbox_new(false, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 4);
	gtk_container_add(GTK_CONTAINER(frame), vbox);

	// Special
	hbox = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 0);
	label = gtk_label_new("Special: ");
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(hbox), label, true, true, 0);

	entry = gtk_entry_new();
	gtk_widget_set_size_request(entry, 32, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_special_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), entry, false, false, 4);
	if (sedit_data.special_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), parse_string("%d", sedit_data.special).c_str());

	GtkWidget *button = gtk_button_new_with_label("Change");
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(sedit_change_special_clicked), entry);
	gtk_widget_set_size_request(button, 96, -1);
	gtk_box_pack_start(GTK_BOX(hbox), button, false, false, 0);

	// Tag
	hbox = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 4);
	label = gtk_label_new("Tag: ");
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(hbox), label, true, true, 0);

	entry = gtk_entry_new();
	gtk_widget_set_size_request(entry, 32, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_tag_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), entry, false, false, 4);
	if (sedit_data.tag_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), parse_string("%d", sedit_data.tag).c_str());

	button = gtk_button_new_with_label("Find Unused");
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(sedit_find_tag_clicked), entry);
	gtk_widget_set_size_request(button, 96, -1);
	gtk_box_pack_start(GTK_BOX(hbox), button, false, false, 0);

	// Light
	hbox = gtk_hbox_new(false, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, false, false, 0);
	label = gtk_label_new("Light Level: ");
	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
	gtk_box_pack_start(GTK_BOX(hbox), label, true, true, 0);

	entry = gtk_entry_new();
	gtk_widget_set_size_request(entry, 48, -1);
	g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(sedit_light_entry_changed), NULL);
	gtk_box_pack_start(GTK_BOX(hbox), entry, false, false, 0);
	if (sedit_data.light_consistent)
		gtk_entry_set_text(GTK_ENTRY(entry), parse_string("%d", sedit_data.light).c_str());

	return main_vbox;
}
Example #27
0
File: gcalc.cpp Project: ombt/ombt
int
main(int argc, char **argv)
{
    // support standard gtk options
    gtk_init(&argc, &argv);

    // check other options
    if (argc == 2 && strcmp(argv[1], "-v") == 0) verbose = true;

    // get get some color in the world
    GdkColor yellow;
    gdk_color_parse("yellow", &yellow);
    GdkColor red;
    gdk_color_parse("red", &red);
    GdkColor darkgray;
    gdk_color_parse("dark gray", &darkgray);
    GdkColor blue;
    gdk_color_parse("blue", &blue);
    GdkColor lightblue;
    gdk_color_parse("light blue", &lightblue);
    GdkColor lightgreen;
    gdk_color_parse("light green", &lightgreen);
    GdkColor magenta;
    gdk_color_parse("magenta", &magenta);
    GdkColor orange;
    gdk_color_parse("orange", &orange);
    GdkColor violet;
    gdk_color_parse("violet", &violet);

    // create main window and add trimmings
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &blue);
    gtk_window_set_default_size(GTK_WINDOW(window), 400, 200);
    gtk_window_set_title(GTK_WINDOW(window), "GCALC");
    gtk_container_set_border_width(GTK_CONTAINER(window), 20);

    // always handle exits
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), NULL);

    // use a table to organize
    GtkWidget *table = gtk_table_new(10, 9, FALSE);
    gtk_container_add(GTK_CONTAINER(window), table);
    gtk_table_set_row_spacings(GTK_TABLE(table), 2);
    gtk_table_set_col_spacings(GTK_TABLE(table), 2);

    // add text box at row 0
    text_entry = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(text_entry), 400);
    gtk_entry_set_editable(GTK_ENTRY(text_entry), editable);
    gtk_entry_set_alignment(GTK_ENTRY(text_entry), 0);
    gtk_table_attach_defaults(GTK_TABLE(table), text_entry, 0, 10, 0, 1);

    // add lines of separation
    GtkWidget *horizontal_line = gtk_hseparator_new();
    gtk_table_attach_defaults(GTK_TABLE(table), horizontal_line, 0, 10, 1, 2);
    GtkWidget *vertical_line = gtk_vseparator_new();
    gtk_table_attach_defaults(GTK_TABLE(table), vertical_line, 5, 6, 1, 10);

    // add row 1 buttons
    // add_button_at("quit", table, VOIDFN(gtk_main_quit), 1, 2, 2, 3, &darkgray);
    add_button_at("quit", table, VOIDFN(gtk_main_quit), 1, 2, 2, 3, &red);
#if 0
    add_button_at("(", table, VOIDFN(button_callback), 2, 3, 2, 3);
    add_button_at(")", table, VOIDFN(button_callback), 3, 4, 2, 3);
#endif
    add_button_at("swap", table, VOIDFN(swap_button_callback), 2, 3, 2, 3, &darkgray);
    add_button_at("C", table, VOIDFN(clear_button_callback), 3, 4, 2, 3, &darkgray);
    add_button_at("AC", table, VOIDFN(allclear_button_callback), 4, 5, 2, 3, &darkgray);
    add_button_at("MC", table, VOIDFN(memory_button_callback), 6, 7, 2, 3, &orange);
    add_button_at("M+", table, VOIDFN(memory_button_callback), 7, 8, 2, 3, &orange);
    add_button_at("M-", table, VOIDFN(memory_button_callback), 8, 9, 2, 3, &orange);
    add_button_at("MR", table, VOIDFN(memory_button_callback), 9, 10, 2, 3, &orange);


    // add row 2 buttons
    add_button_at("1/x", table, VOIDFN(unaryop_button_callback), 1, 2, 3, 4, &magenta);
    add_button_at("x^2", table, VOIDFN(unaryop_button_callback), 2, 3, 3, 4, &magenta);
    add_button_at("x^3", table, VOIDFN(unaryop_button_callback), 3, 4, 3, 4, &magenta);
    add_button_at("y^x", table, VOIDFN(binaryop_button_callback), 4, 5, 3, 4, &lightgreen);
    add_button_at("%", table, VOIDFN(unaryop_button_callback), 6, 7, 3, 4, &magenta);
    add_button_at("+/-", table, VOIDFN(unaryop_button_callback), 7, 8, 3, 4, &magenta);
    add_button_at("/", table, VOIDFN(binaryop_button_callback), 8, 9, 3, 4, &lightgreen);
    add_button_at("x", table, VOIDFN(binaryop_button_callback), 9, 10, 3, 4, &lightgreen);

    // add row 3 buttons
    add_button_at("x!", table, VOIDFN(unaryop_button_callback), 1, 2, 4, 5, &magenta);
    add_button_at("sqrt", table, VOIDFN(unaryop_button_callback), 2, 3, 4, 5, &magenta);
    add_button_at("y^1/x", table, VOIDFN(binaryop_button_callback), 3, 4, 4, 5, &lightgreen);
    add_button_at("log10", table, VOIDFN(unaryop_button_callback), 4, 5, 4, 5, &magenta);
    add_button_at("7", table, VOIDFN(number_button_callback), 6, 7, 4, 5, &yellow);
    add_button_at("8", table, VOIDFN(number_button_callback), 7, 8, 4, 5, &yellow);
    add_button_at("9", table, VOIDFN(number_button_callback), 8, 9, 4, 5, &yellow);
    add_button_at("-", table, VOIDFN(binaryop_button_callback), 9, 10, 4, 5, &lightgreen);

    // add row 4 buttons
    add_button_at("sin", table, VOIDFN(unaryop_button_callback), 1, 2, 5, 6, &magenta);
    add_button_at("cos", table, VOIDFN(unaryop_button_callback), 2, 3, 5, 6, &magenta);
    add_button_at("tan", table, VOIDFN(unaryop_button_callback), 3, 4, 5, 6, &magenta);
    add_button_at("ln", table, VOIDFN(unaryop_button_callback), 4, 5, 5, 6, &magenta);
    add_button_at("4", table, VOIDFN(number_button_callback), 6, 7, 5, 6, &yellow);
    add_button_at("5", table, VOIDFN(number_button_callback), 7, 8, 5, 6, &yellow);
    add_button_at("6", table, VOIDFN(number_button_callback), 8, 9, 5, 6, &yellow);
    add_button_at("+", table, VOIDFN(binaryop_button_callback), 9, 10, 5, 6, &lightgreen);

    // add row 5 buttons
    add_button_at("sinh", table, VOIDFN(unaryop_button_callback), 1, 2, 6, 7, &magenta);
    add_button_at("cosh", table, VOIDFN(unaryop_button_callback), 2, 3, 6, 7, &magenta);
    add_button_at("tanh", table, VOIDFN(unaryop_button_callback), 3, 4, 6, 7, &magenta);
    add_button_at("e^x", table, VOIDFN(unaryop_button_callback), 4, 5, 6, 7, &magenta);
    add_button_at("1", table, VOIDFN(number_button_callback), 6, 7, 6, 7, &yellow);
    add_button_at("2", table, VOIDFN(number_button_callback), 7, 8, 6, 7, &yellow);
    add_button_at("3", table, VOIDFN(number_button_callback), 8, 9, 6, 7, &yellow);
    add_button_at("=", table, VOIDFN(equal_button_callback), 9, 10, 6, 8, &lightblue);

    // add row 6 buttons
    add_button_at("asin", table, VOIDFN(unaryop_button_callback), 1, 2, 7, 8, &magenta);
    add_button_at("acos", table, VOIDFN(unaryop_button_callback), 2, 3, 7, 8, &magenta);
    add_button_at("atan", table, VOIDFN(unaryop_button_callback), 3, 4, 7, 8, &magenta);
    add_button_at("log2", table, VOIDFN(unaryop_button_callback), 4, 5, 7, 8, &magenta);
    add_button_at("0", table, VOIDFN(number_button_callback), 6, 8, 7, 8, &yellow);
    add_button_at(".", table, VOIDFN(number_button_callback), 8, 9, 7, 8, &lightblue);

    // add row 7 buttons
    add_button_at("asinh", table, VOIDFN(unaryop_button_callback), 1, 2, 8, 9, &magenta);
    add_button_at("acosh", table, VOIDFN(unaryop_button_callback), 2, 3, 8, 9, &magenta);
    add_button_at("atanh", table, VOIDFN(unaryop_button_callback), 3, 4, 8, 9, &magenta);
    add_button_at("2^x", table, VOIDFN(unaryop_button_callback), 4, 5, 8, 9, &magenta);

    // add row 8 buttons
    GSList *group = add_radio_button_at("rad", table, NULL, TRUE, VOIDFN(angle_button_callback), 1, 2, 9, 10, &violet);
    add_radio_button_at("deg", table, group, FALSE, VOIDFN(angle_button_callback), 2, 3, 9, 10, &violet);
    add_button_at("pi", table, VOIDFN(constant_button_callback), 3, 4, 9, 10, &violet);
    add_button_at("EE", table, VOIDFN(button_callback), 4, 5, 9, 10, &violet);

#if 0
    // add debug button
    add_button_at("dbg", table, VOIDFN(debug_button_callback), 9, 10, 9, 10, &violet);
#else
    // add menu item with choices to activate
    GtkWidget *menubar = gtk_menu_bar_new();

    GtkWidget *options = gtk_menu_item_new_with_label("options");
    gtk_menu_bar_append(GTK_MENU_BAR(menubar), options);

    GtkWidget *submenu= gtk_menu_new();
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(options), submenu);

    GtkWidget *dbgitem = gtk_check_menu_item_new_with_label("dbg");
    gtk_menu_append(GTK_MENU(submenu), dbgitem);
    g_signal_connect(G_OBJECT(dbgitem), "activate",
                     G_CALLBACK(checked_callback), (gpointer)"dbg");

    GtkWidget *edtitem = gtk_check_menu_item_new_with_label("edt");
    gtk_menu_append(GTK_MENU(submenu), edtitem);
    g_signal_connect(G_OBJECT(edtitem), "activate",
                     G_CALLBACK(checked_callback), (gpointer)"edt");

    gtk_table_attach_defaults(GTK_TABLE(table), menubar, 8, 10, 9, 10);
#endif

    // show main window and anything it contains
    gtk_widget_show_all(window);

    // start up main event loop
    gtk_main();

    // all done
    return 0;
}