Beispiel #1
0
TrayIndicator *MainWidget::createTrayObject(QWidget *parent)
{
    TrayFunctionPointer create_tray = NULL;
#ifdef Q_OS_LINUX
    QString desktop = getenv("XDG_CURRENT_DESKTOP");
    qDebug() << "Current desktop: " << desktop;

    if(desktop.toLower() == "kde")
    {
        // KDENotifier
        QLibrary library("/usr/lib/qcma/libqcma_kdenotifier.so");
        if(library.load())
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
        else
            qDebug() << "Cannot load libqcma_kdenotifier plugin";
    }
    else
    // try to use the appindicator if is available
    // if(desktop.toLower() == "unity")
    {
        // AppIndicator
        QLibrary library("/usr/lib/qcma/libqcma_appindicator.so");
        if(library.load())
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
        else
            qDebug() << "Cannot load libqcma_appindicator plugin";
    }
#endif
    // else QSystemTrayIcon
    return (create_tray != NULL) ? create_tray(parent) : createTrayIndicator(parent);
}
Beispiel #2
0
void load_tray_icon()
{
  if (!hime_status_tray)
    return;
  if (!tray_icon) {
    create_tray(NULL);
    return;
  }
  // wrong width & height if it is not embedded-ready
  if (!gtk_status_icon_is_embedded(tray_icon))
    return;
  iw = gtk_status_icon_get_size(tray_icon), ih = gtk_status_icon_get_size(tray_icon);
  if (!pixbuf) {
    char icon_fname[128];
    get_icon_path(HIME_TRAY_PNG, icon_fname);
    pixbuf = gdk_pixbuf_new_from_file_at_size(icon_fname, iw, ih, NULL);
  }
  char *iconame = HIME_TRAY_PNG;
//  if (current_CS && current_CS->in_method && inmd)
// Workaround due to issue #161
  if (current_CS && current_CS->im_state != HIME_STATE_DISABLED && current_CS->im_state != HIME_STATE_ENG_FULL)
    iconame = inmd[current_CS->in_method].icon;
  char fname[512];
  if (iconame)
    get_icon_path(iconame, fname);
  if (strcmp(pixbuf_ch_fname, fname) && pixbuf_ch) {
    g_object_unref(pixbuf_ch); pixbuf_ch = NULL;
  }
  if (!pixbuf_ch) {
    strcpy(pixbuf_ch_fname, fname);
    pixbuf_ch = gdk_pixbuf_new_from_file_at_size(fname, iw, ih, NULL);
  }
  draw_icon();
  iconame = NULL;
}
Beispiel #3
0
Datei: tray.c Projekt: b4283/hime
gboolean cb_expose(GtkWidget *da, cairo_t *event, gpointer data)
#endif
{
  if (!da)
    create_tray(NULL);

//  dbg("cb_expose\n");

  draw_icon();
  return FALSE;
}
Beispiel #4
0
Datei: tray.c Projekt: b4283/hime
void update_tray_icon()
{
//  dbg("update_tray_icon\n");
  if (!hime_status_tray)
    return;

  if (!da)
    create_tray(NULL);

  gtk_widget_queue_draw(da);
}
Beispiel #5
0
gint
flash_timeout(gpointer data)
{if(Acc_Keep_Link==-1){
	gtk_widget_hide_all (linkwindow);
	gtk_widget_show_all (window1);
	getAtrBox = create_messagebox("提示","与网络连接中断!",1);
 	gtk_widget_show_all (getAtrBox);
	return FALSE;
	}
	create_tray(tray);
	return TRUE;
}
Beispiel #6
0
static void
_init(char *log_level)
{
    setlocale(LC_ALL, "");
    // ignore SIGPIPE
    signal(SIGPIPE, SIG_IGN);
    signal(SIGINT, SIG_IGN);
    signal(SIGTSTP, SIG_IGN);
    signal(SIGWINCH, ui_sigwinch_handler);
    _create_directories();
    log_level_t prof_log_level = log_level_from_string(log_level);
    prefs_load();
    log_init(prof_log_level);
    log_stderr_init(PROF_LEVEL_ERROR);
    if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
#ifdef PROF_HAVE_GIT_VERSION
            log_info("Starting Profanity (%sdev.%s.%s)...", PROF_PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else
            log_info("Starting Profanity (%sdev)...", PROF_PACKAGE_VERSION);
#endif
    } else {
        log_info("Starting Profanity (%s)...", PROF_PACKAGE_VERSION);
    }
    chat_log_init();
    groupchat_log_init();
    accounts_load();
    char *theme = prefs_get_string(PREF_THEME);
    theme_init(theme);
    prefs_free_string(theme);
    ui_init();
    jabber_init();
    cmd_init();
    log_info("Initialising contact list");
    muc_init();
    tlscerts_init();
    scripts_init();
#ifdef PROF_HAVE_LIBOTR
    otr_init();
#endif
#ifdef PROF_HAVE_LIBGPGME
    p_gpg_init();
#endif
    atexit(_shutdown);
    plugins_init();
#ifdef PROF_HAVE_GTK
    if (gtk_ready) {
        log_debug("Building GTK icon");
        create_tray();
    }
#endif
    inp_nonblocking(TRUE);
}
Beispiel #7
0
TrayIndicator *MainWidget::createTrayObject(QWidget *obj_parent)
{
    TrayFunctionPointer create_tray = NULL;

#ifdef Q_OS_LINUX
    QString desktop = getenv("XDG_CURRENT_DESKTOP");
    qDebug() << "Current desktop: " << desktop;

#ifdef QT_DEBUG
    QString library_path = QApplication::applicationDirPath();
#else
    QString library_path = "/usr/lib/qcma";
#endif

    if(desktop.toLower() == "kde")
    {
#ifdef QT_DEBUG
        library_path += "/../kdenotifier";
#endif
        // KDENotifier
        QLibrary library(library_path + "/libqcma_kdenotifier.so");
        if(library.load())
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
        else
            qWarning() << "Cannot load libqcma_kdenotifier plugin from" << library_path;
    }
    else
    // try to use the appindicator if is available
    // if(desktop.toLower() == "unity")
    {
#ifdef QT_DEBUG
        library_path += "/../appindicator";
#endif
        // AppIndicator
        QLibrary library(library_path + "/libqcma_appindicator.so");
        if(library.load())
            create_tray = reinterpret_cast<TrayFunctionPointer>(library.resolve("createTrayIndicator"));
        else
            qWarning() << "Cannot load libqcma_appindicator plugin from" << library_path;
    }
#endif
    // else QSystemTrayIcon
    return (create_tray != NULL) ? create_tray(obj_parent) : createTrayIndicator(obj_parent);
}
Beispiel #8
0
int
main (int argc, char *argv[])
{

	GtkUIManager *ui;
	GError *error = NULL;
	GtkActionGroup *actions;
#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif
  gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
                      argc, argv,
                      GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
                      NULL);
  window1 = create_window1 ();
    //g_thread_create(thread1,NULL,NULL,NULL);//wait for the book :)
     //pthread_create(&tid,NULL,thread1,NULL);//it is not so good!
 	tray = g_new0 (tray_demo, 1);
	tray->window_main = window1;
	create_tray(tray);
	actions = gtk_action_group_new ("Actions");
	gtk_action_group_set_translation_domain (actions, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (actions, entries, n_entries, NULL);
	ui = gtk_ui_manager_new ();
	gtk_ui_manager_insert_action_group (ui, actions, 0);
	gtk_window_add_accel_group (GTK_WINDOW (window1), 
					gtk_ui_manager_get_accel_group (ui));
	if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
	{
		g_message ("building menus failed: %s", error->message);
		g_error_free (error);
	}
	tray->ui = ui;
	tray->actions = actions;
	tray->menus = gtk_ui_manager_get_widget (ui, "/PopupMenu");
g_message("ccc");	
  gtk_widget_show (window1);
  gtk_main ();g_message("here2!");
  return 0;
}
Beispiel #9
0
int main(int argc, char **argv) {
	gtk_init(&argc,&argv);
	create_tray();
	gtk_main();
	return 0;
}
Beispiel #10
0
/*主界面进入点*/
int main(int argc,char **argv)
{
	GtkWidget *win;
	GtkWidget *menu;
	GtkWidget *menu_bar;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *text;
	GtkWidget *scrolled;
	GtkWidget *open;
	GtkWidget *close;
	GtkWidget *clean;
	GtkTextBuffer *buffer;
	GtkAccelGroup *accel_group;
	PangoFontDescription *font_name;
	DATA data;
	CONFDATA conf;
	ABOUT about_data;
	//HELP help_data;
	struct sigaction act,old;

	setpgrp();

	init_with_conf(&conf);
	init_about_data(&about_data);
	//init_help_data(&help_data);

	data.buf=g_string_new(NULL);
	data.python_path=conf.python_path;
	data.proxy_py_path=conf.proxy_py_path;
	setlocale(LC_ALL,"");

	/*设置语言环境*/
	if(conf.language_env == NULL)
	{
		setlocale(LC_CTYPE,"zh_CN.UTF-8");
		setenv("LANG","zh_CN.UTF-8",1);
	}
	else
	{
		setlocale(LC_CTYPE,conf.language_env);
		setenv("LANG",conf.language_env,1);
	}
	
	if(conf.gtk_goagent_path!=NULL)
		chdir(conf.gtk_goagent_path);

	/*是否自动更新
	 * 如果是则在后台运行版更新进程
	 */
	if(strcmp(conf.goagent_auto_upgrade,"true")==0)
		auto_upgrade_goagent(GOAGENT_URL,&conf);

	/*国际化*/
	bindtextdomain("gtk_goagent","./locale/");
	textdomain("gtk_goagent");

	act.sa_flags=0;
	act.sa_handler=clean_data;
	/*设置自定义信号处理
	 * 用于在启动GoAgent失败时清理数据
	 */
	sigaction(SIGUSR1,&act,&old);

	gtk_init(&argc,&argv);

	win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(win),GTK_WIN_POS_CENTER);
	gtk_window_set_title(GTK_WINDOW(win),"Gtk GoAgent");
	gtk_window_set_icon_from_file(GTK_WINDOW(win),"img/64x64/gtk_goagent.png",NULL);

	create_tray(win);
	//create_pre_ui(&pre,&conf);

	vbox=gtk_vbox_new(FALSE,0);
	accel_group=gtk_accel_group_new();
	gtk_window_add_accel_group(GTK_WINDOW(win),accel_group);
	gtk_container_add(GTK_CONTAINER(win),vbox);

	text=gtk_text_view_new();

	/*设置日志显示框字体*/
	if(conf.font!=NULL)
	{
		font_name=pango_font_description_from_string(conf.font);
		gtk_widget_modify_font(text,font_name);
	}

	buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
	/*创建红色黑色和黄色标记
	 * 正常日志黑色输出
	 * 绿色用于警告
	 * 红色用于错误
	 * 黄色用于调试
	 */
	gtk_text_buffer_create_tag(buffer,"green_fg",
			"foreground","green",NULL);
	gtk_text_buffer_create_tag(buffer,"red_fg","foreground",
			"red",NULL);
	gtk_text_buffer_create_tag(buffer,"black_fg","foreground",
			"black",NULL);
	gtk_text_buffer_create_tag(buffer,"yellow_fg",
			"foreground","yellow",NULL);

	data.text=text;
	data.off=0;

	menu_bar=gtk_menu_bar_new();
	gtk_box_pack_start(GTK_BOX(vbox),menu_bar,FALSE,FALSE,0);
	/*创建菜单*/
	menu=create_menu(menu_bar,_("_File"));
	create_menu_with_image(menu,GTK_STOCK_OPEN,accel_group,connect_goagent,&data);
	create_menu_with_image(menu,GTK_STOCK_CLOSE,accel_group,disconnect_goagent,&data);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),gtk_separator_menu_item_new());
	create_menu_with_image(menu,GTK_STOCK_QUIT,accel_group,really_quit,&data);

	menu=create_menu(menu_bar,_("_Edit"));
	create_menu_with_image(menu,GTK_STOCK_PREFERENCES,accel_group,preferences,NULL);
	create_menu_with_image(menu,_("Up_load"),accel_group,upload,&conf);

	menu=create_menu(menu_bar,_("_Help"));
	create_menu_with_image(menu,GTK_STOCK_HELP,accel_group,help,NULL);
	create_menu_with_image(menu,GTK_STOCK_ABOUT,accel_group,about,&about_data);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu),gtk_separator_menu_item_new());
	create_menu_with_image(menu,_("Upgrade GoAg_ent"),accel_group,upgrade_goagent,conf.proxy_py_path);
	//create_menu_with_image(menu,_("Upgrade _Gtk GoAGent"),accel_group,upgrade_gtk_goagent,NULL);

	gtk_widget_set_size_request(text,0x300,0x180);
	/*设置显示构件不可编辑和自动换行*/
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text),FALSE);
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text),GTK_WRAP_CHAR);
	/*创建滚动条并设置自动更新*/
	scrolled=gtk_scrolled_window_new(NULL,NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrolled),text);
	gtk_box_pack_start(GTK_BOX(vbox),scrolled,FALSE,FALSE,0);

	gtk_box_pack_start(GTK_BOX(vbox),gtk_separator_menu_item_new(),FALSE,FALSE,5);
	show_time(vbox);
	gtk_box_pack_start(GTK_BOX(vbox),gtk_separator_menu_item_new(),FALSE,FALSE,5);

	hbox=gtk_hbox_new(FALSE,0);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5);
	
	open=gtk_button_new_with_label(_("Connect"));
	gtk_box_pack_start(GTK_BOX(hbox),open,FALSE,FALSE,30);
	g_signal_connect(G_OBJECT(open),"clicked",G_CALLBACK(connect_goagent),&data);
	clean=gtk_button_new_with_label(_("Clean"));
	gtk_box_pack_start(GTK_BOX(hbox),clean,TRUE,TRUE,100);
	g_signal_connect(G_OBJECT(clean),"clicked",G_CALLBACK(clean_buffer),&data);
	close=gtk_button_new_with_label(_("Disconnect"));
	gtk_box_pack_end(GTK_BOX(hbox),close,FALSE,FALSE,30);
	g_signal_connect(G_OBJECT(close),"clicked",G_CALLBACK(disconnect_goagent),&data);

	g_signal_connect(G_OBJECT(win),"delete_event",G_CALLBACK(really_quit),NULL);

	gtk_widget_show_all(win);

	gtk_main();

	//setpgrp();
	g_idle_remove_by_data(&data);
	g_string_free(data.buf,TRUE);

	kill(0,SIGKILL);
	//killpg(getpgrp(),SIGKILL);
	while(waitpid(-1,NULL,WNOHANG)!=-1);
	//g_idle_remove_by_data(&data);

	return 0;
}
Beispiel #11
0
Datei: tray.c Projekt: b4283/hime
void load_tray_icon()
{
//  dbg("load_tray_icon\n");
  if (!hime_status_tray)
    return;

  if (!da)
    create_tray(NULL);

  char *iconame = inmd[current_CS->in_method].icon;
  char fname[512];

  fname[0]=0;

  if (iconame)
    get_icon_path(iconame, fname);

#if GTK_CHECK_VERSION(2,17,7)
  GtkAllocation dwdh;
  gtk_widget_get_allocation(da, &dwdh);
  int dw = dwdh.width, dh = dwdh.height;
#else
    int dw = da->allocation.width, dh = da->allocation.height;
#endif

  if (!pixbuf || gdk_pixbuf_get_width (pixbuf) != dw || gdk_pixbuf_get_height (pixbuf) != dh) {
    char icon_fname[128];
    get_icon_path(HIME_TRAY_PNG, icon_fname);
    GError *err = NULL;
//    dbg("icon_name %s\n", icon_fname);
    pixbuf = gdk_pixbuf_new_from_file_at_size(icon_fname, dw, dh, &err);
    //Reduce troublesome when hime-tray.png does not exist
    //if (!pixbuf)
    //  p_err("cannot load file %s", icon_fname);
  }

#if 0
  dbg("fname %x %s\n", fname, fname);
#endif
  if (!fname[0]) {
    if (pixbuf_ch)
      g_object_unref(pixbuf_ch);

    pixbuf_ch = NULL;
    if (pixbuf_ch_fname)
      pixbuf_ch_fname[0] = 0;
  } else
  if (!pixbuf_ch_fname || strcmp(fname, pixbuf_ch_fname)) {
    free(pixbuf_ch_fname);
    pixbuf_ch_fname = strdup(fname);

    if (pixbuf_ch)
      g_object_unref(pixbuf_ch);

    dbg("ch %s\n", fname);
    GError *err = NULL;
    pixbuf_ch = gdk_pixbuf_new_from_file_at_size(fname, dw, dh, &err);
  }

  update_tray_icon();
}