示例#1
0
static void in_received_handler(DictionaryIterator *iter, void *context) {
  phone_heartbeat = 5;
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Received message, current screen: %d", current_screen);
  Tuple *server_error_tuple = dict_find(iter, SERVER_ERROR_KEY); 
  if (server_error_tuple){
	    if (current_screen != SCREEN_MESSAGE_KEY){
		server_error = atoi(server_error_tuple->value->cstring);
		APP_LOG(APP_LOG_LEVEL_DEBUG, "Server error received %d", server_error);
		show_message("No connection to Boat Remote Server");
	  } 
	  return;
  }
	
  else{
	  switch(current_menu){
		  case VIEW_MENU:
		  	  switch(current_screen){
				case SCREEN_MESSAGE_KEY:
		  			window_stack_pop(true);
		   		    change_screen(last_screen);
				case SCREEN_GPS_KEY:
		   			update_gps_fields(iter);
		   			break;
				case SCREEN_SAILING_KEY:
				   update_sailing_fields(iter);
				   break;
				case SCREEN_NAVIGATION_KEY:
				   update_navigation_fields(iter);
				   break;
				case SCREEN_WAYPOINT_KEY:
				   update_waypoint_fields(iter);
				   break;
				case SCREEN_LOG_KEY:
				   update_log_fields(iter);
				   break;
				case SCREEN_ANCHOR_WATCH_KEY:
				   update_anchor_watch_fields(iter);
	     		   Tuple *location_status_tuple = dict_find(iter, LOCATION_STATUS_KEY); 
		   		   if (location_status_tuple){
			           if (atoi(location_status_tuple->value->cstring) == 1){
				           show_popup("Attempting to set anchor location using phone GPS");
			           }
			           else{
			               show_popup("Unable to set anchor location using phone GPS, attempting to use boat location");
			           }
		           }
		           break;
			  }
	  }
  }
}
示例#2
0
文件: popup.c 项目: sina-ht/ebview
static gint popup_button_press_event(GtkWidget *widget, GdkEventButton *event)
{
	RESULT *rp;
	GtkTextIter iter;
	guint offset;
	gint buffer_x, buffer_y;

	LOG(LOG_DEBUG, "IN : popup_button_press_event()");

	if(event->type == GDK_BUTTON_PRESS){
		if (event->button == 1){
			gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget),
							      GTK_TEXT_WINDOW_TEXT,
							      (gint)(event->x),
							      (gint)(event->y),
							      &buffer_x,
							      &buffer_y);
			gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget),
							   &iter,
							   buffer_x,
							   buffer_y);

			offset = gtk_text_iter_get_offset(&iter);
	
			if(follow_link(offset) == TRUE){
				LOG(LOG_DEBUG, "OUT : popup_button_press_event() = TRUE");
				return(TRUE);
			} else {
				if(bpushpin_down == FALSE){
					gtk_widget_destroy(popup);
					popup = NULL;
				}
			}
		} else if ((event->button == 2) || (event->button == 3)){
			if(!current_in_result)
				return(TRUE);

			if (event->button == 2) {
				if(g_list_previous(current_in_result) == NULL){
					return(TRUE);
				}
				current_in_result = g_list_previous(current_in_result);
			} else {
				if(g_list_next(current_in_result) == NULL){
					return(TRUE);
				}
				current_in_result = g_list_next(current_in_result);
			}
			if(current_in_result == NULL)
				return(TRUE);
			rp = (RESULT *)(current_in_result->data);
			if(current_in_result){
				show_popup(rp);
			}
		}
	}

	LOG(LOG_DEBUG, "OUT : popup_button_press_event()");
	return(TRUE);
}
示例#3
0
static gboolean button_pressed(GtkWidget *widget,
				GdkEventButton *event, gpointer user_data)
{
	GtkTreeSelection *selection;
	GtkTreePath *path;

	if (event->type != GDK_BUTTON_PRESS)
		return FALSE;

	if (event->button != 3)
		return FALSE;

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));

	if (gtk_tree_selection_count_selected_rows(selection) != 1)
		return FALSE;

	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
					(gint) event->x, (gint) event->y,
					&path, NULL, NULL, NULL) == FALSE)
		return FALSE;

	gtk_tree_selection_unselect_all(selection);
	gtk_tree_selection_select_path(selection, path);

	gtk_tree_path_free(path);

	show_popup(widget, event, selection);

	return TRUE;
}
示例#4
0
INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM, LPARAM)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		Number = 3;
		show_popup(hDlg, Title, Text, Number, 0);
		return TRUE;
	}
	return FALSE;
}
示例#5
0
INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM, LPARAM)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		Number = 0;
		show_popup(hDlg, Title, Text, Number, 1);
		return TRUE;
	}
	ShowWindow(hDlg, SW_HIDE);
	return FALSE;
}
示例#6
0
static gboolean
treeview_clicked_cb(cam* cam, GdkEventButton* ev, GtkTreeView* treeview) {
	gboolean retval = GTK_WIDGET_GET_CLASS(treeview)->button_press_event(GTK_WIDGET(treeview), ev);

	if(ev->button == 3) {
		show_popup(cam, treeview, NULL);
		retval = TRUE;
	}

	return retval;
}
示例#7
0
文件: menu.c 项目: svn2github/iup-iup
int button(Ihandle *ih,int but,int pressed,int x,int y,char* status)
{
  (void)x;
  (void)y;
  (void)status;
  (void)ih;

  if (but==IUP_BUTTON3 && pressed)
    show_popup();

  return IUP_DEFAULT;
}
示例#8
0
static gboolean popup_callback(GtkWidget *widget, gpointer user_data)
{
	GtkTreeSelection *selection;

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));

	if (gtk_tree_selection_count_selected_rows(selection) != 1)
		return FALSE;

	show_popup(widget, NULL, selection);

	return TRUE;
}
示例#9
0
void DlgDownloadProc()
{
	CallFunctionAsync(CreateDownloadDialog, 0);
	if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath)) {
		Title = TranslateT("Pack Updater");
		Text = TranslateT("An error occurred while downloading the update.");
		if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) {
			Number = 1;
			show_popup(0, Title, Text, Number, 0);
		}
		else if (db_get_b(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED))
			MessageBox(NULL, Text, Title, MB_ICONSTOP);
	}
	CallFunctionAsync(DestroyDownloadDialog, 0);
}
void
line_edit_autocomplete::redisplay_popup(const QList<QString>& completions)
{
  if (!completions.empty()) {
    popup->clear();
    QList<QString>::const_iterator iter;
    for (iter = completions.begin(); iter != completions.end(); iter++) {
      popup->addItem(*iter);
    }
    show_popup();
  }
  else {
    popup->clear();
    popup->hide();
  }
}
示例#11
0
void DoCheck(int iFlag)
{
	if (hCheckThread != NULL) {
		Title = TranslateT("Pack Updater");
		Text = TranslateT("Update checking already started!");
		if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
			Number = 2;
			show_popup(0, Title, Text, Number, 0);
		}
		else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
			MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
	}
	else if (iFlag) {
		hCheckThread = mir_forkthread(CheckUpdates, 0);
		db_set_dw(NULL, MODNAME, "LastUpdate", time(NULL));
	}
}
示例#12
0
static void
key_handler(struct window *window,
            struct input *input, uint32_t time,
            uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
            void *data)
{
	struct stacking *stacking = data;

	if (state != WL_KEYBOARD_KEY_STATE_PRESSED)
		return;

	switch (sym) {
	case XKB_KEY_f:
		fullscreen_handler(window, data);
		break;

	case XKB_KEY_m:
		window_set_maximized(window, !window_is_maximized(window));
		break;

	case XKB_KEY_n:
		/* New top-level window. */
		new_window(stacking, NULL);
		break;

	case XKB_KEY_p:
		show_popup(stacking, input, time, window);
		break;

	case XKB_KEY_q:
		exit (0);
		break;

	case XKB_KEY_t:
		/* New transient window. */
		new_window(stacking, window);
		break;

	default:
		break;
	}
}
示例#13
0
static void
button_handler(struct widget *widget,
               struct input *input, uint32_t time,
               uint32_t button,
               enum wl_pointer_button_state state, void *data)
{
	struct stacking *stacking = data;

	switch (button) {
	case BTN_RIGHT:
		if (state == WL_POINTER_BUTTON_STATE_PRESSED)
			show_popup(stacking, input, time,
			           widget_get_user_data(widget));
		break;

	case BTN_LEFT:
	default:
		break;
	}
}
示例#14
0
MainWindow::MainWindow(){
	gameLayout = new QGridLayout;
	mapper = new QSignalMapper(this);
	//add all nine buttons
	int it = 1;
	buttons.push_back(NULL);
	for(int i=1; i<4; i++){
		for(int j=0; j<3; j++){
			QPushButton* b = new QPushButton(" ");
			buttons.push_back(b);
			gameLayout->addWidget(buttons[it], i-1, j, 1, 1);
			connect( buttons[it], SIGNAL( clicked() ), mapper, SLOT( map() ) );
			mapper->setMapping( buttons[it], it );
			it++;
		}
	}
	connect( mapper, SIGNAL( mapped(int) ), this, SLOT(buttonPushed(int) ) );
	setLayout(gameLayout);
	show_popup() ;
	game = new Game();
	if(first) buttons[game->move()]->setText("O");
}
示例#15
0
void
edit_address_widget::show_completions()
{
  QString prefix; // substring on which the completion is to be based

  int pos = cursorPosition();
  int start = completer->get_prefix_pos(text(), pos);
  if (start>=0) {
    prefix=text().mid(start, pos-start);
  }

  if (prefix.isEmpty()) {
    // nothing to complete
    if (popup->isVisible()) {
      popup->clear();
      popup->hide();
    }
  }
  else {
    mail_address_list completions;
    if (completions.fetch_completions(prefix)) {
      if (!completions.empty()) {
	popup->clear();
	mail_address_list::const_iterator iter;
	for (iter = completions.begin(); iter != completions.end(); iter++) {
	  popup->addItem(QString("%1 <%2>").arg(iter->name()).arg(iter->email()));
	}
	show_popup();
      }
      else {
	popup->clear();
	popup->hide();
      }
    }
  }
}
示例#16
0
INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);

	switch (message) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hDlg);
		SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
		SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
		{
			LVCOLUMN lvc = { 0 };
			// Initialize the LVCOLUMN structure.
			// The mask specifies that the format, width, text, and
			// subitem members of the structure are valid.
			lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvc.fmt = LVCFMT_LEFT;

			lvc.iSubItem = 0;
			lvc.pszText = TranslateT("Component Name");
			lvc.cx = 145; // width of column in pixels
			ListView_InsertColumn(hwndList, 0, &lvc);

			lvc.iSubItem = 1;
			lvc.pszText = TranslateT("Current Version");
			lvc.cx = 95; // width of column in pixels
			ListView_InsertColumn(hwndList, 1, &lvc);

			lvc.iSubItem = 2;
			lvc.pszText = TranslateT("New Version");
			lvc.cx = 82; // width of column in pixels
			ListView_InsertColumn(hwndList, 2, &lvc);

			//enumerate plugins, fill in list
			//bool one_enabled = false;
			ListView_DeleteAllItems(hwndList);

			LVITEM lvI = { 0 };

			// Some code to create the list-view control.
			// Initialize LVITEM members that are common to all
			// items.
			lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_NORECOMPUTE;// | LVIF_IMAGE;

			vector<FILEINFO> &todo = *(vector<FILEINFO> *)lParam;
			for (int i = 0; i < (int)todo.size(); ++i) {
				lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_IMAGE;
				lvI.iSubItem = 0;
				lvI.lParam = (LPARAM)&todo[i];
				lvI.pszText = todo[i].tszDescr;
				lvI.iItem = i;
				ListView_InsertItem(hwndList, &lvI);

				lvI.mask = LVIF_TEXT;// | LVIF_IMAGE;

				lvI.iSubItem = 1;
				lvI.pszText = todo[i].tszCurVer;
				ListView_SetItem(hwndList, &lvI);

				lvI.iSubItem = 2;
				lvI.pszText = todo[i].tszNewVer;
				ListView_SetItem(hwndList, &lvI);

				ListView_SetCheckState(hwndList, lvI.iItem, true);
				todo[i].enabled = true;
			}
			HWND hwOk = GetDlgItem(hDlg, IDOK);
			EnableWindow(hwOk, true/*one_enabled ? TRUE : FALSE*/);
			// do this after filling list - enables 'ITEMCHANGED' below
			SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
			Utils_RestoreWindowPositionNoSize(hDlg, 0, MODNAME, "ConfirmWindow");
		}
		return TRUE;

	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->hwndFrom == hwndList) {
			switch (((LPNMHDR)lParam)->code) {
			case LVN_ITEMCHANGED:
				if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
					NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;

					LVITEM lvI = { 0 };

					lvI.iItem = nmlv->iItem;
					lvI.iSubItem = 0;
					lvI.mask = LVIF_PARAM;
					ListView_GetItem(hwndList, &lvI);

					vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
					if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
						todo[lvI.iItem].enabled = ListView_GetCheckState(hwndList, nmlv->iItem);

						bool enableOk = false;
						for (int i = 0; i < (int)todo.size(); ++i) {
							if (todo[i].enabled) {
								enableOk = true;
								break;
							}
						}
						HWND hwOk = GetDlgItem(hDlg, IDOK);
						EnableWindow(hwOk, enableOk ? TRUE : FALSE);
					}
					if (nmlv->uNewState & LVIS_SELECTED) {
						if (mir_tstrcmp(todo[lvI.iItem].tszInfoURL, _T("")))
							EnableWindow(GetDlgItem(hDlg, IDC_INFO), TRUE);
						else
							EnableWindow(GetDlgItem(hDlg, IDC_INFO), FALSE);
						SetDlgItemText(hDlg, IDC_MESSAGE, TranslateTS(todo[lvI.iItem].tszMessage));
					}
				}
				break;
			}
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			switch (LOWORD(wParam)) {
			case IDOK:
			{
				vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
				ShowWindow(hDlg, SW_HIDE);
				TCHAR tszBuff[2048] = { 0 }, tszFileDest[MAX_PATH] = { 0 }, tszFilePathDest[MAX_PATH] = { 0 }, tszFilePathBack[MAX_PATH] = { 0 }, tszFileName[MAX_PATH] = { 0 };
				TCHAR* tszExt = NULL;
				char szKey[64] = { 0 };
				vector<int> arFileType;
				vector<tString> arFilePath;
				vector<tString> arFileName;
				vector<tString> arAdvFolder;
				vector<tString> arExt;
				STARTUPINFO si;
				PROCESS_INFORMATION pi;

				SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
				Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");

				arFileType.clear();
				arFilePath.clear();
				arFileName.clear();
				arAdvFolder.clear();
				arExt.clear();
				for (int i = 0; i < (int)todo.size(); ++i) {
					if (todo[i].enabled) {
						switch (todo[i].FileType) {
						case 1:
							mir_sntprintf(tszFileDest, _T("%s\\Pack"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 2:
							mir_sntprintf(tszFileDest, _T("%s\\Plugins"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 3:
							mir_sntprintf(tszFileDest, _T("%s\\Icons"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 4:
							mir_sntprintf(tszFileDest, _T("%s\\Others"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						case 5:
							mir_sntprintf(tszFileDest, _T("%s\\Others"), tszRoot);
							CreateDirectory(tszFileDest, NULL);
							break;
						default:
							mir_tstrncpy(tszFileDest, tszRoot, _countof(tszFileDest));
							break;
						}
						mir_sntprintf(tszBuff, _T("%s\\Backups"), tszRoot);
						CreateDirectory(tszBuff, NULL);
						mir_tstrncpy(tszFileName, todo[i].File.tszDiskPath, _countof(tszFileName));
						mir_sntprintf(todo[i].File.tszDiskPath, _T("%s\\%s"), tszFileDest, tszFileName);
						UpdatesCount++;

						tszExt = &todo[i].File.tszDownloadURL[mir_tstrlen(todo[i].File.tszDownloadURL) - 5];
						if (mir_tstrcmp(tszExt, _T(".html")) == 0) {
							char* szUrl = mir_t2a(todo[i].File.tszDownloadURL);
							Utils_OpenUrl(szUrl);
							mir_free(szUrl);
						}
						else {
							// download update
							pFileUrl = &todo[i].File;
							Title = TranslateT("Pack Updater");
							if (todo[i].FileType == 1)
								Text = TranslateT("Downloading pack updates...");
							else
								Text = TranslateT("Downloading update...");
							DlgDownloadProc();
							if (!DlgDld) {
								if (UpdatesCount)
									UpdatesCount--;
								continue;
							}
						}
						mir_tstrncpy(todo[i].tszCurVer, todo[i].tszNewVer, _countof(todo[i].tszCurVer));
						mir_snprintf(szKey, "File_%d_CurrentVersion", todo[i].FileNum);
						db_set_ts(NULL, MODNAME, szKey, todo[i].tszCurVer);
						arFileType.push_back(todo[i].FileType);
						arFilePath.push_back(todo[i].File.tszDiskPath);
						arFileName.push_back(tszFileName);
						arAdvFolder.push_back(todo[i].tszAdvFolder);
						arExt.push_back(tszExt);
						if (todo[i].FileType == 1)
							i = (int)todo.size();
					}
				}

				if (UpdatesCount > 1 && mir_tstrcmp(arExt[0].c_str(), _T(".html")) != 0)
					mir_tstrncpy(tszBuff, TranslateT("Downloads complete. Start updating? All your data will be saved and Miranda NG will be closed."), _countof(tszBuff));
				else if (UpdatesCount == 1 && mir_tstrcmp(arExt[0].c_str(), _T(".html")) != 0)
					mir_tstrncpy(tszBuff, TranslateT("Download complete. Start updating? All your data will be saved and Miranda NG will be closed."), _countof(tszBuff));
				if (UpdatesCount > 0 && mir_tstrcmp(arExt[0].c_str(), _T(".html")) != 0) {
					INT rc = -1;
					Title = TranslateT("Pack Updater");
					Text = tszBuff;
					if (ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(NULL, "Popup", "Actions", 0) & 1))
						rc = DialogBox(hInst, MAKEINTRESOURCE(IDD_POPUPDUMMI), NULL, DlgMsgPop);
					else
						rc = MessageBox(NULL, tszBuff, Title, MB_YESNO | MB_ICONQUESTION);
					if (rc == IDYES) {
						for (int i = 0; i < UpdatesCount; i++) {
							TCHAR* tszUtilRootPlug = NULL;
							TCHAR* tszUtilRootIco = NULL;
							TCHAR* tszUtilRoot = NULL;
							TCHAR  tszCurrentDir[MAX_PATH];

							switch (arFileType[i]) {
							case 0:
								break;
							case 1:
								if (Reminder == 2)
									db_set_b(NULL, MODNAME, "Reminder", 1);
								memset(&si, 0, sizeof(STARTUPINFO));
								memset(&pi, 0, sizeof(PROCESS_INFORMATION));
								si.cb = sizeof(STARTUPINFO);
								{
									_tcsncpy_s(tszCurrentDir, arFilePath[i].c_str(), _TRUNCATE);
									TCHAR *p = _tcsrchr(tszCurrentDir, '\\');
									if (p) *p = 0;
								}
								CreateProcess(arFilePath[i].c_str(), _T(""), NULL, NULL, FALSE, NULL, NULL, tszCurrentDir, &si, &pi);
								i = UpdatesCount;
								CallFunctionAsync(ExitMe, 0);
								break;
							case 2:
								tszUtilRootPlug = Utils_ReplaceVarsT(_T("%miranda_path%\\Plugins"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRootPlug, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRootPlug, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRootPlug);
								if (i == UpdatesCount - 1)
									CallFunctionAsync(RestartMe, 0);
								break;
							case 3:
								tszUtilRootIco = Utils_ReplaceVarsT(_T("%miranda_path%\\Icons"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRootIco, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRootIco, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRootIco);
								if (i == UpdatesCount - 1)
									CallFunctionAsync(RestartMe, 0);
								break;
							case 4:
								tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRoot);
								if (i == UpdatesCount - 1)
									CallFunctionAsync(RestartMe, 0);
								break;
							case 5:
								tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
								if (mir_tstrcmp(arAdvFolder[i].c_str(), _T("")) == 0)
									mir_sntprintf(tszFilePathDest, _T("%s\\%s"), tszUtilRoot, arFileName[i].c_str());
								else
									mir_sntprintf(tszFilePathDest, _T("%s\\%s\\%s"), tszUtilRoot, arAdvFolder[i].c_str(), arFileName[i].c_str());
								mir_sntprintf(tszFilePathBack, _T("%s\\Backups\\%s"), tszRoot, arFileName[i].c_str());
								MoveFile(tszFilePathDest, tszFilePathBack);
								MoveFile(arFilePath[i].c_str(), tszFilePathDest);
								mir_free(tszUtilRoot);
								break;
							}
						}
					}
					else { //reminder for not installed pack update
						if (Reminder && (UpdatesCount == 1) && (arFileType[0] == 1))
							db_set_b(NULL, MODNAME, "Reminder", 2);
						mir_sntprintf(tszBuff, TranslateT("You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s"), arFilePath[0].c_str());
						Title = TranslateT("Pack Updater");
						Text = tszBuff;
						if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
							Number = 2;
							show_popup(0, Title, Text, Number, 0);
						}
						else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
							MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
					}
				}
			}
			EndDialog(hDlg, IDOK);
			return TRUE;

			case IDCANCEL:
				SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
				Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ConfirmWindow");
				EndDialog(hDlg, IDCANCEL);
				return TRUE;

			case IDC_INFO:
				int sel = ListView_GetSelectionMark(hwndList);
				vector<FILEINFO> &todo = *(vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
				Utils_OpenUrlT(todo[sel].tszInfoURL);
			}
			break;
		}
	}
	return FALSE;
}
示例#17
0
文件: menu.c 项目: svn2github/iup-iup
int k_m(Ihandle *ih)
{
  (void)ih;
  show_popup();
  return IUP_DEFAULT;
}
示例#18
0
static void CheckUpdates(void *)
{
	TCHAR tszBuff[2048] = { 0 }, tszFileInfo[30] = { 0 }, tszTmpIni[MAX_PATH] = { 0 };
	char szKey[64] = { 0 };
	vector<FILEINFO> UpdateFiles;

	if (!Exists(tszRoot))
		CreateDirectory(tszRoot, NULL);
	Files.clear();
	Reminder = db_get_b(NULL, MODNAME, "Reminder", DEFAULT_REMINDER);
	FileCount = db_get_dw(NULL, MODNAME, "FileCount", DEFAULT_FILECOUNT);

	// Load files info
	ptrT tszDownloadURL(db_get_tsa(NULL, MODNAME, "File_VersionURL"));
	if (!tszDownloadURL) { // URL is not set
		Title = TranslateT("Pack Updater");
		Text = TranslateT("URL for checking updates not found.");
		if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) {
			Number = 1;
			show_popup(0, Title, Text, Number, 0);
		}
		else if (db_get_b(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED))
			MessageBox(NULL, Text, Title, MB_ICONSTOP);
		hCheckThread = NULL;
		return;
	}
	// Download version info
	pFileUrl = (FILEURL *)mir_alloc(sizeof(*pFileUrl));
	mir_tstrncpy(pFileUrl->tszDownloadURL, tszDownloadURL, _countof(pFileUrl->tszDownloadURL));
	mir_sntprintf(tszBuff, _countof(tszBuff), _T("%s\\tmp.ini"), tszRoot);
	mir_tstrncpy(pFileUrl->tszDiskPath, tszBuff, _countof(pFileUrl->tszDiskPath));
	mir_tstrncpy(tszTmpIni, tszBuff, _countof(tszTmpIni));
	Title = TranslateT("Pack Updater");
	Text = TranslateT("Downloading version info...");
	DlgDownloadProc();
	mir_free(pFileUrl);
	if (!DlgDld) {
		hCheckThread = NULL;
		return;
	}

	for (CurrentFile = 0; CurrentFile < FileCount; CurrentFile++) {
		FILEINFO FileInfo = { _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), _T(""), { _T(""), _T("") } };

		mir_snprintf(szKey, _countof(szKey), "File_%d_CurrentVersion", CurrentFile + 1);
		ptrT tszCurVer(db_get_tsa(NULL, MODNAME, szKey));
		if (tszCurVer)
			mir_tstrncpy(FileInfo.tszCurVer, tszCurVer, _countof(FileInfo.tszCurVer));
		else 
			mir_tstrncpy(FileInfo.tszCurVer, _T(""), _countof(FileInfo.tszCurVer));

		mir_snprintf(szKey, _countof(szKey), "File_%d_LastVersion", CurrentFile + 1);
		ptrT tszLastVer(db_get_tsa(NULL, MODNAME, szKey));
		if (tszLastVer)
			mir_tstrncpy(FileInfo.tszLastVer, tszLastVer, _countof(FileInfo.tszLastVer));
		else
			mir_tstrncpy(FileInfo.tszLastVer, _T(""), _countof(FileInfo.tszLastVer));

		Files.push_back(FileInfo);

		// Read version info
		mir_sntprintf(tszFileInfo, _countof(tszFileInfo), _T("FileInfo_%d"), CurrentFile + 1);
		GetPrivateProfileString(tszFileInfo, _T("FileVersion"), _T(""), Files[CurrentFile].tszNewVer, _countof(Files[CurrentFile].tszNewVer), tszTmpIni);
		GetPrivateProfileString(tszFileInfo, _T("Message"), _T(""), Files[CurrentFile].tszMessage, _countof(Files[CurrentFile].tszMessage), tszTmpIni);
		GetPrivateProfileString(tszFileInfo, _T("DownloadURL"), _T(""), Files[CurrentFile].File.tszDownloadURL, _countof(Files[CurrentFile].File.tszDownloadURL), tszTmpIni);
		GetPrivateProfileString(tszFileInfo, _T("AdvFolder"), _T(""), Files[CurrentFile].tszAdvFolder, _countof(Files[CurrentFile].tszAdvFolder), tszTmpIni);
		GetPrivateProfileString(tszFileInfo, _T("Descr"), _T(""), Files[CurrentFile].tszDescr, _countof(Files[CurrentFile].tszDescr), tszTmpIni);
		GetPrivateProfileString(tszFileInfo, _T("DiskFileName"), _T(""), tszBuff, MAX_PATH, tszTmpIni);

		if (_tcsstr(tszBuff, _T("\\"))) { //check update name
			Title = TranslateT("Pack Updater");
			Text = TranslateT("Name of Update's file is not supported.");
			if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) {
				Number = 1;
				show_popup(0, Title, Text, Number, 0);
			}
			else if (db_get_b(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED))
				MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
			continue;
		} // end check update name
		mir_tstrncpy(Files[CurrentFile].File.tszDiskPath, tszBuff, _countof(Files[CurrentFile].File.tszDiskPath));
		GetPrivateProfileString(tszFileInfo, _T("InfoURL"), _T(""), Files[CurrentFile].tszInfoURL, _countof(Files[CurrentFile].tszInfoURL), tszTmpIni);
		Files[CurrentFile].FileType = GetPrivateProfileInt(tszFileInfo, _T("FileType"), 0, tszTmpIni);
		Files[CurrentFile].Force = GetPrivateProfileInt(tszFileInfo, _T("Force"), 0, tszTmpIni);
		Files[CurrentFile].FileNum = CurrentFile + 1;

		if (Files[CurrentFile].FileType == 2) {
			if (mir_tstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
				mir_sntprintf(tszBuff, _countof(tszBuff), _T("Plugins\\%s"), Files[CurrentFile].File.tszDiskPath);
			else
				mir_sntprintf(tszBuff, _countof(tszBuff), _T("Plugins\\%s\\%s"), Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
			TCHAR pluginFolderName[MAX_PATH];
			PathToAbsoluteT(tszBuff, pluginFolderName);
			if (!Files[CurrentFile].Force && (IsPluginDisabled(Files[CurrentFile].File.tszDiskPath) || !Exists(pluginFolderName))) //check if plugin disabled or not exists
				continue;
		}
		// Compare versions
		if (getVer(Files[CurrentFile].tszCurVer) < getVer(Files[CurrentFile].tszNewVer)) { // Yeah, we've got new version.
			VARST tszSysRoot(_T("%SystemRoot%"));
			VARST tszProgFiles(_T("%ProgramFiles%"));

			if (Files[CurrentFile].FileType != 1 && !IsUserAnAdmin() && (_tcsstr(tszRoot, tszSysRoot) || _tcsstr(tszRoot, tszProgFiles))) {
				MessageBox(NULL, TranslateT("Update is not possible!\nYou have no Administrator's rights.\nPlease run Miranda NG with Administrator's rights."), Title, MB_ICONINFORMATION);
				DeleteFile(tszTmpIni);
				hCheckThread = NULL;
				return;
			} // user have not admin's rights

			//добавить проверку на существование файла
			TCHAR tszFilePathDest[MAX_PATH] = { 0 };
			switch (Files[CurrentFile].FileType) {
			case 0:
			case 1:
				break;
			case 2: {
				VARST tszUtilRootPlug(_T("%miranda_path%\\Plugins"));
				if (mir_tstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
					mir_sntprintf(tszFilePathDest, _countof(tszFilePathDest), _T("%s\\%s"), tszUtilRootPlug, Files[CurrentFile].File.tszDiskPath);
				else
					mir_sntprintf(tszFilePathDest, _countof(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootPlug, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
				}
				break;
			case 3: {
				VARST tszUtilRootIco(_T("%miranda_path%\\Icons"));
				if (mir_tstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
					mir_sntprintf(tszFilePathDest, _countof(tszFilePathDest), _T("%s\\%s"), tszUtilRootIco, Files[CurrentFile].File.tszDiskPath);
				else
					mir_sntprintf(tszFilePathDest, _countof(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRootIco, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
				}
				break;
			case 4:
			case 5: {
				VARST tszUtilRoot = Utils_ReplaceVarsT(_T("%miranda_path%"));
				if (mir_tstrcmp(Files[CurrentFile].tszAdvFolder, _T("")) == 0)
					mir_sntprintf(tszFilePathDest, _countof(tszFilePathDest), _T("%s\\%s"), tszUtilRoot, Files[CurrentFile].File.tszDiskPath);
				else
					mir_sntprintf(tszFilePathDest, _countof(tszFilePathDest), _T("%s\\%s\\%s"), tszUtilRoot, Files[CurrentFile].tszAdvFolder, Files[CurrentFile].File.tszDiskPath);
				}
				break;
			}//end* switch (Files[CurrentFile].FileType)

			if (Files[CurrentFile].Force || Exists(tszFilePathDest))
				UpdateFiles.push_back(Files[CurrentFile]);
			// Save last version
			mir_tstrncpy(Files[CurrentFile].tszLastVer, Files[CurrentFile].tszNewVer, _countof(Files[CurrentFile].tszLastVer));
			mir_snprintf(szKey, _countof(szKey), "File_%d_LastVersion", CurrentFile + 1);
			db_set_ts(NULL, MODNAME, szKey, Files[CurrentFile].tszLastVer);
		} // end compare versions
	} //end checking all files in for ()

	// Show dialog
	INT upd_ret = 0;
	if (UpdateFiles.size() > 0)
		upd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles);
	DeleteFile(tszTmpIni);
	if (upd_ret == IDCANCEL) {
		hCheckThread = NULL;
		return;
	}

	if (!UpdatesCount && !Silent) {
		Title = TranslateT("Pack Updater");
		Text = TranslateT("No updates found.");
		if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
			Number = 2;
			show_popup(0, Title, Text, Number, 0);
		}
		else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
			MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
	}

	if (!FileCount) {
		Title = TranslateT("Pack Updater");
		Text = TranslateT("No files for update.");
		if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups2", DEFAULT_POPUP_ENABLED)) {
			Number = 2;
			show_popup(0, Title, Text, Number, 0);
		}
		else if (db_get_b(NULL, MODNAME, "Popups2M", DEFAULT_MESSAGE_ENABLED))
			MessageBox(NULL, Text, Title, MB_ICONINFORMATION);
	}
	hCheckThread = NULL;
}
示例#19
0
文件: popup.c 项目: sina-ht/ebview
void show_result_in_popup()
{
	current_in_result = search_result;
	show_popup(current_in_result->data);
}
示例#20
0
文件: popup.c 项目: sina-ht/ebview
static gint title_click_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	RESULT *rp;
	GdkModifierType mask;
	static GdkWindow *root_win = NULL;

	LOG(LOG_DEBUG, "IN : title_click_event()");


	if(event->type == GDK_BUTTON_PRESS){
		if ((event->button == 2) || (event->button == 3)){
			return(FALSE);
		}

		if((strcmp(data, "<") == 0) || 
		   (strcmp(data, ">") == 0)){

			if(strcmp(data, "<") == 0){
				if(g_list_previous(current_in_result) == NULL){
					return(FALSE);
				}
				current_in_result = g_list_previous(current_in_result);
			} else {
				if(g_list_next(current_in_result) == NULL){
					return(FALSE);
				}
				current_in_result = g_list_next(current_in_result);
			}

			if(current_in_result == NULL)
				return(0);
			rp = (RESULT *)(current_in_result->data);
			if(current_in_result){
				show_popup(rp);
			}

		} else if(strcmp(data, "X") == 0){
			gtk_widget_destroy(popup);
			popup = NULL;
		} else if(strcmp(data, "t") == 0){
			bbutton_down = TRUE;
			root_win = gdk_window_foreign_new (GDK_ROOT_WINDOW ());
			gdk_window_get_pointer (root_win, &prev_x, &prev_y, &mask);
			previous_x = event->x;
			previous_y = event->y;
		} else if(strcmp(data, "p") == 0){
			GdkPixbuf *pixbuf;
			bbutton_down = TRUE;

			if(bpushpin_down == FALSE){
				bpushpin_down = TRUE;

				pixbuf = create_pixbuf(IMAGE_PUSH_ON);
				gtk_image_set_from_pixbuf(GTK_IMAGE(image_pushpin), pixbuf);
				destroy_pixbuf(pixbuf);
			} else {
				bpushpin_down = FALSE;

				pixbuf = create_pixbuf(IMAGE_PUSH_OFF);
				gtk_image_set_from_pixbuf(GTK_IMAGE(image_pushpin), pixbuf);
				destroy_pixbuf(pixbuf);

				gtk_widget_destroy(popup);
				popup = NULL;

			}
		}

	} else if((event->button == 1) && (event->type == GDK_2BUTTON_PRESS)){
		// Double click
	}
	
	LOG(LOG_DEBUG, "OUT : title_click_event()");
	return(TRUE);
}
示例#21
0
void CQuotesProviderBase::WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol/* = ""*/)
{
	time_t nTime = ::time(NULL);

	if (false == rsSymbol.empty())
		db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL, rsSymbol.c_str());

	double dPrev = 0.0;
	bool bValidPrev = Quotes_DBReadDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dPrev);
	if (true == bValidPrev)
		Quotes_DBWriteDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PREV_VALUE, dPrev);

	Quotes_DBWriteDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dRate);
	db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FETCH_TIME, nTime);

	tstring sSymbol = rsSymbol;

	tostringstream oNick;
	oNick.imbue(GetSystemLocale());
	if (false == m_sContactListFormat.empty()) {
		tstring s = format_rate(this, hContact, m_sContactListFormat);
		oNick << s;
	}
	else {
		if (true == sSymbol.empty())
			sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL);

		oNick << std::setfill(_T(' ')) << std::setw(10) << std::left << sSymbol << std::setw(6) << std::right << dRate;
	}
	CTendency tendency;

	if (true == tendency.Parse(this, m_sTendencyFormat, hContact))
		do_set_contact_extra_icon(hContact, tendency);

	db_set_ts(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, oNick.str().c_str());

	tstring sStatusMsg = format_rate(this, hContact, m_sStatusMsgFormat);
	if (false == sStatusMsg.empty())
		db_set_ts(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME, sStatusMsg.c_str());
	else
		db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME);

	bool bUseContactSpecific = (db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0);

	CAdvProviderSettings global_settings(this);

	WORD dwMode = (bUseContactSpecific)
		? db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast<WORD>(lmDisabled))
		: global_settings.GetLogMode();
	if (dwMode&lmExternalFile) {
		bool bAdd = true;
		bool bOnlyIfChanged = (bUseContactSpecific)
			? (db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, 1) > 0)
			: global_settings.GetLogOnlyChangedFlag();
		if (true == bOnlyIfChanged) {
			bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev)));
		}
		if (true == bAdd) {
			tstring sLogFileName = (bUseContactSpecific)
				? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE, global_settings.GetLogFileName().c_str())
				: global_settings.GetLogFileName();

			if (true == sSymbol.empty()) {
				sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL);
			}

			sLogFileName = GenerateLogFileName(sLogFileName, sSymbol);

			tstring sFormat = global_settings.GetLogFormat();
			if (bUseContactSpecific) {
				CQuotesProviderVisitorDbSettings visitor;
				Accept(visitor);
				sFormat = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_LOG_FILE, visitor.m_pszDefLogFileFormat);
			}

			log_to_file(this, hContact, sLogFileName, sFormat);
		}
	}
	if (dwMode&lmInternalHistory) {
		bool bAdd = true;
		bool bOnlyIfChanged = (bUseContactSpecific)
			? (db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, 1) > 0)
			: global_settings.GetHistoryOnlyChangedFlag();

		if (true == bOnlyIfChanged) {
			bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev)));
		}
		if (true == bAdd) {
			tstring sFormat = (bUseContactSpecific)
				? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str())
				: global_settings.GetHistoryFormat();

			log_to_history(this, hContact, nTime, sFormat);
		}
	}

	if (dwMode&lmPopup) {
		bool bOnlyIfChanged = (bUseContactSpecific)
			? (1 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, 1) > 0)
			: global_settings.GetShowPopupIfValueChangedFlag();
		if ((false == bOnlyIfChanged)
			|| ((true == bOnlyIfChanged) && (true == bValidPrev) && (false == IsWithinAccuracy(dRate, dPrev)))) {
			tstring sFormat = (bUseContactSpecific)
				? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str())
				: global_settings.GetPopupFormat();

			CPopupSettings ps = *(global_settings.GetPopupSettingsPtr());
			ps.InitForContact(hContact);
			show_popup(this, hContact, tendency, sFormat, ps);
		}
	}

	SetContactStatus(hContact, ID_STATUS_ONLINE);
}
示例#22
0
INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	int i;
	WORD idCtrl;
	char str[20] = { 0 }, str2[20] = { 0 };

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hdlg);
		//Colors
		if (MyOptions.DefColors == byCOLOR_OWN) {
			CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED);
			CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
			CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
		}
		if (MyOptions.DefColors == byCOLOR_WINDOWS) {
			CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
			CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED);
			CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED);
		}
		if (MyOptions.DefColors == byCOLOR_POPUP) {
			CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_UNCHECKED);
			CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
			CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_UNCHECKED);
		}
		for (i = 0; i < POPUPS; i++) {
			SendDlgItemMessage(hdlg, (i + 42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
			SendDlgItemMessage(hdlg, (i + 41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText);
			EnableWindow(GetDlgItem(hdlg, (i + 42071)), (MyOptions.DefColors == byCOLOR_OWN));
			EnableWindow(GetDlgItem(hdlg, (i + 41071)), (MyOptions.DefColors == byCOLOR_OWN));
		}
		//Timeout
		SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0);
		SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
		SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, MyOptions.Timeout, TRUE);
		//Mouse actions
		for (i = 0; i < _countof(PopupActions); i++) {
			SendDlgItemMessage(hdlg, IDC_LC, CB_SETITEMDATA, SendDlgItemMessage(hdlg, IDC_LC, CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
			SendDlgItemMessage(hdlg, IDC_RC, CB_SETITEMDATA, SendDlgItemMessage(hdlg, IDC_RC, CB_ADDSTRING, 0, (LPARAM)TranslateTS(PopupActions[i].Text)), PopupActions[i].Action);
		}
		SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, MyOptions.LeftClickAction, 0);
		SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, MyOptions.RightClickAction, 0);
		//Popups nitified
		for (i = 0; i < POPUPS; i++) {
			mir_snprintf(str, "Popups%d", i);
			mir_snprintf(str2, "Popups%dM", i);
			CheckDlgButton(hdlg, (i + 40071), (db_get_b(NULL, MODNAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hdlg, (i + 1024), (db_get_b(NULL, MODNAME, str2, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
			if (IsDlgButtonChecked(hdlg, (i + 40071)))
				EnableWindow(GetDlgItem(hdlg, (i + 1024)), FALSE);
			else if (i > 0)
				EnableWindow(GetDlgItem(hdlg, (i + 1024)), TRUE);
		}
		if (!(db_get_dw(NULL, "Popup", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS))
			EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
		else
			EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);

		return TRUE;

	case WM_SHOWWINDOW:
		if (!(db_get_dw(NULL, "Popup", "Actions", 0) & 1) || !ServiceExists(MS_POPUP_REGISTERACTIONS))
			EnableWindow(GetDlgItem(hdlg, (40071)), FALSE);
		else
			EnableWindow(GetDlgItem(hdlg, (40071)), TRUE);
		return TRUE;

	case WM_COMMAND:
		idCtrl = LOWORD(wParam);
		if (HIWORD(wParam) == CPN_COLOURCHANGED) {
			if (idCtrl > 40070) {
				//It's a color picker change. idCtrl is the control id.
				COLORREF color = SendDlgItemMessage(hdlg, idCtrl, CPM_GETCOLOUR, 0, 0);
				int ctlID = idCtrl;
				if ((ctlID > 41070) && (ctlID < 42070)) //It's 41071 or above => Text color.
					PopupsList[ctlID - 41071].colorText = color;
				else if (ctlID > 42070)//Background color.
					PopupsList[ctlID - 42071].colorBack = color;
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
				return TRUE;
			}
		}
		if (HIWORD(wParam) == CBN_SELCHANGE) {
			if (idCtrl == IDC_LC)
				MyOptions.LeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
			else if (idCtrl == IDC_RC)
				MyOptions.RightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);

			SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			return TRUE;
		}

		switch (idCtrl) {
		case IDC_USEOWNCOLORS:
			if (HIWORD(wParam) == BN_CLICKED) {
				MyOptions.DefColors = byCOLOR_OWN;
				BOOL bEnableOthers = TRUE;
				for (i = 0; i < POPUPS; i++) {
					EnableWindow(GetDlgItem(hdlg, (i + 42071)), bEnableOthers); //Background
					EnableWindow(GetDlgItem(hdlg, (i + 41071)), bEnableOthers); //Text
				}
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			}
			break;
		case IDC_USEWINCOLORS:
			if (HIWORD(wParam) == BN_CLICKED) {
				//Use Windows colors
				MyOptions.DefColors = byCOLOR_WINDOWS;
				BOOL bEnableOthers = FALSE;
				for (i = 0; i < POPUPS; i++) {
					EnableWindow(GetDlgItem(hdlg, (i + 42071)), bEnableOthers); //Background
					EnableWindow(GetDlgItem(hdlg, (i + 41071)), bEnableOthers); //Text
				}
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			}
			break;

		case IDC_USEPOPUPCOLORS:
			if (HIWORD(wParam) == BN_CLICKED) {
				//Use Popup colors
				MyOptions.DefColors = byCOLOR_POPUP;
				BOOL bEnableOthers = FALSE;
				for (i = 0; i < POPUPS; i++) {
					EnableWindow(GetDlgItem(hdlg, (i + 42071)), bEnableOthers); //Background
					EnableWindow(GetDlgItem(hdlg, (i + 41071)), bEnableOthers); //Text
				}
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			}
			break;

		case IDC_PREVIEW:
			Title = TranslateT("Pack Updater");
			Text = TranslateT("Test");
			for (i = 0; i < POPUPS; i++) {
				if ((BST_UNCHECKED == IsDlgButtonChecked(hdlg, (i + 40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i + 40071)))))
					continue;
				show_popup(0, Title, Text, i, 0);
			}
			break;

		case IDC_TIMEOUT_VALUE:
		case IDC_MSG_BOXES:
		case IDC_ERRORS:
			if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_ERRORS))
				EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), TRUE);
			else
				EnableWindow(GetDlgItem(hdlg, IDC_ERRORS_MSG), FALSE);
			if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_INFO_MESSAGES:
			if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_INFO_MESSAGES))
				EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), TRUE);
			else
				EnableWindow(GetDlgItem(hdlg, IDC_INFO_MESSAGES_MSG), FALSE);
			if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_PROGR_DLG:
			if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_PROGR_DLG))
				EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), TRUE);
			else
				EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), FALSE);
			if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_MSG_BOXES_MSG:
		case IDC_ERRORS_MSG:
		case IDC_INFO_MESSAGES_MSG:
		case IDC_PROGR_DLG_MSG:
			if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;
		}
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case PSN_RESET:
			//Restore the options stored in memory.
			LoadOptions();
			InitPopupList();
			return TRUE;

		case PSN_APPLY:
			//Text color
			char szSetting[20] = { 0 };
			DWORD ctlColor = 0;
			for (i = 0; i <= POPUPS - 1; i++) {
				ctlColor = SendDlgItemMessage(hdlg, (i + 42071), CPM_GETCOLOUR, 0, 0);
				PopupsList[i].colorBack = ctlColor;
				mir_snprintf(szSetting, "Popups%iBg", i);
				db_set_dw(NULL, MODNAME, szSetting, ctlColor);
				ctlColor = SendDlgItemMessage(hdlg, (i + 41071), CPM_GETCOLOUR, 0, 0);
				PopupsList[i].colorText = ctlColor;
				mir_snprintf(szSetting, "Popups%iTx", i);
				db_set_dw(NULL, MODNAME, szSetting, ctlColor);
			}
			//Colors
			db_set_b(NULL, MODNAME, "DefColors", MyOptions.DefColors);
			//Timeout
			MyOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, 0, TRUE);
			db_set_dw(NULL, MODNAME, "Timeout", MyOptions.Timeout);
			//Left mouse click
			db_set_b(NULL, MODNAME, "LeftClickAction", MyOptions.LeftClickAction);
			//Right mouse click
			db_set_b(NULL, MODNAME, "RightClickAction", MyOptions.RightClickAction);
			//Notified popups
			for (i = 0; i < POPUPS; i++) {
				mir_snprintf(str, "Popups%d", i);
				db_set_b(NULL, MODNAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i + 40071))));
				mir_snprintf(str2, "Popups%dM", i);
				db_set_b(NULL, MODNAME, str2, (BYTE)(IsDlgButtonChecked(hdlg, (i + 1024))));
			}
			return TRUE;
		}
		break; //End WM_NOTIFY
	}
	return FALSE;
}
示例#23
0
static void
treeview_popup_menu_cb(cam* cam, GtkTreeView* treeview) {
	show_popup(cam, treeview, NULL);
}