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 prefs_summary_column_remove(void) { GtkCList *stock_clist = GTK_CLIST(summary_col.stock_clist); GtkCList *shown_clist = GTK_CLIST(summary_col.shown_clist); gint row; SummaryColumnType type; gchar *name; if (!shown_clist->selection) return; row = GPOINTER_TO_INT(shown_clist->selection->data); type = GPOINTER_TO_INT(gtk_clist_get_row_data(shown_clist, row)); gtk_clist_remove(shown_clist, row); if (shown_clist->rows == row) gtk_clist_select_row(shown_clist, row - 1, -1); if (!stock_clist->selection) row = 0; else row = GPOINTER_TO_INT(stock_clist->selection->data) + 1; name = gettext(col_name[type]); row = gtk_clist_insert(stock_clist, row, (gchar **)&name); gtk_clist_set_row_data(stock_clist, row, GINT_TO_POINTER(type)); gtk_clist_select_row(stock_clist, row, -1); }
static void imp_ldif_update_row( GtkCList *clist ) { Ldif_FieldRec *rec; gchar *text[ FIELDS_N_COLS ]; gint row; if( impldif_dlg.rowIndSelect < 0 ) return; row = impldif_dlg.rowIndSelect; rec = gtk_clist_get_row_data( clist, row ); text[ FIELD_COL_SELECT ] = ""; text[ FIELD_COL_FIELD ] = rec->tagName; text[ FIELD_COL_ATTRIB ] = rec->userName; gtk_clist_freeze( clist ); gtk_clist_remove( clist, row ); if( row == impldif_dlg.rowCount - 1 ) { gtk_clist_append( clist, text ); } else { gtk_clist_insert( clist, row, text ); } if( rec->selected ) gtk_clist_set_pixmap( clist, row, FIELD_COL_SELECT, markxpm, markxpmmask ); gtk_clist_set_row_data( clist, row, rec ); gtk_clist_thaw( clist ); }
static void prefs_display_items_add(GtkWidget *widget, gpointer data) { PrefsDisplayItemsDialog *dialog = data; GtkCList *stock_clist = GTK_CLIST(dialog->stock_clist); GtkCList *shown_clist = GTK_CLIST(dialog->shown_clist); PrefsDisplayItem *item; gint row; gchar *name; if (!stock_clist->selection) return; row = GPOINTER_TO_INT(stock_clist->selection->data); item = (PrefsDisplayItem *)gtk_clist_get_row_data(stock_clist, row); if (!item->allow_multiple) { gtk_clist_remove(stock_clist, row); if (stock_clist->rows == row) gtk_clist_select_row(stock_clist, row - 1, -1); } if (!shown_clist->selection) row = 0; else row = GPOINTER_TO_INT(shown_clist->selection->data); item->in_use = TRUE; name = gettext(item->label); row = gtk_clist_insert(shown_clist, row, (gchar **)&name); gtk_clist_set_row_data(shown_clist, row, item); prefs_display_items_set_sensitive(dialog); }
static int pattern_clist_insert_row (struct player_pattern *pp, int row) { char *text[6]; text[0] = text[1] = text[2] = text[3] = text[4] = text[5] = NULL; if (row < 0) row = gtk_clist_append (GTK_CLIST (pattern_clist), text); else gtk_clist_insert (GTK_CLIST (pattern_clist), row, text); pattern_clist_update_row (pp, row); return row; }
/** * helper func for stats_display - * does two things: * * - clears out aged / infrequent search terms * - sticks the rest of the search terms in clist_search_stats * */ static gboolean stats_hash_to_clist(gpointer key, gpointer value, gpointer unused_udata) { gchar *text[3]; gchar period_tmp[32]; gchar total_tmp[32]; struct term_counts *val = value; (void) unused_udata; /* update counts */ if (!val->period_cnt) val->periods++; else val->periods = 0; val->total_cnt += val->period_cnt; /* try to keep the number of infrequent terms down */ if ( (1.0 * val->total_cnt / (val->periods + 2.0)) * 100 < GUI_PROPERTY(search_stats_delcoef) ) { G_FREE_NULL(key); G_FREE_NULL(val); return TRUE; } stat_count++; /* update the display */ /* FIXME: make %8.8d %d and set up custom sort function */ gm_snprintf(period_tmp, sizeof period_tmp, "%8.8d", (int) val->period_cnt); gm_snprintf(total_tmp, sizeof total_tmp, "%8.8d", (int) val->total_cnt); text[0] = key; text[1] = period_tmp; text[2] = total_tmp; { GtkWidget *clist_search_stats = gui_main_window_lookup("clist_search_stats"); gtk_clist_insert(GTK_CLIST(clist_search_stats), 0, text); } /* new period begins */ val->period_cnt = 0; return FALSE; }
void gnome_o_put_the_damn_rules_in_the_box (GtkWidget * w) { int numrules, x; rule *r; GtkCList *clist; clist = GTK_CLIST (lookup_widget (w, "clist1")); gtk_clist_clear (clist); r = (rule *) db_fetch_rules (&numrules); for (x = 0; x < numrules; x++) { gtk_clist_insert (clist, x, &(r[x].name)); gtk_clist_set_row_data (clist, x, &r[x]); } return; }
void on_rule_new_rule_clicked (GtkButton * button, gpointer UNUSED(user_data)) { rule *r; int x; GtkCList *clist; r = (rule *) malloc (sizeof (rule)); r->regex = g_strdup (""); r->mbox = g_strdup ("Inbox"); r->name = g_strdup ("New rule"); r->piece = g_strdup ("Header"); clist = GTK_CLIST (lookup_widget (GTK_WIDGET (button), "clist1")); x = clist->rows; gtk_clist_insert (clist, x, &(r->name)); gtk_clist_set_row_data (clist, x, r); gtk_clist_select_row (clist, x, 0); }
gint gtk_clist_append(GtkCList *clist, gchar *text[]) { return gtk_clist_insert(clist, -1, text); }
/* *If the node passed as a parameter exists then *update it. If not add it to the list */ void update_nodes_list(struct node *node) { int i = 0; char *ip; int found = 0; char *dest; char *tmp[9] = { (char *)"", (char *)"", (char *)"", (char *)"", (char *)"", (char *)"", (char *)"", (char *)"", (char *)"" }; char timer[20]; struct tm *time_st; char itoa_buf[10]; if (memcmp(&node->addr, &main_addr, ipsize) == 0) dest = (char *)"local"; else dest = ip_to_string(&node->addr); gtk_clist_freeze(GTK_CLIST(node_list)); while ((i < node_list_size) && !found) { gtk_clist_get_text(GTK_CLIST(node_list), i, 0, (gchar **) & ip); if (strcmp(dest, ip) == 0) found = 1; i++; } /* Update node */ if (found) { i--; /* Go backt to the right row */ //printf("Updating %s\n\n", ip_to_string(&node->addr)); /* don't update main addr */ /* Gateway */ if (memcmp(&node->addr, &main_addr, ipsize) != 0) { if (memcmp(&node->gw_addr, &null_addr, ipsize) != 0) gtk_clist_set_text(GTK_CLIST(node_list), i, 1, ip_to_string(&node->gw_addr)); /* Weigth */ if (node->hopcount != 0) { gui_itoa(node->hopcount, itoa_buf); gtk_clist_set_text(GTK_CLIST(node_list), i, 2, itoa_buf); } /* Device */ gtk_clist_set_text(GTK_CLIST(node_list), i, 3, &node->dev[0]); } /* Timer */ if (node->timer.tv_usec) { memset(&timer[0], 0, 20); time_st = localtime((time_t *) & node->timer.tv_sec); sprintf(&timer[0], "%02d:%02d:%02d", time_st->tm_hour, time_st->tm_min, time_st->tm_sec); gtk_clist_set_text(GTK_CLIST(node_list), i, 4, &timer[0]); } /* MID */ if (node->mid.next != &node->mid) gtk_clist_set_text(GTK_CLIST(node_list), i, 5, "yes"); else gtk_clist_set_text(GTK_CLIST(node_list), i, 5, "no"); /* HNA */ if (node->hna.next != &node->hna) gtk_clist_set_text(GTK_CLIST(node_list), i, 6, "yes"); else gtk_clist_set_text(GTK_CLIST(node_list), i, 6, "no"); } /* Add new node */ else { i = node_list_size; /* Create entry */ gtk_clist_insert(GTK_CLIST(node_list), i, tmp); /* Main address */ gtk_clist_set_text(GTK_CLIST(node_list), i, 0, dest); if (memcmp(&node->addr, &main_addr, ipsize) == 0) { if (memcmp(&node->gw_addr, &null_addr, ipsize) != 0) gtk_clist_set_text(GTK_CLIST(node_list), i, 1, ip_to_string(&node->gw_addr)); /* Weigth */ if (node->hopcount != 0) { gui_itoa(node->hopcount, itoa_buf); gtk_clist_set_text(GTK_CLIST(node_list), i, 2, itoa_buf); } /* Device */ gtk_clist_set_text(GTK_CLIST(node_list), i, 3, &node->dev[0]); } /* MID */ if (node->mid.next != &node->mid) gtk_clist_set_text(GTK_CLIST(node_list), i, 5, "yes"); else gtk_clist_set_text(GTK_CLIST(node_list), i, 5, "no"); /* HNA */ if (node->hna.next != &node->hna) gtk_clist_set_text(GTK_CLIST(node_list), i, 6, "yes"); else gtk_clist_set_text(GTK_CLIST(node_list), i, 6, "no"); node_list_size++; } gtk_clist_thaw(GTK_CLIST(node_list)); }
void ghack_settings_dialog() { int i; static GtkWidget* dialog; static GtkWidget* swin; static GtkWidget* frame1; dialog = gnome_dialog_new (_("GnomeHack Settings"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE); gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event", GTK_SIGNAL_FUNC (opt_sel_key_hit), tilesets ); frame1 = gtk_frame_new (_("Choose one of the following tilesets:")); gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1); gtk_widget_show (frame1); gtk_container_border_width (GTK_CONTAINER (frame1), 3); swin = gtk_scrolled_window_new (NULL, NULL); clist = gtk_clist_new (2); gtk_clist_column_titles_hide (GTK_CLIST (clist)); gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180); gtk_container_add (GTK_CONTAINER (swin), clist); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_signal_connect (GTK_OBJECT (clist), "select_row", GTK_SIGNAL_FUNC (opt_sel_row_selected), NULL ); gtk_container_add (GTK_CONTAINER (frame1), swin); gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1); /* Add the tilesets into the list here... */ for (i=0; i < no_tilesets; i++) { gchar accelBuf[BUFSZ]; const char *text[3]={accelBuf, tilesets[i].name,NULL}; if ((tilesets[i].flags & ~TILESET_TRANSPARENT) != 0) continue; /* Unsupported flag set */ sprintf( accelBuf, "%c ", tolower(tilesets[i].name[0])); gtk_clist_insert (GTK_CLIST (clist), i, (char**)text); } gtk_clist_columns_autosize (GTK_CLIST (clist)); gtk_widget_show_all (swin); /* Center the dialog over over parent */ gnome_dialog_set_default( GNOME_DIALOG(dialog), 0); gtk_window_set_modal( GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (ghack_get_main_window ()) ); /* Run the dialog -- returning whichever button was pressed */ i = gnome_dialog_run (GNOME_DIALOG (dialog)); gnome_dialog_close (GNOME_DIALOG (dialog)); /* They hit Quit or error */ if (i != 0 ) { return; } if (gn_tileset < no_tilesets) { if (tilesets[gn_tileset].file[0] != '/') { char *path; path = (char *)alloc(strlen(TILESETDIR) + strlen(tilesets[gn_tileset].file) + 2); sprintf(path, TILESETDIR "/%s", tilesets[gn_tileset].file); ghack_free_glyphs(); if (ghack_init_glyphs(path)) g_error ("ERROR: Could not initialize glyphs.\n"); free(path); } else { ghack_free_glyphs(); if (ghack_init_glyphs(tilesets[gn_tileset].file)) g_error ("ERROR: Could not initialize glyphs.\n"); } ghack_reinit_map_window(); } else { /* This shouldn't happen */ g_warning("This shouldn't happen\n"); } }
int ghack_player_sel_dialog(const char** choices, const gchar* title, const gchar* prompt) { int i; static GtkWidget* dialog; static GtkWidget* swin; static GtkWidget* frame1; dialog = gnome_dialog_new(title, GNOME_STOCK_BUTTON_OK, _("Random"), GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_close_hides (GNOME_DIALOG (dialog), FALSE); gtk_signal_connect (GTK_OBJECT (dialog), "key_press_event", GTK_SIGNAL_FUNC (player_sel_key_hit), choices ); frame1 = gtk_frame_new(prompt); gtk_object_set_data (GTK_OBJECT (dialog), "frame1", frame1); gtk_widget_show (frame1); gtk_container_border_width (GTK_CONTAINER (frame1), 3); swin = gtk_scrolled_window_new (NULL, NULL); clist = gtk_clist_new (2); gtk_clist_column_titles_hide (GTK_CLIST (clist)); gtk_widget_set_usize (GTK_WIDGET (clist), 100, 180); gtk_container_add (GTK_CONTAINER (swin), clist); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_signal_connect (GTK_OBJECT (clist), "select_row", GTK_SIGNAL_FUNC (player_sel_row_selected), NULL ); gtk_container_add (GTK_CONTAINER (frame1), swin); gtk_box_pack_start_defaults (GTK_BOX (GNOME_DIALOG (dialog)->vbox), frame1); /* Add the roles into the list here... */ for (i=0; choices[i]; i++) { gchar accelBuf[BUFSZ]; const char *text[3]={accelBuf, choices[i],NULL}; sprintf( accelBuf, "%c ", tolower(choices[i][0])); gtk_clist_insert (GTK_CLIST (clist), i, (char**)text); } gtk_clist_columns_autosize (GTK_CLIST (clist)); gtk_widget_show_all (swin); /* Center the dialog over over parent */ gnome_dialog_set_default( GNOME_DIALOG(dialog), 0); gtk_window_set_modal( GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (ghack_get_main_window ()) ); /* Run the dialog -- returning whichever button was pressed */ i = gnome_dialog_run_and_close(GNOME_DIALOG(dialog)); /* Quit on button 2 or error */ if (i < 0 || i > 1) { return(ROLE_NONE); } /* Random is button 1*/ if (i == 1 ) { return(ROLE_RANDOM); } return ( role_number); }
int ghack_menu_ext_cmd(void) { int n; GtkWidget* dialog; GtkWidget* swin; GtkWidget* frame1; GtkWidget* clist; extMenu info; dialog = gnome_dialog_new("Extended Commands", GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); gnome_dialog_close_hides(GNOME_DIALOG(dialog), FALSE); gtk_signal_connect(GTK_OBJECT(dialog), "key_press_event", GTK_SIGNAL_FUNC(ghack_ext_key_hit), &info); frame1 = gtk_frame_new("Make your selection"); gtk_object_set_data(GTK_OBJECT(dialog), "frame1", frame1); gtk_widget_show(frame1); gtk_container_border_width(GTK_CONTAINER(frame1), 3); swin = gtk_scrolled_window_new(NULL, NULL); clist = gtk_clist_new(2); gtk_object_set_data(GTK_OBJECT(dialog), "clist", clist); gtk_widget_set_usize(clist, 500, 400); gtk_container_add(GTK_CONTAINER(swin), clist); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(ghack_menu_row_selected), NULL); gtk_container_add(GTK_CONTAINER(frame1), swin); gtk_box_pack_start_defaults(GTK_BOX(GNOME_DIALOG(dialog)->vbox), frame1); /* Add the extended commands into the list here... */ for (n = 0; extcmdlist[n].ef_txt; ++n) { const char *text[3]={extcmdlist[n].ef_txt,extcmdlist[n].ef_desc,NULL}; gtk_clist_insert(GTK_CLIST(clist), n, (char**) text); } /* fill in starting info fields */ info.curItem = -1; info.numRows = n; info.charIdx = 0; info.lastTime = 0; gtk_clist_columns_autosize(GTK_CLIST(clist)); gtk_widget_show_all(swin); /* Center the dialog over over parent */ gnome_dialog_set_default(GNOME_DIALOG(dialog), 0); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(ghack_get_main_window())); /* Run the dialog -- returning whichever button was pressed */ n = gnome_dialog_run_and_close(GNOME_DIALOG(dialog)); /* Quit on button 2 or error */ return (n != 0) ? -1 : info.curItem; }
void update_TLB() { int i; char **txt; txt=malloc( 19*sizeof(char*) ); for(i=0; i<19; i++) txt[i]=malloc( 64*sizeof(char) ); gtk_clist_freeze( GTK_CLIST(clTLBentries) ); for( i=0; i<32; i++) { if( (gui_fantom_tlb_entry[i].mask != tlb_e[i].mask) || (gui_fantom_tlb_entry[i].vpn2 != tlb_e[i].vpn2) || (gui_fantom_tlb_entry[i].g != tlb_e[i].g) || (gui_fantom_tlb_entry[i].asid != tlb_e[i].asid) || (gui_fantom_tlb_entry[i].pfn_even != tlb_e[i].pfn_even) || (gui_fantom_tlb_entry[i].c_even != tlb_e[i].c_even) || (gui_fantom_tlb_entry[i].d_even != tlb_e[i].d_even) || (gui_fantom_tlb_entry[i].v_even != tlb_e[i].v_even) || (gui_fantom_tlb_entry[i].pfn_odd != tlb_e[i].pfn_odd) || (gui_fantom_tlb_entry[i].c_odd != tlb_e[i].c_odd) || (gui_fantom_tlb_entry[i].d_odd != tlb_e[i].d_odd) || (gui_fantom_tlb_entry[i].v_odd != tlb_e[i].v_odd) || (gui_fantom_tlb_entry[i].r != tlb_e[i].r) || (gui_fantom_tlb_entry[i].start_even != tlb_e[i].start_even) || (gui_fantom_tlb_entry[i].end_even != tlb_e[i].end_even) || (gui_fantom_tlb_entry[i].phys_even != tlb_e[i].phys_even) || (gui_fantom_tlb_entry[i].start_odd != tlb_e[i].start_odd) || (gui_fantom_tlb_entry[i].end_odd != tlb_e[i].end_odd) || (gui_fantom_tlb_entry[i].phys_odd != tlb_e[i].phys_odd) ) { gtk_clist_remove( GTK_CLIST(clTLBentries), i); gui_fantom_tlb_entry[i].mask = tlb_e[i].mask; sprintf( txt[0], "%hX", tlb_e[i].mask); gui_fantom_tlb_entry[i].vpn2 = tlb_e[i].vpn2; sprintf( txt[1], "%lX", tlb_e[i].vpn2); gui_fantom_tlb_entry[i].g = tlb_e[i].g; sprintf( txt[2], "%hhX", tlb_e[i].g); gui_fantom_tlb_entry[i].asid = tlb_e[i].asid; sprintf( txt[3], "%hhX", tlb_e[i].asid); gui_fantom_tlb_entry[i].pfn_even= tlb_e[i].pfn_even; sprintf( txt[4], "%lX", tlb_e[i].pfn_even); gui_fantom_tlb_entry[i].c_even = tlb_e[i].c_even; sprintf( txt[5], "%hhX", tlb_e[i].c_even); gui_fantom_tlb_entry[i].d_even = tlb_e[i].d_even; sprintf( txt[6], "%hhX", tlb_e[i].d_even); gui_fantom_tlb_entry[i].v_even = tlb_e[i].v_even; sprintf( txt[7], "%hhX", tlb_e[i].v_even); gui_fantom_tlb_entry[i].pfn_odd = tlb_e[i].pfn_odd; sprintf( txt[8], "%lX", tlb_e[i].pfn_odd); gui_fantom_tlb_entry[i].c_odd = tlb_e[i].c_odd; sprintf( txt[9], "%hhX", tlb_e[i].c_odd); gui_fantom_tlb_entry[i].d_odd = tlb_e[i].d_odd; sprintf( txt[10], "%hhX", tlb_e[i].d_odd); gui_fantom_tlb_entry[i].v_odd = tlb_e[i].v_odd; sprintf( txt[11], "%hhX", tlb_e[i].v_odd); gui_fantom_tlb_entry[i].r = tlb_e[i].r; sprintf( txt[12], "%hhX", tlb_e[i].r); //gui_fantom_tlb_entry[i].check_parity_mask = tlb_e[i].check_parity_mask; NOT USED? gui_fantom_tlb_entry[i].start_even = tlb_e[i].start_even; sprintf( txt[13], "%lX", tlb_e[i].start_even); gui_fantom_tlb_entry[i].end_even = tlb_e[i].end_even; sprintf( txt[14], "%lX", tlb_e[i].end_even); gui_fantom_tlb_entry[i].phys_even = tlb_e[i].phys_even; sprintf( txt[15], "%lX", tlb_e[i].phys_even); gui_fantom_tlb_entry[i].start_odd = tlb_e[i].start_odd; sprintf( txt[16], "%lX", tlb_e[i].start_odd); gui_fantom_tlb_entry[i].end_odd = tlb_e[i].end_odd; sprintf( txt[17], "%lX", tlb_e[i].end_odd); gui_fantom_tlb_entry[i].phys_odd = tlb_e[i].phys_odd; sprintf( txt[18], "%lX", tlb_e[i].phys_odd); gtk_clist_insert( GTK_CLIST(clTLBentries), i, txt); gtk_clist_set_background( GTK_CLIST(clTLBentries), i, &color_modif); } else gtk_clist_set_background( GTK_CLIST(clTLBentries), i, &color_ident); } gtk_clist_thaw( GTK_CLIST(clTLBentries) ); }