/*! \brief personality_choice() is called from a one shot timeout from main in order to open the window to ask the user what ECU family to deal with running. */ G_MODULE_EXPORT gboolean personality_choice(void) { GtkWidget *dialog = NULL; GtkWidget *vbox = NULL; GtkWidget *hbox = NULL; GtkWidget *ebox = NULL; GtkWidget *sep = NULL; GtkWidget *button = NULL; GtkWidget *label = NULL; gchar ** dirs = NULL; gchar * filename = NULL; PersonaElement *element = NULL; gchar *tmpbuf = NULL; gboolean shouldjump = FALSE; gchar *name = NULL; GArray *classes = NULL; GSList *group = NULL; GList *p_list = NULL; GList *s_list = NULL; ConfigFile *cfgfile = NULL; guint i = 0; gint result = 0; gchar * pathstub = NULL; extern gconstpointer *global_data; pathstub = g_build_filename(INTERROGATOR_DATA_DIR,"Profiles",NULL); dirs = get_dirs((const gchar *)DATA_GET(global_data,"project_name"),pathstub,&classes); if (!dirs) { MTXDBG(CRITICAL,_("NO Interrogation profiles found, was MegaTunix installed properly?\n")); return FALSE; } i = 0; while (dirs[i]) { tmpbuf = g_build_filename(dirs[i],"details.cfg",NULL); cfgfile = cfg_open_file(tmpbuf); if (!cfgfile) { /*MTXDBG(CRITICAL,_("\"%s\" file missing!, was MegaTunix installed properly?\n"),tmpbuf);*/ i++; g_free(tmpbuf); continue; } g_free(tmpbuf); element = g_new0(PersonaElement, 1); cfg_read_string(cfgfile,"Family","sequence",&element->sequence); cfg_read_string(cfgfile,"Family","friendly_name",&element->name); cfg_read_string(cfgfile,"Family","persona",&element->persona); cfg_read_string(cfgfile,"Family","ecu_lib",&element->ecu_lib); cfg_read_string(cfgfile,"Family","common_lib",&element->common_lib); if (!cfg_read_string(cfgfile,"Family","baud",&element->baud_str)) MTXDBG(CRITICAL,_("\"details.cfg\" baud string undefined!, was MegaTunix installed properly?\n")); element->dirname = g_strdup(dirs[i]); element->filename = g_path_get_basename(dirs[i]); if (g_strcasecmp(element->filename,(gchar *)DATA_GET(global_data,"last_ecu_family")) == 0) element->def = TRUE; if ((DATA_GET(global_data,"cli_persona")) && (element->persona)) { if (g_strcasecmp(element->persona, (gchar *)DATA_GET(global_data,"cli_persona")) == 0) { button = gtk_toggle_button_new(); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),TRUE); persona_selection(button,(gpointer)element); g_object_ref_sink(button); g_object_unref(button); shouldjump = TRUE; } } if (g_array_index(classes,FileClass,i) == PERSONAL) p_list = g_list_prepend(p_list,(gpointer)element); if (g_array_index(classes,FileClass,i) == SYSTEM) s_list = g_list_prepend(s_list,(gpointer)element); g_free(name); i++; cfg_free(cfgfile); } p_list = g_list_sort(p_list,persona_seq_sort); s_list = g_list_sort(s_list,persona_seq_sort); g_strfreev(dirs); g_array_free(classes,TRUE); if (shouldjump) { g_list_foreach(p_list,free_persona_element,NULL); g_list_foreach(s_list,free_persona_element,NULL); g_list_free(p_list); g_list_free(s_list); DATA_SET(global_data,"cli_persona",NULL); if (DATA_GET(global_data,"offline")) goto jumpahead_offline; else goto jumpahead; } set_title(g_strdup(_("Choose an ECU family?"))); update_logbar("interr_view","warning",_("Prompting user for ECU family to interrogate...\n"),FALSE,FALSE,FALSE); dialog = gtk_dialog_new_with_buttons("Select ECU Personality", GTK_WINDOW(lookup_widget("main_window")), GTK_DIALOG_DESTROY_WITH_PARENT, "Exit MegaTunix", GTK_RESPONSE_CLOSE, "Go Offline", GTK_RESPONSE_CANCEL, "Find my ECU", GTK_RESPONSE_OK, NULL); vbox = gtk_vbox_new(TRUE,2); gtk_container_set_border_width(GTK_CONTAINER(vbox),5); //gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),vbox,TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),vbox,TRUE,TRUE,0); if (g_list_length(p_list) > 0) { label = gtk_label_new("Custom (personal) Profiles"); gtk_box_pack_start(GTK_BOX(vbox),label,TRUE,TRUE,0); group = NULL; /* Cycle list for PERSONAL profile files */ for (i=0;i<g_list_length(p_list);i++) { element = (PersonaElement *)g_list_nth_data(p_list,i); ebox = gtk_event_box_new(); gtk_box_pack_start(GTK_BOX(vbox),ebox,TRUE,TRUE,0); hbox = gtk_hbox_new(FALSE,10); gtk_container_add(GTK_CONTAINER(ebox),hbox); label = gtk_label_new(element->name); gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,TRUE,0); if (!check_for_files (element->dirname,"prof")) { gtk_widget_set_sensitive(ebox,FALSE); button = gtk_radio_button_new(NULL); } else { button = gtk_radio_button_new(group); group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); } g_signal_connect(button, "toggled", G_CALLBACK(persona_selection), element); gtk_box_pack_end(GTK_BOX(hbox),button,FALSE,TRUE,0); if (element->def) { gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),TRUE); gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(button)); } } sep = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox),sep,TRUE,TRUE,0); } label = gtk_label_new("System Wide ECU Profiles"); gtk_box_pack_start(GTK_BOX(vbox),label,TRUE,TRUE,0); /* Cycle list for System interogation files */ for (i=0;i<g_list_length(s_list);i++) { element = (PersonaElement *)g_list_nth_data(s_list,i); ebox = gtk_event_box_new(); gtk_box_pack_start(GTK_BOX(vbox),ebox,TRUE,TRUE,0); hbox = gtk_hbox_new(FALSE,10); gtk_container_add(GTK_CONTAINER(ebox),hbox); label = gtk_label_new(element->name); gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,TRUE,0); if (!check_for_files (element->dirname,"prof")) { gtk_widget_set_sensitive(ebox,FALSE); button = gtk_radio_button_new(NULL); } else { button = gtk_radio_button_new(group); group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); } g_signal_connect(button, "toggled", G_CALLBACK(persona_selection), element); gtk_box_pack_end(GTK_BOX(hbox),button,FALSE,TRUE,0); if (element->def) { gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button),TRUE); gtk_toggle_button_toggled(GTK_TOGGLE_BUTTON(button)); } } gtk_widget_show_all(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); g_list_foreach(p_list,free_persona_element,NULL); g_list_foreach(s_list,free_persona_element,NULL); g_list_free(p_list); g_list_free(s_list); switch (result) { case GTK_RESPONSE_CLOSE: leave(NULL,NULL); break; case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: /* Normal mode */ jumpahead: plugins_init(); pathstub = g_build_filename(INTERROGATOR_DATA_DIR,"Profiles",DATA_GET(global_data,"ecu_family"),"comm.xml",NULL); filename = get_file((const gchar *)DATA_GET(global_data,"project_name"),pathstub,NULL); g_free(pathstub); load_comm_xml(filename); g_free(filename); io_cmd("interrogation",NULL); break; default: /* Offline */ jumpahead_offline: plugins_init(); pathstub = g_build_filename(INTERROGATOR_DATA_DIR,"Profiles",DATA_GET(global_data,"ecu_family"),"comm.xml",NULL); filename = get_file((const gchar *)DATA_GET(global_data,"project_name"),pathstub,NULL); g_free(pathstub); load_comm_xml(filename); g_free(filename); g_timeout_add(100,(GSourceFunc)set_offline_mode,NULL); return FALSE; } return FALSE; }
/** * json_reader_read_element: * @reader: a #JsonReader * @index_: the index of the element * * Advances the cursor of @reader to the element @index_ of the array * or the object at the current position. * * You can use the json_reader_get_value* family of functions to retrieve * the value of the element; for instance: * * |[ * json_reader_read_element (reader, 0); * int_value = json_reader_get_int_value (reader); * ]| * * After reading the value, json_reader_end_element() should be called to * reposition the cursor inside the #JsonReader, e.g.: * * |[ * json_reader_read_element (reader, 1); * str_value = json_reader_get_string_value (reader); * json_reader_end_element (reader); * * json_reader_read_element (reader, 2); * str_value = json_reader_get_string_value (reader); * json_reader_end_element (reader); * ]| * * If @reader is not currently on an array or an object, or if the @index_ is * bigger than the size of the array or the object, the #JsonReader will be * put in an error state until json_reader_end_element() is called. * * Return value: %TRUE on success, and %FALSE otherwise * * Since: 0.12 */ gboolean json_reader_read_element (JsonReader *reader, guint index_) { JsonReaderPrivate *priv; g_return_val_if_fail (JSON_READER (reader), FALSE); json_reader_return_val_if_error_set (reader, FALSE); priv = reader->priv; if (priv->current_node == NULL) priv->current_node = priv->root; if (!(JSON_NODE_HOLDS_ARRAY (priv->current_node) || JSON_NODE_HOLDS_OBJECT (priv->current_node))) return json_reader_set_error (reader, JSON_READER_ERROR_NO_ARRAY, "The current node is of type '%s', but " "an array or an object was expected.", json_node_type_name (priv->current_node)); switch (json_node_get_node_type (priv->current_node)) { case JSON_NODE_ARRAY: { JsonArray *array = json_node_get_array (priv->current_node); if (index_ >= json_array_get_length (array)) return json_reader_set_error (reader, JSON_READER_ERROR_INVALID_INDEX, "The index '%d' is greater than the size " "of the array at the current position.", index_); priv->previous_node = priv->current_node; priv->current_node = json_array_get_element (array, index_); } break; case JSON_NODE_OBJECT: { JsonObject *object = json_node_get_object (priv->current_node); GList *members; const gchar *name; if (index_ >= json_object_get_size (object)) return json_reader_set_error (reader, JSON_READER_ERROR_INVALID_INDEX, "The index '%d' is greater than the size " "of the object at the current position.", index_); priv->previous_node = priv->current_node; g_free (priv->current_member); members = json_object_get_members (object); name = g_list_nth_data (members, index_); priv->current_node = json_object_get_member (object, name); priv->current_member = g_strdup (name); g_list_free (members); } break; default: g_assert_not_reached (); return FALSE; } return TRUE; }
static gboolean client_popup_menu(GtkWidget *tree_view, GdkEventButton *event) { /* This will show up a pop up menu with Ignore settings (and maybe something else ;)) */ /* Make sure that a row is selected */ GtkTreeSelection *client_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); if(gtk_tree_selection_count_selected_rows(client_selection)==0) return FALSE; /* Get the row that is currently selected */ GList *row = gtk_tree_selection_get_selected_rows(client_selection, (GtkTreeModel**)(&client_list)); GtkTreePath *client_tree_path = g_list_nth_data(row,0); if(!client_tree_path) return FALSE; /* Get an iterator reference to the row */ GtkTreeIter client_row_pos; gtk_tree_model_get_iter(GTK_TREE_MODEL(client_list), &client_row_pos, client_tree_path); /* Finally, extract some information from it */ char *nick; int id = 0; int stats = 0; gtk_tree_model_get(GTK_TREE_MODEL(client_list),&client_row_pos,0,&nick,1,&id,2, &stats,-1); GtkWidget *context_menu, *ignore_menu, *actions_menu; GtkWidget *menu_item; int button, event_time; ignore_menu = gtk_menu_new(); menu_item = gtk_menu_item_new_with_label("Ignore Voice"); gtk_menu_append(GTK_MENU(ignore_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Ignore Ink"); gtk_menu_append(GTK_MENU(ignore_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Ignore All"); gtk_menu_append(GTK_MENU(ignore_menu),menu_item); actions_menu = gtk_menu_new(); menu_item = gtk_menu_item_new_with_label("Kick to #limbo"); gtk_menu_append(GTK_MENU(actions_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Ban off of the network"); gtk_menu_append(GTK_MENU(actions_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Take Voice"); g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(client_take_voice),(gpointer)id); gtk_menu_append(GTK_MENU(actions_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Take Ink"); g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(client_take_ink),(gpointer)id); gtk_menu_append(GTK_MENU(actions_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Give Voice"); g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(client_give_voice),(gpointer)id); gtk_menu_append(GTK_MENU(actions_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Give Ink"); g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(client_give_ink),(gpointer)id); gtk_menu_append(GTK_MENU(actions_menu),menu_item); context_menu = gtk_menu_new(); menu_item = gtk_menu_item_new_with_label(nick); gtk_widget_set_sensitive(menu_item,FALSE); gtk_menu_append(GTK_MENU(context_menu),menu_item); menu_item = gtk_separator_menu_item_new(); gtk_menu_append(GTK_MENU(context_menu),menu_item); menu_item = gtk_menu_item_new_with_label("Ignore"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), ignore_menu); gtk_menu_append(GTK_MENU(context_menu),menu_item); if(globals_has_ops && id !=-1) { menu_item = gtk_menu_item_new_with_label("Actions"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), actions_menu); gtk_menu_append(GTK_MENU(context_menu),menu_item); } #ifdef LOG if(id>0) { if(client_get_logged(id)) { menu_item = gtk_menu_item_new_with_label("Stop Log"); } else { menu_item = gtk_menu_item_new_with_label("Log"); } g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(client_toggle_log),(void*)id); gtk_menu_append(GTK_MENU(context_menu),menu_item); } #endif //g_signal_connect(G_OBJECT(menuItem),"activate",G_CALLBACK(onMenuSave),NULL); gtk_widget_show_all(context_menu); if(event) { button = event->button; event_time = event->time; } else { button = 3; event_time = gtk_get_current_event_time (); } if(button == 3) { gtk_menu_attach_to_widget(GTK_MENU(context_menu), tree_view, NULL); gtk_menu_popup(GTK_MENU(context_menu), NULL, NULL, NULL, NULL, button, event_time); } return FALSE; }
void DataStorage::update_networks(GList *a_list_networks_update, GList *a_list_object_paths_invalid) { guint length = 0, i; GList *item = NULL; INetwork *network = NULL; gchar *help; DBG3(); g_static_rw_lock_writer_lock(&networks_lock); /* delete all invalid networks from the list */ if(a_list_object_paths_invalid != NULL) { length = g_list_length(a_list_object_paths_invalid); DBG("INVALID NETWORKS '%u'", length); for(i = 0; i < length; i++) { help = (gchar *)g_list_nth_data(a_list_object_paths_invalid, i); DBG2("delete invalid network '%s'.", help); delete_network(help); g_free(help); } m_list_networks = g_list_sort(m_list_networks, sort_networks); } /* update networks and sort them */ if(a_list_networks_update != NULL) { length = g_list_length(a_list_networks_update); DBG("UPDATE NETWORKS '%u'", length); for(i = 0; i < length; i++) { network = (INetwork *)g_list_nth_data(a_list_networks_update, i); DBG2("rat '%s', strength '%u', average '%u', name'%s'.", rat2String(network->get_rat()), network->get_strength(), network->get_strength_average(), network->get_name()); item = lookup_network(network->get_object_path()); if(item != NULL) { /* network already available, just update the old one and delete the new */ INetwork *old = (INetwork *)item->data; old->update(network); delete network; } else { /* network not yet available, add new one */ m_list_networks = g_list_insert_sorted(m_list_networks, network, sort_networks); } } m_list_networks = g_list_sort(m_list_networks, sort_networks); } g_static_rw_lock_writer_unlock(&networks_lock); g_list_foreach(m_list_networks, (GFunc)print_networks, NULL); }
void nav_tree_refresh_synonyms (GSQLNavigation *navigation, GtkTreeView *tv, GtkTreeIter *iter) { GSQL_TRACE_FUNC; GtkTreeModel *model; GtkListStore *detail; GSQLNavigation *nav = NULL; gchar *sql = NULL; gchar *realname = NULL; gchar *owner = NULL; gint id; gint i,n; GtkTreeIter child; GtkTreeIter child_fake; GtkTreeIter child_last; GSQLCursor *cursor; GSQLCursorState state; GSQLVariable *var; GSQLSession *session; GtkListStore *details; gchar *name; gchar key[256]; model = gtk_tree_view_get_model(tv); n = gtk_tree_model_iter_n_children(model, iter); for (; n>1; n--) { gtk_tree_model_iter_children(model, &child, iter); gtk_tree_store_remove(GTK_TREE_STORE(model), &child); } gtk_tree_model_iter_children(model, &child_last, iter); gtk_tree_model_get (model, iter, GSQL_NAV_TREE_REALNAME, &realname, -1); gtk_tree_model_get (model, iter, GSQL_NAV_TREE_SQL, &sql, -1); g_return_if_fail (sql != NULL); gtk_tree_model_get (model, iter, GSQL_NAV_TREE_OWNER, &owner, -1); session = gsql_session_get_active (); if (strncmp (owner, gsql_session_get_username (session), 64)) sql = (gchar *) sql_oracle_synonyms; cursor = gsql_cursor_new (session, sql); state = gsql_cursor_open_with_bind (cursor, FALSE, GSQL_CURSOR_BIND_BY_NAME, G_TYPE_STRING, ":owner", G_TYPE_STRING, owner, G_TYPE_STRING, ":name", G_TYPE_STRING, "%", -1); var = g_list_nth_data(cursor->var_list,0); if (state != GSQL_CURSOR_STATE_OPEN) { gsql_cursor_close (cursor); return; } i = 0; while (gsql_cursor_fetch (cursor, 1) > 0) { i++; if (var->value_type != G_TYPE_STRING) { GSQL_DEBUG ("The name of object should be a string (char *). Is the bug"); name = N_("Incorrect data"); } else { name = (gchar *) var->value; // make a key for a hash of details memset (key, 0, 256); g_snprintf (key, 255, "%x%s%d%s", session, owner, SYNONYM_ID, name); details = gsql_navigation_get_details (navigation, key); oracle_navigation_fill_details (cursor, details); } gtk_tree_store_append (GTK_TREE_STORE(model), &child, iter); gtk_tree_store_set (GTK_TREE_STORE(model), &child, GSQL_NAV_TREE_ID, SYNONYM_ID, GSQL_NAV_TREE_OWNER, owner, GSQL_NAV_TREE_IMAGE, GSQLE_ORACLE_STOCK_SYNONYMS, GSQL_NAV_TREE_NAME, name, GSQL_NAV_TREE_REALNAME, name, GSQL_NAV_TREE_ITEM_INFO, NULL, GSQL_NAV_TREE_SQL, NULL, GSQL_NAV_TREE_OBJECT_POPUP, NULL, GSQL_NAV_TREE_OBJECT_HANDLER, NULL, GSQL_NAV_TREE_EXPAND_HANDLER, NULL, GSQL_NAV_TREE_EVENT_HANDLER, NULL, GSQL_NAV_TREE_STRUCT, synonyms, GSQL_NAV_TREE_DETAILS, details, GSQL_NAV_TREE_NUM_ITEMS, G_N_ELEMENTS(synonyms), -1); gtk_tree_store_append (GTK_TREE_STORE (model), &child_fake, &child); gtk_tree_store_set (GTK_TREE_STORE (model), &child_fake, GSQL_NAV_TREE_ID, -1, GSQL_NAV_TREE_IMAGE, NULL, GSQL_NAV_TREE_NAME, N_("Processing..."), GSQL_NAV_TREE_REALNAME, NULL, GSQL_NAV_TREE_ITEM_INFO, NULL, GSQL_NAV_TREE_SQL, NULL, GSQL_NAV_TREE_OBJECT_POPUP, NULL, GSQL_NAV_TREE_OBJECT_HANDLER, NULL, GSQL_NAV_TREE_EXPAND_HANDLER, NULL, GSQL_NAV_TREE_EVENT_HANDLER, NULL, GSQL_NAV_TREE_STRUCT, NULL, GSQL_NAV_TREE_NUM_ITEMS, NULL, -1); } GSQL_DEBUG ("Items fetched: [%d]", i); if (i > 0) { name = g_strdup_printf("%s<span weight='bold'> [%d]</span>", realname, i); gtk_tree_store_set (GTK_TREE_STORE(model), iter, GSQL_NAV_TREE_NAME, name, -1); g_free (name); } gtk_tree_store_remove(GTK_TREE_STORE(model), &child_last); gsql_cursor_close (cursor); }
/* * The almighty html parser method */ void parse_html(GtkTextView *text_view, GtkTextMark html_start, int ignore) { GtkTextBuffer *html_buffer = gtk_text_view_get_buffer(text_view); tag *last_tag; GList *tag_list = NULL; int tagid = 0; GtkTextIter start_iter, end_iter; GtkTextMark *end_mark; GtkTextIter tag_start_iter, tag_end_iter; gtk_text_buffer_get_iter_at_mark(html_buffer, &start_iter, &html_start); gtk_text_buffer_get_end_iter(html_buffer, &end_iter); end_mark = gtk_text_buffer_create_mark(html_buffer, NULL, &end_iter, TRUE); gtk_text_buffer_get_iter_at_mark(html_buffer, &tag_start_iter, &html_start); gtk_text_buffer_get_iter_at_mark(html_buffer, &tag_end_iter, &html_start); /* Check if < and > exist in that order */ while (search_char(&tag_start_iter, '<') && search_char(&tag_end_iter, '>')) { gchar *tag_string; GtkTextMark *tag_start_mark = NULL, *next_start_mark = NULL; if (gtk_text_iter_compare(&tag_start_iter, &tag_end_iter) > 0) { gtk_text_iter_forward_char(&tag_end_iter); tag_start_iter = tag_end_iter; continue; } gtk_text_iter_forward_char(&tag_end_iter); tag_start_mark = gtk_text_buffer_create_mark(html_buffer, NULL, &tag_start_iter, TRUE); next_start_mark = gtk_text_buffer_create_mark(html_buffer, NULL, &tag_end_iter, TRUE); tag_string = gtk_text_buffer_get_slice(html_buffer, &tag_start_iter, &tag_end_iter, TRUE); /* Get rid of the < and > and clean up the tag string */ tag_string = strstr(tag_string, "<") + 1; if (tag_string && strstr(tag_string, ">")) *(strstr(tag_string, ">")) = '\0'; g_strstrip(tag_string); if (*tag_string == '/' && tag_is_valid(++tag_string)) { int found_match = 0; last_tag = NULL; /* Now get rid of the tag from the text */ gtk_text_buffer_delete(html_buffer, &tag_start_iter, &tag_end_iter); /* * This is an end tag. So now we must apply the tag to * the enclosed text */ do { last_tag = g_list_nth_data(g_list_last(tag_list), 0); if (last_tag == NULL) break; if (!g_ascii_strncasecmp(tag_string, last_tag->name, strlen(tag_string))) { last_tag->end = *tag_start_mark; found_match = 1; } else { last_tag->end = *end_mark; } apply_tag(text_view, *last_tag, ignore); tag_list = g_list_remove(tag_list, last_tag); } while (!found_match); } else if (tag_is_valid(tag_string)) { tag *cur; /* Now get rid of the tag from the text */ gtk_text_buffer_delete(html_buffer, &tag_start_iter, &tag_end_iter); /* This is a start tag. So put this into the list */ cur = (tag *)malloc(sizeof(tag)); bzero(cur->id, 8); sprintf(cur->id, "%d%d", messageid, tagid++); cur->name = strdup(tag_string); cur->start = *tag_start_mark; /* * Insert into the tag list only if it's a * closing type tag */ if (!(ay_strcasestr(tag_string, "smiley") == tag_string || ay_strcasestr(tag_string, "br") == tag_string || ay_strcasestr(tag_string, "img") == tag_string || ay_strcasestr(tag_string, "hr") == tag_string)) { tag_list = g_list_append(tag_list, cur); } else { apply_tag(text_view, *cur, ignore); free(cur); } } /* Re-initialize the string to get new positions */ gtk_text_buffer_get_end_iter(html_buffer, &end_iter); end_mark = gtk_text_buffer_create_mark(html_buffer, NULL, &end_iter, TRUE); gtk_text_buffer_get_iter_at_mark(html_buffer, &tag_start_iter, next_start_mark); gtk_text_buffer_get_iter_at_mark(html_buffer, &tag_end_iter, next_start_mark); } while ((last_tag = g_list_nth_data(g_list_last(tag_list), 0))) { last_tag->end = *end_mark; apply_tag(text_view, *last_tag, ignore); tag_list = g_list_remove(tag_list, last_tag); } g_list_free(tag_list); unescape_html(html_buffer, html_start); messageid++; }
G_MODULE_EXPORT gboolean load_firmware_details(Firmware_Details *firmware, gchar * filename) { ConfigFile *cfgfile; Location_Details *details = NULL; GList *locations = NULL; gchar *tmpbuf = NULL; gchar *section = NULL; gchar ** list = NULL; gint i = 0; gint major = 0; gint minor = 0; cfgfile = cfg_open_file((gchar *)filename); if (!cfgfile) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup_printf(__FILE__": load_firmware_details()\n\tFile \"%s\" NOT OPENED successfully\n",filename)); get_file_api_f(cfgfile,&major,&minor); if ((major != INTERROGATE_MAJOR_API) || (minor != INTERROGATE_MINOR_API)) { thread_update_logbar_f("interr_view","warning",g_strdup_printf(_("Interrogation profile API mismatch (%i.%i != %i.%i):\n\tFile %s will be skipped\n"),major,minor,INTERROGATE_MAJOR_API,INTERROGATE_MINOR_API,filename),FALSE,FALSE); cfg_free(cfgfile); return FALSE; } dbg_func_f(INTERROGATOR,g_strdup_printf(__FILE__": load_firmware_details()\n\tfile:%s opened successfully\n",filename)); firmware->profile_filename = g_strdup(filename); cfg_read_string(cfgfile,"interrogation_profile","name",&firmware->name); if(cfg_read_string(cfgfile,"parameters","EcuTempUnits",&tmpbuf)) { firmware->ecu_temp_units = translate_string_f(tmpbuf); g_free(tmpbuf); } else dbg_func_f(INTERROGATOR,g_strdup_printf(__FILE__": load_firmware_details()\n\tFailed to find EcuTempUnits key in interrogation profile\n")); if(!cfg_read_boolean(cfgfile,"parameters","BigEndian",&firmware->bigendian)) { dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"BigEndian\" key not found in interrogation profile, assuming ECU firmware byte order is big endian, ERROR in interrogation profile\n")); firmware->bigendian = TRUE; } if(!cfg_read_string(cfgfile,"parameters","Capabilities", &tmpbuf)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Capabilities\" enumeration list not found in interrogation profile, ERROR\n")); else { firmware->capabilities = translate_capabilities(tmpbuf); g_free(tmpbuf); } /* Commands to map against the comm.xml */ if(!cfg_read_string(cfgfile,"parameters","RT_Command",&firmware->rt_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"RT_Command\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_int(cfgfile,"parameters","RT_total_bytes", &firmware->rtvars_size)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"RT_total_bytes\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"parameters","Get_All_Command", &firmware->get_all_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Get_All_Command\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"parameters","Read_Command", &firmware->read_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Read_Command\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"parameters","Write_Command", &firmware->write_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Write_Command\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"parameters","Burn_Command", &firmware->burn_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Burn_Command\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"parameters","Burn_All_Command", &firmware->burn_all_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Burn_All_Command\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_boolean(cfgfile,"parameters","ChunkWriteSupport", &firmware->chunk_support)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"ChunkWriteSupport\" flag not found in parameters section in interrogation profile, ERROR\n")); if (firmware->chunk_support) { if(!cfg_read_string(cfgfile,"parameters","Chunk_Write_Command", &firmware->chunk_write_command)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"Chunk_Write_Command\" flag not found in parameters section in interrogation profile, ERROR\n")); } /* Gui Section */ if(!cfg_read_string(cfgfile,"gui","LoadTabs",&tmpbuf)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"LoadTabs\" list not found in interrogation profile, ERROR\n")); else { firmware->tab_list = g_strsplit(tmpbuf,",",0); g_free(tmpbuf); } if(!cfg_read_string(cfgfile,"gui","TabConfs", &tmpbuf)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"TabConfs\" list not found in interrogation profile, ERROR\n")); else { firmware->tab_confs = g_strsplit(tmpbuf,",",0); g_free(tmpbuf); } if(!cfg_read_string(cfgfile,"gui","RealtimeMapFile", &firmware->rtv_map_file)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"RealtimeMapFile\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"gui","SliderMapFile", &firmware->sliders_map_file)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"SliderMapFile\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"gui","RuntimeTextMapFile", &firmware->rtt_map_file)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"RuntimeTextMapFile\" variable not found in interrogation profile, ERROR\n")); if(!cfg_read_string(cfgfile,"gui","StatusMapFile", &firmware->status_map_file)) dbg_func_f(INTERROGATOR|CRITICAL,g_strdup(__FILE__": load_firmware_details()\n\t\"StatusMapFile\" variable not found in interrogation profile, ERROR\n")); /* Megatunix Doesn't yet know how to deal with FreeEMS's locationID's which are semi-analagous to Pages in MS-land */ locations = request_location_ids(NULL); if (locations) { firmware->total_pages = g_list_length(locations); firmware->page_params = g_new0(Page_Params *, firmware->total_pages); for (i=0;i<firmware->total_pages;i++) { firmware->page_params[i] = initialize_page_params(); firmware->page_params[i]->phys_ecu_page = (GINT)g_list_nth_data(locations,i); details = request_location_id_details((GINT)g_list_nth_data(locations,i)); if (details) { firmware->page_params[i]->length = details->length; firmware->page_params[i]->dl_by_default = (details->flags & BLOCK_IS_INDEXABLE); } g_free(details); } g_list_free(locations); } /* MAJOR HACK ALERT, hardcoded for fred! */ firmware->total_tables = 3; firmware->table_params = g_new0(Table_Params *,firmware->total_tables); /* Fuel Table */ firmware->table_params[0] = initialize_table_params(); firmware->table_params[0]->x_page = 0; firmware->table_params[0]->y_page = 0; firmware->table_params[0]->z_page = 0; firmware->table_params[0]->x_bincount = 16; firmware->table_params[0]->y_bincount = 16; firmware->table_params[0]->x_base = 4; firmware->table_params[0]->y_base = 58; firmware->table_params[0]->z_base = 100; firmware->table_params[0]->x_size = MTX_U16; firmware->table_params[0]->y_size = MTX_U16; firmware->table_params[0]->z_size = MTX_U16; firmware->table_params[0]->x_source = g_strdup("RPM"); firmware->table_params[0]->x_fromecu_mult = g_new0(gfloat, 1); firmware->table_params[0]->y_fromecu_mult = g_new0(gfloat, 1); firmware->table_params[0]->z_fromecu_mult = g_new0(gfloat, 1); *(firmware->table_params[0]->x_fromecu_mult) = 0.5; *(firmware->table_params[0]->y_fromecu_mult) = 0.01; *(firmware->table_params[0]->z_fromecu_mult) = 0.001953125; firmware->table_params[0]->y_source = g_strdup("LoadMain"); firmware->table_params[0]->z_source = g_strdup("VEMain"); firmware->table_params[0]->x_suffix = g_strdup("RPM"); firmware->table_params[0]->y_suffix = g_strdup("kPa"); firmware->table_params[0]->z_suffix = g_strdup("%"); firmware->table_params[0]->x_precision = 0; firmware->table_params[0]->y_precision = 1; firmware->table_params[0]->z_precision = 1; firmware->table_params[0]->table_name = g_strdup("FreeEMS very alpha fuel table");; /* Lambda Table */ firmware->table_params[1] = initialize_table_params(); firmware->table_params[1]->x_page = 6; firmware->table_params[1]->y_page = 6; /* Assumes location ID's from 0-6 are contiguous */ firmware->table_params[1]->z_page = 6; firmware->table_params[1]->x_bincount = 16; firmware->table_params[1]->y_bincount = 16; firmware->table_params[1]->x_base = 4; firmware->table_params[1]->y_base = 58; firmware->table_params[1]->z_base = 100; firmware->table_params[1]->x_size = MTX_U16; firmware->table_params[1]->y_size = MTX_U16; firmware->table_params[1]->z_size = MTX_U16; firmware->table_params[1]->x_fromecu_mult = g_new0(gfloat, 1); firmware->table_params[1]->y_fromecu_mult = g_new0(gfloat, 1); firmware->table_params[1]->z_fromecu_mult = g_new0(gfloat, 1); *(firmware->table_params[1]->x_fromecu_mult) = 0.5; *(firmware->table_params[1]->y_fromecu_mult) = 0.01; *(firmware->table_params[1]->z_fromecu_mult) = 0.000030518; firmware->table_params[1]->x_source = g_strdup("RPM"); firmware->table_params[1]->y_source = g_strdup("LoadMain"); firmware->table_params[1]->z_source = g_strdup("Lambda"); firmware->table_params[1]->x_suffix = g_strdup("RPM"); firmware->table_params[1]->y_suffix = g_strdup("kPa"); firmware->table_params[1]->z_suffix = g_strdup("Lambda"); firmware->table_params[1]->x_precision = 0; firmware->table_params[1]->y_precision = 1; firmware->table_params[1]->z_precision = 2; firmware->table_params[1]->table_name = g_strdup("FreeEMS very alpha lambda table");; firmware->table_params[2] = initialize_table_params(); firmware->table_params[2]->x_page = 8; firmware->table_params[2]->y_page = 8; /* Assumes location ID's from 0-8 are contiguous */ firmware->table_params[2]->z_page = 8; firmware->table_params[2]->x_bincount = 16; firmware->table_params[2]->y_bincount = 16; firmware->table_params[2]->x_base = 4; firmware->table_params[2]->y_base = 58; firmware->table_params[2]->z_base = 100; firmware->table_params[2]->x_size = MTX_U16; firmware->table_params[2]->y_size = MTX_U16; firmware->table_params[2]->z_size = MTX_U16; firmware->table_params[2]->x_fromecu_mult = g_new0(gfloat, 1); firmware->table_params[2]->y_fromecu_mult = g_new0(gfloat, 1); firmware->table_params[2]->z_fromecu_mult = g_new0(gfloat, 1); *(firmware->table_params[2]->x_fromecu_mult) = 0.5; *(firmware->table_params[2]->y_fromecu_mult) = 0.01; *(firmware->table_params[2]->z_fromecu_mult) = 0.000976563; firmware->table_params[2]->x_source = g_strdup("RPM"); firmware->table_params[2]->y_source = g_strdup("LoadMain"); firmware->table_params[2]->z_source = g_strdup("Degrees"); firmware->table_params[2]->x_suffix = g_strdup("RPM"); firmware->table_params[2]->y_suffix = g_strdup("kPa"); firmware->table_params[2]->z_suffix = g_strdup("\302\260BTDC"); firmware->table_params[2]->x_precision = 0; firmware->table_params[2]->y_precision = 1; firmware->table_params[2]->z_precision = 3; firmware->table_params[2]->table_name = g_strdup("FreeEMS very alpha spark table");; if (mem_alloc_f) mem_alloc_f(); else dbg_func_f(INTERROGATOR|CRITICAL,g_strdup_printf(__FILE__": load_firmware_details()\n\tFAILED TO LOCATE \"mem_alloc\" function within core/plugins\n")); /* Display firmware version in the window... */ dbg_func_f(INTERROGATOR|CRITICAL,g_strdup_printf(__FILE__": load_firmware_details()\n\tDetected Firmware: %s\n",firmware->name)); thread_update_logbar_f("interr_view","warning",g_strdup_printf(_("Detected Firmware: %s\n"),firmware->name),FALSE,FALSE); thread_update_logbar_f("interr_view","info",g_strdup_printf(_("Loading Settings from: \"%s\"\n"),firmware->profile_filename),FALSE,FALSE); cfg_free(cfgfile); return TRUE; }
static void ggp_pubdir_search_results_add(PurpleConnection *gc, GList *row, gpointer _form) { purple_blist_request_add_buddy(purple_connection_get_account(gc), g_list_nth_data(row, 0), NULL, g_list_nth_data(row, 1)); }
static void ggp_pubdir_search_results_im(PurpleConnection *gc, GList *row, gpointer _form) { purple_conversation_present(PURPLE_CONVERSATION(purple_im_conversation_new( purple_connection_get_account(gc), g_list_nth_data(row, 0)))); }
void TPCATableProps_save_config (TPCATableProps * pDlg) { int i; pDlg->ptest->is_dirty = TRUE; pDlg->ptest->tpc.a.fCreateBranch = GTK_TOGGLE_BUTTON (pDlg->create_branch)->active; pDlg->ptest->tpc.a.fCreateTeller = GTK_TOGGLE_BUTTON (pDlg->create_teller)->active; pDlg->ptest->tpc.a.fCreateAccount = GTK_TOGGLE_BUTTON (pDlg->create_account)->active; pDlg->ptest->tpc.a.fCreateHistory = GTK_TOGGLE_BUTTON (pDlg->create_history)->active; pDlg->ptest->tpc.a.fLoadBranch = GTK_TOGGLE_BUTTON (pDlg->load_branch)->active; pDlg->ptest->tpc.a.fLoadTeller = GTK_TOGGLE_BUTTON (pDlg->load_teller)->active; pDlg->ptest->tpc.a.fLoadAccount = GTK_TOGGLE_BUTTON (pDlg->load_account)->active; pDlg->ptest->tpc.a.fCreateIndex = GTK_TOGGLE_BUTTON (pDlg->create_indexes)->active; pDlg->ptest->tpc.a.fCreateProcedure = GTK_TOGGLE_BUTTON (pDlg->create_procedures)->active; pDlg->ptest->tpc.a.udwMaxBranch = atoi (gtk_entry_get_text (GTK_ENTRY (pDlg->num_branches))); pDlg->ptest->tpc.a.udwMaxTeller = atoi (gtk_entry_get_text (GTK_ENTRY (pDlg->num_tellers))); pDlg->ptest->tpc.a.udwMaxAccount = atoi (gtk_entry_get_text (GTK_ENTRY (pDlg->num_accounts))); strcpy (pDlg->ptest->szTemp, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (pDlg->dbmstype)->entry))); pDlg->ptest->tpc.a.uwDrvIdx = getDriverMapSize() - 1; for (i = 0; i < getDriverMapSize (); i++) if (!strcmp (pDlg->ptest->szTemp, getDriverDBMSName (i))) { pDlg->ptest->tpc.a.uwDrvIdx = i; break; } pDlg->ptest->tpc.a.szBranchDSN[0] = pDlg->ptest->tpc.a.szBranchDBMS[0] = pDlg->ptest->tpc.a.szAccountDSN[0] = pDlg->ptest->tpc.a.szAccountDBMS[0] = pDlg->ptest->tpc.a.szTellerDSN[0] = pDlg->ptest->tpc.a.szTellerDBMS[0] = pDlg->ptest->tpc.a.szHistoryDSN[0] = pDlg->ptest->tpc.a.szHistoryDBMS[0] = 0; if (pDlg->pDSN->dsn_info.dsns) { GList *found; strcpy (pDlg->ptest->tpc.a.szBranchDSN, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (pDlg-> branch_dsn)->entry))); if (!strcmp (pDlg->ptest->tpc.a.szBranchDSN, "<local>")) pDlg->ptest->tpc.a.szBranchDSN[0] = 0; else if (NULL != (found = g_list_find_custom (pDlg->pDSN->dsn_info.dsns, pDlg->ptest->tpc.a.szBranchDSN, (GCompareFunc) strcmp))) strncpy (pDlg->ptest->tpc.a.szBranchDBMS, (char *) g_list_nth_data (pDlg->pDSN->dsn_info.names, g_list_position (pDlg->pDSN->dsn_info.dsns, found)), 50); strcpy (pDlg->ptest->tpc.a.szTellerDSN, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (pDlg-> teller_dsn)->entry))); if (!strcmp (pDlg->ptest->tpc.a.szTellerDSN, "<local>")) pDlg->ptest->tpc.a.szTellerDSN[0] = 0; else if (NULL != (found = g_list_find_custom (pDlg->pDSN->dsn_info.dsns, pDlg->ptest->tpc.a.szTellerDSN, (GCompareFunc) strcmp))) strncpy (pDlg->ptest->tpc.a.szTellerDBMS, (char *) g_list_nth_data (pDlg->pDSN->dsn_info.names, g_list_position (pDlg->pDSN->dsn_info.dsns, found)), 50); strcpy (pDlg->ptest->tpc.a.szAccountDSN, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (pDlg-> account_dsn)->entry))); if (!strcmp (pDlg->ptest->tpc.a.szAccountDSN, "<local>")) pDlg->ptest->tpc.a.szAccountDSN[0] = 0; else if (NULL != (found = g_list_find_custom (pDlg->pDSN->dsn_info.dsns, pDlg->ptest->tpc.a.szAccountDSN, (GCompareFunc) strcmp))) strncpy (pDlg->ptest->tpc.a.szAccountDBMS, (char *) g_list_nth_data (pDlg->pDSN->dsn_info.names, g_list_position (pDlg->pDSN->dsn_info.dsns, found)), 50); strcpy (pDlg->ptest->tpc.a.szHistoryDSN, gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (pDlg-> history_dsn)->entry))); if (!strcmp (pDlg->ptest->tpc.a.szHistoryDSN, "<local>")) pDlg->ptest->tpc.a.szHistoryDSN[0] = 0; else if (NULL != (found = g_list_find_custom (pDlg->pDSN->dsn_info.dsns, pDlg->ptest->tpc.a.szHistoryDSN, (GCompareFunc) strcmp))) strncpy (pDlg->ptest->tpc.a.szHistoryDBMS, (char *) g_list_nth_data (pDlg->pDSN->dsn_info.names, g_list_position (pDlg->pDSN->dsn_info.dsns, found)), 50); } }
static gpointer extract_thread (gpointer user_data) { GList *args = (GList *) user_data; const char *savedir = (const char *) g_list_nth_data (args, 0); GList *files = (GList *) g_list_nth_data (args, 1); GList *indices = (GList *) g_list_nth_data (args, 2); GList *l, *f, *dirs = NULL; char *dir; unsigned long failed = 0, max = 0; gboolean stop = FALSE; GTimer *timer = NULL; g_list_free (args); /* Generate a list of unique subdirectories */ for (l = files; l; l = l->next) { char *p; /* Convert paths to Unix paths */ for (p = (char *) l->data; *p; p++) if (*p == '\\') *p = G_DIR_SEPARATOR; dir = g_path_get_dirname ((gchar *) l->data); if (!g_list_find_custom (dirs, dir, (GCompareFunc) g_ascii_strcasecmp)) { dirs = g_list_prepend (dirs, dir); max++; } else g_free (dir); } g_static_mutex_lock (&extractProgressM); extractProgress.max = max; extractProgress.status = STATUS_MKDIR; g_static_mutex_unlock (&extractProgressM); /* Create the subdirectories */ dirs = g_list_sort (dirs, (GCompareFunc) g_ascii_strcasecmp); dirs = g_list_reverse (dirs); for (l = dirs; l; l = l->next) { dir = g_build_filename (G_DIR_SEPARATOR_S, savedir, (char *) l->data, NULL); mkdirs (dir); g_free (dir); g_static_mutex_lock (&extractProgressM); extractProgress.current++; stop = extractProgress.stop; g_static_mutex_unlock (&extractProgressM); } g_list_foreach (dirs, (GFunc) g_free, NULL); g_list_free (dirs); if (stop) goto end; g_static_mutex_lock (&extractProgressM); extractProgress.current = 0; extractProgress.max = g_list_length (files); extractProgress.status = STATUS_EXTRACT; stop = extractProgress.stop; g_static_mutex_unlock (&extractProgressM); if (stop) goto end; timer = g_timer_new (); g_timer_start (timer); /* Start the actual extraction */ for (l = indices, f = files; l; l = l->next, f = f->next) { unsigned long i; char *fname; i = GPOINTER_TO_INT (l->data); fname = g_build_filename (savedir, (char *) f->data, NULL); if (!grf_index_extract (document.grf, i, fname, NULL)) failed++; g_free (fname); g_static_mutex_lock (&extractProgressM); extractProgress.current++; strncpy (extractProgress.file, document.grf->files[i].name, PATH_MAX - 1); stop = extractProgress.stop; g_static_mutex_unlock (&extractProgressM); if (stop) goto end; } end: if (timer) g_timer_destroy (timer); g_list_free (files); g_list_free (indices); g_static_mutex_lock (&extractProgressM); extractProgress.failed = failed; extractProgress.status = STATUS_DONE; g_static_mutex_unlock (&extractProgressM); return NULL; }
// XXX step 2, basically the main function static int emit_package (lcmgen_t *lcm, _package_contents_t *pc) { // create the package directory, if necessary char **dirs = g_strsplit (pc->name, ".", 0); char *pdname = build_filenamev (dirs); char package_dir[PATH_MAX]; char package_dir_prefix[PATH_MAX]; int have_package = dirs[0] != NULL; sprintf (package_dir_prefix, "%s%s", getopt_get_string(lcm->gopt, "lpath"), strlen(getopt_get_string(lcm->gopt, "lpath")) > 0 ? G_DIR_SEPARATOR_S : ""); sprintf(package_dir, "%s%s%s", package_dir_prefix, pdname, have_package ? G_DIR_SEPARATOR_S : ""); free (pdname); if (strlen (package_dir)) { if (! g_file_test (package_dir, G_FILE_TEST_EXISTS)) { // g_mkdir_with_parents (package_dir, 0755); mkdir_with_parents (package_dir, 0755); } if (!g_file_test (package_dir, G_FILE_TEST_IS_DIR)) { err ("Could not create directory %s\n", package_dir); return -1; } } // write the package init.lua files, if necessary FILE *init_lua_fp = NULL; GHashTable * initlua_requires = NULL; GHashTable * initlua_requires_subpack = NULL; if (have_package) { int ndirs = 0; for (ndirs=0; dirs[ndirs]; ndirs++); for (int i=0 ; i<ndirs; i++) { // make filename char *initlua_fname; { char *initlua_fname_parts[1024]; assert(ndirs + 4 < 1024); initlua_fname_parts[0] = package_dir_prefix; for (int j=0; j<=i; j++) { initlua_fname_parts[j+1] = dirs[j]; } initlua_fname_parts[i+2] = "init.lua"; initlua_fname_parts[i+3] = NULL; initlua_fname = build_filenamev (initlua_fname_parts); } // make current package name char * package_name; { char * name_parts[1024]; assert(i < 1024); for (int j = 0; j <= i; j++) { name_parts[j] = dirs[j]; } name_parts[i + 1] = NULL; package_name = g_strjoinv(".", name_parts); } if (initlua_requires) { g_hash_table_destroy(initlua_requires); initlua_requires = NULL; } if (initlua_requires_subpack) { g_hash_table_destroy(initlua_requires_subpack); initlua_requires_subpack = NULL; } initlua_requires = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); initlua_requires_subpack = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); // if the file already exists, read the contents if (g_file_test (initlua_fname, G_FILE_TEST_EXISTS)) { init_lua_fp = fopen(initlua_fname, "r"); if (!init_lua_fp) { perror ("fopen"); free (initlua_fname); g_free(package_name); return -1; } while(!feof(init_lua_fp)) { char buf[4096]; memset(buf, 0, sizeof(buf)); char *result = fgets(buf, sizeof(buf)-1, init_lua_fp); if(!result) break; // XXX get all of the previous types and packages // this regex works because the first part is greedy GRegex * regex = g_regex_new("require\\('([\\w+\\.]*\\.)(\\w+)'\\)( -- subpackage)?", (GRegexCompileFlags) 0, (GRegexMatchFlags) 0, NULL); GMatchInfo * matchinfo; if(g_regex_match(regex, buf, (GRegexMatchFlags) 0, &matchinfo)){ if(g_match_info_get_match_count(matchinfo) == 3){ // not a subpackage gchar * classname = g_match_info_fetch(matchinfo, 2); g_hash_table_insert(initlua_requires, g_strdup(classname), g_strdup(classname)); }else if(g_match_info_get_match_count(matchinfo) == 4){ // this is a subpackage // XXX fprintf(stderr, "> buff: %s\n", buf); gchar * superpackage = g_match_info_fetch(matchinfo, 1); gchar * subpackage = g_match_info_fetch(matchinfo, 2); // XXX fprintf(stderr, "> super: %s, sub: %s\n", superpackage, subpackage); gchar * fullsubpackage = g_strjoin("", superpackage, subpackage, NULL); // XXX fprintf(stderr, "> [2] inserting: %s\n", fullsubpackage); g_hash_table_insert(initlua_requires_subpack, g_strdup(fullsubpackage), g_strdup(fullsubpackage)); g_free(fullsubpackage); } } g_match_info_free(matchinfo); g_regex_unref(regex); } fclose(init_lua_fp); init_lua_fp = NULL; } init_lua_fp = fopen(initlua_fname, "w"); // XXX fprintf(stderr, "> opened: %s\n", initlua_fname); if (!init_lua_fp) { perror ("fopen"); free (initlua_fname); g_free(package_name); return -1; } #ifndef WIN32 // lock init.lua for exclusive write access // TODO do the equivalent in windows struct flock lockinfo; lockinfo.l_type = F_WRLCK; lockinfo.l_start = 0; lockinfo.l_whence = SEEK_SET; lockinfo.l_len = 0 ; lockinfo.l_pid = getpid(); if(0 != fcntl(fileno(init_lua_fp), F_SETLKW, &lockinfo)) { perror("locking init.lua"); free(initlua_fname); g_free(package_name); fclose(init_lua_fp); return -1; } #endif fprintf (init_lua_fp, "--[[\n" "LCM package init.lua file\n" "This file automatically generated by lcm-gen.\n" "DO NOT MODIFY BY HAND!!!!\n" "--]]\n" "\n" "local M = {}\n" "\n"); // add in all previous types GList * package_types = g_hash_table_get_values(initlua_requires); for (int j = 0; j < g_list_length(package_types); j++) { char * tn = (char *) g_list_nth_data(package_types, j); char * fn = g_strjoin(".", package_name, tn, NULL); fprintf(init_lua_fp, "M.%s = require('%s')\n", tn, fn); g_free(fn); } g_list_free(package_types); // add in all previous packages GList * subpacks = g_hash_table_get_values(initlua_requires_subpack); for (int j = 0; j < g_list_length(subpacks); j++) { char * spn = (char *) g_list_nth_data(subpacks, j); // get the base of the package name char ** tmpsplit = g_strsplit(spn, ".", -1); char * sn = tmpsplit[g_strv_length(tmpsplit) - 1]; // XXX fprintf(stderr, "[1] sn: %s, spn: %s\n", sn, spn); fprintf(init_lua_fp, "M.%s = require('%s') -- subpackage\n", sn, spn); g_strfreev(tmpsplit); } g_list_free(subpacks); // if the current package has a subpackage (which eventually contains the target package) // add a `require` for that subpackage to the current (if it hasn't already) if (i + 1 < ndirs) { char *subpack_name = g_strjoin(".", package_name, dirs[i + 1], NULL); // check for the subpackage name if (!g_hash_table_lookup(initlua_requires_subpack, subpack_name)) { // add it if it didn't exist g_hash_table_insert(initlua_requires_subpack, g_strdup(subpack_name), g_strdup(subpack_name)); // XXX fprintf(stderr, "[2] sn: %s, spn: %s\n", dirs[i + 1], subpack_name); fprintf(init_lua_fp, "M.%s = require('%s') -- subpackage\n", dirs[i + 1], subpack_name); } g_free(subpack_name); } // not yet the target? if (i + 1 < ndirs) { // close it out fprintf(init_lua_fp, "\nreturn M\n\n"); fclose(init_lua_fp); init_lua_fp = NULL; } free (initlua_fname); g_free(package_name); } } g_strfreev (dirs); //////////////////////////////////////////////////////////// // STRUCTS for (int i = 0; i<pc->structs->len; i++) { lcm_struct_t *ls = (lcm_struct_t *) g_ptr_array_index(pc->structs, i); char path[PATH_MAX]; sprintf (path, "%s%s.lua", package_dir, ls->structname->shortname); if(init_lua_fp){ // XXX add the 'require' to the appropriate init.lua if (!g_hash_table_lookup(initlua_requires, ls->structname->shortname)) { fprintf(init_lua_fp, "M.%s = require('%s')\n", ls->structname->shortname, ls->structname->lctypename); } // XXX look for subpackages for (unsigned int m = 0; m < g_ptr_array_size(ls->members); m++) { lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, m); if(g_str_has_prefix(lm->type->package, pc->name)){ // make a regex starting with the current package... gchar ** tmpsplit = g_strsplit(pc->name, ".", 0); gchar * regexpackage = g_strjoinv("\\.", tmpsplit); // only look for immediate submodules, not submodules of the submodules gchar * regexstr = g_strjoin("", "^", regexpackage, "\\.(\\w+)", NULL); GRegex * regex = g_regex_new(regexstr, (GRegexCompileFlags) 0, (GRegexMatchFlags) 0, NULL); GMatchInfo * matchinfo; g_strfreev(tmpsplit); g_free(regexpackage); g_free(regexstr); if (g_regex_match(regex, lm->type->package, (GRegexMatchFlags) 0, &matchinfo)) { if (g_match_info_get_match_count(matchinfo) == 2) { gchar * fullsubpackage = g_match_info_fetch(matchinfo, 0); gchar * subpackage = g_match_info_fetch(matchinfo, 1); // was it already in the file? if (!g_hash_table_lookup(initlua_requires_subpack, fullsubpackage)) { // XXX fprintf(stderr, "> [1] inserting: %s\n", fullsubpackage); g_hash_table_insert(initlua_requires_subpack, g_strdup(fullsubpackage), g_strdup(fullsubpackage)); fprintf(init_lua_fp, "M.%s = require('%s') -- subpackage\n", subpackage, fullsubpackage); } } } g_match_info_free(matchinfo); g_regex_unref(regex); } } } if (!lcm_needs_generation(lcm, ls->lcmfile, path)) continue; FILE *f = fopen(path, "w"); if (f==NULL) return -1; fprintf(f, "--[[\n" "LCM type definitions\n" "This file automatically generated by lcm.\n" "DO NOT MODIFY BY HAND!!!!\n" "--]]\n" "\n" "local lcm = require('lcm')\n\n"); emit_lua_dependencies (lcm, f, ls); // XXX added this... emit_lua_locals(lcm, f, ls); emit_lua_buffer_helper(lcm, f, ls); // XXX step 3, start making the object emit(0, "local %s = {}", ls->structname->shortname); emit(0, "%s.__index = %s", ls->structname->shortname, ls->structname->shortname); emit(0, ""); // CONSTANTS for (unsigned int cn = 0; cn < g_ptr_array_size(ls->constants); cn++) { lcm_constant_t *lc = (lcm_constant_t *) g_ptr_array_index(ls->constants, cn); assert(lcm_is_legal_const_type(lc->lctypename)); emit(1, "%s.%s = %s", ls->structname->shortname, lc->membername, lc->val_str); } if (g_ptr_array_size(ls->constants) > 0) emit(0, ""); // NAMES emit(0, "%s.name = '%s'", ls->structname->shortname, ls->structname->lctypename); emit(0, "%s.packagename = '%s'", ls->structname->shortname, ls->structname->package); emit(0, "%s.shortname = '%s'", ls->structname->shortname, ls->structname->shortname); emit(0, ""); emit_lua_new (lcm, f, ls); emit_lua_fingerprint (lcm, f, ls); emit_lua_encode (lcm, f, ls); emit_lua_encode_one (lcm, f, ls); emit_lua_decode (lcm, f, ls); emit_lua_decode_one (lcm, f, ls); emit(0, "return %s", ls->structname->shortname); emit(0, ""); fclose (f); } if(init_lua_fp){ fprintf(init_lua_fp, "\nreturn M\n\n"); fclose(init_lua_fp); } g_hash_table_destroy(initlua_requires); return 0; }
/*! @brief Returns the nth member of the group * * Returns a pointer to the nth member of the group * * @param group The group * @param nth Which member to return * @returns Pointer to the member * */ OSyncMember *osync_group_nth_member(OSyncGroup *group, int nth) { osync_assert(group); return (OSyncMember *)g_list_nth_data(group->members, nth); }
/*! @brief Gets the nth filter of a group * * Note that you should not add or delete filters while * iterating over them * * @param group The group * @param nth Which filter to return * @returns The filter or NULL if not found * */ OSyncFilter *osync_group_nth_filter(OSyncGroup *group, int nth) { osync_assert(group); return g_list_nth_data(group->filters, nth); }
static void cm_tree_selection_changed_cb(GtkTreeSelection *selection, CookieManagerPage *cmp) { GList *rows; GtkTreeIter iter, iter_store; GtkTreeModel *model; gchar *text, *name; gboolean valid = TRUE; gboolean delete_possible = TRUE; guint rows_len; SoupCookie *cookie; CookieManagerPagePrivate *priv = cmp->priv; rows = gtk_tree_selection_get_selected_rows(selection, &model); rows_len = cm_list_length(rows); if (rows_len == 0) { valid = FALSE; delete_possible = FALSE; } else if (rows_len == 1) { /* get iter */ gtk_tree_model_get_iter(model, &iter, (GtkTreePath*) (g_list_nth_data(rows, 0))); gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(model), &iter_store, &iter); } else valid = FALSE; if (valid && gtk_tree_store_iter_is_valid(priv->store, &iter_store)) { gtk_tree_model_get(model, &iter, COOKIE_MANAGER_COL_COOKIE, &cookie, -1); if (cookie != NULL) { text = cm_get_cookie_description_text(cookie); gtk_label_set_markup(GTK_LABEL(priv->desc_label), text); g_free(text); } else { gtk_tree_model_get(model, &iter, COOKIE_MANAGER_COL_NAME, &name, -1); if (name != NULL) { gint cookie_count = gtk_tree_model_iter_n_children(model, &iter); text = cm_get_domain_description_text(name, cookie_count); gtk_label_set_markup(GTK_LABEL(priv->desc_label), text); g_free(text); g_free(name); } } } /* This is a bit hack'ish but we add some empty lines to get a minimum height of the * label at the bottom without any font size calculation. */ if (! valid) gtk_label_set_text(GTK_LABEL(priv->desc_label), CM_EMPTY_LABEL_TEXT); cm_set_button_sensitiveness(cmp, delete_possible); cm_free_selection_list(rows, (GFunc) gtk_tree_path_free); }
static void ggp_pubdir_search_results_info(PurpleConnection *gc, GList *row, gpointer _form) { ggp_pubdir_get_info_protocol(gc, g_list_nth_data(row, 0)); }
int32_t dt_camera_capture_job_run(dt_job_t *job) { dt_camera_capture_t *t=(dt_camera_capture_t*)job->param; int total = t->brackets ? t->count * t->brackets : t->count; char message[512]= {0}; double fraction=0; snprintf(message, 512, ngettext ("capturing %d image", "capturing %d images", total), total ); /* try to get exp program mode for nikon */ char *expprogram = (char *)dt_camctl_camera_get_property(darktable.camctl, NULL, "expprogram"); /* if fail, lets try fetching mode for cannon */ if(!expprogram) expprogram = (char *)dt_camctl_camera_get_property(darktable.camctl, NULL, "autoexposuremode"); /* Fetch all values for shutterspeed and initialize current value */ GList *values=NULL; gconstpointer orginal_value=NULL; const char *cvalue = dt_camctl_camera_get_property(darktable.camctl, NULL, "shutterspeed"); const char *value = dt_camctl_camera_property_get_first_choice(darktable.camctl, NULL, "shutterspeed"); /* get values for bracketing */ if (t->brackets && expprogram && expprogram[0]=='M' && value && cvalue) { do { // Add value to list values = g_list_append(values, g_strdup(value)); // Check if current values is the same as orginal value, then lets store item ptr if (strcmp(value,cvalue) == 0) orginal_value = g_list_last(values)->data; } while ((value = dt_camctl_camera_property_get_next_choice(darktable.camctl, NULL, "shutterspeed")) != NULL); } else { /* if this was an itended bracket capture bail out */ if(t->brackets) { dt_control_log(_("please set your camera to manual mode first!")); return 1; } } /* create the bgjob plate */ const guint *jid = dt_control_backgroundjobs_create(darktable.control, 0, message); GList *current_value = g_list_find(values,orginal_value); for(int i=0; i<t->count; i++) { // Delay if active if(t->delay) g_usleep(t->delay*G_USEC_PER_SEC); for(int b=0; b<(t->brackets*2)+1; b++) { // If bracket capture, lets set change shutterspeed if (t->brackets) { if (b == 0) { // First bracket, step down time with (steps*brackets), also check so we never set the longest shuttertime which would be bulb mode for(int s=0; s<(t->steps*t->brackets); s++) if (g_list_next(current_value) && g_list_next(g_list_next(current_value))) current_value = g_list_next(current_value); } else { // Step up with (steps) for(int s=0; s<t->steps; s++) if(g_list_previous(current_value)) current_value = g_list_previous(current_value); } } // set the time property for bracked capture if (t->brackets && current_value) dt_camctl_camera_set_property_string(darktable.camctl, NULL, "shutterspeed", current_value->data); // Capture image dt_camctl_camera_capture(darktable.camctl,NULL); fraction += 1.0/total; dt_control_backgroundjobs_progress(darktable.control, jid, fraction); } // lets reset to orginal value before continue if (t->brackets) { current_value = g_list_find(values,orginal_value); dt_camctl_camera_set_property_string(darktable.camctl, NULL, "shutterspeed", current_value->data); } } dt_control_backgroundjobs_destroy(darktable.control, jid); // free values if(values) { for(int i=0; i<g_list_length(values); i++) g_free(g_list_nth_data(values,i)); g_list_free(values); } return 0; }
void odometry_classify_motion_from_flow (GQueue *motions, flow_t **flow, int num) { int nmotions = g_queue_get_length (motions); double totalscore = .0; double maxscore = .0; int maxscoreindex = -1; int64_t utime = flow[0]->utime1; if (g_first_update_utime == 0) g_first_update_utime = utime; // skip if no new flow information if (utime == g_last_update_utime) return; g_last_update_utime = utime; // save flow to images for (int i=0; i<num; i++) { char fname[256]; sprintf (fname, "flow-%d.png", i); flow_draw (flow[i], fname); } int nbuckets = 4; double *scores = math_3d_array_alloc_double (num, nbuckets*nbuckets, nmotions); int *nscores = math_3d_array_alloc_int (num, nbuckets*nbuckets, nmotions); // for each sensor for (int i=0; i<num; i++) { flow_t *fl = flow[i]; int64_t delta_usecs = fl->utime1 - fl->utime0; // for each flow vector... for (int j=0; j<fl->flow_count; j++) { if (!fl->flow_status[j]) continue; double x = fl->flow_points[0][j].x/fl->width; double y = fl->flow_points[0][j].y/fl->height; double fx = ( fl->flow_points[1][j].x - fl->flow_points[0][j].x ) / fl->width * 1000000.0 / delta_usecs; double fy = ( fl->flow_points[1][j].y - fl->flow_points[0][j].y ) / fl->height * 1000000.0 / delta_usecs; int idx = MIN (int (x * nbuckets), nbuckets-1); int idy = MIN (int (y * nbuckets), nbuckets-1); int bucket_index = idx * nbuckets + idy; if (!(-1E-6 < x && x < 1.0 + 1E-6) || !(-1E-6 < y && y < 1.0 + 1E-6)) continue; // score each motion type for (int k=0; k<nmotions; k++) { // the k-th reference flow for sensor i flow_field_t *flow_field = (flow_field_t*)((flow_field_t**)g_queue_peek_nth (motions, k))[i]; double s = flow_field_score_base (flow_field, x, y, fx, fy); assert (0 <= bucket_index && bucket_index < nbuckets*nbuckets); double val = math_3d_array_get_double (scores, num, nbuckets*nbuckets, nmotions, i, bucket_index, k) + s; int n = math_3d_array_get_int (nscores, num, nbuckets*nbuckets, nmotions, i, bucket_index, k) + 1; math_3d_array_set_double (scores, num, nbuckets*nbuckets, nmotions, i, bucket_index, k, val); math_3d_array_set_int (nscores, num, nbuckets*nbuckets, nmotions, i, bucket_index, k, n); } } } // aggregated classifier rankings int *ascores = (int*)calloc (nmotions, sizeof(int)); for (int i=0; i<num; i++) { for (int j=0; j<nbuckets*nbuckets; j++) { GList *motion_votes = NULL; int nvotes=0; for (int k=0; k<nmotions; k++) { pair_t *p = (pair_t*)malloc(sizeof(pair_t)); p->key = k; p->val = math_3d_array_get_double (scores, num, nbuckets*nbuckets, nmotions, i, j, k); motion_votes = g_list_append (motion_votes, p); nvotes += math_3d_array_get_int (nscores, num, nbuckets*nbuckets, nmotions, i, j, k); } if (nvotes > 0) { motion_votes = g_list_sort (motion_votes, pair_comp_val); for (int k=0; k<nmotions; k++) { int key = ((pair_t*)g_list_nth_data (motion_votes, k))->key; assert (0 <= key && key < nmotions); ascores[key] += k; } } for (int k=0; k<nmotions; k++) free ((pair_t*)g_list_nth_data (motion_votes, k)); g_list_free (motion_votes); } } printf ("finding best scoring motion\n"); /* find best scoring motion */ for (int i=0; i<nmotions; i++) { //scores[i] = flow_field_set_compute_score ((flow_field_t**)g_queue_peek_nth (motions, i), flow, num); if (maxscoreindex < 0 || maxscore < ascores[i]) { maxscore = ascores[i]; maxscoreindex = i; } } printf ("ascores: %d %d %d %d %d\n", ascores[0], ascores[1], ascores[2], ascores[3], ascores[4]); FILE *fp = fopen ("motion-type.txt", "a"); fprintf (fp, "%d\n", maxscoreindex); fclose (fp); printf ("MOTION TYPE: %d\n", maxscoreindex); free (scores); free (nscores); free (ascores); }
/* ==================================== */ static void missing_letter_create_item(GooCanvasItem *parent) { int xOffset, yOffset; GdkPixbuf *button_pixmap = NULL; GdkPixbuf *pixmap = NULL; Board *board; /* This are the values of the area in which we must display the image */ gint img_area_x = 290; gint img_area_y = 80; gint img_area_w = 440; gint img_area_h = 310; /* this is the coordinate of the text to find */ gint txt_area_x = 515; gint txt_area_y = 435; guint vertical_separation; gint i; board_number = gcomprisBoard_missing->sublevel-1; g_assert(board_number >= 0 && board_number < g_list_length(board_list)); boardRootItem = \ goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard_missing->canvas), NULL); button_pixmap = gc_pixmap_load("missing_letter/button.png"); /* display the image */ board = g_list_nth_data(board_list, board_number); g_assert(board != NULL); pixmap = gc_pixmap_load(board->pixmapfile); text = goo_canvas_text_new (boardRootItem, _(board->question), (double) txt_area_x, (double) txt_area_y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", 0xFFFFFFFFL, NULL); goo_canvas_image_new (boardRootItem, pixmap, img_area_x+(img_area_w - gdk_pixbuf_get_width(pixmap))/2, img_area_y+(img_area_h - gdk_pixbuf_get_height(pixmap))/2, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif /* Calc the number of proposals */ i = 0; while(board->text[i++]); vertical_separation = 10 + 20 / i; yOffset = ( BOARDHEIGHT - i * gdk_pixbuf_get_height(button_pixmap) - 2 * vertical_separation) / 2 - 20; xOffset = (img_area_x - gdk_pixbuf_get_width(button_pixmap))/2; i = 0; while(board->text[i]) { GooCanvasItem *button; GooCanvasItem *item; GooCanvasItem *group = goo_canvas_group_new (boardRootItem, NULL); button = goo_canvas_image_new (group, button_pixmap, xOffset, yOffset, NULL); g_object_set_data(G_OBJECT(group), "answer", board->answer); g_object_set_data(G_OBJECT(group), "button", button); g_object_set_data(G_OBJECT(group), "solution", GINT_TO_POINTER(board->solution)); g_signal_connect(button, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); item = goo_canvas_text_new (group, board->text[i], xOffset + gdk_pixbuf_get_width(button_pixmap)/2 + 1.0, yOffset + gdk_pixbuf_get_height(button_pixmap)/2 + 1.0, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", gc_skin_color_shadow, NULL); g_signal_connect(item, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); item = goo_canvas_text_new (group, board->text[i], xOffset + gdk_pixbuf_get_width(button_pixmap)/2, yOffset + gdk_pixbuf_get_height(button_pixmap)/2, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", gc_skin_color_text_button, NULL); g_signal_connect(item, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); yOffset += gdk_pixbuf_get_height(button_pixmap) + vertical_separation; i++; } #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(button_pixmap); #else g_object_unref(button_pixmap); #endif }
extern void CommandExternal(char *sz) { #if !HAVE_SOCKETS outputl(_("This installation of GNU Backgammon was compiled without\n" "socket support, and does not implement external controllers.")); #else int h, hPeer, cb; struct sockaddr *psa; char szCommand[256]; char *szResponse = NULL; struct sockaddr_in saRemote; socklen_t saLen; scancontext scanctx; int fExit; int fRestart = TRUE; int retval; sz = NextToken(&sz); if (!sz || !*sz) { outputl(_("You must specify the name of the socket to the external controller.")); return; } memset(&scanctx, 0, sizeof(scanctx)); ExtInitParse(&scanctx.scanner); listenloop: { fExit = FALSE; scanctx.fDebug = FALSE; scanctx.fNewInterface = FALSE; if ((h = ExternalSocket(&psa, &cb, sz)) < 0) { SockErr(sz); ExtDestroyParse(scanctx.scanner); return; } if (bind(h, psa, cb) < 0) { SockErr(sz); closesocket(h); free(psa); ExtDestroyParse(scanctx.scanner); return; } free(psa); if (listen(h, 1) < 0) { SockErr("listen"); closesocket(h); ExternalUnbind(sz); ExtDestroyParse(scanctx.scanner); return; } outputf(_("Waiting for a connection from %s...\n"), sz); outputx(); ProcessEvents(); /* Must set length when using windows */ saLen = sizeof(struct sockaddr); while ((hPeer = accept(h, (struct sockaddr *) &saRemote, &saLen)) < 0) { if (errno == EINTR) { ProcessEvents(); if (fInterrupt) { closesocket(h); ExternalUnbind(sz); ExtDestroyParse(scanctx.scanner); return; } continue; } SockErr("accept"); closesocket(h); ExternalUnbind(sz); ExtDestroyParse(scanctx.scanner); return; } closesocket(h); ExternalUnbind(sz); /* print info about remove client */ outputf(_("Accepted connection from %s.\n"), inet_ntoa(saRemote.sin_addr)); outputx(); ProcessEvents(); while (!fExit && !(retval = ExternalRead(hPeer, szCommand, sizeof(szCommand)))) { if ((ExtParse(&scanctx, szCommand)) == 0) { /* parse error */ szResponse = scanctx.szError; } else { ProcessedFIBSBoard processedBoard; GValue *optionsmapgv; GValue *boarddatagv; GString *dbgStr; int anScore[2]; int fCrawford, fJacoby; char *asz[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; char szBoard[10000]; char **aszLines; char **aszLinesOrig; char *szMatchID; gchar *szOptStr; switch (scanctx.ct) { case COMMAND_HELP: szResponse = g_strdup("\tNo help information available\n"); break; case COMMAND_SET: szOptStr = g_value_get_gstring_gchar(g_list_nth_data(scanctx.pCmdData, 0)); if (g_ascii_strcasecmp(szOptStr, KEY_STR_DEBUG) == 0) { scanctx.fDebug = g_value_get_int(g_list_nth_data(scanctx.pCmdData, 1)); szResponse = g_strdup_printf("Debug output %s\n", scanctx.fDebug ? "ON" : "OFF"); } else if (g_ascii_strcasecmp(szOptStr, KEY_STR_NEWINTERFACE) == 0) { scanctx.fNewInterface = g_value_get_int(g_list_nth_data(scanctx.pCmdData, 1)); szResponse = g_strdup_printf("New interface %s\n", scanctx.fNewInterface ? "ON" : "OFF"); } else { szResponse = g_strdup_printf("Error: set option '%s' not supported\n", szOptStr); } g_list_gv_boxed_free(scanctx.pCmdData); break; case COMMAND_VERSION: szResponse = g_strdup("Interface: " EXTERNAL_INTERFACE_VERSION "\n" "RFBF: " RFBF_VERSION_SUPPORTED "\n" "Engine: " WEIGHTS_VERSION "\n" "Software: " VERSION "\n"); break; case COMMAND_NONE: szResponse = g_strdup("Error: no command given\n"); break; case COMMAND_FIBSBOARD: case COMMAND_EVALUATION: if (scanctx.fDebug) { optionsmapgv = (GValue *) g_list_nth_data(g_value_get_boxed(scanctx.pCmdData), 1); boarddatagv = (GValue *) g_list_nth_data(g_value_get_boxed(scanctx.pCmdData), 0); dbgStr = g_string_new(DEBUG_PREFIX); g_value_tostring(dbgStr, optionsmapgv, 0); g_string_append(dbgStr, "\n" DEBUG_PREFIX); g_value_tostring(dbgStr, boarddatagv, 0); g_string_append(dbgStr, "\n" DEBUG_PREFIX "\n"); ExternalWrite(hPeer, dbgStr->str, strlen(dbgStr->str)); ProcessFIBSBoardInfo(&scanctx.bi, &processedBoard); anScore[0] = processedBoard.nScoreOpp; anScore[1] = processedBoard.nScore; /* If the session isn't using Crawford rule, set crawford flag to false */ fCrawford = scanctx.fCrawfordRule ? processedBoard.fCrawford : FALSE; /* Set the Jacoby flag appropriately from the external interface settings */ fJacoby = scanctx.fJacobyRule; szMatchID = MatchID((unsigned int *) processedBoard.anDice, 1, processedBoard.nResignation, processedBoard.fDoubled, 1, processedBoard.fCubeOwner, fCrawford, processedBoard.nMatchTo, anScore, processedBoard.nCube, fJacoby, GAME_PLAYING); DrawBoard(szBoard, (ConstTanBoard) & processedBoard.anBoard, 1, asz, szMatchID, 15); aszLines = g_strsplit(&szBoard[0], "\n", 32); aszLinesOrig = aszLines; while (*aszLines) { ExternalWrite(hPeer, DEBUG_PREFIX, strlen(DEBUG_PREFIX)); ExternalWrite(hPeer, *aszLines, strlen(*aszLines)); ExternalWrite(hPeer, "\n", 1); aszLines++; } dbgStr = g_string_assign(dbgStr, ""); g_string_append_printf(dbgStr, DEBUG_PREFIX "X is %s, O is %s\n", processedBoard.szPlayer, processedBoard.szOpp); if (processedBoard.nMatchTo) { g_string_append_printf(dbgStr, DEBUG_PREFIX "Match Play %s Crawford Rule\n", scanctx.fCrawfordRule ? "with" : "without"); g_string_append_printf(dbgStr, DEBUG_PREFIX "Score: %d-%d/%d%s, ", processedBoard.nScore, processedBoard.nScoreOpp, processedBoard.nMatchTo, fCrawford ? "*" : ""); } else { g_string_append_printf(dbgStr, DEBUG_PREFIX "Money Session %s Jacoby Rule, %s Beavers\n", scanctx.fJacobyRule ? "with" : "without", scanctx.fBeavers ? "with" : "without"); g_string_append_printf(dbgStr, DEBUG_PREFIX "Score: %d-%d, ", processedBoard.nScore, processedBoard.nScoreOpp); } g_string_append_printf(dbgStr, "Roll: %d%d\n", processedBoard.anDice[0], processedBoard.anDice[1]); g_string_append_printf(dbgStr, DEBUG_PREFIX "CubeOwner: %d, Cube: %d, Turn: %c, Doubled: %d, Resignation: %d\n", processedBoard.fCubeOwner, processedBoard.nCube, 'X', processedBoard.fDoubled, processedBoard.nResignation); g_string_append(dbgStr, DEBUG_PREFIX "\n"); ExternalWrite(hPeer, dbgStr->str, strlen(dbgStr->str)); g_string_free(dbgStr, TRUE); g_strfreev(aszLinesOrig); } g_value_unsetfree(scanctx.pCmdData); if (scanctx.ct == COMMAND_EVALUATION) szResponse = ExtEvaluation(&scanctx); else szResponse = ExtFIBSBoard(&scanctx); break; case COMMAND_EXIT: closesocket(hPeer); fExit = TRUE; break; default: szResponse = g_strdup("Unsupported Command\n"); } unset_scan_context(&scanctx, FALSE); } if (szResponse) { if (ExternalWrite(hPeer, szResponse, strlen(szResponse))) break; g_free(szResponse); szResponse = NULL; } } /* Interrupted : get out of listen loop */ if (retval == -2) { ProcessEvents(); fRestart = FALSE; } closesocket(hPeer); if (szResponse) g_free(szResponse); szResponse = NULL; scanctx.szError = NULL; } if (fRestart) goto listenloop; unset_scan_context(&scanctx, TRUE); #endif }
/** \brief Create and run GtkSatModule popup menu. * \param module The module that should have the popup menu attached to it. * * This function ctreates and executes a popup menu that is related to a * GtkSatModule widget. The module must be a valid GtkSatModule, since it makes * no sense whatsoever to have this kind of popup menu without a GtkSatModule * parent. * */ void gtk_sat_module_popup (GtkSatModule *module) { GtkWidget *menu; /* The pop-up menu */ GtkWidget *satsubmenu; /* Satellite selection submenu */ GtkWidget *menuitem; /* Widget used to create the menu items */ GtkWidget *image; /* Widget used to create menu item icons */ /* misc variables */ GList *sats; sat_t *sat; gchar *buff; guint i,n; if ((module == NULL) || !IS_GTK_SAT_MODULE (module)) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s:%d: %s called with NULL parameter!"), __FILE__, __LINE__, __FUNCTION__); return; } menu = gtk_menu_new (); if (module->state == GTK_SAT_MOD_STATE_DOCKED) { menuitem = gtk_image_menu_item_new_with_label (_("Detach module")); buff = icon_file_name ("gpredict-notebook.png"); image = gtk_image_new_from_file (buff); g_free (buff); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (docking_state_cb), module); } else { menuitem = gtk_image_menu_item_new_with_label (_("Attach module")); buff = icon_file_name ("gpredict-notebook.png"); image = gtk_image_new_from_file (buff); g_free (buff); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (docking_state_cb), module); } if (module->state == GTK_SAT_MOD_STATE_FULLSCREEN) { menuitem = gtk_image_menu_item_new_with_label (_("Exit full screen")); image = gtk_image_new_from_stock (GTK_STOCK_LEAVE_FULLSCREEN, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (screen_state_cb), module); } else { menuitem = gtk_image_menu_item_new_with_label (_("Full screen")); image = gtk_image_new_from_stock (GTK_STOCK_FULLSCREEN, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (screen_state_cb), module); } /* separator */ menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* select satellite submenu */ menuitem = gtk_menu_item_new_with_label(_("Select satellite")); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); satsubmenu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), satsubmenu); sats = g_hash_table_get_values(module->satellites); sats = g_list_sort(sats , (GCompareFunc) sat_nickname_compare ); n = g_list_length(sats); for (i = 0; i < n; i++) { sat = SAT(g_list_nth_data(sats, i)); menuitem = gtk_menu_item_new_with_label(sat->nickname); g_object_set_data(G_OBJECT(menuitem), "catnum", GINT_TO_POINTER(sat->tle.catnr)); g_signal_connect(menuitem, "activate", G_CALLBACK (sat_selected_cb), module); gtk_menu_shell_append(GTK_MENU_SHELL(satsubmenu), menuitem); } /* separator */ menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* sky at a glance */ menuitem = gtk_image_menu_item_new_with_label (_("Sky at a glance")); buff = icon_file_name ("gpredict-planner-small.png"); image = gtk_image_new_from_file (buff); g_free (buff); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (sky_at_glance_cb), module); /* time manager */ menuitem = gtk_image_menu_item_new_with_label (_("Time Controller")); buff = icon_file_name ("gpredict-clock-small.png"); image = gtk_image_new_from_file (buff); g_free (buff); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (tmgr_cb), module); /* separator */ menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* Radio Control */ menuitem = gtk_image_menu_item_new_with_label (_("Radio Control")); buff = icon_file_name ("gpredict-oscilloscope-small.png"); image = gtk_image_new_from_file (buff); g_free (buff); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (rigctrl_cb), module); /* Antenna Control */ menuitem = gtk_image_menu_item_new_with_label (_("Antenna Control")); buff = icon_file_name ("gpredict-antenna-small.png"); image = gtk_image_new_from_file (buff); g_free (buff); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (rotctrl_cb), module); /* separator */ menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* configure */ menuitem = gtk_image_menu_item_new_with_label (_("Configure")); image = gtk_image_new_from_stock (GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (config_cb), module); /* clone */ menuitem = gtk_image_menu_item_new_with_label (_("Clone...")); image = gtk_image_new_from_stock (GTK_STOCK_COPY, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (clone_cb), module); /* separator */ menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* delete module */ menuitem = gtk_image_menu_item_new_with_label (_("Delete")); image = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (delete_cb), module); /* close */ menuitem = gtk_image_menu_item_new_with_label (_("Close")); image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); g_signal_connect (menuitem, "activate", G_CALLBACK (close_cb), module); gtk_widget_show_all (menu); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, gdk_event_get_time (NULL)); }
gboolean os_kernel_update_services (OseaCommXmlServiceData * data, gpointer user_data, RRChannel * channel, gint msg_no) { GList * values; OseaCommDataSet * dataset; OseaCommDataSet * permissions; gchar ** splited_string; gchar * permission_string; gboolean response; gint iterator; gint iterator2; gint height; // Check params values = oseaserver_message_check_params (data, "server_name", "description", "version", "permissions", NULL); if (!values) { // Params seems to be incorrect oseaserver_message_error_answer (channel, msg_no, "Incorrect parameters form", OSEACOMM_CODE_XML_INCORRECT_PARAMETER); return FALSE; } // Check if the server is already installed dataset = oseaserver_command_execute_single_query ("SELECT * FROM kernel_server WHERE name = '%s'", g_list_nth_data (values, 0)); if (oseacomm_dataset_get_height (dataset) == 0) { // Server not installed. Install it. response = oseaserver_command_execute_non_query ("INSERT INTO kernel_server (name, description, version) VALUES ('%s', '%s', %s)", g_list_nth_data (values, 0), g_list_nth_data (values, 1), g_list_nth_data (values, 2)); if (!response) { oseaserver_message_error_answer (channel, msg_no, "Unable to install server services", OSEACOMM_CODE_ERROR); return FALSE; } } oseacomm_dataset_free (dataset); // We are going to check if update_services request is // executed to install all services or to update already existing services. // Right now we only support install mode dataset = oseaserver_command_execute_single_query ("SELECT * \ FROM kernel_permission p, kernel_server s \ WHERE p.server_id = s.id and s.name = '%s'", g_list_nth_data (values, 0)); if (oseacomm_dataset_get_height (dataset) == 0) { // Install mode oseacomm_dataset_free (dataset); // First we are going to insert all permissions g_print ("Recieved permissions\n"); permissions = g_list_nth_data (values, 3); oseacomm_dataset_print (permissions); height = oseacomm_dataset_get_height (permissions); for (iterator = 0; iterator < height; iterator++) { response = oseaserver_command_execute_non_query ("INSERT INTO kernel_permission (name, description, server_id) VALUES \ ('%s', '%s', (SELECT id FROM kernel_server WHERE name = '%s'))", oseacomm_dataset_get (permissions, iterator, 0), oseacomm_dataset_get (permissions, iterator, 1), g_list_nth_data (values, 0)); if (!response) { oseaserver_message_error_answer (channel, msg_no, "Unable to install server services", OSEACOMM_CODE_XML_INCORRECT_PARAMETER); return FALSE; } } // Then we are going to insert all dependencies for (iterator = 0; iterator < height; iterator++) { // Check for NULL permission_string permission_string = (gchar *) oseacomm_dataset_get (permissions, iterator, 2); if (!(permission_string && *permission_string)) continue; splited_string = g_strsplit (permission_string, ",", 0); iterator2 = 0; while (splited_string[iterator2] != NULL) { response = oseaserver_command_execute_non_query ("INSERT INTO kernel_depends (id_permission, id_depends) VALUES ( \ (SELECT id FROM kernel_permission WHERE name = '%s'), \ (SELECT id FROM kernel_permission WHERE name = '%s'))", oseacomm_dataset_get (permissions, iterator, 0), splited_string[iterator2]); if (!response) { oseaserver_message_error_answer (channel, msg_no, "Unable to install service dependencies", OSEACOMM_CODE_XML_INCORRECT_PARAMETER); return FALSE; } iterator2++; } g_strfreev (splited_string); } }else {
gboolean cd_do_key_pressed (gpointer pUserData, GldiContainer *pContainer, guint iKeyVal, guint iModifierType, const gchar *string, int iKeyCode) { g_return_val_if_fail (cd_do_session_is_running (), GLDI_NOTIFICATION_LET_PASS); g_return_val_if_fail (myData.pCurrentDock != NULL, GLDI_NOTIFICATION_LET_PASS); const gchar *cKeyName = gdk_keyval_name (iKeyVal); guint32 iUnicodeChar = gdk_keyval_to_unicode (iKeyVal); cd_debug ("+ cKeyName : %s (%c, %s, %d)", cKeyName, iUnicodeChar, string, iKeyCode); if (myData.sCurrentText->len == 0) { GdkKeymapKey *keys = NULL; guint *keyvals = NULL; int i, n_entries = 0; int iKeyVal2; gdk_keymap_get_entries_for_keycode (gdk_keymap_get_default (), iKeyCode, &keys, &keyvals, &n_entries); for (i = 0; i < n_entries; i ++) { iKeyVal2 = keyvals[i]; if ((iKeyVal2 >= GDK_KEY_0 && iKeyVal2 <= GDK_KEY_9) || (iKeyVal2 >= GDK_KEY_KP_0 && iKeyVal2 <= GDK_KEY_KP_9)) { iKeyVal = iKeyVal2; break; } } g_free (keys); g_free (keyvals); } if (iKeyVal == GDK_KEY_Escape) // on clot la session. { // give the focus back to the window that had it before the user opened this session. if (myData.pPreviouslyActiveWindow != NULL) { gldi_window_show (myData.pPreviouslyActiveWindow); } cd_do_close_session (); } else if (iKeyVal == GDK_KEY_space && myData.sCurrentText->len == 0) // pas d'espace en debut de chaine. { // on rejette. } else if (iKeyVal >= GDK_KEY_Shift_L && iKeyVal <= GDK_KEY_Hyper_R) // on n'ecrit pas les modificateurs. { // on rejette. } else if (iKeyVal == GDK_KEY_Menu) // emulation du clic droit. { if (myData.pCurrentIcon != NULL) { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); // car on va perdre le focus. myData.bIgnoreIconState = FALSE; GtkWidget *menu = gldi_container_build_menu (CAIRO_CONTAINER (myData.pCurrentDock), myData.pCurrentIcon); gldi_menu_popup (menu); } } else if (iKeyVal == GDK_KEY_BackSpace) // on efface la derniere lettre. { if (myData.sCurrentText->len > 0) { cd_debug ("we remove the last letter of %s (%d)", myData.sCurrentText->str, myData.sCurrentText->len); g_string_truncate (myData.sCurrentText, myData.sCurrentText->len-1); // on relance la recherche. if (myData.pCurrentIcon == NULL) // sinon l'icone actuelle convient toujours. cd_do_search_current_icon (FALSE); } } else if (iKeyVal == GDK_KEY_Tab) // jump to next icon. { if (myData.sCurrentText->len > 0) { //gboolean bPrevious = iModifierType & GDK_SHIFT_MASK; // on cherche l'icone suivante. cd_do_search_current_icon (TRUE); // pCurrentIcon peut etre NULL si elle s'est faite detruire pendant la recherche, auquel cas on cherchera juste normalement. } } else if (iKeyVal == GDK_KEY_Return) { if (myData.pCurrentIcon != NULL) { cd_debug ("we click on the icon '%s' [%d, %d]", myData.pCurrentIcon->cName, iModifierType, GDK_SHIFT_MASK); myData.bIgnoreIconState = TRUE; if (iModifierType & GDK_MOD1_MASK) // ALT { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); // car aucune animation ne va la remplacer. myData.bIgnoreIconState = FALSE; gldi_object_notify (CAIRO_CONTAINER (myData.pCurrentDock), NOTIFICATION_MIDDLE_CLICK_ICON, myData.pCurrentIcon, myData.pCurrentDock); } else if (iModifierType & GDK_CONTROL_MASK) // CTRL { myData.bIgnoreIconState = TRUE; gldi_icon_stop_animation (myData.pCurrentIcon); // car on va perdre le focus. myData.bIgnoreIconState = FALSE; GtkWidget *menu = gldi_container_build_menu (CAIRO_CONTAINER (myData.pCurrentDock), myData.pCurrentIcon); gldi_menu_popup (menu); } else { cd_do_simulate_click (CAIRO_CONTAINER (myData.pCurrentDock), myData.pCurrentIcon, iModifierType); } gldi_icon_start_animation (myData.pCurrentIcon); myData.bIgnoreIconState = FALSE; myData.pCurrentIcon = NULL; // sinon on va interrompre l'animation en fermant la session. } cd_do_close_session (); } else if (iKeyVal == GDK_KEY_Left || iKeyVal == GDK_KEY_Right || iKeyVal == GDK_KEY_Up || iKeyVal == GDK_KEY_Down) { iKeyVal = _orient_arrow (pContainer, iKeyVal); if (iKeyVal == GDK_KEY_Up) { if (myData.pCurrentIcon != NULL && myData.pCurrentIcon->pSubDock != NULL) { cd_debug ("on monte dans le sous-dock %s", myData.pCurrentIcon->cName); Icon *pIcon = cairo_dock_get_first_icon (myData.pCurrentIcon->pSubDock->icons); cd_do_change_current_icon (pIcon, myData.pCurrentIcon->pSubDock); } } else if (iKeyVal == GDK_KEY_Down) { if (myData.pCurrentDock->iRefCount > 0) { CairoDock *pParentDock = NULL; Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (myData.pCurrentDock, &pParentDock); if (pPointingIcon != NULL) { cd_debug ("on redescend dans le dock parent via %s", pPointingIcon->cName); cd_do_change_current_icon (pPointingIcon, pParentDock); } } } else if (iKeyVal == GDK_KEY_Left) { if (myData.pCurrentDock->icons != NULL) { Icon *pPrevIcon = cairo_dock_get_previous_icon (myData.pCurrentDock->icons, myData.pCurrentIcon); if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pPrevIcon)) pPrevIcon = cairo_dock_get_previous_icon (myData.pCurrentDock->icons, pPrevIcon); if (pPrevIcon == NULL) // pas trouve ou bien 1ere icone. { pPrevIcon = cairo_dock_get_last_icon (myData.pCurrentDock->icons); } cd_debug ("on se deplace a gauche sur %s", pPrevIcon ? pPrevIcon->cName : "none"); cd_do_change_current_icon (pPrevIcon, myData.pCurrentDock); } } else // Gdk_Right. { if (myData.pCurrentDock->icons != NULL) { Icon *pNextIcon = cairo_dock_get_next_icon (myData.pCurrentDock->icons, myData.pCurrentIcon); if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pNextIcon)) pNextIcon = cairo_dock_get_next_icon (myData.pCurrentDock->icons, pNextIcon); if (pNextIcon == NULL) // pas trouve ou bien 1ere icone. { pNextIcon = cairo_dock_get_first_icon (myData.pCurrentDock->icons); } cd_debug ("on se deplace a gauche sur %s", pNextIcon ? pNextIcon->cName : "none"); cd_do_change_current_icon (pNextIcon, myData.pCurrentDock); } } } else if (iKeyVal == GDK_KEY_Page_Down || iKeyVal == GDK_KEY_Page_Up || iKeyVal == GDK_KEY_Home || iKeyVal == GDK_KEY_End) { if (iModifierType & GDK_CONTROL_MASK) // changement de dock principal { gpointer data[4] = {myData.pCurrentDock, NULL, GINT_TO_POINTER (FALSE), NULL}; gldi_docks_foreach_root ((GFunc) _find_next_dock, data); CairoDock *pNextDock = data[1]; if (pNextDock == NULL) pNextDock = data[3]; if (pNextDock != NULL) { Icon *pNextIcon = NULL; int n = g_list_length (pNextDock->icons); if (n > 0) { pNextIcon = g_list_nth_data (pNextDock->icons, (n-1) / 2); if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pNextIcon) && n > 1) pNextIcon = g_list_nth_data (pNextDock->icons, (n+1) / 2); } cd_do_change_current_icon (pNextIcon, pNextDock); } } Icon *pIcon = (iKeyVal == GDK_KEY_Page_Up || iKeyVal == GDK_KEY_Home ? cairo_dock_get_first_icon (myData.pCurrentDock->icons) : cairo_dock_get_last_icon (myData.pCurrentDock->icons)); cd_debug ("on se deplace a l'extremite sur %s", pIcon ? pIcon->cName : "none"); cd_do_change_current_icon (pIcon, myData.pCurrentDock); } else if ( ((iKeyVal >= GDK_KEY_0 && iKeyVal <= GDK_KEY_9) || (iKeyVal >= GDK_KEY_KP_0 && iKeyVal <= GDK_KEY_KP_9)) && myData.sCurrentText->len == 0) { _activate_nth_icon (iKeyVal, iModifierType); } else if (string) /// utiliser l'unichar ... { cd_debug ("string:'%s'", string); g_string_append_c (myData.sCurrentText, *string); cd_do_search_current_icon (FALSE); } return GLDI_NOTIFICATION_INTERCEPT; }
void nsgtk_about_dialog_init(GtkWindow *parent, struct browser_window *bw, const char *version) { GtkWidget *dialog, *vbox, *button, *image, *label; gchar *name_string; GList *pixbufs = gtk_window_get_default_icon_list(); name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">NetSurf %s</span>", version); /* Create the widgets */ dialog = gtk_dialog_new_with_buttons("About NetSurf", parent, GTK_DIALOG_DESTROY_WITH_PARENT, NULL); vbox = gtk_vbox_new (FALSE, 8); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), vbox, TRUE, TRUE, 0); if (pixbufs != NULL) { GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(GDK_PIXBUF(g_list_nth_data(pixbufs, 0))); image = gtk_image_new(); gtk_image_set_from_icon_set (GTK_IMAGE (image), icon_set, GTK_ICON_SIZE_DIALOG); gtk_icon_set_unref (icon_set); g_list_free (pixbufs); gtk_box_pack_start(GTK_BOX (vbox), image, FALSE, FALSE, 0); } label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), name_string); g_free (name_string); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); label = gtk_label_new("NetSurf is a small fast web browser"); gtk_label_set_selectable(GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); label = gtk_label_new("Copyright © 2003 - 2012 The NetSurf Developers"); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX (vbox), label, FALSE, FALSE, 0); nsgtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); /* Add the OK button */ gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); /* Add the credits button */ button = gtk_button_new_from_stock ("Credits"); gtk_box_pack_end(GTK_BOX (GTK_DIALOG (dialog)->action_area), button, FALSE, TRUE, 0); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE); g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_credits), (gpointer)bw); /* Add the Licence button */ button = gtk_button_new_from_stock ("Licence"); gtk_box_pack_end(GTK_BOX (GTK_DIALOG (dialog)->action_area), button, FALSE, TRUE, 0); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE); g_signal_connect(button, "clicked", G_CALLBACK(nsgtk_about_dialog_licence), (gpointer)bw); /* Ensure that the dialog box is destroyed when the user responds. */ g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); /* Add the label, and show everything we've added to the dialog. */ gtk_widget_show_all(dialog); }
GssStream * gss_program_get_stream (GssProgram * program, int index) { return (GssStream *) g_list_nth_data (program->streams, index); }
static void carrick_list_drag_end (GtkWidget *widget, GdkDragContext *context, CarrickList *list) { CarrickListPrivate *priv = list->priv; GList *children; children = gtk_container_get_children (GTK_CONTAINER (priv->box)); /* destroy the popup window */ g_object_ref (widget); gtk_container_remove (GTK_CONTAINER (priv->drag_window), widget); gtk_widget_destroy (priv->drag_window); priv->drag_window = NULL; /* insert the widget into the list */ gtk_box_pack_start (GTK_BOX (priv->box), widget, FALSE, FALSE, 2); gtk_box_reorder_child (GTK_BOX (priv->box), widget, priv->drop_position); g_object_unref (widget); if (priv->drop_position != priv->drag_position) { GtkWidget *other_widget; DBusGProxy *service, * other_service; const gchar *path; move_data *data = NULL; service = carrick_service_item_get_proxy (CARRICK_SERVICE_ITEM (widget)); data = g_slice_new0 (move_data); data->list = GTK_WIDGET (list->priv->box); data->item = widget; data->pos = priv->drag_position; if (priv->drop_position == 0) { other_widget = g_list_nth_data (children, 0); other_service = carrick_service_item_get_proxy (CARRICK_SERVICE_ITEM (other_widget)); path = dbus_g_proxy_get_path (other_service); net_connman_Service_move_before_async (service, path, move_notify_cb, data); } else { other_widget = g_list_nth_data (children, priv->drop_position - 1); other_service = carrick_service_item_get_proxy (CARRICK_SERVICE_ITEM (other_widget)); path = dbus_g_proxy_get_path (other_service); net_connman_Service_move_after_async (service, path, move_notify_cb, data); } } g_list_free (children); }
static gint on_button_press_event (GtkWidget *widget, GdkEventButton *event, GtkamList *list) { GtkTreePath *path = NULL; GtkWidget *w; GtkamCamera *camera; CameraAbilities a; switch (event->button) { case 3: if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (list), event->x, event->y, &path, NULL, NULL, NULL)) return (FALSE); gtk_tree_model_get_iter (GTK_TREE_MODEL (list->priv->store), &list->priv->iter, path); gtk_tree_path_free (path); camera = gtkam_list_get_camera_from_iter (list, &list->priv->iter); gp_camera_get_abilities (camera->camera, &a); /* What operations does the camera support? */ w = gtk_item_factory_get_widget (list->priv->factory, "/Delete"); gtk_widget_set_sensitive (w, (a.file_operations & GP_FILE_OPERATION_DELETE)); #ifdef HAVE_BONOBO { Bonobo_ServerInfoList *l; guint i; GtkWidget *item, *c; CORBA_Environment ev; CameraFileInfo finfo; gchar *fo, *fi, *query; ViewAsData *d; GList *cl; w = gtk_item_factory_get_widget (list->priv->factory, "/View with..."); c = gtk_item_factory_get_widget (list->priv->factory, "/View with.../Built-in viewer"); cl = gtk_container_get_children (GTK_CONTAINER (w)); for (i = 0; i < g_list_length (cl); i++) { if (g_list_nth_data (cl, i) != c) gtk_container_remove (GTK_CONTAINER (w), GTK_WIDGET (g_list_nth_data (cl, i))); } fo = gtkam_list_get_folder_from_iter (list, &list->priv->iter); fi = gtkam_list_get_name_from_iter (list, &list->priv->iter); gp_camera_file_get_info (camera->camera, fo, fi, &finfo, NULL); g_free (fo); g_free (fi); if (finfo.file.fields & GP_FILE_INFO_TYPE) { CORBA_exception_init (&ev); query = g_strconcat ("repo_ids.has ('IDL:Bonobo/Control:1.0') AND " "bonobo:supported_mime_types.has ('", finfo.file.type, "')", NULL); l = bonobo_activation_query (query, NULL, &ev); g_free (query); CORBA_exception_free (&ev); if (l && l->_length) { for (i = 0; i < l->_length; i++) { Bonobo_ServerInfo *si = &l->_buffer[i]; const gchar *n; if (!si->iid) continue; n = bonobo_server_info_prop_lookup (si, "name", NULL); if (!n) n = si->iid; item = gtk_menu_item_new_with_label (n); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (w), item); d = g_new0 (ViewAsData, 1); d->list = list; d->camera = camera; g_object_ref (G_OBJECT (d->camera)); d->folder = gtkam_list_get_folder_from_iter (list, &list->priv->iter); d->file = gtkam_list_get_name_from_iter (list, &list->priv->iter); d->iid = g_strdup (si->iid); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (on_view_as_activate), d); g_signal_connect (G_OBJECT (item), "destroy", G_CALLBACK (on_menu_item_destroy), d); } } if (l) CORBA_free (l); } } #endif gtk_item_factory_popup (list->priv->factory, event->x_root, event->y_root, event->button, event->time); return (TRUE); default: return (FALSE); } }
static void cm_delete_item(CookieManagerPage *cmp) { GtkTreeIter iter, iter_store, child; GtkTreeModel *model; GtkTreePath *path, *last_path; GtkTreeSelection *selection; GList *rows, *row; GList *refs = NULL; CookieManagerPagePrivate *priv = cmp->priv; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview)); rows = gtk_tree_selection_get_selected_rows(selection, &model); if (cm_list_length(rows) == 0) return; last_path = gtk_tree_path_copy(g_list_nth_data(rows, 0)); /* as paths will change during delete, first create GtkTreeRowReferences for * all selected rows */ row = rows; do { refs = g_list_append(refs, gtk_tree_row_reference_new(model, (GtkTreePath*) (row->data))); } while ((row = row->next) != NULL); row = refs; do { /* get iter */ path = gtk_tree_row_reference_get_path((GtkTreeRowReference*) row->data); if (path == NULL) continue; gtk_tree_model_get_iter(model, &iter, path); if (gtk_tree_model_iter_has_child(model, &iter)) { while (gtk_tree_model_iter_children(model, &child, &iter)) { cm_delete_cookie(cmp, model, &child); cm_store_remove(cmp, &child); /* we retrieve again the iter at path because it got invalid by the delete operation */ gtk_tree_model_get_iter(model, &iter, path); } /* remove/hide the parent */ gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(priv->filter), &iter_store, &iter); if (gtk_tree_model_iter_has_child(GTK_TREE_MODEL(priv->store), &iter_store)) gtk_tree_store_set(priv->store, &iter_store, COOKIE_MANAGER_COL_VISIBLE, FALSE, -1); else cm_store_remove(cmp, &iter); } else { GtkTreePath *path_store, *path_model; gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(priv->filter), &iter_store, &iter); path_store = gtk_tree_model_get_path(GTK_TREE_MODEL(priv->store), &iter_store); path_model = gtk_tree_model_get_path(model, &iter); cm_delete_cookie(cmp, model, &iter); gtk_tree_store_remove(priv->store, &iter_store); /* check whether the parent still has children, otherwise delete it */ if (gtk_tree_path_up(path_store)) { gtk_tree_model_get_iter(GTK_TREE_MODEL(priv->store), &iter_store, path_store); if (! gtk_tree_model_iter_has_child(GTK_TREE_MODEL(priv->store), &iter_store)) /* remove the empty parent */ gtk_tree_store_remove(priv->store, &iter_store); } /* now for the filter model */ if (gtk_tree_path_up(path_model)) { gtk_tree_model_get_iter(model, &iter, path_model); if (! gtk_tree_model_iter_has_child(model, &iter)) { gtk_tree_model_filter_convert_iter_to_child_iter( GTK_TREE_MODEL_FILTER(priv->filter), &iter_store, &iter); /* hide the empty parent */ gtk_tree_store_set(priv->store, &iter_store, COOKIE_MANAGER_COL_VISIBLE, FALSE, -1); } } gtk_tree_path_free(path_store); gtk_tree_path_free(path_model); } gtk_tree_path_free(path); } while ((row = row->next) != NULL); cm_free_selection_list(rows, (GFunc) gtk_tree_path_free); cm_free_selection_list(refs, (GFunc) gtk_tree_row_reference_free); cm_select_path(cmp, model, last_path); gtk_tree_path_free(last_path); }
static void memo_shell_view_execute_search (EShellView *shell_view) { EMemoShellContent *memo_shell_content; EShellWindow *shell_window; EShellContent *shell_content; EShellSearchbar *searchbar; EActionComboBox *combo_box; GtkRadioAction *action; ECalComponentPreview *memo_preview; EPreviewPane *preview_pane; EMemoTable *memo_table; EWebView *web_view; ECalModel *model; gchar *query; gchar *temp; gint value; shell_content = e_shell_view_get_shell_content (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content); searchbar = e_memo_shell_content_get_searchbar (memo_shell_content); action = GTK_RADIO_ACTION (ACTION (MEMO_SEARCH_ANY_FIELD_CONTAINS)); value = gtk_radio_action_get_current_value (action); if (value == MEMO_SEARCH_ADVANCED) { query = e_shell_view_get_search_query (shell_view); if (!query) query = g_strdup (""); } else { const gchar *format; const gchar *text; GString *string; text = e_shell_searchbar_get_search_text (searchbar); if (text == NULL || *text == '\0') { text = ""; value = MEMO_SEARCH_SUMMARY_CONTAINS; } switch (value) { default: text = ""; /* fall through */ case MEMO_SEARCH_SUMMARY_CONTAINS: format = "(contains? \"summary\" %s)"; break; case MEMO_SEARCH_DESCRIPTION_CONTAINS: format = "(contains? \"description\" %s)"; break; case MEMO_SEARCH_ANY_FIELD_CONTAINS: format = "(contains? \"any\" %s)"; break; } /* Build the query. */ string = g_string_new (""); e_sexp_encode_string (string, text); query = g_strdup_printf (format, string->str); g_string_free (string, TRUE); } /* Apply selected filter. */ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); value = e_action_combo_box_get_current_value (combo_box); switch (value) { case MEMO_FILTER_ANY_CATEGORY: break; case MEMO_FILTER_UNMATCHED: temp = g_strdup_printf ( "(and (has-categories? #f) %s", query); g_free (query); query = temp; break; default: { GList *categories; const gchar *category_name; categories = e_util_dup_searchable_categories (); category_name = g_list_nth_data (categories, value); g_list_free_full (categories, g_free); temp = g_strdup_printf ( "(and (has-categories? \"%s\") %s)", category_name, query); g_free (query); query = temp; } } /* Submit the query. */ memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); model = e_memo_table_get_model (memo_table); e_cal_model_set_search_query (model, query); g_free (query); preview_pane = e_memo_shell_content_get_preview_pane (memo_shell_content); web_view = e_preview_pane_get_web_view (preview_pane); memo_preview = E_CAL_COMPONENT_PREVIEW (web_view); e_cal_component_preview_clear (memo_preview); }
static void create_selection_tab (GtkWidget *notebook, gint32 image_ID) { GtkSizeGroup *group; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *hbox; GtkWidget *table; GtkWidget *label; GtkWidget *frame; GtkWidget *toggle; GtkWidget *spinbutton; GtkAdjustment *adj; GtkWidget *button; GtkWidget *font_button; gint32 *image_id_list; gint nimages, j; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hbox, gtk_label_new_with_mnemonic (_("Selection"))); gtk_widget_show (hbox); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0); gtk_widget_show (vbox2); group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); /* Film height/color */ frame = gimp_frame_new (_("Filmstrip")); gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); /* Keep maximum image height */ toggle = gtk_check_button_new_with_mnemonic (_("_Fit height to images")); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &filmvals.keep_height); table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); /* Film height */ adj = GTK_ADJUSTMENT (gtk_adjustment_new (filmvals.film_height, 10, GIMP_MAX_IMAGE_SIZE, 1, 10, 0)); spinbutton = gtk_spin_button_new (adj, 1, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Height:"), 0.0, 0.5, spinbutton, 1, TRUE); gtk_size_group_add_widget (group, label); g_object_unref (group); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_int_adjustment_update), &filmvals.film_height); g_object_bind_property (toggle, "active", spinbutton, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); g_object_bind_property (toggle, "active", /* FIXME: eeeeeek */ g_list_nth_data (gtk_container_get_children (GTK_CONTAINER (table)), 1), "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), filmvals.keep_height); /* Film color */ button = gimp_color_button_new (_("Select Film Color"), COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT, &filmvals.film_color, GIMP_COLOR_AREA_FLAT); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("Co_lor:"), 0.0, 0.5, button, 1, FALSE); gtk_size_group_add_widget (group, label); g_signal_connect (button, "color-changed", G_CALLBACK (gimp_color_button_get_color), &filmvals.film_color); /* Film numbering: Startindex/Font/color */ frame = gimp_frame_new (_("Numbering")); gtk_box_pack_start (GTK_BOX (vbox2), frame, TRUE, TRUE, 0); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); table = gtk_table_new (3, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); /* Startindex */ adj = GTK_ADJUSTMENT (gtk_adjustment_new (filmvals.number_start, 0, GIMP_MAX_IMAGE_SIZE, 1, 10, 0)); spinbutton = gtk_spin_button_new (adj, 1, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Start _index:"), 0.0, 0.5, spinbutton, 1, TRUE); gtk_size_group_add_widget (group, label); g_signal_connect (adj, "value-changed", G_CALLBACK (gimp_int_adjustment_update), &filmvals.number_start); /* Fontfamily for numbering */ font_button = gimp_font_select_button_new (NULL, filmvals.number_font); g_signal_connect (font_button, "font-set", G_CALLBACK (film_font_select_callback), &filmvals); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("_Font:"), 0.0, 0.5, font_button, 1, FALSE); gtk_size_group_add_widget (group, label); /* Numbering color */ button = gimp_color_button_new (_("Select Number Color"), COLOR_BUTTON_WIDTH, COLOR_BUTTON_HEIGHT, &filmvals.number_color, GIMP_COLOR_AREA_FLAT); label = gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, _("Co_lor:"), 0.0, 0.5, button, 1, FALSE); gtk_size_group_add_widget (group, label); g_signal_connect (button, "color-changed", G_CALLBACK (gimp_color_button_get_color), &filmvals.number_color); for (j = 0; j < 2; j++) { toggle = gtk_check_button_new_with_mnemonic (j ? _("At _bottom") : _("At _top")); gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), filmvals.number_pos[j]); gtk_widget_show (toggle); g_signal_connect (toggle, "toggled", G_CALLBACK (gimp_toggle_button_update), &filmvals.number_pos[j]); } /*** The right frame keeps the image selection ***/ frame = gimp_frame_new (_("Image Selection")); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE); gtk_container_add (GTK_CONTAINER (frame), hbox); /* Get a list of all image names */ image_id_list = gimp_image_list (&nimages); filmint.image_list_all = add_image_list (TRUE, nimages, image_id_list, hbox); /* Get a list of the images used for the film */ filmint.image_list_film = add_image_list (FALSE, 1, &image_ID, hbox); gtk_widget_show (hbox); }