5 #define YUILogComponent "gtk"
6 #include <yui/Libyui_config.h>
13 #define CHILD_INDENTATION 8
19 GtkWidget *m_containee;
24 GTK_TYPE_FRAME,
"shadow-type", GTK_SHADOW_NONE, NULL)
26 # if GTK_CHECK_VERSION (3, 14, 0)
27 m_containee = gtk_widget_new (GTK_TYPE_FRAME, NULL);
29 gtk_widget_set_margin_top (m_containee, 0);
30 gtk_widget_set_margin_bottom (m_containee, 0);
31 gtk_widget_set_margin_start (m_containee, CHILD_INDENTATION);
32 gtk_widget_set_margin_end (m_containee, 0);
34 m_containee = gtk_alignment_new (0, 0, 1, 1);
36 gtk_alignment_set_padding (GTK_ALIGNMENT (m_containee),
37 0, 0, CHILD_INDENTATION, 0);
40 gtk_widget_show (m_containee);
41 gtk_container_add (GTK_CONTAINER (getWidget()), m_containee);
44 virtual GtkWidget *getContainer()
45 {
return m_containee; }
50 static GtkWidget *findFirstFocusable (GtkContainer *container)
52 g_return_val_if_fail (container != NULL, NULL);
54 for (GList *l = gtk_container_get_children (container);
56 if (gtk_widget_get_can_focus (GTK_WIDGET(l->data)))
57 return GTK_WIDGET (l->data);
58 else if (GTK_IS_CONTAINER (l->data)) {
59 GtkWidget *ret = findFirstFocusable (GTK_CONTAINER (l->data));
69 frame_label_mnemonic_activate (GtkWidget *widget,
70 gboolean group_cycling,
71 GtkContainer *frame_container)
73 GtkWidget *focusable = findFirstFocusable (frame_container);
74 if (focusable == NULL) {
75 g_warning (
"no focusable widgets for mnemonic");
78 return gtk_widget_mnemonic_activate (focusable, group_cycling);
85 YGFrame (YWidget *parent,
const std::string &label)
86 : YFrame (NULL, label),
89 GtkWidget *label_widget = gtk_label_new_with_mnemonic (
"");
90 g_signal_connect (G_OBJECT (label_widget),
"mnemonic_activate",
91 G_CALLBACK (frame_label_mnemonic_activate),
93 YGUtils::setWidgetFont (GTK_WIDGET (label_widget), PANGO_STYLE_NORMAL,
94 PANGO_WEIGHT_BOLD, PANGO_SCALE_MEDIUM);
95 gtk_widget_show (label_widget);
96 gtk_frame_set_label_widget (GTK_FRAME (getWidget()), label_widget);
101 virtual void setLabel (
const std::string &_str)
103 GtkWidget *label = gtk_frame_get_label_widget (GTK_FRAME (getWidget()));
104 std::string str (YGUtils::mapKBAccel (_str));
105 gtk_label_set_text_with_mnemonic (GTK_LABEL (label), str.c_str());
106 YFrame::setLabel (_str);
109 YGWIDGET_IMPL_CONTAINER (YFrame)
112 virtual std::string getDebugLabel()
const
117 YFrame *YGWidgetFactory::createFrame (YWidget *parent,
const std::string &label)
118 {
return new YGFrame (parent, label); }
120 #include "YCheckBoxFrame.h"
125 YGCheckBoxFrame (YWidget *parent,
const std::string &label,
bool checked)
126 : YCheckBoxFrame (NULL, label, checked),
129 GtkWidget *button = gtk_check_button_new_with_mnemonic(
"");
130 YGUtils::setWidgetFont (gtk_bin_get_child (GTK_BIN (button)), PANGO_STYLE_NORMAL,
131 PANGO_WEIGHT_BOLD, PANGO_SCALE_MEDIUM);
132 gtk_widget_show_all (button);
133 gtk_frame_set_label_widget (GTK_FRAME (getWidget()), button);
137 connect (button,
"toggled", G_CALLBACK (toggled_cb),
this);
141 virtual void setLabel (
const std::string &_str)
143 GtkWidget *button = gtk_frame_get_label_widget (GTK_FRAME (getWidget()));
144 GtkLabel *label = GTK_LABEL (gtk_bin_get_child(GTK_BIN (button)));
146 std::string str (YGUtils::mapKBAccel (_str));
147 gtk_label_set_text_with_mnemonic (label, str.c_str());
148 YCheckBoxFrame::setLabel (_str);
153 GtkWidget *button = gtk_frame_get_label_widget (GTK_FRAME (getWidget()));
154 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
157 void setValue (
bool value)
160 GtkWidget *button = gtk_frame_get_label_widget (GTK_FRAME (getWidget()));
161 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), value);
165 virtual void doSetEnabled (
bool enabled)
167 GtkWidget *frame = getWidget();
169 gtk_widget_set_sensitive (frame, TRUE);
170 handleChildrenEnablement (value());
173 gtk_widget_set_sensitive (frame, FALSE);
174 YWidget::setChildrenEnabled (
false);
176 YWidget::setEnabled (enabled);
179 YGWIDGET_IMPL_CONTAINER (YCheckBoxFrame)
184 pThis->setEnabled (
true);
186 YGUI::ui()->sendEvent (
new YWidgetEvent (pThis, YEvent::ValueChanged));
190 YCheckBoxFrame *YGWidgetFactory::createCheckBoxFrame (
191 YWidget *parent,
const std::string &label,
bool checked)