GtkWidget * gnome_prefs_toggle_new (GtkWidget *table, const gchar *label_txt, const gchar *conf_key, const gchar *tooltip, int row) { GnomePrefsWindow *gpw = NULL; GValue value = { 0, {{0}, {0}}}; GtkWidget *toggle = NULL; gboolean writable = FALSE; int cols = 0; writable = gm_conf_is_key_writable (conf_key); g_value_init (&value, G_TYPE_INT); g_object_get_property (G_OBJECT (table), "n-columns", &value); cols = g_value_get_int (&value); g_value_unset (&value); toggle = gtk_check_button_new_with_mnemonic (label_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (toggle), FALSE); gtk_table_attach (GTK_TABLE (table), toggle, 0, cols, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gm_conf_get_bool (conf_key)); gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (table), "gpw"); if (gpw && tooltip) gtk_widget_set_tooltip_text (toggle, tooltip); g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_changed), (gpointer) conf_key); gm_conf_notifier_add (conf_key, toggle_changed_nt, (gpointer) toggle); gtk_widget_show_all (table); return toggle; }
GtkWidget * preferences_window_new (Ekiga::ServiceCore& core) { GmPreferencesWindow *pw = NULL; GdkPixbuf *pixbuf = NULL; GtkWidget *window = NULL; GtkWidget *container = NULL; gchar *filename = NULL; std::vector <std::string> device_list; gpointer notifier; filename = g_build_filename (DATA_DIR, "pixmaps", PACKAGE_NAME, PACKAGE_NAME "-logo.png", NULL); window = gnome_prefs_window_new (filename); g_free (filename); g_object_set_data_full (G_OBJECT (window), "window_name", g_strdup ("preferences_window"), g_free); gtk_window_set_title (GTK_WINDOW (window), _("Ekiga Preferences")); pixbuf = gtk_widget_render_icon_pixbuf (GTK_WIDGET (window), GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU); gtk_window_set_icon (GTK_WINDOW (window), pixbuf); gtk_widget_realize (GTK_WIDGET (window)); g_object_unref (pixbuf); /* The GMObject data */ pw = new GmPreferencesWindow; pw->audioinput_core = core.get<Ekiga::AudioInputCore> ("audioinput-core"); pw->audiooutput_core = core.get<Ekiga::AudioOutputCore> ("audiooutput-core"); pw->videoinput_core = core.get<Ekiga::VideoInputCore> ("videoinput-core"); g_object_set_data_full (G_OBJECT (window), "GMObject", pw, (GDestroyNotify) gm_pw_destroy); gnome_prefs_window_section_new (window, _("General")); container = gnome_prefs_window_subsection_new (window, _("Personal Data")); gm_pw_init_general_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); container = gnome_prefs_window_subsection_new (window, _("General Settings")); gm_pw_init_interface_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); container = gnome_prefs_window_subsection_new (window, _("Call Options")); gm_pw_init_call_options_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); container = gnome_prefs_window_subsection_new (window, _("Sound Events")); gm_pw_init_sound_events_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); gnome_prefs_window_section_new (window, _("Protocols")); container = gnome_prefs_window_subsection_new (window, _("SIP Settings")); gm_pw_init_sip_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); container = gnome_prefs_window_subsection_new (window, _("H.323 Settings")); gm_pw_init_h323_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); /* The player */ gnome_prefs_window_section_new (window, _("Audio")); container = gnome_prefs_window_subsection_new (window, _("Devices")); gm_pw_init_audio_devices_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); container = gnome_prefs_window_subsection_new (window, _("Codecs")); gm_pw_init_audio_codecs_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); gnome_prefs_window_section_new (window, _("Video")); container = gnome_prefs_window_subsection_new (window, _("Devices")); gm_pw_init_video_devices_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); container = gnome_prefs_window_subsection_new (window, _("Codecs")); gm_pw_init_video_codecs_page (window, container); gtk_widget_show_all (GTK_WIDGET (container)); /* That's an usual GtkWindow, connect it to the signals */ g_signal_connect_swapped (window, "response", G_CALLBACK (gm_window_hide), (gpointer) window); gm_window_hide_on_delete (window); boost::signals2::connection conn; conn = pw->videoinput_core->device_added.connect (boost::bind (&on_videoinput_device_added_cb, _1, _2, window)); pw->connections.add (conn); conn = pw->videoinput_core->device_removed.connect (boost::bind (&on_videoinput_device_removed_cb, _1, _2, window)); pw->connections.add (conn); conn = pw->audioinput_core->device_added.connect (boost::bind (&on_audioinput_device_added_cb, _1, _2, window)); pw->connections.add (conn); conn = pw->audioinput_core->device_removed.connect (boost::bind (&on_audioinput_device_removed_cb, _1, _2, window)); pw->connections.add (conn); conn = pw->audiooutput_core->device_added.connect (boost::bind (&on_audiooutput_device_added_cb, _1, _2, window)); pw->connections.add(conn); conn = pw->audiooutput_core->device_removed.connect (boost::bind (&on_audiooutput_device_removed_cb, _1, _2, window)); pw->connections.add (conn); /* Connect notifiers for SOUND_EVENTS_KEY keys */ notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "enable_incoming_call_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "incoming_call_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "enable_ring_tone_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "ring_tone_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "enable_busy_tone_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "busy_tone_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "enable_new_voicemail_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "new_voicemail_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "enable_new_message_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); notifier = gm_conf_notifier_add (SOUND_EVENTS_KEY "new_message_sound", sound_events_list_changed_nt, window); pw->notifiers.push_front (notifier); return window; }
static void roster_view_gtk_init (G_GNUC_UNUSED RosterViewGtk* self) { GtkWidget *scrolled_window; GtkWidget *vbox = NULL; GtkTreeModel *filtered = NULL; GtkTreeSelection *selection = NULL; GtkTreeViewColumn *col = NULL; GtkCellRenderer *renderer = NULL; self->priv = new RosterViewGtkPrivate; self->priv->folded_groups = gm_conf_get_string_list (CONTACTS_KEY "roster_folded_groups"); self->priv->show_offline_contacts = gm_conf_get_bool (CONTACTS_KEY "show_offline_contacts"); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 0); gtk_frame_set_shadow_type (GTK_FRAME (self), GTK_SHADOW_NONE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); self->priv->store = gtk_tree_store_new (COLUMN_NUMBER, G_TYPE_INT, // type G_TYPE_POINTER, // heap G_TYPE_POINTER, // presentity G_TYPE_STRING, // name G_TYPE_STRING, // status G_TYPE_STRING, // presence G_TYPE_STRING, // color if active G_TYPE_STRING, // group name (invisible) G_TYPE_STRING, // presence G_TYPE_BOOLEAN, // offline G_TYPE_INT); // timeout source gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self->priv->store), COLUMN_NAME, GTK_SORT_ASCENDING); filtered = gtk_tree_model_filter_new (GTK_TREE_MODEL (self->priv->store), NULL); g_object_unref (self->priv->store); self->priv->tree_view = GTK_TREE_VIEW (gtk_tree_view_new_with_model (filtered)); g_object_unref (filtered); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filtered), tree_model_filter_hide_show_offline, self, NULL); gtk_tree_view_set_headers_visible (self->priv->tree_view, FALSE); gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (vbox)); gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (scrolled_window), TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (self->priv->tree_view)); /* Build the GtkTreeView */ // We hide the normal GTK+ expanders and use our own col = gtk_tree_view_column_new (); renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_set_spacing (col, 0); gtk_tree_view_column_pack_start (col, renderer, TRUE); g_object_set (col, "visible", FALSE, NULL); gtk_tree_view_append_column (self->priv->tree_view, col); gtk_tree_view_set_expander_column (self->priv->tree_view, col); col = gtk_tree_view_column_new (); renderer = gm_cell_renderer_expander_new (); gtk_tree_view_column_pack_start (col, renderer, FALSE); g_object_set (renderer, "xalign", 0.0, "xpad", 0, "ypad", 0, "visible", TRUE, "expander-style", GTK_EXPANDER_COLLAPSED, NULL); gtk_tree_view_column_set_cell_data_func (col, renderer, expand_cell_data_func, NULL, NULL); gtk_tree_view_append_column (self->priv->tree_view, col); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_set_spacing (col, 0); gtk_tree_view_column_pack_start (col, renderer, TRUE); gtk_tree_view_column_add_attribute (col, renderer, "text", COLUMN_NAME); gtk_tree_view_column_set_alignment (col, 0.0); g_object_set (renderer, "xalign", 0.5, "ypad", 0, NULL); g_object_set (renderer, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_tree_view_column_set_cell_data_func (col, renderer, show_cell_data_func, GINT_TO_POINTER (TYPE_HEAP), NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, renderer, TRUE); gtk_tree_view_column_add_attribute (col, renderer, "text", COLUMN_NAME); g_object_set (renderer, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_tree_view_column_set_cell_data_func (col, renderer, show_cell_data_func, GINT_TO_POINTER (TYPE_GROUP), NULL); renderer = gtk_cell_renderer_pixbuf_new (); g_object_set (renderer, "yalign", 0.5, "xpad", 5, NULL); gtk_tree_view_column_pack_start (col, renderer, FALSE); gtk_tree_view_column_add_attribute (col, renderer, "icon-name", COLUMN_PRESENCE_ICON); gtk_tree_view_column_set_cell_data_func (col, renderer, show_cell_data_func, GINT_TO_POINTER (TYPE_PRESENTITY), NULL); renderer = gm_cell_renderer_bitext_new (); g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 30, NULL); gtk_tree_view_column_pack_start (col, renderer, FALSE); gtk_tree_view_column_add_attribute (col, renderer, "primary-text", COLUMN_NAME); gtk_tree_view_column_add_attribute (col, renderer, "secondary-text", COLUMN_STATUS); gtk_tree_view_column_add_attribute (col, renderer, "foreground", COLUMN_ACTIVE); gtk_tree_view_column_set_cell_data_func (col, renderer, show_cell_data_func, GINT_TO_POINTER (TYPE_PRESENTITY), NULL); /* Callback when the selection has been changed */ selection = gtk_tree_view_get_selection (self->priv->tree_view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); g_signal_connect (selection, "changed", G_CALLBACK (on_selection_changed), self); g_signal_connect (self->priv->tree_view, "event-after", G_CALLBACK (on_view_event_after), self); /* Notifiers */ self->priv->notifier = gm_conf_notifier_add (CONTACTS_KEY "show_offline_contacts", show_offline_contacts_changed_nt, self); }
GtkWidget * status_menu_new (Ekiga::ServiceCore & core) { StatusMenu *self = NULL; sigc::connection conn; GtkCellRenderer *renderer = NULL; GSList *custom_status_array [NUM_STATUS_TYPES]; self = (StatusMenu *) g_object_new (STATUS_MENU_TYPE, NULL); self->priv = new StatusMenuPrivate (); self->priv->personal_details = core.get ("personal-details"); self->priv->parent = NULL; self->priv->list_store = gtk_list_store_new (NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN); gtk_combo_box_set_model (GTK_COMBO_BOX (self), GTK_TREE_MODEL (self->priv->list_store)); g_object_unref (self->priv->list_store); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), renderer, "pixbuf", COL_ICON, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), renderer, "text", COL_MESSAGE, NULL); g_object_set (renderer, "width", 130, "ellipsize-set", true, "ellipsize", PANGO_ELLIPSIZE_END, NULL); for (int i = 0 ; i < NUM_STATUS_TYPES ; i++) custom_status_array [i] = gm_conf_get_string_list (status_types_keys [i]); status_menu_populate (self, custom_status_array); for (int i = 0 ; i < NUM_STATUS_TYPES ; i++) { g_slist_foreach (custom_status_array [i], (GFunc) g_free, 0); g_slist_free (custom_status_array [i]); } gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0); gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self), (GtkTreeViewRowSeparatorFunc) status_menu_row_is_separator, NULL, NULL); gtk_container_set_border_width (GTK_CONTAINER (self), 0); status_menu_set_option (self, self->priv->personal_details->get_presence (), self->priv->personal_details->get_status ()); g_signal_connect (G_OBJECT (self), "changed", G_CALLBACK (status_menu_option_changed), self); gm_conf_notifier_add (PERSONAL_DATA_KEY "online_custom_status", status_menu_custom_messages_changed, self); gm_conf_notifier_add (PERSONAL_DATA_KEY "away_custom_status", status_menu_custom_messages_changed, self); gm_conf_notifier_add (PERSONAL_DATA_KEY "dnd_custom_status", status_menu_custom_messages_changed, self); conn = self->priv->personal_details->updated.connect (sigc::bind (sigc::ptr_fun (on_details_updated), self)); self->priv->connections.push_back (conn); return GTK_WIDGET (self); }
GtkWidget * gnome_prefs_string_option_menu_new (GtkWidget *table, const gchar *label_txt, const gchar **options, const gchar *conf_key, const gchar *tooltip, int row, const gchar *default_value) { GnomePrefsWindow *gpw = NULL; GtkWidget *label = NULL; GtkWidget *option_menu = NULL; GtkListStore *list_store = NULL; GtkCellRenderer *renderer = NULL; GtkTreeIter iter; gchar *conf_string = NULL; gboolean writable = FALSE; int history = -1; int cpt = 0; writable = gm_conf_is_key_writable (conf_key); label = gtk_label_new (label_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); list_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); option_menu = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store)); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (option_menu), FALSE); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (option_menu), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (option_menu), renderer, "text", COLUMN_STRING_TRANSLATED, "sensitive", COLUMN_SENSITIVE, NULL); g_object_set (G_OBJECT (renderer), "ellipsize-set", TRUE, "ellipsize", PANGO_ELLIPSIZE_END, "width-chars", 45, NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (label), option_menu); conf_string = gm_conf_get_string (conf_key); if (conf_string == NULL) conf_string = g_strdup (default_value); while (options [cpt]) { if (conf_string && !g_strcmp0 (conf_string, options [cpt])) history = cpt; gtk_list_store_append (GTK_LIST_STORE (list_store), &iter); gtk_list_store_set (GTK_LIST_STORE (list_store), &iter, COLUMN_STRING_RAW, options [cpt], COLUMN_STRING_TRANSLATED, gettext (options [cpt]), COLUMN_SENSITIVE, TRUE, -1); cpt++; } if (history == -1) { if (conf_string && g_strcmp0 (conf_string, "")) { gtk_list_store_append (GTK_LIST_STORE (list_store), &iter); gtk_list_store_set (GTK_LIST_STORE (list_store), &iter, COLUMN_STRING_RAW, conf_string, COLUMN_STRING_TRANSLATED, gettext (conf_string), COLUMN_SENSITIVE, FALSE, -1); history = cpt; } else history = 0; } gtk_combo_box_set_active (GTK_COMBO_BOX (option_menu), history); gtk_table_attach (GTK_TABLE (table), option_menu, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (table), "gpw"); if (gpw && tooltip) gtk_widget_set_tooltip_text (option_menu, tooltip); g_signal_connect (option_menu, "changed", G_CALLBACK (string_option_menu_changed), (gpointer) conf_key); gm_conf_notifier_add (conf_key, string_option_menu_changed_nt, (gpointer) option_menu); g_free (conf_string); gtk_widget_show_all (table); return option_menu; }
void gnome_prefs_range_new (GtkWidget *table, const gchar *label1_txt, GtkWidget **spin1, const gchar *label2_txt, GtkWidget **spin2, const gchar *label3_txt, const gchar *spin1_conf_key, const gchar *spin2_conf_key, const gchar *spin1_tooltip, const gchar *spin2_tooltip, double spin1_min, double spin2_min, double spin1_max, double spin2_max, double spins_step, int row) { GnomePrefsWindow *gpw = NULL; int val1 = 0, val2 = 0; gboolean writable = FALSE; GtkWidget *hbox = NULL; GtkAdjustment *adj1 = NULL; GtkWidget *spin_button1 = NULL; GtkWidget *spin_button2 = NULL; GtkAdjustment *adj2 = NULL; GtkWidget *label = NULL; writable = (gm_conf_is_key_writable (spin1_conf_key) && gm_conf_is_key_writable (spin2_conf_key)); hbox = gtk_hbox_new (FALSE, 0); label = gtk_label_new_with_mnemonic (label1_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); val1 = gm_conf_get_int (spin1_conf_key); adj1 = (GtkAdjustment *) gtk_adjustment_new (val1, spin1_min, spin1_max, spins_step, 2.0, 1.0); spin_button1 = gtk_spin_button_new (adj1, 1.0, 0); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (spin_button1), FALSE); gtk_box_pack_start (GTK_BOX (hbox), spin_button1, FALSE, FALSE, 1 * 2); label = gtk_label_new_with_mnemonic (label2_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); val2 = gm_conf_get_int (spin2_conf_key); adj2 = (GtkAdjustment *) gtk_adjustment_new (val2, spin2_min, spin2_max, spins_step, 2.0, 1.0); spin_button2 = gtk_spin_button_new (adj2, 1.0, 0); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (spin_button2), FALSE); gtk_box_pack_start (GTK_BOX (hbox), spin_button2, FALSE, FALSE, 1 * 2); label = gtk_label_new_with_mnemonic (label3_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, row, row+1, (GtkAttachOptions) (NULL), (GtkAttachOptions) (NULL), 0, 0); gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (table), "gpw"); if (gpw && spin1_tooltip && spin2_tooltip) { gtk_widget_set_tooltip_text (spin_button1, spin1_tooltip); gtk_widget_set_tooltip_text (spin_button2, spin2_tooltip); } g_signal_connect (adj1, "value-changed", G_CALLBACK (adjustment_changed), (gpointer) spin1_conf_key); gm_conf_notifier_add (spin1_conf_key, adjustment_changed_nt, (gpointer) adj1); g_signal_connect (adj2, "value-changed", G_CALLBACK (adjustment_changed), (gpointer) spin2_conf_key); gm_conf_notifier_add (spin2_conf_key, adjustment_changed_nt, (gpointer) adj2); if (spin1) *spin1 = spin_button1; if (spin2) *spin2 = spin_button2; }
GtkWidget * gnome_prefs_spin_new (GtkWidget *table, const gchar *label_txt, const gchar *conf_key, const gchar *tooltip, double min, double max, double step, int row, const gchar *label_txt2, gboolean box) { GnomePrefsWindow *gpw = NULL; GtkWidget *hbox = NULL; GtkAdjustment *adj = NULL; GtkWidget *label = NULL; GtkWidget *spin_button = NULL; gboolean writable = FALSE; writable = gm_conf_is_key_writable (conf_key); if (box) hbox = gtk_hbox_new (FALSE, 0); label = gtk_label_new_with_mnemonic (label_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); if (box) gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); else gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); adj = (GtkAdjustment *) gtk_adjustment_new (gm_conf_get_int (conf_key), min, max, step, 10.0, 0.0); spin_button = gtk_spin_button_new (adj, 1.0, 0); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (spin_button), FALSE); if (box) gtk_box_pack_start (GTK_BOX (hbox), spin_button, FALSE, FALSE, 1 * 2); else gtk_table_attach (GTK_TABLE (table), spin_button, 1, 2, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); if (box && label_txt2) { label = gtk_label_new_with_mnemonic (label_txt2); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); } if (box) { guint ncols; g_object_get (G_OBJECT (table), "n-columns", &ncols, NULL); gtk_table_attach (GTK_TABLE (table), hbox, 0, ncols, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); } gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (table), "gpw"); if (gpw && tooltip) gtk_widget_set_tooltip_text (spin_button, tooltip); g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), (gpointer) conf_key); gm_conf_notifier_add (conf_key, adjustment_changed_nt, (gpointer) adj); gtk_widget_show_all (table); return spin_button; }
GtkWidget * gnome_prefs_scale_new (GtkWidget *table, const gchar *down_label_txt, const gchar *up_label_txt, const gchar *conf_key, const gchar *tooltip, double min, double max, double step, int row) { GnomePrefsWindow *gpw = NULL; GtkWidget *hbox = NULL; GtkAdjustment *adj = NULL; GtkWidget *label = NULL; GtkWidget *hscale = NULL; gboolean writable = FALSE; writable = gm_conf_is_key_writable (conf_key); hbox = gtk_hbox_new (FALSE, 0); label = gtk_label_new_with_mnemonic (down_label_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); adj = (GtkAdjustment *) gtk_adjustment_new (gm_conf_get_int (conf_key), min, max, step, 2.0, 1.0); hscale = gtk_hscale_new (adj); gtk_scale_set_draw_value (GTK_SCALE (hscale), FALSE); gtk_widget_set_size_request (GTK_WIDGET (hscale), 150, -1); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (hscale), FALSE); gtk_box_pack_start (GTK_BOX (hbox), hscale, FALSE, FALSE, 1 * 2); label = gtk_label_new_with_mnemonic (up_label_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (table), "gpw"); if (gpw && tooltip) gtk_widget_set_tooltip_text (hscale, tooltip); g_signal_connect (adj, "value-changed", G_CALLBACK (adjustment_changed), (gpointer) conf_key); gm_conf_notifier_add (conf_key, adjustment_changed_nt, (gpointer) adj); gtk_widget_show_all (table); return hscale; }
/* The public functions */ GtkWidget * gnome_prefs_entry_new (GtkWidget *table, const gchar *label_txt, const gchar *conf_key, const gchar *tooltip, int row, gboolean box) { GnomePrefsWindow *gpw = NULL; GValue value = { 0, {{0}, {0}}}; int cols = 0; GtkWidget *entry = NULL; GtkWidget *label = NULL; GtkWidget *hbox = NULL; gchar *conf_string = NULL; gboolean writable = FALSE; writable = gm_conf_is_key_writable (conf_key); if (box) { hbox = gtk_hbox_new (FALSE, 0); g_value_init (&value, G_TYPE_INT); g_object_get_property (G_OBJECT (table), "n-columns", &value); cols = g_value_get_int (&value); g_value_unset (&value); } label = gtk_label_new_with_mnemonic (label_txt); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (label), FALSE); if (box) gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1 * 2); else gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (GTK_FILL), 0, 0); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); entry = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL(label), entry); if (!writable) gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE); if (box) gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 1 * 2); else gtk_table_attach (GTK_TABLE (table), entry, 1, 2, row, row+1, (GtkAttachOptions) (NULL), (GtkAttachOptions) (NULL), 0, 0); conf_string = gm_conf_get_string (conf_key); if (conf_string != NULL) gtk_entry_set_text (GTK_ENTRY (entry), conf_string); g_free (conf_string); g_signal_connect_after (entry, "focus-out-event", G_CALLBACK (entry_focus_changed), (gpointer)conf_key); g_signal_connect_after (entry, "activate", G_CALLBACK (entry_activate_changed), (gpointer)conf_key); gm_conf_notifier_add (conf_key, entry_changed_nt, (gpointer) entry); if (box) gtk_table_attach (GTK_TABLE (table), hbox, 0, cols, row, row+1, (GtkAttachOptions) (NULL), (GtkAttachOptions) (NULL), 0, 0); gpw = (GnomePrefsWindow *) g_object_get_data (G_OBJECT (table), "gpw"); if (gpw && tooltip) gtk_widget_set_tooltip_text (entry, tooltip); gtk_widget_show_all (table); return entry; }