GtkWidget *menu; /* for optionmenu (==droplist) */
GtkWidget *optmenu; /* also for optionmenu */
GtkWidget *text; /* for text */
+ GtkWidget *label; /* for dlg_label_change */
GtkAdjustment *adj; /* for the scrollbar in a list box */
guint textsig;
};
gpointer data);
static void shortcut_add(struct Shortcuts *scs, GtkWidget *labelw,
int chr, int action, void *ptr);
+static void shortcut_highlight(GtkWidget *label, int chr);
static int listitem_single_key(GtkWidget *item, GdkEventKey *event,
gpointer data);
static int listitem_multi_key(GtkWidget *item, GdkEventKey *event,
if (uc->optmenu) {
gtk_option_menu_set_history(GTK_OPTION_MENU(uc->optmenu), index);
} else {
+ int nitems;
+ GList *items;
+ gdouble newtop, newbot;
+
gtk_list_select_item(GTK_LIST(uc->list), index);
+
+ /*
+ * Scroll the list box if necessary to ensure the newly
+ * selected item is visible.
+ */
+ items = gtk_container_children(GTK_CONTAINER(uc->list));
+ nitems = g_list_length(items);
+ if (nitems > 0) {
+ int modified = FALSE;
+ g_list_free(items);
+ newtop = uc->adj->lower +
+ (uc->adj->upper - uc->adj->lower) * index / nitems;
+ newbot = uc->adj->lower +
+ (uc->adj->upper - uc->adj->lower) * (index+1) / nitems;
+ if (uc->adj->value > newtop) {
+ modified = TRUE;
+ uc->adj->value = newtop;
+ } else if (uc->adj->value < newbot - uc->adj->page_size) {
+ modified = TRUE;
+ uc->adj->value = newbot - uc->adj->page_size;
+ }
+ if (modified)
+ gtk_adjustment_value_changed(uc->adj);
+ }
}
}
gtk_label_set_text(GTK_LABEL(uc->text), text);
}
+void dlg_label_change(union control *ctrl, void *dlg, char const *text)
+{
+ struct dlgparam *dp = (struct dlgparam *)dlg;
+ struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
+
+ switch (uc->ctrl->generic.type) {
+ case CTRL_BUTTON:
+ gtk_label_set_text(GTK_LABEL(uc->toplevel), text);
+ shortcut_highlight(uc->toplevel, ctrl->button.shortcut);
+ break;
+ case CTRL_CHECKBOX:
+ gtk_label_set_text(GTK_LABEL(uc->toplevel), text);
+ shortcut_highlight(uc->toplevel, ctrl->checkbox.shortcut);
+ break;
+ case CTRL_RADIO:
+ gtk_label_set_text(GTK_LABEL(uc->label), text);
+ shortcut_highlight(uc->label, ctrl->radio.shortcut);
+ break;
+ case CTRL_EDITBOX:
+ gtk_label_set_text(GTK_LABEL(uc->label), text);
+ shortcut_highlight(uc->label, ctrl->editbox.shortcut);
+ break;
+ case CTRL_FILESELECT:
+ gtk_label_set_text(GTK_LABEL(uc->label), text);
+ shortcut_highlight(uc->label, ctrl->fileselect.shortcut);
+ break;
+ case CTRL_FONTSELECT:
+ gtk_label_set_text(GTK_LABEL(uc->label), text);
+ shortcut_highlight(uc->label, ctrl->fontselect.shortcut);
+ break;
+ case CTRL_LISTBOX:
+ gtk_label_set_text(GTK_LABEL(uc->label), text);
+ shortcut_highlight(uc->label, ctrl->listbox.shortcut);
+ break;
+ default:
+ assert(!"This shouldn't happen");
+ break;
+ }
+}
+
void dlg_filesel_set(union control *ctrl, void *dlg, Filename fn)
{
struct dlgparam *dp = (struct dlgparam *)dlg;
uc->buttons = NULL;
uc->entry = uc->list = uc->menu = NULL;
uc->button = uc->optmenu = uc->text = NULL;
+ uc->label = NULL;
switch (ctrl->generic.type) {
case CTRL_BUTTON:
gtk_widget_show(label);
shortcut_add(scs, label, ctrl->radio.shortcut,
SHORTCUT_UCTRL, uc);
+ uc->label = label;
}
percentages = g_new(gint, ctrl->radio.ncolumns);
for (i = 0; i < ctrl->radio.ncolumns; i++) {
gtk_widget_show(w);
w = container;
+ uc->label = label;
}
gtk_signal_connect(GTK_OBJECT(uc->entry), "focus_out_event",
GTK_SIGNAL_FUNC(editbox_lostfocus), dp);
ctrl->fileselect.shortcut :
ctrl->fontselect.shortcut),
SHORTCUT_UCTRL, uc);
+ uc->label = ww;
}
uc->entry = ww = gtk_entry_new();
shortcut_add(scs, label, ctrl->listbox.shortcut,
SHORTCUT_UCTRL, uc);
w = container;
+ uc->label = label;
}
break;
case CTRL_TEXT:
panels_switch_to(sp->panels, sp->panel);
+ dlg_refresh(NULL, sp->dp);
+
sp->dp->shortcuts = &sp->shortcuts;
sp->dp->currtreeitem = sp->treeitem;
}
return FALSE;
}
-void shortcut_add(struct Shortcuts *scs, GtkWidget *labelw,
- int chr, int action, void *ptr)
+static void shortcut_highlight(GtkWidget *labelw, int chr)
{
GtkLabel *label = GTK_LABEL(labelw);
gchar *currstr, *pattern;
int i;
+ gtk_label_get(label, &currstr);
+ for (i = 0; currstr[i]; i++)
+ if (tolower((unsigned char)currstr[i]) == chr) {
+ GtkRequisition req;
+
+ pattern = dupprintf("%*s_", i, "");
+
+ gtk_widget_size_request(GTK_WIDGET(label), &req);
+ gtk_label_set_pattern(label, pattern);
+ gtk_widget_set_usize(GTK_WIDGET(label), -1, req.height);
+
+ sfree(pattern);
+ break;
+ }
+}
+
+void shortcut_add(struct Shortcuts *scs, GtkWidget *labelw,
+ int chr, int action, void *ptr)
+{
if (chr == NO_SHORTCUT)
return;
scs->sc[chr].uc = (struct uctrl *)ptr;
}
- gtk_label_get(label, &currstr);
- for (i = 0; currstr[i]; i++)
- if (tolower((unsigned char)currstr[i]) == chr) {
- GtkRequisition req;
-
- pattern = dupprintf("%*s_", i, "");
-
- gtk_widget_size_request(GTK_WIDGET(label), &req);
- gtk_label_set_pattern(label, pattern);
- gtk_widget_set_usize(GTK_WIDGET(label), -1, req.height);
-
- sfree(pattern);
- break;
- }
+ shortcut_highlight(labelw, chr);
}
int get_listitemheight(void)
char *title;
char *licence =
- "Copyright 1997-2005 Simon Tatham.\n\n"
+ "Copyright 1997-2006 Simon Tatham.\n\n"
"Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
"Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas "
- "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Markus Kuhn, "
- "and CORE SDI S.A.\n\n"
+ "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, "
+ "Markus Kuhn, and CORE SDI S.A.\n\n"
"Permission is hereby granted, free of charge, to any person "
"obtaining a copy of this software and associated documentation "
w, FALSE, FALSE, 5);
gtk_widget_show(w);
- w = gtk_label_new("Copyright 1997-2005 Simon Tatham. All rights reserved");
+ w = gtk_label_new("Copyright 1997-2006 Simon Tatham. All rights reserved");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(aboutbox)->vbox),
w, FALSE, FALSE, 5);
gtk_widget_show(w);