Advertisement
palmerstone

Gtk 19

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