GtkScaleButton
GtkScaleButton — A button which pops up a scale
👁 📚 官方网站学习资料
例子
#include <gtk/gtk.h>
static GtkWidget *create_window(const gint, const gint);
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkWidget *window;
GtkWidget *scaleButton;
GtkAdjustment *adjustment;
/// *** icon naming: https://developer.gnome.org/icon-naming-spec/
const char *icons[] = {"media-playback-start",
"media-playback-pause",
"media-playback-stop",
"media-record",
"media-seek-backward",
"media-seek-forward",
"media-skip-backward",
"media-skip-forward",
"object-flip-horizontal",
"object-flip-vertical",
NULL};
/// *** Create a Window
window = create_window(400, 500);
/// *** ScaleButton
scaleButton = gtk_scale_button_new(GTK_ICON_SIZE_DIALOG, 0.0, 10.0, 1.0, icons);
g_object_set(scaleButton, "parent", window, "margin", 50, NULL);
/// *** adjustment
adjustment = gtk_adjustment_new(5, 0, 10, 1, 2, 0);
/// ***
gtk_scale_button_set_adjustment(GTK_SCALE_BUTTON(scaleButton), adjustment);
gtk_widget_show_all(window);
gtk_main();
}
static GtkWidget *create_window(const gint w, const gint h)
{
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_set_default_size(GTK_WINDOW(window), w, h);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), "Hello GTK3");
gtk_container_set_border_width(GTK_CONTAINER(window), 50);
return window;
}
- 运行效果