Changeset 427

Show
Ignore:
Timestamp:
08/28/06 18:27:35 (4 years ago)
Author:
radekk
Message:

Info-Panel development code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/branches/sweep-info-panel/src/Makefile.am

    r392 r427  
    4141        format.c format.h \ 
    4242        head.c head.h \ 
     43        info-panel.c info-panel.h \ 
    4344        interface.c interface.h \ 
    4445        levelmeter.c levelmeter.h \ 
  • sweep/branches/sweep-info-panel/src/callbacks.c

    r285 r427  
    4848#include "print.h" 
    4949#include "record.h" 
     50#include "info-panel.h" 
    5051 
    5152/* 
  • sweep/branches/sweep-info-panel/src/cursors.c

    r387 r427  
    161161                                hand_x_hot, hand_y_hot); 
    162162 
    163  
    164163} 
  • sweep/branches/sweep-info-panel/src/main.c

    r230 r427  
    144144  display_env = g_strconcat ("DISPLAY=", gdk_get_display (), NULL); 
    145145  putenv (display_env); 
     146        g_free(display_env); 
    146147#endif 
    147148 
  • sweep/branches/sweep-info-panel/src/print.c

    r124 r427  
    2828 
    2929#include <sweep/sweep_types.h> 
     30#include <sweep/sweep_i18n.h> 
    3031 
    3132/* 
     
    3738{ 
    3839  if (nr_bytes > (1L<<30)) { 
    39     return snprintf (s, n, "%0.3f GB", 
     40    return g_snprintf (s, n, "%0.3f GB", 
    4041                     (gfloat)nr_bytes / (1024.0 * 1024.0 * 1024.0)); 
    4142  } else if (nr_bytes > (1L<<20)) { 
    42     return snprintf (s, n, "%0.3f MB", 
     43    return g_snprintf (s, n, "%0.3f MB", 
    4344                     (gfloat)nr_bytes / (1024.0 * 1024.0)); 
    4445  } else if (nr_bytes > (1L<<10)) { 
    45     return snprintf (s, n, "%0.3f kB", 
     46    return g_snprintf (s, n, "%0.3f kB", 
    4647                     (gfloat)nr_bytes / (1024.0)); 
    4748  } else if (nr_bytes == 1) { 
    48     return snprintf (s, n, "1 byte"); 
     49    return g_snprintf (s, n, "1 byte"); 
    4950  } else { 
    50     return snprintf (s, n, "%ld bytes", nr_bytes); 
     51    return g_snprintf (s, n, "%ld bytes", nr_bytes); 
    5152  } 
    5253} 
     
    7273  /* XXX: %02.3f workaround */ 
    7374  if (sec < 10.0) { 
    74     return snprintf (s, n, "%s%02d:%02d:0%2.3f", sign, hrs, min, sec); 
     75    return g_snprintf (s, n, "%s%02d:%02d:0%2.3f", sign, hrs, min, sec); 
    7576  } else { 
    76     return snprintf (s, n, "%s%02d:%02d:%02.3f", sign, hrs, min, sec); 
     77    return g_snprintf (s, n, "%s%02d:%02d:%02.3f", sign, hrs, min, sec); 
    7778  } 
    7879} 
     
    9596 
    9697  if (hrs > 0.0) 
    97     return snprintf (s, n, "PT%.0fH%.0fM%.0fS%.0fN%dF", hrs, min, sec, N, F); 
     98    return g_snprintf (s, n, "PT%.0fH%.0fM%.0fS%.0fN%dF", hrs, min, sec, N, F); 
    9899  else if (min > 0.0) 
    99     return snprintf (s, n, "PT%.0fM%.0fS%.0fN%dF", min, sec, N, F); 
     100    return g_snprintf (s, n, "PT%.0fM%.0fS%.0fN%dF", min, sec, N, F); 
    100101  else if (sec > 0.0) 
    101     return snprintf (s, n, "PT%.0fS%.0fN%dF", sec, N, F); 
     102    return g_snprintf (s, n, "PT%.0fS%.0fN%dF", sec, N, F); 
    102103  else if (N > 0.0) 
    103     return snprintf (s, n, "PT%.0fN%dF", N, F); 
     104    return g_snprintf (s, n, "PT%.0fN%dF", N, F); 
    104105  else 
    105     return snprintf (s, n, "P0S"); 
     106    return g_snprintf (s, n, "P0S"); 
    106107} 
    107108 
     
    138139  return result; 
    139140} 
     141 
     142void 
     143snprint_channels (gchar * s, gint n, gint channels) 
     144{ 
     145        switch (channels){ 
     146                case 1: 
     147                                g_strlcpy(s, _("Mono"), n); 
     148                                return; 
     149                case 2: 
     150                                g_strlcpy(s, _("Stereo (2.0)"), n); 
     151                                return; 
     152                case 3: 
     153                                g_strlcpy(s, _("2.1"), n); 
     154                                return; 
     155                case 4: 
     156                                g_strlcpy(s, _("Quadro/3.1"), n); 
     157                                return; 
     158                case 6: 
     159                                g_strlcpy(s, _("5.1"), n); 
     160                                return; 
     161                case 7: 
     162                                g_strlcpy(s, _("6.1"), n); 
     163                                return; 
     164                default: 
     165                                //TODO: i18n 
     166                                g_snprintf (s, n, "%d channels", channels); 
     167        } 
     168} 
  • sweep/branches/sweep-info-panel/src/print.h

    r124 r427  
    4949strtime_to_seconds (char * str); 
    5050 
     51/* 
     52 * Prints a string corresponding to number of channels 
     53 */ 
     54void 
     55snprint_channels (gchar * s, gint n, gint channels); 
     56 
    5157#endif /* __PRINT_H__ */ 
  • sweep/branches/sweep-info-panel/src/sample.h

    r124 r427  
    8181sample_selection_replace_with_tmp_sel (sw_sample * s); 
    8282 
     83void 
     84sample_clear_selection (sw_sample * s); 
     85 
    8386#endif /* __SAMPLE_H__ */ 
  • sweep/branches/sweep-info-panel/src/sweep_app.h

    r124 r427  
    249249  GtkWidget * info_clist; 
    250250 
     251        GtkTreeModel * info_panel;      /* for info_panel tree model */ 
     252 
    251253  gint progress_percent; /* completion percentage of current op */ 
    252254 
  • sweep/branches/sweep-info-panel/src/sweep_sample.c

    r279 r427  
    5050#include "preferences.h" 
    5151#include "record.h" 
     52#include "info-panel.h" 
    5253#include "question_dialogs.h" 
    5354#include "sw_chooser.h" 
     
    186187 
    187188  s->info_clist = NULL; 
     189 
     190        s->info_panel = info_panel_create_model(); 
    188191 
    189192  /*  s->recording = FALSE;*/ 
     
    16761679  sw_sel * sel; 
    16771680 
     1681/* 
    16781682  n = snprintf (buf, BUF_LEN, _("Insert selection [")); 
    16791683  n += snprint_time (buf+n, BUF_LEN-n, 
     
    16831687                     frames_to_time (format, s->tmp_sel->sel_end)); 
    16841688  n += snprintf (buf+n, BUF_LEN-n, "]"); 
     1689*/ 
     1690        n = snprintf (buf, BUF_LEN, _("Insert selection")); 
    16851691 
    16861692  g_mutex_lock (s->sounddata->sels_mutex); 
     
    17741780  sw_sel * sel; 
    17751781 
     1782/*       
    17761783  n = snprintf (buf, BUF_LEN, _("Set selection [")); 
    17771784  n += snprint_time (buf+n, BUF_LEN-n, 
     
    17811788                     frames_to_time (format, s->tmp_sel->sel_end)); 
    17821789  n += snprintf (buf+n, BUF_LEN-n, "]"); 
     1790*/ 
     1791        n = snprintf (buf, BUF_LEN, _("Set selection")); 
    17831792 
    17841793  g_mutex_lock (s->sounddata->sels_mutex); 
     
    18021811  sw_sounddata * sounddata = sample->sounddata; 
    18031812  GtkWidget * clist = sample->info_clist; 
    1804  
     1813                 
    18051814#define RATE_BUF_LEN 16 
    18061815  char rate_buf[RATE_BUF_LEN]; 
     
    18151824  char time_buf[TIME_BUF_LEN]; 
    18161825 
    1817   if (clist == NULL) return; 
    1818  
    1819   snprintf (rate_buf, RATE_BUF_LEN, "%d Hz", sounddata->format->rate); 
    1820  
    1821   snprintf (chan_buf, CHAN_BUF_LEN, "%d", sounddata->format->channels); 
    1822  
    1823   snprint_bytes (byte_buf, BYTE_BUF_LEN, 
    1824                 frames_to_bytes (sounddata->format, sounddata->nr_frames)); 
     1826  if (clist) 
     1827        { 
     1828       snprintf (rate_buf, RATE_BUF_LEN, "%d Hz", sounddata->format->rate); 
     1829 
     1830         snprintf (chan_buf, CHAN_BUF_LEN, "%d", sounddata->format->channels); 
     1831 
     1832         snprint_bytes (byte_buf, BYTE_BUF_LEN, 
     1833                        frames_to_bytes (sounddata->format, sounddata->nr_frames)); 
    18251834   
    1826   snprint_time (time_buf, TIME_BUF_LEN, 
    1827                 frames_to_time (sounddata->format, sounddata->nr_frames)); 
    1828  
    1829  
    1830   gtk_clist_set_text (GTK_CLIST(clist), 0, 1, g_basename(sample->pathname)); 
    1831   gtk_clist_set_text (GTK_CLIST(clist), 1, 1, rate_buf); 
    1832   gtk_clist_set_text (GTK_CLIST(clist), 2, 1, chan_buf); 
    1833   gtk_clist_set_text (GTK_CLIST(clist), 3, 1, byte_buf); 
    1834   gtk_clist_set_text (GTK_CLIST(clist), 4, 1, time_buf); 
    1835  
     1835          snprint_time (time_buf, TIME_BUF_LEN, 
     1836                        frames_to_time (sounddata->format, sounddata->nr_frames)); 
     1837 
     1838          gtk_clist_set_text (GTK_CLIST(clist), 0, 1, g_basename(sample->pathname)); 
     1839          gtk_clist_set_text (GTK_CLIST(clist), 1, 1, rate_buf); 
     1840          gtk_clist_set_text (GTK_CLIST(clist), 2, 1, chan_buf); 
     1841          gtk_clist_set_text (GTK_CLIST(clist), 3, 1, byte_buf); 
     1842          gtk_clist_set_text (GTK_CLIST(clist), 4, 1, time_buf); 
     1843        } 
     1844 
     1845        info_panel_sample_info_update(sample); 
     1846        info_panel_selections_info_update(sample); 
    18361847} 
    18371848 
  • sweep/branches/sweep-info-panel/src/sweep_selection.c

    r124 r427  
    3737 
    3838sw_sel * 
    39 sel_new (sw_framecount_t start, sw_framecount_t end
     39sel_new (sw_framecount_t start, sw_framecount_t end, gchar * name
    4040{ 
    4141  sw_framecount_t s, e; 
     
    4848  sel->sel_start = s; 
    4949  sel->sel_end = e; 
     50        sel->name = g_strdup(name); 
    5051 
    5152  return sel; 
     53} 
     54 
     55void 
     56sel_free (sw_sel * sel) 
     57{ 
     58        if (!sel) 
     59                return; 
     60 
     61        g_free(sel->name); 
     62        g_free(sel); 
     63 
    5264} 
    5365 
     
    5769  sw_sel * nsel; 
    5870 
    59   nsel = sel_new (sel->sel_start, sel->sel_end); 
     71  nsel = sel_new (sel->sel_start, sel->sel_end, sel->name); 
    6072 
    6173  return nsel; 
     
    123135  sw_sel * sel; 
    124136 
    125   sel = sel_new (start, end); 
     137  sel = sel_new (start, end, NULL); 
    126138 
    127139  return sels_add_selection (sels, sel); 
     
    142154  if (!sels) { 
    143155    g_list_free (sels); 
    144     sel = sel_new (0, nr_frames); 
     156    sel = sel_new (0, nr_frames, NULL); 
    145157    sels = NULL; 
    146158    sels = g_list_append (sels, sel); 
  • sweep/branches/sweep-info-panel/src/undo_dialog.c

    r279 r427  
    3939#include "interface.h" 
    4040#include "callbacks.h" 
     41#include "info-panel.h" 
    4142 
    4243#include "../pixmaps/undo.xpm" 
     
    192193undo_dialog_refresh_history (sw_sample * sample) 
    193194{ 
     195        info_panel_undo_info_update(sample); 
     196 
    194197  if (sample != ud_sample) 
    195198    return; 
  • sweep/branches/sweep-info-panel/src/view.c

    r370 r427  
    6060#include "cursors.h" 
    6161#include "head.h" 
     62#include "info-panel.h" 
    6263#include "view_pixmaps.h" 
    6364 
     
    17891790  GtkWidget * main_vbox; 
    17901791  GtkWidget * table; 
     1792  GtkWidget * table1; 
    17911793  GtkWidget * hbox; 
    17921794  GtkWidget * vbox; 
     
    18111813  GtkWidget * frame; 
    18121814  GtkWidget * label; 
     1815        GtkWidget * hpaned; 
     1816        GtkWidget * scrolled_window; 
     1817        GtkWidget * treeview; 
    18131818#if 0 
    18141819  GtkWidget * entry; 
     
    22592264  gtk_widget_show (table); 
    22602265 
    2261   /* menu button */ 
     2266        // menu button | time_ruller 
     2267        // db_ruller   | display 
     2268        // scrollbar 
     2269 
     2270        /* hpaned */ 
     2271 
     2272        hpaned = gtk_hpaned_new(); 
     2273  gtk_table_attach (GTK_TABLE(table), hpaned, 
     2274                    0, 2, 0, 3, 
     2275                    GTK_EXPAND|GTK_FILL|GTK_SHRINK, GTK_FILL, 
     2276                    0, 0); 
     2277  gtk_widget_show(hpaned); 
     2278        gtk_paned_set_position(GTK_PANED(hpaned), win_width / 4); 
     2279 
     2280        treeview = info_panel_new(view); 
     2281 
     2282        scrolled_window = gtk_scrolled_window_new (NULL, NULL); 
     2283        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), 
     2284                                GTK_POLICY_AUTOMATIC,  
     2285                                GTK_POLICY_AUTOMATIC); 
     2286        gtk_container_add(GTK_CONTAINER(scrolled_window), treeview); 
     2287 
     2288        gtk_widget_show(treeview); 
     2289 
     2290        gtk_paned_pack1(GTK_PANED(hpaned), scrolled_window, TRUE, TRUE); 
     2291        gtk_widget_show(scrolled_window); 
     2292 
     2293        /* display table */ 
     2294        table1 = gtk_table_new (3, 2, FALSE); 
     2295  gtk_table_set_col_spacing (GTK_TABLE(table1), 0, 1); 
     2296  gtk_table_set_col_spacing (GTK_TABLE(table1), 1, 2); 
     2297  gtk_table_set_row_spacing (GTK_TABLE(table1), 0, 1); 
     2298  gtk_table_set_row_spacing (GTK_TABLE(table1), 1, 2); 
     2299  gtk_container_set_border_width (GTK_CONTAINER(table1), 2); 
     2300 
     2301        gtk_paned_pack2(GTK_PANED(hpaned), table1, TRUE, TRUE); 
     2302   
     2303        gtk_widget_show(table1); 
     2304 
     2305        /* menu button */ 
    22622306  menu_button = gtk_button_new (); 
    2263   gtk_table_attach (GTK_TABLE(table), menu_button, 
     2307  gtk_table_attach (GTK_TABLE(table1), menu_button, 
    22642308                    0, 1, 0, 1, 
    22652309                    GTK_FILL, GTK_FILL, 
     
    22752319 
    22762320  ebox = gtk_event_box_new (); 
    2277   gtk_table_attach (GTK_TABLE(table), ebox, 
     2321  gtk_table_attach (GTK_TABLE(table1), ebox, 
    22782322                    1, 2, 0, 1, 
    22792323                    GTK_EXPAND|GTK_FILL|GTK_SHRINK, GTK_FILL, 
     
    23032347 
    23042348  ebox = gtk_event_box_new (); 
    2305   gtk_table_attach (GTK_TABLE(table), ebox, 
     2349  gtk_table_attach (GTK_TABLE(table1), ebox, 
    23062350                    0, 1, 1, 2, 
    23072351                    GTK_FILL, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 
     
    23292373  /* display */ 
    23302374  view->display = sample_display_new(); 
    2331   gtk_table_attach (GTK_TABLE(table), view->display, 
     2375  gtk_table_attach (GTK_TABLE(table1), view->display, 
    23322376                    1, 2, 1, 2, 
    23332377                    GTK_EXPAND|GTK_FILL|GTK_SHRINK, 
     
    24172461 
    24182462  scrollbar = gtk_hscrollbar_new(GTK_ADJUSTMENT(view->adj)); 
    2419   gtk_table_attach (GTK_TABLE(table), scrollbar, 
     2463  gtk_table_attach (GTK_TABLE(table1), scrollbar, 
    24202464                    1, 2, 2, 3, 
    24212465                    GTK_EXPAND|GTK_FILL|GTK_SHRINK, GTK_FILL, 
     
    38333877  view_refresh_channelops_menu (v); 
    38343878  view_refresh_db_rulers (v); 
     3879//      g_print("VIEW REFRESH\n"); 
    38353880} 
    38363881