Changeset 44cdd3164cb959ab9418ac310b52388d8cc96ca7
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r97f4150
|
r44cdd31
|
|
| 116 | 116 | static unsigned int g_jack_state = JACK_STATE_NA; |
| 117 | 117 | |
| | 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 | |
| 118 | 126 | struct studio_list |
| 119 | 127 | { |
| … |
… |
|
| 156 | 164 | |
| 157 | 165 | #endif |
| | 166 | |
| | 167 | static 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 | |
| | 185 | static 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 | } |
| 158 | 202 | |
| 159 | 203 | void set_latency_items_sensivity(bool sensitive) |
| … |
… |
|
| 668 | 712 | const char * name; |
| 669 | 713 | char * buffer; |
| 670 | | const gchar * stock_id; |
| | 714 | const char * status_image_path; |
| 671 | 715 | const char * tooltip; |
| | 716 | GdkPixbuf * pixbuf; |
| 672 | 717 | |
| 673 | 718 | gtk_widget_set_sensitive(g_menu_item_start_studio, g_studio_state == STUDIO_STATE_STOPPED); |
| … |
… |
|
| 682 | 727 | //gtk_widget_set_sensitive(g_menu_item_load_project, g_studio_loaded); |
| 683 | 728 | |
| 684 | | stock_id = NULL; |
| 685 | 729 | tooltip = NULL; |
| | 730 | status_image_path = NULL; |
| 686 | 731 | |
| 687 | 732 | switch (g_jack_state) |
| … |
… |
|
| 689 | 734 | case JACK_STATE_NA: |
| 690 | 735 | tooltip = status = "JACK is sick"; |
| 691 | | stock_id = GTK_STOCK_DIALOG_WARNING; |
| | 736 | status_image_path = STATUS_ICON_ERROR; |
| 692 | 737 | break; |
| 693 | 738 | case JACK_STATE_STOPPED: |
| … |
… |
|
| 700 | 745 | status = "???"; |
| 701 | 746 | tooltip = "Internal error - unknown jack state"; |
| 702 | | stock_id = GTK_STOCK_DIALOG_WARNING; |
| | 747 | status_image_path = STATUS_ICON_ERROR; |
| 703 | 748 | } |
| 704 | 749 | |
| … |
… |
|
| 709 | 754 | case STUDIO_STATE_NA: |
| 710 | 755 | name = "ladishd is down"; |
| | 756 | status_image_path = STATUS_ICON_DOWN; |
| 711 | 757 | break; |
| 712 | 758 | case STUDIO_STATE_SICK: |
| 713 | 759 | case STUDIO_STATE_UNKNOWN: |
| 714 | 760 | tooltip = name = "ladishd is sick"; |
| 715 | | stock_id = GTK_STOCK_DIALOG_WARNING; |
| | 761 | status_image_path = STATUS_ICON_ERROR; |
| 716 | 762 | break; |
| 717 | 763 | case STUDIO_STATE_UNLOADED: |
| 718 | 764 | name = "No studio loaded"; |
| | 765 | status_image_path = STATUS_ICON_UNLOADED; |
| 719 | 766 | break; |
| 720 | 767 | case STUDIO_STATE_CRASHED: |
| 721 | 768 | status = "Crashed"; |
| 722 | 769 | 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; |
| 724 | 771 | /* fall through */ |
| 725 | 772 | case STUDIO_STATE_STOPPED: |
| … |
… |
|
| 729 | 776 | tooltip = "failed to get studio name"; |
| 730 | 777 | log_error("%s", tooltip); |
| 731 | | stock_id = GTK_STOCK_DIALOG_WARNING; |
| | 778 | status_image_path = STATUS_ICON_ERROR; |
| 732 | 779 | } |
| 733 | 780 | else |
| … |
… |
|
| 737 | 784 | { |
| 738 | 785 | case STUDIO_STATE_STARTED: |
| 739 | | stock_id = GTK_STOCK_YES; |
| | 786 | status_image_path = STATUS_ICON_STARTED; |
| 740 | 787 | tooltip = "Studio is started"; |
| 741 | 788 | break; |
| 742 | 789 | case STUDIO_STATE_STOPPED: |
| 743 | | stock_id = GTK_STOCK_NO; |
| | 790 | status_image_path = STATUS_ICON_STOPPED; |
| 744 | 791 | tooltip = "Studio is stopped"; |
| 745 | 792 | break; |
| … |
… |
|
| 750 | 797 | name = "???"; |
| 751 | 798 | tooltip = "Internal error - unknown studio state"; |
| 752 | | stock_id = GTK_STOCK_DIALOG_WARNING; |
| | 799 | status_image_path = STATUS_ICON_ERROR; |
| 753 | 800 | } |
| 754 | 801 | |
| … |
… |
|
| 756 | 803 | gtk_label_set_text(GTK_LABEL(g_studio_status_label), name); |
| 757 | 804 | |
| 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 | |
| 760 | 815 | //gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(g_status_tool_item), tooltip); |
| 761 | 816 | |
| … |
… |
|
| 1076 | 1131 | } |
| 1077 | 1132 | |
| 1078 | | #define ABOUT_DIALOG_LOGO "ladish-logo-128x128.png" |
| 1079 | | |
| 1080 | 1133 | static void show_about(void) |
| 1081 | 1134 | { |
| … |
… |
|
| 1086 | 1139 | char * license; |
| 1087 | 1140 | |
| 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); |
| 1094 | 1142 | license = read_file_contents(DATA_DIR "/COPYING"); |
| 1095 | 1143 | |
-
|
r5fc59ea
|
r44cdd31
|
|
| 363 | 363 | # install_as(os.path.normpath(bld.env()['DATADIR'] + '/icons/hicolor/' + icon_size + '/apps/'), bld.env()['APP_INSTALL_NAME'] + '.png', 'icons/' + icon_size + '/patchage.png') |
| 364 | 364 | |
| | 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) |
| 365 | 370 | bld.install_files(bld.env['DATA_DIR'], "art/ladish-logo-128x128.png") |
| 366 | 371 | bld.install_files(bld.env['DATA_DIR'], ["COPYING", "AUTHORS", "README", "NEWS"]) |