Mercurial > audlegacy
comparison src/audacious/skin.c @ 4413:de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 06:47:48 +0300 |
parents | f1074a07ec09 |
children | 5125b5910d0e |
comparison
equal
deleted
inserted
replaced
4412:180996fcf12a | 4413:de33c83aa06f |
---|---|
73 | 73 |
74 typedef struct _SkinPixmapIdMapping SkinPixmapIdMapping; | 74 typedef struct _SkinPixmapIdMapping SkinPixmapIdMapping; |
75 typedef struct _SkinMaskInfo SkinMaskInfo; | 75 typedef struct _SkinMaskInfo SkinMaskInfo; |
76 | 76 |
77 | 77 |
78 Skin *bmp_active_skin = NULL; | 78 Skin *aud_active_skin = NULL; |
79 | 79 |
80 static gint skin_current_num; | 80 static gint skin_current_num; |
81 | 81 |
82 static SkinMaskInfo skin_mask_info[] = { | 82 static SkinMaskInfo skin_mask_info[] = { |
83 {275, 116, "Normal"}, | 83 {275, 116, "Normal"}, |
153 { | 153 { |
154 g_mutex_unlock(skin->lock); | 154 g_mutex_unlock(skin->lock); |
155 } | 155 } |
156 | 156 |
157 gboolean | 157 gboolean |
158 bmp_active_skin_reload(void) | 158 aud_active_skin_reload(void) |
159 { | 159 { |
160 AUDDBG("\n"); | 160 AUDDBG("\n"); |
161 return bmp_active_skin_load(bmp_active_skin->path); | 161 return aud_active_skin_load(aud_active_skin->path); |
162 } | 162 } |
163 | 163 |
164 gboolean | 164 gboolean |
165 bmp_active_skin_load(const gchar * path) | 165 aud_active_skin_load(const gchar * path) |
166 { | 166 { |
167 AUDDBG("%s\n", path); | 167 AUDDBG("%s\n", path); |
168 g_return_val_if_fail(bmp_active_skin != NULL, FALSE); | 168 g_return_val_if_fail(aud_active_skin != NULL, FALSE); |
169 | 169 |
170 if (!skin_load(bmp_active_skin, path)) { | 170 if (!skin_load(aud_active_skin, path)) { |
171 AUDDBG("loading failed\n"); | 171 AUDDBG("loading failed\n"); |
172 return FALSE; | 172 return FALSE; |
173 } | 173 } |
174 | 174 |
175 ui_skinned_window_draw_all(mainwin); | 175 ui_skinned_window_draw_all(mainwin); |
177 ui_skinned_window_draw_all(playlistwin); | 177 ui_skinned_window_draw_all(playlistwin); |
178 | 178 |
179 playlistwin_update_list(playlist_get_active()); | 179 playlistwin_update_list(playlist_get_active()); |
180 | 180 |
181 SkinPixmap *pixmap; | 181 SkinPixmap *pixmap; |
182 pixmap = &bmp_active_skin->pixmaps[SKIN_POSBAR]; | 182 pixmap = &aud_active_skin->pixmaps[SKIN_POSBAR]; |
183 /* last 59 pixels of SKIN_POSBAR are knobs (normal and selected) */ | 183 /* last 59 pixels of SKIN_POSBAR are knobs (normal and selected) */ |
184 gtk_widget_set_size_request(mainwin_position, pixmap->width - 59, pixmap->height); | 184 gtk_widget_set_size_request(mainwin_position, pixmap->width - 59, pixmap->height); |
185 | 185 |
186 return TRUE; | 186 return TRUE; |
187 } | 187 } |
514 } | 514 } |
515 | 515 |
516 gboolean | 516 gboolean |
517 init_skins(const gchar * path) | 517 init_skins(const gchar * path) |
518 { | 518 { |
519 bmp_active_skin = skin_new(); | 519 aud_active_skin = skin_new(); |
520 | 520 |
521 skin_parse_hints(bmp_active_skin, NULL); | 521 skin_parse_hints(aud_active_skin, NULL); |
522 | 522 |
523 /* create the windows if they haven't been created yet, needed for bootstrapping */ | 523 /* create the windows if they haven't been created yet, needed for bootstrapping */ |
524 if (mainwin == NULL) | 524 if (mainwin == NULL) |
525 { | 525 { |
526 mainwin_create(); | 526 mainwin_create(); |
527 equalizerwin_create(); | 527 equalizerwin_create(); |
528 playlistwin_create(); | 528 playlistwin_create(); |
529 } | 529 } |
530 | 530 |
531 if (!bmp_active_skin_load(path)) { | 531 if (!aud_active_skin_load(path)) { |
532 if (path != NULL) | 532 if (path != NULL) |
533 AUDDBG("Unable to load skin (%s), trying default...\n", path); | 533 AUDDBG("Unable to load skin (%s), trying default...\n", path); |
534 else | 534 else |
535 AUDDBG("Skin not defined: trying default...\n"); | 535 AUDDBG("Skin not defined: trying default...\n"); |
536 | 536 |
537 /* can't load configured skin, retry with default */ | 537 /* can't load configured skin, retry with default */ |
538 if (!bmp_active_skin_load(BMP_DEFAULT_SKIN_PATH)) { | 538 if (!aud_active_skin_load(BMP_DEFAULT_SKIN_PATH)) { |
539 AUDDBG("Unable to load default skin (%s)! Giving up.\n", | 539 AUDDBG("Unable to load default skin (%s)! Giving up.\n", |
540 BMP_DEFAULT_SKIN_PATH); | 540 BMP_DEFAULT_SKIN_PATH); |
541 return FALSE; | 541 return FALSE; |
542 } | 542 } |
543 } | 543 } |
548 return TRUE; | 548 return TRUE; |
549 } | 549 } |
550 | 550 |
551 void cleanup_skins() | 551 void cleanup_skins() |
552 { | 552 { |
553 skin_destroy(bmp_active_skin); | 553 skin_destroy(aud_active_skin); |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 /* | 557 /* |
558 * Opens and parses a skin's hints file. | 558 * Opens and parses a skin's hints file. |
1598 #endif | 1598 #endif |
1599 | 1599 |
1600 if(archive) del_directory(skin_path); | 1600 if(archive) del_directory(skin_path); |
1601 g_free(skin_path); | 1601 g_free(skin_path); |
1602 | 1602 |
1603 gtk_widget_shape_combine_mask(mainwin, skin_get_mask(bmp_active_skin, SKIN_MASK_MAIN + cfg.player_shaded), 0, 0); | 1603 gtk_widget_shape_combine_mask(mainwin, skin_get_mask(aud_active_skin, SKIN_MASK_MAIN + cfg.player_shaded), 0, 0); |
1604 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(bmp_active_skin, SKIN_MASK_EQ + cfg.equalizer_shaded), 0, 0); | 1604 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + cfg.equalizer_shaded), 0, 0); |
1605 | 1605 |
1606 return TRUE; | 1606 return TRUE; |
1607 } | 1607 } |
1608 | 1608 |
1609 void | 1609 void |
1612 gchar *command; | 1612 gchar *command; |
1613 | 1613 |
1614 g_return_if_fail(path != NULL); | 1614 g_return_if_fail(path != NULL); |
1615 | 1615 |
1616 command = g_strdup_printf("cp %s %s", | 1616 command = g_strdup_printf("cp %s %s", |
1617 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]); | 1617 path, aud_paths[BMP_PATH_USER_SKIN_DIR]); |
1618 if (system(command)) { | 1618 if (system(command)) { |
1619 AUDDBG("Unable to install skin (%s) into user directory (%s)\n", | 1619 AUDDBG("Unable to install skin (%s) into user directory (%s)\n", |
1620 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]); | 1620 path, aud_paths[BMP_PATH_USER_SKIN_DIR]); |
1621 } | 1621 } |
1622 g_free(command); | 1622 g_free(command); |
1623 } | 1623 } |
1624 | 1624 |
1625 static SkinPixmap * | 1625 static SkinPixmap * |
1679 skin_reload_forced(void) | 1679 skin_reload_forced(void) |
1680 { | 1680 { |
1681 gboolean error; | 1681 gboolean error; |
1682 AUDDBG("\n"); | 1682 AUDDBG("\n"); |
1683 | 1683 |
1684 skin_lock(bmp_active_skin); | 1684 skin_lock(aud_active_skin); |
1685 error = skin_load_nolock(bmp_active_skin, bmp_active_skin->path, TRUE); | 1685 error = skin_load_nolock(aud_active_skin, aud_active_skin->path, TRUE); |
1686 skin_unlock(bmp_active_skin); | 1686 skin_unlock(aud_active_skin); |
1687 | 1687 |
1688 return error; | 1688 return error; |
1689 } | 1689 } |
1690 | 1690 |
1691 void | 1691 void |
1799 if (pixmap_id == SKIN_VOLUME || pixmap_id == SKIN_BALANCE) { | 1799 if (pixmap_id == SKIN_VOLUME || pixmap_id == SKIN_BALANCE) { |
1800 if (ysrc+height > 421 && xsrc+width <= pixmap->width) | 1800 if (ysrc+height > 421 && xsrc+width <= pixmap->width) |
1801 return; | 1801 return; |
1802 } | 1802 } |
1803 /* let's copy what's under widget */ | 1803 /* let's copy what's under widget */ |
1804 gdk_pixbuf_copy_area(skin_get_pixmap(bmp_active_skin, SKIN_MAIN)->pixbuf, | 1804 gdk_pixbuf_copy_area(skin_get_pixmap(aud_active_skin, SKIN_MAIN)->pixbuf, |
1805 x, y, width, height, pix, xdest, ydest); | 1805 x, y, width, height, pix, xdest, ydest); |
1806 | 1806 |
1807 /* XMMS skins seems to have SKIN_MONOSTEREO with size 58x20 instead of 58x24 */ | 1807 /* XMMS skins seems to have SKIN_MONOSTEREO with size 58x20 instead of 58x24 */ |
1808 if (pixmap_id == SKIN_MONOSTEREO) | 1808 if (pixmap_id == SKIN_MONOSTEREO) |
1809 height = pixmap->height/2; | 1809 height = pixmap->height/2; |
2050 else | 2050 else |
2051 y_offset = 15; | 2051 y_offset = 15; |
2052 } | 2052 } |
2053 | 2053 |
2054 skin_draw_pixbuf(NULL, skin, pix, SKIN_TITLEBAR, 27, y_offset, | 2054 skin_draw_pixbuf(NULL, skin, pix, SKIN_TITLEBAR, 27, y_offset, |
2055 0, 0, bmp_active_skin->properties.mainwin_width, MAINWIN_TITLEBAR_HEIGHT); | 2055 0, 0, aud_active_skin->properties.mainwin_width, MAINWIN_TITLEBAR_HEIGHT); |
2056 } | 2056 } |
2057 | 2057 |
2058 | 2058 |
2059 void | 2059 void |
2060 skin_set_random_skin(void) | 2060 skin_set_random_skin(void) |
2063 guint32 randval; | 2063 guint32 randval; |
2064 | 2064 |
2065 /* Get a random value to select the skin to use */ | 2065 /* Get a random value to select the skin to use */ |
2066 randval = g_random_int_range(0, g_list_length(skinlist)); | 2066 randval = g_random_int_range(0, g_list_length(skinlist)); |
2067 node = g_list_nth(skinlist, randval)->data; | 2067 node = g_list_nth(skinlist, randval)->data; |
2068 bmp_active_skin_load(node->path); | 2068 aud_active_skin_load(node->path); |
2069 } | 2069 } |