PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/recipes/matchbox-applet-cards/files/oz-gpe.patch

https://github.com/e3c/openembedded
Patch | 466 lines | 420 code | 46 blank | 0 comment | 0 complexity | ad9b65ee078b1e01d4b385c5ed6bc9df MD5 | raw file
  1. --- mb-applet-cards-1.0.2/mb-applet-cards.desktop.ori 2005-11-10 21:17:56.000000000 +0100
  2. +++ mb-applet-cards-1.0.2/mb-applet-cards.desktop 2005-11-10 21:18:11.000000000 +0100
  3. @@ -1,7 +1,7 @@
  4. [Desktop Entry]
  5. Name=CF/SD Monitor
  6. Comment=Panel based CF/SD Monitor
  7. -Exec=mb-applet-cards
  8. +Exec=gpe-applet-cards
  9. Type=PanelApp
  10. Icon=cards.png
  11. Categories=Panel;Utility;MB
  12. --- mb-applet-cards-1.0.2/mb-applet-cards.c.ori 2005-09-13 22:18:53.000000000 +0200
  13. +++ mb-applet-cards-1.0.2/mb-applet-cards.c 2005-11-15 10:33:13.000000000 +0100
  14. @@ -47,6 +47,8 @@
  15. #define POPUP_PTR_SZ 10
  16. #define IMG_PREFIX "/usr/share/pixmaps"
  17. +#define SD_MOUNT_PATH "/media/card"
  18. +#define CARD_CONTROL "/sbin/cardctl"
  19. static char *ImgLookup[64] = {
  20. "cards." IMG_EXT,
  21. @@ -71,8 +73,8 @@
  22. GtkWidget *cards_window;
  23. GtkWidget *cards;
  24. -GtkWidget *button;
  25. -GtkWidget *button1;
  26. +GtkWidget *button_cf;
  27. +GtkWidget *button_sd;
  28. GtkWidget *boxV;
  29. GtkWidget *box_cf;
  30. GtkWidget *box_sd;
  31. @@ -123,15 +125,15 @@
  32. int err;
  33. gtk_widget_hide (cards_window);
  34. if (old_cf_status == 1) {
  35. - err = system("cardctl eject 0");
  36. - if (err != 0) {
  37. - error_dialog("CF/PCMCIA card eject failed!");
  38. - }
  39. + err = system(CARD_CONTROL " eject 0");
  40. + if (err != 0) {
  41. + error_dialog("CF/PCMCIA card eject failed!");
  42. + }
  43. } else {
  44. - err = system("cardctl insert 0");
  45. - if (err != 0) {
  46. - error_dialog("CF/PCMCIA card insert failed!");
  47. - }
  48. + err = system(CARD_CONTROL " insert 0");
  49. + if (err != 0) {
  50. + error_dialog("CF/PCMCIA card insert failed!");
  51. + }
  52. }
  53. }
  54. @@ -142,15 +144,15 @@
  55. GtkWidget *dialog;
  56. gtk_widget_hide (cards_window);
  57. if (old_sd_status == 1) {
  58. - err = system("umount /mnt/card");
  59. - if (err != 0) {
  60. - error_dialog("SD/MMC card unmount failed!");
  61. - }
  62. + err = system("umount " SD_MOUNT_PATH);
  63. + if (err != 0) {
  64. + error_dialog("SD/MMC card unmount failed!");
  65. + }
  66. } else {
  67. - err = system("mount /mnt/card");
  68. - if (err != 0) {
  69. - error_dialog("SD/MMC card mount failed!");
  70. - }
  71. + err = system("mount " SD_MOUNT_PATH);
  72. + if (err != 0) {
  73. + error_dialog("SD/MMC card mount failed!");
  74. + }
  75. }
  76. }
  77. @@ -158,35 +160,35 @@
  78. {
  79. boxV = gtk_vbox_new(FALSE, 0);
  80. - button = gtk_button_new ();
  81. + button_cf = gtk_button_new ();
  82. - g_signal_connect (G_OBJECT (button), "clicked",
  83. - G_CALLBACK (callback_cf), (gpointer) "cool button");
  84. + g_signal_connect (G_OBJECT (button_cf), "clicked",
  85. + G_CALLBACK (callback_cf), (gpointer) "button_cf");
  86. box_cf = xpm_label_box (IMG_PREFIX "/cf_mount.png", "CF eject\nlala");
  87. gtk_widget_show (box_cf);
  88. - gtk_container_add (GTK_CONTAINER (button), box_cf);
  89. + gtk_container_add (GTK_CONTAINER (button_cf), box_cf);
  90. - gtk_box_pack_start(GTK_BOX(boxV), button, FALSE, FALSE, 0);
  91. + gtk_box_pack_start(GTK_BOX(boxV), button_cf, FALSE, FALSE, 0);
  92. - gtk_widget_show (button);
  93. + gtk_widget_show (button_cf);
  94. - button1 = gtk_button_new ();
  95. + button_sd = gtk_button_new ();
  96. - g_signal_connect (G_OBJECT (button1), "clicked",
  97. - G_CALLBACK (callback_sd), (gpointer) "cool button1");
  98. + g_signal_connect (G_OBJECT (button_sd), "clicked",
  99. + G_CALLBACK (callback_sd), (gpointer) "button_sd");
  100. box_sd = xpm_label_box (IMG_PREFIX "/sd_mount.png", "SD eject");
  101. gtk_widget_show (box_sd);
  102. - gtk_container_add (GTK_CONTAINER (button1), box_sd);
  103. + gtk_container_add (GTK_CONTAINER (button_sd), box_sd);
  104. - gtk_box_pack_start(GTK_BOX(boxV), button1, FALSE, FALSE, 0);
  105. + gtk_box_pack_start(GTK_BOX(boxV), button_sd, FALSE, FALSE, 0);
  106. - gtk_widget_show (button1);
  107. + gtk_widget_show (button_sd);
  108. gtk_container_add (GTK_CONTAINER (cards_window), boxV);
  109. @@ -198,49 +200,51 @@
  110. int sd_found = 0;
  111. FILE *inf;
  112. char buf[256];
  113. - inf = fopen("/var/lib/pcmcia/stab", "r");
  114. + //inf = fopen("/var/lib/pcmcia/stab", "r");
  115. + inf = fopen("/var/run/stab", "r");
  116. fgets(buf, 256, inf);
  117. fclose(inf);
  118. if (strncmp(buf, "Socket 0: empty", 15 ) == 0) {
  119. -// if (old_cf_status != 0) {
  120. - gtk_widget_destroy(box_cf);
  121. - box_cf = xpm_label_box (IMG_PREFIX "/cf_unmount.png", "empty");
  122. - gtk_widget_show (box_cf);
  123. - gtk_container_add (GTK_CONTAINER (button), box_cf);
  124. -// }
  125. - old_cf_status = 0;
  126. +// if (old_cf_status != 0) {
  127. + gtk_widget_destroy(box_cf);
  128. + box_cf = xpm_label_box (IMG_PREFIX "/cf_unmount.png", "empty");
  129. + gtk_widget_show (box_cf);
  130. + gtk_container_add (GTK_CONTAINER (button_cf), box_cf);
  131. +// }
  132. + old_cf_status = 0;
  133. } else {
  134. -// if (old_cf_status != 1) {
  135. - gtk_widget_destroy(box_cf);
  136. - box_cf = xpm_label_box (IMG_PREFIX "/cf_mount.png", &buf[10]);
  137. - gtk_widget_show (box_cf);
  138. - gtk_container_add (GTK_CONTAINER (button), box_cf);
  139. -// }
  140. - old_cf_status = 1;
  141. +// if (old_cf_status != 1) {
  142. + gtk_widget_destroy(box_cf);
  143. + box_cf = xpm_label_box (IMG_PREFIX "/cf_mount.png", &buf[10]);
  144. + gtk_widget_show (box_cf);
  145. + gtk_container_add (GTK_CONTAINER (button_cf), box_cf);
  146. +// }
  147. + old_cf_status = 1;
  148. }
  149. inf = fopen("/etc/mtab", "r");
  150. while (!feof(inf)) {
  151. - fgets(buf, 256, inf);
  152. - if (strncmp(buf, "/dev/mmcd", 9) == 0) sd_found = 1;
  153. + fgets(buf, 256, inf);
  154. + //if (strncmp(buf, "/dev/mmcd", 9) == 0) sd_found = 1;
  155. + if (strncmp(buf, "/dev/mmc", 8) == 0) sd_found = 1;
  156. }
  157. fclose(inf);
  158. if (sd_found == 0) {
  159. -// if (old_sd_status != 0) {
  160. - gtk_widget_destroy(box_sd);
  161. - box_sd = xpm_label_box (IMG_PREFIX "/sd_unmount.png", "empty");
  162. - gtk_widget_show (box_sd);
  163. - gtk_container_add (GTK_CONTAINER (button1), box_sd);
  164. -// }
  165. - old_sd_status = 0;
  166. +// if (old_sd_status != 0) {
  167. + gtk_widget_destroy(box_sd);
  168. + box_sd = xpm_label_box (IMG_PREFIX "/sd_unmount.png", "empty");
  169. + gtk_widget_show (box_sd);
  170. + gtk_container_add (GTK_CONTAINER (button_sd), box_sd);
  171. +// }
  172. + old_sd_status = 0;
  173. } else {
  174. -// if (old_sd_status != 1) {
  175. - gtk_widget_destroy(box_sd);
  176. - box_sd = xpm_label_box (IMG_PREFIX "/sd_mount.png", "SD card");
  177. - gtk_widget_show (box_sd);
  178. - gtk_container_add (GTK_CONTAINER (button1), box_sd);
  179. -// }
  180. - old_sd_status = 1;
  181. +// if (old_sd_status != 1) {
  182. + gtk_widget_destroy(box_sd);
  183. + box_sd = xpm_label_box (IMG_PREFIX "/sd_mount.png", "SD card");
  184. + gtk_widget_show (box_sd);
  185. + gtk_container_add (GTK_CONTAINER (button_sd), box_sd);
  186. +// }
  187. + old_sd_status = 1;
  188. }
  189. }
  190. @@ -250,13 +254,13 @@
  191. paint_callback (MBTrayApp *app, Drawable drw )
  192. {
  193. MBPixbufImage *img_backing = NULL;
  194. -
  195. +
  196. img_backing = mb_tray_app_get_background (app, pb);
  197. /* CurrentVolLevel */
  198. - mb_pixbuf_img_composite(pb, img_backing,
  199. - ImgsScaled[0],
  200. - 0, 0);
  201. + mb_pixbuf_img_composite(pb, img_backing,
  202. + ImgsScaled[0],
  203. + 0, 0);
  204. mb_pixbuf_img_render_to_drawable(pb, img_backing, drw, 0, 0);
  205. @@ -284,48 +288,46 @@
  206. for (i=0; i<1; i++)
  207. {
  208. if (Imgs[i] != NULL) mb_pixbuf_img_free(pb, Imgs[i]);
  209. - icon_path = mb_dot_desktop_icon_get_full_path (ThemeName,
  210. - 32,
  211. - ImgLookup[i]);
  212. -
  213. - if (icon_path == NULL
  214. - || !(Imgs[i] = mb_pixbuf_img_new_from_file(pb, icon_path)))
  215. - {
  216. - fprintf(stderr, "cards: failed to load icon\n" );
  217. - exit(1);
  218. - }
  219. + icon_path = mb_dot_desktop_icon_get_full_path (ThemeName,
  220. + 32,
  221. + ImgLookup[i]);
  222. + if (icon_path == NULL
  223. + || !(Imgs[i] = mb_pixbuf_img_new_from_file(pb, icon_path)))
  224. + {
  225. + fprintf(stderr, "cards: failed to load icon\n" );
  226. + exit(1);
  227. + }
  228. free(icon_path);
  229. }
  230. }
  231. -void
  232. +void
  233. theme_callback (MBTrayApp *app, char *theme_name)
  234. {
  235. if (!theme_name) return;
  236. if (ThemeName) free(ThemeName);
  237. ThemeName = strdup(theme_name);
  238. - load_icons();
  239. + load_icons();
  240. resize_callback (app, mb_tray_app_width(app), mb_tray_app_width(app) );
  241. }
  242. +/*
  243. gboolean
  244. popup_close (GtkWidget *w, GtkWidget *list_view)
  245. {
  246. gtk_widget_hide (cards_window);
  247. PopupIsMapped = False;
  248. -
  249. }
  250. +*/
  251. static void
  252. cards_clicked (GtkWidget *w, GdkEventButton *ev)
  253. {
  254. gdk_pointer_ungrab (ev->time);
  255. -
  256. gtk_widget_hide (cards_window);
  257. }
  258. -
  259. static void
  260. button_callback (MBTrayApp *app, int cx, int cy, Bool is_released)
  261. {
  262. @@ -337,6 +339,7 @@
  263. if (PopupIsMapped) {
  264. gtk_widget_hide (cards_window);
  265. PopupIsMapped = False;
  266. + return;
  267. }
  268. mb_tray_app_get_absolute_coords (app, &x, &y);
  269. @@ -344,65 +347,58 @@
  270. gtk_widget_show_all (cards_window);
  271. gdk_window_get_geometry (cards_window->window, NULL, NULL,
  272. - &win_w, &win_h, NULL);
  273. + &win_w, &win_h, NULL);
  274. if (mb_tray_app_tray_is_vertical (app))
  275. {
  276. - if (x > (DisplayWidth(mb_tray_app_xdisplay(app),
  277. - mb_tray_app_xscreen(app)) /2) )
  278. - x -= ( mb_tray_app_width(app) + win_w );
  279. + if (x > (DisplayWidth(mb_tray_app_xdisplay(app),
  280. + mb_tray_app_xscreen(app)) /2) )
  281. + x -= ( mb_tray_app_width(app) + win_w );
  282. else
  283. - x += mb_tray_app_width(app);
  284. + x += mb_tray_app_width(app);
  285. }
  286. else
  287. {
  288. if (y < mb_tray_app_height(app))
  289. - { y = mb_tray_app_height(app); }
  290. + { y = mb_tray_app_height(app); }
  291. else
  292. - {
  293. - y = DisplayHeight(mb_tray_app_xdisplay(app),
  294. - mb_tray_app_xscreen(app))
  295. - - win_h - mb_tray_app_height(app) - 4;
  296. - }
  297. -
  298. - x -= (mb_tray_app_width(app)/2);
  299. -
  300. - if ((x + win_w) > DisplayWidth(mb_tray_app_xdisplay(app),
  301. - mb_tray_app_xscreen(app)))
  302. - x = DisplayWidth(mb_tray_app_xdisplay(app),
  303. - mb_tray_app_xscreen(app)) - win_w - 2;
  304. + {
  305. + y = DisplayHeight(mb_tray_app_xdisplay(app),
  306. + mb_tray_app_xscreen(app))
  307. + - win_h - mb_tray_app_height(app) - 4;
  308. + }
  309. +
  310. + x -= (mb_tray_app_width(app)/2);
  311. +
  312. + if ((x + win_w) > DisplayWidth(mb_tray_app_xdisplay(app),
  313. + mb_tray_app_xscreen(app)))
  314. + x = DisplayWidth(mb_tray_app_xdisplay(app),
  315. + mb_tray_app_xscreen(app)) - win_w - 2;
  316. }
  317. -
  318. check_for_cards();
  319. -
  320. +
  321. gtk_widget_set_uposition (GTK_WIDGET (cards_window), x, y);
  322. -
  323. +
  324. gdk_pointer_grab (cards_window->window, TRUE, GDK_BUTTON_PRESS_MASK, NULL, NULL, CurrentTime);
  325. PopupIsMapped = True;
  326. }
  327. -
  328. +/*
  329. void
  330. popup_vol_changed_cb (GtkAdjustment *adj, gpointer data)
  331. {
  332. int value;
  333. MBTrayApp *app = (MBTrayApp *)data;
  334. -
  335. mb_tray_app_repaint(app);
  336. }
  337. +*/
  338. void
  339. popup_init(MBTrayApp *app)
  340. {
  341. - GtkWidget *vbox;
  342. - GtkWidget *hbox;
  343. - GtkWidget *label;
  344. - GtkWidget *button_mute, *button_ok;
  345. - GtkAdjustment *adj;
  346. -
  347. cards_window = gtk_window_new (GTK_WINDOW_POPUP);
  348. g_signal_connect (G_OBJECT (cards_window), "button-press-event", G_CALLBACK (cards_clicked), NULL);
  349. @@ -412,8 +408,6 @@
  350. gtk_widget_realize (cards_window);
  351. }
  352. -
  353. -
  354. GdkFilterReturn
  355. event_filter (GdkXEvent *xev, GdkEvent *gev, gpointer data)
  356. {
  357. @@ -430,7 +424,6 @@
  358. static gboolean
  359. cards_timeout_cb (MBTrayApp *app)
  360. {
  361. -
  362. mb_tray_app_repaint(app);
  363. return TRUE;
  364. @@ -451,40 +444,39 @@
  365. #endif
  366. /* XXX check for err_str here */
  367. -
  368. app = mb_tray_app_new_with_display ( "CF/SD Monitor",
  369. - resize_callback,
  370. - paint_callback,
  371. - &argc,
  372. - &argv,
  373. - GDK_DISPLAY ());
  374. -
  375. - if (!app) exit(0);
  376. -
  377. - pb = mb_pixbuf_new(mb_tray_app_xdisplay(app),
  378. - mb_tray_app_xscreen(app));
  379. -
  380. + resize_callback,
  381. + paint_callback,
  382. + &argc,
  383. + &argv,
  384. + GDK_DISPLAY ());
  385. +
  386. + if (!app) exit(0);
  387. +
  388. + pb = mb_pixbuf_new(mb_tray_app_xdisplay(app),
  389. + mb_tray_app_xscreen(app));
  390. +
  391. mb_tray_app_set_theme_change_callback (app, theme_callback );
  392. mb_tray_app_set_button_callback (app, button_callback );
  393. -
  394. +
  395. gtk_timeout_add (500,
  396. - (GSourceFunc) cards_timeout_cb,
  397. - app);
  398. -
  399. + (GSourceFunc) cards_timeout_cb,
  400. + app);
  401. +
  402. load_icons();
  403. -
  404. +
  405. mb_tray_app_set_icon(app, pb, Imgs[0]);
  406. popup_init(app);
  407. mb_tray_app_main_init (app);
  408. -
  409. +
  410. gdk_window_add_filter (NULL, event_filter, (gpointer)app );
  411. -
  412. +
  413. init_buttons();
  414. -
  415. +
  416. gtk_main ();
  417. -
  418. +
  419. return 1;
  420. }