Added argument for function to set checking function for showing menu

pull/11/head
parent 1dce6e622f
commit 7a1c5b9f58

@ -917,20 +917,25 @@ GtkWidget *yon_ubl_browser_window_open(char *link, char *browser_window_name){
user=getlogin(); user=getlogin();
char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL);
yon_launch(command); yon_launch(command);
return NULL return NULL;
} }
#endif #endif
// rmb menu section // rmb menu section
gboolean on_rmb_menu_open(GtkWidget *self,GdkEventButton *event, rmb_menu_window *window){ typedef int (*RmbCheck)(void*);
if (self){};
if (event->button==3){
gtk_widget_show_all(window->menu); gboolean on_rmb_menu_open(GtkWidget *self,GdkEventButton *event, rmb_menu_window *window){
gtk_menu_popup_at_pointer(GTK_MENU(window->menu),NULL); int (*func)(void*) = (RmbCheck)(window->show_function);
if (func(window->show_data)){
if (self){};
if (event->button==3){
gtk_widget_show_all(window->menu);
gtk_menu_popup_at_pointer(GTK_MENU(window->menu),NULL);
return 0;
}
return 0; return 0;
} }
return 0;
} }
rmb_menu_window *yon_rmb_menu_new(){ rmb_menu_window *yon_rmb_menu_new(){
@ -942,9 +947,11 @@ rmb_menu_window *yon_rmb_menu_new(){
return window; return window;
} }
rmb_menu_window *yon_rmb_menu_setup(GtkWidget *target_widget, const char *button_label, const char *icon_name, GCallback function, gpointer data,...){ rmb_menu_window *yon_rmb_menu_setup(GtkWidget *target_widget, int (show_function)(void*), void *show_data, const char *button_label, const char *icon_name, GCallback function, gpointer data,...){
if (target_widget){ if (target_widget){
rmb_menu_window *window = yon_rmb_menu_new(); rmb_menu_window *window = yon_rmb_menu_new();
window->show_function=(GCallback)show_function;
window->show_data=show_data;
{ {
GtkWidget *menu_item = gtk_menu_item_new(); GtkWidget *menu_item = gtk_menu_item_new();
GtkWidget *content_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); GtkWidget *content_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
@ -996,6 +1003,7 @@ rmb_menu_window *yon_rmb_menu_setup(GtkWidget *target_widget, const char *button
gtk_menu_shell_append(GTK_MENU_SHELL(window->menu),menu_item); gtk_menu_shell_append(GTK_MENU_SHELL(window->menu),menu_item);
} }
g_signal_connect(G_OBJECT(target_widget),"button-press-event",G_CALLBACK(on_rmb_menu_open),window); g_signal_connect(G_OBJECT(target_widget),"button-press-event",G_CALLBACK(on_rmb_menu_open),window);
} }
} }
#endif #endif

@ -429,7 +429,9 @@ GtkWidget *yon_ubl_browser_window_open(char *link, char *browser_window_name);
typedef struct { typedef struct {
GtkWidget *menu; GtkWidget *menu;
dictionary *buttons; dictionary *buttons;
GCallback show_function;
void *show_data;
} rmb_menu_window; } rmb_menu_window;
rmb_menu_window *yon_rmb_menu_setup(GtkWidget *target_widget, const char *button_label, const char *icon_name, GCallback function, gpointer data,...); rmb_menu_window *yon_rmb_menu_setup(GtkWidget *target_widget, int (*show_function)(void*), void *show_data, const char *button_label, const char *icon_name, GCallback function, gpointer data,...);
#endif #endif
Loading…
Cancel
Save