Update UI to use country/city chooser
This commit is contained in:
		| @@ -24,6 +24,8 @@ struct _AgWindowPrivate { | ||||
|     GtkWidget     *selection_toolbar; | ||||
|     GtkWidget     *stack; | ||||
|     GtkWidget     *name; | ||||
|     GtkWidget     *country; | ||||
|     GtkWidget     *city; | ||||
|     GtkWidget     *north_lat; | ||||
|     GtkWidget     *south_lat; | ||||
|     GtkWidget     *latitude; | ||||
| @@ -55,6 +57,8 @@ struct _AgWindowPrivate { | ||||
|     GtkListStore  *house_system_model; | ||||
|     GtkListStore  *db_chart_data; | ||||
|     AgDbSave      *saved_data; | ||||
|     GtkEntryCompletion *country_comp; | ||||
|     GtkEntryCompletion *city_comp; | ||||
| }; | ||||
|  | ||||
| G_DEFINE_QUARK(ag_window_error_quark, ag_window_error); | ||||
| @@ -1387,6 +1391,15 @@ ag_window_list_selection_changed_cb(GdMainView *view, AgWindow *window) | ||||
|     // Here it is possible to set button sensitivity later | ||||
| } | ||||
|  | ||||
| gboolean | ||||
| ag_window_country_selected_callback(GtkEntryCompletion *country_comp, | ||||
|                                     GtkTreeModel       *list, | ||||
|                                     GtkTreeIter        *iter, | ||||
|                                     AgWindow           *window) | ||||
| { | ||||
|     return FALSE; | ||||
| } | ||||
|  | ||||
| static void | ||||
| ag_window_init(AgWindow *window) | ||||
| { | ||||
| @@ -1414,6 +1427,15 @@ ag_window_init(AgWindow *window) | ||||
|             window | ||||
|         ); | ||||
|  | ||||
|     gtk_entry_completion_set_model(priv->country_comp, country_list); | ||||
|     gtk_entry_completion_set_text_column(priv->country_comp, AG_COUNTRY_NAME); | ||||
|     gtk_entry_set_completion(GTK_ENTRY(priv->country), priv->country_comp); | ||||
|  | ||||
|     gtk_entry_completion_set_model(priv->city_comp, city_list); | ||||
|     gtk_entry_completion_set_text_column(priv->city_comp, AG_CITY_NAME); | ||||
|     gtk_entry_completion_set_minimum_key_length(priv->city_comp, 3); | ||||
|     gtk_entry_set_completion(GTK_ENTRY(priv->city), priv->city_comp); | ||||
|  | ||||
|     house_system_list = gswe_all_house_systems(); | ||||
|     g_list_foreach(house_system_list, (GFunc)ag_window_add_house_system, priv); | ||||
|     g_list_free(house_system_list); | ||||
| @@ -1506,6 +1528,16 @@ ag_window_name_changed_cb(GtkEntry *name_entry, AgWindow *window) | ||||
|     gtk_header_bar_set_subtitle(GTK_HEADER_BAR(priv->header_bar), name); | ||||
| } | ||||
|  | ||||
| static void | ||||
| ag_window_country_changed_callback(GtkSearchEntry *country, AgWindow *window) | ||||
| { | ||||
| } | ||||
|  | ||||
| static void | ||||
| ag_window_city_changed_callback(GtkSearchEntry *city, AgWindow *window) | ||||
| { | ||||
| } | ||||
|  | ||||
| static void | ||||
| ag_window_class_init(AgWindowClass *klass) | ||||
| { | ||||
| @@ -1544,6 +1576,22 @@ ag_window_class_init(AgWindowClass *klass) | ||||
|             tab_edit | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_child_private(widget_class, AgWindow, name); | ||||
|     gtk_widget_class_bind_template_child_private( | ||||
|             widget_class, | ||||
|             AgWindow, | ||||
|             country | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_child_private( | ||||
|             widget_class, | ||||
|             AgWindow, | ||||
|             country_comp | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_child_private(widget_class, AgWindow, city); | ||||
|     gtk_widget_class_bind_template_child_private( | ||||
|             widget_class, | ||||
|             AgWindow, | ||||
|             city_comp | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_child_private(widget_class, AgWindow, year); | ||||
|     gtk_widget_class_bind_template_child_private(widget_class, AgWindow, month); | ||||
|     gtk_widget_class_bind_template_child_private(widget_class, AgWindow, day); | ||||
| @@ -1642,6 +1690,18 @@ ag_window_class_init(AgWindowClass *klass) | ||||
|             widget_class, | ||||
|             ag_window_name_changed_cb | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_callback( | ||||
|             widget_class, | ||||
|             ag_window_country_selected_callback | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_callback( | ||||
|             widget_class, | ||||
|             ag_window_country_changed_callback | ||||
|         ); | ||||
|     gtk_widget_class_bind_template_callback( | ||||
|             widget_class, | ||||
|             ag_window_city_changed_callback | ||||
|         ); | ||||
| } | ||||
|  | ||||
| gboolean | ||||
|   | ||||
| @@ -136,6 +136,11 @@ | ||||
|       <column type="guint"/> | ||||
|     </columns> | ||||
|   </object> | ||||
|   <object class="GtkEntryCompletion" id="country_comp"> | ||||
|     <signal name="match-selected" handler="ag_window_country_selected_callback" swapped="no"/> | ||||
|   </object> | ||||
|   <object class="GtkEntryCompletion" id="city_comp"> | ||||
|   </object> | ||||
|   <template class="AgWindow" parent="GtkApplicationWindow"> | ||||
|     <property name="can_focus">False</property> | ||||
|     <property name="has_focus">False</property> | ||||
| @@ -394,10 +399,11 @@ | ||||
|                     <property name="primary_icon_name">edit-find-symbolic</property> | ||||
|                     <property name="primary_icon_activatable">False</property> | ||||
|                     <property name="primary_icon_sensitive">False</property> | ||||
|                     <signal name="search-changed" handler="ag_window_country_changed_callback" swapped="no"/> | ||||
|                   </object> | ||||
|                   <packing> | ||||
|                     <property name="left_attach">1</property> | ||||
|                     <property name="top_attach">2</property> | ||||
|                     <property name="top_attach">1</property> | ||||
|                     <property name="width">3</property> | ||||
|                   </packing> | ||||
|                 </child> | ||||
| @@ -419,10 +425,11 @@ | ||||
|                     <property name="primary_icon_name">edit-find-symbolic</property> | ||||
|                     <property name="primary_icon_activatable">False</property> | ||||
|                     <property name="primary_icon_sensitive">False</property> | ||||
|                     <signal name="search-changed" handler="ag_window_city_changed_callback" swapped="no"/> | ||||
|                   </object> | ||||
|                   <packing> | ||||
|                     <property name="left_attach">1</property> | ||||
|                     <property name="top_attach">1</property> | ||||
|                     <property name="top_attach">2</property> | ||||
|                     <property name="width">3</property> | ||||
|                   </packing> | ||||
|                 </child> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user