Advertisement
palmerstone

Gtk 21

Nov 29th, 2011
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.59 KB | None | 0 0
  1. #include <cairo.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <windows.h>
  5. #include <gtk/gtk.h>
  6. #include <gdk/gdk.h>
  7. #include <gtk/gtkscale.h>
  8. #include <gtk/gtkvscale.h>
  9. #include <gtk/gtkvscale.h>
  10. #include <gdk/gdkkeysyms.h>
  11. #include <gdk-pixbuf/gdk-pixbuf.h>
  12.  
  13. const int square_size = 30;
  14. float brightness_val = 0.0, contrast_val = 0.0;
  15. int global, ini, total, flag = 0, image_flag = 0, image_flag2 = 0;
  16. int width, height, heightini;
  17. char str[500], str2[500], str3[500], str4[500], str5[500], str6[500], slide[500];
  18. char image_list[5000][100];
  19.  
  20. gint offset;
  21. GtkWindow *window;
  22. GdkPixbuf *windowicon, *mypic, *result_pixbuf;
  23. GtkWidget *fixed_layout, *img, *img2, *dialog, *gbdialog, *grayscale, *brightness, *contrast, *negative;
  24. GtkButton *openbutton, *closebutton, *nextbutton, *previousbutton, *playbutton, *aboutbutton, *gotofirstbutton, *gotolastbutton, *stopbutton, *negativebutton, *greyscalebutton, *contrastbutton, *brightnessbutton, *restorebutton1, *restorebutton2, *brightnessbutton2, *contrastbutton2;
  25. GtkTooltips *opentooltip, *closetooltip, *nexttooltip, *previoustooltip, *playtooltip, *abouttooltip, *gotofirsttooltip, *gotolasttooltip, *stoptooltip, *negativetooltip, *greyscaletooltip, *contrasttooltip, *brightnesstooltip, *restoretooltip1, *restoretooltip2, *brightnesstooltip2, *contrasttooltip2;
  26.  
  27. static unsigned char apply_contrast (unsigned char u_value, float contrast);
  28. static unsigned char apply_brightness (unsigned char u_value, float brightness);
  29. static int keyboard_keys(GtkWidget *futile, GdkEventKey *lol, gpointer user_data);
  30. void create_toolbar();
  31. void show_about();
  32. void open_file();
  33. void start_slide();
  34. void stop_slide();
  35. void get_list(char filename[500]);
  36. void store_list();
  37. gboolean show_next(gpointer userdata);
  38. void show_next2();
  39. void show_previous();
  40. void image_brightness();
  41. void image_contrast();
  42. void goto_first();
  43. void goto_last();
  44. void image_negative();
  45. void increase_brightness();
  46. void decrease_brightness();
  47. void increase_contrast();
  48. void decrease_contrast();
  49. void image_greyscale();
  50. void show_original1();
  51. void show_original2();
  52. void goodbye_dialog();
  53.  
  54. void create_toolbar()
  55. {
  56. ini = 10;
  57. openbutton = gtk_button_new();
  58. opentooltip = gtk_tooltips_new();
  59. gtk_widget_set_size_request(GTK_WIDGET(openbutton), square_size, square_size);
  60. gtk_button_set_image (GTK_BUTTON(openbutton),gtk_image_new_from_stock(GTK_STOCK_ORIENTATION_PORTRAIT, GTK_ICON_SIZE_BUTTON));
  61. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(openbutton), ini, heightini - 40);
  62. gtk_tooltips_set_tip(opentooltip, GTK_WIDGET(openbutton), "Open (Ctrl+O)", "Open (Ctrl+O)");
  63.  
  64. total = (14 * 30) + (13 * 4);
  65. ini = (width - total) / 2;
  66.  
  67. brightnessbutton2 = gtk_button_new();
  68. brightnesstooltip2 = gtk_tooltips_new();
  69. gtk_widget_set_size_request(GTK_WIDGET(brightnessbutton2), square_size, square_size);
  70. gtk_button_set_image (GTK_BUTTON(brightnessbutton2),gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_BUTTON));
  71. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(brightnessbutton2), ini, heightini - 40);
  72. gtk_tooltips_set_tip(brightnesstooltip2, GTK_WIDGET(brightnessbutton2), "Decrease Brightness (-)", "Decrease Brightness (-)");
  73.  
  74. ini += 40;
  75. brightnessbutton = gtk_button_new();
  76. brightnesstooltip = gtk_tooltips_new();
  77. gtk_widget_set_size_request(GTK_WIDGET(brightnessbutton), square_size, square_size);
  78. gtk_button_set_image (GTK_BUTTON(brightnessbutton),gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_BUTTON));
  79. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(brightnessbutton), ini, heightini - 40);
  80. gtk_tooltips_set_tip(brightnesstooltip, GTK_WIDGET(brightnessbutton), "Increase Brightness (+)", "Increase Brightness (+)");
  81.  
  82. ini += 40;
  83. contrastbutton2 = gtk_button_new();
  84. contrasttooltip2 = gtk_tooltips_new();
  85. gtk_widget_set_size_request(GTK_WIDGET(contrastbutton2), square_size, square_size);
  86. gtk_button_set_image (GTK_BUTTON(contrastbutton2),gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON));
  87. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(contrastbutton2), ini, heightini - 40);
  88. gtk_tooltips_set_tip(contrasttooltip2, GTK_WIDGET(contrastbutton2), "Decrease Contrast", "Decrease Contrast");
  89.  
  90. ini += 40;
  91. contrastbutton = gtk_button_new();
  92. contrasttooltip = gtk_tooltips_new();
  93. gtk_widget_set_size_request(GTK_WIDGET(contrastbutton), square_size, square_size);
  94. gtk_button_set_image (GTK_BUTTON(contrastbutton),gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON));
  95. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(contrastbutton), ini, heightini - 40);
  96. gtk_tooltips_set_tip(contrasttooltip, GTK_WIDGET(contrastbutton), "Increase Contrast", "Increase Contrast");
  97.  
  98. ini += 40;
  99. gotofirstbutton = gtk_button_new();
  100. gotofirsttooltip = gtk_tooltips_new();
  101. gtk_widget_set_size_request(GTK_WIDGET(gotofirstbutton), square_size, square_size);
  102. gtk_button_set_image (GTK_BUTTON(gotofirstbutton),gtk_image_new_from_stock(GTK_STOCK_GOTO_FIRST, GTK_ICON_SIZE_BUTTON));
  103. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(gotofirstbutton), ini, heightini - 40);
  104. gtk_tooltips_set_tip(gotofirsttooltip, GTK_WIDGET(gotofirstbutton), "Go to first image (Page Up)", "Go to first image (Page Up)");
  105.  
  106. ini += 40;
  107. previousbutton = gtk_button_new();
  108. previoustooltip = gtk_tooltips_new();
  109. gtk_widget_set_size_request(GTK_WIDGET(previousbutton), square_size, square_size);
  110. gtk_button_set_image (GTK_BUTTON(previousbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_BUTTON));
  111. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(previousbutton), ini, heightini - 40);
  112. gtk_tooltips_set_tip(previoustooltip, GTK_WIDGET(previousbutton), "Show Previous (Left key)", "Show Previous (Left key)");
  113.  
  114. ini += 40;
  115. playbutton = gtk_button_new();
  116. playtooltip = gtk_tooltips_new();
  117. gtk_widget_set_size_request(GTK_WIDGET(playbutton), square_size, square_size);
  118. gtk_button_set_image (GTK_BUTTON(playbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON));
  119. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(playbutton), ini, heightini - 40);
  120. gtk_tooltips_set_tip(playtooltip, GTK_WIDGET(playbutton), "Start Slideshow (Spacebar)", "Start Slideshow (Spacebar)");
  121.  
  122. stopbutton = gtk_button_new();
  123. stoptooltip = gtk_tooltips_new();
  124. gtk_widget_set_size_request(GTK_WIDGET(stopbutton), square_size, square_size);
  125. gtk_button_set_image (GTK_BUTTON(stopbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON));
  126. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(stopbutton), ini, heightini - 40);
  127. gtk_tooltips_set_tip(stoptooltip, GTK_WIDGET(stopbutton), "Stop Slideshow (Spacebar)", "Stop Slideshow (Spacebar)");
  128.  
  129. ini += 40;
  130. nextbutton = gtk_button_new();
  131. nexttooltip = gtk_tooltips_new();
  132. gtk_widget_set_size_request(GTK_WIDGET(nextbutton), square_size, square_size);
  133. gtk_button_set_image (GTK_BUTTON(nextbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_NEXT, GTK_ICON_SIZE_BUTTON));
  134. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(nextbutton), ini, heightini - 40);
  135. gtk_tooltips_set_tip(nexttooltip, GTK_WIDGET(nextbutton), "Show Next (Right Key)", "Show Next (Right Key)");
  136.  
  137. ini += 40;
  138. gotolastbutton = gtk_button_new();
  139. gotolasttooltip = gtk_tooltips_new();
  140. gtk_widget_set_size_request(GTK_WIDGET(gotolastbutton), square_size, square_size);
  141. gtk_button_set_image (GTK_BUTTON(gotolastbutton),gtk_image_new_from_stock(GTK_STOCK_GOTO_LAST, GTK_ICON_SIZE_BUTTON));
  142. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(gotolastbutton), ini, heightini - 40);
  143. gtk_tooltips_set_tip(gotolasttooltip, GTK_WIDGET(gotolastbutton), "Go to last image (Page Down)", "Go to last image (Page Down)");
  144.  
  145. ini += 40;
  146. negativebutton = gtk_button_new();
  147. negativetooltip = gtk_tooltips_new();
  148. gtk_widget_set_size_request(GTK_WIDGET(negativebutton), square_size, square_size);
  149. gtk_button_set_image (GTK_BUTTON(negativebutton),gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_BUTTON));
  150. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(negativebutton), ini, heightini - 40);
  151. gtk_tooltips_set_tip(negativetooltip, GTK_WIDGET(negativebutton), "Show Negative (Ctrl+N)", "Show Negative (Ctrl+N)");
  152.  
  153. restorebutton1 = gtk_button_new();
  154. restoretooltip1 = gtk_tooltips_new();
  155. gtk_widget_set_size_request(GTK_WIDGET(restorebutton1), square_size, square_size);
  156. gtk_button_set_image (GTK_BUTTON(restorebutton1),gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
  157. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(restorebutton1), ini, heightini - 40);
  158. gtk_tooltips_set_tip(restoretooltip1, GTK_WIDGET(restorebutton1), "Restore", "Restore");
  159.  
  160. ini += 40;
  161. greyscalebutton = gtk_button_new();
  162. greyscaletooltip = gtk_tooltips_new();
  163. gtk_widget_set_size_request(GTK_WIDGET(greyscalebutton), square_size, square_size);
  164. gtk_button_set_image (GTK_BUTTON(greyscalebutton),gtk_image_new_from_stock(GTK_STOCK_CONNECT, GTK_ICON_SIZE_BUTTON));
  165. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(greyscalebutton), ini, heightini - 40);
  166. gtk_tooltips_set_tip(greyscaletooltip, GTK_WIDGET(greyscalebutton), "Show Greyscale Image (Ctrl+G)", "Show Greyscale Image (Ctrl+G)");
  167.  
  168. restorebutton2 = gtk_button_new();
  169. restoretooltip2 = gtk_tooltips_new();
  170. gtk_widget_set_size_request(GTK_WIDGET(restorebutton2), square_size, square_size);
  171. gtk_button_set_image (GTK_BUTTON(restorebutton2),gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
  172. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(restorebutton2), ini, heightini - 40);
  173. gtk_tooltips_set_tip(restoretooltip2, GTK_WIDGET(restorebutton2), "Restore", "Restore");
  174.  
  175. ini = width - 40;
  176. closebutton = gtk_button_new();
  177. closetooltip = gtk_tooltips_new();
  178. gtk_widget_set_size_request(GTK_WIDGET(closebutton), square_size, square_size);
  179. gtk_button_set_image (GTK_BUTTON(closebutton),gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON));
  180. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(closebutton), ini, heightini - 40);
  181. gtk_tooltips_set_tip(closetooltip, GTK_WIDGET(closebutton), "Close :( (Ctrl+Q)", "Close :( (Ctrl+Q)");
  182.  
  183. ini -= 40;
  184. aboutbutton = gtk_button_new();
  185. abouttooltip = gtk_tooltips_new();
  186. gtk_widget_set_size_request(GTK_WIDGET(aboutbutton), square_size, square_size);
  187. gtk_button_set_image (GTK_BUTTON(aboutbutton),gtk_image_new_from_stock(GTK_STOCK_INFO, GTK_ICON_SIZE_BUTTON));
  188. gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(aboutbutton), ini, heightini - 40);
  189. gtk_tooltips_set_tip(abouttooltip, GTK_WIDGET(aboutbutton), "About Us :)", "About Us :)");
  190.  
  191.  
  192. }
  193.  
  194.  
  195.  
  196. void show_about()
  197. {
  198. GtkWidget *dialog;
  199. const char copyright[] = "Copyright @ Fireflight TM, 2011. All rights reserved.";
  200. const char *author[] = {"Scape", "mr.rana", "(And special thanks to Mehedi Hasan and Shadman Shadab)", "", "Contact information: sgtlaugh@gmail.com",NULL};
  201. dialog = gtk_about_dialog_new();
  202. gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(dialog),"Firedlight Image Viewer v1.052 (beta)");
  203. gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(dialog),author);
  204. gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog), copyright);
  205. gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(dialog),"A free image viewer :)");
  206. windowicon = gdk_pixbuf_new_from_file(slide, NULL);
  207. gtk_window_set_icon(GTK_WINDOW(dialog), windowicon);
  208. gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
  209. gtk_dialog_run(GTK_DIALOG(dialog));
  210. gtk_widget_destroy(dialog);
  211. }
  212.  
  213. void open_file()
  214. {
  215. char *filename;
  216. dialog = gtk_file_chooser_dialog_new ("Open File",window,GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,NULL);
  217. if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
  218. {
  219. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  220. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  221. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  222. filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
  223. strcpy(slide, filename);
  224. get_list(filename);
  225. store_list();
  226. system(str2);
  227. img = gtk_image_new_from_file(filename);
  228. img2 = img;
  229. mypic = gdk_pixbuf_new_from_file(filename, NULL);
  230. windowicon = gdk_pixbuf_new_from_file(filename, NULL);
  231. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  232. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  233. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  234. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  235. gtk_widget_show(img);
  236. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  237. g_free (filename);
  238. }
  239. gtk_widget_destroy (dialog);
  240. }
  241.  
  242. void image_greyscale()
  243. {
  244. image_flag = 0;
  245. GtkWidget *img;
  246. gtk_widget_hide(GTK_WIDGET(greyscalebutton));
  247. gtk_widget_show(GTK_WIDGET(restorebutton2));
  248.  
  249. if (image_flag2 == 0)
  250. {
  251. char *sp, *dp;
  252. int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
  253.  
  254. result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
  255. gdk_pixbuf_get_has_alpha (mypic),
  256. gdk_pixbuf_get_bits_per_sample (mypic),
  257. gdk_pixbuf_get_width (mypic),
  258. gdk_pixbuf_get_height (mypic));
  259.  
  260. localwidth = gdk_pixbuf_get_width (result_pixbuf);
  261. localheight = gdk_pixbuf_get_height (result_pixbuf);
  262. result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
  263. mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
  264. bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
  265.  
  266. sp = gdk_pixbuf_get_pixels (mypic);
  267. dp = gdk_pixbuf_get_pixels (result_pixbuf);
  268. for (line = 0; line < localheight; line ++)
  269. {
  270. char *sq = sp;
  271. char *dq = dp;
  272. int i;
  273.  
  274. for (i = 0; i < localwidth; i ++)
  275. {
  276. dq[0] = (sq[0] + sq[1] + sq[2]) / 10;
  277. dq[1] = dq[0];
  278. dq[2] = dq[0];
  279.  
  280. dq += bytes_per_pixel;
  281. sq += bytes_per_pixel;
  282. }
  283.  
  284. sp += mypic_rowstride;
  285. dp += result_rowstride;
  286. }
  287. }
  288. img = gtk_image_new();
  289. result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
  290. gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
  291. gtk_widget_show(img);
  292. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  293. image_flag2 = 1;
  294. }
  295.  
  296. void show_original2()
  297. {
  298. GtkWidget *img3;
  299. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img2));
  300. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  301. img3 = gtk_image_new();
  302. gtk_image_set_from_pixbuf(GTK_IMAGE(img3), pixbuf);
  303. gtk_widget_show(img3);
  304. gtk_container_add(GTK_CONTAINER(fixed_layout), img3);
  305. gtk_widget_hide(GTK_WIDGET(restorebutton2));
  306. gtk_widget_show(GTK_WIDGET(greyscalebutton));
  307. }
  308.  
  309. void image_negative()
  310. {
  311. image_flag2 = 0;
  312. GtkWidget *img;
  313. gtk_widget_hide(GTK_WIDGET(negativebutton));
  314. gtk_widget_show(GTK_WIDGET(restorebutton1));
  315.  
  316. if (image_flag == 0)
  317. {
  318. char *sp, *dp;
  319. int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
  320.  
  321. result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
  322. gdk_pixbuf_get_has_alpha (mypic),
  323. gdk_pixbuf_get_bits_per_sample (mypic),
  324. gdk_pixbuf_get_width (mypic),
  325. gdk_pixbuf_get_height (mypic));
  326.  
  327. localwidth = gdk_pixbuf_get_width (result_pixbuf);
  328. localheight = gdk_pixbuf_get_height (result_pixbuf);
  329. result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
  330. mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
  331. bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
  332.  
  333. sp = gdk_pixbuf_get_pixels (mypic);
  334. dp = gdk_pixbuf_get_pixels (result_pixbuf);
  335.  
  336. for (line = 0; line < localheight; line++)
  337. {
  338. char *sq = sp;
  339. char *dq = dp;
  340. int i;
  341.  
  342. for (i = 0; i < localwidth; i++)
  343. {
  344. dq[0] = 255 - sq[0];
  345. dq[1] = 255 - sq[1];
  346. dq[2] = 255 - sq[2];
  347.  
  348. dq += bytes_per_pixel;
  349. sq += bytes_per_pixel;
  350. }
  351.  
  352. sp += mypic_rowstride;
  353. dp += result_rowstride;
  354. }
  355. }
  356. img = gtk_image_new();
  357. result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
  358. gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
  359. gtk_widget_show(img);
  360. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  361. image_flag = 1;
  362. }
  363.  
  364. void show_original1()
  365. {
  366. GtkWidget *img3;
  367. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img2));
  368. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  369. img3 = gtk_image_new();
  370. gtk_image_set_from_pixbuf(GTK_IMAGE(img3), pixbuf);
  371. gtk_widget_show(img3);
  372. gtk_container_add(GTK_CONTAINER(fixed_layout), img3);
  373. gtk_widget_hide(GTK_WIDGET(restorebutton1));
  374. gtk_widget_show(GTK_WIDGET(negativebutton));
  375. }
  376.  
  377. static unsigned char apply_brightness (unsigned char u_value, float brightness)
  378. {
  379. float nvalue, value;
  380. double power;
  381.  
  382. value = (float) u_value / 255.0;
  383.  
  384. if (brightness < 0.0) value = value * (1.0 + brightness);
  385. else value = value + ((1.0 - value) * brightness);
  386.  
  387. return (guchar) (value * 255);
  388. }
  389.  
  390. static unsigned char apply_contrast (unsigned char u_value, float contrast)
  391. {
  392. float nvalue;
  393. double power;
  394. float value;
  395. value = (float) u_value / 255.0;
  396.  
  397. if (contrast < 0.0)
  398. {
  399. if (value > 0.5) nvalue = 1.0 - value;
  400. else nvalue = value;
  401.  
  402. if (nvalue < 0.0) nvalue = 0.0;
  403. nvalue = 0.5 * pow (nvalue * 2.0 , (double) (1.0 + contrast));
  404.  
  405. if (value > 0.5) value = 1.0 - nvalue;
  406. else value = nvalue;
  407. }
  408. else
  409. {
  410. if (value > 0.5) nvalue = 1.0 - value;
  411. else nvalue = value;
  412.  
  413. if (nvalue < 0.0) nvalue = 0.0;
  414. power = (contrast == 1.0) ? 127 : 1.0 / (1.0 - contrast);
  415. nvalue = 0.5 * pow (2.0 * nvalue, power);
  416. if (value > 0.5) value = 1.0 - nvalue;
  417. else value = nvalue;
  418. }
  419. return (guchar) (value * 255);
  420. }
  421.  
  422. void image_contrast()
  423. {
  424. GtkWidget *img;
  425. GdkPixbuf *result_pixbuf;
  426. char *sp, *dp;
  427. int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
  428. g_return_val_if_fail ((contrast_val > -1.0 ) && (contrast_val < 1.0 ), NULL);
  429.  
  430. result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
  431. gdk_pixbuf_get_has_alpha (mypic),
  432. gdk_pixbuf_get_bits_per_sample (mypic),
  433. gdk_pixbuf_get_width (mypic),
  434. gdk_pixbuf_get_height (mypic));
  435.  
  436. localwidth = gdk_pixbuf_get_width (result_pixbuf);
  437. localheight = gdk_pixbuf_get_height (result_pixbuf);
  438. result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
  439. mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
  440. bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
  441. sp = gdk_pixbuf_get_pixels (mypic);
  442. dp = gdk_pixbuf_get_pixels (result_pixbuf);
  443.  
  444. for (line = 0; line < localheight; line ++)
  445. {
  446. char *sq = sp;
  447. char *dq = dp;
  448. int i;
  449.  
  450. for (i = 0; i < localwidth; i ++)
  451. {
  452. dq[0] = apply_contrast (sq[0], contrast_val);
  453. dq[1] = apply_contrast (sq[1], contrast_val);
  454. dq[2] = apply_contrast (sq[2], contrast_val);
  455. dq += bytes_per_pixel;
  456. sq += bytes_per_pixel;
  457. }
  458. sp += mypic_rowstride;
  459. dp += result_rowstride;
  460. }
  461.  
  462. img = gtk_image_new();
  463. result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
  464. gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
  465. gtk_widget_show(img);
  466. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  467. }
  468.  
  469. void image_brightness()
  470. {
  471. GtkWidget *img;
  472. char *sp, *dp;
  473. int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
  474.  
  475. g_return_val_if_fail ((brightness_val > -1.0 ) && (brightness_val < 1.0 ), NULL);
  476. result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
  477. gdk_pixbuf_get_has_alpha (mypic),
  478. gdk_pixbuf_get_bits_per_sample (mypic),
  479. gdk_pixbuf_get_width (mypic),
  480. gdk_pixbuf_get_height (mypic));
  481.  
  482. localwidth = gdk_pixbuf_get_width (result_pixbuf);
  483. localheight = gdk_pixbuf_get_height (result_pixbuf);
  484. result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
  485. mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
  486. bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
  487. sp = gdk_pixbuf_get_pixels (mypic);
  488. dp = gdk_pixbuf_get_pixels (result_pixbuf);
  489.  
  490. for (line = 0; line < localheight; line ++)
  491. {
  492. char *sq = sp;
  493. char *dq = dp;
  494. int i;
  495.  
  496. for (i = 0; i < localwidth; i ++)
  497. {
  498. dq[0] = apply_brightness (sq[0], brightness_val);
  499. dq[1] = apply_brightness (sq[1], brightness_val);
  500. dq[2] = apply_brightness (sq[2], brightness_val);
  501. dq += bytes_per_pixel;
  502. sq += bytes_per_pixel;
  503. }
  504. sp += mypic_rowstride;
  505. dp += result_rowstride;
  506. }
  507. img = gtk_image_new();
  508. result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
  509. gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
  510. gtk_widget_show(img);
  511. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  512. }
  513.  
  514. static int keyboard_keys(GtkWidget *futile, GdkEventKey *lol, gpointer user_data)
  515. {
  516. printf("%d\n", lol->keyval);
  517. if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_q)
  518. goodbye_dialog();
  519. if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_o)
  520. open_file();
  521. if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_n)
  522. image_negative();
  523. if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_g)
  524. image_greyscale();
  525. if (lol->keyval == GDK_KEY_Right)
  526. show_next2();
  527. if (lol->keyval == GDK_KEY_Left)
  528. show_previous();
  529. if (lol->keyval == GDK_KEY_space)
  530. {
  531. if (flag == 0) flag = 1;
  532. else flag = 0;
  533. if (flag == 1) start_slide();
  534. else stop_slide();
  535. }
  536. if (lol->keyval == GDK_KEY_Page_Up)
  537. goto_first();
  538. if (lol->keyval == GDK_KEY_Page_Down)
  539. goto_last();
  540. if (lol->keyval == 65451 || lol->keyval == GDK_KEY_plus)
  541. increase_brightness();
  542. if (lol->keyval == 65453 || lol->keyval == GDK_KEY_minus)
  543. decrease_brightness();
  544. return TRUE;
  545. }
  546.  
  547.  
  548. void start_slide()
  549. {
  550. if (flag == 0)
  551. {
  552. gint func_ref = g_timeout_add(3000, show_next, (gpointer)32);
  553. gtk_widget_hide(GTK_WIDGET(playbutton));
  554. gtk_widget_hide(GTK_WIDGET(openbutton));
  555. gtk_widget_hide(GTK_WIDGET(closebutton));
  556. gtk_widget_hide(GTK_WIDGET(gotofirstbutton));
  557. gtk_widget_hide(GTK_WIDGET(gotolastbutton));
  558. gtk_widget_hide(GTK_WIDGET(nextbutton));
  559. gtk_widget_hide(GTK_WIDGET(previousbutton));
  560. gtk_widget_hide(GTK_WIDGET(aboutbutton));
  561. gtk_widget_hide(GTK_WIDGET(negativebutton));
  562. gtk_widget_hide(GTK_WIDGET(restorebutton1));
  563. gtk_widget_hide(GTK_WIDGET(restorebutton2));
  564. gtk_widget_hide(GTK_WIDGET(greyscalebutton));
  565. gtk_widget_hide(GTK_WIDGET(contrastbutton));
  566. gtk_widget_hide(GTK_WIDGET(contrastbutton2));
  567. gtk_widget_hide(GTK_WIDGET(brightnessbutton));
  568. gtk_widget_hide(GTK_WIDGET(brightnessbutton2));
  569. gtk_widget_show(GTK_WIDGET(stopbutton));
  570. }
  571. flag = 1;
  572.  
  573. }
  574.  
  575. void stop_slide()
  576. {
  577. flag = 0;
  578. //gint func_ref = g_timeout_add(10000000, show_next, (gpointer)32);
  579. img2 = img;
  580. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  581. gtk_widget_hide(GTK_WIDGET(stopbutton));
  582. gtk_widget_show(GTK_WIDGET(playbutton));
  583. gtk_widget_show(GTK_WIDGET(openbutton));
  584. gtk_widget_show(GTK_WIDGET(closebutton));
  585. gtk_widget_show(GTK_WIDGET(gotofirstbutton));
  586. gtk_widget_show(GTK_WIDGET(gotolastbutton));
  587. gtk_widget_show(GTK_WIDGET(nextbutton));
  588. gtk_widget_show(GTK_WIDGET(previousbutton));
  589. gtk_widget_show(GTK_WIDGET(negativebutton));
  590. gtk_widget_show(GTK_WIDGET(greyscalebutton));
  591. gtk_widget_show(GTK_WIDGET(contrastbutton));
  592. gtk_widget_show(GTK_WIDGET(contrastbutton2));
  593. gtk_widget_show(GTK_WIDGET(brightnessbutton));
  594. gtk_widget_show(GTK_WIDGET(brightnessbutton2));
  595. gtk_widget_show(GTK_WIDGET(aboutbutton));
  596. }
  597.  
  598. void get_list(char filename[500])
  599. {
  600. int k = 0, j, l = 0, x;
  601. int len = strlen(filename);
  602. for (j = len - 1; filename[j] != '\\'; j--) x = 1;
  603. str[0] = 0;
  604. strcat(str, "cd /d ");
  605. for (k = 0; k < j; k++) str4[l++] = filename[k];
  606. str4[l] = 0;
  607. str3[0] = filename[0], str3[1] = filename[1], str3[2] = 0;
  608. system(str3);
  609. strcat(str, str4);
  610. strcpy(str2, str);
  611. strcat(str, " && dir /b >> dir_listing.txt");
  612. strcat(str2, " && del dir_listing.txt");
  613. system(str);
  614. strcat(str4, "\\dir_listing.txt");
  615. }
  616.  
  617. void store_list()
  618. {
  619. FILE *input;
  620. input = fopen(str4, "r");
  621. for (global = 0; ;global++)
  622. {
  623. if (fscanf(input, "%[^\n]", image_list[global]) == EOF) break;
  624. fgetc(input);
  625. }
  626. fclose(input);
  627. }
  628.  
  629. gboolean show_next(gpointer userdata)
  630. {
  631. if (flag == 0) return FALSE;
  632. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  633. for (; ;)
  634. {
  635. for (i = 0; i < global; i++)
  636. {
  637. strcpy(str3, image_list[i]);
  638. l = 0, len = strlen(slide);
  639. str5[0] = 0;
  640. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  641. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  642. str5[l] = 0, k = 0;
  643. strcat(str5, str3), len = strlen(str3);
  644. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  645. str6[k] = 0;
  646. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  647. {
  648. if (flag2 == 1)
  649. {
  650. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  651. img = gtk_image_new_from_file(str5);
  652. //img2 = img;
  653. // mypic = gdk_pixbuf_new_from_file(str5, NULL);
  654. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  655. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  656. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  657. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  658. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  659. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  660. gtk_widget_show(img);
  661. strcpy(slide, str5);
  662. flag3 = 1;
  663. break;
  664.  
  665. }
  666. if (strcmp(str5, slide) == 0) flag2 = 1;
  667. }
  668. }
  669. if (flag3 == 1) break;
  670. }
  671. return TRUE;
  672. }
  673.  
  674. void show_next2()
  675. {
  676. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  677. for (; ;)
  678. {
  679. for (i = 0; i < global; i++)
  680. {
  681. strcpy(str3, image_list[i]);
  682. l = 0, len = strlen(slide);
  683. str5[0] = 0;
  684. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  685. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  686. str5[l] = 0, k = 0;
  687. strcat(str5, str3), len = strlen(str3);
  688. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  689. str6[k] = 0;
  690. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  691. {
  692. if (flag2 == 1)
  693. {
  694. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  695. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  696. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  697. img = gtk_image_new_from_file(str5);
  698. img2 = img;
  699. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  700. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  701. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  702. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  703. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  704. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  705. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  706. gtk_widget_show(img);
  707. strcpy(slide, str5);
  708. flag3 = 1;
  709. break;
  710.  
  711. }
  712. if (strcmp(str5, slide) == 0) flag2 = 1;
  713. }
  714. }
  715. if (flag3 == 1) break;
  716. }
  717. }
  718.  
  719. void show_previous()
  720. {
  721. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  722. for (; ;)
  723. {
  724. for (i = global - 1; i >= 0; i--)
  725. {
  726. strcpy(str3, image_list[i]);
  727. l = 0, len = strlen(slide);
  728. str5[0] = 0;
  729. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  730. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  731. str5[l] = 0, k = 0;
  732. strcat(str5, str3), len = strlen(str3);
  733. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  734. str6[k] = 0;
  735. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  736. {
  737. if (flag2 == 1)
  738. {
  739. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  740. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  741. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  742. img = gtk_image_new_from_file(str5);
  743. img2 = img;
  744. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  745. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  746. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  747. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  748. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  749. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  750. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  751. gtk_widget_show(img);
  752. strcpy(slide, str5);
  753. flag3 = 1;
  754. break;
  755.  
  756. }
  757. if (strcmp(str5, slide) == 0) flag2 = 1;
  758. }
  759. }
  760. if (flag3 == 1) break;
  761. }
  762. }
  763.  
  764. void goto_first()
  765. {
  766. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  767. for (i = 0; i < global; i++)
  768. {
  769. strcpy(str3, image_list[i]);
  770. l = 0, len = strlen(slide);
  771. str5[0] = 0;
  772. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  773. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  774. str5[l] = 0, k = 0;
  775. strcat(str5, str3), len = strlen(str3);
  776. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  777. str6[k] = 0;
  778. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  779. {
  780. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  781. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  782. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  783. img = gtk_image_new_from_file(str5);
  784. img2 = img;
  785. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  786. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  787. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  788. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  789. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  790. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  791. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  792. gtk_widget_show(img);
  793. strcpy(slide, str5);
  794. flag3 = 1;
  795. break;
  796. }
  797. }
  798. }
  799.  
  800. void increase_brightness()
  801. {
  802. if (brightness_val == 1.0) brightness_val = 0.999;
  803. if (brightness_val <= 1.0)
  804. {
  805. brightness_val += 0.10;
  806. image_brightness();
  807. }
  808. }
  809.  
  810. void decrease_brightness()
  811. {
  812. if (brightness_val == -1.0) brightness_val = -0.999;
  813. if(brightness_val >= -1.0)
  814. {
  815. brightness_val -= 0.10;
  816. image_brightness();
  817. }
  818.  
  819. }
  820.  
  821. void increase_contrast()
  822. {
  823. if (contrast_val == 1.0) contrast_val = 0.999;
  824. if (contrast_val <= 1.0)
  825. {
  826. contrast_val += 0.10;
  827. image_contrast();
  828. }
  829. }
  830.  
  831. void decrease_contrast()
  832. {
  833. if (contrast_val == -1.0) contrast_val = -0.999;
  834. if(contrast_val >= -1.0)
  835. {
  836. contrast_val -= 0.10;
  837. image_contrast();
  838. }
  839.  
  840. }
  841.  
  842. void goto_last()
  843. {
  844. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  845. for (i = global - 1; i >= 0; i--)
  846. {
  847. strcpy(str3, image_list[i]);
  848. l = 0, len = strlen(slide);
  849. str5[0] = 0;
  850. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  851. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  852. str5[l] = 0, k = 0;
  853. strcat(str5, str3), len = strlen(str3);
  854. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  855. str6[k] = 0;
  856. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  857. {
  858. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  859. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  860. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  861. img = gtk_image_new_from_file(str5);
  862. img2 = img;
  863. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  864. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  865. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  866. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  867. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  868. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  869. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  870. gtk_widget_show(img);
  871. strcpy(slide, str5);
  872. flag3 = 1;
  873. break;
  874. }
  875. }
  876. }
  877.  
  878. void goodbye_dialog()
  879. {
  880. gbdialog = gtk_message_dialog_new (GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Thank you for using this application!\nPlease click Ok to exit.");
  881. gtk_window_set_position (GTK_WINDOW (gbdialog), GTK_WIN_POS_CENTER);
  882. gtk_dialog_run (GTK_DIALOG (gbdialog));
  883. gtk_widget_destroy (gbdialog);
  884. gtk_main_quit();
  885. }
  886.  
  887. int main(int argc, char *argv[])
  888. {
  889. gtk_init(&argc, &argv);
  890. width = gdk_screen_width();
  891. height = gdk_screen_height();
  892. window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  893. gtk_window_set_skip_taskbar_hint (window, TRUE);
  894. gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
  895. gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
  896. gtk_widget_set_size_request(GTK_WIDGET(window), width, height);
  897. gtk_window_set_title(GTK_WINDOW(window), "Fireflight Image Viewer 1.052");
  898. heightini = height;
  899. height = (height * 16) / 17;
  900.  
  901. fixed_layout = gtk_fixed_new();
  902. char picturename[] = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg";
  903. img = gtk_image_new_from_file(picturename);
  904. img2 = img;
  905. mypic = gdk_pixbuf_new_from_file(picturename, NULL);
  906. windowicon = gdk_pixbuf_new_from_file(picturename, NULL);
  907. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  908. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  909. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  910. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  911. strcpy(slide, picturename);
  912. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  913. create_toolbar();
  914. gtk_container_add(GTK_CONTAINER(window), fixed_layout);
  915. get_list(picturename);
  916. store_list();
  917. system(str2);
  918.  
  919. gtk_window_fullscreen(window);
  920. g_signal_connect(G_OBJECT(window), "delete-event",G_CALLBACK(gtk_main_quit), NULL);
  921. g_signal_connect(G_OBJECT(openbutton), "clicked", G_CALLBACK(open_file), NULL);
  922. g_signal_connect(G_OBJECT(gotofirstbutton), "clicked", G_CALLBACK(goto_first), NULL);
  923. g_signal_connect(G_OBJECT(gotolastbutton), "clicked", G_CALLBACK(goto_last), NULL);
  924. g_signal_connect(G_OBJECT(aboutbutton), "clicked", G_CALLBACK(show_about), NULL);
  925. g_signal_connect(G_OBJECT(closebutton), "clicked",G_CALLBACK(goodbye_dialog), NULL);
  926. g_signal_connect(G_OBJECT(playbutton), "clicked",G_CALLBACK(start_slide), NULL);
  927. g_signal_connect(G_OBJECT(stopbutton), "clicked",G_CALLBACK(stop_slide), NULL);
  928. g_signal_connect(G_OBJECT(nextbutton), "clicked",G_CALLBACK(show_next2), NULL);
  929. g_signal_connect(G_OBJECT(negativebutton), "clicked",G_CALLBACK(image_negative), NULL);
  930. g_signal_connect(G_OBJECT(brightnessbutton), "clicked",G_CALLBACK(increase_brightness), NULL);
  931. g_signal_connect(G_OBJECT(contrastbutton), "clicked",G_CALLBACK(increase_contrast), NULL);
  932. g_signal_connect(G_OBJECT(brightnessbutton2), "clicked",G_CALLBACK(decrease_brightness), NULL);
  933. g_signal_connect(G_OBJECT(contrastbutton2), "clicked",G_CALLBACK(decrease_contrast), NULL);
  934. g_signal_connect(G_OBJECT(restorebutton1), "clicked",G_CALLBACK(show_original1), NULL);
  935. g_signal_connect(G_OBJECT(restorebutton2), "clicked",G_CALLBACK(show_original2), NULL);
  936. g_signal_connect(G_OBJECT(greyscalebutton), "clicked",G_CALLBACK(image_greyscale), NULL);
  937. g_signal_connect(G_OBJECT(previousbutton), "clicked",G_CALLBACK(show_previous), NULL);
  938. g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(keyboard_keys), (gpointer)window);
  939. gtk_widget_show_all(GTK_WIDGET(window));
  940. gtk_widget_hide(GTK_WIDGET(stopbutton)), gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  941. gtk_main();
  942.  
  943. return 0x0;
  944. }
  945.  
  946.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement