?? recvmsg.c
字號:
dbg_out("Resize:(%d,%d)\n",width,height); gtk_window_resize (GTK_WINDOW(window),width,height); } return window;}static voidprint_one_window(gpointer data,gpointer user_data) { if (!data) return; dbg_out("stored window: %x\n",(unsigned int)data); return;}static voidlistup_current_stored_windows(void){ g_static_mutex_lock(&store_win_mutex); g_list_foreach(store_wins, print_one_window, NULL); g_static_mutex_unlock(&store_win_mutex);}static voidshow_one_window(gpointer data,gpointer user_data) { int rc; GtkWidget *top; GtkWidget *download_window; ipmsg_private_data_t *private; ipmsg_recvmsg_private_t *sender_info; if (!data) return; top=GTK_WIDGET(data); dbg_out("show stored window: %x\n",(unsigned int)top); private=(ipmsg_private_data_t *)lookup_widget(GTK_WIDGET(top),"senderInfo" ); IPMSG_ASSERT_PRIVATE(private,IPMSG_PRIVATE_RECVMSG); sender_info=private->data; g_assert(sender_info); /* ダウンロードウィンドウ生成 */ if ((!(sender_info->flags & IPMSG_SECRETOPT)) && (sender_info->flags & IPMSG_FILEATTACHOPT) && (sender_info->ext_part)){ dbg_out("This message has attachment\n"); rc=internal_create_download_window(top,&download_window); if (!rc) { g_assert (download_window); append_displayed_window(download_window); gtk_widget_show (download_window); }else{ err_out("Can not create download window %s (%d)\n",strerror(-rc),rc); } } if (!(sender_info->flags & IPMSG_SECRETOPT)) { append_opened_window(top); } append_displayed_window(top); gtk_widget_show (top); play_sound(); return;}voidshow_stored_windows(void) { g_static_mutex_lock(&store_win_mutex); g_list_foreach(store_wins, show_one_window, NULL); g_list_free(store_wins); store_wins=NULL; g_static_mutex_unlock(&store_win_mutex);}voidstore_message_window(const msg_data_t *msg,const char *from){ GtkWidget *window; GtkWidget *textview1; window=internal_create_recv_message_window(msg,from); if (window) { g_static_mutex_lock(&store_win_mutex); store_wins=g_list_append(store_wins,window); g_static_mutex_unlock(&store_win_mutex); listup_current_stored_windows(); }}gboolean recv_windows_are_stored(void) { GList *first; g_static_mutex_lock(&store_win_mutex); first=g_list_first(store_wins); g_static_mutex_unlock(&store_win_mutex); if (first) return TRUE; return FALSE;}voidrecv_message_window(const msg_data_t *msg,const char *from){ int rc; GtkWidget *window; GtkWidget *text_view; GtkWidget *download_window; ipmsg_private_data_t *private; ipmsg_recvmsg_private_t *sender_info; if ( (!msg) || (!from) ) return; window=internal_create_recv_message_window(msg,from); if (window) { private=(ipmsg_private_data_t *)lookup_widget(GTK_WIDGET(window),"senderInfo" ); IPMSG_ASSERT_PRIVATE(private,IPMSG_PRIVATE_RECVMSG); sender_info=private->data; /* 封書でなければここでダウンロードウィンドウ生成 */ if ( (!(sender_info->flags & IPMSG_SECRETOPT)) && (sender_info->flags & IPMSG_FILEATTACHOPT) && (sender_info->ext_part)){ dbg_out("This message has attachment\n"); rc=internal_create_download_window(window,&download_window); if (!rc) { g_assert (download_window); gtk_widget_show (download_window); append_displayed_window(download_window); }else{ err_out("Can not create download window %s (%d)\n",strerror(-rc),rc); } } if (!(sender_info->flags & IPMSG_SECRETOPT)) { append_opened_window(window); text_view=lookup_widget(window,"viewwindowTextView"); } gtk_widget_show (window); append_displayed_window(window); play_sound(); }}int append_opened_window(GtkWidget *window) { g_assert(window); dbg_out("Append openlist:%x\n",(unsigned int)window); g_static_mutex_lock(&openwin_mutex); opened_wins=g_list_append(opened_wins,window); g_static_mutex_unlock(&openwin_mutex); return 0;}int destroy_all_opened_windows(void) { GList *node; GtkWidget *window; g_static_mutex_lock(&openwin_mutex); while((node=g_list_first (opened_wins))) { window=node->data; g_assert(window); opened_wins=g_list_remove (opened_wins,node); /* 參照のみなのでここではデータは開放しない */ g_static_mutex_unlock(&openwin_mutex); gtk_widget_destroy(window); g_static_mutex_lock(&openwin_mutex); } g_static_mutex_unlock(&openwin_mutex); return 0;}intremove_window_from_openlist(GtkWidget *window){ g_static_mutex_lock(&openwin_mutex); dbg_out("Remove %x from openlist\n",(unsigned int)window); /* 參照のみなのでここではデータは開放しない */ opened_wins=g_list_remove(opened_wins,window); g_static_mutex_unlock(&openwin_mutex); return 0;}int append_displayed_window(GtkWidget *window) { g_assert(window); dbg_out("Append displayed windows list:%x\n",(unsigned int)window); g_static_mutex_lock(&displayedwin_mutex); if (g_list_find(displayed_wins,window)) { dbg_out("Already exist %x\n",(unsigned int)window); goto unlock_out; } displayed_wins=g_list_append(displayed_wins,window); unlock_out: g_static_mutex_unlock(&displayedwin_mutex); return 0;}intremove_window_from_displaylist(GtkWidget *window){ g_static_mutex_lock(&displayedwin_mutex); dbg_out("Remove %x from displaylist\n",(unsigned int)window); if (g_list_find(displayed_wins,window)) /* 參照のみなのでここではデータは開放しない */ displayed_wins=g_list_remove(displayed_wins,window); g_static_mutex_unlock(&displayedwin_mutex); return 0;}voidpresent_all_displayed_windows(void) { GList *node; GtkWidget *window; g_static_mutex_lock(&displayedwin_mutex); for(node=g_list_first (displayed_wins); node; node=g_list_next (node)) { window=node->data; g_assert(window); gtk_window_present (GTK_WINDOW(window)); } g_static_mutex_unlock(&displayedwin_mutex); return ;}static voidon_pixmap_destroy(GtkObject *object, gpointer user_data){ // dbg_out("here %x\n",object);}static GtkWidget*lookup_widget_with_applet(GtkWidget *widget, const gchar *widget_name) { GtkWidget *found_widget; found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); if (!found_widget) found_widget=lookup_widget(widget,widget_name); if (!found_widget) g_warning ("Widget not found: %s", widget_name); return found_widget;}static gboolean default_message_watcher(GtkWidget *window,gboolean is_normal) { GtkWidget *startBtn; GtkWidget *current_image; GtkWidget *new_image; g_assert(window); current_image=lookup_widget_with_applet(window,"image3"); g_assert(current_image); startBtn = lookup_widget_with_applet(window,"startBtn"); g_assert(startBtn); g_signal_connect ((gpointer) current_image, "destroy", G_CALLBACK (on_pixmap_destroy),NULL); if (is_normal) new_image=normal_image; else new_image=reverse_image; gtk_widget_show (new_image); //dbg_out("remove:%x\n",current_image); gtk_container_remove (GTK_CONTAINER (startBtn), current_image); gtk_container_add (GTK_CONTAINER (startBtn), new_image); //dbg_out("new object relation:%x => %x\n",current_image,new_image); GLADE_HOOKUP_OBJECT (window, new_image, "image3");}static gboolean message_watcher(gpointer data) { static gboolean is_normal=TRUE; GtkWidget *init_win=data; g_assert(init_win); g_source_remove (init_win_timer_id); if ( (is_normal) && (!recv_windows_are_stored()) && (!hostinfo_is_ipmsg_absent()) ) goto source_set_out; if ( (!is_normal) && (!recv_windows_are_stored()) && (hostinfo_is_ipmsg_absent()) ) goto source_set_out; g_assert(normal_image); g_assert(reverse_image); if (is_normal) is_normal=FALSE; else is_normal=TRUE;#if GTK_CHECK_VERSION(2,10,0) if ((GTK_IS_STATUS_ICON(init_win))) systray_message_watcher(init_win,is_normal); else#endif default_message_watcher(init_win,is_normal); source_set_out: init_win_timer_id=g_timeout_add(MSG_WATCH_INTERVAL,message_watcher,init_win); return TRUE; }intstart_message_watcher(GtkWidget *init_win){ if (!init_win) return -EINVAL; normal_image = create_pixmap (init_win, "g2ipmsg/ipmsg.xpm"); reverse_image = create_pixmap (init_win, "g2ipmsg/ipmsgrev.xpm"); g_assert(normal_image); g_assert(reverse_image); gtk_widget_ref (normal_image); gtk_widget_ref (reverse_image); dbg_out("Start message watcher \n"); init_win_timer_id=g_timeout_add(MSG_WATCH_INTERVAL,message_watcher,init_win); return 0;}intcleanup_message_watcher(void){ dbg_out("End message watcher \n"); gtk_widget_unref (normal_image); gtk_widget_unref (reverse_image); g_source_remove (init_win_timer_id); dbg_out("Cleanuped message watcher \n"); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -