static void notify_cb (const char *name, XSettingsAction action, XSettingsSetting *setting, void *data) { int row; char *text[4]; switch (action) { case XSETTINGS_ACTION_NEW: text[NAME] = (char *)name; text[TYPE] = text[VALUE] = text[SERIAL] = ""; row = gtk_clist_insert (GTK_CLIST (settings_clist), 0, text); gtk_clist_set_row_data_full (GTK_CLIST (settings_clist), row, g_strdup (name), (GDestroyNotify)g_free); update_row (row, setting); break; case XSETTINGS_ACTION_CHANGED: row = find_row (name); update_row (row, setting); break; case XSETTINGS_ACTION_DELETED: row = find_row (name); gtk_clist_remove (GTK_CLIST (settings_clist), row); break; } }
static void OkSelectContactDialog(GtkWidget * widget, SelectContactData * data) { GList *sel; PhonebookEntry *pbEntry; gchar *key; if ((sel = GTK_CLIST(data->clist)->selection) != NULL) { D_SpeedDial *d = (D_SpeedDial *) g_malloc(sizeof(D_SpeedDial)); gtk_clist_freeze(GTK_CLIST(clist)); pbEntry = gtk_clist_get_row_data(GTK_CLIST(data->clist), GPOINTER_TO_INT(sel->data)); gtk_clist_get_text(GTK_CLIST(clist), selectedKey, 0, &key); gtk_clist_set_text(GTK_CLIST(clist), selectedKey, 1, pbEntry->entry.name); gtk_clist_set_text(GTK_CLIST(clist), selectedKey, 2, pbEntry->entry.number); d->entry.number = *key - '0'; d->entry.memory_type = pbEntry->entry.memory_type + 2; d->entry.location = pbEntry->entry.location; gtk_clist_set_row_data_full(GTK_CLIST(clist), selectedKey, (gpointer) d, DestroyCListData); gtk_clist_sort(GTK_CLIST(clist)); gtk_clist_thaw(GTK_CLIST(clist)); } gtk_widget_destroy(GTK_WIDGET(data->clist)); gtk_widget_destroy(GTK_WIDGET(data->clistScrolledWindow)); gtk_widget_destroy(GTK_WIDGET(data->dialog)); }
void upload_stats_gui_add(struct ul_stats *us) { GtkCList *clist = clist_ul_stats(); const gchar *rowdata[c_us_num]; enum c_us i; int row; char size_tmp[16]; char attempts_tmp[16]; char complete_tmp[16]; char norm_tmp[16]; char rtime_tmp[64]; char dtime_tmp[64]; g_strlcpy(size_tmp, short_size(us->size, show_metric_units()), sizeof size_tmp); gm_snprintf(attempts_tmp, sizeof attempts_tmp, "%u", us->attempts); gm_snprintf(complete_tmp, sizeof complete_tmp, "%u", us->complete); gm_snprintf(norm_tmp, sizeof norm_tmp, "%.3f", us->norm); if (us->rtime) { timestamp_to_string_buf(us->rtime, rtime_tmp, sizeof rtime_tmp); } else { rtime_tmp[0] = '\0'; } if (us->dtime) { timestamp_to_string_buf(us->dtime, dtime_tmp, sizeof dtime_tmp); } else { dtime_tmp[0] = '\0'; } for (i = 0; i < c_us_num; i++) switch (i) { case c_us_filename: rowdata[i] = lazy_utf8_to_ui_string(us->filename); break; case c_us_size: rowdata[i] = size_tmp; break; case c_us_attempts: rowdata[i] = attempts_tmp; break; case c_us_complete: rowdata[i] = complete_tmp; break; case c_us_norm: rowdata[i] = norm_tmp; break; case c_us_rtime: rowdata[i] = rtime_tmp; break; case c_us_dtime: rowdata[i] = dtime_tmp; break; case c_us_num: g_assert_not_reached(); } row = gtk_clist_append(clist, deconstify_gpointer(rowdata)); g_return_if_fail(row >= 0); ul_stats_set_row(us, row); gtk_clist_set_row_data_full(clist, row, us, on_clist_ul_stats_row_removed); /* FIXME: should use auto_sort? */ if (0 == clist->freeze_count) { gtk_clist_sort(clist); clist_sync_rows(clist, on_clist_ul_stats_row_moved); } }
gint gw_categories_edit_box_add_category ( GtkWindow *w, GWDBCategory *p) { GWCatalogPlugin *plugin = NULL; GWDBContext *context = gw_am_get_current_catalog_context ( ); GWDBCategory *category = NULL; GtkCList *list = NULL; gchar *info[2]; guint row; gint result = -1; gchar *category_name = NULL; #ifdef GW_DEBUG_GUI_COMPONENT g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__); #endif if ( w != NULL ) { list = gtk_object_get_data ( GTK_OBJECT ( w), GW_REF_CATEGORIES_EDIT_BOX_CATEGORIES_LIST); /* Does one have to leave the program if list is NULL? */ if ( p == NULL ) { category = gw_db_category_new ( ); category_name = gw_categories_edit_box_get_category_name ( w); if ( category_name != NULL ) { if ( strlen ( category_name) > 0 ) { if ( context != NULL) { plugin = (GWCatalogPlugin*)gw_db_context_get_plugin ( context); gw_db_category_set_name ( category, category_name); gw_db_category_set_description ( category, gw_categories_edit_box_get_category_description ( w)); plugin->gw_db_catalog_add_db_category ( context, category); } } else { g_free ( category_name); } } } else { category = p; } g_strdup_to_gtk_text ( gw_db_category_get_name ( category), info[0]); g_strdup_to_gtk_text ( gw_db_category_get_description ( category), info[1]); row = gtk_clist_append ( list, info); //FIXME memory leak // gtk_clist_set_row_data ( list, row, category); gtk_clist_set_row_data_full ( list, row, category, (GtkDestroyNotify)gw_db_category_free); g_free ( info[0]); g_free ( info[1]); result = 0; } return result; }
static int AddMoveRecordRow( void ) { gamelistrow *pglr; static char *aszData[] = {NULL, NULL, NULL}; char szIndex[5]; int row; sprintf(szIndex, "%d", GTK_CLIST(pwGameList)->rows); aszData[0] = szIndex; row = gtk_clist_append(GTK_CLIST(pwGameList), aszData); gtk_clist_set_row_style(GTK_CLIST(pwGameList), row, psGameList); pglr = malloc(sizeof(*pglr)); pglr->fCombined = FALSE; pglr->apmr[0] = pglr->apmr[1] = NULL; gtk_clist_set_row_data_full(GTK_CLIST(pwGameList), row, pglr, free); return row; }
static void OkImportDialog(GtkWidget * w, GtkFileSelection * fs) { FILE *f; D_SpeedDial *d; PhonebookEntry *pbEntry; gchar buf[IO_BUF_LEN]; gchar *row[3]; gchar *fileName; gint location; register gint i, row_i = 0; fileName = (gchar *) gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)); gtk_widget_hide(GTK_WIDGET(fs)); if ((f = fopen(fileName, "r")) == NULL) { g_snprintf(buf, IO_BUF_LEN, _("Can't open file %s for reading!\n"), fileName); gtk_label_set_text(GTK_LABEL(errorDialog.text), buf); gtk_widget_show(errorDialog.dialog); return; } if (!GUI_ContactsIsIntialized()) GUI_ReadContacts(); gtk_clist_freeze(GTK_CLIST(clist)); gtk_clist_clear(GTK_CLIST(clist)); speedDialInitialized = FALSE; i = 0; while (fgets(buf, IO_BUF_LEN, f) && i++ < 9) { if ((d = (D_SpeedDial *) g_malloc(sizeof(D_SpeedDial))) == NULL) { g_print(_("Error: %s: line %d: Can't allocate memory!\n"), __FILE__, __LINE__); gtk_clist_clear(GTK_CLIST(clist)); gtk_clist_sort(GTK_CLIST(clist)); gtk_clist_thaw(GTK_CLIST(clist)); return; } if (ParseLine(d, buf)) { if (d->entry.number != i) { g_free(d); gtk_clist_clear(GTK_CLIST(clist)); gtk_label_set_text(GTK_LABEL(errorDialog.text), _("Error reading file!")); gtk_widget_show(errorDialog.dialog); gtk_clist_sort(GTK_CLIST(clist)); gtk_clist_thaw(GTK_CLIST(clist)); return; } if (d->entry.location == 0) location = i; else location = d->entry.location; if ((pbEntry = GUI_GetEntry(d->entry.memory_type - 2, location)) == NULL) { g_free(d); continue; } *buf = i + '0'; *(buf + 1) = '\0'; row[0] = buf; row[1] = pbEntry->entry.name; row[2] = pbEntry->entry.number; gtk_clist_append(GTK_CLIST(clist), row); gtk_clist_set_row_data_full(GTK_CLIST(clist), row_i++, (gpointer) d, DestroyCListData); } else { g_free(d); gtk_clist_clear(GTK_CLIST(clist)); gtk_label_set_text(GTK_LABEL(errorDialog.text), _("Error reading file!")); gtk_widget_show(errorDialog.dialog); gtk_clist_sort(GTK_CLIST(clist)); gtk_clist_thaw(GTK_CLIST(clist)); return; } } gtk_clist_sort(GTK_CLIST(clist)); gtk_clist_thaw(GTK_CLIST(clist)); speedDialInitialized = TRUE; }
static void ReadSpeedDial(void) { PhonebookEntry *pbEntry; D_SpeedDial *d; PhoneEvent *e; gchar *row[3]; gchar buf[2] = " "; gint location; register gint i, row_i = 0; if (!GUI_ContactsIsIntialized()) GUI_ReadContacts(); gtk_label_set_text(GTK_LABEL(infoDialog.text), _("Reading data ...")); gtk_widget_show_now(infoDialog.dialog); GUI_Refresh(); gtk_clist_freeze(GTK_CLIST(clist)); gtk_clist_clear(GTK_CLIST(clist)); for (i = 2; i < 10; i++) { if ((d = (D_SpeedDial *) g_malloc(sizeof(D_SpeedDial))) == NULL) { g_print(_("Error: %s: line %d: Can't allocate memory!\n"), __FILE__, __LINE__); return; } memset(d, 0, sizeof(D_SpeedDial)); d->entry.number = i; if ((e = (PhoneEvent *) g_malloc(sizeof(PhoneEvent))) == NULL) { g_print(_("Error: %s: line %d: Can't allocate memory!\n"), __FILE__, __LINE__); g_free(d); return; } e->event = Event_GetSpeedDial; e->data = d; GUI_InsertEvent(e); pthread_mutex_lock(&speedDialMutex); pthread_cond_wait(&speedDialCond, &speedDialMutex); pthread_mutex_unlock(&speedDialMutex); if (d->status != GN_ERR_NONE) { g_print(_("Cannot read speed dial key %d!\n"), i); *buf = i + '0'; row[0] = buf; row[1] = '\0'; row[2] = '\0'; } else { if (d->entry.location == 0) location = i; else location = d->entry.location; if ((pbEntry = GUI_GetEntry(d->entry.memory_type, location)) == NULL) { g_free(d); continue; } *buf = i + '0'; row[0] = buf; row[1] = pbEntry->entry.name; row[2] = pbEntry->entry.number; } gtk_clist_append(GTK_CLIST(clist), row); gtk_clist_set_row_data_full(GTK_CLIST(clist), row_i++, (gpointer) d, DestroyCListData); /* GUI_Refresh (); */ } gtk_widget_hide(infoDialog.dialog); gtk_clist_sort(GTK_CLIST(clist)); gtk_clist_thaw(GTK_CLIST(clist)); speedDialInitialized = TRUE; }