^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifdef HAVE_CONFIG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # include <config.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "lkc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "images.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <glade/glade.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <gtk/gtk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <glib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <gdk/gdkkeysyms.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <strings.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) //#define DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) OPT_NORMAL, OPT_ALL, OPT_PROMPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static gint view_mode = FULL_VIEW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static gboolean show_name = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static gboolean show_range = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static gboolean show_value = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static gboolean resizeable = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static int opt_mode = OPT_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) GtkWidget *main_wnd = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) GtkWidget *tree1_w = NULL; // left frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) GtkWidget *tree2_w = NULL; // right frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) GtkWidget *text_w = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) GtkWidget *hpaned = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) GtkWidget *vpaned = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) GtkWidget *back_btn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) GtkWidget *save_btn = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) GtkWidget *save_menu_item = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) GtkTextTag *tag1, *tag2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) GdkColor color;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) GtkTreeStore *tree1, *tree2, *tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) GtkTreeModel *model1, *model2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static GtkTreeIter *parents[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static gint indent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static struct menu *current; // current node for SINGLE view
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static struct menu *browsed; // browsed node for SPLIT view
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) COL_OPTION, COL_NAME, COL_NO, COL_MOD, COL_YES, COL_VALUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) COL_MENU, COL_COLOR, COL_EDIT, COL_PIXBUF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) COL_PIXVIS, COL_BTNVIS, COL_BTNACT, COL_BTNINC, COL_BTNRAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) COL_NUMBER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static void display_list(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static void display_tree(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static void display_tree_part(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static void update_tree(struct menu *src, GtkTreeIter * dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static gchar **fill_row(struct menu *menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static void conf_changed(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* Helping/Debugging Functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) static const char *dbg_sym_flags(int val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static char buf[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) bzero(buf, 256);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (val & SYMBOL_CONST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) strcat(buf, "const/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (val & SYMBOL_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) strcat(buf, "check/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (val & SYMBOL_CHOICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) strcat(buf, "choice/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if (val & SYMBOL_CHOICEVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) strcat(buf, "choiceval/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (val & SYMBOL_VALID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) strcat(buf, "valid/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (val & SYMBOL_OPTIONAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) strcat(buf, "optional/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) if (val & SYMBOL_WRITE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) strcat(buf, "write/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (val & SYMBOL_CHANGED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) strcat(buf, "changed/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (val & SYMBOL_NO_WRITE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) strcat(buf, "no_write/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) buf[strlen(buf) - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static void replace_button_icon(GladeXML *xml, GdkDrawable *window,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) GtkStyle *style, gchar *btn_name, gchar **xpm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) GdkPixmap *pixmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) GdkBitmap *mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) GtkToolButton *button;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) GtkWidget *image;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) pixmap = gdk_pixmap_create_from_xpm_d(window, &mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) &style->bg[GTK_STATE_NORMAL],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) xpm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) image = gtk_image_new_from_pixmap(pixmap, mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) gtk_widget_show(image);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) gtk_tool_button_set_icon_widget(button, image);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /* Main Window Initialization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static void init_main_window(const gchar *glade_file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) GladeXML *xml;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) GtkWidget *widget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) GtkTextBuffer *txtbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) GtkStyle *style;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) xml = glade_xml_new(glade_file, "window1", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) if (!xml)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) g_error("GUI loading failed !\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) glade_xml_signal_autoconnect(xml);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) main_wnd = glade_xml_get_widget(xml, "window1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) hpaned = glade_xml_get_widget(xml, "hpaned1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) vpaned = glade_xml_get_widget(xml, "vpaned1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) tree1_w = glade_xml_get_widget(xml, "treeview1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) tree2_w = glade_xml_get_widget(xml, "treeview2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) text_w = glade_xml_get_widget(xml, "textview3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) back_btn = glade_xml_get_widget(xml, "button1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) gtk_widget_set_sensitive(back_btn, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) widget = glade_xml_get_widget(xml, "show_name1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) show_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) widget = glade_xml_get_widget(xml, "show_range1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) widget = glade_xml_get_widget(xml, "show_data1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) show_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) save_btn = glade_xml_get_widget(xml, "button3");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) save_menu_item = glade_xml_get_widget(xml, "save1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) conf_set_changed_callback(conf_changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) style = gtk_widget_get_style(main_wnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) widget = glade_xml_get_widget(xml, "toolbar1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) replace_button_icon(xml, main_wnd->window, style,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) "button4", (gchar **) xpm_single_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) replace_button_icon(xml, main_wnd->window, style,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) "button5", (gchar **) xpm_split_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) replace_button_icon(xml, main_wnd->window, style,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) "button6", (gchar **) xpm_tree_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) "foreground", "red",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) "weight", PANGO_WEIGHT_BOLD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) tag2 = gtk_text_buffer_create_tag(txtbuf, "mytag2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /*"style", PANGO_STYLE_OBLIQUE, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) gtk_widget_show(main_wnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static void init_tree_model(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) gint i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) tree = tree2 = gtk_tree_store_new(COL_NUMBER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) G_TYPE_STRING, G_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) G_TYPE_STRING, G_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) G_TYPE_STRING, G_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) G_TYPE_POINTER, GDK_TYPE_COLOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) G_TYPE_BOOLEAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) model2 = GTK_TREE_MODEL(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) for (parents[0] = NULL, i = 1; i < 256; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) tree1 = gtk_tree_store_new(COL_NUMBER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) G_TYPE_STRING, G_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) G_TYPE_STRING, G_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) G_TYPE_STRING, G_TYPE_STRING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) G_TYPE_POINTER, GDK_TYPE_COLOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) G_TYPE_BOOLEAN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) model1 = GTK_TREE_MODEL(tree1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static void init_left_tree(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) GtkTreeView *view = GTK_TREE_VIEW(tree1_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) GtkCellRenderer *renderer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) GtkTreeSelection *sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) gtk_tree_view_set_model(view, model1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) gtk_tree_view_set_headers_visible(view, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) gtk_tree_view_set_rules_hint(view, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) column = gtk_tree_view_column_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) gtk_tree_view_append_column(view, column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) gtk_tree_view_column_set_title(column, "Options");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) renderer = gtk_cell_renderer_toggle_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) renderer, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) "active", COL_BTNACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) "inconsistent", COL_BTNINC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) "visible", COL_BTNVIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) "radio", COL_BTNRAD, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) renderer, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) "text", COL_OPTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) sel = gtk_tree_view_get_selection(view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) gtk_widget_realize(tree1_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static void renderer_edited(GtkCellRendererText * cell,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) const gchar * path_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) const gchar * new_text, gpointer user_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static void init_right_tree(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) GtkTreeView *view = GTK_TREE_VIEW(tree2_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) GtkCellRenderer *renderer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) GtkTreeSelection *sel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) gint i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) gtk_tree_view_set_model(view, model2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) gtk_tree_view_set_headers_visible(view, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) gtk_tree_view_set_rules_hint(view, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) column = gtk_tree_view_column_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) gtk_tree_view_append_column(view, column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) gtk_tree_view_column_set_title(column, "Options");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) renderer = gtk_cell_renderer_pixbuf_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) renderer, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) "pixbuf", COL_PIXBUF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) "visible", COL_PIXVIS, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) renderer = gtk_cell_renderer_toggle_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) renderer, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) "active", COL_BTNACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) "inconsistent", COL_BTNINC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) "visible", COL_BTNVIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) "radio", COL_BTNRAD, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) renderer, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) "text", COL_OPTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) gtk_tree_view_insert_column_with_attributes(view, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) "Name", renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) "text", COL_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) gtk_tree_view_insert_column_with_attributes(view, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) "N", renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) "text", COL_NO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) gtk_tree_view_insert_column_with_attributes(view, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) "M", renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) "text", COL_MOD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) gtk_tree_view_insert_column_with_attributes(view, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) "Y", renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) "text", COL_YES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) gtk_tree_view_insert_column_with_attributes(view, -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) "Value", renderer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) "text", COL_VALUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) "editable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) COL_EDIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) "foreground-gdk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) COL_COLOR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) g_signal_connect(G_OBJECT(renderer), "edited",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) G_CALLBACK(renderer_edited), NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) column = gtk_tree_view_get_column(view, COL_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) gtk_tree_view_column_set_visible(column, show_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) column = gtk_tree_view_get_column(view, COL_NO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) gtk_tree_view_column_set_visible(column, show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) column = gtk_tree_view_get_column(view, COL_MOD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) gtk_tree_view_column_set_visible(column, show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) column = gtk_tree_view_get_column(view, COL_YES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) gtk_tree_view_column_set_visible(column, show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) column = gtk_tree_view_get_column(view, COL_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) gtk_tree_view_column_set_visible(column, show_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (resizeable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) for (i = 0; i < COL_VALUE; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) column = gtk_tree_view_get_column(view, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) gtk_tree_view_column_set_resizable(column, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) sel = gtk_tree_view_get_selection(view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* Utility Functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static void text_insert_help(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) GtkTextBuffer *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) GtkTextIter start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) const char *prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct gstr help = str_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) menu_get_ext_help(menu, &help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) gtk_text_buffer_get_bounds(buffer, &start, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) gtk_text_buffer_delete(buffer, &start, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) gtk_text_buffer_get_end_iter(buffer, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) gtk_text_buffer_get_end_iter(buffer, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) str_free(&help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) static void text_insert_msg(const char *title, const char *message)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) GtkTextBuffer *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) GtkTextIter start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) const char *msg = message;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) gtk_text_buffer_get_bounds(buffer, &start, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) gtk_text_buffer_delete(buffer, &start, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) gtk_text_buffer_get_end_iter(buffer, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) gtk_text_buffer_insert_with_tags(buffer, &end, title, -1, tag1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) gtk_text_buffer_get_end_iter(buffer, &end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) gtk_text_buffer_insert_with_tags(buffer, &end, msg, -1, tag2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) /* Main Windows Callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) void on_save_activate(GtkMenuItem * menuitem, gpointer user_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) GtkWidget *dialog, *label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) gint result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) if (!conf_get_changed())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) dialog = gtk_dialog_new_with_buttons("Warning !",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) GTK_WINDOW(main_wnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) (GtkDialogFlags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) (GTK_DIALOG_MODAL |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) GTK_DIALOG_DESTROY_WITH_PARENT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) GTK_STOCK_OK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) GTK_RESPONSE_YES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) GTK_STOCK_NO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) GTK_RESPONSE_NO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) GTK_STOCK_CANCEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) GTK_RESPONSE_CANCEL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) gtk_dialog_set_default_response(GTK_DIALOG(dialog),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) GTK_RESPONSE_CANCEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) label = gtk_label_new("\nSave configuration ?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) gtk_widget_show(label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) result = gtk_dialog_run(GTK_DIALOG(dialog));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) switch (result) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) case GTK_RESPONSE_YES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) on_save_activate(NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) case GTK_RESPONSE_NO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) case GTK_RESPONSE_CANCEL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) case GTK_RESPONSE_DELETE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) gtk_widget_destroy(dialog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) void on_window1_destroy(GtkObject * object, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) gtk_main_quit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) on_window1_size_request(GtkWidget * widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) GtkRequisition * requisition, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) static gint old_h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) gint w, h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) if (widget->window == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) gdk_window_get_size(widget->window, &w, &h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) if (h == old_h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) old_h = h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) /* Menu & Toolbar Callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) load_filename(GtkFileSelection * file_selector, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) const gchar *fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) (user_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) if (conf_read(fn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) text_insert_msg("Error", "Unable to load configuration !");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) display_tree(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) GtkWidget *fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) fs = gtk_file_selection_new("Load file...");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) "clicked",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) G_CALLBACK(load_filename), (gpointer) fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) g_signal_connect_swapped(GTK_OBJECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) (GTK_FILE_SELECTION(fs)->ok_button),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) "clicked", G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) (gpointer) fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) g_signal_connect_swapped(GTK_OBJECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) (GTK_FILE_SELECTION(fs)->cancel_button),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) "clicked", G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) (gpointer) fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) gtk_widget_show(fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) if (conf_write(NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) text_insert_msg("Error", "Unable to save configuration !");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) conf_write_autoconf(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) store_filename(GtkFileSelection * file_selector, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) const gchar *fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) (user_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) if (conf_write(fn))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) text_insert_msg("Error", "Unable to save configuration !");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) gtk_widget_destroy(GTK_WIDGET(user_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) GtkWidget *fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) fs = gtk_file_selection_new("Save file as...");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) "clicked",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) G_CALLBACK(store_filename), (gpointer) fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) g_signal_connect_swapped(GTK_OBJECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) (GTK_FILE_SELECTION(fs)->ok_button),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) "clicked", G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) (gpointer) fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) g_signal_connect_swapped(GTK_OBJECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) (GTK_FILE_SELECTION(fs)->cancel_button),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) "clicked", G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) (gpointer) fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) gtk_widget_show(fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (!on_window1_delete_event(NULL, NULL, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) gtk_widget_destroy(GTK_WIDGET(main_wnd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) void on_show_name1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) GtkTreeViewColumn *col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) show_name = GTK_CHECK_MENU_ITEM(menuitem)->active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) if (col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) gtk_tree_view_column_set_visible(col, show_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) GtkTreeViewColumn *col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) show_range = GTK_CHECK_MENU_ITEM(menuitem)->active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) if (col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) gtk_tree_view_column_set_visible(col, show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_MOD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) gtk_tree_view_column_set_visible(col, show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_YES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) if (col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) gtk_tree_view_column_set_visible(col, show_range);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) GtkTreeViewColumn *col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) show_value = GTK_CHECK_MENU_ITEM(menuitem)->active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_VALUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) if (col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) gtk_tree_view_column_set_visible(col, show_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) opt_mode = OPT_NORMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) gtk_tree_store_clear(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) display_tree(&rootmenu); /* instead of update_tree to speed-up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) opt_mode = OPT_ALL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) gtk_tree_store_clear(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) display_tree(&rootmenu); /* instead of update_tree to speed-up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) opt_mode = OPT_PROMPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) gtk_tree_store_clear(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) display_tree(&rootmenu); /* instead of update_tree to speed-up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) GtkWidget *dialog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) const gchar *intro_text =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) "Welcome to gkc, the GTK+ graphical configuration tool\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) "For each option, a blank box indicates the feature is disabled, a\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) "check indicates it is enabled, and a dot indicates that it is to\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) "be compiled as a module. Clicking on the box will cycle through the three states.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) "If you do not see an option (e.g., a device driver) that you\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) "believe should be present, try turning on Show All Options\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) "under the Options menu.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) "Although there is no cross reference yet to help you figure out\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) "what other options must be enabled to support the option you\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) "are interested in, you can still view the help of a grayed-out\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) "option.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) "\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) "Toggling Show Debug Info under the Options menu will show \n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) "the dependencies, which you can then match by examining other options.";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) GTK_DIALOG_DESTROY_WITH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) GTK_MESSAGE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) GTK_BUTTONS_CLOSE, "%s", intro_text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) GTK_OBJECT(dialog));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) gtk_widget_show_all(dialog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) GtkWidget *dialog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) const gchar *about_text =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) "gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) "Based on the source code from Roman Zippel.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) GTK_DIALOG_DESTROY_WITH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) GTK_MESSAGE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) GTK_BUTTONS_CLOSE, "%s", about_text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) GTK_OBJECT(dialog));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) gtk_widget_show_all(dialog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) GtkWidget *dialog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) const gchar *license_text =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) "gkc is released under the terms of the GNU GPL v2.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) "For more information, please see the source code or\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) "visit http://www.fsf.org/licenses/licenses.html\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) GTK_DIALOG_DESTROY_WITH_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) GTK_MESSAGE_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) GTK_BUTTONS_CLOSE, "%s", license_text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) G_CALLBACK(gtk_widget_destroy),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) GTK_OBJECT(dialog));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) gtk_widget_show_all(dialog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) void on_back_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) enum prop_type ptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) current = current->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) ptype = current->prompt ? current->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) if (ptype != P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) current = current->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) display_tree_part();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (current == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) gtk_widget_set_sensitive(back_btn, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) void on_load_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) on_load1_activate(NULL, user_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) void on_single_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) view_mode = SINGLE_VIEW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) gtk_widget_hide(tree1_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) current = &rootmenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) display_tree_part();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) void on_split_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) gint w, h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) view_mode = SPLIT_VIEW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) gtk_widget_show(tree1_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) gtk_paned_set_position(GTK_PANED(hpaned), w / 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) if (tree2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) gtk_tree_store_clear(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) display_list();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) /* Disable back btn, like in full mode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) gtk_widget_set_sensitive(back_btn, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) void on_full_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) view_mode = FULL_VIEW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) gtk_widget_hide(tree1_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) if (tree2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) gtk_tree_store_clear(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) display_tree(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) gtk_widget_set_sensitive(back_btn, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) void on_collapse_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) void on_expand_clicked(GtkButton * button, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) /* CTree Callbacks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) /* Change hex/int/string value in the cell */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) static void renderer_edited(GtkCellRendererText * cell,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) const gchar * path_string,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) const gchar * new_text, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) const char *old_def, *new_def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) if (!gtk_tree_model_get_iter(model2, &iter, path))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) new_def = new_text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) sym_set_string_value(sym, new_def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) update_tree(&rootmenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) gtk_tree_path_free(path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) /* Change the value of a symbol and update the tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static void change_sym_value(struct menu *menu, gint col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) struct symbol *sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) tristate newval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) if (!sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) if (col == COL_NO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) newval = no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) else if (col == COL_MOD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) newval = mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) else if (col == COL_YES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) newval = yes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) switch (sym_get_type(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) if (!sym_tristate_within_range(sym, newval))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) newval = yes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) sym_set_tristate_value(sym, newval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) if (view_mode == FULL_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) update_tree(&rootmenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) else if (view_mode == SPLIT_VIEW) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) update_tree(browsed, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) display_list();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) else if (view_mode == SINGLE_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) display_tree_part(); //fixme: keep exp/coll
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) case S_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) case S_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) case S_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) static void toggle_sym_value(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) if (!menu->sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) sym_toggle_tristate_value(menu->sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) if (view_mode == FULL_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) update_tree(&rootmenu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) else if (view_mode == SPLIT_VIEW) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) update_tree(browsed, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) display_list();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) else if (view_mode == SINGLE_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) display_tree_part(); //fixme: keep exp/coll
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) static gint column2index(GtkTreeViewColumn * column)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) gint i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) for (i = 0; i < COL_NUMBER; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) GtkTreeViewColumn *col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) if (col == column)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) /* User click: update choice (full) or goes down (single) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) gboolean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) on_treeview2_button_press_event(GtkWidget * widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) GdkEventButton * event, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) GtkTreeView *view = GTK_TREE_VIEW(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) GtkTreePath *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) gint col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) #if GTK_CHECK_VERSION(2,1,4) // bug in ctree with earlier version of GTK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) gint tx = (gint) event->x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) gint ty = (gint) event->y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) gint cx, cy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) &cy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) gtk_tree_view_get_cursor(view, &path, &column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) if (path == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) if (!gtk_tree_model_get_iter(model2, &iter, path))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) col = column2index(column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) if (event->type == GDK_2BUTTON_PRESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) enum prop_type ptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) if (ptype == P_MENU && view_mode != FULL_VIEW && col == COL_OPTION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) // goes down into menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) current = menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) display_tree_part();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) gtk_widget_set_sensitive(back_btn, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) } else if (col == COL_OPTION) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) toggle_sym_value(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) gtk_tree_view_expand_row(view, path, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) if (col == COL_VALUE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) toggle_sym_value(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) gtk_tree_view_expand_row(view, path, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) } else if (col == COL_NO || col == COL_MOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) || col == COL_YES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) change_sym_value(menu, col);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) gtk_tree_view_expand_row(view, path, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) /* Key pressed: update choice */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) gboolean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) on_treeview2_key_press_event(GtkWidget * widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) GdkEventKey * event, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) GtkTreeView *view = GTK_TREE_VIEW(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) GtkTreePath *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) gint col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) gtk_tree_view_get_cursor(view, &path, &column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) if (path == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) if (event->keyval == GDK_space) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) if (gtk_tree_view_row_expanded(view, path))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) gtk_tree_view_collapse_row(view, path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) gtk_tree_view_expand_row(view, path, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) return TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) if (event->keyval == GDK_KP_Enter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) if (widget == tree1_w)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) gtk_tree_model_get_iter(model2, &iter, path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) if (!strcasecmp(event->string, "n"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) col = COL_NO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) else if (!strcasecmp(event->string, "m"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) col = COL_MOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) else if (!strcasecmp(event->string, "y"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) col = COL_YES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) col = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) change_sym_value(menu, col);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) /* Row selection changed: update help */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) on_treeview2_cursor_changed(GtkTreeView * treeview, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) GtkTreeSelection *selection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) selection = gtk_tree_view_get_selection(treeview);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) if (gtk_tree_selection_get_selected(selection, &model2, &iter)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) text_insert_help(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) /* User click: display sub-tree in the right frame. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) gboolean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) on_treeview1_button_press_event(GtkWidget * widget,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) GdkEventButton * event, gpointer user_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) GtkTreeView *view = GTK_TREE_VIEW(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) GtkTreePath *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) gint tx = (gint) event->x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) gint ty = (gint) event->y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) gint cx, cy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) &cy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if (path == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) gtk_tree_model_get_iter(model1, &iter, path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) if (event->type == GDK_2BUTTON_PRESS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) toggle_sym_value(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) current = menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) display_tree_part();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) browsed = menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) display_tree_part();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) gtk_widget_realize(tree2_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) gtk_tree_view_set_cursor(view, path, NULL, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) gtk_widget_grab_focus(tree2_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) return FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) /* Fill a row of strings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) static gchar **fill_row(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) static gchar *row[COL_NUMBER];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) struct symbol *sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) const char *def;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) int stype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) tristate val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) enum prop_type ptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) for (i = COL_OPTION; i <= COL_COLOR; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) g_free(row[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) bzero(row, sizeof(row));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) row[COL_OPTION] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) g_strdup_printf("%s %s", menu_get_prompt(menu),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) sym && !sym_has_value(sym) ? "(NEW)" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) if (opt_mode == OPT_ALL && !menu_is_visible(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) row[COL_COLOR] = g_strdup("DarkGray");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) else if (opt_mode == OPT_PROMPT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) menu_has_prompt(menu) && !menu_is_visible(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) row[COL_COLOR] = g_strdup("DarkGray");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) row[COL_COLOR] = g_strdup("Black");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) switch (ptype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) case P_MENU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) row[COL_PIXBUF] = (gchar *) xpm_menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) if (view_mode == SINGLE_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) row[COL_PIXVIS] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) case P_COMMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) row[COL_PIXBUF] = (gchar *) xpm_void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) row[COL_PIXBUF] = (gchar *) xpm_void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) row[COL_PIXVIS] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) if (!sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) return row;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) row[COL_NAME] = g_strdup(sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) sym_calc_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) sym->flags &= ~SYMBOL_CHANGED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) if (sym_is_choice(sym)) { // parse childs for getting final value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) struct symbol *def_sym = sym_get_choice_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) struct menu *def_menu = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) if (menu_is_visible(child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) && child->sym == def_sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) def_menu = child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) if (def_menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) row[COL_VALUE] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) g_strdup(menu_get_prompt(def_menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) if (sym->flags & SYMBOL_CHOICEVAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) stype = sym_get_type(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) switch (stype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) if (sym_is_choice(sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) /* fall through */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) val = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) switch (val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) case no:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) row[COL_NO] = g_strdup("N");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) row[COL_VALUE] = g_strdup("N");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) row[COL_BTNACT] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) case mod:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) row[COL_MOD] = g_strdup("M");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) row[COL_VALUE] = g_strdup("M");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) row[COL_BTNINC] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) case yes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) row[COL_YES] = g_strdup("Y");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) row[COL_VALUE] = g_strdup("Y");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) row[COL_BTNACT] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) row[COL_BTNINC] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) if (val != no && sym_tristate_within_range(sym, no))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) row[COL_NO] = g_strdup("_");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) if (val != mod && sym_tristate_within_range(sym, mod))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) row[COL_MOD] = g_strdup("_");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) if (val != yes && sym_tristate_within_range(sym, yes))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) row[COL_YES] = g_strdup("_");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) case S_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) case S_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) case S_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) def = sym_get_string_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) row[COL_VALUE] = g_strdup(def);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) row[COL_EDIT] = GINT_TO_POINTER(TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) row[COL_BTNVIS] = GINT_TO_POINTER(FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) return row;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) /* Set the node content with a row of strings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) GdkColor color;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) gboolean success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) GdkPixbuf *pix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) pix = gdk_pixbuf_new_from_xpm_data((const char **)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) row[COL_PIXBUF]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) gdk_color_parse(row[COL_COLOR], &color);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) FALSE, FALSE, &success);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) gtk_tree_store_set(tree, node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) COL_OPTION, row[COL_OPTION],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) COL_NAME, row[COL_NAME],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) COL_NO, row[COL_NO],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) COL_MOD, row[COL_MOD],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) COL_YES, row[COL_YES],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) COL_VALUE, row[COL_VALUE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) COL_MENU, (gpointer) menu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) COL_COLOR, &color,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) COL_EDIT, GPOINTER_TO_INT(row[COL_EDIT]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) COL_PIXBUF, pix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) COL_PIXVIS, GPOINTER_TO_INT(row[COL_PIXVIS]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) COL_BTNVIS, GPOINTER_TO_INT(row[COL_BTNVIS]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) COL_BTNACT, GPOINTER_TO_INT(row[COL_BTNACT]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) COL_BTNINC, GPOINTER_TO_INT(row[COL_BTNINC]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) COL_BTNRAD, GPOINTER_TO_INT(row[COL_BTNRAD]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) g_object_unref(pix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) /* Add a node to the tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) static void place_node(struct menu *menu, char **row)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) GtkTreeIter *parent = parents[indent - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) GtkTreeIter *node = parents[indent];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) gtk_tree_store_append(tree, node, parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) set_node(node, menu, row);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) /* Find a node in the GTK+ tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) static GtkTreeIter found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) * Find a menu in the GtkTree starting at parent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) static GtkTreeIter *gtktree_iter_find_node(GtkTreeIter *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) struct menu *tofind)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) GtkTreeIter *child = &iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) gboolean valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) GtkTreeIter *ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) valid = gtk_tree_model_iter_children(model2, child, parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) while (valid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) gtk_tree_model_get(model2, child, 6, &menu, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) if (menu == tofind) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) memcpy(&found, child, sizeof(GtkTreeIter));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) return &found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) ret = gtktree_iter_find_node(child, tofind);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) valid = gtk_tree_model_iter_next(model2, child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) * Update the tree by adding/removing entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) * Does not change other nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) static void update_tree(struct menu *src, GtkTreeIter * dst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) struct menu *child1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) GtkTreeIter iter, tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) GtkTreeIter *child2 = &iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) gboolean valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) GtkTreeIter *sibling;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) struct menu *menu1, *menu2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) if (src == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) indent = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) valid = gtk_tree_model_iter_children(model2, child2, dst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) for (child1 = src->list; child1; child1 = child1->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) sym = child1->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) reparse:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) menu1 = child1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) if (valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) gtk_tree_model_get(model2, child2, COL_MENU,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) &menu2, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) menu2 = NULL; // force adding of a first child
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) printf("%*c%s | %s\n", indent, ' ',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) menu1 ? menu_get_prompt(menu1) : "nil",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) menu2 ? menu_get_prompt(menu2) : "nil");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) (opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) /* remove node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) if (gtktree_iter_find_node(dst, menu1) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) memcpy(&tmp, child2, sizeof(GtkTreeIter));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) valid = gtk_tree_model_iter_next(model2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) child2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) gtk_tree_store_remove(tree2, &tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) if (!valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) return; /* next parent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) goto reparse; /* next child */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) if (menu1 != menu2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) if (gtktree_iter_find_node(dst, menu1) == NULL) { // add node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) if (!valid && !menu2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) sibling = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) sibling = child2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) gtk_tree_store_insert_before(tree2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) child2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) dst, sibling);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) set_node(child2, menu1, fill_row(menu1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) if (menu2 == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) valid = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) } else { // remove node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) memcpy(&tmp, child2, sizeof(GtkTreeIter));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) valid = gtk_tree_model_iter_next(model2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) child2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) gtk_tree_store_remove(tree2, &tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) if (!valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) return; // next parent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) goto reparse; // next child
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) } else if (sym && (sym->flags & SYMBOL_CHANGED)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) set_node(child2, menu1, fill_row(menu1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) indent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) update_tree(child1, child2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) indent--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) valid = gtk_tree_model_iter_next(model2, child2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) /* Display the whole tree (single/split/full view) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) static void display_tree(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) enum prop_type ptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) if (menu == &rootmenu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) indent = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) current = &rootmenu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) prop = child->prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) sym = child->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) ptype = prop ? prop->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) if (sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) sym->flags &= ~SYMBOL_CHANGED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) if ((view_mode == SPLIT_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) && !(child->flags & MENU_ROOT) && (tree == tree1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) && (tree == tree2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) (opt_mode == OPT_ALL && menu_get_prompt(child)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) place_node(child, fill_row(child));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) printf("%s", prop_get_type_name(ptype));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) printf(" | ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) if (sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) printf("%s", sym_type_name(sym->type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) printf(" | ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) printf("%s", dbg_sym_flags(sym->flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) printf("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) printf("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) if ((view_mode != FULL_VIEW) && (ptype == P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) && (tree == tree2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) || (view_mode == FULL_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) || (view_mode == SPLIT_VIEW))*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) /* Change paned position if the view is not in 'split mode' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) gtk_paned_set_position(GTK_PANED(hpaned), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) || (view_mode == FULL_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) || (view_mode == SPLIT_VIEW)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) indent++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) display_tree(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) indent--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) /* Display a part of the tree starting at current node (single/split view) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) static void display_tree_part(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) if (tree2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) gtk_tree_store_clear(tree2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) if (view_mode == SINGLE_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) display_tree(current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) else if (view_mode == SPLIT_VIEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) display_tree(browsed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) /* Display the list in the left frame (split view) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) static void display_list(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) if (tree1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) gtk_tree_store_clear(tree1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) tree = tree1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) display_tree(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) tree = tree2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) static void fixup_rootmenu(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) static int menu_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) menu->flags |= MENU_ROOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) if (child->prompt && child->prompt->type == P_MENU) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) menu_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) fixup_rootmenu(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) menu_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) } else if (!menu_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) fixup_rootmenu(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) /* Main */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) int main(int ac, char *av[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) char *env;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) gchar *glade_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) /* GTK stuffs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) gtk_set_locale();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) gtk_init(&ac, &av);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) glade_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) //add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) //add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) /* Determine GUI path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) env = getenv(SRCTREE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) if (env)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) glade_file = g_strconcat(env, "/scripts/kconfig/gconf.glade", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) else if (av[0][0] == '/')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) glade_file = g_strconcat(av[0], ".glade", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) /* Conf stuffs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) if (ac > 1 && av[1][0] == '-') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) switch (av[1][1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) case 'a':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) //showAll = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) case 's':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) conf_set_message_callback(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) case 'h':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) case '?':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) printf("%s [-s] <config>\n", av[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) exit(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) name = av[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) name = av[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) conf_parse(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) fixup_rootmenu(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) conf_read(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) /* Load the interface and connect signals */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) init_main_window(glade_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) init_tree_model();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) init_left_tree();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) init_right_tree();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) switch (view_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) case SINGLE_VIEW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) display_tree_part();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) case SPLIT_VIEW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) display_list();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) case FULL_VIEW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) display_tree(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) gtk_main();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) static void conf_changed(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) bool changed = conf_get_changed();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) gtk_widget_set_sensitive(save_btn, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) gtk_widget_set_sensitive(save_menu_item, changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) }