Changeset 44cdd3164cb959ab9418ac310b52388d8cc96ca7

Show
Ignore:
Timestamp:
02/21/10 20:11:30 (5 months ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
fa67487ea8ca6701a10256e458178aa161280964
Parents:
97f4150664c833e181971788d8f58962f4b5e66d
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-02-21T20:11:30Z+0200
Message:

Use custom status icons (and more of them). Fixes #65

Files:
6 added
2 modified

Legend:

Unmodified
Added
Removed
  • gui/main.c

    r97f4150 r44cdd31  
    116116static unsigned int g_jack_state = JACK_STATE_NA; 
    117117 
     118#define ABOUT_DIALOG_LOGO     "ladish-logo-128x128.png" 
     119#define STATUS_ICON_DOWN      "status_down.png"         /* temporary down during service restart */ 
     120#define STATUS_ICON_UNLOADED  "status_unloaded.png" 
     121#define STATUS_ICON_STARTED   "status_started.png" 
     122#define STATUS_ICON_STOPPED   "status_stopped.png" 
     123#define STATUS_ICON_WARNING   "status_warning.png"      /* xruns */ 
     124#define STATUS_ICON_ERROR     "status_error.png"        /* bad error */ 
     125 
    118126struct studio_list 
    119127{ 
     
    156164 
    157165#endif 
     166 
     167static GdkPixbuf * load_pixbuf_internal(const char * directory, const char * filename) 
     168{ 
     169  char * fullpath; 
     170  GdkPixbuf * pixbuf; 
     171 
     172  fullpath = catdup(directory, filename); 
     173  if (fullpath == NULL) 
     174  { 
     175    return NULL; 
     176  } 
     177 
     178  pixbuf = gdk_pixbuf_new_from_file(fullpath, NULL); 
     179 
     180  free(fullpath); 
     181 
     182  return pixbuf; 
     183} 
     184 
     185static GdkPixbuf * load_pixbuf(const char * filename) 
     186{ 
     187  GdkPixbuf * pixbuf; 
     188  static const char * pixbuf_dirs[] = {"./art/", DATA_DIR "/", NULL}; 
     189  const char ** dir; 
     190 
     191  for (dir = pixbuf_dirs; *dir != NULL; dir++) 
     192  { 
     193    pixbuf = load_pixbuf_internal(*dir, filename); 
     194    if (pixbuf != NULL) 
     195    { 
     196      return pixbuf; 
     197    } 
     198  } 
     199 
     200  return NULL; 
     201} 
    158202 
    159203void set_latency_items_sensivity(bool sensitive) 
     
    668712  const char * name; 
    669713  char * buffer; 
    670   const gchar * stock_id; 
     714  const char * status_image_path; 
    671715  const char * tooltip; 
     716  GdkPixbuf * pixbuf; 
    672717 
    673718  gtk_widget_set_sensitive(g_menu_item_start_studio, g_studio_state == STUDIO_STATE_STOPPED); 
     
    682727  //gtk_widget_set_sensitive(g_menu_item_load_project, g_studio_loaded); 
    683728 
    684   stock_id = NULL; 
    685729  tooltip = NULL; 
     730  status_image_path = NULL; 
    686731 
    687732  switch (g_jack_state) 
     
    689734  case JACK_STATE_NA: 
    690735    tooltip = status = "JACK is sick"; 
    691     stock_id = GTK_STOCK_DIALOG_WARNING; 
     736    status_image_path = STATUS_ICON_ERROR; 
    692737    break; 
    693738  case JACK_STATE_STOPPED: 
     
    700745    status = "???"; 
    701746    tooltip = "Internal error - unknown jack state"; 
    702     stock_id = GTK_STOCK_DIALOG_WARNING; 
     747    status_image_path = STATUS_ICON_ERROR; 
    703748  } 
    704749 
     
    709754  case STUDIO_STATE_NA: 
    710755    name = "ladishd is down"; 
     756    status_image_path = STATUS_ICON_DOWN; 
    711757    break; 
    712758  case STUDIO_STATE_SICK: 
    713759  case STUDIO_STATE_UNKNOWN: 
    714760    tooltip = name = "ladishd is sick"; 
    715     stock_id = GTK_STOCK_DIALOG_WARNING; 
     761    status_image_path = STATUS_ICON_ERROR; 
    716762    break; 
    717763  case STUDIO_STATE_UNLOADED: 
    718764    name = "No studio loaded"; 
     765    status_image_path = STATUS_ICON_UNLOADED; 
    719766    break; 
    720767  case STUDIO_STATE_CRASHED: 
    721768    status = "Crashed"; 
    722769    tooltip = "Crashed studio, save your work if you can and unload the studio"; 
    723     stock_id = GTK_STOCK_DIALOG_WARNING; 
     770    status_image_path = STATUS_ICON_ERROR; 
    724771    /* fall through */ 
    725772  case STUDIO_STATE_STOPPED: 
     
    729776      tooltip = "failed to get studio name"; 
    730777      log_error("%s", tooltip); 
    731       stock_id = GTK_STOCK_DIALOG_WARNING; 
     778      status_image_path = STATUS_ICON_ERROR; 
    732779    } 
    733780    else 
     
    737784      { 
    738785      case STUDIO_STATE_STARTED: 
    739         stock_id = GTK_STOCK_YES; 
     786        status_image_path = STATUS_ICON_STARTED; 
    740787        tooltip = "Studio is started"; 
    741788        break; 
    742789      case STUDIO_STATE_STOPPED: 
    743         stock_id = GTK_STOCK_NO; 
     790        status_image_path = STATUS_ICON_STOPPED; 
    744791        tooltip = "Studio is stopped"; 
    745792        break; 
     
    750797    name = "???"; 
    751798    tooltip = "Internal error - unknown studio state"; 
    752     stock_id = GTK_STOCK_DIALOG_WARNING; 
     799    status_image_path = STATUS_ICON_ERROR; 
    753800  } 
    754801 
     
    756803  gtk_label_set_text(GTK_LABEL(g_studio_status_label), name); 
    757804 
    758   log_error("status icon stock id: %s", stock_id); 
    759   gtk_image_set_from_stock(GTK_IMAGE(g_status_image), stock_id, GTK_ICON_SIZE_SMALL_TOOLBAR); 
     805  if (status_image_path == NULL || (pixbuf = load_pixbuf(status_image_path)) == NULL) 
     806  { 
     807    gtk_image_set_from_stock(GTK_IMAGE(g_status_image), GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_SMALL_TOOLBAR); 
     808  } 
     809  else 
     810  { 
     811    gtk_image_set_from_pixbuf(GTK_IMAGE(g_status_image), pixbuf); 
     812    g_object_unref(pixbuf); 
     813  } 
     814 
    760815  //gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(g_status_tool_item), tooltip); 
    761816 
     
    10761131} 
    10771132 
    1078 #define ABOUT_DIALOG_LOGO "ladish-logo-128x128.png" 
    1079  
    10801133static void show_about(void) 
    10811134{ 
     
    10861139  char * license; 
    10871140 
    1088   pixbuf = gdk_pixbuf_new_from_file("./art/" ABOUT_DIALOG_LOGO, NULL); 
    1089   if (pixbuf == NULL) 
    1090   { 
    1091     pixbuf = gdk_pixbuf_new_from_file(DATA_DIR "/" ABOUT_DIALOG_LOGO, NULL); 
    1092   } 
    1093  
     1141  pixbuf =  load_pixbuf(ABOUT_DIALOG_LOGO); 
    10941142  license = read_file_contents(DATA_DIR "/COPYING"); 
    10951143 
  • wscript

    r5fc59ea r44cdd31  
    363363    #    install_as(os.path.normpath(bld.env()['DATADIR'] + '/icons/hicolor/' + icon_size + '/apps/'), bld.env()['APP_INSTALL_NAME'] + '.png', 'icons/' + icon_size + '/patchage.png') 
    364364 
     365    status_images = [] 
     366    for status in ["down", "unloaded", "started", "stopped", "warning", "error"]: 
     367        status_images.append("art/status_" + status + ".png") 
     368 
     369    bld.install_files(bld.env['DATA_DIR'], status_images) 
    365370    bld.install_files(bld.env['DATA_DIR'], "art/ladish-logo-128x128.png") 
    366371    bld.install_files(bld.env['DATA_DIR'], ["COPYING", "AUTHORS", "README", "NEWS"])