static void gtk_tooltip_init (GtkTooltip *tooltip) { tooltip->timeout_id = 0; tooltip->browse_mode_timeout_id = 0; tooltip->browse_mode_enabled = FALSE; tooltip->keyboard_mode_enabled = FALSE; tooltip->current_window = NULL; tooltip->keyboard_widget = NULL; tooltip->tooltip_widget = NULL; tooltip->toplevel_window = NULL; tooltip->last_window = NULL; tooltip->window = g_object_ref (gtk_window_new (GTK_WINDOW_POPUP)); on_screen_changed (tooltip->window, NULL, tooltip); gtk_window_set_type_hint (GTK_WINDOW (tooltip->window), GDK_WINDOW_TYPE_HINT_TOOLTIP); gtk_widget_set_app_paintable (tooltip->window, TRUE); gtk_window_set_resizable (GTK_WINDOW (tooltip->window), FALSE); gtk_widget_set_name (tooltip->window, "gtk-tooltip"); g_signal_connect (tooltip->window, "hide", G_CALLBACK (gtk_tooltip_window_hide), tooltip); tooltip->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment), tooltip->window->style->ythickness, tooltip->window->style->ythickness, tooltip->window->style->xthickness, tooltip->window->style->xthickness); gtk_container_add (GTK_CONTAINER (tooltip->window), tooltip->alignment); gtk_widget_show (tooltip->alignment); g_signal_connect_swapped (tooltip->window, "style-set", G_CALLBACK (gtk_tooltip_window_style_set), tooltip); g_signal_connect_swapped (tooltip->window, "expose-event", G_CALLBACK (gtk_tooltip_paint_window), tooltip); tooltip->box = gtk_hbox_new (FALSE, tooltip->window->style->xthickness); gtk_container_add (GTK_CONTAINER (tooltip->alignment), tooltip->box); gtk_widget_show (tooltip->box); tooltip->image = gtk_image_new (); gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->image, FALSE, FALSE, 0); tooltip->label = gtk_label_new (""); gtk_label_set_line_wrap (GTK_LABEL (tooltip->label), TRUE); gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->label, FALSE, FALSE, 0); g_signal_connect (tooltip->window, "composited-changed", G_CALLBACK (on_composited_changed), tooltip); g_signal_connect (tooltip->window, "screen-changed", G_CALLBACK (on_screen_changed), tooltip); g_signal_connect (tooltip->window, "realize", G_CALLBACK (on_realized), tooltip); tooltip->custom_widget = NULL; }
TransparentSlider::TransparentSlider() : _redInit(0.5), _greenInit(1), _blueInit(0.5), _alphaInit(0.5), _buttonLabel("Close"), _box(Gtk::ORIENTATION_VERTICAL), _inner_box(Gtk::ORIENTATION_HORIZONTAL), _alignment(Gtk::ALIGN_END, Gtk::ALIGN_END, 0.0, 0.0), _button(_buttonLabel), _adjustmentRed(Gtk::Adjustment::create(_redInit, 0, 1.0, 0.1, 0.1, 0)), _adjustmentGreen(Gtk::Adjustment::create(_greenInit, 0, 1.0, 0.1, 0.1, 0)), _adjustmentBlue(Gtk::Adjustment::create(_blueInit, 0, 1.0, 0.1, 0.1, 0)), _adjustmentAlpha(Gtk::Adjustment::create(_alphaInit, 0, 1.0, 0.1, 0.1, 0)), _scaleRed(_adjustmentRed, Gtk::ORIENTATION_VERTICAL), _scaleGreen(_adjustmentGreen, Gtk::ORIENTATION_VERTICAL), _scaleBlue(_adjustmentBlue, Gtk::ORIENTATION_VERTICAL), _scaleAlpha(_adjustmentAlpha, Gtk::ORIENTATION_VERTICAL) { // Set up the top-level window. set_border_width(10); set_title("Color Slider Test"); set_default_size(400,400); set_decorated(false); add_events(Gdk::BUTTON_PRESS_MASK); set_position(Gtk::WIN_POS_CENTER); set_app_paintable(true); // Signal handlers signal_draw().connect(sigc::mem_fun(*this, &TransparentSlider::on_draw)); signal_screen_changed().connect(sigc::mem_fun(*this, &TransparentSlider::on_screen_changed)); signal_button_press_event().connect(sigc::mem_fun(*this, &TransparentSlider::on_window_clicked)); _button.signal_clicked().connect(sigc::mem_fun(*this, &TransparentSlider::on_button_clicked)); // Widgets // Add the box and pack it. add(_box); _box.pack_start(_inner_box); _box.pack_start(_alignment); // Pack the inner box _inner_box.set_homogeneous(); _inner_box.pack_start(_scaleRed); _inner_box.pack_start(_scaleGreen); _inner_box.pack_start(_scaleBlue); _inner_box.pack_start(_scaleAlpha); // Set up the scales: _scaleRed.set_digits(3); _scaleRed.set_inverted(); _scaleGreen.set_digits(3); _scaleGreen.set_inverted(); _scaleBlue.set_digits(3); _scaleBlue.set_inverted(); _scaleAlpha.set_digits(3); _scaleAlpha.set_inverted(); // Set up the close button _alignment.add(_button); _button.set_size_request(100, 10); // Initialize the process of drawing the colored part. on_screen_changed(get_screen()); // Show the window and all its children. show_all_children(); }