Advertisement
Guest User

ByteBowl.c

a guest
May 26th, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <gtk/gtk.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. static GtkTargetEntry target_table[] = {
  6. { "text/plain", 0, 0 }
  7. };
  8.  
  9. void target_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x,
  10. gint y, GtkSelectionData* data, guint info, guint time) {
  11. char* result = gtk_selection_data_get_text(data);
  12. printf("Data Recieved: %s\n", result);
  13. }
  14.  
  15. static void activate(GtkApplication* app, gpointer user_data)
  16. {
  17.  
  18. GtkWidget* window = gtk_application_window_new(app);
  19. gtk_window_set_title(GTK_WINDOW(window), "ByteBowl");
  20. gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
  21.  
  22. gtk_drag_dest_set(window, GTK_DEST_DEFAULT_ALL, target_table, 1, GDK_ACTION_COPY);
  23. g_signal_connect(window, "drag_data_received", G_CALLBACK(target_drag_data_received), NULL);
  24.  
  25. gtk_widget_show_all(window);
  26.  
  27. }
  28.  
  29. int main(int argc, char* argv[])
  30. {
  31.  
  32. GtkApplication* app = gtk_application_new("org.gtk.bytebowl", G_APPLICATION_FLAGS_NONE);
  33. g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
  34.  
  35. int status = g_application_run(G_APPLICATION(app), argc, argv);
  36. g_object_unref(app);
  37.  
  38. return status;
  39.  
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement