Branch
Hash :
adb9e235
Author :
Thomas de Grivel
Date :
2023-01-14T18:26:30
license
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
/* rtbuf
* Copyright 2018-2023 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software excepted
* on Apple computers granted the above copyright notice and
* this permission paragraph are included in all copies and
* substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include <assert.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include "../librtbuf/rtbuf.h"
#include "rtbuf_gtk3.h"
#include "rtbuf_gtk3_input_widget.h"
void rtbuf_gtk_input_disconnect (RtbufInputWidget *widget)
{
s_rtbuf *rtbuf;
unsigned int in;
printf("rtbuf-gtk input disconnect\n");
rtbuf = rtbuf_input_widget_get_rtbuf(widget);
in = rtbuf_input_widget_get_in(widget);
rtbuf_in_unbind(rtbuf, in);
}
void rtbuf_gtk_input_menu (RtbufInputWidget *widget, GdkEvent *event)
{
static GtkMenu *menu = 0;
static GtkWidget *disconnect;
static guint signal;
printf("rtbuf-gtk input menu\n");
if (!menu) {
signal = g_signal_lookup("activate", GTK_TYPE_MENU_ITEM);
assert(signal);
menu = GTK_MENU(gtk_menu_new());
disconnect = gtk_menu_item_new_with_label("Disconnect");
gtk_container_add(GTK_CONTAINER(menu), disconnect);
gtk_widget_show(disconnect);
}
g_signal_handlers_disconnect_matched(G_OBJECT(disconnect),
G_SIGNAL_MATCH_FUNC,
signal,
0,
NULL,
(void*) G_CALLBACK(rtbuf_gtk_input_disconnect),
NULL);
g_signal_connect_swapped(G_OBJECT(disconnect), "activate",
G_CALLBACK(rtbuf_gtk_input_disconnect),
widget);
gtk_menu_popup_at_pointer(menu, event);
}
gboolean rtbuf_gtk_input_button_press (RtbufInputWidget *widget,
GdkEvent *event)
{
printf("rtbuf-gtk input check button press\n");
if (event->type == GDK_BUTTON_PRESS) {
GdkEventButton *eb = (GdkEventButton*) event;
if (eb->button == 1) {
if (drag_connection)
rtbuf_gtk_drag_connection_end(widget);
return TRUE;
}
else if (eb->button == 3) {
rtbuf_gtk_input_menu(widget, event);
return TRUE;
}
}
return FALSE;
}