Get things building on Gtk+ 2 again.
This commit is contained in:
parent
a1fa47a978
commit
1aaa2d84e3
@ -42,21 +42,25 @@ bool gtk_shader_parameters_dialog (GtkWindow *parent)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
|
|
||||||
gtk_widget_set_size_request(dialog, 640, 480);
|
gtk_widget_set_size_request(dialog, 640, 480);
|
||||||
|
|
||||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))),
|
||||||
|
scrolled_window);
|
||||||
|
|
||||||
|
#if GTK_MAJOR_VERSION >= 3
|
||||||
|
|
||||||
gtk_widget_set_hexpand (scrolled_window, TRUE);
|
gtk_widget_set_hexpand (scrolled_window, TRUE);
|
||||||
gtk_widget_set_vexpand (scrolled_window, TRUE);
|
gtk_widget_set_vexpand (scrolled_window, TRUE);
|
||||||
gtk_widget_set_margin_start (scrolled_window, 5);
|
gtk_widget_set_margin_start (scrolled_window, 5);
|
||||||
gtk_widget_set_margin_end (scrolled_window, 5);
|
gtk_widget_set_margin_end (scrolled_window, 5);
|
||||||
gtk_widget_set_margin_top (scrolled_window, 5);
|
gtk_widget_set_margin_top (scrolled_window, 5);
|
||||||
gtk_widget_set_margin_bottom (scrolled_window, 5);
|
gtk_widget_set_margin_bottom (scrolled_window, 5);
|
||||||
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))),
|
|
||||||
scrolled_window);
|
|
||||||
GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||||
GtkWidget *grid = gtk_grid_new ();
|
GtkWidget *grid = gtk_grid_new ();
|
||||||
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
|
gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
|
||||||
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
|
||||||
gtk_container_add (GTK_CONTAINER (vbox), grid);
|
gtk_container_add (GTK_CONTAINER (vbox), grid);
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window), vbox);
|
gtk_container_add (GTK_CONTAINER (scrolled_window), vbox);
|
||||||
|
|
||||||
@ -80,10 +84,10 @@ bool gtk_shader_parameters_dialog (GtkWindow *parent)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkWidget *scale = gtk_hscale_new_with_range (p->min, p->max, p->step);
|
GtkWidget *scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, p->min, p->max, p->step);
|
||||||
gtk_widget_set_hexpand (scale, TRUE);
|
gtk_widget_set_hexpand (scale, TRUE);
|
||||||
gtk_grid_attach (GTK_GRID (grid), scale, 1, i, 1, 1);
|
gtk_grid_attach (GTK_GRID (grid), scale, 1, i, 1, 1);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT);
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_LEFT);
|
||||||
gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
|
gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
|
||||||
gtk_scale_set_digits (GTK_SCALE (scale), 3);
|
gtk_scale_set_digits (GTK_SCALE (scale), 3);
|
||||||
gtk_range_set_value (GTK_RANGE (scale), p->val);
|
gtk_range_set_value (GTK_RANGE (scale), p->val);
|
||||||
@ -97,6 +101,53 @@ bool gtk_shader_parameters_dialog (GtkWindow *parent)
|
|||||||
value_holders[i] = scale;
|
value_holders[i] = scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
GtkWidget *vbox = gtk_vbox_new (FALSE, 5);
|
||||||
|
GtkWidget *table = gtk_table_new (params->size (), 2, FALSE);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (table), 12);
|
||||||
|
gtk_container_add (GTK_CONTAINER (vbox), table);
|
||||||
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), vbox);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 5);
|
||||||
|
|
||||||
|
GtkWidget **value_holders = new GtkWidget*[params->size()];
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < params->size(); i++)
|
||||||
|
{
|
||||||
|
GLSLParam *p = &(*params)[i];
|
||||||
|
GtkWidget *label = gtk_label_new (p->name);
|
||||||
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i + 1, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
|
|
||||||
|
if (p->min == 0.0 && p->max == 1.0 && p->step == 1.0)
|
||||||
|
{
|
||||||
|
GtkWidget *check = gtk_check_button_new ();
|
||||||
|
gtk_table_attach (GTK_TABLE (table), check, 1, 2, i, i + 1, GTK_FILL, GTK_FILL, 0, 0);
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), (int) p->val);
|
||||||
|
value_holders[i] = check;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GtkWidget *scale = gtk_hscale_new_with_range (p->min, p->max, p->step);
|
||||||
|
gtk_table_attach (GTK_TABLE (table), scale, 1, 2, i, i + 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0);
|
||||||
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_LEFT);
|
||||||
|
gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
|
||||||
|
gtk_scale_set_digits (GTK_SCALE (scale), 3);
|
||||||
|
gtk_range_set_value (GTK_RANGE (scale), p->val);
|
||||||
|
g_signal_connect_data (G_OBJECT (scale),
|
||||||
|
"value-changed",
|
||||||
|
G_CALLBACK (value_changed),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(GConnectFlags) 0);
|
||||||
|
|
||||||
|
value_holders[i] = scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gtk_widget_show_all (dialog);
|
gtk_widget_show_all (dialog);
|
||||||
int response = gtk_dialog_run (GTK_DIALOG(dialog));
|
int response = gtk_dialog_run (GTK_DIALOG(dialog));
|
||||||
|
Loading…
Reference in New Issue
Block a user