static void sexy_icon_entry_destroy(GtkObject *obj) { SexyIconEntry *entry; entry = SEXY_ICON_ENTRY(obj); sexy_icon_entry_set_icon(entry, SEXY_ICON_ENTRY_PRIMARY, NULL); sexy_icon_entry_set_icon(entry, SEXY_ICON_ENTRY_SECONDARY, NULL); if (GTK_OBJECT_CLASS(parent_class)->destroy) GTK_OBJECT_CLASS(parent_class)->destroy(obj); }
static void build_search_entry(GitgWindow *window, GtkBuilder *builder) { GtkWidget *box = GTK_WIDGET(gtk_builder_get_object(builder, "hbox_top")); GtkWidget *entry = sexy_icon_entry_new(); GtkImage *image = GTK_IMAGE(gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU)); sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), SEXY_ICON_ENTRY_PRIMARY, image); gtk_tree_view_set_search_entry(window->priv->tree_view, GTK_ENTRY(entry)); gtk_widget_show(entry); gtk_box_pack_end(GTK_BOX(box), entry, FALSE, FALSE, 0); GtkBuilder *b = gitg_utils_new_builder( "gitg-menus.xml"); GtkUIManager *manager = GTK_UI_MANAGER(gtk_builder_get_object(b, "uiman")); window->priv->search_popup = GTK_WIDGET(g_object_ref(gtk_ui_manager_get_widget(manager, "/ui/search_popup"))); gtk_builder_connect_signals(b, window); g_object_unref(b); g_signal_connect(entry, "icon-pressed", G_CALLBACK(on_search_icon_pressed), window); gtk_tree_view_set_search_column(window->priv->tree_view, 1); gtk_tree_view_set_search_equal_func(window->priv->tree_view, search_equal_func, window, NULL); GtkAccelGroup *group = gtk_accel_group_new(); GClosure *closure = g_cclosure_new(G_CALLBACK(focus_search), entry, NULL); gtk_accel_group_connect(group, GDK_f, GDK_CONTROL_MASK, 0, closure); gtk_window_add_accel_group(GTK_WINDOW(window), group); }
/** * sexy_icon_entry_add_clear_button * @icon_entry: A #SexyIconEntry. * * A convenience function to add a clear button to the end of the entry. * This is useful for search boxes. */ void sexy_icon_entry_add_clear_button(SexyIconEntry *icon_entry, gpointer data, gpointer function) { GtkWidget *icon; g_return_if_fail(icon_entry != NULL); g_return_if_fail(SEXY_IS_ICON_ENTRY(icon_entry)); icon = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); gtk_widget_show(icon); sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(icon_entry), SEXY_ICON_ENTRY_SECONDARY, GTK_IMAGE(icon)); sexy_icon_entry_set_icon_highlight(SEXY_ICON_ENTRY(icon_entry), SEXY_ICON_ENTRY_SECONDARY, TRUE); if (icon_entry->priv->icon_released_id != 0) { g_signal_handler_disconnect(icon_entry, icon_entry->priv->icon_released_id); } icon_entry->priv->icon_released_id = g_signal_connect(G_OBJECT(icon_entry), "icon_released", G_CALLBACK(function), data); }
void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id) { #if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_stock(GTK_ENTRY(entry), icon_pos, stock_id); #else GtkImage *image = GTK_IMAGE(gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_LARGE_TOOLBAR)); if (image != NULL) { sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), (SexyIconEntryPosition)icon_pos, image); g_object_unref(image); } #endif }
void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry, GtkEntryIconPosition icon_pos, GdkPixbuf *pixbuf) { #if GTK_CHECK_VERSION(2,16,0) gtk_entry_set_icon_from_pixbuf(GTK_ENTRY(entry), icon_pos, pixbuf); #else GtkImage *image = GTK_IMAGE(gtk_image_new_from_pixbuf(pixbuf)); if (image != NULL) { sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry), (SexyIconEntryPosition)icon_pos, image); g_object_unref(image); } #endif }