Advertisement
palmerstone

Gtk 15

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