176 gtk_widget_set_visible (widg, TRUE);
178 gtk_widget_show_all (widg);
192 gtk_widget_set_visible (widg, FALSE);
194 gtk_widget_hide (widg);
210 if (GTK_IS_WIDGET(widg))
212 gtk_widget_set_sensitive (widg, sensitive);
229 gtk_container_add (GTK_CONTAINER(widg), child);
235 gtk_window_set_child ((GtkWindow *)widg, child);
243 gtk_scrolled_window_set_child ((GtkScrolledWindow *)widg, NULL);
244 gtk_scrolled_window_set_child ((GtkScrolledWindow *)widg, child);
248 gtk_viewport_set_child ((GtkViewport *)widg, child);
252 gtk_button_set_child ((GtkButton *)widg, child);
256 gtk_frame_set_child ((GtkFrame *)widg, child);
260 gtk_expander_set_child ((GtkExpander *)widg, child);
277void add_box_child_end (GtkWidget * widg, GtkWidget * child, gboolean expand, gboolean fill,
int padding)
281 gtk_box_append (GTK_BOX(widg), child);
283 gtk_box_pack_end (GTK_BOX(widg), child, expand, fill, padding);
299void add_box_child_start (
int orientation, GtkWidget * widg, GtkWidget * child, gboolean expand, gboolean fill,
int padding)
302 if (orientation == GTK_ORIENTATION_HORIZONTAL && padding)
304 gtk_box_append (GTK_BOX(widg),
markup_label (
" ", padding, -1, 0.0, 0.0));
306 else if (orientation == GTK_ORIENTATION_VERTICAL && padding > 10)
308 gtk_box_append (GTK_BOX(widg),
markup_label (
" ", -1, padding/2, 0.0, 0.0));
310 gtk_box_append (GTK_BOX(widg), child);
311 if (orientation == GTK_ORIENTATION_HORIZONTAL && padding)
313 gtk_box_append (GTK_BOX(widg),
markup_label (
" ", padding, -1, 0.0, 0.0));
315 else if (orientation == GTK_ORIENTATION_VERTICAL && padding > 10)
317 gtk_box_append (GTK_BOX(widg),
markup_label (
" ", -1, padding/2, 0.0, 0.0));
320 gtk_box_pack_start (GTK_BOX(widg), child, expand, fill, padding);
337 gtk_menu_item_set_submenu ((GtkMenuItem *)item, sub_menu);
351 return gtk_window_new ();
353 return gtk_window_new (GTK_WINDOW_TOPLEVEL);
385void add_widget_gesture_and_key_action (GtkWidget * widget,
386 gchar * cp_name, GCallback cp_handler, gpointer cp_data,
387 gchar * cr_name, GCallback cr_handler, gpointer cr_data,
388 gchar * kp_name, GCallback kp_handler, gpointer kp_data,
389 gchar * mo_name, GCallback mo_handler, gpointer mo_data,
390 gchar * sc_name, GCallback sc_handler, gpointer sc_data)
392 GtkGesture * gesture;
393 GtkEventController * key;
394 GtkEventController *
motion;
397 gesture = gtk_gesture_click_new ();
398 gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (gesture), cp_name);
399 gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
400 if (cp_handler) g_signal_connect (gesture,
"pressed", cp_handler, cp_data);
401 gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
405 gesture = gtk_gesture_click_new ();
406 gtk_event_controller_set_name (GTK_EVENT_CONTROLLER (gesture), cr_name);
407 gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
408 if (cr_handler) g_signal_connect (gesture,
"released", cr_handler, cr_data);
409 gtk_widget_add_controller (widget, GTK_EVENT_CONTROLLER (gesture));
413 key = gtk_event_controller_key_new ();
414 gtk_event_controller_set_name (key, kp_name);
415 if (kp_handler) g_signal_connect (key,
"key-pressed", kp_handler, kp_data);
416 gtk_widget_add_controller (widget, key);
420 motion = gtk_event_controller_motion_new ();
421 gtk_event_controller_set_name (
motion, mo_name);
422 if (mo_handler) g_signal_connect (
motion,
"motion", mo_handler, mo_data);
423 gtk_widget_add_controller (widget,
motion);
427 motion = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL);
428 gtk_event_controller_set_name (
motion, sc_name);
429 if (sc_handler) g_signal_connect (
motion,
"scroll", sc_handler, sc_data);
430 gtk_widget_add_controller (widget,
motion);
445GtkWidget *
create_win (gchar * str, GtkWidget * parent, gboolean modal, gboolean resiz)
450 gtk_window_set_resizable (GTK_WINDOW (win), TRUE);
452 gtk_window_set_attached_to (GTK_WINDOW (win), parent);
453 gtk_window_set_icon (GTK_WINDOW (win),
THETD);
456 gtk_window_set_modal (GTK_WINDOW(win), modal);
457 gtk_window_set_resizable (GTK_WINDOW(win), resiz);
458 gtk_window_set_destroy_with_parent (GTK_WINDOW (win), TRUE);
472void run_this_gtk_native_dialog (GtkNativeDialog * dial, GCallback handler, gpointer data)
474 gtk_native_dialog_set_modal (dial, TRUE);
475 if (handler) g_signal_connect (G_OBJECT(dial),
"response", handler, data);
476 gtk_native_dialog_show (dial);
494 gtk_window_set_modal (GTK_WINDOW(dial), TRUE);
495 if (handler) g_signal_connect (G_OBJECT(dial),
"response", handler, data);
512 GtkWidget * win = gtk_dialog_new_with_buttons (str, parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, _(
"_Close"), GTK_RESPONSE_CLOSE, NULL);
513 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
515 gtk_window_set_icon (GTK_WINDOW (win),
THETD);
531GtkWidget *
message_dialogmodal (gchar * message, gchar * title, GtkMessageType mtype, GtkButtonsType buttons, GtkWidget * parent)
536 win = gtk_message_dialog_new (GTK_WINDOW(parent), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, mtype, buttons, NULL);
540 win = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, mtype, buttons, NULL);
542 gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (win), message);
543 gtk_window_set_title (GTK_WINDOW(win), title);
544 gtk_window_set_resizable (GTK_WINDOW (win), FALSE);
546 gtk_window_set_icon (GTK_WINDOW (win),
THETD);
563 GtkWidget * dca = gtk_dialog_new_with_buttons (title, GTK_WINDOW(parent), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
564 "Cancel", GTK_RESPONSE_CANCEL,
"Apply", GTK_RESPONSE_APPLY, NULL);
565 gtk_window_set_resizable (GTK_WINDOW(dca), resiz);
567 gtk_window_set_icon (GTK_WINDOW (dca),
THETD);
584 gtk_window_resize (GTK_WINDOW(window),
x,
y);
586 gtk_window_set_default_size (GTK_WINDOW(window),
x,
y);
600 return gtk_editable_get_text (GTK_EDITABLE(entry));
602 return gtk_entry_get_text (entry);
616 gchar * value = g_strdup_printf(
"%d", intval);
618 gtk_editable_set_text (GTK_EDITABLE(entry), (
const gchar *)value);
620 gtk_entry_set_text (entry, (
const gchar *)value);
635 gchar * value = g_strdup_printf(
"%f", doubleval);
637 gtk_editable_set_text (GTK_EDITABLE(entry), (
const gchar *)value);
639 gtk_entry_set_text (entry, (
const gchar *)value);
654 gchar * value = g_strdup_printf(
"%15.10lf", doubleval);
656 gtk_editable_set_text (GTK_EDITABLE(entry), (
const gchar *)value);
658 gtk_entry_set_text (entry, (
const gchar *)value);
674 gtk_editable_set_text (GTK_EDITABLE(entry), (
const gchar *)
text);
676 gtk_entry_set_text (entry, (
const gchar *)
text);
689 gtk_text_view_set_monospace (GTK_TEXT_VIEW(view), TRUE);
703 gtk_label_set_xalign (GTK_LABEL (
lab),
ax);
704 gtk_label_set_yalign (GTK_LABEL (
lab),
ay);
716 if (GTK_IS_WIDGET(widg))
718 return gtk_widget_is_visible (widg);
745 float val,
int pos,
int round,
int size,
746 GCallback handler, GCallback scroll_handler, gpointer data)
749 hscale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
min,
max, delta);
750 gtk_scale_set_draw_value (GTK_SCALE(hscale), TRUE);
751 gtk_widget_set_size_request (hscale, size, -1);
752 gtk_scale_set_value_pos (GTK_SCALE(hscale), pos);
753 gtk_range_set_value (GTK_RANGE(hscale),
val);
754 gtk_range_set_round_digits (GTK_RANGE(hscale), round);
755 if (handler != NULL) g_signal_connect (G_OBJECT(hscale),
"value-changed", handler, data);
756 if (scroll_handler != NULL) g_signal_connect (G_OBJECT(hscale),
"change-value", scroll_handler, data);
779 float val,
int pos,
int round,
int size,
780 GCallback handler, GCallback scroll_handler, gpointer data)
783 vscale = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
min,
max, delta);
784 gtk_scale_set_draw_value (GTK_SCALE(vscale), TRUE);
785 gtk_scale_set_value_pos (GTK_SCALE(vscale), pos);
786 gtk_widget_set_size_request (vscale, size, size);
787 gtk_range_set_value (GTK_RANGE(vscale),
val);
788 gtk_range_set_round_digits (GTK_RANGE(vscale), round);
789 if (handler != NULL) g_signal_connect (G_OBJECT(vscale),
"value-changed", handler, data);
790 if (scroll_handler != NULL) g_signal_connect (G_OBJECT(vscale),
"change-value", scroll_handler, data);
803 return gtk_box_new (GTK_ORIENTATION_VERTICAL, spacing);
815 return gtk_box_new (GTK_ORIENTATION_HORIZONTAL, spacing);
828 return gtk_dialog_get_content_area (GTK_DIALOG(widg));
831 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, gtk_dialog_get_content_area (GTK_DIALOG(widg)),
vbox, TRUE, TRUE, 0);
849 gtk_layout_put (GTK_LAYOUT(
layout), child, x_pos, y_pos);
851 gtk_fixed_put (GTK_FIXED(
layout), child, x_pos, y_pos);
867 gtk_widget_set_size_request (
vbox, size_x, size_y);
884 layout = gtk_layout_new (NULL, NULL);
886 layout = gtk_fixed_new ();
888 gtk_widget_set_size_request (
layout,
x,
y);
902 gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combo),
text);
915 gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT(combo),
text);
925 return gtk_combo_box_text_new ();
937 GtkTextTagTable * textags = gtk_text_buffer_get_tag_table(buffer);
940 tag = gtk_text_tag_new (
"sans");
942 gtk_text_tag_table_add (textags,
tag);
943 g_object_unref (
tag);
946 tag = gtk_text_tag_new (
"monospace");
948 gtk_text_tag_table_add (textags,
tag);
949 g_object_unref (
tag);
952 tag = gtk_text_tag_new (
"default-size");
954 gtk_text_tag_table_add (textags,
tag);
955 g_object_unref (
tag);
958 tag = gtk_text_tag_new (
"underline");
959 g_object_set (
tag,
"size",
DEFAULT_FONT_SIZE * PANGO_SCALE,
"underline", PANGO_UNDERLINE_SINGLE, NULL);
960 gtk_text_tag_table_add (textags,
tag);
961 g_object_unref (
tag);
964 tag = gtk_text_tag_new (
"underline_double");
965 g_object_set (
tag,
"size",
DEFAULT_FONT_SIZE * PANGO_SCALE,
"underline", PANGO_UNDERLINE_DOUBLE, NULL);
966 gtk_text_tag_table_add (textags,
tag);
967 g_object_unref (
tag);
970 tag = gtk_text_tag_new (
"italic");
972 gtk_text_tag_table_add (textags,
tag);
973 g_object_unref (
tag);
976 tag = gtk_text_tag_new (
"bold");
978 gtk_text_tag_table_add (textags,
tag);
979 g_object_unref (
tag);
982 tag = gtk_text_tag_new (
"bold_italic");
984 "style", PANGO_STYLE_ITALIC,
985 "weight", PANGO_WEIGHT_BOLD, NULL);
986 gtk_text_tag_table_add (textags,
tag);
987 g_object_unref (
tag);
990 tag = gtk_text_tag_new (
"sup");
992 gtk_text_tag_table_add (textags,
tag);
993 g_object_unref (
tag);
996 tag = gtk_text_tag_new (
"sub");
998 gtk_text_tag_table_add (textags,
tag);
999 g_object_unref (
tag);
1002 tag = gtk_text_tag_new(
"justify-left");
1003 g_object_set(
tag,
"size",
DEFAULT_FONT_SIZE * PANGO_SCALE,
"justification", GTK_JUSTIFY_LEFT, NULL);
1004 gtk_text_tag_table_add(textags,
tag);
1005 g_object_unref(
tag);
1008 tag = gtk_text_tag_new(
"justify-center");
1009 g_object_set(
tag,
"size",
DEFAULT_FONT_SIZE * PANGO_SCALE,
"justification", GTK_JUSTIFY_CENTER, NULL);
1010 gtk_text_tag_table_add(textags,
tag);
1011 g_object_unref(
tag);
1014 tag = gtk_text_tag_new(
"justify-right");
1015 g_object_set(
tag,
"justification", GTK_JUSTIFY_RIGHT, NULL);
1016 gtk_text_tag_table_add(textags,
tag);
1017 g_object_unref (
tag);
1020 tag = gtk_text_tag_new(
"heading");
1022 "weight", PANGO_WEIGHT_BOLD,
1024 "justification", GTK_JUSTIFY_CENTER,
1025 "underline", PANGO_UNDERLINE_DOUBLE, NULL);
1026 gtk_text_tag_table_add(textags,
tag);
1027 g_object_unref (
tag);
1030 tag = gtk_text_tag_new(
"red");
1032 gtk_text_tag_table_add(textags,
tag);
1033 g_object_unref (
tag);
1036 tag = gtk_text_tag_new(
"orange");
1038 gtk_text_tag_table_add(textags,
tag);
1039 g_object_unref (
tag);
1042 tag = gtk_text_tag_new(
"yellow");
1044 gtk_text_tag_table_add(textags,
tag);
1045 g_object_unref (
tag);
1048 tag = gtk_text_tag_new(
"green");
1050 gtk_text_tag_table_add(textags,
tag);
1051 g_object_unref (
tag);
1054 tag = gtk_text_tag_new(
"light_green");
1056 gtk_text_tag_table_add(textags,
tag);
1057 g_object_unref (
tag);
1060 tag = gtk_text_tag_new(
"cyan");
1062 gtk_text_tag_table_add(textags,
tag);
1063 g_object_unref (
tag);
1066 tag = gtk_text_tag_new(
"blue");
1068 gtk_text_tag_table_add(textags,
tag);
1069 g_object_unref (
tag);
1072 tag = gtk_text_tag_new(
"pink");
1074 gtk_text_tag_table_add(textags,
tag);
1075 g_object_unref (
tag);
1078 tag = gtk_text_tag_new(
"violet");
1080 gtk_text_tag_table_add(textags,
tag);
1081 g_object_unref (
tag);
1084 tag = gtk_text_tag_new(
"grey_back");
1086 gtk_text_tag_table_add(textags,
tag);
1087 g_object_unref (
tag);
1090 tag = gtk_text_tag_new(
"bold_grey_back");
1092 "background",
"lightgrey",
1093 "weight", PANGO_WEIGHT_BOLD, NULL);
1094 gtk_text_tag_table_add(textags,
tag);
1095 g_object_unref (
tag);
1098 tag = gtk_text_tag_new (
"bold_red");
1100 "foreground",
"red",
1101 "weight", PANGO_WEIGHT_BOLD, NULL);
1102 gtk_text_tag_table_add (textags,
tag);
1103 g_object_unref (
tag);
1106 tag = gtk_text_tag_new (
"bold_blue");
1108 "foreground",
"blue",
1109 "weight", PANGO_WEIGHT_BOLD, NULL);
1110 gtk_text_tag_table_add (textags,
tag);
1111 g_object_unref (
tag);
1114 tag = gtk_text_tag_new (
"bold_green");
1116 "foreground",
"green",
1117 "weight", PANGO_WEIGHT_BOLD, NULL);
1118 gtk_text_tag_table_add (textags,
tag);
1119 g_object_unref (
tag);
1122 tag = gtk_text_tag_new (
"bold_orange");
1124 "foreground",
"orange",
1125 "weight", PANGO_WEIGHT_BOLD, NULL);
1126 gtk_text_tag_table_add (textags,
tag);
1127 g_object_unref (
tag);
1130 tag = gtk_text_tag_new (
"bold_pink");
1132 "foreground",
"pink",
1133 "weight", PANGO_WEIGHT_BOLD, NULL);
1134 gtk_text_tag_table_add (textags,
tag);
1135 g_object_unref (
tag);
1138 tag = gtk_text_tag_new (
"sub_italic");
1140 "style", PANGO_STYLE_ITALIC,
1141 "scale", .6,
"rise", -6000, NULL);
1142 gtk_text_tag_table_add (textags,
tag);
1143 g_object_unref (
tag);
1146 tag = gtk_text_tag_new (
"sub_bold");
1148 "weight", PANGO_WEIGHT_BOLD,
1149 "scale", .6,
"rise", -6000, NULL);
1150 gtk_text_tag_table_add (textags,
tag);
1151 g_object_unref (
tag);
1154 tag = gtk_text_tag_new (
"sup_bold");
1156 "weight", PANGO_WEIGHT_BOLD,
1157 "scale", .6,
"rise", 6000, NULL);
1158 gtk_text_tag_table_add (textags,
tag);
1159 g_object_unref (
tag);
1173 GtkTextBuffer * buffer;
1176 buffer = gtk_text_buffer_new (NULL);
1178 gtk_text_buffer_get_start_iter (buffer, &bStart);
1179 gtk_text_buffer_get_end_iter (buffer, &bEnd);
1180 gtk_text_buffer_delete (buffer, &bStart, &bEnd);
1181 if (
text != NULL) gtk_text_buffer_set_text (buffer,
text, -1);
1182 if (handler != NULL) g_signal_connect (G_OBJECT (buffer),
"changed", handler, data);
1199GtkWidget *
create_text_view (
int dimx,
int dimy,
int edit,
int mono, GCallback handler, gpointer data, gchar *
text)
1201 GtkWidget * tview = gtk_text_view_new ();
1202 gtk_text_view_set_buffer (GTK_TEXT_VIEW(tview),
add_buffer(handler, data,
text));
1203 gtk_widget_set_size_request (tview, dimx, dimy);
1204 gtk_text_view_set_editable (GTK_TEXT_VIEW(tview), edit);
1221static void convert_alpha (cairo_surface_t * surf, GdkPixbuf *
pix,
int src_x,
int src_y,
int width,
int height)
1224 guchar * src_data = cairo_image_surface_get_data (surf);
1225 int src_stride = cairo_image_surface_get_stride (surf);
1226 guchar * dest_data = gdk_pixbuf_get_pixels (
pix);
1227 int dest_stride = gdk_pixbuf_get_rowstride (
pix);
1229 src_data += src_stride * src_y + src_x * 4;
1231 for (
y = 0;
y < height;
y++) {
1232 guint32 *src = (guint32 *) src_data;
1234 for (
x = 0;
x < width;
x++) {
1235 guint alpha = src[
x] >> 24;
1239 dest_data[
x * 4 + 0] = 0;
1240 dest_data[
x * 4 + 1] = 0;
1241 dest_data[
x * 4 + 2] = 0;
1245 dest_data[
x * 4 + 0] = (((src[
x] & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
1246 dest_data[
x * 4 + 1] = (((src[
x] & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
1247 dest_data[
x * 4 + 2] = (((src[
x] & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
1249 dest_data[
x * 4 + 3] = alpha;
1252 src_data += src_stride;
1253 dest_data += dest_stride;
1266 int width = cairo_image_surface_get_width (surf);
1267 int height = cairo_image_surface_get_height (surf);
1268 GdkPixbuf *
pix = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width , height);
1269 convert_alpha (surf,
pix, 0, 0, width, height);
1283G_MODULE_EXPORT gboolean
to_activate_entry (GtkWidget * widg, GdkEventFocus * event, gpointer data)
1285 g_signal_emit_by_name (G_OBJECT(widg),
"activate", data);
1299 g_signal_emit_by_name (G_OBJECT(gtk_event_controller_get_widget((GtkEventController *)focus)),
"activate", data);
1314GtkWidget *
create_entry (GCallback handler,
int dim,
int cdim, gboolean key_release, gpointer data)
1316 GtkWidget * entry = gtk_entry_new ();
1317 gtk_widget_set_size_request (entry, dim, -1);
1319 gtk_editable_set_width_chars (GTK_EDITABLE(entry), 0);
1320 gtk_editable_set_max_width_chars (GTK_EDITABLE(entry), cdim);
1322 gtk_entry_set_width_chars (GTK_ENTRY(entry), 0);
1323 gtk_entry_set_max_width_chars (GTK_ENTRY(entry), cdim);
1325 gtk_entry_set_alignment (GTK_ENTRY(entry), 1.0);
1327 if (handler != NULL)
1329 g_signal_connect (G_OBJECT (entry),
"activate", handler, data);
1331 g_signal_connect (G_OBJECT (entry),
"focus-out-event", G_CALLBACK(
to_activate_entry), data);
1340 GtkEventController * focus = gtk_event_controller_focus_new ();
1341 gtk_event_controller_set_name (focus,
"focus-out");
1342 g_signal_connect (G_OBJECT(focus),
"leave", G_CALLBACK(
to_activate_entry), data);
1343 gtk_widget_add_controller (entry, focus);
1349 g_signal_connect (G_OBJECT (entry),
"key-release-event", G_CALLBACK(
to_activate_entry), data);
1367 return gtk_image_new_from_icon_name (stock_id);
1369 return gtk_image_new_from_icon_name (stock_id, GTK_ICON_SIZE_MENU);
1384 return (add_mnemo) ? gtk_menu_item_new_with_mnemonic (name) : gtk_menu_item_new_with_label (name);
1402 item = gtk_check_menu_item_new ();
1403 if (radio) gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM(item), TRUE);
1404 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item),
status);
1408 item = gtk_menu_item_new ();
1410 gtk_container_add (GTK_CONTAINER(item), widg);
1445 GtkWidget * icon = NULL;
1449 icon = gtk_image_new_from_pixbuf ((GdkPixbuf*)item_image);
1453 icon = gtk_image_new_from_pixbuf (
convert_to_pixbuf ((cairo_surface_t *)item_image));
1455 icon = gtk_image_new_from_surface ((cairo_surface_t *)item_image);
1459 icon = gtk_image_new_from_file ((
const gchar *)item_image);
1492 int icon_format, gpointer item_icon,
1493 GCallback handler, gpointer data,
1494 gboolean accel, guint key, GdkModifierType mod,
1495 gboolean check, gboolean radio, gboolean
status)
1497 GtkWidget * item = NULL;
1498 GtkWidget * icon = NULL;
1499 GtkWidget *
lab = NULL;
1505 lab = gtk_accel_label_new (name);
1507 gtk_widget_set_size_request (
lab, -1, -1);
1508 gtk_label_set_use_markup (GTK_LABEL(
lab), TRUE);
1509 gtk_accel_label_set_accel ((GtkAccelLabel *)
lab, key, mod);
1539 if (handler != NULL) g_signal_connect (G_OBJECT(item),
"activate", handler, data);
1540 if (menu != NULL) gtk_menu_shell_append ((GtkMenuShell *)menu, item);
1556GtkWidget *
add_advanced_item (GtkWidget * menu, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod)
1558 return gtk3_menu_item (menu,
"Advanced",
IMG_STOCK, (gpointer)
DPROPERTIES, handler, data, accel, key, mod, FALSE, FALSE, FALSE);
1570 gtk_menu_shell_append ((GtkMenuShell *)menu, gtk_separator_menu_item_new ());
1587 GtkWidget *
lab = gtk_label_new (
text);
1589 gtk_widget_set_size_request (
lab, dimx, dimy);
1590 gtk_label_set_use_markup (GTK_LABEL(
lab), TRUE);
1604 ColRGBA * new_col = g_malloc0 (num*
sizeof*new_col);
1606 for (i=0; i<num; i++) new_col[i] =
col[i];
1658 g_object_set (renderer,
"foreground-rgba", & colo,
"foreground-set", TRUE, NULL);
1659 g_object_set(renderer,
"weight", PANGO_WEIGHT_BOLD,
"weight-set", TRUE, NULL);
1663 g_object_set(renderer,
"foreground-set", FALSE,
"weight", FALSE, NULL);
1686 gtk_button_set_child (but,
hbox);
1690 gtk_button_set_child (but,
img);
1710 gtk_label_set_xalign (GTK_LABEL(
lab),
ax);
1711 gtk_label_set_yalign (GTK_LABEL(
lab),
ay);
1712 gtk_widget_set_size_request (
lab, dimx, dimy);
1713 gtk_label_set_use_markup (GTK_LABEL(
lab), TRUE);
1732 colorb = gtk_color_button_new_with_rgba (& colo);
1733 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER(colorb), alpha);
1734 if (handler != NULL) g_signal_connect (G_OBJECT(colorb),
"color-set", handler, data);
1735 gtk_widget_set_size_request (colorb, dimx, dimy);
1750GtkWidget *
font_button (gchar * font,
int dimx,
int dimy, GCallback handler, gpointer data)
1752 GtkWidget * fontb = gtk_font_button_new_with_font (font);
1753 g_signal_connect (G_OBJECT(fontb),
"font-set", handler, data);
1754 gtk_widget_set_size_request (fontb, dimx, dimy);
1772GtkWidget *
spin_button (GCallback handler,
double value,
double start,
double end,
double step,
int digits,
int dim, gpointer data)
1774 GtkWidget *
spin = gtk_spin_button_new_with_range (start, end,
step);
1775 gtk_spin_button_set_digits (GTK_SPIN_BUTTON(
spin), digits);
1777 gtk_editable_set_alignment (GTK_EDITABLE(
spin), 1.0);
1779 gtk_entry_set_alignment (GTK_ENTRY(
spin), 1.0);
1781 gtk_spin_button_set_value (GTK_SPIN_BUTTON(
spin), value);
1782 gtk_widget_set_size_request (
spin, dim, -1);
1783 if (handler != NULL) g_signal_connect (G_OBJECT (
spin),
"value-changed", handler, data);
1799GtkWidget *
check_button (gchar *
text,
int dimx,
int dimy, gboolean state, GCallback handler, gpointer data)
1801 GtkWidget * but = gtk_check_button_new ();
1805 gtk_check_button_set_label (GTK_CHECK_BUTTON(but),
text);
1806 GtkWidget *
lab = gtk_widget_get_last_child (but);
1812 gtk_widget_set_size_request (but, dimx, dimy);
1814 gtk_check_button_set_active (GTK_CHECK_BUTTON(but), state);
1816 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(but), state);
1818 if (handler != NULL) g_signal_connect (G_OBJECT(but),
"toggled", handler, data);
1834GtkWidget *
radio_button (gchar *
text,
int dimx,
int dimy, gboolean state, GCallback handler, gpointer data)
1838 but = gtk_toggle_button_new ();
1840 but = gtk_radio_button_new (NULL);
1843 gtk_widget_set_size_request (but, dimx, dimy);
1844 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(but), state);
1845 if (handler != NULL) g_signal_connect (G_OBJECT(but),
"toggled", handler, data);
1863GtkWidget *
create_button (gchar *
text,
int image_format, gchar *
image,
int dimx,
int dimy,
int relief, GCallback handler, gpointer data)
1867 but = (
text) ? gtk_button_new_with_label (
text) : gtk_button_new ();
1869 but = (
text && image_format ==
IMG_NONE) ? gtk_button_new_with_label (
text) : gtk_button_new ();
1872 gtk_widget_set_size_request (but, dimx, dimy);
1874 gtk_button_set_relief (GTK_BUTTON(but), relief);
1877 if (relief == GTK_RELIEF_NONE) gtk_button_set_has_frame (GTK_BUTTON(but), FALSE);
1879 if (handler != NULL)
1881 g_signal_connect (G_OBJECT (but),
"clicked", handler, data);
1897 gtk_image_set_from_icon_name (GTK_IMAGE(widg), icon);
1899 gtk_image_set_from_icon_name (GTK_IMAGE(widg), icon, GTK_ICON_SIZE_BUTTON);
1912GtkWidget *
abox (GtkWidget * box,
char *
lab,
int vspace)
1964 scroll = gtk_scrolled_window_new ();
1966 scroll = gtk_scrolled_window_new (NULL, NULL);
1967 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scroll), shadow);
1969 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1970 gtk_widget_set_size_request (scroll, dimx, dimy);
1972 if (box != NULL)
add_box_child_start (GTK_ORIENTATION_VERTICAL, box, scroll, TRUE, TRUE, 0);
1986 GtkWidget * expand = gtk_expander_new (name);
1988 if (file_img != NULL)
1990 GtkWidget *
img = gtk_image_new_from_file (file_img);
1991 gtk_widget_set_size_request (
img, 20, 20);
1995 gtk_expander_set_label_widget (GTK_EXPANDER(expand),
hbox);
2008 GtkCssProvider * provider = gtk_css_provider_new ();
2010#if GTK_MINOR_VERSION < 12
2011 gtk_css_provider_load_from_data (provider, css, -1);
2013 gtk_css_provider_load_from_string (provider, css);
2015 gtk_style_context_add_provider_for_display (gdk_display_get_default (),
2016 GTK_STYLE_PROVIDER(provider),
2017 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2019 gtk_css_provider_load_from_data (provider, css, -1, NULL);
2020 gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
2021 GTK_STYLE_PROVIDER(provider),
2022 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2024 g_object_unref (provider);
2038 if (GTK_IS_WIDGET(widg))
2042 gtk_widget_destroy (widg);
2068 gtk_window_destroy (GTK_WINDOW(dialog));
2086 gtk_native_dialog_destroy (dialog);
2087 g_object_unref (dialog);
2115 return gtk_file_chooser_get_files (chooser);
2125 return gtk_file_chooser_get_filenames (chooser);
2139 return g_file_get_parse_name (gtk_file_chooser_get_file (chooser));
2141 return gtk_file_chooser_get_filename (chooser);
2155 return g_file_get_parse_name (gtk_file_chooser_get_current_folder (chooser));
2157 return gtk_file_chooser_get_current_folder (chooser);
2171 GFile * default_file_for_saving = g_file_new_for_path (filename);
2172 gboolean
res = gtk_file_chooser_set_file (chooser, default_file_for_saving, NULL);
2175 gchar * str = g_strdup_printf (
"Impossible to locate file: %s", filename);
2191 gtk_file_chooser_set_current_folder (chooser, g_file_new_for_path (
"./"), NULL);
2193 gtk_file_chooser_set_current_folder (chooser,
"");
2208GtkFileChooserNative *
create_file_chooser (
const gchar * title, GtkWindow * parent, GtkFileChooserAction act,
const gchar * act_name)
2210 return gtk_file_chooser_native_new (title, parent, act, act_name,
"Cancel");
2223GtkWidget *
create_file_chooser (
const gchar * title, GtkWindow * parent, GtkFileChooserAction act,
const gchar * act_name)
2225 return gtk_file_chooser_dialog_new (title, parent, act,
"Cancel", GTK_RESPONSE_CANCEL, act_name, GTK_RESPONSE_ACCEPT, NULL);
2239 gtk_color_chooser_get_rgba (colob, &
col);
2253 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER(color_win), &
col);
2268 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER(color_win), & colo);
2288 gtk_popover_set_has_arrow (GTK_POPOVER(
pop), FALSE);
2289 gtk_popover_set_pointing_to (GTK_POPOVER(
pop), & rect);
2290 gtk_popover_popup (GTK_POPOVER(
pop));
2304 gtk_menu_popup_at_pointer (GTK_MENU (widg), event);
2318 return (GtkWidget *)gtk_widget_get_root (widg);
2320 return gtk_widget_get_toplevel (widg);
2390 g_signal_connect (G_OBJECT (widg),
"close-request", handler, data);
2392 g_signal_connect (G_OBJECT (widg),
"delete-event", handler, data);
2406 return gtk_widget_get_allocated_width (widg);
2408 return gtk_widget_get_width (widg);
2422 return gtk_widget_get_allocated_height (widg);
2424 return gtk_widget_get_height (widg);
GMainLoop * Event_loop[5]
Global variable declarations Global convenience function declarations Global data structure defin...
GtkWidget * create_menu_item_from_widget(GtkWidget *widg, gboolean check, gboolean radio, gboolean status)
GtkWidget * gtk3_menu_item(GtkWidget *menu, gchar *name, int icon_format, gpointer item_icon, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod, gboolean check, gboolean radio, gboolean status)
GtkWidget * add_advanced_item(GtkWidget *menu, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod)
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
#define DEFAULT_FONT_SIZE
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
void add_menu_separator(GtkWidget *menu)
GtkWidget * menu_item_new_with_submenu(gchar *name, gboolean active, GtkWidget *sub_menu)
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
gboolean spin(gpointer data)
spin
GtkWidget * dialog_cancel_apply(gchar *title, GtkWidget *parent, gboolean resiz)
create a dialog modal offering a choice to apply something or not
GdkPixbuf * convert_to_pixbuf(cairo_surface_t *surf)
convert cairo surface to GdkPixbuf
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
void set_renderer_color(int tocol, GtkCellRenderer *renderer, ColRGBA col)
set the color of a GtkCellRenderer
void adjust_label(GtkWidget *lab, int dimx, int dimy, float ax, float ay)
adjust the text position, and widget size of a GtkLabel
ColRGBA gdkrgba_to_rgba(GdkRGBA colgdk)
convert GdkRGBA color to ColRGBA color
GtkWidget * font_button(gchar *font, int dimx, int dimy, GCallback handler, gpointer data)
create a font selection button
GtkWidget * create_text_view(int dimx, int dimy, int edit, int mono, GCallback handler, gpointer data, gchar *text)
create a GtkTextView and display some text
GtkTextBuffer * add_buffer(GCallback handler, gpointer data, gchar *text)
create a GtkTextBuffer
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
void set_color_chooser_color(GtkWidget *color_win, ColRGBA col)
set the color of a color selection window
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
void resize_this_window(GtkWidget *window, int x, int y)
resize this GtkWindow
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
ColRGBA get_window_color(GtkWidget *color_win)
get the ColRGBA color from a color selection window
GtkWidget * add_vbox_to_layout(GtkWidget *layout, int size_x, int size_y)
Insert a vertical GtkBox in a GtkLatout then send back the GtkBox.
int get_widget_height(GtkWidget *widg)
retrive GtkWidget height
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
GdkRGBA colrgba_togtkrgba(ColRGBA col)
convert ColRGBA color to GdkRGBA color
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
G_MODULE_EXPORT gboolean hide_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
hide a GtkWindow
void pop_menu_at_pointer(GtkWidget *widg, GdkEvent *event)
popup a menu at pointer location
gboolean file_chooser_set_file_name(GtkFileChooser *chooser, gchar *filename)
set file name in a GtkFilechooser
G_MODULE_EXPORT gboolean destroy_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
destroy a GtkWindow
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
int get_widget_width(GtkWidget *widg)
retrive GtkWidget width
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
GtkWidget * create_vscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an vertical scale GtkWidget
void layout_add_widget(GtkWidget *layout, GtkWidget *child, int x_pos, int y_pos)
Add a GtkWidget in a GtkLayout.
GtkWidget * fbox(GtkWidget *box, char *lab)
gchar * file_chooser_get_current_folder(GtkFileChooser *chooser)
get the current folder for a GtkFileChooser
GtkWidget * radio_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a radio button
GtkWidget * spin_button(GCallback handler, double value, double start, double end, double step, int digits, int dim, gpointer data)
create a spin button
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
G_MODULE_EXPORT void to_activate_entry(GtkEventControllerFocus *focus, gpointer data)
GtkEntry activate signal managment.
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
GtkWidget * get_top_level(GtkWidget *widg)
get the top level container, window, of a widget
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
void button_set_image(GtkButton *but, gchar *text, int format, gpointer image)
Add an image to a GtkButton.
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
GtkWidget * cbox(GtkWidget *box, char *lab)
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
void text_view_set_monospace(GtkWidget *view)
set the font of a GtkTextView as monospace
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
GtkWidget * new_gtk_window()
create a new GtkWindow
GtkWidget * create_image_from_data(int format, gpointer item_image)
create Gtk image for data
void gtk_label_align(GtkWidget *lab, float ax, float ay)
set text alignment in a GtkLabel
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
GtkWidget * create_hscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an horizontal scale GtkWidget
GtkWidget * bbox(GtkWidget *box, char *lab)
void add_box_child_end(GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the end position.
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
void provide_gtk_css(gchar *css)
create a css provider based on the css data
GSList * file_chooser_get_file_names(GtkFileChooser *chooser)
create a file list from files selected using a GtkFileChooser
void setup_text_tags(GtkTextBuffer *buffer)
prepare the avialable text tags for the GtkTextBuffer
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
GtkWidget * message_dialogmodal(gchar *message, gchar *title, GtkMessageType mtype, GtkButtonsType buttons, GtkWidget *parent)
create a modal (cannot be ignored) message window
void combo_text_prepend(GtkWidget *combo, gchar *text)
prepend text in GtkComboBox widget
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
ColRGBA * duplicate_color(int num, ColRGBA *col)
duplicate a ColRGBA pointer
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
GtkWidget * create_expander(gchar *name, gchar *file_img)
create GtkExpander
GtkWidget * create_file_chooser(const gchar *title, GtkWindow *parent, GtkFileChooserAction act, const gchar *act_name)
create a GtkFileChooser, utility to select file(s)
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
void show_the_widgets(GtkWidget *widg)
show GtkWidget
void update_entry_long_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as long double
void show_error(char *error, int val, GtkWidget *win)
show error message
Messaging function declarations.