static void gnt_label_size_request(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); gnt_util_get_text_bound(label->text, &widget->priv.width, &widget->priv.height); }
static void tinyurl_notify_tinyuri(GntWidget *win, const gchar *url) { gchar *message; GntWidget *label = g_object_get_data(G_OBJECT(win), "info-widget"); message = g_strdup_printf(_("TinyURL for above: %s"), url); gnt_label_set_text(GNT_LABEL(label), message); g_free(message); }
static void gnt_label_draw(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); chtype flag = gnt_text_format_flag_to_chtype(label->flags); wbkgdset(widget->window, '\0' | flag); mvwaddstr(widget->window, 0, 0, C_(label->text)); GNTDEBUG; }
static void gnt_label_get_property(GObject *obj, guint prop_id, GValue *value, GParamSpec *spec) { GntLabel *label = GNT_LABEL(obj); switch (prop_id) { case PROP_TEXT: g_value_set_string(value, label->text); break; case PROP_TEXT_FLAG: g_value_set_int(value, label->flags); break; default: break; } }
static void gnt_label_set_property(GObject *obj, guint prop_id, const GValue *value, GParamSpec *spec) { GntLabel *label = GNT_LABEL(obj); switch (prop_id) { case PROP_TEXT: g_free(label->text); label->text = gnt_util_onscreen_fit_string(g_value_get_string(value), -1); break; case PROP_TEXT_FLAG: label->flags = g_value_get_int(value); break; default: g_return_if_reached(); break; } }
static void gnt_label_destroy(GntWidget *widget) { GntLabel *label = GNT_LABEL(widget); g_free(label->text); }
void finch_sounds_show_all(void) { GntWidget *box, *tmpbox, *splitbox, *cmbox, *slider; GntWidget *entry; GntWidget *chkbox; GntWidget *button; GntWidget *label; GntWidget *tree; GntWidget *win; gint i; GList *itr, *list; if (pref_dialog) { gnt_window_present(pref_dialog->window); return; } pref_dialog = g_new0(SoundPrefDialog, 1); pref_dialog->original_profile = g_strdup(finch_sound_get_active_profile()); pref_dialog->window = win = gnt_window_box_new(FALSE, TRUE); gnt_box_set_pad(GNT_BOX(win), 0); gnt_box_set_toplevel(GNT_BOX(win), TRUE); gnt_box_set_title(GNT_BOX(win), _("Sound Preferences")); gnt_box_set_fill(GNT_BOX(win), TRUE); gnt_box_set_alignment(GNT_BOX(win), GNT_ALIGN_MID); /* Profiles */ splitbox = gnt_hbox_new(FALSE); gnt_box_set_pad(GNT_BOX(splitbox), 0); gnt_box_set_alignment(GNT_BOX(splitbox), GNT_ALIGN_TOP); box = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(box), 0); gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Profiles"), GNT_TEXT_FLAG_BOLD)); pref_dialog->profiles = tree = gnt_tree_new(); gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)g_ascii_strcasecmp); g_signal_connect(G_OBJECT(tree), "selection-changed", G_CALLBACK(prof_load_cb), NULL); itr = list = finch_sound_get_profiles(); for (; itr; itr = itr->next) { /* Do not free itr->data. It's the stored as a key for the tree, and will * be freed when the tree is destroyed. */ gnt_tree_add_row_after(GNT_TREE(tree), itr->data, gnt_tree_create_row(GNT_TREE(tree), itr->data), NULL, NULL); } g_list_free(list); gnt_box_add_widget(GNT_BOX(box), tree); pref_dialog->new_profile = entry = gnt_entry_new(""); gnt_box_add_widget(GNT_BOX(box), entry); tmpbox = gnt_hbox_new(FALSE); button = gnt_button_new("Add"); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(prof_add_cb), entry); gnt_box_add_widget(GNT_BOX(tmpbox), button); button = gnt_button_new("Delete"); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(prof_del_cb), NULL); gnt_box_add_widget(GNT_BOX(tmpbox), button); gnt_box_add_widget(GNT_BOX(box), tmpbox); gnt_box_add_widget(GNT_BOX(splitbox), box); gnt_box_add_widget(GNT_BOX(splitbox), gnt_vline_new()); /* Sound method */ box = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(box), 0); pref_dialog->method = cmbox = gnt_combo_box_new(); gnt_tree_set_hash_fns(GNT_TREE(GNT_COMBO_BOX(cmbox)->dropdown), g_str_hash, g_str_equal, NULL); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "automatic", _("Automatic")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "alsa", "ALSA"); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "esd", "ESD"); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "beep", _("Console Beep")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "custom", _("Command")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "nosound", _("No Sound")); label = gnt_label_new_with_format(_("Sound Method"), GNT_TEXT_FLAG_BOLD); gnt_box_add_widget(GNT_BOX(box), label); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Method: "))); gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); gnt_box_add_widget(GNT_BOX(box), tmpbox); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Sound Command\n(%s for filename)"))); pref_dialog->command = entry = gnt_entry_new(""); gnt_box_add_widget(GNT_BOX(tmpbox), entry); gnt_box_add_widget(GNT_BOX(box), tmpbox); gnt_box_add_widget(GNT_BOX(box), gnt_line_new(FALSE)); /* Sound options */ gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Sound Options"), GNT_TEXT_FLAG_BOLD)); pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus")); gnt_box_add_widget(GNT_BOX(box), chkbox); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new("Enable Sounds:")); pref_dialog->while_status = cmbox = gnt_combo_box_new(); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(3), _("Always")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(1), _("Only when available")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(2), _("Only when not available")); gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); gnt_box_add_widget(GNT_BOX(box), tmpbox); tmpbox = gnt_hbox_new(TRUE); gnt_box_set_pad(GNT_BOX(tmpbox), 0); gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Volume(0-100):"))); pref_dialog->volume = slider = gnt_slider_new(FALSE, 100, 0); gnt_slider_set_step(GNT_SLIDER(slider), 5); gnt_slider_set_small_step(GNT_SLIDER(slider), 1); gnt_slider_set_large_step(GNT_SLIDER(slider), 20); label = gnt_label_new(""); gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(label)); gnt_box_set_pad(GNT_BOX(tmpbox), 1); gnt_box_add_widget(GNT_BOX(tmpbox), slider); gnt_box_add_widget(GNT_BOX(tmpbox), label); gnt_box_add_widget(GNT_BOX(box), tmpbox); gnt_box_add_widget(GNT_BOX(splitbox), box); gnt_box_add_widget(GNT_BOX(win), splitbox); gnt_box_add_widget(GNT_BOX(win), gnt_hline_new()); /* Sound events */ gnt_box_add_widget(GNT_BOX(win), gnt_label_new_with_format(_("Sound Events"), GNT_TEXT_FLAG_BOLD)); pref_dialog->events = tree = gnt_tree_new_with_columns(2); gnt_tree_set_column_titles(GNT_TREE(tree), _("Event"), _("File")); gnt_tree_set_show_title(GNT_TREE(tree), TRUE); for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { FinchSoundEvent * event = &sounds[i]; if (event->label == NULL) { continue; } gnt_tree_add_choice(GNT_TREE(tree), GINT_TO_POINTER(i), gnt_tree_create_row(GNT_TREE(tree), event->label, event->def), NULL, NULL); } gnt_tree_adjust_columns(GNT_TREE(tree)); gnt_box_add_widget(GNT_BOX(win), tree); box = gnt_hbox_new(FALSE); button = gnt_button_new(_("Test")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(test_cb), NULL); gnt_box_add_widget(GNT_BOX(box), button); button = gnt_button_new(_("Reset")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(reset_cb), NULL); gnt_box_add_widget(GNT_BOX(box), button); button = gnt_button_new(_("Choose...")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(choose_cb), NULL); gnt_box_add_widget(GNT_BOX(box), button); gnt_box_add_widget(GNT_BOX(win), box); gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); /* Add new stuff before this */ box = gnt_hbox_new(FALSE); gnt_box_set_fill(GNT_BOX(box), TRUE); button = gnt_button_new(_("Save")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_cb), win); gnt_box_add_widget(GNT_BOX(box), button); button = gnt_button_new(_("Cancel")); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cancel_cb), win); gnt_box_add_widget(GNT_BOX(box), button); gnt_box_add_widget(GNT_BOX(win), box); g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(release_pref_dialog), NULL); load_pref_window(finch_sound_get_active_profile()); gnt_widget_show(win); }