⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dndtrash.cc

📁 一个功能比较强的下载软件
💻 CC
📖 第 1 页 / 共 2 页
字号:
			gdk_window_raise(dnd_trash_window->window);	};	return TRUE;};static int dnd_trash_configure(GtkWidget *window){//	gdk_window_get_root_origin (window->window, &(CFG.DND_TRASH_X),//				    &(CFG.DND_TRASH_Y));	gdk_window_get_position(window->window,&(CFG.DND_TRASH_X),				&(CFG.DND_TRASH_Y));	return(FALSE);};/*static GdkPixbuf *dnd_trash_scale(GdkPixbuf *pixbuf){	int temp,w,h;	gdk_window_get_geometry((GdkWindow *)NULL,&temp,&temp,&w,&h,&temp);	if (w<2048){		float ratio=float(w)/2048.0;		w=gdk_pixbuf_get_width(pixbuf);		h=gdk_pixbuf_get_height(pixbuf);		GdkPixbuf *rval=gdk_pixbuf_scale_simple(pixbuf,gint(float(w)*ratio),gint(float(h)*ratio),GDK_INTERP_HYPER);		gdk_pixbuf_unref(pixbuf);		return(rval);	};	return(pixbuf);};*/void dnd_trash_destroy_theme(){	if (dnd_trash_pixbuf1){		gdk_pixbuf_unref(dnd_trash_pixbuf1);		dnd_trash_pixbuf1=NULL;	};	if (dnd_trash_pixbuf2){		gdk_pixbuf_unref(dnd_trash_pixbuf2);		dnd_trash_pixbuf2=NULL;	};	dnd_trash_tooltip_text=NULL;	if (dnd_trash_tooltips){		gtk_object_destroy(GTK_OBJECT(dnd_trash_tooltips));		dnd_trash_tooltips=NULL;	};};void dnd_trash_init(){	CFG.DND_TRASH=1;	CFG.DND_NEED_POPUP=1;	if (dnd_trash_window) return;	dnd_trash_moveable=0;#include "pixmaps/dndtrash.xpm"#include "pixmaps/dndtrashi.xpm"	/* GtkWidget is the storage type for widgets */	GtkWidget *pixmap;	GtkStyle *style;    //	dnd_trash_window = gtk_window_new( GTK_WINDOW_POPUP );	dnd_trash_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);	gtk_window_set_type_hint (GTK_WINDOW(dnd_trash_window),				  GDK_WINDOW_TYPE_HINT_DIALOG);	gtk_window_set_resizable(GTK_WINDOW(dnd_trash_window),FALSE);	gtk_window_set_wmclass(GTK_WINDOW(dnd_trash_window),"D4X_DnDBasket", "D4X_DnDBasket");	gtk_window_set_title(GTK_WINDOW (dnd_trash_window), _("DnD basket"));	gtk_widget_set_events(dnd_trash_window,			      gtk_widget_get_events(dnd_trash_window) |			      GDK_FOCUS_CHANGE_MASK |			      GDK_BUTTON_MOTION_MASK |			      GDK_POINTER_MOTION_MASK |			      GDK_POINTER_MOTION_HINT_MASK |			      GDK_BUTTON_PRESS_MASK |			      GDK_BUTTON_RELEASE_MASK |			      GDK_STRUCTURE_MASK |			      GDK_VISIBILITY_NOTIFY_MASK |			      GDK_EXPOSURE_MASK);	/* create pixmaps first	 */	gint width=0,height=0;	gtk_widget_realize(dnd_trash_window);	if (dnd_trash_pixbuf1==NULL){		char *iconfile1=NULL;		char *iconfile2=NULL;		char *themeicon=d4x_xml_find_obj_value(D4X_THEME_DATA,"dndbasket icon>file");		if (themeicon)			iconfile1=sum_strings(CFG.THEMES_DIR,"/",themeicon,NULL);		themeicon=d4x_xml_find_obj_value(D4X_THEME_DATA,"dndbasket dropicon>file");		if (themeicon)			iconfile2=sum_strings(CFG.THEMES_DIR,"/",themeicon,NULL);		GdkPixbuf *pixbuf=NULL;		GError *error=NULL;		if (iconfile1 && (pixbuf=gdk_pixbuf_new_from_file(iconfile1,&error))){			dnd_trash_pixbuf1=pixbuf;		}else{			dnd_trash_pixbuf1=gdk_pixbuf_new_from_xpm_data((const char**)dndtrash_xpm);		};		pixbuf=NULL;		if (error) g_error_free(error);		error=NULL;		gdk_pixbuf_ref(dnd_trash_pixbuf1);		if (iconfile2 && (pixbuf=gdk_pixbuf_new_from_file(iconfile2,&error))){			dnd_trash_pixbuf2=pixbuf;		}else{			dnd_trash_pixbuf2=gdk_pixbuf_new_from_xpm_data((const char**)dndtrashi_xpm);		};		if (error) g_error_free(error);		gdk_pixbuf_ref(dnd_trash_pixbuf2);		if (iconfile1) delete[] iconfile1;		if (iconfile2) delete[] iconfile2;		gdk_pixbuf_render_pixmap_and_mask(dnd_trash_pixbuf1,NULL,&dnd_trash_mask1,1);		gdk_bitmap_ref(dnd_trash_mask1);		gdk_pixbuf_render_pixmap_and_mask(dnd_trash_pixbuf2,NULL,&dnd_trash_mask2,1);		gdk_bitmap_ref(dnd_trash_mask2);	};	width=gdk_pixbuf_get_width(dnd_trash_pixbuf1);	height=gdk_pixbuf_get_width(dnd_trash_pixbuf1);	d4x_normalize_coords(&(CFG.DND_TRASH_X),&(CFG.DND_TRASH_Y),width,height);	gtk_window_move(GTK_WINDOW(dnd_trash_window), gint(CFG.DND_TRASH_X),gint(CFG.DND_TRASH_Y));	/* Create the main window, and attach delete_event signal to terminate	 * the application.  Note that the main window will not have a titlebar	 * since we're making it a popup. *///	gtk_window_set_transient_for(GTK_WINDOW(dnd_trash_window), GTK_WINDOW(MainWindow));	gtk_window_set_default_size(GTK_WINDOW(dnd_trash_window),width,height);//	gtk_widget_set_events(dnd_trash_window,GDK_ALL_EVENTS_MASK);	g_signal_connect(G_OBJECT (dnd_trash_window), "delete_event",			 G_CALLBACK (dnd_trash_destroy), NULL);	g_signal_connect(G_OBJECT (dnd_trash_window), "motion_notify_event",			 G_CALLBACK (dnd_trash_motion), NULL);	g_signal_connect(G_OBJECT (dnd_trash_window), "button_press_event",			 G_CALLBACK (dnd_trash_button_press), NULL);	g_signal_connect(G_OBJECT (dnd_trash_window), "button_release_event",			 G_CALLBACK (dnd_trash_button_release), NULL);		g_signal_connect(G_OBJECT(dnd_trash_window),			 "drag_data_received",			 G_CALLBACK(list_dnd_drop_internal),			 NULL);	g_signal_connect(G_OBJECT (dnd_trash_window), "drag_leave",			 G_CALLBACK (dnd_drag_leave), NULL);	g_signal_connect(G_OBJECT (dnd_trash_window),"drag_motion",			 G_CALLBACK (dnd_drag_motion),NULL);	gtk_drag_dest_set(GTK_WIDGET(dnd_trash_window),	                  (GtkDestDefaults)(GTK_DEST_DEFAULT_MOTION |	                                    GTK_DEST_DEFAULT_HIGHLIGHT |	                                    GTK_DEST_DEFAULT_DROP),	                  download_drop_types, n_download_drop_types,	                  (GdkDragAction)(GDK_ACTION_COPY|GDK_ACTION_MOVE));	g_signal_connect(G_OBJECT(dnd_trash_window), "visibility_notify_event",			 G_CALLBACK(dnd_trash_no_expose),			 dnd_trash_window);			  	g_signal_connect(G_OBJECT(dnd_trash_window), "no_expose_event",			 G_CALLBACK(dnd_trash_no_expose),			 dnd_trash_window);	gtk_widget_realize(dnd_trash_window);	gdk_window_set_decorations(dnd_trash_window->window,GdkWMDecoration(0));	gtk_widget_show (dnd_trash_window);	/* Now for the pixmap and the pixmap widget */	dnd_trash_gtk_pixmap = pixmap = gtk_image_new_from_pixbuf(dnd_trash_pixbuf1);//		gtk_widget_show( pixmap );	/* To display the pixmap, we use a fixed widget to place the pixmap */	dnd_trash_fixed = gtk_fixed_new();//	gtk_widget_set_usize( dnd_trash_fixed, width, height );//	gtk_event_box_new();	gtk_fixed_put( GTK_FIXED(dnd_trash_fixed), pixmap, 0, 0 );	gtk_container_add( GTK_CONTAINER(dnd_trash_window), dnd_trash_fixed );	gtk_widget_show_all( dnd_trash_fixed );	d4xXmlObject *xmltip=d4x_xml_find_obj(D4X_THEME_DATA,"dndbasket tooltip");	if (dnd_trash_tooltips==NULL){		dnd_trash_tooltips=gtk_tooltips_new();		gtk_tooltips_force_window(dnd_trash_tooltips);		GtkStyle *current_style =gtk_style_copy(gtk_widget_get_style(dnd_trash_tooltips->tip_window));/* FIXME: GTK2		g_signal_connect(G_OBJECT(dnd_trash_tooltips->tip_window), "draw",				   G_CALLBACK(dnd_trash_tooltips_draw),NULL);		g_signal_connect(G_OBJECT(dnd_trash_tooltips->tip_window), "expose_event",				   G_CALLBACK(dnd_trash_tooltips_draw),NULL);*/		char *bgcolor=NULL,*fgcolor=NULL;		if (xmltip){			d4xXmlField *fld=NULL;			fld=xmltip->get_attr("bgcolor");			bgcolor=fld?fld->value.get():NULL;			fld=xmltip->get_attr("fgcolor");			fgcolor=fld?fld->value.get():NULL;		};		if (bgcolor){			gdk_color_parse(bgcolor,&(current_style->bg[GTK_STATE_NORMAL]));			current_style->fg[GTK_STATE_ACTIVE]=current_style->bg[GTK_STATE_NORMAL];		}else			current_style->bg[GTK_STATE_NORMAL]=current_style->fg[GTK_STATE_ACTIVE]=LYELLOW;		if (fgcolor)			gdk_color_parse(fgcolor,&(current_style->fg[GTK_STATE_NORMAL]));		current_style->bg[GTK_STATE_ACTIVE]=current_style->fg[GTK_STATE_NORMAL];		gtk_widget_set_style(dnd_trash_tooltips->tip_window, current_style);	};	if (xmltip){		dnd_trash_tooltip_text=xmltip->value.get();	}else		dnd_trash_tooltip_text=_("Drop link here");	gtk_tooltips_set_tip(dnd_trash_tooltips,			     dnd_trash_window,			     dnd_trash_tooltip_text,			     (const gchar *)NULL);	gtk_tooltips_enable(dnd_trash_tooltips);	/* This mask cut out everything except the image */	if (dnd_trash_mask1)		gtk_widget_shape_combine_mask( dnd_trash_window, dnd_trash_mask1,0,0);	/* show the window */	gtk_widget_show( dnd_trash_window );//	gdk_window_set_icon(dnd_trash_window->window,(GdkWindow *)NULL,dnd_trash_pixmap1,dnd_trash_mask1);	gdk_window_resize(dnd_trash_window->window,width,height);	set_dndtrash_button();	wm_skip_window(dnd_trash_window);	gdk_window_move(dnd_trash_window->window,CFG.DND_TRASH_X,CFG.DND_TRASH_Y);	g_signal_connect(G_OBJECT(dnd_trash_window), "configure_event",			 G_CALLBACK(dnd_trash_configure),			 NULL);	gdk_window_set_functions(dnd_trash_window->window,GdkWMFunction(GDK_FUNC_MOVE|GDK_FUNC_CLOSE));};void dnd_trash_menu_prepare(){	GtkWidget *menu_item=gtk_item_factory_get_widget(dnd_trash_item_factory,_(dnd_menu_inames[DM_SPEED_1]));	GTK_CHECK_MENU_ITEM(menu_item)->active=CFG.SPEED_LIMIT==1?TRUE:FALSE;	if (GTK_WIDGET_VISIBLE(menu_item)) gtk_widget_queue_draw(menu_item);	menu_item=gtk_item_factory_get_widget(dnd_trash_item_factory,_(dnd_menu_inames[DM_SPEED_2]));	GTK_CHECK_MENU_ITEM(menu_item)->active=CFG.SPEED_LIMIT==2?TRUE:FALSE;	if (GTK_WIDGET_VISIBLE(menu_item)) gtk_widget_queue_draw(menu_item);	menu_item=gtk_item_factory_get_widget(dnd_trash_item_factory,_(dnd_menu_inames[DM_SPEED_3]));	GTK_CHECK_MENU_ITEM(menu_item)->active=CFG.SPEED_LIMIT==3?TRUE:FALSE;	if (GTK_WIDGET_VISIBLE(menu_item)) gtk_widget_queue_draw(menu_item);};void dnd_trash_menu_calback(gpointer *data, guint action, GtkWidget *widget){	if (action>0 && action<4){		CFG.SPEED_LIMIT=action;		set_speed_buttons();	};};static void dnd_trash_delete_completed(){	aa.del_completed();};void dnd_trash_set_del_completed(gint how){	GtkWidget *menu_item=gtk_item_factory_get_widget(dnd_trash_item_factory,					      _(dnd_menu_inames[DM_DELCOMPLETED]));	if (menu_item)		gtk_widget_set_sensitive(menu_item,how);};static gint dnd_trash_menu_umap(){	CFG.DND_NEED_POPUP=1;	dnd_trash_no_expose();	return(FALSE);};void dnd_trash_init_menu() {	GtkItemFactoryEntry menu_items[] = {		{_(dnd_menu_inames[DM_NEW]),		(gchar *)NULL,	(GtkItemFactoryCallback)init_add_window,		0, (gchar *)NULL},		{_(dnd_menu_inames[DM_PASTE]),		(gchar *)NULL,	(GtkItemFactoryCallback)init_add_clipboard_window,	0, (gchar *)NULL},		{_(dnd_menu_inames[DM_AUTOMATED]),	(gchar *)NULL,	(GtkItemFactoryCallback)d4x_automated_add,		0,(gchar *)NULL},		{_(dnd_menu_inames[DM_DELCOMPLETED]),	(gchar *)NULL,	(GtkItemFactoryCallback)dnd_trash_delete_completed,	0, (gchar *)NULL},		{_(dnd_menu_inames[DM_SEP]),		(gchar *)NULL,	(GtkItemFactoryCallback)NULL,				0, "<Separator>"},		{_(dnd_menu_inames[DM_OPTIONS]),	(gchar *)NULL,	(GtkItemFactoryCallback)d4x_prefs_init,			0, (gchar *)NULL},		{_(dnd_menu_inames[DM_SPEED]),		(gchar *)NULL,	(GtkItemFactoryCallback)NULL,				0, "<Branch>"},		{_(dnd_menu_inames[DM_SPEED_1]),	(gchar *)NULL,	(GtkItemFactoryCallback)dnd_trash_menu_calback,		1, "<RadioItem>"},		{_(dnd_menu_inames[DM_SPEED_2]),	(gchar *)NULL,	(GtkItemFactoryCallback)dnd_trash_menu_calback,		2, _(dnd_menu_inames[DM_SPEED_1])},		{_(dnd_menu_inames[DM_SPEED_3]),	(gchar *)NULL,	(GtkItemFactoryCallback)dnd_trash_menu_calback,		3, _(dnd_menu_inames[DM_SPEED_2])},		{_(dnd_menu_inames[DM_SEP]),		(gchar *)NULL,	(GtkItemFactoryCallback)NULL,				0, "<Separator>"},		{_(dnd_menu_inames[DM_EXIT]),		(gchar *)NULL,	(GtkItemFactoryCallback)ask_exit,			0, (gchar *)NULL}	};	int nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);	GtkAccelGroup *accel_group;	accel_group = gtk_accel_group_new();	dnd_trash_item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>",accel_group);	gtk_item_factory_create_items(dnd_trash_item_factory, nmenu_items, menu_items, NULL);	dnd_trash_menu = gtk_item_factory_get_widget(dnd_trash_item_factory, "<main>");	g_signal_connect(G_OBJECT (dnd_trash_menu), "unmap_event",			 G_CALLBACK(dnd_trash_menu_umap), NULL);	dnd_trash_init_speed_tips();};static gint dnd_trash_animation_end(gpointer unused){	gint width,height;	gtk_image_set_from_pixbuf(GTK_IMAGE(dnd_trash_gtk_pixmap),				  dnd_trash_pixbuf1);	width=gdk_pixbuf_get_width(dnd_trash_pixbuf1);	height=gdk_pixbuf_get_height(dnd_trash_pixbuf1);	gdk_window_resize(dnd_trash_window->window,width,height);	gtk_widget_shape_combine_mask(dnd_trash_window, dnd_trash_mask1, 0, 0 );	/* draw NOW */	GdkRectangle rect;	rect.x=dnd_trash_gtk_pixmap->allocation.x;	rect.y=dnd_trash_gtk_pixmap->allocation.y;	rect.width=dnd_trash_gtk_pixmap->allocation.width;	rect.height=dnd_trash_gtk_pixmap->allocation.height;	gtk_widget_queue_draw(dnd_trash_gtk_pixmap);	return 0;};void dnd_trash_animation(){	if (dnd_trash_window){		gint width,height;		gtk_image_set_from_pixbuf(GTK_IMAGE(dnd_trash_gtk_pixmap),					  dnd_trash_pixbuf2);		width=gdk_pixbuf_get_width(dnd_trash_pixbuf2);		height=gdk_pixbuf_get_height(dnd_trash_pixbuf2);		gdk_window_resize(dnd_trash_window->window,width,height);		gtk_widget_shape_combine_mask(dnd_trash_window, dnd_trash_mask2,0, 0 );		GdkRectangle rect;		rect.x=dnd_trash_gtk_pixmap->allocation.x;		rect.y=dnd_trash_gtk_pixmap->allocation.y;		rect.width=dnd_trash_gtk_pixmap->allocation.width;		rect.height=dnd_trash_gtk_pixmap->allocation.height;		gtk_widget_queue_draw(dnd_trash_gtk_pixmap);//		gtk_widget_draw(dnd_trash_gtk_pixmap,&rect);		gtk_timeout_add (500, dnd_trash_animation_end , NULL);	};};void dnd_trash_set_tooltip(char *str,float percent){	dnd_trash_tooltip_percent=percent;	if (str==NULL)		str=dnd_trash_tooltip_text;	if (str==NULL || dnd_trash_window==NULL) return;	gtk_tooltips_set_tip(dnd_trash_tooltips,			     dnd_trash_window,			     str,NULL);};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -