static void update_title_stack (GtkShortcutsWindow *self) { GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self); GtkWidget *visible_child; visible_child = gtk_stack_get_visible_child (priv->stack); if (GTK_IS_SHORTCUTS_SECTION (visible_child)) { if (number_of_children (GTK_CONTAINER (priv->stack)) > 3) { gchar *title; gtk_stack_set_visible_child_name (priv->title_stack, "sections"); g_object_get (visible_child, "title", &title, NULL); gtk_label_set_label (priv->menu_label, title); g_free (title); } else { gtk_stack_set_visible_child_name (priv->title_stack, "title"); } } else if (visible_child != NULL) { gtk_stack_set_visible_child_name (priv->title_stack, "search"); } }
//---------------------------------------------------------------------------// bool Schema::compatible(const Schema &s) const { index_t dt_id = m_dtype.id(); index_t s_dt_id = s.dtype().id(); if(dt_id != s_dt_id) return false; bool res = true; if(dt_id == DataType::OBJECT_ID) { // each of s's entries that match paths must have dtypes that match std::map<std::string, index_t>::const_iterator itr; for(itr = s.object_map().begin(); itr != s.object_map().end() && res; itr++) { // make sure we actually have the path if(has_path(itr->first)) { // use index to fetch the child from the other schema const Schema &s_chld = s.child(itr->second); // fetch our child by name const Schema &chld = fetch_child(itr->first); // do compat check res = chld.compatible(s_chld); } } } else if(dt_id == DataType::LIST_ID) { // each of s's entries dtypes must match index_t s_n_chd = s.number_of_children(); // can't be compatible in this case if(number_of_children() < s_n_chd) return false; const std::vector<Schema*> &s_lst = s.children(); const std::vector<Schema*> &lst = children(); for(index_t i = 0; i < s_n_chd && res; i++) { res = lst[i]->compatible(*s_lst[i]); } } else { res = m_dtype.compatible(s.dtype()); } return res; }
//---------------------------------------------------------------------------// bool Schema::equals(const Schema &s) const { index_t dt_id = m_dtype.id(); index_t s_dt_id = s.dtype().id(); if(dt_id != s_dt_id) return false; bool res = true; if(dt_id == DataType::OBJECT_ID) { // all entries must be equal std::map<std::string, index_t>::const_iterator itr; for(itr = s.object_map().begin(); itr != s.object_map().end() && res; itr++) { if(has_path(itr->first)) { index_t s_idx = itr->second; res = s.children()[s_idx]->equals(fetch_child(itr->first)); } else { res = false; } } for(itr = object_map().begin(); itr != object_map().end() && res; itr++) { if(s.has_path(itr->first)) { index_t idx = itr->second; res = children()[idx]->equals(s.fetch_child(itr->first)); } else { res = false; } } } else if(dt_id == DataType::LIST_ID) { // all entries must be equal index_t s_n_chd = s.number_of_children(); // can't be compatible in this case if(number_of_children() != s_n_chd) return false; const std::vector<Schema*> &s_lst = s.children(); const std::vector<Schema*> &lst = children(); for(index_t i = 0; i < s_n_chd && res; i++) { res = lst[i]->equals(*s_lst[i]); } } else { res = m_dtype.equals(s.dtype()); } return res; }