GTK v1.2 Tutorial(英文)Now that we have a combo box, tailored to look and act how we want it, all that remains is being able to get data from the combo box. This is relatively straightforward. The majority of the time, all you are going to care about getting data from is the entry. The entry is accessed simply by GTK_ENTRY(GTK_COMBO(combo)->entry). The two principal things that you are going to want to do with it are attach to the activate signal, which indicates that the user has pressed the Return or Enter key, and read the text. The first is accomplished using something like:
Getting the text at any arbitrary time is accomplished by simply using the entry function:
Such as:
that will disable the activate signal on the entry widget in the combo box. Personally, I can't think of why you'd want to use it, but it does exist. 9.12 Calendar The Calendar widget is an effective way to display and retrieve monthly date related information. It is a very simple widget to create and work with. Creating a GtkCalendar widget is a simple as:
There might be times where you need to change a lot of information within this widget and the following functions allow you to make multiple change to a Calendar widget without the user seeing multiple on-screen updates.
They work just like the freeze/thaw functions of every other widget. The Calendar widget has a few options that allow you to change the way the widget both looks and operates by using the function
The flags argument can be formed by combining either of the following five options using the logical bitwise OR (|) operation: GTK_CALENDAR_SHOW_HEADING - this option specifies that the month and year should be shown when drawing the calendar. GTK_CALENDAR_SHOW_DAY_NAMES - this option specifies that the three letter descriptions should be displayed for each day (eg MON,TUE...). GTK_CALENDAR_NO_MONTH_CHANGE - this option states that the user should not and can not change the currently displayed month. This can be good if you only need to display a particular month such as if you are displaying 12 calendar widgets for every month in a particular year. GTK_CALENDAR_SHOW_WEEK_NUMBERS - this option specifies that the number for each week should be displayed down the left side of the calendar. (eg. Jan 1 = Week 1,Dec 31 = Week 52). GTK_CALENDAR_WEEK_START_MONDAY - this option states that the calander week will start on Monday instead of Sunday which is the default. This only affects the order in which days are displayed from left to right. The following functions are used to set the the currently displayed date:
The return value from gtk_calendar_select_month() is a boolean value indicating whether the selection was successful. With gtk_calendar_select_day() the specified day number is selected within the current month, if that is possible. A day value of 0 will deselect any current selection. In addition to having a day selected, any number of days in the month may be "marked". A marked day is highlighted within the calendar display. The following functions are provided to manipulate marked days:
|