static gboolean button_pressed_callback (GtkWidget *widget, GdkEventButton *event) { NemoWindow *window; NemoWindowSlot *slot; NemoView *view; NemoLocationEntry *entry; if (event->button != 3) { return FALSE; } window = nemo_location_bar_get_window (gtk_widget_get_parent (widget)); slot = nemo_window_get_active_slot (window); view = slot->content_view; entry = NEMO_LOCATION_ENTRY (gtk_bin_get_child (GTK_BIN (widget))); if (view == NULL || nemo_location_entry_get_secondary_action (entry) == NEMO_LOCATION_ENTRY_ACTION_GOTO) { return FALSE; } nemo_view_pop_up_location_context_menu (view, event, NULL); return FALSE; }
static gboolean label_button_pressed_callback (GtkWidget *widget, GdkEventButton *event) { NemoWindow *window; NemoWindowSlot *slot; NemoView *view; GtkWidget *label; if (event->button != 3) { return FALSE; } window = nemo_location_bar_get_window (gtk_widget_get_parent (widget)); slot = nemo_window_get_active_slot (window); view = slot->content_view; label = gtk_bin_get_child (GTK_BIN (widget)); /* only pop-up if the URI in the entry matches the displayed location */ if (view == NULL || strcmp (gtk_label_get_text (GTK_LABEL (label)), LOCATION_LABEL)) { return FALSE; } nemo_view_pop_up_location_context_menu (view, event, NULL); return FALSE; }
static void drag_data_received_callback (GtkWidget *widget, GdkDragContext *context, int x, int y, GtkSelectionData *data, guint info, guint32 time, gpointer callback_data) { char **names; NemoApplication *application; int name_count; NemoWindow *new_window, *window; GdkScreen *screen; gboolean new_windows_for_extras; char *prompt; char *detail; GFile *location; NemoLocationBar *self = NEMO_LOCATION_BAR (widget); g_assert (data != NULL); g_assert (callback_data == NULL); names = g_uri_list_extract_uris ((const gchar *) gtk_selection_data_get_data (data)); if (names == NULL || *names == NULL) { g_warning ("No D&D URI's"); g_strfreev (names); gtk_drag_finish (context, FALSE, FALSE, time); return; } window = nemo_location_bar_get_window (widget); new_windows_for_extras = FALSE; /* Ask user if they really want to open multiple windows * for multiple dropped URIs. This is likely to have been * a mistake. */ name_count = g_strv_length (names); if (name_count > 1) { prompt = g_strdup_printf (ngettext("Do you want to view %d location?", "Do you want to view %d locations?", name_count), name_count); detail = g_strdup_printf (ngettext("This will open %d separate window.", "This will open %d separate windows.", name_count), name_count); /* eel_run_simple_dialog should really take in pairs * like gtk_dialog_new_with_buttons() does. */ new_windows_for_extras = eel_run_simple_dialog (GTK_WIDGET (window), TRUE, GTK_MESSAGE_QUESTION, prompt, detail, GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL) != 0 /* GNOME_OK */; g_free (prompt); g_free (detail); if (!new_windows_for_extras) { g_strfreev (names); gtk_drag_finish (context, FALSE, FALSE, time); return; } } nemo_location_bar_set_location (self, names[0]); emit_location_changed (self); if (new_windows_for_extras) { int i; application = nemo_application_get_singleton (); screen = gtk_window_get_screen (GTK_WINDOW (window)); for (i = 1; names[i] != NULL; ++i) { new_window = nemo_application_create_window (application, screen); location = g_file_new_for_uri (names[i]); nemo_window_go_to (new_window, location); g_object_unref (location); } } g_strfreev (names); gtk_drag_finish (context, TRUE, FALSE, time); }