@@ -4,27 +4,33 @@ You should know:
4
4
- D_ prefix is used for Diploma Holder functions.
5
5
6
6
void on_submit_button_clicked(GtkWidget *widget, gpointer data)
7
- - Handles the 'submit' button click event in a GTK application.
8
- - Retrieves text from SSC and HSC entry widgets and the selected department from a combo box.
9
- - Checks if any of the required fields are empty and displays a message if so.
10
- - Converts the retrieved text to float values for SSC and HSC results.
11
- - Initializes an Undergraduate struct with pointers to department-specific functions.
12
- - Calls the appropriate function based on the selected department,
13
- passing SSC and HSC results along with a callback function to display results.
14
- - Frees memory allocated by GTK for the selected department string.
7
+ - Handles the submission of user input for undergraduate program admission calculations.
8
+ - Parameters:
9
+ - GtkWidget *widget: The widget that triggered this callback.
10
+ - gpointer data: Additional data passed to the callback (unused in this function).
11
+ - Steps:
12
+ - Retrieves the text entered in the SSC, HSC, and credit entry fields, as well as the selected department.
13
+ - Checks if any required fields are empty. If so, displays an error message and clears the result view.
14
+ - Converts the SSC and HSC text to double values.
15
+ - Clears the result view.
16
+ - Calls `getCalculated` function for the selected department, passing the SSC, HSC, `get_credit` callback, and `display_result` callback to perform the calculation and display the result.
17
+ - Frees the memory allocated for the selected department string.
15
18
16
19
NOTE: This function is crucial for processing user input and ensuring that all required
17
20
fields are filled before proceeding with department-specific calculations or actions.
18
21
19
22
void D_on_submit_button_clicked(GtkWidget *widget, gpointer data)
20
- - Serves as a callback for the 'submit' button in the diploma interface of a GTK application.
21
- - Retrieves text from the diploma entry widget and the selected department from a combo box.
22
- - Checks if any of the required fields are empty and displays a message if so.
23
- - Converts the retrieved text to a float value for the diploma result.
24
- - Initializes an `UndergraduateDiploma` struct with pointers to department-specific functions for diploma holders.
25
- - Calls the appropriate function based on the selected department,
26
- passing the diploma result along with a callback function to display results.
27
- - Frees memory allocated by GTK for the selected department string.
23
+ - Handles the submission of user input for diploma program admission calculations.
24
+ - Parameters:
25
+ - GtkWidget *widget: The widget that triggered this callback.
26
+ - gpointer data: Additional data passed to the callback (unused in this function).
27
+ - Steps:
28
+ - Retrieves the text entered in the diploma entry, credit entry fields and the selected department.
29
+ - Checks if any required fields are empty. If so, displays an error message and clears the result view.
30
+ - Converts the diploma text to a double value.
31
+ - Clears the result view.
32
+ - Calls `D_getCalculated` function for the selected department, passing the diploma result, `D_get_credit` callback, and `display_result` callback to perform the calculation and display the result.
33
+ - Frees the memory allocated for the selected department string.
28
34
29
35
NOTE: This function is essential for processing diploma holder input and ensuring that all required
30
36
fields are filled before proceeding with department-specific calculations or actions.
@@ -38,43 +44,118 @@ void display_result(const char *message)
38
44
NOTE: The `display_result` function is a utility function used throughout the GTK application to output
39
45
messages to both the user interface and the console, aiding in both user interaction and debugging.
40
46
47
+ int get_credit(sqlite3_stmt *stmt)
48
+ - Checks if the credit transfer option is active using the `credit_transfer_check_yes` toggle button.
49
+ - Retrieves the total number of credits, the number of semesters, and the duration in years from the database statement.
50
+ - If the credit transfer option is active
51
+ - Calculates the minimum and maximum credits based on the total credits and number of semesters.
52
+ - Retrieves the number of credits entered by the user from the `credit_entry` widget.
53
+ - Checks if the entered credits are within the valid range (between minimum and maximum credits).
54
+ - If the entered credits are less than the minimum required credits, displays an error message using `display_result`.
55
+ - If the entered credits are more than the maximum allowed credits, displays an error message.
56
+ - Calculates the approximate number of semesters and years based on the entered credits.
57
+ - Returns 0 on success, or -1 if there are any errors or invalid input.
58
+
59
+ int D_get_credit(sqlite3_stmt *stmt, double DiplomaResult)
60
+ - Checks if the credit transfer option is active using the `credit_transfer_check_yes` toggle button.
61
+ - Retrieves the total number of credits, the number of semesters, and the duration in years from the database statement.
62
+ - If the credit transfer option is active
63
+ - Calculates the minimum and maximum credits based on the total credits and number of semesters.
64
+ - Retrieves the number of credits entered by the user from the `credit_entry` widget.
65
+ - Checks if the entered credits are within the valid range (between minimum and maximum credits).
66
+ - If the entered credits are less than the minimum required credits, displays an error message using `display_result`.
67
+ - If the entered credits are more than the maximum allowed credits, displays an error message.
68
+ - Calculates the approximate number of semesters and years based on the entered credits.
69
+ - Calls the `D_getwaiver` function to determine waiver eligibility based on the `DiplomaResult`.
70
+ - If eligible, retrieves the total credits and number of semesters for waiver.
71
+ - If not eligible, retrieves the total credits and number of semesters without waiver.
72
+ - Returns 0 on success, or -1 if there are any errors or invalid input.
73
+
74
+ void on_credit_transfer_no_toggled(GtkToggleButton *togglebutton, gpointer data)
75
+ - This function is called when the "No" option for credit transfer is toggled.
76
+ - It sets the credit transfer option to "No" by deactivating the credit entry widget.
77
+ - Ensures that the related interface elements for credit transfer are disabled.
78
+
79
+ void on_credit_transfer_yes_toggled(GtkToggleButton *togglebutton, gpointer data)
80
+ - This function is called when the "Yes" option for credit transfer is toggled.
81
+ - It sets the credit transfer option to "Yes" by activating the credit entry widget.
82
+ - Ensures that the related interface elements for credit transfer are enabled.
83
+
41
84
void show_undergraduate(GtkWidget *widget, gpointer data)
42
- - This callback function is triggered to show the undergraduate interface.
43
- - It first clears any previous content in the container using `gtk_container_foreach` and `gtk_widget_destroy`.
44
- - Then, it calls `create_undergraduate_interface` to build the undergraduate interface inside the content area.
45
- - Finally, it refreshes the container to display the new interface with `gtk_widget_show_all`.
85
+ - Clears the existing content in the container and displays the undergraduate interface.
86
+ - Parameters:
87
+ - GtkWidget *widget: The widget that triggered this callback.
88
+ - gpointer data: Additional data passed to the callback (unused in this function).
89
+ - Steps:
90
+ - Calls `gtk_container_foreach` to iterate over all children of `content_area` and destroy them, clearing the previous content.
91
+ - Calls `create_undergraduate_interface` to create and set up the undergraduate interface within `content_area`.
92
+ - Calls `gtk_widget_show_all` to refresh the `content_area` and display the new contents.
93
+ - Sets the `credit_entry` widget to be invisible initially, as the "No" option for credit transfer is toggled by default.
46
94
47
95
void show_diploma(GtkWidget *widget, gpointer data)
48
- - Similar to `show_undergraduate`, this callback function is used to show the diploma interface.
49
- - It clears any existing content in the container.
50
- - Calls `create_diploma_interface` to construct the diploma interface within the content area.
51
- - Refreshes the container to update the display with the new interface.
96
+ - Clears the existing content in the container and displays the diploma interface.
97
+ - Parameters:
98
+ - GtkWidget *widget: The widget that triggered this callback.
99
+ - gpointer data: Additional data passed to the callback (unused in this function).
100
+ - Steps:
101
+ - Calls `gtk_container_foreach` to iterate over all children of `content_area` and destroy them, clearing the previous content.
102
+ - Calls `create_diploma_interface` to create and set up the diploma interface within `content_area`.
103
+ - Calls `gtk_widget_show_all` to refresh the `content_area` and display the new contents.
104
+ - Sets the `credit_entry` widget to be invisible initially, as the "No" option for credit transfer is toggled by default.
52
105
53
106
NOTE: Both functions are essential for switching between different user interfaces within the application,
54
107
ensuring a smooth transition and clear display of the relevant interface based on user selection.
55
108
56
109
void create_undergraduate_interface(GtkWidget *container)
57
- - This function constructs the undergraduate interface within a given container widget.
58
- - It creates a new grid widget to organize interface elements.
59
- - Adds labels and entry widgets for SSC and HSC results, allowing users to input their scores.
60
- - Sets up a combo box for department selection with various options like BBA, LLB, EEE, etc.
61
- - Includes a 'Submit' button that triggers the `on_submit_button_clicked` callback when clicked.
62
- - Initializes a text view and its associated buffer for displaying results, making it non-editable and hiding the cursor.
110
+ - Creates and sets up the user interface for the undergraduate program section.
111
+ - Parameters:
112
+ - GtkWidget *container: The GTK container widget where the undergraduate interface will be added.
113
+ - Steps:
114
+ - Initializes the GTK grid and packs it into the provided container.
115
+ - Creates and configures the widgets for SSC result, HSC result, department selection, credit transfer options, and submission button.
116
+ - Adds labels, entries, combo boxes, and buttons to the grid.
117
+ - Connects the signals and callbacks to handle user interactions for credit transfer options and the submit button.
118
+ - Adds a text view for displaying results and sets its properties to be non-editable and non-visible cursor.
119
+ - Packs and attaches the widgets to the provided container using the grid layout.
63
120
64
121
NOTE: The `create_undergraduate_interface` function is crucial for setting up the user interface where undergraduate applicants
65
122
can enter their results and select their desired department for further processing or evaluation in the application.
66
123
67
124
void create_diploma_interface(GtkWidget *container)
68
- - This function is designed to construct the diploma interface within a specified container widget.
69
- - It creates a grid layout to organize interface elements systematically.
70
- - Adds a label and an entry widget for the diploma result, allowing diploma holders to input their score.
71
- - Sets up a combo box for department selection with options like EEE, Textile, CSE, etc.
72
- - Includes a 'Submit' button that connects to the `D_on_submit_button_clicked` callback for processing the input when clicked.
73
- - Initializes a text view and its associated buffer for result display, configured to be non-editable and with an invisible cursor.
125
+ - Creates and sets up the user interface for the diploma holders section.
126
+ - Parameters:
127
+ - GtkWidget *container: The GTK container widget where the diploma interface will be added.
128
+ - Steps:
129
+ - Initializes the GTK grid and packs it into the provided container.
130
+ - Creates and configures the widgets for Diploma result, department selection, credit transfer options, and submission button.
131
+ - Adds labels, entries, combo boxes, and buttons to the grid.
132
+ - Connects the signals and callbacks to handle user interactions for credit transfer options and the submit button.
133
+ - Adds a text view for displaying results and sets its properties to be non-editable and non-visible cursor.
134
+ - Packs and attaches the widgets to the provided container using the grid layout.
74
135
75
136
NOTE: The `create_diploma_interface` function plays a key role in providing a user interface for diploma holders to
76
137
enter their results and choose their department for subsequent actions or calculations in the application.
77
138
139
+ void on_about_activate(GtkWidget *widget)
140
+ - Activates and displays the "About" dialog.
141
+ - Calls the read_about_description() function to read the description from the file.
142
+ - Creates a new GTK dialog with the title "About".
143
+ - Creates a vertical box (vbox) to hold the contents of the dialog.
144
+ - Creates a label widget for the description and sets its text to about_description.
145
+ - Packs the label into the vertical box.
146
+ - Creates a horizontal box (hbox) to hold additional text and the "Give a Star" button.
147
+ - Creates a label widget for additional text "Help us by giving a star to the GitHub repo" and packs it into the horizontal box.
148
+ - Creates a button labeled "Give a Star", connects its "clicked" signal to the on_give_star_clicked function, and packs it into the horizontal box.
149
+ - Packs the horizontal box into the vertical box.
150
+ - Adds the vertical box to the content area of the dialog.
151
+ - Displays all widgets in the dialog.
152
+ - Connects the "response" signal of the dialog to the gtk_widget_destroy function to handle dialog closure.
153
+
154
+ void on_give_star_clicked()
155
+ - Handles the action when the "Give a Star" button is clicked in the "About" dialog.
156
+ - Defines the GitHub repository URL as "https://github.com/nazmusweb-coding/DOS-Programming".
157
+ - Uses gtk_show_uri_on_window() to open the GitHub repository URL in the default web browser.
158
+
78
159
GtkWidget *content_area;
79
160
- This global widget serves as the main container for the content in the application.
80
161
It is where different interfaces are loaded and displayed.
@@ -95,19 +176,40 @@ GtkTextBuffer *result_buffer;
95
176
GtkWidget *diploma_entry;
96
177
- Similar to `ssc_entry` and `hsc_entry`, this global entry widget is used for inputting diploma results in the diploma interface.
97
178
179
+ GtkWidget *credit_transfer_check_no;
180
+ - Represents a global GTK check button widget used to indicate the absence of credit transfer option.
181
+ - Initially set to active state (checked) by default.
182
+ - Used in the user interface to allow selection of no credit transfer option.
183
+
184
+ GtkWidget *credit_transfer_check_yes;
185
+ - Represents a global GTK check button widget used to indicate the presence of credit transfer option.
186
+ - Initially set to inactive state (unchecked) by default.
187
+ - Used in the user interface to allow selection of credit transfer option.
188
+
189
+ GtkWidget *credit_entry;
190
+ - Represents a global GTK entry widget used for user input of the amount of credit to transfer.
191
+ - Placeholder text suggests users to enter the amount of credit.
192
+ - Used alongside the credit transfer check buttons to provide additional information when credit transfer option is selected.
193
+
98
194
int main(int argc, char **argv)
99
- - This function is the entry point of the GTK application.
100
- - Initializes GTK with `gtk_init`.
101
- - Creates the main window with a title "NUB Admission Costing Calculator" and sets
102
- its properties like border width, default size, position, and resizability.
103
- - Sets up a grid layout as the main container for the window's content.
104
- - Constructs a menu bar with menu items "Undergraduate" and "Undergraduate (for Diploma Holders)"
105
- which are connected to their respective callback functions to display different interfaces.
106
- - Initializes the `content_area` as a vertical box to hold different interfaces and attaches it to the grid.
107
- - Calls `create_undergraduate_interface` to load the undergraduate interface by default.
108
- - Shows all widgets with `gtk_widget_show_all`.
109
- - Connects the window's destroy event to end the GTK main loop, allowing for clean exit of the application.
110
- - Enters GTK main loop with `gtk_main`.
195
+ - Initializes GTK and creates the main window with a menu bar.
196
+ - Parameters:
197
+ - int argc: The number of command-line arguments.
198
+ - char **argv: The array of command-line arguments.
199
+ - Steps:
200
+ - Initializes the GTK library with the command-line arguments.
201
+ - Creates the main window with a title and default size.
202
+ - Sets the window position to center and makes the window non-resizable.
203
+ - Creates a grid layout and attaches it to the main window.
204
+ - Creates a menu bar with options for "Undergraduate", "Undergraduate (for Diploma Holders)", and "About".
205
+ - Connects the menu items to their respective callback functions: `show_undergraduate`, `show_diploma`, and `on_about_activate`.
206
+ - Attaches the menu bar to the grid.
207
+ - Creates a vertical box as the content area and attaches it to the grid.
208
+ - Displays the undergraduate interface by default.
209
+ - Shows all widgets and hides the credit entry field by default.
210
+ - Connects the main window's destroy event to the GTK main loop to ensure proper application termination.
211
+ - Enters the GTK main loop.
212
+ - Returns 0 upon successful completion.
111
213
112
214
NOTE: The `main` function sets up the initial state of the application, including window properties, menu options,
113
215
and default interface. It also handles event connections for user interactions and application lifecycle.
0 commit comments