summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1aa8e4a)
raw | patch | inline | side by side (parent: 1aa8e4a)
author | joncruz <joncruz@users.sourceforge.net> | |
Sat, 13 Oct 2007 09:05:49 +0000 (09:05 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sat, 13 Oct 2007 09:05:49 +0000 (09:05 +0000) |
src/dialogs/swatches.cpp | patch | blob | history |
index 1196c8378e466ac7defecaf9330dcbd731fb27c3..6607657e58f7e6ca7c95e5e24d39d98e76bd15b6 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types
#include <gtk/gtkdnd.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkseparatormenuitem.h>
#include <glibmm/i18n.h>
#include <gdkmm/pixbuf.h>
// }
static void handleClick( GtkWidget* widget, gpointer callback_data ) {
+ (void)widget;
ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
if ( item ) {
item->buttonClicked(false);
}
static void handleSecondaryClick( GtkWidget* widget, gint arg1, gpointer callback_data ) {
+ (void)widget;
+ (void)arg1;
ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
if ( item ) {
item->buttonClicked(true);
}
}
+static GtkWidget* popupMenu = 0;
+static ColorItem* bounceTarget = 0;
+
+static void redirClick( GtkMenuItem *menuitem, gpointer user_data )
+{
+ (void)user_data;
+ if ( bounceTarget ) {
+ handleClick( GTK_WIDGET(menuitem), bounceTarget );
+ }
+}
+
+static void redirSecondaryClick( GtkMenuItem *menuitem, gpointer user_data )
+{
+ (void)user_data;
+ if ( bounceTarget ) {
+ handleSecondaryClick( GTK_WIDGET(menuitem), 0, bounceTarget );
+ }
+}
+
+static gboolean handleButtonPress( GtkWidget* widget, GdkEventButton* event, gpointer user_data)
+{
+ (void)widget;
+ gboolean handled = FALSE;
+
+ if ( (event->button == 3) && (event->type == GDK_BUTTON_PRESS) ) {
+ if ( !popupMenu ) {
+ popupMenu = gtk_menu_new();
+ GtkWidget* child = 0;
+
+ child = gtk_menu_item_new_with_label("Set fill");
+ g_signal_connect( G_OBJECT(child),
+ "activate",
+ G_CALLBACK(redirClick),
+ user_data);
+ gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
+
+ child = gtk_menu_item_new_with_label("Set stroke");
+
+ g_signal_connect( G_OBJECT(child),
+ "activate",
+ G_CALLBACK(redirSecondaryClick),
+ user_data);
+ gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
+
+ gtk_widget_show_all(popupMenu);
+ }
+
+ ColorItem* item = reinterpret_cast<ColorItem*>(user_data);
+ if ( item ) {
+ bounceTarget = item;
+ if ( popupMenu ) {
+ gtk_menu_popup(GTK_MENU(popupMenu), NULL, NULL, NULL, NULL, event->button, event->time);
+ handled = TRUE;
+ }
+ }
+ }
+
+ return handled;
+}
+
static void dieDieDie( GtkObject *obj, gpointer user_data )
{
g_message("die die die %p %p", obj, user_data );
@@ -498,6 +564,11 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Inkscape::
G_CALLBACK(handleSecondaryClick),
this);
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "button-press-event",
+ G_CALLBACK(handleButtonPress),
+ this);
+
gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
GDK_BUTTON1_MASK,
sourceColorEntries,