Advertisement
palmerstone

Gtk 20

Nov 29th, 2011
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.29 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. if (lol->state == GDK_CONTROL_MASK && (lol->keyval == GDK_KEY_q || lol->keyval == GDK_KEY_Q))
  517. goodbye_dialog();
  518. if (lol->state == GDK_CONTROL_MASK && (lol->keyval == GDK_KEY_O || lol->keyval == GDK_KEY_o))
  519. open_file();
  520. if (lol->state == GDK_CONTROL_MASK && (lol->keyval == GDK_KEY_N || lol->keyval == GDK_KEY_n))
  521. image_negative();
  522. if (lol->state == GDK_CONTROL_MASK && (lol->keyval == GDK_KEY_G || lol->keyval == GDK_KEY_g))
  523. image_greyscale();
  524. if (lol->keyval == GDK_KEY_Right)
  525. show_next2();
  526. if (lol->keyval == GDK_KEY_Left)
  527. show_previous();
  528. if (lol->keyval == GDK_KEY_space)
  529. {
  530. if (flag == 0) flag = 1;
  531. else flag = 0;
  532. if (flag == 1) start_slide();
  533. else stop_slide();
  534. }
  535. if (lol->keyval == GDK_KEY_Page_Up)
  536. goto_first();
  537. if (lol->keyval == GDK_KEY_Page_Down)
  538. goto_last();
  539. return TRUE;
  540. }
  541.  
  542.  
  543. void start_slide()
  544. {
  545. flag = 1;
  546. gint func_ref = g_timeout_add(3000, show_next, (gpointer)32);
  547. gtk_widget_hide(GTK_WIDGET(playbutton));
  548. gtk_widget_hide(GTK_WIDGET(openbutton));
  549. gtk_widget_hide(GTK_WIDGET(closebutton));
  550. gtk_widget_hide(GTK_WIDGET(gotofirstbutton));
  551. gtk_widget_hide(GTK_WIDGET(gotolastbutton));
  552. gtk_widget_hide(GTK_WIDGET(nextbutton));
  553. gtk_widget_hide(GTK_WIDGET(previousbutton));
  554. gtk_widget_hide(GTK_WIDGET(aboutbutton));
  555. gtk_widget_hide(GTK_WIDGET(negativebutton));
  556. gtk_widget_hide(GTK_WIDGET(restorebutton1));
  557. gtk_widget_hide(GTK_WIDGET(restorebutton2));
  558. gtk_widget_hide(GTK_WIDGET(greyscalebutton));
  559. gtk_widget_hide(GTK_WIDGET(contrastbutton));
  560. gtk_widget_hide(GTK_WIDGET(contrastbutton2));
  561. gtk_widget_hide(GTK_WIDGET(brightnessbutton));
  562. gtk_widget_hide(GTK_WIDGET(brightnessbutton2));
  563. gtk_widget_show(GTK_WIDGET(stopbutton));
  564.  
  565. }
  566.  
  567. void stop_slide()
  568. {
  569. flag = 0;
  570. gint func_ref = g_timeout_add(10000000, show_next, (gpointer)32);
  571. gtk_widget_hide(GTK_WIDGET(stopbutton));
  572. gtk_widget_show(GTK_WIDGET(playbutton));
  573. gtk_widget_show(GTK_WIDGET(openbutton));
  574. gtk_widget_show(GTK_WIDGET(closebutton));
  575. gtk_widget_show(GTK_WIDGET(gotofirstbutton));
  576. gtk_widget_show(GTK_WIDGET(gotolastbutton));
  577. gtk_widget_show(GTK_WIDGET(nextbutton));
  578. gtk_widget_show(GTK_WIDGET(previousbutton));
  579. gtk_widget_show(GTK_WIDGET(negativebutton));
  580. gtk_widget_show(GTK_WIDGET(greyscalebutton));
  581. gtk_widget_show(GTK_WIDGET(contrastbutton));
  582. gtk_widget_show(GTK_WIDGET(contrastbutton2));
  583. gtk_widget_show(GTK_WIDGET(brightnessbutton));
  584. gtk_widget_show(GTK_WIDGET(brightnessbutton2));
  585. gtk_widget_show(GTK_WIDGET(aboutbutton));
  586. }
  587.  
  588. void get_list(char filename[500])
  589. {
  590. int k = 0, j, l = 0, x;
  591. int len = strlen(filename);
  592. for (j = len - 1; filename[j] != '\\'; j--) x = 1;
  593. str[0] = 0;
  594. strcat(str, "cd /d ");
  595. for (k = 0; k < j; k++) str4[l++] = filename[k];
  596. str4[l] = 0;
  597. str3[0] = filename[0], str3[1] = filename[1], str3[2] = 0;
  598. system(str3);
  599. strcat(str, str4);
  600. strcpy(str2, str);
  601. strcat(str, " && dir /b >> dir_listing.txt");
  602. strcat(str2, " && del dir_listing.txt");
  603. system(str);
  604. strcat(str4, "\\dir_listing.txt");
  605. }
  606.  
  607. void store_list()
  608. {
  609. FILE *input;
  610. input = fopen(str4, "r");
  611. for (global = 0; ;global++)
  612. {
  613. if (fscanf(input, "%[^\n]", image_list[global]) == EOF) break;
  614. fgetc(input);
  615. }
  616. fclose(input);
  617. }
  618.  
  619. gboolean show_next(gpointer userdata)
  620. {
  621. if (flag == 0) return FALSE;
  622. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  623. for (; ;)
  624. {
  625. for (i = 0; i < global; i++)
  626. {
  627. strcpy(str3, image_list[i]);
  628. l = 0, len = strlen(slide);
  629. str5[0] = 0;
  630. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  631. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  632. str5[l] = 0, k = 0;
  633. strcat(str5, str3), len = strlen(str3);
  634. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  635. str6[k] = 0;
  636. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  637. {
  638. if (flag2 == 1)
  639. {
  640. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  641. img = gtk_image_new_from_file(str5);
  642. img2 = img;
  643. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  644. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  645. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  646. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  647. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  648. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  649. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  650. gtk_widget_show(img);
  651. strcpy(slide, str5);
  652. flag3 = 1;
  653. break;
  654.  
  655. }
  656. if (strcmp(str5, slide) == 0) flag2 = 1;
  657. }
  658. }
  659. if (flag3 == 1) break;
  660. }
  661. return TRUE;
  662. }
  663.  
  664. void show_next2()
  665. {
  666. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  667. for (; ;)
  668. {
  669. for (i = 0; i < global; i++)
  670. {
  671. strcpy(str3, image_list[i]);
  672. l = 0, len = strlen(slide);
  673. str5[0] = 0;
  674. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  675. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  676. str5[l] = 0, k = 0;
  677. strcat(str5, str3), len = strlen(str3);
  678. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  679. str6[k] = 0;
  680. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  681. {
  682. if (flag2 == 1)
  683. {
  684. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  685. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  686. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  687. img = gtk_image_new_from_file(str5);
  688. img2 = img;
  689. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  690. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  691. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  692. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  693. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  694. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  695. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  696. gtk_widget_show(img);
  697. strcpy(slide, str5);
  698. flag3 = 1;
  699. break;
  700.  
  701. }
  702. if (strcmp(str5, slide) == 0) flag2 = 1;
  703. }
  704. }
  705. if (flag3 == 1) break;
  706. }
  707. }
  708.  
  709. void show_previous()
  710. {
  711. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  712. for (; ;)
  713. {
  714. for (i = global - 1; i >= 0; i--)
  715. {
  716. strcpy(str3, image_list[i]);
  717. l = 0, len = strlen(slide);
  718. str5[0] = 0;
  719. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  720. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  721. str5[l] = 0, k = 0;
  722. strcat(str5, str3), len = strlen(str3);
  723. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  724. str6[k] = 0;
  725. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  726. {
  727. if (flag2 == 1)
  728. {
  729. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  730. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  731. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  732. img = gtk_image_new_from_file(str5);
  733. img2 = img;
  734. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  735. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  736. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  737. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  738. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  739. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  740. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  741. gtk_widget_show(img);
  742. strcpy(slide, str5);
  743. flag3 = 1;
  744. break;
  745.  
  746. }
  747. if (strcmp(str5, slide) == 0) flag2 = 1;
  748. }
  749. }
  750. if (flag3 == 1) break;
  751. }
  752. }
  753.  
  754. void goto_first()
  755. {
  756. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  757. for (i = 0; i < global; i++)
  758. {
  759. strcpy(str3, image_list[i]);
  760. l = 0, len = strlen(slide);
  761. str5[0] = 0;
  762. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  763. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  764. str5[l] = 0, k = 0;
  765. strcat(str5, str3), len = strlen(str3);
  766. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  767. str6[k] = 0;
  768. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  769. {
  770. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  771. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  772. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  773. img = gtk_image_new_from_file(str5);
  774. img2 = img;
  775. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  776. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  777. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  778. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  779. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  780. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  781. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  782. gtk_widget_show(img);
  783. strcpy(slide, str5);
  784. flag3 = 1;
  785. break;
  786. }
  787. }
  788. }
  789.  
  790. void increase_brightness()
  791. {
  792. if (brightness_val == 1.0) brightness_val = 0.999;
  793. if (brightness_val <= 1.0)
  794. {
  795. brightness_val += 0.10;
  796. image_brightness();
  797. }
  798. }
  799.  
  800. void decrease_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.  
  811. void increase_contrast()
  812. {
  813. if (contrast_val == 1.0) contrast_val = 0.999;
  814. if (contrast_val <= 1.0)
  815. {
  816. contrast_val += 0.10;
  817. image_contrast();
  818. }
  819. }
  820.  
  821. void decrease_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.  
  832. void goto_last()
  833. {
  834. int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
  835. for (i = global - 1; i >= 0; i--)
  836. {
  837. strcpy(str3, image_list[i]);
  838. l = 0, len = strlen(slide);
  839. str5[0] = 0;
  840. for (j = len - 1; slide[j] != '\\'; j--) k = 1;
  841. for (k = 0; k <= j; k++) str5[l++] = slide[k];
  842. str5[l] = 0, k = 0;
  843. strcat(str5, str3), len = strlen(str3);
  844. for (l = len - 4; l < len; l++) str6[k++] = str3[l];
  845. str6[k] = 0;
  846. if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
  847. {
  848. gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  849. gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
  850. image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
  851. img = gtk_image_new_from_file(str5);
  852. img2 = img;
  853. mypic = gdk_pixbuf_new_from_file(str5, NULL);
  854. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  855. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  856. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  857. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  858. windowicon = gdk_pixbuf_new_from_file(str5, NULL);
  859. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  860. gtk_widget_show(img);
  861. strcpy(slide, str5);
  862. flag3 = 1;
  863. break;
  864. }
  865. }
  866. }
  867.  
  868. void goodbye_dialog()
  869. {
  870. 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.");
  871. gtk_window_set_position (GTK_WINDOW (gbdialog), GTK_WIN_POS_CENTER);
  872. gtk_dialog_run (GTK_DIALOG (gbdialog));
  873. gtk_widget_destroy (gbdialog);
  874. gtk_main_quit();
  875. }
  876.  
  877. int main(int argc, char *argv[])
  878. {
  879. gtk_init(&argc, &argv);
  880. width = gdk_screen_width();
  881. height = gdk_screen_height();
  882. window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  883. gtk_window_set_skip_taskbar_hint (window, TRUE);
  884. gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
  885. gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
  886. gtk_widget_set_size_request(GTK_WIDGET(window), width, height);
  887. gtk_window_set_title(GTK_WINDOW(window), "Fireflight Image Viewer 1.052");
  888. heightini = height;
  889. height = (height * 16) / 17;
  890.  
  891. fixed_layout = gtk_fixed_new();
  892. char picturename[] = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg";
  893. img = gtk_image_new_from_file(picturename);
  894. img2 = img;
  895. mypic = gdk_pixbuf_new_from_file(picturename, NULL);
  896. windowicon = gdk_pixbuf_new_from_file(picturename, NULL);
  897. gtk_window_set_icon(GTK_WINDOW(window), windowicon);
  898. GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
  899. pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
  900. gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
  901. strcpy(slide, picturename);
  902. gtk_container_add(GTK_CONTAINER(fixed_layout), img);
  903. create_toolbar();
  904. gtk_container_add(GTK_CONTAINER(window), fixed_layout);
  905. get_list(picturename);
  906. store_list();
  907. system(str2);
  908.  
  909. gtk_window_fullscreen(window);
  910. g_signal_connect(G_OBJECT(window), "delete-event",G_CALLBACK(gtk_main_quit), NULL);
  911. g_signal_connect(G_OBJECT(openbutton), "clicked", G_CALLBACK(open_file), NULL);
  912. g_signal_connect(G_OBJECT(gotofirstbutton), "clicked", G_CALLBACK(goto_first), NULL);
  913. g_signal_connect(G_OBJECT(gotolastbutton), "clicked", G_CALLBACK(goto_last), NULL);
  914. g_signal_connect(G_OBJECT(aboutbutton), "clicked", G_CALLBACK(show_about), NULL);
  915. g_signal_connect(G_OBJECT(closebutton), "clicked",G_CALLBACK(goodbye_dialog), NULL);
  916. g_signal_connect(G_OBJECT(playbutton), "clicked",G_CALLBACK(start_slide), NULL);
  917. g_signal_connect(G_OBJECT(stopbutton), "clicked",G_CALLBACK(stop_slide), NULL);
  918. g_signal_connect(G_OBJECT(nextbutton), "clicked",G_CALLBACK(show_next2), NULL);
  919. g_signal_connect(G_OBJECT(negativebutton), "clicked",G_CALLBACK(image_negative), NULL);
  920. g_signal_connect(G_OBJECT(brightnessbutton), "clicked",G_CALLBACK(increase_brightness), NULL);
  921. g_signal_connect(G_OBJECT(contrastbutton), "clicked",G_CALLBACK(increase_contrast), NULL);
  922. g_signal_connect(G_OBJECT(brightnessbutton2), "clicked",G_CALLBACK(decrease_brightness), NULL);
  923. g_signal_connect(G_OBJECT(contrastbutton2), "clicked",G_CALLBACK(decrease_contrast), NULL);
  924. g_signal_connect(G_OBJECT(restorebutton1), "clicked",G_CALLBACK(show_original1), NULL);
  925. g_signal_connect(G_OBJECT(restorebutton2), "clicked",G_CALLBACK(show_original2), NULL);
  926. g_signal_connect(G_OBJECT(greyscalebutton), "clicked",G_CALLBACK(image_greyscale), NULL);
  927. g_signal_connect(G_OBJECT(previousbutton), "clicked",G_CALLBACK(show_previous), NULL);
  928. g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(keyboard_keys), (gpointer)window);
  929. gtk_widget_show_all(GTK_WIDGET(window));
  930. gtk_widget_hide(GTK_WIDGET(stopbutton)), gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
  931. gtk_main();
  932.  
  933. return 0x0;
  934. }
  935.  
  936.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement